Previous Thread
Next Thread
Print Thread
Rate Thread
#285584 06/20/2005 6:06 PM
Joined: Sep 2004
Posts: 8
Lurker
Lurker
Offline
Joined: Sep 2004
Posts: 8
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:

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&amp;box=$box&amp;page<br />=$prev&amp;sb=$sb&amp;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&amp;box=$box&amp;page<br />=$next&amp;sb=$sb&amp;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&amp;page=0&amp;box=$box&amp;sb=$sb&am<br />p;o=$o\">1</a> ";<br />$pagejumpers .= "<a href=\"{$config['phpurl']}/viewmessages.php?Cat=$Cat&amp;page=$midprint&amp;box=$box&amp;sb=<br />$sb&amp;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&amp;page=$i&amp;view=$view&amp;box=$box<br />&amp;sb=$sb&amp;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&amp;page=$midprint&amp;box=$box&a<br />mp;sb=$sb&amp;o=$o\">...</a> ";<br />      $pagejumpers .= "<a href=\"{$config['phpurl']}/viewmessages.php?Cat=$Cat&amp;page=$Totalprint&amp;box=$box<br />&amp;sb=$sb&amp;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.

Sponsored Links
Entire Thread
Subject Posted By Posted
Beta-[6.4] Paginate PMs bostongio 06/21/2005 1:06 AM
Re: Beta-[6.4] Paginate PMs AllenAyres 06/21/2005 7:13 AM
Re: Beta-[6.4] Paginate PMs StanCA 06/21/2005 11:57 PM
Re: Beta-[6.4] Paginate PMs bostongio 06/22/2005 2:19 PM
Re: Beta-[6.4] Paginate PMs StanCA 06/22/2005 4:56 PM
Re: Beta-[6.4] Paginate PMs Anno 06/23/2005 3:03 PM
Re: Beta-[6.4] Paginate PMs bostongio 06/23/2005 11:34 PM
Re: Beta-[6.4] Paginate PMs Anno 06/24/2005 9:35 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
Nettomo
Nettomo
Germany, Bremen
Posts: 417
Joined: November 2001
Forum Statistics
Forums63
Topics37,583
Posts293,955
Members13,824
Most Online151,614
Nov 14th, 2025
Today's Statistics
Currently Online 410
Topics Created 0
Posts Made 0
Users Online 0
Birthdays 12
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)