Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 530 lines (427 sloc) 21.339 kb
4775e82 # more line-ending properties
ts77 authored
1 <?php
2
3 ////////////////////////////////////////////////////////////////////////////////
4 // //
253986c # Updated copyright notices to 2007
mmakaay authored
5 // Copyright (C) 2007 Phorum Development Team //
4775e82 # more line-ending properties
ts77 authored
6 // http://www.phorum.org //
7 // //
8 // This program is free software. You can redistribute it and/or modify //
9 // it under the terms of either the current Phorum License (viewable at //
10 // phorum.org) or the Phorum License that was distributed with this file //
11 // //
12 // This program is distributed in the hope that it will be useful, //
13 // but WITHOUT ANY WARRANTY, without even the implied warranty of //
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. //
15 // //
16 // You should have received a copy of the Phorum License //
17 // along with this program. //
18 ////////////////////////////////////////////////////////////////////////////////
19 define('phorum_page','list');
20
21 include_once("./common.php");
22 include_once("./include/format_functions.php");
29c09f9 # Disabled timing code in read/list (left behind from message cache deve...
mmakaay authored
23 //include_once('./include/timing.php');
77f7d59 # moved caching layers around and added apc-layer
ts77 authored
24
29c09f9 # Disabled timing code in read/list (left behind from message cache deve...
mmakaay authored
25 //timing_start();
4775e82 # more line-ending properties
ts77 authored
26
27 // set all our common URL's
28 phorum_build_common_urls();
29
30 if(!phorum_check_read_common()) {
31 return;
32 }
33
34
35 if(empty($PHORUM["forum_id"])){
36 $dest_url = phorum_get_url(PHORUM_INDEX_URL);
37 phorum_redirect_by_url($dest_url);
38 exit();
39 }
40
41 // somehow we got to a folder in list.php
42 if($PHORUM["folder_flag"]){
43 $dest_url = phorum_get_url(PHORUM_INDEX_URL, $PHORUM["forum_id"]);
44 phorum_redirect_by_url($dest_url);
45 exit();
46 }
47
3034b4d # Putting a versioning part in the cache key for newflag caching
mmakaay authored
48 $newflagkey = $PHORUM["forum_id"]."-".$PHORUM['user']['user_id'];
8aa3374 # message caching including forum-versions + hybrid read view (needs tho...
ts77 authored
49
4775e82 # more line-ending properties
ts77 authored
50 // check for markread
b080ff0 added newflag caching
ts77 authored
51 if (!empty($PHORUM["args"][1]) && $PHORUM["args"][1] == 'markread' && $PHORUM["DATA"]["LOGGEDIN"]){
4775e82 # more line-ending properties
ts77 authored
52 // setting all posts read
53 unset($PHORUM['user']['newinfo']);
54 phorum_db_newflag_allread();
b080ff0 added newflag caching
ts77 authored
55 if($PHORUM['cache_newflags']) {
8aa3374 # message caching including forum-versions + hybrid read view (needs tho...
ts77 authored
56 phorum_cache_remove('newflags',$newflagkey);
57 phorum_cache_remove('newflags_index',$newflagkey);
b080ff0 added newflag caching
ts77 authored
58 }
59
4775e82 # more line-ending properties
ts77 authored
60
61 // redirect to a fresh list without markread in url
62 $dest_url = phorum_get_url(PHORUM_LIST_URL);
63 phorum_redirect_by_url($dest_url);
64 exit();
65
66 }
67
68 if ($PHORUM["DATA"]["LOGGEDIN"]) { // reading newflags in
b080ff0 added newflag caching
ts77 authored
69
70 $PHORUM['user']['newinfo'] = null;
71
72 if($PHORUM['cache_newflags']) {
3034b4d # Putting a versioning part in the cache key for newflag caching
mmakaay authored
73 $PHORUM['user']['newinfo']=phorum_cache_get('newflags',$newflagkey,$PHORUM['cache_version']);
b080ff0 added newflag caching
ts77 authored
74 }
75
76 if($PHORUM['user']['newinfo'] == null) {
77 $PHORUM['user']['newinfo']=phorum_db_newflag_get_flags();
78 if($PHORUM['cache_newflags']) {
3034b4d # Putting a versioning part in the cache key for newflag caching
mmakaay authored
79 phorum_cache_put('newflags',$newflagkey,$PHORUM['user']['newinfo'],86400,$PHORUM['cache_version']);
b080ff0 added newflag caching
ts77 authored
80 }
81 }
4775e82 # more line-ending properties
ts77 authored
82 }
83
84 // figure out what page we are on
85 if (empty($PHORUM["args"]["page"]) || !is_numeric($PHORUM["args"]["page"]) || $PHORUM["args"]["page"] < 0){
86 $page=1;
87 } else {
f44efc9 # build_move_url was not set if user not a moderator
brian authored
88 $page=intval($PHORUM["args"]["page"]);
4775e82 # more line-ending properties
ts77 authored
89 }
90 $offset=$page-1;
91
92 // check the moderation-settings
93 $PHORUM["DATA"]["MODERATOR"] = phorum_user_access_allowed(PHORUM_USER_ALLOW_MODERATE_MESSAGES);
94
feca1e8 # Removed old announcement code from the list script
mmakaay authored
95 // Find out how many forums this user can moderate.
96 // If the user can moderate more than one forum, then
97 // present the move message moderation link.
98 if ($PHORUM["DATA"]["MODERATOR"]) {
99 $build_move_url=false;
eece5ae # Changed phorum_db_get_forums() to use NULL as the default $forum_id
mmakaay authored
100 $forums=phorum_db_get_forums(0, NULL, $PHORUM['vroot']);
f44efc9 # build_move_url was not set if user not a moderator
brian authored
101 $modforums=0;
feca1e8 # Removed old announcement code from the list script
mmakaay authored
102 foreach ($forums as $id=>$forum) {
103 if ($forum["folder_flag"]==0 && phorum_user_moderate_allowed($id)) {
f44efc9 # build_move_url was not set if user not a moderator
brian authored
104 $modforums++;
feca1e8 # Removed old announcement code from the list script
mmakaay authored
105 if ($modforums > 1) {
106 $build_move_url = true;
107 break;
108 }
4775e82 # more line-ending properties
ts77 authored
109 }
f44efc9 # build_move_url was not set if user not a moderator
brian authored
110 }
4775e82 # more line-ending properties
ts77 authored
111 }
112
113 if($PHORUM['threaded_list']) { // make it simpler :)
114 $PHORUM["list_length"] = $PHORUM['list_length_threaded'];
115 } else {
116 $PHORUM["list_length"] = $PHORUM['list_length_flat'];
117 }
118
75d241b # Fix for #165: paging for list.php incorrect when a forum has sticky me...
mmakaay authored
119 // Figure out paging for threaded and flat mode. Sticky messages
120 // are in the thread_count, but because these are handled as a separate
feca1e8 # Removed old announcement code from the list script
mmakaay authored
121 // list, they should not be included in the pages computation.
75d241b # Fix for #165: paging for list.php incorrect when a forum has sticky me...
mmakaay authored
122 $pages=ceil(($PHORUM["thread_count"] - $PHORUM['sticky_count']) / $PHORUM["list_length"]);
4775e82 # more line-ending properties
ts77 authored
123
feca1e8 # Removed old announcement code from the list script
mmakaay authored
124 // If we only have stickies, the number of pages will be zero.
125 // In that case, simply use one page.
fdc38f9 # Fix for #162
mmakaay authored
126 if ($pages == 0) $pages = 1;
127
e4f1e04 "MFB: # small fix for min_id on first visit"
ts77 authored
128 $pages_shown = (isset($PHORUM["TMP"]["list_pages_shown"])) ? $PHORUM["TMP"]["list_pages_shown"] : 11;
1427e2f # this commit gets flat list page done
brian authored
129
130 // first $pages_shown pages
33890e5 # Bugfix in paging: When we had 5 pages on screen and page 5 selected, t...
mmakaay authored
131 if($page - floor($pages_shown/2) <= 0 || $page < $pages_shown){
4775e82 # more line-ending properties
ts77 authored
132 $page_start=1;
1427e2f # this commit gets flat list page done
brian authored
133
134 // last $pages_shown pages
135 } elseif($page > $pages - floor($pages_shown/2)) {
136 $page_start = $pages - $pages_shown + 1;
137
138 // all others
4775e82 # more line-ending properties
ts77 authored
139 } else {
1427e2f # this commit gets flat list page done
brian authored
140 $page_start = $page - floor($pages_shown/2);
4775e82 # more line-ending properties
ts77 authored
141 }
142
143 $pageno=1;
1427e2f # this commit gets flat list page done
brian authored
144
145 for($x=0;$x<$pages_shown && $x<$pages;$x++){
4775e82 # more line-ending properties
ts77 authored
146 $pageno=$x+$page_start;
147 $PHORUM["DATA"]["PAGES"][] = array(
148 "pageno"=>$pageno,
149 "url"=>phorum_get_url(PHORUM_LIST_URL, $PHORUM["forum_id"], "page=$pageno")
150 );
151 }
152
93a7576 # Bugfix: pages to show=5 and pages=3 with page 3 selected -> pager had ...
mmakaay authored
153
4775e82 # more line-ending properties
ts77 authored
154 $PHORUM["DATA"]["CURRENTPAGE"]=$page;
155 $PHORUM["DATA"]["TOTALPAGES"]=$pages;
156
157 if($page_start>1){
158 $PHORUM["DATA"]["URL"]["FIRSTPAGE"]=phorum_get_url(PHORUM_LIST_URL, $PHORUM["forum_id"], "page=1");
159 }
160
161 if($pageno<$pages){
162 $PHORUM["DATA"]["URL"]["LASTPAGE"]=phorum_get_url(PHORUM_LIST_URL, $PHORUM["forum_id"], "page=$pages");
163 }
164
165 if($pages>$page){
166 $nextpage=$page+1;
167 $PHORUM["DATA"]["URL"]["NEXTPAGE"]=phorum_get_url(PHORUM_LIST_URL, $PHORUM["forum_id"], "page=$nextpage");
168 }
169 if($page>1){
170 $prevpage=$page-1;
171 $PHORUM["DATA"]["URL"]["PREVPAGE"]=phorum_get_url(PHORUM_LIST_URL, $PHORUM["forum_id"], "page=$prevpage");
172 }
173
174 $min_id=0;
175
4fc2c60 # $rows wasn't initialized in the caching code
mmakaay authored
176 $rows = NULL;
eb6eb71 # Pulled $PHORUM['TMP']['bodies_in_list']) from the db layer and turned ...
mmakaay authored
177 $bodies_in_list = isset($PHORUM['TMP']['bodies_in_list']) && $PHORUM['TMP']['bodies_in_list'];
77f7d59 # moved caching layers around and added apc-layer
ts77 authored
178 if($PHORUM['cache_messages'] && (!$PHORUM['DATA']['LOGGEDIN'] || $PHORUM['use_cookies'])) {
eb6eb71 # Pulled $PHORUM['TMP']['bodies_in_list']) from the db layer and turned ...
mmakaay authored
179 $cache_key=$PHORUM['forum_id']."-".$PHORUM['cache_version']."-".$page."-".$PHORUM['threaded_list']."-".$PHORUM['threaded_read']."-".$PHORUM["language"]."-".$PHORUM["count_views"]."-".($bodies_in_list?"1":"0");
77f7d59 # moved caching layers around and added apc-layer
ts77 authored
180 $rows = phorum_cache_get('message_list',$cache_key);
181 }
4775e82 # more line-ending properties
ts77 authored
182
77f7d59 # moved caching layers around and added apc-layer
ts77 authored
183 if($rows == null) {
4775e82 # more line-ending properties
ts77 authored
184
185
29c09f9 # Disabled timing code in read/list (left behind from message cache deve...
mmakaay authored
186 //timing_mark('before db');
77f7d59 # moved caching layers around and added apc-layer
ts77 authored
187 // Get the threads
188 $rows = array();
4775e82 # more line-ending properties
ts77 authored
189
77f7d59 # moved caching layers around and added apc-layer
ts77 authored
190 // get the thread set started
eb6eb71 # Pulled $PHORUM['TMP']['bodies_in_list']) from the db layer and turned ...
mmakaay authored
191 $rows = phorum_db_get_thread_list($offset, $bodies_in_list);
77f7d59 # moved caching layers around and added apc-layer
ts77 authored
192
29c09f9 # Disabled timing code in read/list (left behind from message cache deve...
mmakaay authored
193 //timing_mark('after db');
77f7d59 # moved caching layers around and added apc-layer
ts77 authored
194
195 // redirect if invalid page
196 if(count($rows) < 1 && $offset > 0){
197 $dest_url = phorum_get_url(PHORUM_LIST_URL);
198 phorum_redirect_by_url($dest_url);
199 exit();
200 }
201
202 if ($PHORUM["threaded_list"]){
203
204 // loop through and read all the data in.
205 foreach($rows as $key => $row){
206
207 if($PHORUM["count_views"]) { // show viewcount if enabled
208 if($PHORUM["count_views"] == 2) { // viewcount as column
209 $rows[$key]["viewcount"] = number_format($row['viewcount'], 0, $PHORUM["dec_sep"], $PHORUM["thous_sep"]);
210 } else { // viewcount added to the subject
211 $rows[$key]["subject"]=$row["subject"]." ({$row['viewcount']} " . $PHORUM['DATA']['LANG']['Views_Subject'] . ")";
fa1e9cf Fix for bug #188: new flags not shown for sticky and announce in threade...
mmakaay authored
212 }
c26cbfa setting up more data in list.php if the bodies are retrieved too, like m...
ts77 authored
213 }
77f7d59 # moved caching layers around and added apc-layer
ts77 authored
214
6d6b1fa # For each date field "XYZ" in the template data, I added a "raw_XYZ" fi...
mmakaay authored
215 $rows[$key]["raw_datestamp"] = $row["datestamp"];
77f7d59 # moved caching layers around and added apc-layer
ts77 authored
216 $rows[$key]["datestamp"] = phorum_date($PHORUM["short_date_time"], $row["datestamp"]);
6d6b1fa # For each date field "XYZ" in the template data, I added a "raw_XYZ" fi...
mmakaay authored
217 $rows[$key]["raw_lastpost"] = $row["modifystamp"];
77f7d59 # moved caching layers around and added apc-layer
ts77 authored
218 $rows[$key]["lastpost"] = phorum_date($PHORUM["short_date_time"], $row["modifystamp"]);
8aa3374 # message caching including forum-versions + hybrid read view (needs tho...
ts77 authored
219
77f7d59 # moved caching layers around and added apc-layer
ts77 authored
220 $rows[$key]["URL"]["READ"] = phorum_get_url(PHORUM_READ_URL, $row["thread"], $row["message_id"]);
221
222 if($row["message_id"] == $row["thread"]){
223 $rows[$key]["threadstart"] = true;
224 }else{
225 $rows[$key]["threadstart"] = false;
226 }
227
228 $rows[$key]["new"] = "";
229 // recognizing moved threads
230 if(isset($row['meta']['moved']) && $row['meta']['moved'] == 1) {
231 $rows[$key]['moved']=1;
4775e82 # more line-ending properties
ts77 authored
232 }
77f7d59 # moved caching layers around and added apc-layer
ts77 authored
233 }
234 // don't move this up. We want it to be conditional.
235 include_once("./include/thread_sort.php");
4775e82 # more line-ending properties
ts77 authored
236
77f7d59 # moved caching layers around and added apc-layer
ts77 authored
237 $rows = phorum_sort_threads($rows);
4775e82 # more line-ending properties
ts77 authored
238
77f7d59 # moved caching layers around and added apc-layer
ts77 authored
239 }else{
4775e82 # more line-ending properties
ts77 authored
240
77f7d59 # moved caching layers around and added apc-layer
ts77 authored
241 // loop through and read all the data in.
242 foreach($rows as $key => $row){
4775e82 # more line-ending properties
ts77 authored
243
6d6b1fa # For each date field "XYZ" in the template data, I added a "raw_XYZ" fi...
mmakaay authored
244 $rows[$key]["raw_lastpost"] = $row["modifystamp"];
77f7d59 # moved caching layers around and added apc-layer
ts77 authored
245 $rows[$key]["lastpost"] = phorum_date($PHORUM["short_date_time"], $row["modifystamp"]);
6d6b1fa # For each date field "XYZ" in the template data, I added a "raw_XYZ" fi...
mmakaay authored
246 $rows[$key]["raw_datestamp"] = $row["datestamp"];
77f7d59 # moved caching layers around and added apc-layer
ts77 authored
247 $rows[$key]["datestamp"] = phorum_date($PHORUM["short_date_time"], $row["datestamp"]);
248 $rows[$key]["URL"]["READ"] = phorum_get_url(PHORUM_READ_URL, $row["thread"]);
249 $rows[$key]["URL"]["NEWPOST"] = phorum_get_url(PHORUM_READ_URL, $row["thread"],"gotonewpost");
4775e82 # more line-ending properties
ts77 authored
250
77f7d59 # moved caching layers around and added apc-layer
ts77 authored
251 $rows[$key]["new"] = "";
4775e82 # more line-ending properties
ts77 authored
252
77f7d59 # moved caching layers around and added apc-layer
ts77 authored
253 if($PHORUM["count_views"]) { // show viewcount if enabled
254 if($PHORUM["count_views"] == 2) { // viewcount as column
255 $PHORUM["DATA"]["VIEWCOUNT_COLUMN"]=true;
256 $rows[$key]["viewcount"]=$row['viewcount'];
257 } else { // viewcount added to the subject
258 $rows[$key]["subject"]=$row["subject"]." ({$row['viewcount']} " . $PHORUM['DATA']['LANG']['Views_Subject'] . ")";
259 }
260 }
4775e82 # more line-ending properties
ts77 authored
261
77f7d59 # moved caching layers around and added apc-layer
ts77 authored
262 // recognizing moved threads
263 if(isset($row['meta']['moved']) && $row['meta']['moved'] == 1) {
264 $rows[$key]['moved']=1;
265 } else {
266 $rows[$key]['moved']=0;
267 }
4775e82 # more line-ending properties
ts77 authored
268
77f7d59 # moved caching layers around and added apc-layer
ts77 authored
269 // default thread-count
270 $thread_count=$row["thread_count"];
4775e82 # more line-ending properties
ts77 authored
271
77f7d59 # moved caching layers around and added apc-layer
ts77 authored
272 $rows[$key]["thread_count"] = number_format($row['thread_count'], 0, $PHORUM["dec_sep"], $PHORUM["thous_sep"]);
e4f1e04 "MFB: # small fix for min_id on first visit"
ts77 authored
273
77f7d59 # moved caching layers around and added apc-layer
ts77 authored
274 $pages=1;
4775e82 # more line-ending properties
ts77 authored
275
a765f65 # fixing moderator-pages with message-caching
ts77 authored
276 if(!$PHORUM["threaded_read"]) {
277
278 // pages for regular users
279 if($thread_count>$PHORUM["read_length"]){
280
281
282 $pages=ceil($thread_count/$PHORUM["read_length"]);
283
284 if($pages<=5){
285 $page_links=array();
286 for($x=1;$x<=$pages;$x++){
287 $url=phorum_get_url(PHORUM_READ_URL, $row["thread"], "page=$x");
288 $page_links[]="<a href=\"$url\">$x</a>";
289 }
290 $rows[$key]["pages"]=implode("&nbsp;", $page_links);
291 } else {
292 $url=phorum_get_url(PHORUM_READ_URL, $row["thread"], "page=1");
293 $rows[$key]["pages"]="<a href=\"$url\">1</a>&nbsp;";
294 $rows[$key]["pages"].="...&nbsp;";
295 $pageno=$pages-2;
296 $url=phorum_get_url(PHORUM_READ_URL, $row["thread"], "page=$pageno");
297 $rows[$key]["pages"].="<a href=\"$url\">$pageno</a>&nbsp;";
298 $pageno=$pages-1;
299 $url=phorum_get_url(PHORUM_READ_URL, $row["thread"], "page=$pageno");
300 $rows[$key]["pages"].="<a href=\"$url\">$pageno</a>&nbsp;";
301 $pageno=$pages;
302 $url=phorum_get_url(PHORUM_READ_URL, $row["thread"], "page=$pageno");
303 $rows[$key]["pages"].="<a href=\"$url\">$pageno</a>";
304 }
305
306 }
307
308 // pages for moderators
309 if(isset($row["meta"]["message_ids_moderator"])) {
310 $thread_count=count($row["meta"]["message_ids_moderator"]);
311
312 if($thread_count>$PHORUM["read_length"]){
313
314 $pages_mods=ceil($thread_count/$PHORUM["read_length"]);
315
316 $rows[$key]["pages_moderators_count"] = $pages_mods;
317
318 if($pages_mods<=5){
319 $page_links=array();
320 for($x=1;$x<=$pages_mods;$x++){
321 $url=phorum_get_url(PHORUM_READ_URL, $row["thread"], "page=$x");
322 $page_links[]="<a href=\"$url\">$x</a>";
323 }
324 $rows[$key]["pages_moderators"]=implode("&nbsp;", $page_links);
325 } else {
326 $url=phorum_get_url(PHORUM_READ_URL, $row["thread"], "page=1");
327 $rows[$key]["pages_moderators"]="<a href=\"$url\">1</a>&nbsp;";
328 $rows[$key]["pages_moderators"].="...&nbsp;";
329 $pageno=$pages_mods-2;
330 $url=phorum_get_url(PHORUM_READ_URL, $row["thread"], "page=$pageno");
331 $rows[$key]["pages_moderators"].="<a href=\"$url\">$pageno</a>&nbsp;";
332 $pageno=$pages_mods-1;
333 $url=phorum_get_url(PHORUM_READ_URL, $row["thread"], "page=$pageno");
334 $rows[$key]["pages_moderators"].="<a href=\"$url\">$pageno</a>&nbsp;";
335 $pageno=$pages_mods;
336 $url=phorum_get_url(PHORUM_READ_URL, $row["thread"], "page=$pageno");
337 $rows[$key]["pages_moderators"].="<a href=\"$url\">$pageno</a>";
338 }
77f7d59 # moved caching layers around and added apc-layer
ts77 authored
339 }
340 }
341 }
342
a765f65 # fixing moderator-pages with message-caching
ts77 authored
343
b39a376 # Start of an implementation for having display names. The previous comm...
mmakaay authored
344 if(isset($row['recent_message_id'])) { // should always be true
a765f65 # fixing moderator-pages with message-caching
ts77 authored
345 // building the recent message link
77f7d59 # moved caching layers around and added apc-layer
ts77 authored
346 if($pages>1){
b39a376 # Start of an implementation for having display names. The previous comm...
mmakaay authored
347 $rows[$key]["URL"]["LAST_POST"]=phorum_get_url(PHORUM_READ_URL, $row["thread"], $row['recent_message_id'], "page=$pages");
77f7d59 # moved caching layers around and added apc-layer
ts77 authored
348 } else {
b39a376 # Start of an implementation for having display names. The previous comm...
mmakaay authored
349 $rows[$key]["URL"]["LAST_POST"]=phorum_get_url(PHORUM_READ_URL, $row["thread"], $row['recent_message_id']);
77f7d59 # moved caching layers around and added apc-layer
ts77 authored
350 }
4775e82 # more line-ending properties
ts77 authored
351 }
a765f65 # fixing moderator-pages with message-caching
ts77 authored
352
353
4775e82 # more line-ending properties
ts77 authored
354 }
77f7d59 # moved caching layers around and added apc-layer
ts77 authored
355 }
1427e2f # this commit gets flat list page done
brian authored
356
77f7d59 # moved caching layers around and added apc-layer
ts77 authored
357
358 if($PHORUM['cache_messages'] && (!$PHORUM['DATA']['LOGGEDIN'] || $PHORUM['use_cookies'])) {
359 phorum_cache_put('message_list',$cache_key,$rows);
360 }
361 }
362
12b32b9 "# taking count-views in account for message-caching on list "
ts77 authored
363 if($PHORUM["count_views"] == 2) { // viewcount as column
364 $PHORUM["DATA"]["VIEWCOUNT_COLUMN"]=true;
365 }
29c09f9 # Disabled timing code in read/list (left behind from message cache deve...
mmakaay authored
366 //timing_mark('after preparation');
77f7d59 # moved caching layers around and added apc-layer
ts77 authored
367
8aa3374 # message caching including forum-versions + hybrid read view (needs tho...
ts77 authored
368 if($PHORUM['DATA']['LOGGEDIN']) {
77f7d59 # moved caching layers around and added apc-layer
ts77 authored
369 // the stuff needed by user
370 foreach($rows as $key => $row){
26596b4 # Stripping old announcement code
mmakaay authored
371 // Newflag for collapsed flat view or for sticky threads. For these,
372 // we only show the information for the thread starter. But we have
373 // to go through all the messages in the thread to see if any of
374 // them is new.
42fdcfb # fixing message caching issues with newflags
ts77 authored
375 if (!$row['moved'] && (!$PHORUM['threaded_list'] || $rows[$key]['sort'] == PHORUM_SORT_STICKY) && isset($row['meta']['message_ids']) && is_array($row['meta']['message_ids'])) {
77f7d59 # moved caching layers around and added apc-layer
ts77 authored
376 foreach ($row['meta']['message_ids'] as $cur_id) {
26596b4 # Stripping old announcement code
mmakaay authored
377 if(!isset($PHORUM['user']['newinfo'][$cur_id]) && $cur_id > $PHORUM['user']['newinfo']['min_id']) {
378 $rows[$key]["new"] = $PHORUM["DATA"]["LANG"]["newflag"];
379 }
42fdcfb # fixing message caching issues with newflags
ts77 authored
380 // for users without min_id
381 if($min_id == 0 || $min_id > $cur_id) $min_id = $cur_id;
77f7d59 # moved caching layers around and added apc-layer
ts77 authored
382 }
383 }
26596b4 # Stripping old announcement code
mmakaay authored
384 // For other views, we have a line for each message. So here
385 // we only have to look at the message itself to decide whether
386 // it's new or not.
77f7d59 # moved caching layers around and added apc-layer
ts77 authored
387 else {
42fdcfb # fixing message caching issues with newflags
ts77 authored
388 if (!$row['moved'] && !isset($PHORUM['user']['newinfo'][$row['message_id']]) && $row['message_id'] > $PHORUM['user']['newinfo']['min_id']) {
77f7d59 # moved caching layers around and added apc-layer
ts77 authored
389 $rows[$key]["new"]=$PHORUM["DATA"]["LANG"]["newflag"];
4775e82 # more line-ending properties
ts77 authored
390 }
42fdcfb # fixing message caching issues with newflags
ts77 authored
391
392 // for users without min_id
393 if($min_id == 0 || $min_id > $row['message_id']) $min_id = $row['message_id'];
77f7d59 # moved caching layers around and added apc-layer
ts77 authored
394 }
4775e82 # more line-ending properties
ts77 authored
395
77f7d59 # moved caching layers around and added apc-layer
ts77 authored
396 if($PHORUM["DATA"]["MODERATOR"]){
397 $rows[$key]["URL"]["DELETE_MESSAGE"] = phorum_get_url(PHORUM_MODERATION_URL, PHORUM_DELETE_MESSAGE, $row["message_id"]);
398 $rows[$key]["URL"]["DELETE_THREAD"] = phorum_get_url(PHORUM_MODERATION_URL, PHORUM_DELETE_TREE, $row["message_id"]);
399 if($build_move_url) {
400 $rows[$key]["URL"]["MOVE"] = phorum_get_url(PHORUM_MODERATION_URL, PHORUM_MOVE_THREAD, $row["message_id"]);
401 }
402 $rows[$key]["URL"]["MERGE"] = phorum_get_url(PHORUM_MODERATION_URL, PHORUM_MERGE_THREAD, $row["message_id"]);
a765f65 # fixing moderator-pages with message-caching
ts77 authored
403
404 // pagelinks for moderators
7e55e43 # avoid warnings
ts77 authored
405 if(isset($row['pages_moderators'])) {
406 $rows[$key]['pages'] = $row['pages_moderators'];
407 }
a765f65 # fixing moderator-pages with message-caching
ts77 authored
408
409 // building their last message link too
7e55e43 # avoid warnings
ts77 authored
410 if(isset($row['recent_message_id']) && isset($row['pages_moderators_count'])) { // should always be true
a765f65 # fixing moderator-pages with message-caching
ts77 authored
411 // building the recent message link
412 $pages = $row['pages_moderators_count'];
413 if($pages>1){
414 $rows[$key]["URL"]["LAST_POST"]=phorum_get_url(PHORUM_READ_URL, $row["thread"], $row['recent_message_id'], "page=$pages");
415 } else {
416 $rows[$key]["URL"]["LAST_POST"]=phorum_get_url(PHORUM_READ_URL, $row["thread"], $row['recent_message_id']);
417 }
4775e82 # more line-ending properties
ts77 authored
418 }
419 }
77f7d59 # moved caching layers around and added apc-layer
ts77 authored
420
4775e82 # more line-ending properties
ts77 authored
421 }
77f7d59 # moved caching layers around and added apc-layer
ts77 authored
422
4775e82 # more line-ending properties
ts77 authored
423 }
424
425 // run list mods
6babf27 # Separated phorum_get_url() into it's own include/phorum_get_url.php fi...
mmakaay authored
426 if (isset($PHORUM["hooks"]["list"]))
427 $rows = phorum_hook("list", $rows);
4775e82 # more line-ending properties
ts77 authored
428
293da1e Moved all template output to common function for control. Added new sta...
brian authored
429 // if we retrieve the body too we need to setup some more variables for
eb6eb71 # Pulled $PHORUM['TMP']['bodies_in_list']) from the db layer and turned ...
mmakaay authored
430 // the messages to make it a little more similar to the view in read.php
431 if ($bodies_in_list)
432 {
c26cbfa setting up more data in list.php if the bodies are retrieved too, like m...
ts77 authored
433 foreach ($rows as $id => $row) {
434
435 // is the message unapproved?
436 $row["is_unapproved"] = ($row['status'] < 0) ? 1 : 0;
437
438 // check if its the first message in the thread
439 if($row["message_id"] == $row["thread"]) {
440 $row["threadstart"] = true;
441 } else{
442 $row["threadstart"] = false;
443 }
444
445 // mask host if not a moderator
446 if(empty($PHORUM["user"]["admin"]) && (empty($PHORUM["DATA"]["MODERATOR"]) || !PHORUM_MOD_IP_VIEW)){
447 if($PHORUM["display_ip_address"]){
448 if($row["moderator_post"]){
449 $row["ip"]=$PHORUM["DATA"]["LANG"]["Moderator"];
450 } elseif(is_numeric(str_replace(".", "", $row["ip"]))){
451 $row["ip"]=substr($row["ip"],0,strrpos($row["ip"],'.')).'.---';
452 } else {
453 $row["ip"]="---".strstr($row["ip"], ".");
454 }
455
456 } else {
457 $row["ip"]=$PHORUM["DATA"]["LANG"]["IPLogged"];
458 }
459 }
460
461 // add the edited-message to a post if its edited
462 if(isset($row['meta']['edit_count']) && $row['meta']['edit_count'] > 0) {
463 $editmessage = str_replace ("%count%", $row['meta']['edit_count'], $PHORUM["DATA"]["LANG"]["EditedMessage"]);
28f3067 # more template related changes for 5.2
brian authored
464 $editmessage = str_replace ("%lastedit%", phorum_date($PHORUM["short_date_time"],$row['meta']['edit_date']), $editmessage);
c26cbfa setting up more data in list.php if the bodies are retrieved too, like m...
ts77 authored
465 $editmessage = str_replace ("%lastuser%", $row['meta']['edit_username'], $editmessage);
466 $row["body"].="\n\n\n\n$editmessage";
467 }
468
469
470 if($PHORUM["max_attachments"]>0 && isset($row["meta"]["attachments"])){
471 $PHORUM["DATA"]["ATTACHMENTS"]=true;
472 $row["attachments"]=$row["meta"]["attachments"];
473 // unset($row["meta"]["attachments"]);
474 foreach($row["attachments"] as $key=>$file){
475 $row["attachments"][$key]["size"]=phorum_filesize($file["size"]);
9bb97e1 # Replaced htmlentities with htmlspecialchars. This will effectively pre...
mmakaay authored
476 $row["attachments"][$key]["name"]=htmlspecialchars($file['name']);
4e50dbf In the admin general settings, there's a new option "Put file name in
mmakaay authored
477 $row["attachments"][$key]["url"] = phorum_get_url(PHORUM_FILE_URL, "file={$file['file_id']}", "filename=".urlencode($file['name']));
c26cbfa setting up more data in list.php if the bodies are retrieved too, like m...
ts77 authored
478 }
479 }
480 $rows[$id] = $row;
481 }
482 }
483
9bea911 # Some updates for display_name functionality and getting rid of the
mmakaay authored
484 // The list page needs additional formatting for the recent author data
485 $recent_author_spec = array(
486 "recent_user_id", // user_id
487 "recent_author", // author
488 NULL, // email (we won't link to email for recent)
489 "recent_author", // target author field
490 "RECENT_AUTHOR_PROFILE" // target author profile URL field
491 );
492
4775e82 # more line-ending properties
ts77 authored
493 // format messages
9bea911 # Some updates for display_name functionality and getting rid of the
mmakaay authored
494 $rows = phorum_format_messages($rows, array($recent_author_spec));
4775e82 # more line-ending properties
ts77 authored
495
29c09f9 # Disabled timing code in read/list (left behind from message cache deve...
mmakaay authored
496 //timing_mark('after formatting');
4775e82 # more line-ending properties
ts77 authored
497
498 // set up the data
1427e2f # this commit gets flat list page done
brian authored
499 $PHORUM["DATA"]["MESSAGES"] = $rows;
4775e82 # more line-ending properties
ts77 authored
500
a699957 "# fixing mark-read url"
ts77 authored
501 $PHORUM["DATA"]["URL"]["MARK_READ"] = phorum_get_url(PHORUM_LIST_URL, $PHORUM["forum_id"], "markread");
4775e82 # more line-ending properties
ts77 authored
502 if($PHORUM["DATA"]["MODERATOR"]) {
503 $PHORUM["DATA"]["URL"]["UNAPPROVED"] = phorum_get_url(PHORUM_PREPOST_URL);
504 }
505
506 // updating new-info for first visit (last message on first page is first new)
26596b4 # Stripping old announcement code
mmakaay authored
507 if ($PHORUM["DATA"]["LOGGEDIN"] && $PHORUM['user']['newinfo']['min_id'] == 0 && !isset($PHORUM['user']['newinfo'][$min_id]) && $min_id != 0){
4775e82 # more line-ending properties
ts77 authored
508 // setting it as min-id
ce2004e "MFB: # another take in min_id for first visit"
ts77 authored
509 // set it -1 as the comparison is "post newer than min_id"
510 $min_id--;
4775e82 # more line-ending properties
ts77 authored
511 phorum_db_newflag_add_read($min_id);
b080ff0 added newflag caching
ts77 authored
512 if($PHORUM['cache_newflags']) {
8aa3374 # message caching including forum-versions + hybrid read view (needs tho...
ts77 authored
513 phorum_cache_remove('newflags',$newflagkey);
514 phorum_cache_remove('newflags_index',$newflagkey);
b080ff0 added newflag caching
ts77 authored
515 }
4775e82 # more line-ending properties
ts77 authored
516 }
517
518 // include the correct template
519 if ($PHORUM["threaded_list"]){
293da1e Moved all template output to common function for control. Added new sta...
brian authored
520 $template = "list_threads";
4775e82 # more line-ending properties
ts77 authored
521 }else{
293da1e Moved all template output to common function for control. Added new sta...
brian authored
522 $template = "list";
4775e82 # more line-ending properties
ts77 authored
523 }
524
293da1e Moved all template output to common function for control. Added new sta...
brian authored
525 phorum_output($template);
4775e82 # more line-ending properties
ts77 authored
526
29c09f9 # Disabled timing code in read/list (left behind from message cache deve...
mmakaay authored
527 //timing_mark('end');
528 //timing_print();
77f7d59 # moved caching layers around and added apc-layer
ts77 authored
529
7e55e43 # avoid warnings
ts77 authored
530 ?>
Something went wrong with that request. Please try again.