Passed
Pull Request — master (#5728)
by David
10:20 queued 27s
created
html/inc/forum.inc 1 patch
Spacing   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -54,12 +54,12 @@  discard block
 block discarded – undo
54 54
 define('THREAD_SOLVED', 1);
55 55
 
56 56
 define('AVATAR_WIDTH', 100);
57
-define('AVATAR_HEIGHT',100);
57
+define('AVATAR_HEIGHT', 100);
58 58
 
59 59
 define('ST_NEW_TIME', 1209600); //3600*24*14 - 14 days
60 60
 define('ST_NEW', 'New member');
61 61
 
62
-define('MAXIMUM_EDIT_TIME',3600);
62
+define('MAXIMUM_EDIT_TIME', 3600);
63 63
     // allow edits of forums posts up till one hour after posting.
64 64
 
65 65
 define('MAX_FORUM_LOGGING_TIME', 2419200); //3600*24*28 - 28 days
@@ -77,24 +77,24 @@  discard block
 block discarded – undo
77 77
 define('IMAGE_HIDDEN', 'img/hidden.png');
78 78
 define('IMAGE_STICKY_LOCKED', 'img/sticky_locked_post.png');
79 79
 define('IMAGE_POST', 'img/post.png');
80
-define('NEW_IMAGE_HEIGHT','15');
80
+define('NEW_IMAGE_HEIGHT', '15');
81 81
 define('EMPHASIZE_IMAGE', 'img/emphasized_post.png');
82
-define('EMPHASIZE_IMAGE_HEIGHT','15');
82
+define('EMPHASIZE_IMAGE_HEIGHT', '15');
83 83
 define('FILTER_IMAGE', 'img/filtered_post.png');
84
-define('FILTER_IMAGE_HEIGHT','15');
84
+define('FILTER_IMAGE_HEIGHT', '15');
85 85
 define('RATE_POSITIVE_IMAGE', 'img/rate_positive.png');
86
-define('RATE_POSITIVE_IMAGE_HEIGHT','9');
86
+define('RATE_POSITIVE_IMAGE_HEIGHT', '9');
87 87
 define('RATE_NEGATIVE_IMAGE', 'img/rate_negative.png');
88
-define('RATE_NEGATIVE_IMAGE_HEIGHT','9');
88
+define('RATE_NEGATIVE_IMAGE_HEIGHT', '9');
89 89
 define('REPORT_POST_IMAGE', 'img/report_post.png');
90
-define('REPORT_POST_IMAGE_HEIGHT','9');
90
+define('REPORT_POST_IMAGE_HEIGHT', '9');
91 91
 
92 92
 define('SOLUTION', tra('This answered my question'));
93 93
 define('SUFFERER', tra('I also have this question'));
94 94
 define('OFF_TOPIC', tra('Off-topic'));
95 95
 
96
-define ('DEFAULT_LOW_RATING_THRESHOLD', -25);
97
-define ('DEFAULT_HIGH_RATING_THRESHOLD', 5);
96
+define('DEFAULT_LOW_RATING_THRESHOLD', -25);
97
+define('DEFAULT_HIGH_RATING_THRESHOLD', 5);
98 98
 
99 99
 // special user attributes
100 100
 //
@@ -172,15 +172,15 @@  discard block
 block discarded – undo
172 172
 
173 173
 // return forum/thread title, with links.
174 174
 //
175
-function forum_title($category, $forum, $thread, $link_thread=false) {
175
+function forum_title($category, $forum, $thread, $link_thread = false) {
176 176
     if ($category) {
177 177
         $is_helpdesk = $category->is_helpdesk;
178 178
     } else {
179 179
         $is_helpdesk = false;
180 180
     }
181 181
 
182
-    $where = $is_helpdesk?tra("Questions and Answers"):tra("Message boards");
183
-    $top_url = $is_helpdesk?"forum_help_desk.php":"forum_index.php";
182
+    $where = $is_helpdesk ?tra("Questions and Answers") : tra("Message boards");
183
+    $top_url = $is_helpdesk ? "forum_help_desk.php" : "forum_index.php";
184 184
 
185 185
     $x = '';
186 186
     if (!$forum && !$thread) {
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
     return $x;
215 215
 }
216 216
 
217
-function team_forum_title($forum, $thread=null, $link_thread=false) {
217
+function team_forum_title($forum, $thread = null, $link_thread = false) {
218 218
     $team = BoincTeam::lookup_id($forum->category);
219 219
     $x = sprintf('<a href="forum_index.php">%s</a> :',
220 220
         tra("Message boards")
@@ -248,12 +248,12 @@  discard block
 block discarded – undo
248 248
 }
249 249
 
250 250
 function page_link($url, $page_num, $items_per_page, $text) {
251
-    return " <a href=\"$url&amp;start=" . $page_num*$items_per_page . "\">$text</a> ";
251
+    return " <a href=\"$url&amp;start=".$page_num*$items_per_page."\">$text</a> ";
252 252
 }
253 253
 
254 254
 // return a string for navigating pages
255 255
 //
256
-function page_links($url, $nitems, $items_per_page, $start){
256
+function page_links($url, $nitems, $items_per_page, $start) {
257 257
     // How many pages to potentially show before and after this one:
258 258
     $preshow = 3;
259 259
     $postshow = 3;
@@ -261,14 +261,14 @@  discard block
 block discarded – undo
261 261
     $x = "";
262 262
 
263 263
     if ($nitems <= $items_per_page) return "";
264
-    $npages = ceil($nitems / $items_per_page);
265
-    $curpage = ceil($start / $items_per_page);
264
+    $npages = ceil($nitems/$items_per_page);
265
+    $curpage = ceil($start/$items_per_page);
266 266
 
267 267
     // If this is not the first page, display "previous"
268 268
     //
269
-    if ($curpage > 0){
269
+    if ($curpage > 0) {
270 270
         $x .= page_link(
271
-            $url, $curpage-1, $items_per_page,
271
+            $url, $curpage - 1, $items_per_page,
272 272
             tra("Previous")." &middot; "
273 273
         );
274 274
     }
@@ -283,8 +283,8 @@  discard block
 block discarded – undo
283 283
     }
284 284
     // Display a list of pages surrounding this one
285 285
     //
286
-    for ($i=$curpage-$preshow; $i<=$curpage+$postshow; $i++){
287
-        $page_str = (string)($i+1);
286
+    for ($i = $curpage - $preshow; $i <= $curpage + $postshow; $i++) {
287
+        $page_str = (string)($i + 1);
288 288
         if ($i < 0) continue;
289 289
         if ($i >= $npages) break;
290 290
 
@@ -293,20 +293,20 @@  discard block
 block discarded – undo
293 293
         } else {
294 294
             $x .= page_link($url, $i, $items_per_page, $page_str);
295 295
         }
296
-        if ($i == $npages-1) break;
297
-        if ($i == $curpage+$postshow) break;
296
+        if ($i == $npages - 1) break;
297
+        if ($i == $curpage + $postshow) break;
298 298
         $x .= " &middot; ";
299 299
     }
300 300
 
301
-    if ($curpage + $postshow < $npages-1) {
301
+    if ($curpage + $postshow < $npages - 1) {
302 302
         $x .= " . . . ";
303
-        $x .= page_link($url, $npages-1, $items_per_page, $npages);
303
+        $x .= page_link($url, $npages - 1, $items_per_page, $npages);
304 304
     }
305 305
     // If there is a next page
306 306
     //
307
-    if ($curpage < $npages-1){
307
+    if ($curpage < $npages - 1) {
308 308
         $x .= page_link(
309
-            $url, $curpage+1, $items_per_page,
309
+            $url, $curpage + 1, $items_per_page,
310 310
             " &middot; ".tra("Next")
311 311
         );
312 312
     }
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
 function cleanup_title($title) {
328 328
     $x = sanitize_tags(bb2html($title));
329 329
     $x = trim($x);
330
-    if (strlen($x)==0) return "(no title)";
330
+    if (strlen($x) == 0) return "(no title)";
331 331
     else return $x;
332 332
 }
333 333
 
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
             $i = 0;
390 390
             foreach ($posts as $post) {
391 391
                 if ($post->id == $postid) {
392
-                    $start = $i - ($i % $num_to_show);
392
+                    $start = $i - ($i%$num_to_show);
393 393
                     $jump_to_post = $post;
394 394
                     break;
395 395
                 }
@@ -416,7 +416,7 @@  discard block
 block discarded – undo
416 416
             // if jump to post, figure out what page to show
417 417
             //
418 418
             if ($jump_to_post) {
419
-                $start = $ibest - ($ibest % $num_to_show);
419
+                $start = $ibest - ($ibest%$num_to_show);
420 420
             } else {
421 421
                 $start = $default_start;
422 422
             }
@@ -524,8 +524,8 @@  discard block
 block discarded – undo
524 524
 // Generates a table row with two cells: author and message
525 525
 //
526 526
 function show_post(
527
-    $post, $thread, $forum, $logged_in_user, $start=0,
528
-    $latest_viewed=0, $controls=FORUM_CONTROLS, $filter=true
527
+    $post, $thread, $forum, $logged_in_user, $start = 0,
528
+    $latest_viewed = 0, $controls = FORUM_CONTROLS, $filter = true
529 529
 ) {
530 530
     global $country_to_iso3166_2;
531 531
 
@@ -533,7 +533,7 @@  discard block
 block discarded – undo
533 533
 
534 534
     // If the user no longer exists, skip the post
535 535
     //
536
-    if (!$user){
536
+    if (!$user) {
537 537
         return;
538 538
     }
539 539
 
@@ -554,9 +554,9 @@  discard block
 block discarded – undo
554 554
     // check whether the poster is on the list of people to ignore
555 555
     //
556 556
     $ignore_poster = false;
557
-    if ($logged_in_user){
557
+    if ($logged_in_user) {
558 558
         $tokens = url_tokens($logged_in_user->authenticator);
559
-        if (is_ignoring($logged_in_user, $user)){
559
+        if (is_ignoring($logged_in_user, $user)) {
560 560
             $ignore_poster = true;
561 561
         }
562 562
     }
@@ -570,8 +570,8 @@  discard block
 block discarded – undo
570 570
             if (is_moderator($logged_in_user, $forum)) {
571 571
                 $can_edit = true;
572 572
             } else if (can_reply($thread, $forum, $logged_in_user)) {
573
-                $time_limit = $post->timestamp+MAXIMUM_EDIT_TIME;
574
-                $can_edit = time()<$time_limit;
573
+                $time_limit = $post->timestamp + MAXIMUM_EDIT_TIME;
574
+                $can_edit = time() < $time_limit;
575 575
             } else {
576 576
                 $can_edit = false;
577 577
             }
@@ -581,24 +581,24 @@  discard block
 block discarded – undo
581 581
     // Print the special user lines, if any
582 582
     //
583 583
     global $special_user_bitfield;
584
-    $fstatus="";
584
+    $fstatus = "";
585 585
     $keys = array_keys($special_user_bitfield);
586 586
     $is_posted_by_special = false;
587
-    for ($i=0; $i<sizeof($special_user_bitfield);$i++) {
587
+    for ($i = 0; $i < sizeof($special_user_bitfield); $i++) {
588 588
         if ($user->prefs && $user->prefs->privilege($keys[$i])) {
589
-            $fstatus.="<nobr>".$special_user_bitfield[$keys[$i]]."<nobr><br>";
589
+            $fstatus .= "<nobr>".$special_user_bitfield[$keys[$i]]."<nobr><br>";
590 590
             $is_posted_by_special = true;
591 591
         }
592 592
     }
593 593
 
594 594
     // Highlight special users if set in prefs;
595 595
     //
596
-    if ($logged_in_user && $logged_in_user->prefs){
596
+    if ($logged_in_user && $logged_in_user->prefs) {
597 597
         $highlight = $logged_in_user->prefs->highlight_special && $is_posted_by_special;
598 598
     } else {
599 599
         $highlight = $is_posted_by_special;
600 600
     }
601
-    $class = $highlight?' style="border-left: 5px solid LightGreen" ':'';
601
+    $class = $highlight ? ' style="border-left: 5px solid LightGreen" ' : '';
602 602
 
603 603
     // row and start of author col
604 604
     //
@@ -610,12 +610,12 @@  discard block
 block discarded – undo
610 610
 
611 611
     echo user_links($user, 0, 30);
612 612
     echo "<br>";
613
-    if ($user->create_time > time()-ST_NEW_TIME) $fstatus.=ST_NEW."<br>";
613
+    if ($user->create_time > time() - ST_NEW_TIME) $fstatus .= ST_NEW."<br>";
614 614
     echo "<span class=\"small\">";
615 615
     if ($fstatus) echo "$fstatus";
616 616
 
617
-    if (!$filter || !$ignore_poster){
618
-        if ($user->prefs && $user->prefs->avatar!="" && (!$logged_in_user || ($logged_in_user->prefs->hide_avatars==false))) {
617
+    if (!$filter || !$ignore_poster) {
618
+        if ($user->prefs && $user->prefs->avatar != "" && (!$logged_in_user || ($logged_in_user->prefs->hide_avatars == false))) {
619 619
             echo "<img width=\"".AVATAR_WIDTH."\" height=\"".AVATAR_HEIGHT."\" src=\"".avatar_url($user->prefs->avatar)."\" alt=\"Avatar\"><br>";
620 620
         }
621 621
     }
@@ -623,14 +623,14 @@  discard block
 block discarded – undo
623 623
 
624 624
     $url = "pm.php?action=new&amp;userid=".$user->id;
625 625
     $name = $user->name;
626
-    show_button_small($url, tra("Send message"), tra("Send %1 a private message",$name));
626
+    show_button_small($url, tra("Send message"), tra("Send %1 a private message", $name));
627 627
     echo '<br>'.tra("Joined: %1", gmdate('j M y', $user->create_time)), "<br>";
628 628
 
629 629
     if (!isset($user->nposts)) {
630 630
         $user->nposts = BoincPost::count("user=$user->id");
631 631
     }
632 632
 
633
-    if (function_exists('project_forum_user_info')){
633
+    if (function_exists('project_forum_user_info')) {
634 634
         project_forum_user_info($user);
635 635
     } else {
636 636
         echo tra("Posts: %1", $user->nposts)."<br>";
@@ -639,8 +639,8 @@  discard block
 block discarded – undo
639 639
         //
640 640
         //echo "ID: ".$user->id."<br>";
641 641
         if (!NO_COMPUTING) {
642
-            echo tra("Credit: %1", number_format($user->total_credit)) ."<br>";
643
-            echo tra("RAC: %1",    number_format($user->expavg_credit))."<br>";
642
+            echo tra("Credit: %1", number_format($user->total_credit))."<br>";
643
+            echo tra("RAC: %1", number_format($user->expavg_credit))."<br>";
644 644
         }
645 645
 
646 646
         // to use this feature:
@@ -669,7 +669,7 @@  discard block
 block discarded – undo
669 669
         echo "<form action=\"forum_rate.php?post=", $post->id, "\" method=\"post\">";
670 670
     }
671 671
 
672
-    if ($logged_in_user && $post->timestamp > $latest_viewed){
672
+    if ($logged_in_user && $post->timestamp > $latest_viewed) {
673 673
         show_image(NEW_IMAGE, tra("You haven't read this message yet"), tra("Unread"), NEW_IMAGE_HEIGHT);
674 674
     }
675 675
 
@@ -689,8 +689,8 @@  discard block
 block discarded – undo
689 689
     if ($post->modified) {
690 690
         echo "<br>".tra("Last modified: %1", pretty_time_Str($post->modified));
691 691
     }
692
-    if ($ignore_poster && $filter){
693
-        echo "<br>" .tra(
692
+    if ($ignore_poster && $filter) {
693
+        echo "<br>".tra(
694 694
             "This post is hidden because the sender is on your 'ignore' list.  Click %1 here %2 to view hidden posts",
695 695
             "<a href=\"?id=".$thread->id."&amp;filter=false&amp;start=$start#".$post->id."\">",
696 696
             "</a>"
@@ -703,7 +703,7 @@  discard block
 block discarded – undo
703 703
         <p>
704 704
     ";
705 705
 
706
-    if (!$filter || !$ignore_poster){
706
+    if (!$filter || !$ignore_poster) {
707 707
         $posttext = $post->content;
708 708
 
709 709
         // If the creator of this post has a signature and
@@ -711,7 +711,7 @@  discard block
 block discarded – undo
711 711
         // user has signatures enabled: show it
712 712
         //
713 713
         $posttext = output_transform($posttext, $options);
714
-        if ($post->signature && (!$logged_in_user || !$logged_in_user->prefs->hide_signatures)){
714
+        if ($post->signature && (!$logged_in_user || !$logged_in_user->prefs->hide_signatures)) {
715 715
             $sig = output_transform($user->prefs->signature, $options);
716 716
             $posttext .= "<hr>$sig\n";
717 717
         }
@@ -745,10 +745,10 @@  discard block
 block discarded – undo
745 745
         }
746 746
         if (($controls == FORUM_CONTROLS) && (can_reply($thread, $forum, $logged_in_user))) {
747 747
             echo "&nbsp;&nbsp;&nbsp;&nbsp;";
748
-            $url = "forum_reply.php?thread=" . $thread->id . "&amp;post=" . $post->id . "&amp;no_quote=1#input";
748
+            $url = "forum_reply.php?thread=".$thread->id."&amp;post=".$post->id."&amp;no_quote=1#input";
749 749
             // "Reply" is used as a verb
750 750
             show_button($url, tra("Reply"), tra("Post a reply to this message"));
751
-            $url = "forum_reply.php?thread=" . $thread->id . "&amp;post=" . $post->id . "#input";
751
+            $url = "forum_reply.php?thread=".$thread->id."&amp;post=".$post->id."#input";
752 752
             // "Quote" is used as a verb
753 753
             show_button($url, tra("Quote"), tra("Post a reply by quoting this message"));
754 754
         }
@@ -770,7 +770,7 @@  discard block
 block discarded – undo
770 770
     $content = output_transform($post->content, $options);
771 771
     $when = time_diff_str($post->timestamp, time());
772 772
     $user = BoincUser::lookup_id($post->user);
773
-    if (!$user){
773
+    if (!$user) {
774 774
         return;
775 775
     }
776 776
 
@@ -826,9 +826,9 @@  discard block
 block discarded – undo
826 826
 function post_rules() {
827 827
     if (defined('FORUM_RULES')) return FORUM_RULES;
828 828
     if (function_exists("project_forum_post_rules")) {
829
-      $project_rules=project_forum_post_rules();
829
+      $project_rules = project_forum_post_rules();
830 830
     } else {
831
-      $project_rules="";
831
+      $project_rules = "";
832 832
     }
833 833
     return sprintf("
834 834
         <ul>
@@ -857,7 +857,7 @@  discard block
 block discarded – undo
857 857
     );
858 858
 }
859 859
 
860
-function post_warning($forum=null) {
860
+function post_warning($forum = null) {
861 861
     $x = "<br><br>
862 862
         <table><tr><td align=left>
863 863
     ";
@@ -945,7 +945,7 @@  discard block
 block discarded – undo
945 945
     $content = substr($content, 0, 64000);
946 946
     $content = BoincDb::escape_string($content);
947 947
     $now = time();
948
-    $sig = $signature?1:0;
948
+    $sig = $signature ? 1 : 0;
949 949
     $id = BoincPost::insert("(thread, user, timestamp, content, modified, parent_post, score, votes, signature, hidden) values ($thread->id, $user->id, $now, '$content', 0, $parent_id, 0, 0, $sig, 0)");
950 950
     if (!$id) {
951 951
         $forum_error = "Failed to add post to DB.";
@@ -965,7 +965,7 @@  discard block
 block discarded – undo
965 965
 //
966 966
 function update_thread_timestamp($thread) {
967 967
     $posts = BoincPost::enum("thread=$thread->id and hidden=0 order by timestamp desc limit 1");
968
-    if (count($posts)>0) {
968
+    if (count($posts) > 0) {
969 969
         $post = $posts[0];
970 970
         $thread->update("timestamp=$post->timestamp");
971 971
     }
@@ -973,7 +973,7 @@  discard block
 block discarded – undo
973 973
 
974 974
 function update_forum_timestamp($forum) {
975 975
     $threads = BoincThread::enum("forum=$forum->id and hidden=0 order by timestamp desc limit 1");
976
-    if (count($threads)>0) {
976
+    if (count($threads) > 0) {
977 977
         $thread = $threads[0];
978 978
         $forum->update("timestamp=$thread->timestamp");
979 979
     }
@@ -996,7 +996,7 @@  discard block
 block discarded – undo
996 996
     if (is_news_forum($forum) && !$export) {
997 997
         $status = 1;
998 998
     }
999
-    $id  = BoincThread::insert("(forum, owner, status, title, timestamp, views, replies, activity, sufferers, score, votes, create_time, hidden, sticky, locked) values ($forum->id, $user->id, $status, '$title', $now, 0, -1, 0, 0, 0, 0, $now, 0, 0, 0)");
999
+    $id = BoincThread::insert("(forum, owner, status, title, timestamp, views, replies, activity, sufferers, score, votes, create_time, hidden, sticky, locked) values ($forum->id, $user->id, $status, '$title', $now, 0, -1, 0, 0, 0, 0, $now, 0, 0, 0)");
1000 1000
     if (!$id) {
1001 1001
         $forum_error = "Failed to add thread to DB.";
1002 1002
         return null;
@@ -1126,22 +1126,22 @@  discard block
 block discarded – undo
1126 1126
 // $sticky - bool (not directly passed to SQL)
1127 1127
 //
1128 1128
 function get_forum_threads(
1129
-    $forumID, $start=-1, $nRec=-1, $sort_style=MODIFIED_NEW,
1129
+    $forumID, $start = -1, $nRec = -1, $sort_style = MODIFIED_NEW,
1130 1130
     $show_hidden = 0, $sticky = 1
1131 1131
 ) {
1132 1132
     //if (! (is_numeric($forumID) && is_numeric($min) && is_numeric($nRec))) {
1133 1133
     //    return NULL;  // Something is wrong here.
1134 1134
     //}
1135 1135
 
1136
-    $sql = 'forum = ' . $forumID ;
1136
+    $sql = 'forum = '.$forumID;
1137 1137
     $stickysql = "";
1138
-    if ($sticky){
1138
+    if ($sticky) {
1139 1139
         $stickysql = "sticky DESC, ";
1140 1140
     }
1141 1141
     if (!$show_hidden) {
1142 1142
         $sql .= ' AND hidden = 0';
1143 1143
     }
1144
-    switch($sort_style) {
1144
+    switch ($sort_style) {
1145 1145
     case MODIFIED_NEW:
1146 1146
         $sql .= ' ORDER BY '.$stickysql.'timestamp DESC';
1147 1147
         break;
@@ -1194,7 +1194,7 @@  discard block
 block discarded – undo
1194 1194
     if (!$show_hidden) {
1195 1195
         $sql .= ' AND hidden = 0';
1196 1196
     }
1197
-    switch($sort_style) {
1197
+    switch ($sort_style) {
1198 1198
     case CREATE_TIME_NEW:
1199 1199
         $sql .= ' ORDER BY timestamp desc';
1200 1200
         break;
@@ -1216,7 +1216,7 @@  discard block
 block discarded – undo
1216 1216
 //
1217 1217
 function show_post_moderation_links(
1218 1218
     $config, $logged_in_user, $post, $forum, $tokens
1219
-){
1219
+) {
1220 1220
     $moderators_allowed_to_ban = parse_bool($config, "moderators_allowed_to_ban");
1221 1221
     $moderators_vote_to_ban = parse_bool($config, "moderators_vote_to_ban");
1222 1222
 
@@ -1303,14 +1303,14 @@  discard block
 block discarded – undo
1303 1303
     // We do not tell the (ab)user how much this is -
1304 1304
     // no need to make it easy for them to break the system.
1305 1305
     //
1306
-    if ($user->total_credit<$forum->post_min_total_credit || $user->expavg_credit<$forum->post_min_expavg_credit) {
1306
+    if ($user->total_credit < $forum->post_min_total_credit || $user->expavg_credit < $forum->post_min_expavg_credit) {
1307 1307
         error_page(tra("To create a new thread in %1 you must have a certain level of average credit. This is to protect against abuse of the system.", $forum->title));
1308 1308
     }
1309 1309
 
1310 1310
     // If the user is posting faster than forum regulations allow
1311 1311
     // Tell the user to wait a while before creating any more posts
1312 1312
     //
1313
-    if (time()-$user->prefs->last_post <$forum->post_min_interval) {
1313
+    if (time() - $user->prefs->last_post < $forum->post_min_interval) {
1314 1314
         error_page(tra("You cannot create threads right now. Please wait before trying again. This is to protect against abuse of the system."));
1315 1315
     }
1316 1316
 }
@@ -1336,10 +1336,10 @@  discard block
 block discarded – undo
1336 1336
 // - edit their posts at any time
1337 1337
 // - hide/unhide/move threads and posts
1338 1338
 
1339
-function is_moderator($user, $forum=null) {
1339
+function is_moderator($user, $forum = null) {
1340 1340
     if (!$user) return false;
1341 1341
     BoincForumPrefs::lookup($user);
1342
-    $type = $forum?$forum->parent_type:0;
1342
+    $type = $forum ? $forum->parent_type : 0;
1343 1343
     switch ($type) {
1344 1344
     case 0:
1345 1345
         if ($user->prefs->privilege(S_MODERATOR)) return true;
@@ -1356,7 +1356,7 @@  discard block
 block discarded – undo
1356 1356
     return false;
1357 1357
 }
1358 1358
 
1359
-function thread_list_header($subscriptions=false) {
1359
+function thread_list_header($subscriptions = false) {
1360 1360
     if ($subscriptions) {
1361 1361
         $x = [
1362 1362
             tra("Thread"),
@@ -1379,13 +1379,13 @@  discard block
 block discarded – undo
1379 1379
 // show a 1-line summary of thread and its forum.
1380 1380
 // Used for search results and subscription list
1381 1381
 //
1382
-function thread_list_item($thread, $user, $subscriptions=false) {
1382
+function thread_list_item($thread, $user, $subscriptions = false) {
1383 1383
     $thread_forum = BoincForum::lookup_id($thread->forum);
1384 1384
     if (!$thread_forum) return;
1385 1385
     if (!is_forum_visible_to_user($thread_forum, $user)) return;
1386 1386
     $owner = BoincUser::lookup_id($thread->owner);
1387 1387
     if (!$owner) return;
1388
-    switch($thread_forum->parent_type) {
1388
+    switch ($thread_forum->parent_type) {
1389 1389
     case 0:
1390 1390
         $category = BoincCategory::lookup_id($thread_forum->category);
1391 1391
         $title = forum_title($category, $thread_forum, $thread, true);
@@ -1406,7 +1406,7 @@  discard block
 block discarded – undo
1406 1406
     } else {
1407 1407
         $x = [
1408 1408
             $title,
1409
-            $thread->replies+1,
1409
+            $thread->replies + 1,
1410 1410
             user_links($owner),
1411 1411
             $thread->views,
1412 1412
             time_diff_str($thread->timestamp, time())
@@ -1441,13 +1441,13 @@  discard block
 block discarded – undo
1441 1441
 
1442 1442
 function subscribed_thread_web_line($notify) {
1443 1443
     $thread = BoincThread::lookup_id($notify->opaque);
1444
-    return tra("New posts in the thread %1","<a href=forum_thread.php?id=$thread->id>$thread->title</a>");
1444
+    return tra("New posts in the thread %1", "<a href=forum_thread.php?id=$thread->id>$thread->title</a>");
1445 1445
 }
1446 1446
 
1447 1447
 function subscribed_thread_rss($notify) {
1448 1448
     $thread = BoincThread::lookup_id($notify->opaque);
1449 1449
     $title = tra("New posts in subscribed thread");
1450
-    $msg = tra("There are new posts in the thread '%1'",$thread->title);
1450
+    $msg = tra("There are new posts in the thread '%1'", $thread->title);
1451 1451
     $url = secure_url_base()."forum_thread.php?id=$thread->id";
1452 1452
     return [$title, $msg, $url];
1453 1453
 }
@@ -1459,13 +1459,13 @@  discard block
 block discarded – undo
1459 1459
 
1460 1460
 function subscribed_forum_web_line($notify) {
1461 1461
     $forum = BoincForum::lookup_id($notify->opaque);
1462
-    return tra("New threads in the forum %1","<a href=forum_forum.php?id=$forum->id>$forum->title</a>");
1462
+    return tra("New threads in the forum %1", "<a href=forum_forum.php?id=$forum->id>$forum->title</a>");
1463 1463
 }
1464 1464
 
1465 1465
 function subscribed_forum_rss($notify) {
1466 1466
     $forum = BoincForum::lookup_id($notify->opaque);
1467 1467
     $title = tra("New posts in subscribed forum");
1468
-    $msg = tra("There are new threads in the forum '%1'",$forum->title);
1468
+    $msg = tra("There are new threads in the forum '%1'", $forum->title);
1469 1469
     $url = secure_url_base()."forum_forum.php?id=$forum->id";
1470 1470
     return [$title, $msg, $url];
1471 1471
 }
Please login to merge, or discard this patch.
html/user/forum_search_action.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -31,10 +31,10 @@  discard block
 block discarded – undo
31 31
 // Optionally filters by forum, user, time, or hidden if specified.
32 32
 //
33 33
 function search_thread_titles(
34
-    $keyword_list, $forum="", $user="", $time="", $limit=200,
35
-    $sort_style=CREATE_TIME_NEW, $show_hidden = false
36
-){
37
-    $search_string="%";
34
+    $keyword_list, $forum = "", $user = "", $time = "", $limit = 200,
35
+    $sort_style = CREATE_TIME_NEW, $show_hidden = false
36
+) {
37
+    $search_string = "%";
38 38
     foreach ($keyword_list as $key => $word) {
39 39
         $search_string .= BoincDb::escape_string($word)."%";
40 40
     }
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
     if (!$show_hidden) {
52 52
         $query .= " and thread.hidden = 0";
53 53
     }
54
-    switch($sort_style) {
54
+    switch ($sort_style) {
55 55
     case MODIFIED_NEW:
56 56
         $query .= ' ORDER BY timestamp DESC';
57 57
         break;
@@ -84,11 +84,11 @@  discard block
 block discarded – undo
84 84
 //
85 85
 function search_post_content(
86 86
     $keyword_list, $forum, $user, $time, $limit, $sort_style, $show_hidden
87
-){
87
+) {
88 88
     $db = BoincDb::get();
89 89
 
90
-    $search_string="%";
91
-    foreach ($keyword_list as $key => $word){
90
+    $search_string = "%";
91
+    foreach ($keyword_list as $key => $word) {
92 92
         $search_string .= BoincDb::escape_string($word)."%";
93 93
     }
94 94
     $optional_join = "";
@@ -100,20 +100,20 @@  discard block
 block discarded – undo
100 100
     }
101 101
     $query = "select post.* from ".$db->db_name.".post".$optional_join." where content like '".$search_string."'";
102 102
     if ($forum) {
103
-        $query.=" and forum = $forum->id";
103
+        $query .= " and forum = $forum->id";
104 104
     }
105 105
     if ($user) {
106
-        $query.=" and post.user = $user->id ";
106
+        $query .= " and post.user = $user->id ";
107 107
     }
108 108
     if ($time) {
109
-        $query.=" and post.timestamp > $time";
109
+        $query .= " and post.timestamp > $time";
110 110
     }
111 111
     if (!$show_hidden) {
112 112
         $query .= " AND post.hidden = 0";
113 113
     }
114
-    switch($sort_style) {
114
+    switch ($sort_style) {
115 115
     case VIEWS_MOST:
116
-        $query.= ' ORDER BY views DESC';
116
+        $query .= ' ORDER BY views DESC';
117 117
         break;
118 118
     case CREATE_TIME_NEW:
119 119
         $query .= ' ORDER by post.timestamp desc';
@@ -128,13 +128,13 @@  discard block
 block discarded – undo
128 128
         $query .= ' ORDER BY post.timestamp DESC';
129 129
         break;
130 130
     }
131
-    $query.= " limit $limit";
131
+    $query .= " limit $limit";
132 132
     return BoincPost::enum_general($query);
133 133
 }
134 134
 
135 135
 $logged_in_user = get_logged_in_user(false);
136 136
 BoincForumPrefs::lookup($logged_in_user);
137
-if ($logged_in_user && $logged_in_user->prefs->privilege(S_MODERATOR)){
137
+if ($logged_in_user && $logged_in_user->prefs->privilege(S_MODERATOR)) {
138 138
     $show_hidden_posts = true;
139 139
 } else {
140 140
     $show_hidden_posts = false;
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 $search_max_time = post_int("search_max_time");
148 148
 $search_forum = post_int("search_forum");
149 149
 $search_sort = post_int("search_sort");
150
-$search_list = explode(" ",$search_keywords);
150
+$search_list = explode(" ", $search_keywords);
151 151
 if ($search_max_time) {
152 152
     $min_timestamp = time() - ($search_max_time*3600*24);
153 153
 } else {
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 
157 157
 $limit = 100;
158 158
 
159
-if ($search_forum==-1){
159
+if ($search_forum == -1) {
160 160
     $forum = null;
161 161
 } else if ($search_forum) {
162 162
     $forum = BoincForum::lookup_id($search_forum);
@@ -173,11 +173,11 @@  discard block
 block discarded – undo
173 173
 
174 174
 // Display the threads while we search for posts
175 175
 //
176
-if (count($threads)){
177
-    echo "<h3>" . tra("Thread titles matching your query:") . "</h3>";
176
+if (count($threads)) {
177
+    echo "<h3>".tra("Thread titles matching your query:")."</h3>";
178 178
     start_table('table-striped');
179 179
     thread_list_header();
180
-    foreach ($threads as $thread){
180
+    foreach ($threads as $thread) {
181 181
         if ($thread->hidden) continue;
182 182
         thread_list_item($thread, $logged_in_user);
183 183
     }
@@ -193,8 +193,8 @@  discard block
 block discarded – undo
193 193
     $show_hidden_posts
194 194
 );
195 195
 
196
-if (count($posts)){
197
-    echo "<h3>" . tra("Messages matching your query:") . "</h3>";
196
+if (count($posts)) {
197
+    echo "<h3>".tra("Messages matching your query:")."</h3>";
198 198
     start_table();
199 199
     $n = 1;
200 200
     $options = get_output_options($logged_in_user);
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
     end_table();
217 217
 }
218 218
 
219
-if (!count($threads) && !count($posts)){
219
+if (!count($threads) && !count($posts)) {
220 220
     echo "<p>".tra("Sorry, couldn't find anything matching your search query. You can try to broaden your search by using less words (or less specific words).")."</p>
221 221
     <p>"
222 222
     .tra("You can also %1 try the same search on Google. %2",
@@ -227,5 +227,5 @@  discard block
 block discarded – undo
227 227
 echo "<p><a href=\"forum_search.php\">".tra("Perform another search")."</a></p>";
228 228
 page_tail();
229 229
 
230
-$cvs_version_tracker[]="\$Id$";  //Generated automatically - do not edit
230
+$cvs_version_tracker[] = "\$Id$"; //Generated automatically - do not edit
231 231
 ?>
Please login to merge, or discard this patch.
html/user/forum_index.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 
66 66
     show_forum_header($user);
67 67
 
68
-    if (defined('FORUM_QA_MERGED_MODE') && FORUM_QA_MERGED_MODE){
68
+    if (defined('FORUM_QA_MERGED_MODE') && FORUM_QA_MERGED_MODE) {
69 69
         $categories = BoincCategory::enum("true order by orderID");
70 70
     } else {
71 71
         echo "<p>"
@@ -206,5 +206,5 @@  discard block
 block discarded – undo
206 206
 } else {
207 207
     main($user);
208 208
 }
209
-$cvs_version_tracker[]="\$Id$";  //Generated automatically - do not edit
209
+$cvs_version_tracker[] = "\$Id$"; //Generated automatically - do not edit
210 210
 ?>
Please login to merge, or discard this patch.