@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | error_page("Forums are disabled"); |
44 | 44 | } |
45 | 45 | |
46 | -if (user_can_create_thread($logged_in_user, $forum)=='no') { |
|
46 | +if (user_can_create_thread($logged_in_user, $forum) == 'no') { |
|
47 | 47 | error_page(tra("Only project admins may create a thread here. However, you may reply to existing threads.")); |
48 | 48 | } |
49 | 49 | check_post_access($logged_in_user, $forum); |
@@ -56,10 +56,10 @@ discard block |
||
56 | 56 | $preview = post_str("preview", true); |
57 | 57 | $warning = null; |
58 | 58 | |
59 | -if ($content && $title && (!$preview)){ |
|
59 | +if ($content && $title && (!$preview)) { |
|
60 | 60 | if (post_str('add_signature', true)) { |
61 | - $add_signature = true; // set a flag and concatenate later |
|
62 | - } else { |
|
61 | + $add_signature = true; // set a flag and concatenate later |
|
62 | + } else { |
|
63 | 63 | $add_signature = false; |
64 | 64 | } |
65 | 65 | check_tokens($logged_in_user->authenticator); |
@@ -74,14 +74,14 @@ discard block |
||
74 | 74 | if (post_str('subscribe', true)) { |
75 | 75 | BoincSubscription::replace($logged_in_user->id, $thread->id); |
76 | 76 | } |
77 | - header('Location: forum_thread.php?id=' . $thread->id); |
|
77 | + header('Location: forum_thread.php?id='.$thread->id); |
|
78 | 78 | } else { |
79 | 79 | error_page("Can't create thread. $forum_error"); |
80 | 80 | } |
81 | 81 | } |
82 | 82 | } |
83 | 83 | |
84 | -page_head(tra("Create new thread"),'','','', $bbcode_js); |
|
84 | +page_head(tra("Create new thread"), '', '', '', $bbcode_js); |
|
85 | 85 | show_forum_header($logged_in_user); |
86 | 86 | |
87 | 87 | if ($warning) { |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | $submit_help = "<br /><font color=\"red\">".tra("Remember to add a title")."</font>"; |
123 | 123 | } |
124 | 124 | |
125 | -if ($force_title && $title){ |
|
125 | +if ($force_title && $title) { |
|
126 | 126 | row2( |
127 | 127 | tra("Title"), |
128 | 128 | sprintf( |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | row2( |
137 | 137 | tra("Title").$submit_help, |
138 | 138 | sprintf('<input type="text" class="form-control" name="title" value="%s">', |
139 | - $title?htmlspecialchars($title):'' |
|
139 | + $title ?htmlspecialchars($title) : '' |
|
140 | 140 | ), |
141 | 141 | null, FORUM_LH_PCT |
142 | 142 | ); |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | sprintf( |
148 | 148 | '%s <textarea class="form-control" name="content" rows="12" cols="80">%s</textarea>', |
149 | 149 | $bbcode_html, |
150 | - $content?htmlspecialchars($content):'' |
|
150 | + $content ?htmlspecialchars($content) : '' |
|
151 | 151 | ), |
152 | 152 | null, FORUM_LH_PCT |
153 | 153 | ); |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | if (!$logged_in_user->prefs->no_signature_by_default) { |
156 | 156 | $enable_signature = 'checked="true"'; |
157 | 157 | } else { |
158 | - $enable_signature=''; |
|
158 | + $enable_signature = ''; |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | if (is_news_forum($forum)) { |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | require_once("../inc/text_transform.inc"); |
25 | 25 | |
26 | 26 | define('THREADS_PER_PAGE', 50); |
27 | -define('FORUM_LH_PCT', '25%'); // width of LH column |
|
27 | +define('FORUM_LH_PCT', '25%'); // width of LH column |
|
28 | 28 | |
29 | 29 | $forum_error = ""; |
30 | 30 | // for functions that return null on error, |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | define('THREAD_SOLVED', 1); |
56 | 56 | |
57 | 57 | define('AVATAR_WIDTH', 100); |
58 | -define('AVATAR_HEIGHT',100); |
|
58 | +define('AVATAR_HEIGHT', 100); |
|
59 | 59 | |
60 | 60 | define('ST_NEW_TIME', 1209600); //3600*24*14 - 14 days |
61 | 61 | define('ST_NEW', 'New member'); |
@@ -80,24 +80,24 @@ discard block |
||
80 | 80 | define('IMAGE_HIDDEN', 'img/hidden.png'); |
81 | 81 | define('IMAGE_STICKY_LOCKED', 'img/sticky_locked_post.png'); |
82 | 82 | define('IMAGE_POST', 'img/post.png'); |
83 | -define('NEW_IMAGE_HEIGHT','15'); |
|
83 | +define('NEW_IMAGE_HEIGHT', '15'); |
|
84 | 84 | define('EMPHASIZE_IMAGE', 'img/emphasized_post.png'); |
85 | -define('EMPHASIZE_IMAGE_HEIGHT','15'); |
|
85 | +define('EMPHASIZE_IMAGE_HEIGHT', '15'); |
|
86 | 86 | define('FILTER_IMAGE', 'img/filtered_post.png'); |
87 | -define('FILTER_IMAGE_HEIGHT','15'); |
|
87 | +define('FILTER_IMAGE_HEIGHT', '15'); |
|
88 | 88 | define('RATE_POSITIVE_IMAGE', 'img/rate_positive.png'); |
89 | -define('RATE_POSITIVE_IMAGE_HEIGHT','9'); |
|
89 | +define('RATE_POSITIVE_IMAGE_HEIGHT', '9'); |
|
90 | 90 | define('RATE_NEGATIVE_IMAGE', 'img/rate_negative.png'); |
91 | -define('RATE_NEGATIVE_IMAGE_HEIGHT','9'); |
|
91 | +define('RATE_NEGATIVE_IMAGE_HEIGHT', '9'); |
|
92 | 92 | define('REPORT_POST_IMAGE', 'img/report_post.png'); |
93 | -define('REPORT_POST_IMAGE_HEIGHT','9'); |
|
93 | +define('REPORT_POST_IMAGE_HEIGHT', '9'); |
|
94 | 94 | |
95 | 95 | define('SOLUTION', tra('This answered my question')); |
96 | 96 | define('SUFFERER', tra('I also have this question')); |
97 | 97 | define('OFF_TOPIC', tra('Off-topic')); |
98 | 98 | |
99 | -define ('DEFAULT_LOW_RATING_THRESHOLD', -25); |
|
100 | -define ('DEFAULT_HIGH_RATING_THRESHOLD', 5); |
|
99 | +define('DEFAULT_LOW_RATING_THRESHOLD', -25); |
|
100 | +define('DEFAULT_HIGH_RATING_THRESHOLD', 5); |
|
101 | 101 | |
102 | 102 | // special user attributes |
103 | 103 | // |
@@ -175,15 +175,15 @@ discard block |
||
175 | 175 | |
176 | 176 | // return forum/thread title, with links. |
177 | 177 | // |
178 | -function forum_title($category, $forum, $thread, $link_thread=false) { |
|
178 | +function forum_title($category, $forum, $thread, $link_thread = false) { |
|
179 | 179 | if ($category) { |
180 | 180 | $is_helpdesk = $category->is_helpdesk; |
181 | 181 | } else { |
182 | 182 | $is_helpdesk = false; |
183 | 183 | } |
184 | 184 | |
185 | - $where = $is_helpdesk?tra("Questions and Answers"):tra("Message boards"); |
|
186 | - $top_url = $is_helpdesk?"forum_help_desk.php":"forum_index.php"; |
|
185 | + $where = $is_helpdesk ?tra("Questions and Answers") : tra("Message boards"); |
|
186 | + $top_url = $is_helpdesk ? "forum_help_desk.php" : "forum_index.php"; |
|
187 | 187 | |
188 | 188 | $x = ''; |
189 | 189 | if (!$forum && !$thread) { |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | return $x; |
218 | 218 | } |
219 | 219 | |
220 | -function team_forum_title($forum, $thread=null, $link_thread=false) { |
|
220 | +function team_forum_title($forum, $thread = null, $link_thread = false) { |
|
221 | 221 | $team = BoincTeam::lookup_id($forum->category); |
222 | 222 | $x = sprintf('<a href="forum_index.php">%s</a> :', |
223 | 223 | tra("Message boards") |
@@ -251,12 +251,12 @@ discard block |
||
251 | 251 | } |
252 | 252 | |
253 | 253 | function page_link($url, $page_num, $items_per_page, $text) { |
254 | - return " <a href=\"$url&start=" . $page_num*$items_per_page . "\">$text</a> "; |
|
254 | + return " <a href=\"$url&start=".$page_num*$items_per_page."\">$text</a> "; |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | // return a string for navigating pages |
258 | 258 | // |
259 | -function page_links($url, $nitems, $items_per_page, $start){ |
|
259 | +function page_links($url, $nitems, $items_per_page, $start) { |
|
260 | 260 | // How many pages to potentially show before and after this one: |
261 | 261 | $preshow = 3; |
262 | 262 | $postshow = 3; |
@@ -264,14 +264,14 @@ discard block |
||
264 | 264 | $x = ""; |
265 | 265 | |
266 | 266 | if ($nitems <= $items_per_page) return ""; |
267 | - $npages = ceil($nitems / $items_per_page); |
|
268 | - $curpage = ceil($start / $items_per_page); |
|
267 | + $npages = ceil($nitems/$items_per_page); |
|
268 | + $curpage = ceil($start/$items_per_page); |
|
269 | 269 | |
270 | 270 | // If this is not the first page, display "previous" |
271 | 271 | // |
272 | - if ($curpage > 0){ |
|
272 | + if ($curpage > 0) { |
|
273 | 273 | $x .= page_link( |
274 | - $url, $curpage-1, $items_per_page, |
|
274 | + $url, $curpage - 1, $items_per_page, |
|
275 | 275 | tra("Previous")." · " |
276 | 276 | ); |
277 | 277 | } |
@@ -286,8 +286,8 @@ discard block |
||
286 | 286 | } |
287 | 287 | // Display a list of pages surrounding this one |
288 | 288 | // |
289 | - for ($i=$curpage-$preshow; $i<=$curpage+$postshow; $i++){ |
|
290 | - $page_str = (string)($i+1); |
|
289 | + for ($i = $curpage - $preshow; $i <= $curpage + $postshow; $i++) { |
|
290 | + $page_str = (string)($i + 1); |
|
291 | 291 | if ($i < 0) continue; |
292 | 292 | if ($i >= $npages) break; |
293 | 293 | |
@@ -296,20 +296,20 @@ discard block |
||
296 | 296 | } else { |
297 | 297 | $x .= page_link($url, $i, $items_per_page, $page_str); |
298 | 298 | } |
299 | - if ($i == $npages-1) break; |
|
300 | - if ($i == $curpage+$postshow) break; |
|
299 | + if ($i == $npages - 1) break; |
|
300 | + if ($i == $curpage + $postshow) break; |
|
301 | 301 | $x .= " · "; |
302 | 302 | } |
303 | 303 | |
304 | - if ($curpage + $postshow < $npages-1) { |
|
304 | + if ($curpage + $postshow < $npages - 1) { |
|
305 | 305 | $x .= " . . . "; |
306 | - $x .= page_link($url, $npages-1, $items_per_page, $npages); |
|
306 | + $x .= page_link($url, $npages - 1, $items_per_page, $npages); |
|
307 | 307 | } |
308 | 308 | // If there is a next page |
309 | 309 | // |
310 | - if ($curpage < $npages-1){ |
|
310 | + if ($curpage < $npages - 1) { |
|
311 | 311 | $x .= page_link( |
312 | - $url, $curpage+1, $items_per_page, |
|
312 | + $url, $curpage + 1, $items_per_page, |
|
313 | 313 | " · ".tra("Next") |
314 | 314 | ); |
315 | 315 | } |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | function cleanup_title($title) { |
331 | 331 | $x = sanitize_tags(bb2html($title)); |
332 | 332 | $x = trim($x); |
333 | - if (strlen($x)==0) return "(no title)"; |
|
333 | + if (strlen($x) == 0) return "(no title)"; |
|
334 | 334 | else return $x; |
335 | 335 | } |
336 | 336 | |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | $i = 0; |
393 | 393 | foreach ($posts as $post) { |
394 | 394 | if ($post->id == $postid) { |
395 | - $start = $i - ($i % $num_to_show); |
|
395 | + $start = $i - ($i%$num_to_show); |
|
396 | 396 | $jump_to_post = $post; |
397 | 397 | break; |
398 | 398 | } |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | // if jump to post, figure out what page to show |
420 | 420 | // |
421 | 421 | if ($jump_to_post) { |
422 | - $start = $ibest - ($ibest % $num_to_show); |
|
422 | + $start = $ibest - ($ibest%$num_to_show); |
|
423 | 423 | } else { |
424 | 424 | $start = $default_start; |
425 | 425 | } |
@@ -527,8 +527,8 @@ discard block |
||
527 | 527 | // Generates a table row with two cells: author and message |
528 | 528 | // |
529 | 529 | function show_post( |
530 | - $post, $thread, $forum, $logged_in_user, $start=0, |
|
531 | - $latest_viewed=0, $controls=FORUM_CONTROLS, $filter=true |
|
530 | + $post, $thread, $forum, $logged_in_user, $start = 0, |
|
531 | + $latest_viewed = 0, $controls = FORUM_CONTROLS, $filter = true |
|
532 | 532 | ) { |
533 | 533 | global $country_to_iso3166_2; |
534 | 534 | |
@@ -536,7 +536,7 @@ discard block |
||
536 | 536 | |
537 | 537 | // If the user no longer exists, skip the post |
538 | 538 | // |
539 | - if (!$user){ |
|
539 | + if (!$user) { |
|
540 | 540 | return; |
541 | 541 | } |
542 | 542 | |
@@ -557,9 +557,9 @@ discard block |
||
557 | 557 | // check whether the poster is on the list of people to ignore |
558 | 558 | // |
559 | 559 | $ignore_poster = false; |
560 | - if ($logged_in_user){ |
|
560 | + if ($logged_in_user) { |
|
561 | 561 | $tokens = url_tokens($logged_in_user->authenticator); |
562 | - if (is_ignoring($logged_in_user, $user)){ |
|
562 | + if (is_ignoring($logged_in_user, $user)) { |
|
563 | 563 | $ignore_poster = true; |
564 | 564 | } |
565 | 565 | } |
@@ -573,8 +573,8 @@ discard block |
||
573 | 573 | if (is_moderator($logged_in_user, $forum)) { |
574 | 574 | $can_edit = true; |
575 | 575 | } else if (can_reply($thread, $forum, $logged_in_user)) { |
576 | - $time_limit = $post->timestamp+MAXIMUM_EDIT_TIME; |
|
577 | - $can_edit = time()<$time_limit; |
|
576 | + $time_limit = $post->timestamp + MAXIMUM_EDIT_TIME; |
|
577 | + $can_edit = time() < $time_limit; |
|
578 | 578 | } else { |
579 | 579 | $can_edit = false; |
580 | 580 | } |
@@ -584,24 +584,24 @@ discard block |
||
584 | 584 | // Print the special user lines, if any |
585 | 585 | // |
586 | 586 | global $special_user_bitfield; |
587 | - $fstatus=""; |
|
587 | + $fstatus = ""; |
|
588 | 588 | $keys = array_keys($special_user_bitfield); |
589 | 589 | $is_posted_by_special = false; |
590 | - for ($i=0; $i<sizeof($special_user_bitfield);$i++) { |
|
590 | + for ($i = 0; $i < sizeof($special_user_bitfield); $i++) { |
|
591 | 591 | if ($user->prefs && $user->prefs->privilege($keys[$i])) { |
592 | - $fstatus.="<nobr>".$special_user_bitfield[$keys[$i]]."<nobr><br>"; |
|
592 | + $fstatus .= "<nobr>".$special_user_bitfield[$keys[$i]]."<nobr><br>"; |
|
593 | 593 | $is_posted_by_special = true; |
594 | 594 | } |
595 | 595 | } |
596 | 596 | |
597 | 597 | // Highlight special users if set in prefs; |
598 | 598 | // |
599 | - if ($logged_in_user && $logged_in_user->prefs){ |
|
599 | + if ($logged_in_user && $logged_in_user->prefs) { |
|
600 | 600 | $highlight = $logged_in_user->prefs->highlight_special && $is_posted_by_special; |
601 | 601 | } else { |
602 | 602 | $highlight = $is_posted_by_special; |
603 | 603 | } |
604 | - $class = $highlight?' style="border-left: 5px solid LightGreen" ':''; |
|
604 | + $class = $highlight ? ' style="border-left: 5px solid LightGreen" ' : ''; |
|
605 | 605 | |
606 | 606 | // row and start of author col |
607 | 607 | // |
@@ -613,12 +613,12 @@ discard block |
||
613 | 613 | |
614 | 614 | echo user_links($user, 0, 30); |
615 | 615 | echo "<br>"; |
616 | - if ($user->create_time > time()-ST_NEW_TIME) $fstatus.=ST_NEW."<br>"; |
|
616 | + if ($user->create_time > time() - ST_NEW_TIME) $fstatus .= ST_NEW."<br>"; |
|
617 | 617 | echo "<span class=\"small\">"; |
618 | 618 | if ($fstatus) echo "$fstatus"; |
619 | 619 | |
620 | - if (!$filter || !$ignore_poster){ |
|
621 | - if ($user->prefs && $user->prefs->avatar!="" && (!$logged_in_user || ($logged_in_user->prefs->hide_avatars==false))) { |
|
620 | + if (!$filter || !$ignore_poster) { |
|
621 | + if ($user->prefs && $user->prefs->avatar != "" && (!$logged_in_user || ($logged_in_user->prefs->hide_avatars == false))) { |
|
622 | 622 | echo "<img width=\"".AVATAR_WIDTH."\" height=\"".AVATAR_HEIGHT."\" src=\"".avatar_url($user->prefs->avatar)."\" alt=\"Avatar\"><br>"; |
623 | 623 | } |
624 | 624 | } |
@@ -626,14 +626,14 @@ discard block |
||
626 | 626 | |
627 | 627 | $url = "pm.php?action=new&userid=".$user->id; |
628 | 628 | $name = $user->name; |
629 | - show_button_small($url, tra("Send message"), tra("Send %1 a private message",$name)); |
|
629 | + show_button_small($url, tra("Send message"), tra("Send %1 a private message", $name)); |
|
630 | 630 | echo '<br>'.tra("Joined: %1", gmdate('j M y', $user->create_time)), "<br>"; |
631 | 631 | |
632 | 632 | if (!isset($user->nposts)) { |
633 | 633 | $user->nposts = BoincPost::count("user=$user->id"); |
634 | 634 | } |
635 | 635 | |
636 | - if (function_exists('project_forum_user_info')){ |
|
636 | + if (function_exists('project_forum_user_info')) { |
|
637 | 637 | project_forum_user_info($user); |
638 | 638 | } else { |
639 | 639 | echo tra("Posts: %1", $user->nposts)."<br>"; |
@@ -642,8 +642,8 @@ discard block |
||
642 | 642 | // |
643 | 643 | //echo "ID: ".$user->id."<br>"; |
644 | 644 | if (!NO_COMPUTING) { |
645 | - echo tra("Credit: %1", number_format($user->total_credit)) ."<br>"; |
|
646 | - echo tra("RAC: %1", number_format($user->expavg_credit))."<br>"; |
|
645 | + echo tra("Credit: %1", number_format($user->total_credit))."<br>"; |
|
646 | + echo tra("RAC: %1", number_format($user->expavg_credit))."<br>"; |
|
647 | 647 | } |
648 | 648 | |
649 | 649 | // to use this feature: |
@@ -672,7 +672,7 @@ discard block |
||
672 | 672 | echo "<form action=\"forum_rate.php?post=", $post->id, "\" method=\"post\">"; |
673 | 673 | } |
674 | 674 | |
675 | - if ($logged_in_user && $post->timestamp > $latest_viewed){ |
|
675 | + if ($logged_in_user && $post->timestamp > $latest_viewed) { |
|
676 | 676 | show_image(NEW_IMAGE, tra("You haven't read this message yet"), tra("Unread"), NEW_IMAGE_HEIGHT); |
677 | 677 | } |
678 | 678 | |
@@ -692,8 +692,8 @@ discard block |
||
692 | 692 | if ($post->modified) { |
693 | 693 | echo "<br>".tra("Last modified: %1", pretty_time_Str($post->modified)); |
694 | 694 | } |
695 | - if ($ignore_poster && $filter){ |
|
696 | - echo "<br>" .tra( |
|
695 | + if ($ignore_poster && $filter) { |
|
696 | + echo "<br>".tra( |
|
697 | 697 | "This post is hidden because the sender is on your 'ignore' list. Click %1 here %2 to view hidden posts", |
698 | 698 | "<a href=\"?id=".$thread->id."&filter=false&start=$start#".$post->id."\">", |
699 | 699 | "</a>" |
@@ -706,7 +706,7 @@ discard block |
||
706 | 706 | <p> |
707 | 707 | "; |
708 | 708 | |
709 | - if (!$filter || !$ignore_poster){ |
|
709 | + if (!$filter || !$ignore_poster) { |
|
710 | 710 | $posttext = $post->content; |
711 | 711 | |
712 | 712 | // If the creator of this post has a signature and |
@@ -714,7 +714,7 @@ discard block |
||
714 | 714 | // user has signatures enabled: show it |
715 | 715 | // |
716 | 716 | $posttext = output_transform($posttext, $options); |
717 | - if ($post->signature && (!$logged_in_user || !$logged_in_user->prefs->hide_signatures)){ |
|
717 | + if ($post->signature && (!$logged_in_user || !$logged_in_user->prefs->hide_signatures)) { |
|
718 | 718 | $sig = output_transform($user->prefs->signature, $options); |
719 | 719 | $posttext .= "<hr>$sig\n"; |
720 | 720 | } |
@@ -748,10 +748,10 @@ discard block |
||
748 | 748 | } |
749 | 749 | if (($controls == FORUM_CONTROLS) && (can_reply($thread, $forum, $logged_in_user))) { |
750 | 750 | echo " "; |
751 | - $url = "forum_reply.php?thread=" . $thread->id . "&post=" . $post->id . "&no_quote=1#input"; |
|
751 | + $url = "forum_reply.php?thread=".$thread->id."&post=".$post->id."&no_quote=1#input"; |
|
752 | 752 | // "Reply" is used as a verb |
753 | 753 | show_button($url, tra("Reply"), tra("Post a reply to this message")); |
754 | - $url = "forum_reply.php?thread=" . $thread->id . "&post=" . $post->id . "#input"; |
|
754 | + $url = "forum_reply.php?thread=".$thread->id."&post=".$post->id."#input"; |
|
755 | 755 | // "Quote" is used as a verb |
756 | 756 | show_button($url, tra("Quote"), tra("Post a reply by quoting this message")); |
757 | 757 | } |
@@ -773,7 +773,7 @@ discard block |
||
773 | 773 | $content = output_transform($post->content, $options); |
774 | 774 | $when = time_diff_str($post->timestamp, time()); |
775 | 775 | $user = BoincUser::lookup_id($post->user); |
776 | - if (!$user){ |
|
776 | + if (!$user) { |
|
777 | 777 | return; |
778 | 778 | } |
779 | 779 | |
@@ -787,10 +787,10 @@ discard block |
||
787 | 787 | switch ($forum->parent_type) { |
788 | 788 | case 0: |
789 | 789 | $category = BoincCategory::lookup_id($forum->category); |
790 | - $title= forum_title($category, $forum, $thread, true); |
|
790 | + $title = forum_title($category, $forum, $thread, true); |
|
791 | 791 | break; |
792 | 792 | case 1: |
793 | - $title= team_forum_title($forum); |
|
793 | + $title = team_forum_title($forum); |
|
794 | 794 | break; |
795 | 795 | } |
796 | 796 | row_array([ |
@@ -828,9 +828,9 @@ discard block |
||
828 | 828 | function post_rules() { |
829 | 829 | if (defined('FORUM_RULES')) return FORUM_RULES; |
830 | 830 | if (function_exists("project_forum_post_rules")) { |
831 | - $project_rules=project_forum_post_rules(); |
|
831 | + $project_rules = project_forum_post_rules(); |
|
832 | 832 | } else { |
833 | - $project_rules=""; |
|
833 | + $project_rules = ""; |
|
834 | 834 | } |
835 | 835 | return sprintf(" |
836 | 836 | <ul> |
@@ -859,7 +859,7 @@ discard block |
||
859 | 859 | ); |
860 | 860 | } |
861 | 861 | |
862 | -function post_warning($forum=null) { |
|
862 | +function post_warning($forum = null) { |
|
863 | 863 | $x = '<p><div style="text-align:left">'; |
864 | 864 | |
865 | 865 | // let projects add extra instructions in specific forums, |
@@ -945,7 +945,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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; |
@@ -1125,22 +1125,22 @@ discard block |
||
1125 | 1125 | // $sticky - bool (not directly passed to SQL) |
1126 | 1126 | // |
1127 | 1127 | function get_forum_threads( |
1128 | - $forumID, $start=-1, $nRec=-1, $sort_style=MODIFIED_NEW, |
|
1128 | + $forumID, $start = -1, $nRec = -1, $sort_style = MODIFIED_NEW, |
|
1129 | 1129 | $show_hidden = 0, $sticky = 1 |
1130 | 1130 | ) { |
1131 | 1131 | //if (! (is_numeric($forumID) && is_numeric($min) && is_numeric($nRec))) { |
1132 | 1132 | // return NULL; // Something is wrong here. |
1133 | 1133 | //} |
1134 | 1134 | |
1135 | - $sql = 'forum = ' . $forumID ; |
|
1135 | + $sql = 'forum = '.$forumID; |
|
1136 | 1136 | $stickysql = ""; |
1137 | - if ($sticky){ |
|
1137 | + if ($sticky) { |
|
1138 | 1138 | $stickysql = "sticky DESC, "; |
1139 | 1139 | } |
1140 | 1140 | if (!$show_hidden) { |
1141 | 1141 | $sql .= ' AND hidden = 0'; |
1142 | 1142 | } |
1143 | - switch($sort_style) { |
|
1143 | + switch ($sort_style) { |
|
1144 | 1144 | case MODIFIED_NEW: |
1145 | 1145 | $sql .= ' ORDER BY '.$stickysql.'timestamp DESC'; |
1146 | 1146 | break; |
@@ -1193,7 +1193,7 @@ discard block |
||
1193 | 1193 | if (!$show_hidden) { |
1194 | 1194 | $sql .= ' AND hidden = 0'; |
1195 | 1195 | } |
1196 | - switch($sort_style) { |
|
1196 | + switch ($sort_style) { |
|
1197 | 1197 | case CREATE_TIME_NEW: |
1198 | 1198 | $sql .= ' ORDER BY timestamp desc'; |
1199 | 1199 | break; |
@@ -1215,7 +1215,7 @@ discard block |
||
1215 | 1215 | // |
1216 | 1216 | function show_post_moderation_links( |
1217 | 1217 | $config, $logged_in_user, $post, $forum, $tokens |
1218 | -){ |
|
1218 | +) { |
|
1219 | 1219 | $moderators_allowed_to_ban = parse_bool($config, "moderators_allowed_to_ban"); |
1220 | 1220 | $moderators_vote_to_ban = parse_bool($config, "moderators_vote_to_ban"); |
1221 | 1221 | |
@@ -1278,9 +1278,9 @@ discard block |
||
1278 | 1278 | // |
1279 | 1279 | function user_can_create_thread($user, $forum) { |
1280 | 1280 | if ($forum->is_dev_blog) { |
1281 | - return is_admin($user)?'yes':'no'; |
|
1281 | + return is_admin($user) ? 'yes' : 'no'; |
|
1282 | 1282 | } |
1283 | - return $user ?'yes':'login'; |
|
1283 | + return $user ? 'yes' : 'login'; |
|
1284 | 1284 | } |
1285 | 1285 | |
1286 | 1286 | function check_post_access($user, $forum) { |
@@ -1306,14 +1306,14 @@ discard block |
||
1306 | 1306 | // We do not tell the (ab)user how much this is - |
1307 | 1307 | // no need to make it easy for them to break the system. |
1308 | 1308 | // |
1309 | - if ($user->total_credit<$forum->post_min_total_credit || $user->expavg_credit<$forum->post_min_expavg_credit) { |
|
1309 | + if ($user->total_credit < $forum->post_min_total_credit || $user->expavg_credit < $forum->post_min_expavg_credit) { |
|
1310 | 1310 | 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)); |
1311 | 1311 | } |
1312 | 1312 | |
1313 | 1313 | // If the user is posting faster than forum regulations allow |
1314 | 1314 | // Tell the user to wait a while before creating any more posts |
1315 | 1315 | // |
1316 | - if (time()-$user->prefs->last_post <$forum->post_min_interval) { |
|
1316 | + if (time() - $user->prefs->last_post < $forum->post_min_interval) { |
|
1317 | 1317 | error_page(tra("You cannot create threads right now. Please wait before trying again. This is to protect against abuse of the system.")); |
1318 | 1318 | } |
1319 | 1319 | } |
@@ -1339,10 +1339,10 @@ discard block |
||
1339 | 1339 | // - edit their posts at any time |
1340 | 1340 | // - hide/unhide/move threads and posts |
1341 | 1341 | |
1342 | -function is_moderator($user, $forum=null) { |
|
1342 | +function is_moderator($user, $forum = null) { |
|
1343 | 1343 | if (!$user) return false; |
1344 | 1344 | BoincForumPrefs::lookup($user); |
1345 | - $type = $forum?$forum->parent_type:0; |
|
1345 | + $type = $forum ? $forum->parent_type : 0; |
|
1346 | 1346 | switch ($type) { |
1347 | 1347 | case 0: |
1348 | 1348 | if ($user->prefs->privilege(S_MODERATOR)) return true; |
@@ -1359,7 +1359,7 @@ discard block |
||
1359 | 1359 | return false; |
1360 | 1360 | } |
1361 | 1361 | |
1362 | -function thread_list_header($subscriptions=false) { |
|
1362 | +function thread_list_header($subscriptions = false) { |
|
1363 | 1363 | if ($subscriptions) { |
1364 | 1364 | $x = [ |
1365 | 1365 | tra("Thread"), |
@@ -1382,13 +1382,13 @@ discard block |
||
1382 | 1382 | // show a 1-line summary of thread and its forum. |
1383 | 1383 | // Used for search results and subscription list |
1384 | 1384 | // |
1385 | -function thread_list_item($thread, $user, $subscriptions=false) { |
|
1385 | +function thread_list_item($thread, $user, $subscriptions = false) { |
|
1386 | 1386 | $thread_forum = BoincForum::lookup_id($thread->forum); |
1387 | 1387 | if (!$thread_forum) return; |
1388 | 1388 | if (!is_forum_visible_to_user($thread_forum, $user)) return; |
1389 | 1389 | $owner = BoincUser::lookup_id($thread->owner); |
1390 | 1390 | if (!$owner) return; |
1391 | - switch($thread_forum->parent_type) { |
|
1391 | + switch ($thread_forum->parent_type) { |
|
1392 | 1392 | case 0: |
1393 | 1393 | $category = BoincCategory::lookup_id($thread_forum->category); |
1394 | 1394 | $title = forum_title($category, $thread_forum, $thread, true); |
@@ -1409,7 +1409,7 @@ discard block |
||
1409 | 1409 | } else { |
1410 | 1410 | $x = [ |
1411 | 1411 | $title, |
1412 | - $thread->replies+1, |
|
1412 | + $thread->replies + 1, |
|
1413 | 1413 | user_links($owner), |
1414 | 1414 | $thread->views, |
1415 | 1415 | time_diff_str($thread->timestamp, time()) |
@@ -1446,13 +1446,13 @@ discard block |
||
1446 | 1446 | |
1447 | 1447 | function subscribed_thread_web_line($notify) { |
1448 | 1448 | $thread = BoincThread::lookup_id($notify->opaque); |
1449 | - return tra("New posts in the thread %1","<a href=forum_thread.php?id=$thread->id>$thread->title</a>"); |
|
1449 | + return tra("New posts in the thread %1", "<a href=forum_thread.php?id=$thread->id>$thread->title</a>"); |
|
1450 | 1450 | } |
1451 | 1451 | |
1452 | 1452 | function subscribed_thread_rss($notify) { |
1453 | 1453 | $thread = BoincThread::lookup_id($notify->opaque); |
1454 | 1454 | $title = tra("New posts in subscribed thread"); |
1455 | - $msg = tra("There are new posts in the thread '%1'",$thread->title); |
|
1455 | + $msg = tra("There are new posts in the thread '%1'", $thread->title); |
|
1456 | 1456 | $url = secure_url_base()."forum_thread.php?id=$thread->id"; |
1457 | 1457 | return [$title, $msg, $url]; |
1458 | 1458 | } |
@@ -1464,13 +1464,13 @@ discard block |
||
1464 | 1464 | |
1465 | 1465 | function subscribed_forum_web_line($notify) { |
1466 | 1466 | $forum = BoincForum::lookup_id($notify->opaque); |
1467 | - return tra("New threads in the forum %1","<a href=forum_forum.php?id=$forum->id>$forum->title</a>"); |
|
1467 | + return tra("New threads in the forum %1", "<a href=forum_forum.php?id=$forum->id>$forum->title</a>"); |
|
1468 | 1468 | } |
1469 | 1469 | |
1470 | 1470 | function subscribed_forum_rss($notify) { |
1471 | 1471 | $forum = BoincForum::lookup_id($notify->opaque); |
1472 | 1472 | $title = tra("New posts in subscribed forum"); |
1473 | - $msg = tra("There are new threads in the forum '%1'",$forum->title); |
|
1473 | + $msg = tra("There are new threads in the forum '%1'", $forum->title); |
|
1474 | 1474 | $url = secure_url_base()."forum_forum.php?id=$forum->id"; |
1475 | 1475 | return [$title, $msg, $url]; |
1476 | 1476 | } |