Previous Thread
Next Thread
Print Thread
Rate Thread
#229739 12/24/2002 6:35 AM
Joined: Aug 2002
Posts: 1,191
Kahuna
Kahuna
Joined: Aug 2002
Posts: 1,191
Mod Name / Version Filter PM's 1.0
Description Allows your users to filter their private messages by sender/receiver and or date
Working under UBB.threads 6.1
Any pre-requisites None
Author(s) dimopoulos
Credits ubbdev.com who taught me how to do things in php and ubb threads
Demo None.
Files Altered viewmessages.php, templates/default/viewmessages.tmpl
Database Altered No
New Files None
Any other info Please report any problems you might have and I'll try to fix them as soon as possible.

Step 1
Open viewmessages.php

Step 1.1
Find this:
code:

// Grab the proper private messages
$field1 = $ubbt_lang['TEXT_FROM'];
$field2 = $ubbt_lang['TEXT_REC'];
if ($box == "received") {
$extra = "<>";
}
else {
$extra = "=";
$field1 = $ubbt_lang['SENT_TO'];
$field2 = $ubbt_lang['SENT'];
}


BELOW IT ADD
code:


$strWhere = "";

if (!empty($fltdate))
{
$strWhere .= " AND FROM_UNIXTIME( M_Sent, '%d/%b/%Y' ) = '$fltdate' ";
}

if (!empty($fltfrom))
{
$strWhere .= " AND M_Sender = '$fltfrom' ";
}



Step 1.2
Find this:
code:

$query = "
SELECT M_Status, M_Subject, M_Sender, M_Sent, M_Number
FROM {$config['tbprefix']}Messages
WHERE M_Username = '$username_q'
AND M_Status $extra 'X'
ORDER BY M_Sent DESC
";


CHANGE it to this
code:

$query = "
SELECT M_Status, M_Subject, M_Sender, M_Sent, M_Number
FROM {$config['tbprefix']}Messages
WHERE M_Username = '$username_q'
AND M_Status $extra 'X'
$strWhere
ORDER BY M_Sent DESC
";



Step 1.3
Find this:
code:

$messagesize = sizeof($message);


BELOW IT ADD
code:

$strQuery = "SELECT M_Sender
FROM {$config['tbprefix']}Messages
WHERE M_Username = '$username_q'
AND M_Status $extra 'X'
GROUP BY M_Sender
ORDER BY M_Sender
";
$strUserFilter = populate_combo( $dbh, $strQuery, "fltfrom", $fltfrom );
$strQuery = "SELECT FROM_UNIXTIME( M_Sent, '%d/%b/%Y' ) AS MDate
FROM {$config['tbprefix']}Messages
WHERE M_Username = '$username_q'
AND M_Status $extra 'X'
GROUP BY MDate
ORDER BY M_Sent DESC
";
$strDateFilter = populate_combo( $dbh, $strQuery, "fltdate", $fltdate );



Step 1.4
Find this:
code:

// ----------------
// send the footer
$html -> send_footer();


BELOW IT ADD
code:

function populate_combo( &$dbh, $strSQL, $strControlName, $strChoice="" )
{

// This will create the option box
$strOutput = "";
$strSelected = "";
$arrReturned = array();
$strCr = chr(13);

$strOutput .= "<select name="$strControlName" class="buttons">$strCr";
if ( empty($strChoice) )
{
$strOutput .= "<option value="" selected="selected">No Filter$strCr";
}
else
{
$strOutput .= "<option value="">No Filter$strCr";
}

// Database call
$sth = $dbh -> do_query($strSQL);
while ( $arrReturned = $dbh -> fetch_array($sth) )
{
// Check for the selected option
if ( $strChoice == $arrReturned[0] )
{
$strSelected = "selected="selected"";
}
else
{
$strSelected = "";
}
$strOutput .= "<option value="{$arrReturned[0]}" $strSelected>{$arrReturned[0]}$strCr";
}
$strOutput .= "</select>$strCr";

$dbh -> finish_sth($sth);

return $strOutput;
}




Step 2 OPTIONAL:
For those who have applied the PM Limit modification (to show the private messages in pages) you need to also do the following:

Step 2.3
Find this:
code:

$prevstart = "<a href="{$config['phpurl']}/viewmessages.php?Cat=$Cat&page=$prev&box=$box">";


CHANGE it to this
code:

$prevstart = "<a href="{$config['phpurl']}/viewmessages.php?Cat=$Cat&page=$prev&box=$box&fltfrom=$fltfrom&fltdate=$fltdate">";



Step 1.3
Find this:
code:

$nextstart = "<a href="{$config['phpurl']}/viewmessages.php?Cat=$Cat&page=$next&box=$box">";


CHANGE it to this
code:

$nextstart = "<a href="{$config['phpurl']}/viewmessages.php?Cat=$Cat&page=$next&box=$box&fltfrom=$fltfrom&fltdate=$fltdate">";




Step 3
Open viewmessages.tmpl

Step 3.1
Find this:
code:

<form name="checkboxform1" method="post" action="{$config['phpurl']}/delete.php">
<input type="hidden" name="Cat" value="$Cat" />
<input type="hidden" name="box" value="$box" />
<table width="{$theme['tablewidth']}" align="center" cellpadding="1" cellspacing="1" class="tablesurround">
<tr>
<td>
<table cellpadding="{$theme['cellpadding']}" cellspacing="{$theme['cellspacing']}" width="100%" class="tableborders">


ABOVE IT ADD
code:

<form name="filterform1" method="post" action="{$config['phpurl']}/viewmessages.php">
<input type="hidden" name="Cat" value="$Cat" />
<input type="hidden" name="box" value="$box" />
<table width="{$theme['tablewidth']}" align="center" cellpadding="1" cellspacing="1" class="tablesurround">
<tr>
<td>
<table cellpadding="{$theme['cellpadding']}" cellspacing="{$theme['cellspacing']}" width="100%" class="tableborders">
<td class="tdheader" align="right">
Filter messages:  
From:  {$strUserFilter}  
Date:  {$strDateFilter}    
<input type="submit" name="refreshpm" value="Refresh" class="buttons" />
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>



This modification is particularly handy to my users who don't delete their PM's - neither do I (no space problems here )
Enjoy!
Attachments
62437-FilterPM 1.0.zip (0 Bytes, 11 downloads)


Nikos
Sponsored Links
Entire Thread
Subject Posted By Posted
Filter PM's 1.0 dimopoulos 12/24/2002 1:35 PM
Re: Filter PM's 1.0 dimopoulos 12/24/2002 1:38 PM
Re: Filter PM's 1.0 Gardener 12/24/2002 4:05 PM
Re: Filter PM's 1.0 JoshPet 12/24/2002 7:43 PM
Re: Filter PM's 1.0 dimopoulos 12/30/2002 4:27 PM
Re: Filter PM's 1.0 Gardener 12/31/2002 6:09 AM

Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Shock Hosting
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
JAISP
JAISP
PA
Posts: 449
Joined: February 2008
Forum Statistics
Forums63
Topics37,583
Posts293,955
Members13,824
Most Online151,614
Nov 14th, 2025
Today's Statistics
Currently Online 1193
Topics Created 0
Posts Made 0
Users Online 0
Birthdays 20
Top Posters
AllenAyres 21,080
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,834
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2026 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.1.0
(Snapshot build 20260108)