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
Joined: Mar 2000
Posts: 21,079
Likes: 3
I type Like navaho
I type Like navaho
Joined: Mar 2000
Posts: 21,079
Likes: 3
danke


- Allen wavey
- What Drives You?
Joined: Jul 2002
Posts: 79
Power User
Power User
Offline
Joined: Jul 2002
Posts: 79
this will work with 6.5.1??? right??

Joined: Sep 2004
Posts: 8
Lurker
Lurker
Offline
Joined: Sep 2004
Posts: 8
I don't have copies of other version of the software, just my 6.4.x version. I'm not sure how much of significance changed between the two versions in viewmessages.php, as that's the key file.

Joined: Jul 2002
Posts: 79
Power User
Power User
Offline
Joined: Jul 2002
Posts: 79
getting this message in 6.5.1
Attachments
128406-Picture1.png (0 Bytes, 69 downloads)

Sponsored Links
Joined: May 2001
Posts: 550
Code Monkey
Code Monkey
Offline
Joined: May 2001
Posts: 550

Joined: Sep 2004
Posts: 8
Lurker
Lurker
Offline
Joined: Sep 2004
Posts: 8
Hmm, I couldn't find that but glad to see others were thinking the same thing. That one only went up to 6.3, so here's the answer for 6.4. 6.5 anyone?

Joined: May 2001
Posts: 550
Code Monkey
Code Monkey
Offline
Joined: May 2001
Posts: 550
2 issues:

1. In viewmessages.php you are using the variable $nums which is not defined.

2. In viewmessages.tmpl you are not useing the variables $prevoption and $nextoption


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
Gizmo
Gizmo
Portland, OR, USA
Posts: 5,833
Joined: January 2000
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 20221218)