Beta-[6.4] Paginate PMs - 06/21/2005 1:06 AM
Mod Name / Version: Paginate PMs
Description: This mod puts your PMs into pages (much like forum threads are), which is especially helpful to your users who keep a lot of their PMs lying around.
This code is a simple cut and paste from this functionality found within postlist.php, adapted for use with PMs.
Working Under: UBB.Threads 6.4
Mod Status: Beta
Any pre-requisites:
Author(s): bostongio
Date: 06/20/05
Credits: UBBthreads
Files Altered: viewmessages.php
templates/default/viewmessages.tmpl
New Files:
Database Altered: No
Info/Instructions: In viewmessages.php
Find:
Replace with:
-------------------------------------------------------------------
Find:
Replace with:
--------------------------------------------------------------------
Find:
Replace with:
===============================================================
In templates/default/viewmessages.tmpl
Find at the bottom of the file:
Replace with:
Disclaimer: Please backup every file that you intend to modify.
If the modification modifies the database, it's a good idea to backup your database before doing so.
Note: If you modify your UBB.Threads code, you may be giving up your right for "official" support from Infopop.If you need official support, you'll need to restore unmodified files.
Description: This mod puts your PMs into pages (much like forum threads are), which is especially helpful to your users who keep a lot of their PMs lying around.
This code is a simple cut and paste from this functionality found within postlist.php, adapted for use with PMs.
Working Under: UBB.Threads 6.4
Mod Status: Beta
Any pre-requisites:
Author(s): bostongio
Date: 06/20/05
Credits: UBBthreads
Files Altered: viewmessages.php
templates/default/viewmessages.tmpl
New Files:
Database Altered: No
Info/Instructions: In viewmessages.php
Find:
Code
<br />// ---------------------------------------------------------<br />// Ok, we found the profile, now lets put it all onto a page<br /> $html -> send_header("$ubbt_lang[$box]",$Cat,0,$user);<br />
Replace with:
Code
<br />// ---------------------------------------------------------<br />// Ok, we found the profile, now lets put it all onto a page<br /> $html -> send_header("$ubbt_lang[$box]",$Cat,0,$user);<br /><br /><br />// -----------------------------------------<br />// Find out how many posts to show per page<br /> if (!$PostsPer) {<br /> $PostsPer = $theme['postsperpage'];<br /> }<br /><br />// ---------------------------------------------------------------------<br />// Now we calculate which posts to grab for this page. We want to grab<br />// one from the previous page and one from the next page so we know what<br />// the previous and nexts posts will be<br /> if (!($page > 0)) {<br /> $Totalgrab = $PostsPer + 1;<br /> $Posts = $PostsPer + 1;<br /> }<br /> else {<br /> $Startat = $page * $PostsPer;<br /> $Posts = $PostsPer + 1;<br /> $Totalgrab = "$Startat, $Posts";<br /> }<br /><br /> $endpage = 1;<br /> $limit = "LIMIT $Totalgrab";<br /><br />
-------------------------------------------------------------------
Find:
Code
<br />// -------------------------<br />// Get any private messages.<br /> $username_q = addslashes($Username);<br /> $query = "<br /> SELECT t1.M_Status, t1.M_Subject, t1.M_Sender, t1.M_Sent, t1.M_Number, t2.U_Username<br /> FROM {$config['tbprefix']}Messages AS t1,<br /> {$config['tbprefix']}Users AS t2<br /> WHERE t1.M_Uid = '{$user['U_Number']}'<br /> AND t1.M_Status $extra 'X'<br /> AND t1.M_Sender = t2.U_Number<br /> ORDER BY t1.M_Sent DESC<br /> ";<br /> $sth = $dbh -> do_query($query);<br /><br /> $i = 0;<br />
Replace with:
Code
<br /><br />// -------------------------<br />// Get any private messages.<br /> $username_q = addslashes($Username);<br /> $query = "<br /> SELECT t1.M_Status, t1.M_Subject, t1.M_Sender, t1.M_Sent, t1.M_Number, t2.U_Username<br /> FROM {$config['tbprefix']}Messages AS t1,<br /> {$config['tbprefix']}Users AS t2<br /> WHERE t1.M_Uid = '{$user['U_Number']}'<br /> AND t1.M_Status $extra 'X'<br /> AND t1.M_Sender = t2.U_Number<br /> ORDER BY t1.M_Sent DESC<br /> $limit<br /> ";<br /> $sth = $dbh -> do_query($query);<br /><br /> $i = 0;<br /><br />// -------------------------------------------------------------------<br />// If $page is greater than 0 then we need a link to the previous page<br /> if ($page > 0) {<br /> $prev = $page - 1;<br /> $prevstart = "<a class=\"noun\" href=\"{$config['phpurl']}/viewmessages.php?Cat=$Cat&box=$box&page<br />=$prev&sb=$sb&o=$o\">";<br /> $prevoption = "previous.gif";<br /> $prevstop = "</a>";<br /> }<br /> else {<br /> $prevoption = "greyprevious.gif";<br /> }<br /><br />// ----------------------------------------------------------------------<br />// If total parent posts is greater than $PostsPer*Page then we give them<br />// a link to the next page<br /> if ($nums >= ($PostsPer + 1) ) {<br /> $next = $page + 1;<br /> $nextstart = "<a class=\"noun\" href=\"{$config['phpurl']}/viewmessages.php?Cat=$Cat&box=$box&page<br />=$next&sb=$sb&o=$o\">";<br /> $nextstop = "</a>";<br /> $nextoption = "next.gif";<br /> }<br /> else {<br /> $nextoption = "greynext.gif";<br /> }<br /><br />
--------------------------------------------------------------------
Find:
Code
<br /> $messagesize = "0";<br /> if (isset($message)) {<br /> $messagesize = sizeof($message);<br /> }<br />
Replace with:
Code
<br /> $messagesize = "0";<br /> if (isset($message)) {<br /> $messagesize = sizeof($message);<br /> }<br /><br /> $query = "<br /> SELECT COUNT(*)<br /> FROM {$config['tbprefix']}Messages AS t1,<br /> {$config['tbprefix']}Users AS t2<br /> WHERE t1.M_Uid = '{$user['U_Number']}'<br /> AND t1.M_Status $extra 'X'<br /> AND t1.M_Sender = t2.U_Number<br /> ";<br /> $sth = $dbh -> do_query($query);<br /> list($totaltopics) = $dbh -> fetch_array($sth);<br /> $dbh -> finish_sth($sth);<br /><br /> $Threads = $totaltopics;<br /> $TotalP = ceil($Threads/$PostsPer);<br /> if ($TotalP > 0) { $pagejumpers = "Page "; }<br /><br /> $Startpage = $page - 5;<br /> $Endpage = $page + 5;<br /><br /> if ($Startpage < 0) {<br /> $Endpage = $Endpage - $Startpage;<br /> $Startpage = 0;<br /> }<br /> if ($Endpage > $TotalP) {<br /> $Endpage = $TotalP;<br /> $Startpage = $Endpage - 10;<br /> }<br /> if ($Startpage < 0) { $Startpage = 0; }<br /> if ($Startpage > 0) {<br /> $midprint = intval($Startpage / 2) - 1;<br /> $pagejumpers .= "<a href=\"{$config['phpurl']}/viewmessages.php?Cat=$Cat&page=0&box=$box&sb=$sb&am<br />p;o=$o\">1</a> ";<br />$pagejumpers .= "<a href=\"{$config['phpurl']}/viewmessages.php?Cat=$Cat&page=$midprint&box=$box&sb=<br />$sb&o=$o\">...</a> ";<br /> }<br /> if ($Threads > $PostsPer) {<br /> for ($i = $Startpage; $i <= $Endpage; $i++) {<br /> $printedpage = $i + 1;<br /> if ($i == $page) {<br /> $pagejumpers .= "<strong>[$printedpage]</strong> ";<br /> } else {<br /> if ($printedpage <= $Endpage) {<br />$pagejumpers .= "<a href=\"{$config['phpurl']}/viewmessages.php?Cat=$Cat&page=$i&view=$view&box=$box<br />&sb=$sb&o=$o\">$printedpage</a> ";<br /> }<br /> }<br /> }<br /> }<br /> else {<br /> $pagejumpers .= "1";<br /> }<br /> if ($Endpage < $TotalP) {<br /> $Totalprint = $TotalP - 1;<br /> $midprint = $TotalP - intval(($TotalP - $Endpage) / 2);<br /> $pagejumpers .= "<a href=\"{$config['phpurl']}/viewmessages.php?Cat=$Cat&page=$midprint&box=$box&a<br />mp;sb=$sb&o=$o\">...</a> ";<br /> $pagejumpers .= "<a href=\"{$config['phpurl']}/viewmessages.php?Cat=$Cat&page=$Totalprint&box=$box<br />&sb=$sb&o=$o\">$TotalP</a> ";<br /> }<br /> $pagejumpers .= "</font>";<br /><br />
===============================================================
In templates/default/viewmessages.tmpl
Find at the bottom of the file:
Code
<br /></td><br /></tr><br />$tbclose<br /><br /></form><br />UBBTPRINT;<br />/* UBBTREMARK */ ?><br />
Replace with:
Code
<br /></td><br /></tr><br /><br /><tr><br /><td colspan="8" class="tdheader" align="right"><br />$pagejumpers<br /></td></tr><br /><br />$tbclose<br /><br /></form><br />UBBTPRINT;<br />/* UBBTREMARK */ ?><br />
Disclaimer: Please backup every file that you intend to modify.
If the modification modifies the database, it's a good idea to backup your database before doing so.
Note: If you modify your UBB.Threads code, you may be giving up your right for "official" support from Infopop.If you need official support, you'll need to restore unmodified files.