Home
Download
Add-ons
Help
Forum
Organisation
Project
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email?
February 13, 2012, 03:39:18 AM
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Search:
Advanced search
Wollen Sie dem WebsiteBaker Team beitreten?
Nähere Informationen finden Sie unter
hier
und auf unserer
neuen Webseite
.
149700
Posts in
21103
Topics by
7538
Members
Latest Member:
ionline
WebsiteBaker Community Forum
English
Modules
(Moderator:
Argos
)
PM module
Pages: [
1
]
Go Down
Author
Topic: PM module (Read 580 times)
crnogorac081
AddOn Development
Offline
Posts: 1680
PM module
«
on:
August 25, 2009, 04:27:44 PM »
I am building a small pm module, so that users can send pm to each other..
I found some tutorial for this, but I am kind a stucked with php coding..
Could someone please help me with this code ? It doesnt show messages , only button to send a message and go home.. I can send a message, and it is visible in DB, but it is not displayed here..
Code:
// prevent this file from being accessed directly
if (!defined('WB_PATH')) die(header('Location: ../../index.php'));
// include config.php file and admin class
require_once('../../config.php');
// load module language file
$lang = (dirname(__FILE__)) . '/languages/' . LANGUAGE . '.php';
require_once(!file_exists($lang) ? (dirname(__FILE__)) . '/languages/EN.php' : $lang );
$userfinal=$_SESSION['USER_ID'];
// get the messages from the table.
$get_messages = mysql_query("SELECT message_id FROM ".TABLE_PREFIX."mod_pm_messages WHERE to_user='$userfinal' ORDER BY message_id DESC") or die(mysql_error());
$get_messages2 = mysql_query("SELECT * FROM ".TABLE_PREFIX."mod_pm_messages WHERE to_user='$userfinal' ORDER BY message_id DESC") or die(mysql_error());
$num_messages = mysql_num_rows($get_messages);
// display each message title, with a link to their content
echo '<ul>';
for($count = 1; $count <= $num_messages; $count++)
{
$row = mysql_fetch_array($get_messages2);
//if the message is not read, show "(new)" after the title, else, just show the title.
if($row['message_read'] == 0)
{
echo '<a href="'.WB_URL.'/modules/pmmessages/read_message.php?messageid=' . $row['message_id'] . '">' . $row['message_title'] . '</a>(New)<br>';
}else{
echo '<a href="'.WB_URL.'/modules/pmmessages/read_message.php?messageid=' . $row['message_id'] . '">' . $row['message_title'] . '</a><br>';
}}
echo '</ul>';
echo '<form name="newmsgfrm" method="post" action="'.WB_URL.'/modules/pmmessages/new_message.php">';
echo '<input type="submit" value="Send a New Message">';
echo '</form>';
echo '<form name="backfrm" method="post" action="'.WB_URL.'">';
echo '<input type="submit" value="Back to Home">';
echo '</form>';
cheers
Logged
Wow, I coded something myself: PM Messanger Modul ,Searchbox with suggestions
aldus
Offline
Posts: 1238
Re: PM module
«
Reply #1 on:
August 25, 2009, 04:42:24 PM »
Hello
Hm ... some irritation about the two querys for 'get_messages' and 'get_messages2',
as for the "for"-loop you are using the count of the first one and the result is/must 1 ... so imho
the loop never starts.
Code:
<?php
// ignore this line ...
/**
* prevent this file from being accessed directly
*/
if (!
defined
(
'WB_PATH'
)) die(
header
(
'Location: ../../index.php'
));
/**
* load module language file
*/
$lang
= (
dirname
(
__FILE__
)) .
'/languages/'
.
LANGUAGE
.
'.php'
;
require_once(!
file_exists
(
$lang
) ? (
dirname
(
__FILE__
)) .
'/languages/EN.php'
:
$lang
);
$userfinal
=
$_SESSION
[
'USER_ID'
];
/**
* get the messages from the table.
*/
$get_messages
=
$database
->
query
(
"SELECT message_id FROM "
.
TABLE_PREFIX
.
"mod_pm_messages WHERE to_user='
$userfinal
' ORDER BY message_id DESC"
);
$get_messages2
=
$database
->
query
(
"SELECT * FROM "
.
TABLE_PREFIX
.
"mod_pm_messages WHERE to_user='
$userfinal
' ORDER BY message_id DESC"
);
$num_messages
=
$get_messages
->
numRows
();
/**
* display each message title, with a link to their content
*/
echo
'<ul>'
;
while(
$row
=
$get_messages2
->
fetchRow
() ){
/**
* if the message is not read, show "(new)" after the title, else, just show the title.
*/
echo
'<li><a href="'
.
WB_URL
.
'/modules/pmmessages/read_message.php?messageid='
.
$row
[
'message_id'
] .
'">'
.
$row
[
'message_title'
] .
'</a>'
.((
$row
[
'message_read'
] ==
0
) ?
'(New)'
:
''
).
'<br></li>'
;
}
echo
'</ul>'
;
echo
'<form name="newmsgfrm" method="post" action="'
.
WB_URL
.
'/modules/pmmessages/new_message.php">'
;
echo
'<input type="submit" value="Send a New Message">'
;
echo
'</form>'
;
echo
'<form name="backfrm" method="post" action="'
.
WB_URL
.
'">'
;
echo
'<input type="submit" value="Back to Home">'
;
echo
'</form>'
;
Also - there are/were missing "<li>" tags inside the "<ul>" ...
Regards
Aldus
Logged
crnogorac081
AddOn Development
Offline
Posts: 1680
Re: PM module
«
Reply #2 on:
August 25, 2009, 08:20:51 PM »
Hi,
I have date format stored in DB: 1251217881 how to make it look like normal
)
cheers
Logged
Wow, I coded something myself: PM Messanger Modul ,Searchbox with suggestions
crnogorac081
AddOn Development
Offline
Posts: 1680
Re: PM module
«
Reply #3 on:
August 25, 2009, 11:22:33 PM »
Is there a tool module which has settings in the admin tools and also has a page in frontend to use it as example..
I want to make a PM module, so that you can send pm to other members. So its lame to put it as page module, on certan page.. So I would like to set setting in admin-tool menu in backend, and to send and read PM in frontend..
Also, could someone tell me how to make a normal date from this one: 1251217881 which is in DB ?
figured out
cheers
«
Last Edit: August 26, 2009, 03:33:01 AM by crnogorac081
»
Logged
Wow, I coded something myself: PM Messanger Modul ,Searchbox with suggestions
crnogorac081
AddOn Development
Offline
Posts: 1680
Re: PM module
«
Reply #4 on:
August 26, 2009, 11:29:53 AM »
Hi,
just a quick question, I have this code in backend
a href="'.WB_URL.'/modules/pmmessages/modify.php?doing=user_management ....
in the modify.php file in WB_URL.'/modules/pmmessages/
I also have in the same file case loop:
if(isset($_GET['doing'])) {
$case_doing = $_GET['doing'];
//use a switch case statement to determine what section to display
switch ($case_doing) {
case "user_management":
return PM_UserManagement();
break;
..................
and:
function PM_UserManagement() {
echo '<br/>Test code<br/>';
}
But when I click on first link from the post, I get error: Cannot access this file directly
? But I am in the same file.. Can anyone help ?
cheers
Logged
Wow, I coded something myself: PM Messanger Modul ,Searchbox with suggestions
crnogorac081
AddOn Development
Offline
Posts: 1680
Re: PM module
«
Reply #5 on:
August 26, 2009, 12:58:26 PM »
guys,
am I blacklisted or something ?
Logged
Wow, I coded something myself: PM Messanger Modul ,Searchbox with suggestions
Luckyluke
Offline
Posts: 555
Re: PM module
«
Reply #6 on:
August 26, 2009, 01:56:40 PM »
Quote from: crnogorac081 on August 26, 2009, 12:58:26 PM
guys,
am I blacklisted or something ?
Why do you think?
Many of us are living in Western Europe, so GMT +1. So many are
now
on our daily job. We all think of WB but also a bit of our daily job
BTW: You're doing a good job here in the WB forum. Keep up the good work.
Grtz,
Luc
Logged
crnogorac081
AddOn Development
Offline
Posts: 1680
Re: PM module
«
Reply #7 on:
August 26, 2009, 02:03:49 PM »
Lol, I am also GMT+1
I just hate that progress must stop because some stupid coding error
)
Quote
BTW: You're doing a good job here in the WB forum. Keep up the good work.
Thanks Luc
unless we help each others, the whole project lose a point
)
So I ll do my best from my side
cheers
Logged
Wow, I coded something myself: PM Messanger Modul ,Searchbox with suggestions
Pages: [
1
]
Go Up
Jump to:
Please select a destination:
-----------------------------
General
-----------------------------
=> General Announcements
-----------------------------
English
-----------------------------
=> Help & Support
-----------------------------
General
-----------------------------
=> WebsiteBaker Website Showcase
-----------------------------
English
-----------------------------
=> Modules
=> Templates, Menus & Design
=> WebsiteBaker Language Files
=> Droplets (PHP code for use with Droplet module) & Snippets (raw PHP code)
-----------------------------
General
-----------------------------
=> Guest Area & Off-Topic
-----------------------------
English
-----------------------------
=> WebsiteBaker 2.x discussion
=> WebsiteBaker 3
-----------------------------
General
-----------------------------
=> Security Announcements
-----------------------------
Deutsch (German)
-----------------------------
=> Hilfe/Support
-----------------------------
General
-----------------------------
=> Documentation
-----------------------------
Francais (French)
-----------------------------
=> Help/Support
-----------------------------
Italiano (Italian)
-----------------------------
=> Help/Support
-----------------------------
Deutsch (German)
-----------------------------
=> Ankündigungen
=> Diskussion über WB
=> Off-Topic
=> Archiv für Themen bis 2007
=> Module & Snippets
-----------------------------
English
-----------------------------
=> Archive (posts up to 2007)
-----------------------------
Nederlands (Dutch)
-----------------------------
=> Aankondigingen
=> Hulp & Ondersteuning
=> Niet-Terzake (Off Topic)
-----------------------------
Deutsch (German)
-----------------------------
=> jQuery
=> Tutorials
=> Templates & Design
-----------------------------
English
-----------------------------
=> jQuery
-----------------------------
Bakery (WB shop module)
-----------------------------
=> Bakery English
=> Bakery Deutsch
-----------------------------
English
-----------------------------
=> WebsiteBaker 2.9
===> Announcements
===> Help/Support
===> Suggestions
-----------------------------
Deutsch (German)
-----------------------------
=> WebsiteBaker 2.9
===> Ankündigungen
===> Hilfe/Support
===> Vorschläge
-----------------------------
English
-----------------------------
===> Software bugs
-----------------------------
Deutsch (German)
-----------------------------
===> Softwarefehler
=====> Module / Extensions
-----------------------------
English
-----------------------------
=====> Modules / Extensions
-----------------------------
Deutsch (German)
-----------------------------
===> Erfahrungs und Testberichte
-----------------------------
KeepInTouch (Multi Contact Module)
-----------------------------
=> KeepInTouch English
=> KeepInTouch Deutsch
Loading...