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
Hal_dup2 #229740 12/24/2002 6:38 AM
Joined: Aug 2002
Posts: 1,191
Kahuna
Kahuna
Joined: Aug 2002
Posts: 1,191
Screenshots of what it does are attached to this message

Warm regards

Nikos
Attachments
62438-FilterPM 1.0 Screenshots.zip (0 Bytes, 21 downloads)


Nikos
Hal_dup2 #229741 12/24/2002 9:05 AM
Joined: May 1999
Posts: 1,715
Addict
Addict
Joined: May 1999
Posts: 1,715
Thanks for the mod! Seems to be a nice one, I think I'll try to install this and merge it with my limit mod (although it might not be needed now).


Hal_dup2 #229742 12/24/2002 12:43 PM
Joined: Nov 2001
Posts: 10,369
I type Like navaho
I type Like navaho
Joined: Nov 2001
Posts: 10,369
Nice one!

c0bra #229743 12/30/2002 9:27 AM
Joined: Aug 2002
Posts: 1,191
Kahuna
Kahuna
Joined: Aug 2002
Posts: 1,191
Gardener,

There are instructions on how to bind it with your Limit modification.

I found this to be extremely helpful - and my users love it - since we don't delete private messages in our forum. I for instance have roughly 900 messages in there and another user is reaching around 1500, so when searching it's a nice feature.

Warm regards

Nikos


Nikos
Sponsored Links
Hal_dup2 #229744 12/30/2002 11:09 PM
Joined: May 1999
Posts: 1,715
Addict
Addict
Joined: May 1999
Posts: 1,715
That sounds even better, I will install it for sure then. =] Same thing at our site, we don't delete anything...


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:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
isaac
isaac
California
Posts: 1,157
Joined: July 2001
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
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-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20240430)