Welcome, Guest. Please login or register.
Did you miss your activation email?
February 13, 2012, 03:39:18 AM

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
* Home Help Search Login Register
Pages: [1]   Go Down
Print
Author Topic: PM module  (Read 580 times)
crnogorac081
AddOn Development
*
Offline Offline

Posts: 1680



« 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 Offline

Posts: 1238


« 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 Offline

Posts: 1680



« 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 Smiley)

cheers
Logged

Wow, I coded something myself: PM Messanger Modul ,Searchbox with suggestions
crnogorac081
AddOn Development
*
Offline Offline

Posts: 1680



« 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 Smiley

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 Offline

Posts: 1680



« 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          Huh?  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 Offline

Posts: 1680



« Reply #5 on: August 26, 2009, 12:58:26 PM »

guys,

am I  blacklisted or something ?  grin
Logged

Wow, I coded something myself: PM Messanger Modul ,Searchbox with suggestions
Luckyluke

Offline Offline

Posts: 555



« Reply #6 on: August 26, 2009, 01:56:40 PM »

guys,

am I  blacklisted or something ?  grin

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  cool

BTW: You're doing a good job here in the WB forum. Keep up the good work.

Grtz,
Luc
Logged
crnogorac081
AddOn Development
*
Offline Offline

Posts: 1680



« Reply #7 on: August 26, 2009, 02:03:49 PM »

Lol, I am also GMT+1 Smiley I just hate that progress must stop because some stupid coding error Smiley)

Quote
BTW: You're doing a good job here in the WB forum. Keep up the good work.

Thanks Luc Smiley unless we help each others, the whole project lose a point Smiley)

So I ll do my best from my side Smiley

cheers
Logged

Wow, I coded something myself: PM Messanger Modul ,Searchbox with suggestions
Pages: [1]   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!