skip to main content

kiesler.at

Latest posts enhancement
updated by rck, 2005-07-10

For me, phpWebSites phpwsbb forum module has a lot of potential which is largely unused. One step in the right direction would be the display of

  • Who replied last and
  • how many replies have there been to a thread

in the phpwsbb last forum posts block. It would also be nice to have the latest post label (instead of the thread label) and the editor of the post (if there is one) instead of that of the owner. Well, I hacked phpwsbb again to do just that.

                     
1 | 2

phpwsbb/class/Runtime.php

This is where all the magic of the show latest threads block happens. Don Seiler used a simple sqlSelect call to fetch the latest non-hidden posts and gave the result to a new instance of PHPWSBB_Forum.

First, we generate a nice SQL statement that does a bit more than Don's simple sqlSelect:

104         function genLatestThreadsSQL($limit) {
105 
106                 $prefix=$GLOBALS['core']->tbl_prefix;
107 
108                 $sql = 'SELECT DISTINCT t.id, p.editor, p.owner, ';
109                 $sql.=          'p.label, count(q.tid)-1 pcount ';
110                 $sql.= "FROM ${prefix}mod_phpwsbb_threads t, ";
111                 $sql.=          "${prefix}mod_phpwsbb_messages p, ";
112                 $sql.=          "${prefix}mod_phpwsbb_messages q ";
113                 $sql.=  'WHERE p.id=t.lastpost_post_id AND ';
114                 $sql.=          'q.tid=t.id AND t.hidden="0" ';
115                 $sql.=  'GROUP BY q.tid ';
116                 $sql.=  'ORDER BY t.lastpost DESC ';
117                 $sql.=  "LIMIT $limit";
118 
119 
120                 return($sql);
121 
122         }

...it doesn't really matter where in Runtime.php you put this. Then, we'll enhance (or shall I write: completely redo) the original Latest Threads Block method by showing the information gained through the new SQL statement:

126     /**
127     * Displays block with next set of games in it
128     *
129     * @author   Don Seiler <don@NOSPAM.seiler.us>
130     */
131     function showLatestThreadsBlock() {
132 
133         // Get settings
134 
135         $settings               = $GLOBALS['core']->sqlSelect('mod_phpwsbb_settings');
136         $showblock              = $settings[0]['showlatestthreadsblock'];
137         $blocktitle             = $settings[0]['latestthreadsblocktitle'];
138         $limit                  = $settings[0]['maxlatestthreads'];
139         $allow_anon_view        = $settings[0]['allow_anon_view'];
140         $bboffline              = $settings[0]['bboffline'];
141 
142 
143         if ($bboffline && !$_SESSION['OBJ_user']->isDeity())
144                 return;
145 
146         if(!$showblock)
147                 return;
148         
149 
150         if(!$allow_anon_view && !$_SESSION['OBJ_user']->username)
151                 return;
152 
153         $block = NULL;
154 
155         // $sql = PHPWS_ genLatestThreadsSQL($limit);
156         $sql=PHPWSBB_Runtime::genLatestThreadsSQL($limit);
157 
158         $result = $GLOBALS['core']->getAllAssoc($sql);
159         $length=30;
160 
161         if($result)
162                 foreach($result as $nr => $row) {
163 
164                         $editor=$row['editor'];
165                         $owner=$row['owner'];
166                         $title=$row['label'];
167                         $posts=$row['pcount'];
168                         $id=$row['id'];
169 
170                         if(strlen($title)>$length)
171                                 $lbl=substr($title, 0, $length).'...';
172                         else
173                                 $lbl=$title;
174 
175                         if(isset($editor))
176                                 $poster=$editor;
177                         else
178                         if(isset($owner))
179                                 $poster=$owner;
180                         else
181                                 $poster=$_SESSION['translate']->it('Guest');
182 
183 
184                         $link=PHPWS_Text::moduleLink($lbl, 'phpwsbb',
185                                 array(  'PHPWSBB_MAN_OP'=>'view',
186                                         'PHPWS_MAN_ITEMS'=>$id),
187                                 null, null, null);
188 
189                         $block .=       "<p><strong>$poster</strong><br />".
190                                         "$link($posts)</p>";
191 
192                 }
193 
194         $GLOBALS['CNT_phpwsbb_latestthreadsblock']['title'] =
195                 $blocktitle;
196 
197         $GLOBALS['CNT_phpwsbb_latestthreadsblock']['content'] = $block;
198         
199     }// END FUNC showLatestThreadsBlock

Download

Runtime.diff(6452)
                     
1 | 2
phpwsbb/class/Runtime.php
Going further



RSSComments - Make a comment
The comments are owned by the poster. We are not responsible for its content.
RSSAll Articles
2008, 2007, 2006, 2005, 2004

What's Related

Article Manager

Hacks

Latest Updates

AdministrativeTexts
updated by freddiemac1993, 2013-06-14
wiki

Re: adventures
created by brittdavis10, 2012-02-23 (1 rply, 3 views)
thread

Re: how to run phpwebsite...
created by alexander, 2011-08-25 (2 rpls, 3607 views)
thread

Re: Forum tags
created by HaroldFaragher, 2011-08-22 (3 rpls, 8488 views)
thread


Zu den KO2100 Foren