@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | |
73 | 73 | echo ' |
74 | 74 | <div class="main_container"> |
75 | - <div class="cat_bar ', $category['is_collapsed'] ? 'collapsed' : '','" id="category_', $category['id'], '"> |
|
75 | + <div class="cat_bar ', $category['is_collapsed'] ? 'collapsed' : '', '" id="category_', $category['id'], '"> |
|
76 | 76 | <h3 class="catbg">'; |
77 | 77 | |
78 | 78 | // If this category even can collapse, show a link to collapse it. |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | foreach ($board['children'] as $child) |
248 | 248 | { |
249 | 249 | if (!$child['is_redirect']) |
250 | - $child['link'] = ''. ($child['new'] ? '<a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')"><span class="new_posts">' . $txt['new'] . '</span></a>' : '') . '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . '</a>'; |
|
250 | + $child['link'] = '' . ($child['new'] ? '<a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')"><span class="new_posts">' . $txt['new'] . '</span></a>' : '') . '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . '</a>'; |
|
251 | 251 | else |
252 | 252 | $child['link'] = '<a href="' . $child['href'] . '" title="' . comma_format($child['posts']) . ' ' . $txt['redirects'] . ' - ' . $child['short_description'] . '">' . $child['name'] . '</a>'; |
253 | 253 |
@@ -67,8 +67,9 @@ discard block |
||
67 | 67 | foreach ($context['categories'] as $category) |
68 | 68 | { |
69 | 69 | // If theres no parent boards we can see, avoid showing an empty category (unless its collapsed) |
70 | - if (empty($category['boards']) && !$category['is_collapsed']) |
|
71 | - continue; |
|
70 | + if (empty($category['boards']) && !$category['is_collapsed']) { |
|
71 | + continue; |
|
72 | + } |
|
72 | 73 | |
73 | 74 | echo ' |
74 | 75 | <div class="main_container"> |
@@ -76,9 +77,10 @@ discard block |
||
76 | 77 | <h3 class="catbg">'; |
77 | 78 | |
78 | 79 | // If this category even can collapse, show a link to collapse it. |
79 | - if ($category['can_collapse']) |
|
80 | - echo ' |
|
80 | + if ($category['can_collapse']) { |
|
81 | + echo ' |
|
81 | 82 | <span id="category_', $category['id'], '_upshrink" class="', $category['is_collapsed'] ? 'toggle_down' : 'toggle_up', ' floatright" data-collapsed="', (int) $category['is_collapsed'], '" title="', !$category['is_collapsed'] ? $txt['hide_category'] : $txt['show_category'], '" style="display: none;"></span>'; |
83 | + } |
|
82 | 84 | |
83 | 85 | echo ' |
84 | 86 | ', $category['link'], ' |
@@ -108,10 +110,11 @@ discard block |
||
108 | 110 | </div>'; |
109 | 111 | |
110 | 112 | // Won't somebody think of the children! |
111 | - if (function_exists('template_bi_' . $board['type'] . '_children')) |
|
112 | - call_user_func('template_bi_' . $board['type'] . '_children', $board); |
|
113 | - else |
|
114 | - template_bi_board_children($board); |
|
113 | + if (function_exists('template_bi_' . $board['type'] . '_children')) { |
|
114 | + call_user_func('template_bi_' . $board['type'] . '_children', $board); |
|
115 | + } else { |
|
116 | + template_bi_board_children($board); |
|
117 | + } |
|
115 | 118 | |
116 | 119 | echo ' |
117 | 120 | </div><!-- #board_[id] -->'; |
@@ -126,12 +129,13 @@ discard block |
||
126 | 129 | </div><!-- #boardindex_table -->'; |
127 | 130 | |
128 | 131 | // Show the mark all as read button? |
129 | - if ($context['user']['is_logged'] && !empty($context['categories'])) |
|
130 | - echo ' |
|
132 | + if ($context['user']['is_logged'] && !empty($context['categories'])) { |
|
133 | + echo ' |
|
131 | 134 | <div class="mark_read"> |
132 | 135 | ', template_button_strip($context['mark_read_button'], 'right'), ' |
133 | 136 | </div>'; |
134 | -} |
|
137 | + } |
|
138 | + } |
|
135 | 139 | |
136 | 140 | /** |
137 | 141 | * Outputs the board icon for a standard board. |
@@ -175,18 +179,20 @@ discard block |
||
175 | 179 | </a>'; |
176 | 180 | |
177 | 181 | // Has it outstanding posts for approval? |
178 | - if ($board['can_approve_posts'] && ($board['unapproved_posts'] || $board['unapproved_topics'])) |
|
179 | - echo ' |
|
182 | + if ($board['can_approve_posts'] && ($board['unapproved_posts'] || $board['unapproved_topics'])) { |
|
183 | + echo ' |
|
180 | 184 | <a href="', $scripturl, '?action=moderate;area=postmod;sa=', ($board['unapproved_topics'] > 0 ? 'topics' : 'posts'), ';brd=', $board['id'], ';', $context['session_var'], '=', $context['session_id'], '" title="', sprintf($txt['unapproved_posts'], $board['unapproved_topics'], $board['unapproved_posts']), '" class="moderation_link">(!)</a>'; |
185 | + } |
|
181 | 186 | |
182 | 187 | echo ' |
183 | 188 | <p class="board_description">', $board['description'], '</p>'; |
184 | 189 | |
185 | 190 | // Show the "Moderators: ". Each has name, href, link, and id. (but we're gonna use link_moderators.) |
186 | - if (!empty($board['link_moderators'])) |
|
187 | - echo ' |
|
191 | + if (!empty($board['link_moderators'])) { |
|
192 | + echo ' |
|
188 | 193 | <p class="moderators">', count($board['link_moderators']) == 1 ? $txt['moderator'] : $txt['moderators'], ': ', implode(', ', $board['link_moderators']), '</p>'; |
189 | -} |
|
194 | + } |
|
195 | + } |
|
190 | 196 | |
191 | 197 | /** |
192 | 198 | * Outputs the board stats for a standard board. |
@@ -227,10 +233,11 @@ discard block |
||
227 | 233 | */ |
228 | 234 | function template_bi_board_lastpost($board) |
229 | 235 | { |
230 | - if (!empty($board['last_post']['id'])) |
|
231 | - echo ' |
|
236 | + if (!empty($board['last_post']['id'])) { |
|
237 | + echo ' |
|
232 | 238 | <p>', $board['last_post']['last_post_message'], '</p>'; |
233 | -} |
|
239 | + } |
|
240 | + } |
|
234 | 241 | |
235 | 242 | /** |
236 | 243 | * Outputs the board children for a standard board. |
@@ -251,14 +258,16 @@ discard block |
||
251 | 258 | id, name, description, new (is it new?), topics (#), posts (#), href, link, and last_post. */ |
252 | 259 | foreach ($board['children'] as $child) |
253 | 260 | { |
254 | - if (!$child['is_redirect']) |
|
255 | - $child['link'] = ''. ($child['new'] ? '<a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')"><span class="new_posts">' . $txt['new'] . '</span></a>' : '') . '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . '</a>'; |
|
256 | - else |
|
257 | - $child['link'] = '<a href="' . $child['href'] . '" title="' . comma_format($child['posts']) . ' ' . $txt['redirects'] . ' - ' . $child['short_description'] . '">' . $child['name'] . '</a>'; |
|
261 | + if (!$child['is_redirect']) { |
|
262 | + $child['link'] = ''. ($child['new'] ? '<a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')"><span class="new_posts">' . $txt['new'] . '</span></a>' : '') . '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . '</a>'; |
|
263 | + } else { |
|
264 | + $child['link'] = '<a href="' . $child['href'] . '" title="' . comma_format($child['posts']) . ' ' . $txt['redirects'] . ' - ' . $child['short_description'] . '">' . $child['name'] . '</a>'; |
|
265 | + } |
|
258 | 266 | |
259 | 267 | // Has it posts awaiting approval? |
260 | - if ($child['can_approve_posts'] && ($child['unapproved_posts'] || $child['unapproved_topics'])) |
|
261 | - $child['link'] .= ' <a href="' . $scripturl . '?action=moderate;area=postmod;sa=' . ($child['unapproved_topics'] > 0 ? 'topics' : 'posts') . ';brd=' . $child['id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" title="' . sprintf($txt['unapproved_posts'], $child['unapproved_topics'], $child['unapproved_posts']) . '" class="moderation_link">(!)</a>'; |
|
268 | + if ($child['can_approve_posts'] && ($child['unapproved_posts'] || $child['unapproved_topics'])) { |
|
269 | + $child['link'] .= ' <a href="' . $scripturl . '?action=moderate;area=postmod;sa=' . ($child['unapproved_topics'] > 0 ? 'topics' : 'posts') . ';brd=' . $child['id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" title="' . sprintf($txt['unapproved_posts'], $child['unapproved_topics'], $child['unapproved_posts']) . '" class="moderation_link">(!)</a>'; |
|
270 | + } |
|
262 | 271 | |
263 | 272 | $children[] = $child['new'] ? '<span class="strong">' . $child['link'] . '</span>' : '<span>' . $child['link'] . '</span>'; |
264 | 273 | } |
@@ -285,8 +294,9 @@ discard block |
||
285 | 294 | { |
286 | 295 | global $context, $options, $txt; |
287 | 296 | |
288 | - if (empty($context['info_center'])) |
|
289 | - return; |
|
297 | + if (empty($context['info_center'])) { |
|
298 | + return; |
|
299 | + } |
|
290 | 300 | |
291 | 301 | // Here's where the "Info Center" starts... |
292 | 302 | echo ' |
@@ -386,14 +396,15 @@ discard block |
||
386 | 396 | /* Each post in latest_posts has: |
387 | 397 | board (with an id, name, and link.), topic (the topic's id.), poster (with id, name, and link.), |
388 | 398 | subject, short_subject (shortened with...), time, link, and href. */ |
389 | - foreach ($context['latest_posts'] as $post) |
|
390 | - echo ' |
|
399 | + foreach ($context['latest_posts'] as $post) { |
|
400 | + echo ' |
|
391 | 401 | <tr class="windowbg"> |
392 | 402 | <td class="recentpost"><strong>', $post['link'], '</strong></td> |
393 | 403 | <td class="recentposter">', $post['poster']['link'], '</td> |
394 | 404 | <td class="recentboard">', $post['board']['link'], '</td> |
395 | 405 | <td class="recenttime">', $post['time'], '</td> |
396 | 406 | </tr>'; |
407 | + } |
|
397 | 408 | echo ' |
398 | 409 | </table>'; |
399 | 410 | } |
@@ -417,11 +428,12 @@ discard block |
||
417 | 428 | </div>'; |
418 | 429 | |
419 | 430 | // Holidays like "Christmas", "Chanukah", and "We Love [Unknown] Day" :P |
420 | - if (!empty($context['calendar_holidays'])) |
|
421 | - echo ' |
|
431 | + if (!empty($context['calendar_holidays'])) { |
|
432 | + echo ' |
|
422 | 433 | <p class="inline holiday"> |
423 | 434 | <span>', $txt['calendar_prompt'], '</span> ', implode(', ', $context['calendar_holidays']), ' |
424 | 435 | </p>'; |
436 | + } |
|
425 | 437 | |
426 | 438 | // People's birthdays. Like mine. And yours, I guess. Kidding. |
427 | 439 | if (!empty($context['calendar_birthdays'])) |
@@ -431,9 +443,10 @@ discard block |
||
431 | 443 | <span class="birthday">', $context['calendar_only_today'] ? $txt['birthdays'] : $txt['birthdays_upcoming'], '</span>'; |
432 | 444 | |
433 | 445 | // Each member in calendar_birthdays has: id, name (person), age (if they have one set?), is_last. (last in list?), and is_today (birthday is today?) |
434 | - foreach ($context['calendar_birthdays'] as $member) |
|
435 | - echo ' |
|
446 | + foreach ($context['calendar_birthdays'] as $member) { |
|
447 | + echo ' |
|
436 | 448 | <a href="', $scripturl, '?action=profile;u=', $member['id'], '">', $member['is_today'] ? '<strong class="fix_rtl_names">' : '', $member['name'], $member['is_today'] ? '</strong>' : '', isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a>', $member['is_last'] ? '' : ', '; |
449 | + } |
|
437 | 450 | |
438 | 451 | echo ' |
439 | 452 | </p>'; |
@@ -448,9 +461,10 @@ discard block |
||
448 | 461 | |
449 | 462 | // Each event in calendar_events should have: |
450 | 463 | // title, href, is_last, can_edit (are they allowed?), modify_href, and is_today. |
451 | - foreach ($context['calendar_events'] as $event) |
|
452 | - echo ' |
|
464 | + foreach ($context['calendar_events'] as $event) { |
|
465 | + echo ' |
|
453 | 466 | ', $event['can_edit'] ? '<a href="' . $event['modify_href'] . '" title="' . $txt['calendar_edit'] . '"><span class="generic_icons calendar_modify"></span></a> ' : '', $event['href'] == '' ? '' : '<a href="' . $event['href'] . '">', $event['is_today'] ? '<strong>' . $event['title'] . '</strong>' : $event['title'], $event['href'] == '' ? '' : '</a>', $event['is_last'] ? '<br>' : ', '; |
467 | + } |
|
454 | 468 | echo ' |
455 | 469 | </p>'; |
456 | 470 | } |
@@ -496,15 +510,19 @@ discard block |
||
496 | 510 | // Handle hidden users and buddies. |
497 | 511 | $bracketList = array(); |
498 | 512 | |
499 | - if ($context['show_buddies']) |
|
500 | - $bracketList[] = comma_format($context['num_buddies']) . ' ' . ($context['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']); |
|
501 | - if (!empty($context['num_spiders'])) |
|
502 | - $bracketList[] = comma_format($context['num_spiders']) . ' ' . ($context['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']); |
|
503 | - if (!empty($context['num_users_hidden'])) |
|
504 | - $bracketList[] = comma_format($context['num_users_hidden']) . ' ' . ($context['num_spiders'] == 1 ? $txt['hidden'] : $txt['hidden_s']); |
|
513 | + if ($context['show_buddies']) { |
|
514 | + $bracketList[] = comma_format($context['num_buddies']) . ' ' . ($context['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']); |
|
515 | + } |
|
516 | + if (!empty($context['num_spiders'])) { |
|
517 | + $bracketList[] = comma_format($context['num_spiders']) . ' ' . ($context['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']); |
|
518 | + } |
|
519 | + if (!empty($context['num_users_hidden'])) { |
|
520 | + $bracketList[] = comma_format($context['num_users_hidden']) . ' ' . ($context['num_spiders'] == 1 ? $txt['hidden'] : $txt['hidden_s']); |
|
521 | + } |
|
505 | 522 | |
506 | - if (!empty($bracketList)) |
|
507 | - echo ' (' . implode(', ', $bracketList) . ')'; |
|
523 | + if (!empty($bracketList)) { |
|
524 | + echo ' (' . implode(', ', $bracketList) . ')'; |
|
525 | + } |
|
508 | 526 | |
509 | 527 | echo $context['show_who'] ? '</a>' : '', ' |
510 | 528 | |
@@ -518,9 +536,10 @@ discard block |
||
518 | 536 | ', sprintf($txt['users_active'], $modSettings['lastActive']), ': ', implode(', ', $context['list_users_online']); |
519 | 537 | |
520 | 538 | // Showing membergroups? |
521 | - if (!empty($settings['show_group_key']) && !empty($context['membergroups'])) |
|
522 | - echo ' |
|
539 | + if (!empty($settings['show_group_key']) && !empty($context['membergroups'])) { |
|
540 | + echo ' |
|
523 | 541 | <span class="membergroups">' . implode(', ', $context['membergroups']) . '</span>'; |
542 | + } |
|
524 | 543 | } |
525 | 544 | |
526 | 545 | echo ' |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 4 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * Show the list of topics in this board, along with any child boards. |
@@ -56,8 +57,9 @@ discard block |
||
56 | 57 | |
57 | 58 | $context['name'] = $board_info['name']; |
58 | 59 | $context['description'] = $board_info['description']; |
59 | - if (!empty($board_info['description'])) |
|
60 | - $context['meta_description'] = strip_tags($board_info['description']); |
|
60 | + if (!empty($board_info['description'])) { |
|
61 | + $context['meta_description'] = strip_tags($board_info['description']); |
|
62 | + } |
|
61 | 63 | |
62 | 64 | // How many topics do we have in total? |
63 | 65 | $board_info['total_topics'] = allowedTo('approve_posts') ? $board_info['num_topics'] + $board_info['unapproved_topics'] : $board_info['num_topics'] + $board_info['unapproved_user_topics']; |
@@ -73,12 +75,14 @@ discard block |
||
73 | 75 | $session_name = session_name(); |
74 | 76 | foreach ($_GET as $k => $v) |
75 | 77 | { |
76 | - if (!in_array($k, array('board', 'start', $session_name))) |
|
77 | - $context['robot_no_index'] = true; |
|
78 | + if (!in_array($k, array('board', 'start', $session_name))) { |
|
79 | + $context['robot_no_index'] = true; |
|
80 | + } |
|
78 | 81 | } |
79 | 82 | } |
80 | - if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) |
|
81 | - $context['robot_no_index'] = true; |
|
83 | + if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) { |
|
84 | + $context['robot_no_index'] = true; |
|
85 | + } |
|
82 | 86 | |
83 | 87 | // If we can view unapproved messages and there are some build up a list. |
84 | 88 | if (allowedTo('approve_posts') && ($board_info['unapproved_topics'] || $board_info['unapproved_posts'])) |
@@ -89,14 +93,16 @@ discard block |
||
89 | 93 | } |
90 | 94 | |
91 | 95 | // We only know these. |
92 | - if (isset($_REQUEST['sort']) && !in_array($_REQUEST['sort'], array('subject', 'starter', 'last_poster', 'replies', 'views', 'first_post', 'last_post'))) |
|
93 | - $_REQUEST['sort'] = 'last_post'; |
|
96 | + if (isset($_REQUEST['sort']) && !in_array($_REQUEST['sort'], array('subject', 'starter', 'last_poster', 'replies', 'views', 'first_post', 'last_post'))) { |
|
97 | + $_REQUEST['sort'] = 'last_post'; |
|
98 | + } |
|
94 | 99 | |
95 | 100 | // Make sure the starting place makes sense and construct the page index. |
96 | - if (isset($_REQUEST['sort'])) |
|
97 | - $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d;sort=' . $_REQUEST['sort'] . (isset($_REQUEST['desc']) ? ';desc' : ''), $_REQUEST['start'], $board_info['total_topics'], $context['maxindex'], true); |
|
98 | - else |
|
99 | - $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d', $_REQUEST['start'], $board_info['total_topics'], $context['maxindex'], true); |
|
101 | + if (isset($_REQUEST['sort'])) { |
|
102 | + $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d;sort=' . $_REQUEST['sort'] . (isset($_REQUEST['desc']) ? ';desc' : ''), $_REQUEST['start'], $board_info['total_topics'], $context['maxindex'], true); |
|
103 | + } else { |
|
104 | + $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d', $_REQUEST['start'], $board_info['total_topics'], $context['maxindex'], true); |
|
105 | + } |
|
100 | 106 | $context['start'] = &$_REQUEST['start']; |
101 | 107 | |
102 | 108 | // Set a canonical URL for this page. |
@@ -132,14 +138,16 @@ discard block |
||
132 | 138 | $context['link_moderators'] = array(); |
133 | 139 | if (!empty($board_info['moderators'])) |
134 | 140 | { |
135 | - foreach ($board_info['moderators'] as $mod) |
|
136 | - $context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>'; |
|
141 | + foreach ($board_info['moderators'] as $mod) { |
|
142 | + $context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>'; |
|
143 | + } |
|
137 | 144 | } |
138 | 145 | if (!empty($board_info['moderator_groups'])) |
139 | 146 | { |
140 | 147 | // By default just tack the moderator groups onto the end of the members |
141 | - foreach ($board_info['moderator_groups'] as $mod_group) |
|
142 | - $context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>'; |
|
148 | + foreach ($board_info['moderator_groups'] as $mod_group) { |
|
149 | + $context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>'; |
|
150 | + } |
|
143 | 151 | } |
144 | 152 | |
145 | 153 | // Now we tack the info onto the end of the linktree |
@@ -191,20 +199,24 @@ discard block |
||
191 | 199 | ); |
192 | 200 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
193 | 201 | { |
194 | - if (empty($row['id_member'])) |
|
195 | - continue; |
|
202 | + if (empty($row['id_member'])) { |
|
203 | + continue; |
|
204 | + } |
|
196 | 205 | |
197 | - if (!empty($row['online_color'])) |
|
198 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
199 | - else |
|
200 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
206 | + if (!empty($row['online_color'])) { |
|
207 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
208 | + } else { |
|
209 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
210 | + } |
|
201 | 211 | |
202 | 212 | $is_buddy = in_array($row['id_member'], $user_info['buddies']); |
203 | - if ($is_buddy) |
|
204 | - $link = '<strong>' . $link . '</strong>'; |
|
213 | + if ($is_buddy) { |
|
214 | + $link = '<strong>' . $link . '</strong>'; |
|
215 | + } |
|
205 | 216 | |
206 | - if (!empty($row['show_online']) || allowedTo('moderate_forum')) |
|
207 | - $context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
|
217 | + if (!empty($row['show_online']) || allowedTo('moderate_forum')) { |
|
218 | + $context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
|
219 | + } |
|
208 | 220 | // @todo why are we filling this array of data that are just counted (twice) and discarded? ??? |
209 | 221 | $context['view_members'][$row['log_time'] . $row['member_name']] = array( |
210 | 222 | 'id' => $row['id_member'], |
@@ -217,8 +229,9 @@ discard block |
||
217 | 229 | 'hidden' => empty($row['show_online']), |
218 | 230 | ); |
219 | 231 | |
220 | - if (empty($row['show_online'])) |
|
221 | - $context['view_num_hidden']++; |
|
232 | + if (empty($row['show_online'])) { |
|
233 | + $context['view_num_hidden']++; |
|
234 | + } |
|
222 | 235 | } |
223 | 236 | $context['view_num_guests'] = $smcFunc['db_num_rows']($request) - count($context['view_members']); |
224 | 237 | $smcFunc['db_free_result']($request); |
@@ -260,8 +273,9 @@ discard block |
||
260 | 273 | // Bring in any changes we want to make before the query. |
261 | 274 | call_integration_hook('integrate_pre_messageindex', array(&$sort_methods)); |
262 | 275 | |
263 | - foreach ($sort_methods as $key => $val) |
|
264 | - $context['topics_headers'][$key] = '<a href="' . $scripturl . '?board=' . $context['current_board'] . '.' . $context['start'] . ';sort=' . $key . ($context['sort_by'] == $key && $context['sort_direction'] == 'up' ? ';desc' : '') . '">' . $txt[$key] . ($context['sort_by'] == $key ? '<span class="sort sort_' . $context['sort_direction'] . '"></span>' : '') . '</a>'; |
|
276 | + foreach ($sort_methods as $key => $val) { |
|
277 | + $context['topics_headers'][$key] = '<a href="' . $scripturl . '?board=' . $context['current_board'] . '.' . $context['start'] . ';sort=' . $key . ($context['sort_by'] == $key && $context['sort_direction'] == 'up' ? ';desc' : '') . '">' . $txt[$key] . ($context['sort_by'] == $key ? '<span class="sort sort_' . $context['sort_direction'] . '"></span>' : '') . '</a>'; |
|
278 | + } |
|
265 | 279 | |
266 | 280 | // Calculate the fastest way to get the topics. |
267 | 281 | $start = (int) $_REQUEST['start']; |
@@ -271,14 +285,15 @@ discard block |
||
271 | 285 | $fake_ascending = true; |
272 | 286 | $context['maxindex'] = $board_info['total_topics'] < $start + $context['maxindex'] + 1 ? $board_info['total_topics'] - $start : $context['maxindex']; |
273 | 287 | $start = $board_info['total_topics'] < $start + $context['maxindex'] + 1 ? 0 : $board_info['total_topics'] - $start - $context['maxindex']; |
288 | + } else { |
|
289 | + $fake_ascending = false; |
|
274 | 290 | } |
275 | - else |
|
276 | - $fake_ascending = false; |
|
277 | 291 | |
278 | 292 | // Setup the default topic icons... |
279 | 293 | $context['icon_sources'] = array(); |
280 | - foreach ($context['stable_icons'] as $icon) |
|
281 | - $context['icon_sources'][$icon] = 'images_url'; |
|
294 | + foreach ($context['stable_icons'] as $icon) { |
|
295 | + $context['icon_sources'][$icon] = 'images_url'; |
|
296 | + } |
|
282 | 297 | |
283 | 298 | $topic_ids = array(); |
284 | 299 | $context['topics'] = array(); |
@@ -316,8 +331,9 @@ discard block |
||
316 | 331 | $message_pre_index_parameters |
317 | 332 | ); |
318 | 333 | $topic_ids = array(); |
319 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
320 | - $topic_ids[] = $row['id_topic']; |
|
334 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
335 | + $topic_ids[] = $row['id_topic']; |
|
336 | + } |
|
321 | 337 | } |
322 | 338 | |
323 | 339 | // Grab the appropriate topic information... |
@@ -375,11 +391,13 @@ discard block |
||
375 | 391 | // Begin 'printing' the message index for current board. |
376 | 392 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
377 | 393 | { |
378 | - if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') |
|
379 | - continue; |
|
394 | + if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') { |
|
395 | + continue; |
|
396 | + } |
|
380 | 397 | |
381 | - if (!$pre_query) |
|
382 | - $topic_ids[] = $row['id_topic']; |
|
398 | + if (!$pre_query) { |
|
399 | + $topic_ids[] = $row['id_topic']; |
|
400 | + } |
|
383 | 401 | |
384 | 402 | // Reference the main color class. |
385 | 403 | $colorClass = 'windowbg'; |
@@ -389,8 +407,9 @@ discard block |
||
389 | 407 | { |
390 | 408 | // Limit them to $modSettings['preview_characters'] characters |
391 | 409 | $row['first_body'] = strip_tags(strtr(parse_bbc($row['first_body'], $row['first_smileys'], $row['id_first_msg']), array('<br>' => ' '))); |
392 | - if ($smcFunc['strlen']($row['first_body']) > $modSettings['preview_characters']) |
|
393 | - $row['first_body'] = $smcFunc['substr']($row['first_body'], 0, $modSettings['preview_characters']) . '...'; |
|
410 | + if ($smcFunc['strlen']($row['first_body']) > $modSettings['preview_characters']) { |
|
411 | + $row['first_body'] = $smcFunc['substr']($row['first_body'], 0, $modSettings['preview_characters']) . '...'; |
|
412 | + } |
|
394 | 413 | |
395 | 414 | // Censor the subject and message preview. |
396 | 415 | censorText($row['first_subject']); |
@@ -401,27 +420,27 @@ discard block |
||
401 | 420 | { |
402 | 421 | $row['last_subject'] = $row['first_subject']; |
403 | 422 | $row['last_body'] = $row['first_body']; |
404 | - } |
|
405 | - else |
|
423 | + } else |
|
406 | 424 | { |
407 | 425 | $row['last_body'] = strip_tags(strtr(parse_bbc($row['last_body'], $row['last_smileys'], $row['id_last_msg']), array('<br>' => ' '))); |
408 | - if ($smcFunc['strlen']($row['last_body']) > $modSettings['preview_characters']) |
|
409 | - $row['last_body'] = $smcFunc['substr']($row['last_body'], 0, $modSettings['preview_characters']) . '...'; |
|
426 | + if ($smcFunc['strlen']($row['last_body']) > $modSettings['preview_characters']) { |
|
427 | + $row['last_body'] = $smcFunc['substr']($row['last_body'], 0, $modSettings['preview_characters']) . '...'; |
|
428 | + } |
|
410 | 429 | |
411 | 430 | censorText($row['last_subject']); |
412 | 431 | censorText($row['last_body']); |
413 | 432 | } |
414 | - } |
|
415 | - else |
|
433 | + } else |
|
416 | 434 | { |
417 | 435 | $row['first_body'] = ''; |
418 | 436 | $row['last_body'] = ''; |
419 | 437 | censorText($row['first_subject']); |
420 | 438 | |
421 | - if ($row['id_first_msg'] == $row['id_last_msg']) |
|
422 | - $row['last_subject'] = $row['first_subject']; |
|
423 | - else |
|
424 | - censorText($row['last_subject']); |
|
439 | + if ($row['id_first_msg'] == $row['id_last_msg']) { |
|
440 | + $row['last_subject'] = $row['first_subject']; |
|
441 | + } else { |
|
442 | + censorText($row['last_subject']); |
|
443 | + } |
|
425 | 444 | } |
426 | 445 | |
427 | 446 | // Decide how many pages the topic should have. |
@@ -432,42 +451,50 @@ discard block |
||
432 | 451 | $pages = constructPageIndex($scripturl . '?topic=' . $row['id_topic'] . '.%1$d', $start, $row['num_replies'] + 1, $context['messages_per_page'], true, false); |
433 | 452 | |
434 | 453 | // If we can use all, show all. |
435 | - if (!empty($modSettings['enableAllMessages']) && $row['num_replies'] + 1 < $modSettings['enableAllMessages']) |
|
436 | - $pages .= ' <a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>'; |
|
454 | + if (!empty($modSettings['enableAllMessages']) && $row['num_replies'] + 1 < $modSettings['enableAllMessages']) { |
|
455 | + $pages .= ' <a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>'; |
|
456 | + } |
|
457 | + } else { |
|
458 | + $pages = ''; |
|
437 | 459 | } |
438 | - else |
|
439 | - $pages = ''; |
|
440 | 460 | |
441 | 461 | // We need to check the topic icons exist... |
442 | 462 | if (!empty($modSettings['messageIconChecks_enable'])) |
443 | 463 | { |
444 | - if (!isset($context['icon_sources'][$row['first_icon']])) |
|
445 | - $context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
446 | - if (!isset($context['icon_sources'][$row['last_icon']])) |
|
447 | - $context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
448 | - } |
|
449 | - else |
|
464 | + if (!isset($context['icon_sources'][$row['first_icon']])) { |
|
465 | + $context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
466 | + } |
|
467 | + if (!isset($context['icon_sources'][$row['last_icon']])) { |
|
468 | + $context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
469 | + } |
|
470 | + } else |
|
450 | 471 | { |
451 | - if (!isset($context['icon_sources'][$row['first_icon']])) |
|
452 | - $context['icon_sources'][$row['first_icon']] = 'images_url'; |
|
453 | - if (!isset($context['icon_sources'][$row['last_icon']])) |
|
454 | - $context['icon_sources'][$row['last_icon']] = 'images_url'; |
|
472 | + if (!isset($context['icon_sources'][$row['first_icon']])) { |
|
473 | + $context['icon_sources'][$row['first_icon']] = 'images_url'; |
|
474 | + } |
|
475 | + if (!isset($context['icon_sources'][$row['last_icon']])) { |
|
476 | + $context['icon_sources'][$row['last_icon']] = 'images_url'; |
|
477 | + } |
|
455 | 478 | } |
456 | 479 | |
457 | - if (!empty($board_info['recycle'])) |
|
458 | - $row['first_icon'] = 'recycled'; |
|
480 | + if (!empty($board_info['recycle'])) { |
|
481 | + $row['first_icon'] = 'recycled'; |
|
482 | + } |
|
459 | 483 | |
460 | 484 | // Is this topic pending approval, or does it have any posts pending approval? |
461 | - if ($context['can_approve_posts'] && $row['unapproved_posts']) |
|
462 | - $colorClass .= (!$row['approved'] ? ' approvetopic' : ' approvepost'); |
|
485 | + if ($context['can_approve_posts'] && $row['unapproved_posts']) { |
|
486 | + $colorClass .= (!$row['approved'] ? ' approvetopic' : ' approvepost'); |
|
487 | + } |
|
463 | 488 | |
464 | 489 | // Sticky topics should get a different color, too. |
465 | - if ($row['is_sticky']) |
|
466 | - $colorClass .= ' sticky'; |
|
490 | + if ($row['is_sticky']) { |
|
491 | + $colorClass .= ' sticky'; |
|
492 | + } |
|
467 | 493 | |
468 | 494 | // Locked topics get special treatment as well. |
469 | - if ($row['locked']) |
|
470 | - $colorClass .= ' locked'; |
|
495 | + if ($row['locked']) { |
|
496 | + $colorClass .= ' locked'; |
|
497 | + } |
|
471 | 498 | |
472 | 499 | // 'Print' the topic info. |
473 | 500 | $context['topics'][$row['id_topic']] = array_merge($row, array( |
@@ -548,8 +575,9 @@ discard block |
||
548 | 575 | $smcFunc['db_free_result']($result); |
549 | 576 | |
550 | 577 | // Fix the sequence of topics if they were retrieved in the wrong order. (for speed reasons...) |
551 | - if ($fake_ascending) |
|
552 | - $context['topics'] = array_reverse($context['topics'], true); |
|
578 | + if ($fake_ascending) { |
|
579 | + $context['topics'] = array_reverse($context['topics'], true); |
|
580 | + } |
|
553 | 581 | |
554 | 582 | if (!empty($modSettings['enableParticipation']) && !$user_info['is_guest'] && !empty($topic_ids)) |
555 | 583 | { |
@@ -566,8 +594,9 @@ discard block |
||
566 | 594 | 'limit' => count($topic_ids), |
567 | 595 | ) |
568 | 596 | ); |
569 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
570 | - $context['topics'][$row['id_topic']]['is_posted_in'] = true; |
|
597 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
598 | + $context['topics'][$row['id_topic']]['is_posted_in'] = true; |
|
599 | + } |
|
571 | 600 | $smcFunc['db_free_result']($result); |
572 | 601 | } |
573 | 602 | } |
@@ -592,9 +621,9 @@ discard block |
||
592 | 621 | // Can we restore topics? |
593 | 622 | $context['can_restore'] = allowedTo('move_any') && !empty($board_info['recycle']); |
594 | 623 | |
595 | - if ($user_info['is_admin'] || $modSettings['topic_move_any']) |
|
596 | - $context['can_move_any'] = true; |
|
597 | - else |
|
624 | + if ($user_info['is_admin'] || $modSettings['topic_move_any']) { |
|
625 | + $context['can_move_any'] = true; |
|
626 | + } else |
|
598 | 627 | { |
599 | 628 | // We'll use this in a minute |
600 | 629 | $boards_allowed = boardsAllowedTo('post_new'); |
@@ -621,11 +650,13 @@ discard block |
||
621 | 650 | } |
622 | 651 | |
623 | 652 | // Can we use quick moderation checkboxes? |
624 | - if ($options['display_quick_mod'] == 1) |
|
625 | - $context['can_quick_mod'] = $context['user']['is_logged'] || $context['can_approve'] || $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move'] || $context['can_merge'] || $context['can_restore']; |
|
653 | + if ($options['display_quick_mod'] == 1) { |
|
654 | + $context['can_quick_mod'] = $context['user']['is_logged'] || $context['can_approve'] || $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move'] || $context['can_merge'] || $context['can_restore']; |
|
655 | + } |
|
626 | 656 | // Or the icons? |
627 | - else |
|
628 | - $context['can_quick_mod'] = $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move']; |
|
657 | + else { |
|
658 | + $context['can_quick_mod'] = $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move']; |
|
659 | + } |
|
629 | 660 | } |
630 | 661 | |
631 | 662 | if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1) |
@@ -659,13 +690,15 @@ discard block |
||
659 | 690 | ); |
660 | 691 | |
661 | 692 | // We've seen all these boards now! |
662 | - foreach ($board_info['parent_boards'] as $k => $dummy) |
|
663 | - if (isset($_SESSION['topicseen_cache'][$k])) |
|
693 | + foreach ($board_info['parent_boards'] as $k => $dummy) { |
|
694 | + if (isset($_SESSION['topicseen_cache'][$k])) |
|
664 | 695 | unset($_SESSION['topicseen_cache'][$k]); |
696 | + } |
|
665 | 697 | } |
666 | 698 | |
667 | - if (isset($_SESSION['topicseen_cache'][$board])) |
|
668 | - unset($_SESSION['topicseen_cache'][$board]); |
|
699 | + if (isset($_SESSION['topicseen_cache'][$board])) { |
|
700 | + unset($_SESSION['topicseen_cache'][$board]); |
|
701 | + } |
|
669 | 702 | |
670 | 703 | $request = $smcFunc['db_query']('', ' |
671 | 704 | SELECT id_topic, id_board, sent |
@@ -686,8 +719,9 @@ discard block |
||
686 | 719 | $context['is_marked_notify'] = true; |
687 | 720 | $board_sent = $row['sent']; |
688 | 721 | } |
689 | - if (!empty($row['id_topic'])) |
|
690 | - $context['topics'][$row['id_topic']]['is_watched'] = true; |
|
722 | + if (!empty($row['id_topic'])) { |
|
723 | + $context['topics'][$row['id_topic']]['is_watched'] = true; |
|
724 | + } |
|
691 | 725 | } |
692 | 726 | $smcFunc['db_free_result']($request); |
693 | 727 | |
@@ -711,8 +745,7 @@ discard block |
||
711 | 745 | $pref = !empty($pref[$user_info['id']]) ? $pref[$user_info['id']] : array(); |
712 | 746 | $pref = isset($pref['board_notify_' . $board]) ? $pref['board_notify_' . $board] : (!empty($pref['board_notify']) ? $pref['board_notify'] : 0); |
713 | 747 | $context['board_notification_mode'] = !$context['is_marked_notify'] ? 1 : ($pref & 0x02 ? 3 : ($pref & 0x01 ? 2 : 1)); |
714 | - } |
|
715 | - else |
|
748 | + } else |
|
716 | 749 | { |
717 | 750 | $context['is_marked_notify'] = false; |
718 | 751 | $context['board_notification_mode'] = 1; |
@@ -725,23 +758,27 @@ discard block |
||
725 | 758 | $context['becomesUnapproved'] = !empty($_SESSION['becomesUnapproved']) ? true : false; |
726 | 759 | |
727 | 760 | // Don't want to show this forever... |
728 | - if ($context['becomesUnapproved']) |
|
729 | - unset($_SESSION['becomesUnapproved']); |
|
761 | + if ($context['becomesUnapproved']) { |
|
762 | + unset($_SESSION['becomesUnapproved']); |
|
763 | + } |
|
730 | 764 | |
731 | 765 | // Build the message index button array. |
732 | 766 | $context['normal_buttons'] = array(); |
733 | 767 | |
734 | - if ($context['can_post_new']) |
|
735 | - $context['normal_buttons']['new_topic'] = array('text' => 'new_topic', 'image' => 'new_topic.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0', 'active' => true); |
|
768 | + if ($context['can_post_new']) { |
|
769 | + $context['normal_buttons']['new_topic'] = array('text' => 'new_topic', 'image' => 'new_topic.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0', 'active' => true); |
|
770 | + } |
|
736 | 771 | |
737 | - if ($context['can_post_poll']) |
|
738 | - $context['normal_buttons']['post_poll'] = array('text' => 'new_poll', 'image' => 'new_poll.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0;poll'); |
|
772 | + if ($context['can_post_poll']) { |
|
773 | + $context['normal_buttons']['post_poll'] = array('text' => 'new_poll', 'image' => 'new_poll.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0;poll'); |
|
774 | + } |
|
739 | 775 | |
740 | - if (!$context['user']['is_logged']) |
|
741 | - $context['normal_buttons']['markread'] = array('text' => 'mark_read_short', 'image' => 'markread.png', 'lang' => true, 'custom' => 'data-confirm="' . $txt['are_sure_mark_read'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=board;board=' . $context['current_board'] . '.0;' . $context['session_var'] . '=' . $context['session_id']); |
|
776 | + if (!$context['user']['is_logged']) { |
|
777 | + $context['normal_buttons']['markread'] = array('text' => 'mark_read_short', 'image' => 'markread.png', 'lang' => true, 'custom' => 'data-confirm="' . $txt['are_sure_mark_read'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=board;board=' . $context['current_board'] . '.0;' . $context['session_var'] . '=' . $context['session_id']); |
|
778 | + } |
|
742 | 779 | |
743 | - if ($context['can_mark_notify']) |
|
744 | - $context['normal_buttons']['notify'] = array( |
|
780 | + if ($context['can_mark_notify']) { |
|
781 | + $context['normal_buttons']['notify'] = array( |
|
745 | 782 | 'lang' => true, |
746 | 783 | 'text' => 'notify_board_' . $context['board_notification_mode'], |
747 | 784 | 'sub_buttons' => array( |
@@ -759,6 +796,7 @@ discard block |
||
759 | 796 | ), |
760 | 797 | ), |
761 | 798 | ); |
799 | + } |
|
762 | 800 | |
763 | 801 | // Javascript for inline editing. |
764 | 802 | loadJavaScriptFile('topic.js', array('defer' => false), 'smf_topic'); |
@@ -780,18 +818,21 @@ discard block |
||
780 | 818 | checkSession('request'); |
781 | 819 | |
782 | 820 | // Lets go straight to the restore area. |
783 | - if (isset($_REQUEST['qaction']) && $_REQUEST['qaction'] == 'restore' && !empty($_REQUEST['topics'])) |
|
784 | - redirectexit('action=restoretopic;topics=' . implode(',', $_REQUEST['topics']) . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
821 | + if (isset($_REQUEST['qaction']) && $_REQUEST['qaction'] == 'restore' && !empty($_REQUEST['topics'])) { |
|
822 | + redirectexit('action=restoretopic;topics=' . implode(',', $_REQUEST['topics']) . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
823 | + } |
|
785 | 824 | |
786 | - if (isset($_SESSION['topicseen_cache'])) |
|
787 | - $_SESSION['topicseen_cache'] = array(); |
|
825 | + if (isset($_SESSION['topicseen_cache'])) { |
|
826 | + $_SESSION['topicseen_cache'] = array(); |
|
827 | + } |
|
788 | 828 | |
789 | 829 | // This is going to be needed to send off the notifications and for updateLastMessages(). |
790 | 830 | require_once($sourcedir . '/Subs-Post.php'); |
791 | 831 | |
792 | 832 | // Remember the last board they moved things to. |
793 | - if (isset($_REQUEST['move_to'])) |
|
794 | - $_SESSION['move_to_topic'] = $_REQUEST['move_to']; |
|
833 | + if (isset($_REQUEST['move_to'])) { |
|
834 | + $_SESSION['move_to_topic'] = $_REQUEST['move_to']; |
|
835 | + } |
|
795 | 836 | |
796 | 837 | // Only a few possible actions. |
797 | 838 | $possibleActions = array(); |
@@ -811,8 +852,7 @@ discard block |
||
811 | 852 | ); |
812 | 853 | |
813 | 854 | $redirect_url = 'board=' . $board . '.' . $_REQUEST['start']; |
814 | - } |
|
815 | - else |
|
855 | + } else |
|
816 | 856 | { |
817 | 857 | /** |
818 | 858 | * @todo Ugly. There's no getting around this, is there? |
@@ -830,8 +870,7 @@ discard block |
||
830 | 870 | if (!empty($board)) |
831 | 871 | { |
832 | 872 | $boards_can['post_new'] = array_diff(boardsAllowedTo('post_new'), array($board)); |
833 | - } |
|
834 | - else |
|
873 | + } else |
|
835 | 874 | { |
836 | 875 | $boards_can['post_new'] = boardsAllowedTo('post_new'); |
837 | 876 | } |
@@ -842,55 +881,67 @@ discard block |
||
842 | 881 | } |
843 | 882 | } |
844 | 883 | |
845 | - if (!$user_info['is_guest']) |
|
846 | - $possibleActions[] = 'markread'; |
|
847 | - if (!empty($boards_can['make_sticky'])) |
|
848 | - $possibleActions[] = 'sticky'; |
|
849 | - if (!empty($boards_can['move_any']) || !empty($boards_can['move_own'])) |
|
850 | - $possibleActions[] = 'move'; |
|
851 | - if (!empty($boards_can['remove_any']) || !empty($boards_can['remove_own'])) |
|
852 | - $possibleActions[] = 'remove'; |
|
853 | - if (!empty($boards_can['lock_any']) || !empty($boards_can['lock_own'])) |
|
854 | - $possibleActions[] = 'lock'; |
|
855 | - if (!empty($boards_can['merge_any'])) |
|
856 | - $possibleActions[] = 'merge'; |
|
857 | - if (!empty($boards_can['approve_posts'])) |
|
858 | - $possibleActions[] = 'approve'; |
|
884 | + if (!$user_info['is_guest']) { |
|
885 | + $possibleActions[] = 'markread'; |
|
886 | + } |
|
887 | + if (!empty($boards_can['make_sticky'])) { |
|
888 | + $possibleActions[] = 'sticky'; |
|
889 | + } |
|
890 | + if (!empty($boards_can['move_any']) || !empty($boards_can['move_own'])) { |
|
891 | + $possibleActions[] = 'move'; |
|
892 | + } |
|
893 | + if (!empty($boards_can['remove_any']) || !empty($boards_can['remove_own'])) { |
|
894 | + $possibleActions[] = 'remove'; |
|
895 | + } |
|
896 | + if (!empty($boards_can['lock_any']) || !empty($boards_can['lock_own'])) { |
|
897 | + $possibleActions[] = 'lock'; |
|
898 | + } |
|
899 | + if (!empty($boards_can['merge_any'])) { |
|
900 | + $possibleActions[] = 'merge'; |
|
901 | + } |
|
902 | + if (!empty($boards_can['approve_posts'])) { |
|
903 | + $possibleActions[] = 'approve'; |
|
904 | + } |
|
859 | 905 | |
860 | 906 | // Two methods: $_REQUEST['actions'] (id_topic => action), and $_REQUEST['topics'] and $_REQUEST['qaction']. |
861 | 907 | // (if action is 'move', $_REQUEST['move_to'] or $_REQUEST['move_tos'][$topic] is used.) |
862 | 908 | if (!empty($_REQUEST['topics'])) |
863 | 909 | { |
864 | 910 | // If the action isn't valid, just quit now. |
865 | - if (empty($_REQUEST['qaction']) || !in_array($_REQUEST['qaction'], $possibleActions)) |
|
866 | - redirectexit($redirect_url); |
|
911 | + if (empty($_REQUEST['qaction']) || !in_array($_REQUEST['qaction'], $possibleActions)) { |
|
912 | + redirectexit($redirect_url); |
|
913 | + } |
|
867 | 914 | |
868 | 915 | // Merge requires all topics as one parameter and can be done at once. |
869 | 916 | if ($_REQUEST['qaction'] == 'merge') |
870 | 917 | { |
871 | 918 | // Merge requires at least two topics. |
872 | - if (empty($_REQUEST['topics']) || count($_REQUEST['topics']) < 2) |
|
873 | - redirectexit($redirect_url); |
|
919 | + if (empty($_REQUEST['topics']) || count($_REQUEST['topics']) < 2) { |
|
920 | + redirectexit($redirect_url); |
|
921 | + } |
|
874 | 922 | |
875 | 923 | require_once($sourcedir . '/SplitTopics.php'); |
876 | 924 | return MergeExecute($_REQUEST['topics']); |
877 | 925 | } |
878 | 926 | |
879 | 927 | // Just convert to the other method, to make it easier. |
880 | - foreach ($_REQUEST['topics'] as $topic) |
|
881 | - $_REQUEST['actions'][(int) $topic] = $_REQUEST['qaction']; |
|
928 | + foreach ($_REQUEST['topics'] as $topic) { |
|
929 | + $_REQUEST['actions'][(int) $topic] = $_REQUEST['qaction']; |
|
930 | + } |
|
882 | 931 | } |
883 | 932 | |
884 | 933 | // Weird... how'd you get here? |
885 | - if (empty($_REQUEST['actions'])) |
|
886 | - redirectexit($redirect_url); |
|
934 | + if (empty($_REQUEST['actions'])) { |
|
935 | + redirectexit($redirect_url); |
|
936 | + } |
|
887 | 937 | |
888 | 938 | // Validate each action. |
889 | 939 | $temp = array(); |
890 | 940 | foreach ($_REQUEST['actions'] as $topic => $action) |
891 | 941 | { |
892 | - if (in_array($action, $possibleActions)) |
|
893 | - $temp[(int) $topic] = $action; |
|
942 | + if (in_array($action, $possibleActions)) { |
|
943 | + $temp[(int) $topic] = $action; |
|
944 | + } |
|
894 | 945 | } |
895 | 946 | $_REQUEST['actions'] = $temp; |
896 | 947 | |
@@ -911,27 +962,31 @@ discard block |
||
911 | 962 | { |
912 | 963 | if (!empty($board)) |
913 | 964 | { |
914 | - if ($row['id_board'] != $board || ($modSettings['postmod_active'] && !$row['approved'] && !allowedTo('approve_posts'))) |
|
915 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
916 | - } |
|
917 | - else |
|
965 | + if ($row['id_board'] != $board || ($modSettings['postmod_active'] && !$row['approved'] && !allowedTo('approve_posts'))) { |
|
966 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
967 | + } |
|
968 | + } else |
|
918 | 969 | { |
919 | 970 | // Don't allow them to act on unapproved posts they can't see... |
920 | - if ($modSettings['postmod_active'] && !$row['approved'] && !in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])) |
|
921 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
971 | + if ($modSettings['postmod_active'] && !$row['approved'] && !in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])) { |
|
972 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
973 | + } |
|
922 | 974 | // Goodness, this is fun. We need to validate the action. |
923 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'sticky' && !in_array(0, $boards_can['make_sticky']) && !in_array($row['id_board'], $boards_can['make_sticky'])) |
|
924 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
925 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'move' && !in_array(0, $boards_can['move_any']) && !in_array($row['id_board'], $boards_can['move_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['move_own']) && !in_array($row['id_board'], $boards_can['move_own'])))) |
|
926 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
927 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'remove' && !in_array(0, $boards_can['remove_any']) && !in_array($row['id_board'], $boards_can['remove_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['remove_own']) && !in_array($row['id_board'], $boards_can['remove_own'])))) |
|
928 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
975 | + elseif ($_REQUEST['actions'][$row['id_topic']] == 'sticky' && !in_array(0, $boards_can['make_sticky']) && !in_array($row['id_board'], $boards_can['make_sticky'])) { |
|
976 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
977 | + } elseif ($_REQUEST['actions'][$row['id_topic']] == 'move' && !in_array(0, $boards_can['move_any']) && !in_array($row['id_board'], $boards_can['move_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['move_own']) && !in_array($row['id_board'], $boards_can['move_own'])))) { |
|
978 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
979 | + } elseif ($_REQUEST['actions'][$row['id_topic']] == 'remove' && !in_array(0, $boards_can['remove_any']) && !in_array($row['id_board'], $boards_can['remove_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['remove_own']) && !in_array($row['id_board'], $boards_can['remove_own'])))) { |
|
980 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
981 | + } |
|
929 | 982 | // @todo $locked is not set, what are you trying to do? (taking the change it is supposed to be $row['locked']) |
930 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'lock' && !in_array(0, $boards_can['lock_any']) && !in_array($row['id_board'], $boards_can['lock_any']) && ($row['id_member_started'] != $user_info['id'] || $row['locked'] == 1 || (!in_array(0, $boards_can['lock_own']) && !in_array($row['id_board'], $boards_can['lock_own'])))) |
|
931 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
983 | + elseif ($_REQUEST['actions'][$row['id_topic']] == 'lock' && !in_array(0, $boards_can['lock_any']) && !in_array($row['id_board'], $boards_can['lock_any']) && ($row['id_member_started'] != $user_info['id'] || $row['locked'] == 1 || (!in_array(0, $boards_can['lock_own']) && !in_array($row['id_board'], $boards_can['lock_own'])))) { |
|
984 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
985 | + } |
|
932 | 986 | // If the topic is approved then you need permission to approve the posts within. |
933 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'approve' && (!$row['unapproved_posts'] || (!in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])))) |
|
934 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
987 | + elseif ($_REQUEST['actions'][$row['id_topic']] == 'approve' && (!$row['unapproved_posts'] || (!in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])))) { |
|
988 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
989 | + } |
|
935 | 990 | } |
936 | 991 | } |
937 | 992 | $smcFunc['db_free_result']($request); |
@@ -949,11 +1004,11 @@ discard block |
||
949 | 1004 | { |
950 | 1005 | $topic = (int) $topic; |
951 | 1006 | |
952 | - if ($action == 'markread') |
|
953 | - $markCache[] = $topic; |
|
954 | - elseif ($action == 'sticky') |
|
955 | - $stickyCache[] = $topic; |
|
956 | - elseif ($action == 'move') |
|
1007 | + if ($action == 'markread') { |
|
1008 | + $markCache[] = $topic; |
|
1009 | + } elseif ($action == 'sticky') { |
|
1010 | + $stickyCache[] = $topic; |
|
1011 | + } elseif ($action == 'move') |
|
957 | 1012 | { |
958 | 1013 | require_once($sourcedir . '/MoveTopic.php'); |
959 | 1014 | moveTopicConcurrence(); |
@@ -961,23 +1016,25 @@ discard block |
||
961 | 1016 | // $moveCache[0] is the topic, $moveCache[1] is the board to move to. |
962 | 1017 | $moveCache[1][$topic] = (int) (isset($_REQUEST['move_tos'][$topic]) ? $_REQUEST['move_tos'][$topic] : $_REQUEST['move_to']); |
963 | 1018 | |
964 | - if (empty($moveCache[1][$topic])) |
|
965 | - continue; |
|
1019 | + if (empty($moveCache[1][$topic])) { |
|
1020 | + continue; |
|
1021 | + } |
|
966 | 1022 | |
967 | 1023 | $moveCache[0][] = $topic; |
1024 | + } elseif ($action == 'remove') { |
|
1025 | + $removeCache[] = $topic; |
|
1026 | + } elseif ($action == 'lock') { |
|
1027 | + $lockCache[] = $topic; |
|
1028 | + } elseif ($action == 'approve') { |
|
1029 | + $approveCache[] = $topic; |
|
968 | 1030 | } |
969 | - elseif ($action == 'remove') |
|
970 | - $removeCache[] = $topic; |
|
971 | - elseif ($action == 'lock') |
|
972 | - $lockCache[] = $topic; |
|
973 | - elseif ($action == 'approve') |
|
974 | - $approveCache[] = $topic; |
|
975 | 1031 | } |
976 | 1032 | |
977 | - if (empty($board)) |
|
978 | - $affectedBoards = array(); |
|
979 | - else |
|
980 | - $affectedBoards = array($board => array(0, 0)); |
|
1033 | + if (empty($board)) { |
|
1034 | + $affectedBoards = array(); |
|
1035 | + } else { |
|
1036 | + $affectedBoards = array($board => array(0, 0)); |
|
1037 | + } |
|
981 | 1038 | |
982 | 1039 | // Do all the stickies... |
983 | 1040 | if (!empty($stickyCache)) |
@@ -1037,14 +1094,16 @@ discard block |
||
1037 | 1094 | { |
1038 | 1095 | $to = $moveCache[1][$row['id_topic']]; |
1039 | 1096 | |
1040 | - if (empty($to)) |
|
1041 | - continue; |
|
1097 | + if (empty($to)) { |
|
1098 | + continue; |
|
1099 | + } |
|
1042 | 1100 | |
1043 | 1101 | // Does this topic's board count the posts or not? |
1044 | 1102 | $countPosts[$row['id_topic']] = empty($row['count_posts']); |
1045 | 1103 | |
1046 | - if (!isset($moveTos[$to])) |
|
1047 | - $moveTos[$to] = array(); |
|
1104 | + if (!isset($moveTos[$to])) { |
|
1105 | + $moveTos[$to] = array(); |
|
1106 | + } |
|
1048 | 1107 | |
1049 | 1108 | $moveTos[$to][] = $row['id_topic']; |
1050 | 1109 | |
@@ -1058,8 +1117,9 @@ discard block |
||
1058 | 1117 | require_once($sourcedir . '/MoveTopic.php'); |
1059 | 1118 | |
1060 | 1119 | // Do the actual moves... |
1061 | - foreach ($moveTos as $to => $topics) |
|
1062 | - moveTopics($topics, $to); |
|
1120 | + foreach ($moveTos as $to => $topics) { |
|
1121 | + moveTopics($topics, $to); |
|
1122 | + } |
|
1063 | 1123 | |
1064 | 1124 | // Does the post counts need to be updated? |
1065 | 1125 | if (!empty($moveTos)) |
@@ -1108,20 +1168,23 @@ discard block |
||
1108 | 1168 | |
1109 | 1169 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1110 | 1170 | { |
1111 | - if (!isset($members[$row['id_member']])) |
|
1112 | - $members[$row['id_member']] = 0; |
|
1171 | + if (!isset($members[$row['id_member']])) { |
|
1172 | + $members[$row['id_member']] = 0; |
|
1173 | + } |
|
1113 | 1174 | |
1114 | - if ($topicRecounts[$row['id_topic']] === '+') |
|
1115 | - $members[$row['id_member']] += 1; |
|
1116 | - else |
|
1117 | - $members[$row['id_member']] -= 1; |
|
1175 | + if ($topicRecounts[$row['id_topic']] === '+') { |
|
1176 | + $members[$row['id_member']] += 1; |
|
1177 | + } else { |
|
1178 | + $members[$row['id_member']] -= 1; |
|
1179 | + } |
|
1118 | 1180 | } |
1119 | 1181 | |
1120 | 1182 | $smcFunc['db_free_result']($request); |
1121 | 1183 | |
1122 | 1184 | // And now update them member's post counts |
1123 | - foreach ($members as $id_member => $post_adj) |
|
1124 | - updateMemberData($id_member, array('posts' => 'posts + ' . $post_adj)); |
|
1185 | + foreach ($members as $id_member => $post_adj) { |
|
1186 | + updateMemberData($id_member, array('posts' => 'posts + ' . $post_adj)); |
|
1187 | + } |
|
1125 | 1188 | |
1126 | 1189 | } |
1127 | 1190 | } |
@@ -1201,8 +1264,9 @@ discard block |
||
1201 | 1264 | approveTopics($approveCache); |
1202 | 1265 | |
1203 | 1266 | // Time for some logging! |
1204 | - foreach ($approveCache as $topic) |
|
1205 | - logAction('approve_topic', array('topic' => $topic, 'member' => $approveCacheMembers[$topic])); |
|
1267 | + foreach ($approveCache as $topic) { |
|
1268 | + logAction('approve_topic', array('topic' => $topic, 'member' => $approveCacheMembers[$topic])); |
|
1269 | + } |
|
1206 | 1270 | } |
1207 | 1271 | } |
1208 | 1272 | |
@@ -1237,8 +1301,7 @@ discard block |
||
1237 | 1301 | $lockStatus[$row['id_topic']] = empty($row['locked']); |
1238 | 1302 | } |
1239 | 1303 | $smcFunc['db_free_result']($result); |
1240 | - } |
|
1241 | - else |
|
1304 | + } else |
|
1242 | 1305 | { |
1243 | 1306 | $result = $smcFunc['db_query']('', ' |
1244 | 1307 | SELECT id_topic, locked, id_board |
@@ -1288,13 +1351,15 @@ discard block |
||
1288 | 1351 | ) |
1289 | 1352 | ); |
1290 | 1353 | $logged_topics = array(); |
1291 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1292 | - $logged_topics[$row['id_topic']] = $row['unwatched']; |
|
1354 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1355 | + $logged_topics[$row['id_topic']] = $row['unwatched']; |
|
1356 | + } |
|
1293 | 1357 | $smcFunc['db_free_result']($request); |
1294 | 1358 | |
1295 | 1359 | $markArray = array(); |
1296 | - foreach ($markCache as $topic) |
|
1297 | - $markArray[] = array($modSettings['maxMsgID'], $user_info['id'], $topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0)); |
|
1360 | + foreach ($markCache as $topic) { |
|
1361 | + $markArray[] = array($modSettings['maxMsgID'], $user_info['id'], $topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0)); |
|
1362 | + } |
|
1298 | 1363 | |
1299 | 1364 | $smcFunc['db_insert']('replace', |
1300 | 1365 | '{db_prefix}log_topics', |
@@ -1307,8 +1372,9 @@ discard block |
||
1307 | 1372 | foreach ($moveCache as $topic) |
1308 | 1373 | { |
1309 | 1374 | // Didn't actually move anything! |
1310 | - if (!isset($topic[0])) |
|
1311 | - break; |
|
1375 | + if (!isset($topic[0])) { |
|
1376 | + break; |
|
1377 | + } |
|
1312 | 1378 | |
1313 | 1379 | logAction('move', array('topic' => $topic[0], 'board_from' => $topic[1], 'board_to' => $topic[2])); |
1314 | 1380 | sendNotifications($topic[0], 'move'); |
@@ -1330,8 +1396,9 @@ discard block |
||
1330 | 1396 | 'calendar_updated' => time(), |
1331 | 1397 | )); |
1332 | 1398 | |
1333 | - if (!empty($affectedBoards)) |
|
1334 | - updateLastMessages(array_keys($affectedBoards)); |
|
1399 | + if (!empty($affectedBoards)) { |
|
1400 | + updateLastMessages(array_keys($affectedBoards)); |
|
1401 | + } |
|
1335 | 1402 | |
1336 | 1403 | redirectexit($redirect_url); |
1337 | 1404 | } |
@@ -15,8 +15,9 @@ discard block |
||
15 | 15 | * @version 2.1 Beta 4 |
16 | 16 | */ |
17 | 17 | |
18 | -if (!defined('SMF')) |
|
18 | +if (!defined('SMF')) { |
|
19 | 19 | die('No direct access...'); |
20 | +} |
|
20 | 21 | |
21 | 22 | /** |
22 | 23 | * Main dispatcher. This function checks permissions and passes control through to the relevant section. |
@@ -245,8 +246,9 @@ discard block |
||
245 | 246 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
246 | 247 | { |
247 | 248 | // Private PM/email subjects and similar shouldn't be shown in the mailbox area. |
248 | - if (!empty($row['private'])) |
|
249 | - $row['subject'] = $txt['personal_message']; |
|
249 | + if (!empty($row['private'])) { |
|
250 | + $row['subject'] = $txt['personal_message']; |
|
251 | + } |
|
250 | 252 | |
251 | 253 | $mails[] = $row; |
252 | 254 | } |
@@ -300,8 +302,9 @@ discard block |
||
300 | 302 | $element = substr($key, strrpos($key, '_') + 1); |
301 | 303 | $processedBirthdayEmails[$index][$element] = $value; |
302 | 304 | } |
303 | - foreach ($processedBirthdayEmails as $index => $dummy) |
|
304 | - $emails[$index] = $index; |
|
305 | + foreach ($processedBirthdayEmails as $index => $dummy) { |
|
306 | + $emails[$index] = $index; |
|
307 | + } |
|
305 | 308 | |
306 | 309 | $config_vars = array( |
307 | 310 | // Mail queue stuff, this rocks ;) |
@@ -322,8 +325,9 @@ discard block |
||
322 | 325 | |
323 | 326 | call_integration_hook('integrate_modify_mail_settings', array(&$config_vars)); |
324 | 327 | |
325 | - if ($return_config) |
|
326 | - return $config_vars; |
|
328 | + if ($return_config) { |
|
329 | + return $config_vars; |
|
330 | + } |
|
327 | 331 | |
328 | 332 | // Saving? |
329 | 333 | if (isset($_GET['save'])) |
@@ -398,9 +402,9 @@ discard block |
||
398 | 402 | ); |
399 | 403 | list ($_GET['te']) = $smcFunc['db_fetch_row']($request); |
400 | 404 | $smcFunc['db_free_result']($request); |
405 | + } else { |
|
406 | + $_GET['te'] = (int) $_GET['te']; |
|
401 | 407 | } |
402 | - else |
|
403 | - $_GET['te'] = (int) $_GET['te']; |
|
404 | 408 | |
405 | 409 | $_GET['sent'] = isset($_GET['sent']) ? (int) $_GET['sent'] : 0; |
406 | 410 | |
@@ -424,12 +428,14 @@ discard block |
||
424 | 428 | |
425 | 429 | // Try get more time... |
426 | 430 | @set_time_limit(600); |
427 | - if (function_exists('apache_reset_timeout')) |
|
428 | - @apache_reset_timeout(); |
|
431 | + if (function_exists('apache_reset_timeout')) { |
|
432 | + @apache_reset_timeout(); |
|
433 | + } |
|
429 | 434 | |
430 | 435 | // Have we already used our maximum time? |
431 | - if ((time() - $time_start) < 5) |
|
432 | - return; |
|
436 | + if ((time() - $time_start) < 5) { |
|
437 | + return; |
|
438 | + } |
|
433 | 439 | |
434 | 440 | $context['continue_get_data'] = '?action=admin;area=mailqueue;sa=clear;te=' . $_GET['te'] . ';sent=' . $_GET['sent'] . ';' . $context['session_var'] . '=' . $context['session_id']; |
435 | 441 | $context['page_title'] = $txt['not_done_title']; |
@@ -459,8 +465,9 @@ discard block |
||
459 | 465 | { |
460 | 466 | global $txt; |
461 | 467 | |
462 | - if ($time_diff < 0) |
|
463 | - $time_diff = 0; |
|
468 | + if ($time_diff < 0) { |
|
469 | + $time_diff = 0; |
|
470 | + } |
|
464 | 471 | |
465 | 472 | // Just do a bit of an if fest... |
466 | 473 | if ($time_diff > 86400) |
@@ -481,8 +488,9 @@ discard block |
||
481 | 488 | return sprintf($minutes == 1 ? $txt['mq_minute'] : $txt['mq_minutes'], $minutes); |
482 | 489 | } |
483 | 490 | // Otherwise must be second |
484 | - else |
|
485 | - return sprintf($time_diff == 1 ? $txt['mq_second'] : $txt['mq_seconds'], $time_diff); |
|
486 | -} |
|
491 | + else { |
|
492 | + return sprintf($time_diff == 1 ? $txt['mq_second'] : $txt['mq_seconds'], $time_diff); |
|
493 | + } |
|
494 | + } |
|
487 | 495 | |
488 | 496 | ?> |
489 | 497 | \ No newline at end of file |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | |
92 | 92 | $table = str_replace('{db_prefix}', $db_prefix, $table); |
93 | 93 | |
94 | - $pg_tables = array('pg_catalog','information_schema'); |
|
94 | + $pg_tables = array('pg_catalog', 'information_schema'); |
|
95 | 95 | |
96 | 96 | $request = $smcFunc['db_query']('', ' |
97 | 97 | SELECT pg_relation_size(C.oid) AS "size" |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | global $db_connection; |
291 | 291 | static $ver; |
292 | 292 | |
293 | - if(!empty($ver)) |
|
293 | + if (!empty($ver)) |
|
294 | 294 | return $ver; |
295 | 295 | |
296 | 296 | $ver = pg_version($db_connection)['server']; |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Add the functions implemented in this file to the $smcFunc array. |
@@ -23,8 +24,8 @@ discard block |
||
23 | 24 | { |
24 | 25 | global $smcFunc; |
25 | 26 | |
26 | - if (!isset($smcFunc['db_backup_table']) || $smcFunc['db_backup_table'] != 'smf_db_backup_table') |
|
27 | - $smcFunc += array( |
|
27 | + if (!isset($smcFunc['db_backup_table']) || $smcFunc['db_backup_table'] != 'smf_db_backup_table') { |
|
28 | + $smcFunc += array( |
|
28 | 29 | 'db_backup_table' => 'smf_db_backup_table', |
29 | 30 | 'db_optimize_table' => 'smf_db_optimize_table', |
30 | 31 | 'db_table_sql' => 'smf_db_table_sql', |
@@ -32,7 +33,8 @@ discard block |
||
32 | 33 | 'db_get_version' => 'smf_db_get_version', |
33 | 34 | 'db_get_vendor' => 'smf_db_get_vendor', |
34 | 35 | ); |
35 | -} |
|
36 | + } |
|
37 | + } |
|
36 | 38 | |
37 | 39 | /** |
38 | 40 | * Backup $table to $backup_table. |
@@ -48,13 +50,14 @@ discard block |
||
48 | 50 | |
49 | 51 | // Do we need to drop it first? |
50 | 52 | $tables = smf_db_list_tables(false, $backup_table); |
51 | - if (!empty($tables)) |
|
52 | - $smcFunc['db_query']('', ' |
|
53 | + if (!empty($tables)) { |
|
54 | + $smcFunc['db_query']('', ' |
|
53 | 55 | DROP TABLE {raw:backup_table}', |
54 | 56 | array( |
55 | 57 | 'backup_table' => $backup_table, |
56 | 58 | ) |
57 | 59 | ); |
60 | + } |
|
58 | 61 | |
59 | 62 | /** |
60 | 63 | * @todo Should we create backups of sequences as well? |
@@ -117,8 +120,9 @@ discard block |
||
117 | 120 | ) |
118 | 121 | ); |
119 | 122 | |
120 | - if (!$request) |
|
121 | - return -1; |
|
123 | + if (!$request) { |
|
124 | + return -1; |
|
125 | + } |
|
122 | 126 | |
123 | 127 | $request = $smcFunc['db_query']('', ' |
124 | 128 | SELECT pg_relation_size(C.oid) AS "size" |
@@ -136,11 +140,12 @@ discard block |
||
136 | 140 | $row = $smcFunc['db_fetch_assoc']($request); |
137 | 141 | $smcFunc['db_free_result']($request); |
138 | 142 | |
139 | - if (isset($row['size'])) |
|
140 | - return ($old_size - $row['size']) / 1024; |
|
141 | - else |
|
142 | - return 0; |
|
143 | -} |
|
143 | + if (isset($row['size'])) { |
|
144 | + return ($old_size - $row['size']) / 1024; |
|
145 | + } else { |
|
146 | + return 0; |
|
147 | + } |
|
148 | + } |
|
144 | 149 | |
145 | 150 | /** |
146 | 151 | * This function lists all tables in the database. |
@@ -167,8 +172,9 @@ discard block |
||
167 | 172 | ); |
168 | 173 | |
169 | 174 | $tables = array(); |
170 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
171 | - $tables[] = $row[0]; |
|
175 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
176 | + $tables[] = $row[0]; |
|
177 | + } |
|
172 | 178 | $smcFunc['db_free_result']($request); |
173 | 179 | |
174 | 180 | return $tables; |
@@ -209,12 +215,14 @@ discard block |
||
209 | 215 | ); |
210 | 216 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
211 | 217 | { |
212 | - if ($row['data_type'] == 'character varying') |
|
213 | - $row['data_type'] = 'varchar'; |
|
214 | - elseif ($row['data_type'] == 'character') |
|
215 | - $row['data_type'] = 'char'; |
|
216 | - if ($row['character_maximum_length']) |
|
217 | - $row['data_type'] .= '(' . $row['character_maximum_length'] . ')'; |
|
218 | + if ($row['data_type'] == 'character varying') { |
|
219 | + $row['data_type'] = 'varchar'; |
|
220 | + } elseif ($row['data_type'] == 'character') { |
|
221 | + $row['data_type'] = 'char'; |
|
222 | + } |
|
223 | + if ($row['character_maximum_length']) { |
|
224 | + $row['data_type'] .= '(' . $row['character_maximum_length'] . ')'; |
|
225 | + } |
|
218 | 226 | |
219 | 227 | // Make the CREATE for this column. |
220 | 228 | $schema_create .= ' "' . $row['column_name'] . '" ' . $row['data_type'] . ($row['is_nullable'] != 'YES' ? ' NOT NULL' : ''); |
@@ -265,13 +273,14 @@ discard block |
||
265 | 273 | { |
266 | 274 | if ($row['is_primary']) |
267 | 275 | { |
268 | - if (preg_match('~\(([^\)]+?)\)~i', $row['inddef'], $matches) == 0) |
|
269 | - continue; |
|
276 | + if (preg_match('~\(([^\)]+?)\)~i', $row['inddef'], $matches) == 0) { |
|
277 | + continue; |
|
278 | + } |
|
270 | 279 | |
271 | 280 | $index_create .= $crlf . 'ALTER TABLE ' . $tableName . ' ADD PRIMARY KEY ("' . $matches[1] . '");'; |
281 | + } else { |
|
282 | + $index_create .= $crlf . $row['inddef'] . ';'; |
|
272 | 283 | } |
273 | - else |
|
274 | - $index_create .= $crlf . $row['inddef'] . ';'; |
|
275 | 284 | } |
276 | 285 | $smcFunc['db_free_result']($result); |
277 | 286 | |
@@ -290,8 +299,9 @@ discard block |
||
290 | 299 | global $db_connection; |
291 | 300 | static $ver; |
292 | 301 | |
293 | - if(!empty($ver)) |
|
294 | - return $ver; |
|
302 | + if(!empty($ver)) { |
|
303 | + return $ver; |
|
304 | + } |
|
295 | 305 | |
296 | 306 | $ver = pg_version($db_connection)['server']; |
297 | 307 |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Finds or repairs errors in the database to fix possible problems. |
@@ -50,8 +51,9 @@ discard block |
||
50 | 51 | ); |
51 | 52 | |
52 | 53 | // Start displaying errors without fixing them. |
53 | - if (isset($_GET['fixErrors'])) |
|
54 | - checkSession('get'); |
|
54 | + if (isset($_GET['fixErrors'])) { |
|
55 | + checkSession('get'); |
|
56 | + } |
|
55 | 57 | |
56 | 58 | // Will want this. |
57 | 59 | loadForumTests(); |
@@ -69,11 +71,11 @@ discard block |
||
69 | 71 | $_SESSION['repairboards_to_fix'] = $context['to_fix']; |
70 | 72 | $_SESSION['repairboards_to_fix2'] = null; |
71 | 73 | |
72 | - if (empty($context['repair_errors'])) |
|
73 | - $context['repair_errors'][] = '???'; |
|
74 | + if (empty($context['repair_errors'])) { |
|
75 | + $context['repair_errors'][] = '???'; |
|
76 | + } |
|
74 | 77 | } |
75 | - } |
|
76 | - else |
|
78 | + } else |
|
77 | 79 | { |
78 | 80 | $context['error_search'] = false; |
79 | 81 | $context['to_fix'] = isset($_SESSION['repairboards_to_fix']) ? $_SESSION['repairboards_to_fix'] : array(); |
@@ -120,16 +122,19 @@ discard block |
||
120 | 122 | |
121 | 123 | // More time, I need more time! |
122 | 124 | @set_time_limit(600); |
123 | - if (function_exists('apache_reset_timeout')) |
|
124 | - @apache_reset_timeout(); |
|
125 | + if (function_exists('apache_reset_timeout')) { |
|
126 | + @apache_reset_timeout(); |
|
127 | + } |
|
125 | 128 | |
126 | 129 | // Errr, wait. How much time has this taken already? |
127 | - if (!$force && (time() - $time_start) < 3) |
|
128 | - return; |
|
130 | + if (!$force && (time() - $time_start) < 3) { |
|
131 | + return; |
|
132 | + } |
|
129 | 133 | |
130 | 134 | // Restore the query cache if interested. |
131 | - if (!empty($db_temp_cache)) |
|
132 | - $db_cache = $db_temp_cache; |
|
135 | + if (!empty($db_temp_cache)) { |
|
136 | + $db_cache = $db_temp_cache; |
|
137 | + } |
|
133 | 138 | |
134 | 139 | $context['continue_get_data'] = '?action=admin;area=repairboards' . (isset($_GET['fixErrors']) ? ';fixErrors' : '') . ';step=' . $_GET['step'] . ';substep=' . $_GET['substep'] . ';' . $context['session_var'] . '=' . $context['session_id']; |
135 | 140 | $context['page_title'] = $txt['not_done_title']; |
@@ -138,10 +143,11 @@ discard block |
||
138 | 143 | $context['sub_template'] = 'not_done'; |
139 | 144 | |
140 | 145 | // Change these two if more steps are added! |
141 | - if (empty($max_substep)) |
|
142 | - $context['continue_percent'] = round(($_GET['step'] * 100) / $context['total_steps']); |
|
143 | - else |
|
144 | - $context['continue_percent'] = round((($_GET['step'] + ($_GET['substep'] / $max_substep)) * 100) / $context['total_steps']); |
|
146 | + if (empty($max_substep)) { |
|
147 | + $context['continue_percent'] = round(($_GET['step'] * 100) / $context['total_steps']); |
|
148 | + } else { |
|
149 | + $context['continue_percent'] = round((($_GET['step'] + ($_GET['substep'] / $max_substep)) * 100) / $context['total_steps']); |
|
150 | + } |
|
145 | 151 | |
146 | 152 | // Never more than 100%! |
147 | 153 | $context['continue_percent'] = min($context['continue_percent'], 100); |
@@ -612,8 +618,9 @@ discard block |
||
612 | 618 | $row['myid_last_msg'] = (int) $row['myid_last_msg']; |
613 | 619 | |
614 | 620 | // Not really a problem? |
615 | - if ($row['id_first_msg'] == $row['myid_first_msg'] && $row['id_last_msg'] == $row['myid_last_msg'] && $row['approved'] == $row['firstmsg_approved']) |
|
616 | - return false; |
|
621 | + if ($row['id_first_msg'] == $row['myid_first_msg'] && $row['id_last_msg'] == $row['myid_last_msg'] && $row['approved'] == $row['firstmsg_approved']) { |
|
622 | + return false; |
|
623 | + } |
|
617 | 624 | |
618 | 625 | $memberStartedID = (int) getMsgMemberID($row['myid_first_msg']); |
619 | 626 | $memberUpdatedID = (int) getMsgMemberID($row['myid_last_msg']); |
@@ -637,15 +644,19 @@ discard block |
||
637 | 644 | 'message_function' => function ($row) use ($txt, &$context) |
638 | 645 | { |
639 | 646 | // A pretend error? |
640 | - if ($row['id_first_msg'] == $row['myid_first_msg'] && $row['id_last_msg'] == $row['myid_last_msg'] && $row['approved'] == $row['firstmsg_approved']) |
|
641 | - return false; |
|
647 | + if ($row['id_first_msg'] == $row['myid_first_msg'] && $row['id_last_msg'] == $row['myid_last_msg'] && $row['approved'] == $row['firstmsg_approved']) { |
|
648 | + return false; |
|
649 | + } |
|
642 | 650 | |
643 | - if ($row['id_first_msg'] != $row['myid_first_msg']) |
|
644 | - $context['repair_errors'][] = sprintf($txt['repair_stats_topics_1'], $row['id_topic'], $row['id_first_msg']); |
|
645 | - if ($row['id_last_msg'] != $row['myid_last_msg']) |
|
646 | - $context['repair_errors'][] = sprintf($txt['repair_stats_topics_2'], $row['id_topic'], $row['id_last_msg']); |
|
647 | - if ($row['approved'] != $row['firstmsg_approved']) |
|
648 | - $context['repair_errors'][] = sprintf($txt['repair_stats_topics_5'], $row['id_topic']); |
|
651 | + if ($row['id_first_msg'] != $row['myid_first_msg']) { |
|
652 | + $context['repair_errors'][] = sprintf($txt['repair_stats_topics_1'], $row['id_topic'], $row['id_first_msg']); |
|
653 | + } |
|
654 | + if ($row['id_last_msg'] != $row['myid_last_msg']) { |
|
655 | + $context['repair_errors'][] = sprintf($txt['repair_stats_topics_2'], $row['id_topic'], $row['id_last_msg']); |
|
656 | + } |
|
657 | + if ($row['approved'] != $row['firstmsg_approved']) { |
|
658 | + $context['repair_errors'][] = sprintf($txt['repair_stats_topics_5'], $row['id_topic']); |
|
659 | + } |
|
649 | 660 | |
650 | 661 | return true; |
651 | 662 | }, |
@@ -675,8 +686,9 @@ discard block |
||
675 | 686 | $row['my_num_replies'] = (int) $row['my_num_replies']; |
676 | 687 | |
677 | 688 | // Not really a problem? |
678 | - if ($row['my_num_replies'] == $row['num_replies']) |
|
679 | - return false; |
|
689 | + if ($row['my_num_replies'] == $row['num_replies']) { |
|
690 | + return false; |
|
691 | + } |
|
680 | 692 | |
681 | 693 | $smcFunc['db_query']('', ' |
682 | 694 | UPDATE {db_prefix}topics |
@@ -695,11 +707,13 @@ discard block |
||
695 | 707 | global $txt, $context; |
696 | 708 | |
697 | 709 | // Just joking? |
698 | - if ($row['my_num_replies'] == $row['num_replies']) |
|
699 | - return false; |
|
710 | + if ($row['my_num_replies'] == $row['num_replies']) { |
|
711 | + return false; |
|
712 | + } |
|
700 | 713 | |
701 | - if ($row['num_replies'] != $row['my_num_replies']) |
|
702 | - $context['repair_errors'][] = sprintf($txt['repair_stats_topics_3'], $row['id_topic'], $row['num_replies']); |
|
714 | + if ($row['num_replies'] != $row['my_num_replies']) { |
|
715 | + $context['repair_errors'][] = sprintf($txt['repair_stats_topics_3'], $row['id_topic'], $row['num_replies']); |
|
716 | + } |
|
703 | 717 | |
704 | 718 | return true; |
705 | 719 | |
@@ -1290,8 +1304,9 @@ discard block |
||
1290 | 1304 | $inserts = array(); |
1291 | 1305 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
1292 | 1306 | { |
1293 | - foreach (text2words($row['subject']) as $word) |
|
1294 | - $inserts[] = array($word, $row['id_topic']); |
|
1307 | + foreach (text2words($row['subject']) as $word) { |
|
1308 | + $inserts[] = array($word, $row['id_topic']); |
|
1309 | + } |
|
1295 | 1310 | if (count($inserts) > 500) |
1296 | 1311 | { |
1297 | 1312 | $smcFunc['db_insert']('ignore', |
@@ -1305,13 +1320,14 @@ discard block |
||
1305 | 1320 | |
1306 | 1321 | } |
1307 | 1322 | |
1308 | - if (!empty($inserts)) |
|
1309 | - $smcFunc['db_insert']('ignore', |
|
1323 | + if (!empty($inserts)) { |
|
1324 | + $smcFunc['db_insert']('ignore', |
|
1310 | 1325 | '{db_prefix}log_search_subjects', |
1311 | 1326 | array('word' => 'string', 'id_topic' => 'int'), |
1312 | 1327 | $inserts, |
1313 | 1328 | array('word', 'id_topic') |
1314 | 1329 | ); |
1330 | + } |
|
1315 | 1331 | |
1316 | 1332 | }, |
1317 | 1333 | 'message_function' => function ($row) |
@@ -1581,8 +1597,9 @@ discard block |
||
1581 | 1597 | $current_step++; |
1582 | 1598 | |
1583 | 1599 | // Already done this? |
1584 | - if ($_GET['step'] > $current_step) |
|
1585 | - continue; |
|
1600 | + if ($_GET['step'] > $current_step) { |
|
1601 | + continue; |
|
1602 | + } |
|
1586 | 1603 | |
1587 | 1604 | // If we're fixing it but it ain't broke why try? |
1588 | 1605 | if ($do_fix && !in_array($error_type, $to_fix)) |
@@ -1611,14 +1628,16 @@ discard block |
||
1611 | 1628 | while (!$done) |
1612 | 1629 | { |
1613 | 1630 | // Make sure there's at least one ID to test. |
1614 | - if (isset($test['substeps']) && empty($step_max)) |
|
1615 | - break; |
|
1631 | + if (isset($test['substeps']) && empty($step_max)) { |
|
1632 | + break; |
|
1633 | + } |
|
1616 | 1634 | |
1617 | 1635 | // What is the testing query (Changes if we are testing or fixing) |
1618 | - if (!$do_fix) |
|
1619 | - $test_query = 'check_query'; |
|
1620 | - else |
|
1621 | - $test_query = isset($test['fix_query']) ? 'fix_query' : 'check_query'; |
|
1636 | + if (!$do_fix) { |
|
1637 | + $test_query = 'check_query'; |
|
1638 | + } else { |
|
1639 | + $test_query = isset($test['fix_query']) ? 'fix_query' : 'check_query'; |
|
1640 | + } |
|
1622 | 1641 | |
1623 | 1642 | // Do the test... |
1624 | 1643 | $request = $smcFunc['db_query']('', |
@@ -1628,10 +1647,11 @@ discard block |
||
1628 | 1647 | ); |
1629 | 1648 | |
1630 | 1649 | // Does it need a fix? |
1631 | - if (!empty($test['check_type']) && $test['check_type'] == 'count') |
|
1632 | - list ($needs_fix) = $smcFunc['db_fetch_row']($request); |
|
1633 | - else |
|
1634 | - $needs_fix = $smcFunc['db_num_rows']($request); |
|
1650 | + if (!empty($test['check_type']) && $test['check_type'] == 'count') { |
|
1651 | + list ($needs_fix) = $smcFunc['db_fetch_row']($request); |
|
1652 | + } else { |
|
1653 | + $needs_fix = $smcFunc['db_num_rows']($request); |
|
1654 | + } |
|
1635 | 1655 | |
1636 | 1656 | $total_queries++; |
1637 | 1657 | |
@@ -1643,8 +1663,9 @@ discard block |
||
1643 | 1663 | // Assume need to fix. |
1644 | 1664 | $found_errors = true; |
1645 | 1665 | |
1646 | - if (isset($test['message'])) |
|
1647 | - $context['repair_errors'][] = $txt[$test['message']]; |
|
1666 | + if (isset($test['message'])) { |
|
1667 | + $context['repair_errors'][] = $txt[$test['message']]; |
|
1668 | + } |
|
1648 | 1669 | |
1649 | 1670 | // One per row! |
1650 | 1671 | elseif (isset($test['messages'])) |
@@ -1654,10 +1675,11 @@ discard block |
||
1654 | 1675 | $variables = $test['messages']; |
1655 | 1676 | foreach ($variables as $k => $v) |
1656 | 1677 | { |
1657 | - if ($k == 0 && isset($txt[$v])) |
|
1658 | - $variables[$k] = $txt[$v]; |
|
1659 | - elseif ($k > 0 && isset($row[$v])) |
|
1660 | - $variables[$k] = $row[$v]; |
|
1678 | + if ($k == 0 && isset($txt[$v])) { |
|
1679 | + $variables[$k] = $txt[$v]; |
|
1680 | + } elseif ($k > 0 && isset($row[$v])) { |
|
1681 | + $variables[$k] = $row[$v]; |
|
1682 | + } |
|
1661 | 1683 | } |
1662 | 1684 | $context['repair_errors'][] = call_user_func_array('sprintf', $variables); |
1663 | 1685 | } |
@@ -1668,13 +1690,15 @@ discard block |
||
1668 | 1690 | { |
1669 | 1691 | // Find out if there are actually errors. |
1670 | 1692 | $found_errors = false; |
1671 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1672 | - $found_errors |= $test['message_function']($row); |
|
1693 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1694 | + $found_errors |= $test['message_function']($row); |
|
1695 | + } |
|
1673 | 1696 | } |
1674 | 1697 | |
1675 | 1698 | // Actually have something to fix? |
1676 | - if ($found_errors) |
|
1677 | - $to_fix[] = $error_type; |
|
1699 | + if ($found_errors) { |
|
1700 | + $to_fix[] = $error_type; |
|
1701 | + } |
|
1678 | 1702 | } |
1679 | 1703 | |
1680 | 1704 | // We want to fix, we need to fix - so work out what exactly to do! |
@@ -1684,8 +1708,9 @@ discard block |
||
1684 | 1708 | if (isset($test['fix_collect'])) |
1685 | 1709 | { |
1686 | 1710 | $ids = array(); |
1687 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1688 | - $ids[] = $row[$test['fix_collect']['index']]; |
|
1711 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1712 | + $ids[] = $row[$test['fix_collect']['index']]; |
|
1713 | + } |
|
1689 | 1714 | if (!empty($ids)) |
1690 | 1715 | { |
1691 | 1716 | // Fix it! |
@@ -1694,30 +1719,34 @@ discard block |
||
1694 | 1719 | } |
1695 | 1720 | |
1696 | 1721 | // Simply executing a fix it query? |
1697 | - elseif (isset($test['fix_it_query'])) |
|
1698 | - $smcFunc['db_query']('', |
|
1722 | + elseif (isset($test['fix_it_query'])) { |
|
1723 | + $smcFunc['db_query']('', |
|
1699 | 1724 | $test['fix_it_query'], |
1700 | 1725 | array( |
1701 | 1726 | ) |
1702 | 1727 | ); |
1728 | + } |
|
1703 | 1729 | |
1704 | 1730 | // Do we have some processing to do? |
1705 | 1731 | elseif (isset($test['fix_processing'])) |
1706 | 1732 | { |
1707 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1708 | - $test['fix_processing']($row); |
|
1733 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1734 | + $test['fix_processing']($row); |
|
1735 | + } |
|
1709 | 1736 | } |
1710 | 1737 | |
1711 | 1738 | // What about the full set of processing? |
1712 | - elseif (isset($test['fix_full_processing'])) |
|
1713 | - $test['fix_full_processing']($request); |
|
1739 | + elseif (isset($test['fix_full_processing'])) { |
|
1740 | + $test['fix_full_processing']($request); |
|
1741 | + } |
|
1714 | 1742 | |
1715 | 1743 | // Do we have other things we need to fix as a result? |
1716 | 1744 | if (!empty($test['force_fix'])) |
1717 | 1745 | { |
1718 | - foreach ($test['force_fix'] as $item) |
|
1719 | - if (!in_array($item, $to_fix)) |
|
1746 | + foreach ($test['force_fix'] as $item) { |
|
1747 | + if (!in_array($item, $to_fix)) |
|
1720 | 1748 | $to_fix[] = $item; |
1749 | + } |
|
1721 | 1750 | } |
1722 | 1751 | } |
1723 | 1752 | } |
@@ -1735,16 +1764,17 @@ discard block |
||
1735 | 1764 | if ($_GET['substep'] <= $step_max) |
1736 | 1765 | { |
1737 | 1766 | pauseRepairProcess($to_fix, $error_type, $step_max); |
1767 | + } else { |
|
1768 | + $done = true; |
|
1738 | 1769 | } |
1739 | - else |
|
1740 | - $done = true; |
|
1770 | + } else { |
|
1771 | + $done = true; |
|
1741 | 1772 | } |
1742 | - else |
|
1743 | - $done = true; |
|
1744 | 1773 | |
1745 | 1774 | // Don't allow more than 1000 queries at a time. |
1746 | - if ($total_queries >= 1000) |
|
1747 | - pauseRepairProcess($to_fix, $error_type, $step_max, true); |
|
1775 | + if ($total_queries >= 1000) { |
|
1776 | + pauseRepairProcess($to_fix, $error_type, $step_max, true); |
|
1777 | + } |
|
1748 | 1778 | } |
1749 | 1779 | |
1750 | 1780 | // Keep going. |
@@ -1757,8 +1787,9 @@ discard block |
||
1757 | 1787 | if ($do_fix) |
1758 | 1788 | { |
1759 | 1789 | $key = array_search($error_type, $to_fix); |
1760 | - if ($key !== false && isset($to_fix[$key])) |
|
1761 | - unset($to_fix[$key]); |
|
1790 | + if ($key !== false && isset($to_fix[$key])) { |
|
1791 | + unset($to_fix[$key]); |
|
1792 | + } |
|
1762 | 1793 | } |
1763 | 1794 | |
1764 | 1795 | // Are we done? |
@@ -1781,10 +1812,11 @@ discard block |
||
1781 | 1812 | static $createOnce = false; |
1782 | 1813 | |
1783 | 1814 | // Have we already created it? |
1784 | - if ($createOnce) |
|
1785 | - return; |
|
1786 | - else |
|
1787 | - $createOnce = true; |
|
1815 | + if ($createOnce) { |
|
1816 | + return; |
|
1817 | + } else { |
|
1818 | + $createOnce = true; |
|
1819 | + } |
|
1788 | 1820 | |
1789 | 1821 | // Back to the forum's default language. |
1790 | 1822 | loadLanguage('Admin', $language); |
@@ -1799,8 +1831,9 @@ discard block |
||
1799 | 1831 | 'cat_name' => $txt['salvaged_category_name'], |
1800 | 1832 | ) |
1801 | 1833 | ); |
1802 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
1803 | - list ($salvageCatID) = $smcFunc['db_fetch_row']($result); |
|
1834 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
1835 | + list ($salvageCatID) = $smcFunc['db_fetch_row']($result); |
|
1836 | + } |
|
1804 | 1837 | $smcFunc['db_free_result']($result); |
1805 | 1838 | |
1806 | 1839 | if (empty($salvageCatID)) |
@@ -1832,8 +1865,9 @@ discard block |
||
1832 | 1865 | 'board_name' => $txt['salvaged_board_name'], |
1833 | 1866 | ) |
1834 | 1867 | ); |
1835 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
1836 | - list ($salvageBoardID) = $smcFunc['db_fetch_row']($result); |
|
1868 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
1869 | + list ($salvageBoardID) = $smcFunc['db_fetch_row']($result); |
|
1870 | + } |
|
1837 | 1871 | $smcFunc['db_free_result']($result); |
1838 | 1872 | |
1839 | 1873 | if (empty($salvageBoardID)) |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | LEFT JOIN {db_prefix}topics AS t ON (t.id_topic = m.id_topic) |
233 | 233 | WHERE t.id_topic IS NULL |
234 | 234 | GROUP BY m.id_topic, m.id_board', |
235 | - 'fix_processing' => function ($row) use ($smcFunc) |
|
235 | + 'fix_processing' => function($row) use ($smcFunc) |
|
236 | 236 | { |
237 | 237 | global $salvageBoardID; |
238 | 238 | |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | // Remove all topics that have zero messages in the messages table. |
319 | 319 | 'fix_collect' => array( |
320 | 320 | 'index' => 'id_topic', |
321 | - 'process' => function ($topics) use ($smcFunc) |
|
321 | + 'process' => function($topics) use ($smcFunc) |
|
322 | 322 | { |
323 | 323 | $smcFunc['db_query']('', ' |
324 | 324 | DELETE FROM {db_prefix}topics |
@@ -356,21 +356,21 @@ discard block |
||
356 | 356 | AND p.id_poll IS NULL |
357 | 357 | GROUP BY o.id_poll, t.id_topic, t.id_board, t.id_member_started, m.member_name |
358 | 358 | ', |
359 | - 'fix_processing' => function ($row) use ($smcFunc, $txt) |
|
359 | + 'fix_processing' => function($row) use ($smcFunc, $txt) |
|
360 | 360 | { |
361 | 361 | global $salvageBoardID; |
362 | 362 | |
363 | 363 | $row['poster_name'] = !empty($row['poster_name']) ? $row['poster_name'] : $txt['guest']; |
364 | 364 | $row['id_poster'] = !empty($row['id_poster']) ? $row['id_poster'] : 0; |
365 | 365 | |
366 | - if(empty($row['id_board'])) |
|
366 | + if (empty($row['id_board'])) |
|
367 | 367 | { |
368 | 368 | // Only if we don't have a reasonable idea of where to put it. |
369 | 369 | createSalvageArea(); |
370 | - $row['id_board'] = (int)$salvageBoardID; |
|
370 | + $row['id_board'] = (int) $salvageBoardID; |
|
371 | 371 | } |
372 | 372 | |
373 | - if(empty($row['id_topic'])) { |
|
373 | + if (empty($row['id_topic'])) { |
|
374 | 374 | $newMessageID = $smcFunc['db_insert']('', |
375 | 375 | '{db_prefix}messages', |
376 | 376 | array( |
@@ -492,7 +492,7 @@ discard block |
||
492 | 492 | LEFT JOIN {db_prefix}topics AS t ON (t.id_poll = p.id_poll) |
493 | 493 | WHERE p.id_poll BETWEEN {STEP_LOW} AND {STEP_HIGH} |
494 | 494 | AND t.id_poll IS NULL', |
495 | - 'fix_processing' => function ($row) use ($smcFunc, $txt) |
|
495 | + 'fix_processing' => function($row) use ($smcFunc, $txt) |
|
496 | 496 | { |
497 | 497 | global $salvageBoardID; |
498 | 498 | |
@@ -605,7 +605,7 @@ discard block |
||
605 | 605 | WHERE t.id_topic BETWEEN {STEP_LOW} AND {STEP_HIGH} |
606 | 606 | GROUP BY t.id_topic, t.id_first_msg, t.id_last_msg, t.approved, mf.approved |
607 | 607 | ORDER BY t.id_topic', |
608 | - 'fix_processing' => function ($row) use ($smcFunc) |
|
608 | + 'fix_processing' => function($row) use ($smcFunc) |
|
609 | 609 | { |
610 | 610 | $row['firstmsg_approved'] = (int) $row['firstmsg_approved']; |
611 | 611 | $row['myid_first_msg'] = (int) $row['myid_first_msg']; |
@@ -634,7 +634,7 @@ discard block |
||
634 | 634 | ) |
635 | 635 | ); |
636 | 636 | }, |
637 | - 'message_function' => function ($row) use ($txt, &$context) |
|
637 | + 'message_function' => function($row) use ($txt, &$context) |
|
638 | 638 | { |
639 | 639 | // A pretend error? |
640 | 640 | if ($row['id_first_msg'] == $row['myid_first_msg'] && $row['id_last_msg'] == $row['myid_last_msg'] && $row['approved'] == $row['firstmsg_approved']) |
@@ -668,7 +668,7 @@ discard block |
||
668 | 668 | WHERE t.id_topic BETWEEN {STEP_LOW} AND {STEP_HIGH} |
669 | 669 | GROUP BY t.id_topic, t.num_replies, mf.approved |
670 | 670 | ORDER BY t.id_topic', |
671 | - 'fix_processing' => function ($row) |
|
671 | + 'fix_processing' => function($row) |
|
672 | 672 | { |
673 | 673 | |
674 | 674 | global $smcFunc; |
@@ -689,7 +689,7 @@ discard block |
||
689 | 689 | ); |
690 | 690 | |
691 | 691 | }, |
692 | - 'message_function' => function ($row) |
|
692 | + 'message_function' => function($row) |
|
693 | 693 | { |
694 | 694 | |
695 | 695 | global $txt, $context; |
@@ -722,7 +722,7 @@ discard block |
||
722 | 722 | GROUP BY t.id_topic, t.unapproved_posts |
723 | 723 | HAVING unapproved_posts != COUNT(mu.id_msg) |
724 | 724 | ORDER BY t.id_topic', |
725 | - 'fix_processing' => function ($row) |
|
725 | + 'fix_processing' => function($row) |
|
726 | 726 | { |
727 | 727 | |
728 | 728 | global $smcFunc; |
@@ -764,7 +764,7 @@ discard block |
||
764 | 764 | WHERE b.id_board IS NULL |
765 | 765 | AND t.id_topic BETWEEN {STEP_LOW} AND {STEP_HIGH} |
766 | 766 | GROUP BY t.id_board', |
767 | - 'fix_processing' => function ($row) |
|
767 | + 'fix_processing' => function($row) |
|
768 | 768 | { |
769 | 769 | |
770 | 770 | global $smcFunc, $salvageCatID, $txt; |
@@ -813,7 +813,7 @@ discard block |
||
813 | 813 | ORDER BY b.id_cat, b.id_board', |
814 | 814 | 'fix_collect' => array( |
815 | 815 | 'index' => 'id_cat', |
816 | - 'process' => function ($cats) |
|
816 | + 'process' => function($cats) |
|
817 | 817 | { |
818 | 818 | global $smcFunc, $salvageCatID; |
819 | 819 | createSalvageArea(); |
@@ -849,7 +849,7 @@ discard block |
||
849 | 849 | // Last step-make sure all non-guest posters still exist. |
850 | 850 | 'fix_collect' => array( |
851 | 851 | 'index' => 'id_msg', |
852 | - 'process' => function ($msgs) |
|
852 | + 'process' => function($msgs) |
|
853 | 853 | { |
854 | 854 | |
855 | 855 | global $smcFunc; |
@@ -878,7 +878,7 @@ discard block |
||
878 | 878 | ORDER BY b.id_parent, b.id_board', |
879 | 879 | 'fix_collect' => array( |
880 | 880 | 'index' => 'id_parent', |
881 | - 'process' => function ($parents) |
|
881 | + 'process' => function($parents) |
|
882 | 882 | { |
883 | 883 | global $smcFunc, $salvageBoardID, $salvageCatID; |
884 | 884 | createSalvageArea(); |
@@ -912,7 +912,7 @@ discard block |
||
912 | 912 | AND p.id_poll IS NULL', |
913 | 913 | 'fix_collect' => array( |
914 | 914 | 'index' => 'id_poll', |
915 | - 'process' => function ($polls) |
|
915 | + 'process' => function($polls) |
|
916 | 916 | { |
917 | 917 | |
918 | 918 | global $smcFunc; |
@@ -946,7 +946,7 @@ discard block |
||
946 | 946 | ORDER BY cal.id_topic', |
947 | 947 | 'fix_collect' => array( |
948 | 948 | 'index' => 'id_topic', |
949 | - 'process' => function ($events) |
|
949 | + 'process' => function($events) |
|
950 | 950 | { |
951 | 951 | |
952 | 952 | global $smcFunc; |
@@ -978,7 +978,7 @@ discard block |
||
978 | 978 | AND lt.id_member BETWEEN {STEP_LOW} AND {STEP_HIGH}', |
979 | 979 | 'fix_collect' => array( |
980 | 980 | 'index' => 'id_topic', |
981 | - 'process' => function ($topics) |
|
981 | + 'process' => function($topics) |
|
982 | 982 | { |
983 | 983 | |
984 | 984 | global $smcFunc; |
@@ -1010,7 +1010,7 @@ discard block |
||
1010 | 1010 | GROUP BY lt.id_member', |
1011 | 1011 | 'fix_collect' => array( |
1012 | 1012 | 'index' => 'id_member', |
1013 | - 'process' => function ($members) |
|
1013 | + 'process' => function($members) |
|
1014 | 1014 | { |
1015 | 1015 | |
1016 | 1016 | global $smcFunc; |
@@ -1042,7 +1042,7 @@ discard block |
||
1042 | 1042 | GROUP BY lb.id_board', |
1043 | 1043 | 'fix_collect' => array( |
1044 | 1044 | 'index' => 'id_board', |
1045 | - 'process' => function ($boards) |
|
1045 | + 'process' => function($boards) |
|
1046 | 1046 | { |
1047 | 1047 | |
1048 | 1048 | global $smcFunc; |
@@ -1074,7 +1074,7 @@ discard block |
||
1074 | 1074 | GROUP BY lb.id_member', |
1075 | 1075 | 'fix_collect' => array( |
1076 | 1076 | 'index' => 'id_member', |
1077 | - 'process' => function ($members) use ($smcFunc) |
|
1077 | + 'process' => function($members) use ($smcFunc) |
|
1078 | 1078 | { |
1079 | 1079 | $smcFunc['db_query']('', ' |
1080 | 1080 | DELETE FROM {db_prefix}log_boards |
@@ -1103,7 +1103,7 @@ discard block |
||
1103 | 1103 | GROUP BY lmr.id_board', |
1104 | 1104 | 'fix_collect' => array( |
1105 | 1105 | 'index' => 'id_board', |
1106 | - 'process' => function ($boards) use ($smcFunc) |
|
1106 | + 'process' => function($boards) use ($smcFunc) |
|
1107 | 1107 | { |
1108 | 1108 | $smcFunc['db_query']('', ' |
1109 | 1109 | DELETE FROM {db_prefix}log_mark_read |
@@ -1132,7 +1132,7 @@ discard block |
||
1132 | 1132 | GROUP BY lmr.id_member', |
1133 | 1133 | 'fix_collect' => array( |
1134 | 1134 | 'index' => 'id_member', |
1135 | - 'process' => function ($members) use ($smcFunc) |
|
1135 | + 'process' => function($members) use ($smcFunc) |
|
1136 | 1136 | { |
1137 | 1137 | $smcFunc['db_query']('', ' |
1138 | 1138 | DELETE FROM {db_prefix}log_mark_read |
@@ -1161,7 +1161,7 @@ discard block |
||
1161 | 1161 | GROUP BY pmr.id_pm', |
1162 | 1162 | 'fix_collect' => array( |
1163 | 1163 | 'index' => 'id_pm', |
1164 | - 'process' => function ($pms) use ($smcFunc) |
|
1164 | + 'process' => function($pms) use ($smcFunc) |
|
1165 | 1165 | { |
1166 | 1166 | $smcFunc['db_query']('', ' |
1167 | 1167 | DELETE FROM {db_prefix}pm_recipients |
@@ -1191,7 +1191,7 @@ discard block |
||
1191 | 1191 | GROUP BY pmr.id_member', |
1192 | 1192 | 'fix_collect' => array( |
1193 | 1193 | 'index' => 'id_member', |
1194 | - 'process' => function ($members) |
|
1194 | + 'process' => function($members) |
|
1195 | 1195 | { |
1196 | 1196 | |
1197 | 1197 | global $smcFunc; |
@@ -1223,7 +1223,7 @@ discard block |
||
1223 | 1223 | AND mem.id_member IS NULL', |
1224 | 1224 | 'fix_collect' => array( |
1225 | 1225 | 'index' => 'id_pm', |
1226 | - 'process' => function ($guestMessages) |
|
1226 | + 'process' => function($guestMessages) |
|
1227 | 1227 | { |
1228 | 1228 | |
1229 | 1229 | global $smcFunc; |
@@ -1255,7 +1255,7 @@ discard block |
||
1255 | 1255 | GROUP BY ln.id_member', |
1256 | 1256 | 'fix_collect' => array( |
1257 | 1257 | 'index' => 'id_member', |
1258 | - 'process' => function ($members) use ($smcFunc) |
|
1258 | + 'process' => function($members) use ($smcFunc) |
|
1259 | 1259 | { |
1260 | 1260 | $smcFunc['db_query']('', ' |
1261 | 1261 | DELETE FROM {db_prefix}log_notify |
@@ -1282,7 +1282,7 @@ discard block |
||
1282 | 1282 | LEFT JOIN {db_prefix}log_search_subjects AS lss ON (lss.id_topic = t.id_topic) |
1283 | 1283 | WHERE t.id_topic BETWEEN {STEP_LOW} AND {STEP_HIGH} |
1284 | 1284 | AND lss.id_topic IS NULL', |
1285 | - 'fix_full_processing' => function ($result) |
|
1285 | + 'fix_full_processing' => function($result) |
|
1286 | 1286 | { |
1287 | 1287 | |
1288 | 1288 | global $smcFunc; |
@@ -1314,7 +1314,7 @@ discard block |
||
1314 | 1314 | ); |
1315 | 1315 | |
1316 | 1316 | }, |
1317 | - 'message_function' => function ($row) |
|
1317 | + 'message_function' => function($row) |
|
1318 | 1318 | { |
1319 | 1319 | |
1320 | 1320 | global $txt, $context; |
@@ -1344,7 +1344,7 @@ discard block |
||
1344 | 1344 | AND t.id_topic IS NULL', |
1345 | 1345 | 'fix_collect' => array( |
1346 | 1346 | 'index' => 'id_topic', |
1347 | - 'process' => function ($deleteTopics) |
|
1347 | + 'process' => function($deleteTopics) |
|
1348 | 1348 | { |
1349 | 1349 | |
1350 | 1350 | global $smcFunc; |
@@ -1376,7 +1376,7 @@ discard block |
||
1376 | 1376 | AND mem.id_member IS NULL', |
1377 | 1377 | 'fix_collect' => array( |
1378 | 1378 | 'index' => 'id_member', |
1379 | - 'process' => function ($members) |
|
1379 | + 'process' => function($members) |
|
1380 | 1380 | { |
1381 | 1381 | |
1382 | 1382 | global $smcFunc; |
@@ -1407,7 +1407,7 @@ discard block |
||
1407 | 1407 | AND p.id_poll IS NULL', |
1408 | 1408 | 'fix_collect' => array( |
1409 | 1409 | 'index' => 'id_poll', |
1410 | - 'process' => function ($polls) |
|
1410 | + 'process' => function($polls) |
|
1411 | 1411 | { |
1412 | 1412 | |
1413 | 1413 | global $smcFunc; |
@@ -1438,7 +1438,7 @@ discard block |
||
1438 | 1438 | AND lrc.id_report IS NULL', |
1439 | 1439 | 'fix_collect' => array( |
1440 | 1440 | 'index' => 'id_report', |
1441 | - 'process' => function ($reports) |
|
1441 | + 'process' => function($reports) |
|
1442 | 1442 | { |
1443 | 1443 | |
1444 | 1444 | global $smcFunc; |
@@ -1469,7 +1469,7 @@ discard block |
||
1469 | 1469 | AND lr.id_report IS NULL', |
1470 | 1470 | 'fix_collect' => array( |
1471 | 1471 | 'index' => 'id_report', |
1472 | - 'process' => function ($reports) |
|
1472 | + 'process' => function($reports) |
|
1473 | 1473 | { |
1474 | 1474 | global $smcFunc; |
1475 | 1475 | $smcFunc['db_query']('', ' |
@@ -1499,7 +1499,7 @@ discard block |
||
1499 | 1499 | GROUP BY lgr.id_member', |
1500 | 1500 | 'fix_collect' => array( |
1501 | 1501 | 'index' => 'id_member', |
1502 | - 'process' => function ($members) |
|
1502 | + 'process' => function($members) |
|
1503 | 1503 | { |
1504 | 1504 | global $smcFunc; |
1505 | 1505 | $smcFunc['db_query']('', ' |
@@ -1529,7 +1529,7 @@ discard block |
||
1529 | 1529 | GROUP BY lgr.id_group', |
1530 | 1530 | 'fix_collect' => array( |
1531 | 1531 | 'index' => 'id_group', |
1532 | - 'process' => function ($groups) |
|
1532 | + 'process' => function($groups) |
|
1533 | 1533 | { |
1534 | 1534 | global $smcFunc; |
1535 | 1535 | $smcFunc['db_query']('', ' |
@@ -898,13 +898,13 @@ |
||
898 | 898 | if ($start_char === 'C') |
899 | 899 | $limit_seek = $limit; |
900 | 900 | else |
901 | - $limit_seek = $limit + 1; |
|
901 | + $limit_seek = $limit + 1; |
|
902 | 902 | |
903 | 903 | $request = $smcFunc['db_query']('', ' |
904 | 904 | SELECT id_msg, id_member, approved |
905 | 905 | FROM {db_prefix}messages |
906 | 906 | WHERE id_topic = {int:current_topic} |
907 | - AND id_msg '. $page_operator . ' {int:page_id}'. (!$modSettings['postmod_active'] || $approve_posts ? '' : ' |
|
907 | + AND id_msg '. $page_operator . ' {int:page_id}' . (!$modSettings['postmod_active'] || $approve_posts ? '' : ' |
|
908 | 908 | AND (approved = {int:is_approved}' . ($user_info['is_guest'] ? '' : ' OR id_member = {int:current_member}') . ')') . ' |
909 | 909 | ORDER BY id_msg ' . ($ascending ? '' : 'DESC') . ($context['messages_per_page'] == -1 ? '' : ' |
910 | 910 | LIMIT {int:limit}'), |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 4 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * The central part of the board - topic display. |
@@ -34,8 +35,9 @@ discard block |
||
34 | 35 | global $messages_request, $language, $smcFunc; |
35 | 36 | |
36 | 37 | // What are you gonna display if these are empty?! |
37 | - if (empty($topic)) |
|
38 | - fatal_lang_error('no_board', false); |
|
38 | + if (empty($topic)) { |
|
39 | + fatal_lang_error('no_board', false); |
|
40 | + } |
|
39 | 41 | |
40 | 42 | // Load the proper template. |
41 | 43 | loadTemplate('Display'); |
@@ -52,15 +54,17 @@ discard block |
||
52 | 54 | $context['messages_per_page'] = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages']; |
53 | 55 | |
54 | 56 | // Let's do some work on what to search index. |
55 | - if (count($_GET) > 2) |
|
56 | - foreach ($_GET as $k => $v) |
|
57 | + if (count($_GET) > 2) { |
|
58 | + foreach ($_GET as $k => $v) |
|
57 | 59 | { |
58 | 60 | if (!in_array($k, array('topic', 'board', 'start', session_name()))) |
59 | 61 | $context['robot_no_index'] = true; |
62 | + } |
|
60 | 63 | } |
61 | 64 | |
62 | - if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) |
|
63 | - $context['robot_no_index'] = true; |
|
65 | + if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) { |
|
66 | + $context['robot_no_index'] = true; |
|
67 | + } |
|
64 | 68 | |
65 | 69 | // Find the previous or next topic. Make a fuss if there are no more. |
66 | 70 | if (isset($_REQUEST['prev_next']) && ($_REQUEST['prev_next'] == 'prev' || $_REQUEST['prev_next'] == 'next')) |
@@ -172,8 +176,9 @@ discard block |
||
172 | 176 | $topic_parameters |
173 | 177 | ); |
174 | 178 | |
175 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
176 | - fatal_lang_error('not_a_topic', false, 404); |
|
179 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
180 | + fatal_lang_error('not_a_topic', false, 404); |
|
181 | + } |
|
177 | 182 | $context['topicinfo'] = $smcFunc['db_fetch_assoc']($request); |
178 | 183 | $smcFunc['db_free_result']($request); |
179 | 184 | |
@@ -210,8 +215,9 @@ discard block |
||
210 | 215 | $context['topic_unwatched'] = isset($context['topicinfo']['unwatched']) ? $context['topicinfo']['unwatched'] : 0; |
211 | 216 | |
212 | 217 | // Add up unapproved replies to get real number of replies... |
213 | - if ($modSettings['postmod_active'] && $approve_posts) |
|
214 | - $context['real_num_replies'] += $context['topicinfo']['unapproved_posts'] - ($context['topicinfo']['approved'] ? 0 : 1); |
|
218 | + if ($modSettings['postmod_active'] && $approve_posts) { |
|
219 | + $context['real_num_replies'] += $context['topicinfo']['unapproved_posts'] - ($context['topicinfo']['approved'] ? 0 : 1); |
|
220 | + } |
|
215 | 221 | |
216 | 222 | // If this topic has unapproved posts, we need to work out how many posts the user can see, for page indexing. |
217 | 223 | if ($modSettings['postmod_active'] && $context['topicinfo']['unapproved_posts'] && !$user_info['is_guest'] && !$approve_posts) |
@@ -231,11 +237,11 @@ discard block |
||
231 | 237 | $smcFunc['db_free_result']($request); |
232 | 238 | |
233 | 239 | $context['total_visible_posts'] = $context['num_replies'] + $myUnapprovedPosts + ($context['topicinfo']['approved'] ? 1 : 0); |
240 | + } elseif ($user_info['is_guest']) { |
|
241 | + $context['total_visible_posts'] = $context['num_replies'] + ($context['topicinfo']['approved'] ? 1 : 0); |
|
242 | + } else { |
|
243 | + $context['total_visible_posts'] = $context['num_replies'] + $context['topicinfo']['unapproved_posts'] + ($context['topicinfo']['approved'] ? 1 : 0); |
|
234 | 244 | } |
235 | - elseif ($user_info['is_guest']) |
|
236 | - $context['total_visible_posts'] = $context['num_replies'] + ($context['topicinfo']['approved'] ? 1 : 0); |
|
237 | - else |
|
238 | - $context['total_visible_posts'] = $context['num_replies'] + $context['topicinfo']['unapproved_posts'] + ($context['topicinfo']['approved'] ? 1 : 0); |
|
239 | 245 | |
240 | 246 | // The start isn't a number; it's information about what to do, where to go. |
241 | 247 | if (!is_numeric($_REQUEST['start'])) |
@@ -248,8 +254,7 @@ discard block |
||
248 | 254 | { |
249 | 255 | $context['start_from'] = $context['total_visible_posts'] - 1; |
250 | 256 | $_REQUEST['start'] = empty($options['view_newest_first']) ? $context['start_from'] : 0; |
251 | - } |
|
252 | - else |
|
257 | + } else |
|
253 | 258 | { |
254 | 259 | // Find the earliest unread message in the topic. (the use of topics here is just for both tables.) |
255 | 260 | $request = $smcFunc['db_query']('', ' |
@@ -277,9 +282,9 @@ discard block |
||
277 | 282 | if (substr($_REQUEST['start'], 0, 4) == 'from') |
278 | 283 | { |
279 | 284 | $timestamp = (int) substr($_REQUEST['start'], 4); |
280 | - if ($timestamp === 0) |
|
281 | - $_REQUEST['start'] = 0; |
|
282 | - else |
|
285 | + if ($timestamp === 0) { |
|
286 | + $_REQUEST['start'] = 0; |
|
287 | + } else |
|
283 | 288 | { |
284 | 289 | // Find the number of messages posted before said time... |
285 | 290 | $request = $smcFunc['db_query']('', ' |
@@ -307,11 +312,11 @@ discard block |
||
307 | 312 | elseif (substr($_REQUEST['start'], 0, 3) == 'msg') |
308 | 313 | { |
309 | 314 | $virtual_msg = (int) substr($_REQUEST['start'], 3); |
310 | - if (!$context['topicinfo']['unapproved_posts'] && $virtual_msg >= $context['topicinfo']['id_last_msg']) |
|
311 | - $context['start_from'] = $context['total_visible_posts'] - 1; |
|
312 | - elseif (!$context['topicinfo']['unapproved_posts'] && $virtual_msg <= $context['topicinfo']['id_first_msg']) |
|
313 | - $context['start_from'] = 0; |
|
314 | - else |
|
315 | + if (!$context['topicinfo']['unapproved_posts'] && $virtual_msg >= $context['topicinfo']['id_last_msg']) { |
|
316 | + $context['start_from'] = $context['total_visible_posts'] - 1; |
|
317 | + } elseif (!$context['topicinfo']['unapproved_posts'] && $virtual_msg <= $context['topicinfo']['id_first_msg']) { |
|
318 | + $context['start_from'] = 0; |
|
319 | + } else |
|
315 | 320 | { |
316 | 321 | // Find the start value for that message...... |
317 | 322 | $request = $smcFunc['db_query']('', ' |
@@ -394,21 +399,25 @@ discard block |
||
394 | 399 | ); |
395 | 400 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
396 | 401 | { |
397 | - if (empty($row['id_member'])) |
|
398 | - continue; |
|
402 | + if (empty($row['id_member'])) { |
|
403 | + continue; |
|
404 | + } |
|
399 | 405 | |
400 | - if (!empty($row['online_color'])) |
|
401 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
402 | - else |
|
403 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
406 | + if (!empty($row['online_color'])) { |
|
407 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
408 | + } else { |
|
409 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
410 | + } |
|
404 | 411 | |
405 | 412 | $is_buddy = in_array($row['id_member'], $user_info['buddies']); |
406 | - if ($is_buddy) |
|
407 | - $link = '<strong>' . $link . '</strong>'; |
|
413 | + if ($is_buddy) { |
|
414 | + $link = '<strong>' . $link . '</strong>'; |
|
415 | + } |
|
408 | 416 | |
409 | 417 | // Add them both to the list and to the more detailed list. |
410 | - if (!empty($row['show_online']) || allowedTo('moderate_forum')) |
|
411 | - $context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
|
418 | + if (!empty($row['show_online']) || allowedTo('moderate_forum')) { |
|
419 | + $context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
|
420 | + } |
|
412 | 421 | $context['view_members'][$row['log_time'] . $row['member_name']] = array( |
413 | 422 | 'id' => $row['id_member'], |
414 | 423 | 'username' => $row['member_name'], |
@@ -420,8 +429,9 @@ discard block |
||
420 | 429 | 'hidden' => empty($row['show_online']), |
421 | 430 | ); |
422 | 431 | |
423 | - if (empty($row['show_online'])) |
|
424 | - $context['view_num_hidden']++; |
|
432 | + if (empty($row['show_online'])) { |
|
433 | + $context['view_num_hidden']++; |
|
434 | + } |
|
425 | 435 | } |
426 | 436 | |
427 | 437 | // The number of guests is equal to the rows minus the ones we actually used ;). |
@@ -435,11 +445,13 @@ discard block |
||
435 | 445 | |
436 | 446 | // If all is set, but not allowed... just unset it. |
437 | 447 | $can_show_all = !empty($modSettings['enableAllMessages']) && $context['total_visible_posts'] > $context['messages_per_page'] && $context['total_visible_posts'] < $modSettings['enableAllMessages']; |
438 | - if (isset($_REQUEST['all']) && !$can_show_all) |
|
439 | - unset($_REQUEST['all']); |
|
448 | + if (isset($_REQUEST['all']) && !$can_show_all) { |
|
449 | + unset($_REQUEST['all']); |
|
450 | + } |
|
440 | 451 | // Otherwise, it must be allowed... so pretend start was -1. |
441 | - elseif (isset($_REQUEST['all'])) |
|
442 | - $_REQUEST['start'] = -1; |
|
452 | + elseif (isset($_REQUEST['all'])) { |
|
453 | + $_REQUEST['start'] = -1; |
|
454 | + } |
|
443 | 455 | |
444 | 456 | // Construct the page index, allowing for the .START method... |
445 | 457 | $context['page_index'] = constructPageIndex($scripturl . '?topic=' . $topic . '.%1$d', $_REQUEST['start'], $context['total_visible_posts'], $context['messages_per_page'], true); |
@@ -476,8 +488,9 @@ discard block |
||
476 | 488 | $_REQUEST['start'] = 0; |
477 | 489 | } |
478 | 490 | // They aren't using it, but the *option* is there, at least. |
479 | - else |
|
480 | - $context['page_index'] .= ' <a href="' . $scripturl . '?topic=' . $topic . '.0;all">' . $txt['all'] . '</a> '; |
|
491 | + else { |
|
492 | + $context['page_index'] .= ' <a href="' . $scripturl . '?topic=' . $topic . '.0;all">' . $txt['all'] . '</a> '; |
|
493 | + } |
|
481 | 494 | } |
482 | 495 | |
483 | 496 | // Build the link tree. |
@@ -493,14 +506,16 @@ discard block |
||
493 | 506 | if (!empty($board_info['moderators'])) |
494 | 507 | { |
495 | 508 | // Add a link for each moderator... |
496 | - foreach ($board_info['moderators'] as $mod) |
|
497 | - $context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>'; |
|
509 | + foreach ($board_info['moderators'] as $mod) { |
|
510 | + $context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>'; |
|
511 | + } |
|
498 | 512 | } |
499 | 513 | if (!empty($board_info['moderator_groups'])) |
500 | 514 | { |
501 | 515 | // Add a link for each moderator group as well... |
502 | - foreach ($board_info['moderator_groups'] as $mod_group) |
|
503 | - $context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=viewmemberes;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>'; |
|
516 | + foreach ($board_info['moderator_groups'] as $mod_group) { |
|
517 | + $context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=viewmemberes;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>'; |
|
518 | + } |
|
504 | 519 | } |
505 | 520 | |
506 | 521 | if (!empty($context['link_moderators'])) |
@@ -531,9 +546,9 @@ discard block |
||
531 | 546 | // For quick reply we need a response prefix in the default forum language. |
532 | 547 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix', 600))) |
533 | 548 | { |
534 | - if ($language === $user_info['language']) |
|
535 | - $context['response_prefix'] = $txt['response_prefix']; |
|
536 | - else |
|
549 | + if ($language === $user_info['language']) { |
|
550 | + $context['response_prefix'] = $txt['response_prefix']; |
|
551 | + } else |
|
537 | 552 | { |
538 | 553 | loadLanguage('index', $language, false); |
539 | 554 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -565,8 +580,9 @@ discard block |
||
565 | 580 | list($start, $end, $allday, $span, $tz, $tz_abbrev) = buildEventDatetimes($row); |
566 | 581 | |
567 | 582 | // Sanity check |
568 | - if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) |
|
569 | - continue; |
|
583 | + if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) { |
|
584 | + continue; |
|
585 | + } |
|
570 | 586 | |
571 | 587 | $linked_calendar_event = array( |
572 | 588 | 'id' => $row['id_event'], |
@@ -615,8 +631,9 @@ discard block |
||
615 | 631 | } |
616 | 632 | $smcFunc['db_free_result']($request); |
617 | 633 | |
618 | - if (!empty($context['linked_calendar_events'])) |
|
619 | - $context['linked_calendar_events'][count($context['linked_calendar_events']) - 1]['is_last'] = true; |
|
634 | + if (!empty($context['linked_calendar_events'])) { |
|
635 | + $context['linked_calendar_events'][count($context['linked_calendar_events']) - 1]['is_last'] = true; |
|
636 | + } |
|
620 | 637 | } |
621 | 638 | |
622 | 639 | // Create the poll info if it exists. |
@@ -679,8 +696,9 @@ discard block |
||
679 | 696 | $smcFunc['db_free_result']($request); |
680 | 697 | |
681 | 698 | // Got we multi choice? |
682 | - if ($pollinfo['max_votes'] > 1) |
|
683 | - $realtotal = $pollinfo['total']; |
|
699 | + if ($pollinfo['max_votes'] > 1) { |
|
700 | + $realtotal = $pollinfo['total']; |
|
701 | + } |
|
684 | 702 | |
685 | 703 | // If this is a guest we need to do our best to work out if they have voted, and what they voted for. |
686 | 704 | if ($user_info['is_guest'] && $pollinfo['guest_vote'] && allowedTo('poll_vote')) |
@@ -693,20 +711,21 @@ discard block |
||
693 | 711 | foreach ($guestinfo as $i => $guestvoted) |
694 | 712 | { |
695 | 713 | $guestvoted = explode(',', $guestvoted); |
696 | - if ($guestvoted[0] == $context['topicinfo']['id_poll']) |
|
697 | - break; |
|
714 | + if ($guestvoted[0] == $context['topicinfo']['id_poll']) { |
|
715 | + break; |
|
716 | + } |
|
698 | 717 | } |
699 | 718 | // Has the poll been reset since guest voted? |
700 | 719 | if ($pollinfo['reset_poll'] > $guestvoted[1]) |
701 | 720 | { |
702 | 721 | // Remove the poll info from the cookie to allow guest to vote again |
703 | 722 | unset($guestinfo[$i]); |
704 | - if (!empty($guestinfo)) |
|
705 | - $_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo); |
|
706 | - else |
|
707 | - unset($_COOKIE['guest_poll_vote']); |
|
708 | - } |
|
709 | - else |
|
723 | + if (!empty($guestinfo)) { |
|
724 | + $_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo); |
|
725 | + } else { |
|
726 | + unset($_COOKIE['guest_poll_vote']); |
|
727 | + } |
|
728 | + } else |
|
710 | 729 | { |
711 | 730 | // What did they vote for? |
712 | 731 | unset($guestvoted[0], $guestvoted[1]); |
@@ -820,23 +839,29 @@ discard block |
||
820 | 839 | // Build the poll moderation button array. |
821 | 840 | $context['poll_buttons'] = array(); |
822 | 841 | |
823 | - if ($context['allow_return_vote']) |
|
824 | - $context['poll_buttons']['vote'] = array('text' => 'poll_return_vote', 'image' => 'poll_options.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start']); |
|
842 | + if ($context['allow_return_vote']) { |
|
843 | + $context['poll_buttons']['vote'] = array('text' => 'poll_return_vote', 'image' => 'poll_options.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start']); |
|
844 | + } |
|
825 | 845 | |
826 | - if ($context['show_view_results_button']) |
|
827 | - $context['poll_buttons']['results'] = array('text' => 'poll_results', 'image' => 'poll_results.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start'] . ';viewresults'); |
|
846 | + if ($context['show_view_results_button']) { |
|
847 | + $context['poll_buttons']['results'] = array('text' => 'poll_results', 'image' => 'poll_results.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start'] . ';viewresults'); |
|
848 | + } |
|
828 | 849 | |
829 | - if ($context['allow_change_vote']) |
|
830 | - $context['poll_buttons']['change_vote'] = array('text' => 'poll_change_vote', 'image' => 'poll_change_vote.png', 'url' => $scripturl . '?action=vote;topic=' . $context['current_topic'] . '.' . $context['start'] . ';poll=' . $context['poll']['id'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
850 | + if ($context['allow_change_vote']) { |
|
851 | + $context['poll_buttons']['change_vote'] = array('text' => 'poll_change_vote', 'image' => 'poll_change_vote.png', 'url' => $scripturl . '?action=vote;topic=' . $context['current_topic'] . '.' . $context['start'] . ';poll=' . $context['poll']['id'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
852 | + } |
|
831 | 853 | |
832 | - if ($context['allow_lock_poll']) |
|
833 | - $context['poll_buttons']['lock'] = array('text' => (!$context['poll']['is_locked'] ? 'poll_lock' : 'poll_unlock'), 'image' => 'poll_lock.png', 'url' => $scripturl . '?action=lockvoting;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
854 | + if ($context['allow_lock_poll']) { |
|
855 | + $context['poll_buttons']['lock'] = array('text' => (!$context['poll']['is_locked'] ? 'poll_lock' : 'poll_unlock'), 'image' => 'poll_lock.png', 'url' => $scripturl . '?action=lockvoting;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
856 | + } |
|
834 | 857 | |
835 | - if ($context['allow_edit_poll']) |
|
836 | - $context['poll_buttons']['edit'] = array('text' => 'poll_edit', 'image' => 'poll_edit.png', 'url' => $scripturl . '?action=editpoll;topic=' . $context['current_topic'] . '.' . $context['start']); |
|
858 | + if ($context['allow_edit_poll']) { |
|
859 | + $context['poll_buttons']['edit'] = array('text' => 'poll_edit', 'image' => 'poll_edit.png', 'url' => $scripturl . '?action=editpoll;topic=' . $context['current_topic'] . '.' . $context['start']); |
|
860 | + } |
|
837 | 861 | |
838 | - if ($context['can_remove_poll']) |
|
839 | - $context['poll_buttons']['remove_poll'] = array('text' => 'poll_remove', 'image' => 'admin_remove_poll.png', 'custom' => 'data-confirm="' . $txt['poll_remove_warn'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removepoll;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
862 | + if ($context['can_remove_poll']) { |
|
863 | + $context['poll_buttons']['remove_poll'] = array('text' => 'poll_remove', 'image' => 'admin_remove_poll.png', 'custom' => 'data-confirm="' . $txt['poll_remove_warn'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removepoll;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
864 | + } |
|
840 | 865 | |
841 | 866 | // Allow mods to add additional buttons here |
842 | 867 | call_integration_hook('integrate_poll_buttons'); |
@@ -871,9 +896,9 @@ discard block |
||
871 | 896 | { |
872 | 897 | $start_char = 'C'; |
873 | 898 | $page_id = $context['topicinfo']['id_first_msg']; |
899 | + } else { |
|
900 | + $start_char = null; |
|
874 | 901 | } |
875 | - else |
|
876 | - $start_char = null; |
|
877 | 902 | |
878 | 903 | $limit = $context['messages_per_page']; |
879 | 904 | |
@@ -888,17 +913,17 @@ discard block |
||
888 | 913 | { |
889 | 914 | $ascending = true; |
890 | 915 | $page_operator = '>='; |
891 | - } |
|
892 | - else |
|
916 | + } else |
|
893 | 917 | { |
894 | 918 | $ascending = false; |
895 | 919 | $page_operator = '<='; |
896 | 920 | } |
897 | 921 | |
898 | - if ($start_char === 'C') |
|
899 | - $limit_seek = $limit; |
|
900 | - else |
|
901 | - $limit_seek = $limit + 1; |
|
922 | + if ($start_char === 'C') { |
|
923 | + $limit_seek = $limit; |
|
924 | + } else { |
|
925 | + $limit_seek = $limit + 1; |
|
926 | + } |
|
902 | 927 | |
903 | 928 | $request = $smcFunc['db_query']('', ' |
904 | 929 | SELECT id_msg, id_member, approved |
@@ -921,21 +946,23 @@ discard block |
||
921 | 946 | $found_msg = false; |
922 | 947 | |
923 | 948 | // Fallback |
924 | - if ($smcFunc['db_num_rows']($request) < 1) |
|
925 | - unset($start_char); |
|
926 | - else |
|
949 | + if ($smcFunc['db_num_rows']($request) < 1) { |
|
950 | + unset($start_char); |
|
951 | + } else |
|
927 | 952 | { |
928 | 953 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
929 | 954 | { |
930 | 955 | // Check if the start msg is in our result |
931 | - if ($row['id_msg'] == $page_id) |
|
932 | - $found_msg = true; |
|
956 | + if ($row['id_msg'] == $page_id) { |
|
957 | + $found_msg = true; |
|
958 | + } |
|
933 | 959 | |
934 | 960 | // Skip the the start msg if we not in mode C |
935 | 961 | if ($start_char === 'C' || $row['id_msg'] != $page_id) |
936 | 962 | { |
937 | - if (!empty($row['id_member'])) |
|
938 | - $all_posters[$row['id_msg']] = $row['id_member']; |
|
963 | + if (!empty($row['id_member'])) { |
|
964 | + $all_posters[$row['id_msg']] = $row['id_member']; |
|
965 | + } |
|
939 | 966 | |
940 | 967 | $messages[] = $row['id_msg']; |
941 | 968 | } |
@@ -951,8 +978,9 @@ discard block |
||
951 | 978 | } |
952 | 979 | |
953 | 980 | // Before Page bring in the right order |
954 | - if (!empty($start_char) && $start_char === 'L') |
|
955 | - krsort($messages); |
|
981 | + if (!empty($start_char) && $start_char === 'L') { |
|
982 | + krsort($messages); |
|
983 | + } |
|
956 | 984 | } |
957 | 985 | |
958 | 986 | // Jump to page |
@@ -989,14 +1017,16 @@ discard block |
||
989 | 1017 | |
990 | 1018 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
991 | 1019 | { |
992 | - if (!empty($row['id_member'])) |
|
993 | - $all_posters[$row['id_msg']] = $row['id_member']; |
|
1020 | + if (!empty($row['id_member'])) { |
|
1021 | + $all_posters[$row['id_msg']] = $row['id_member']; |
|
1022 | + } |
|
994 | 1023 | $messages[] = $row['id_msg']; |
995 | 1024 | } |
996 | 1025 | |
997 | 1026 | // Sort the messages into the correct display order |
998 | - if (!$ascending) |
|
999 | - sort($messages); |
|
1027 | + if (!$ascending) { |
|
1028 | + sort($messages); |
|
1029 | + } |
|
1000 | 1030 | } |
1001 | 1031 | |
1002 | 1032 | // Remember the paging data for next time |
@@ -1016,8 +1046,9 @@ discard block |
||
1016 | 1046 | if (!$user_info['is_guest'] && !empty($messages)) |
1017 | 1047 | { |
1018 | 1048 | $mark_at_msg = max($messages); |
1019 | - if ($mark_at_msg >= $context['topicinfo']['id_last_msg']) |
|
1020 | - $mark_at_msg = $modSettings['maxMsgID']; |
|
1049 | + if ($mark_at_msg >= $context['topicinfo']['id_last_msg']) { |
|
1050 | + $mark_at_msg = $modSettings['maxMsgID']; |
|
1051 | + } |
|
1021 | 1052 | if ($mark_at_msg >= $context['topicinfo']['new_from']) |
1022 | 1053 | { |
1023 | 1054 | $smcFunc['db_insert']($context['topicinfo']['new_from'] == 0 ? 'ignore' : 'replace', |
@@ -1049,8 +1080,9 @@ discard block |
||
1049 | 1080 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1050 | 1081 | { |
1051 | 1082 | // Find if this topic is marked for notification... |
1052 | - if (!empty($row['id_topic'])) |
|
1053 | - $context['is_marked_notify'] = true; |
|
1083 | + if (!empty($row['id_topic'])) { |
|
1084 | + $context['is_marked_notify'] = true; |
|
1085 | + } |
|
1054 | 1086 | |
1055 | 1087 | // Only do this once, but mark the notifications as "not sent yet" for next time. |
1056 | 1088 | if (!empty($row['sent']) && $do_once) |
@@ -1072,8 +1104,9 @@ discard block |
||
1072 | 1104 | } |
1073 | 1105 | |
1074 | 1106 | // Have we recently cached the number of new topics in this board, and it's still a lot? |
1075 | - if (isset($_REQUEST['topicseen']) && isset($_SESSION['topicseen_cache'][$board]) && $_SESSION['topicseen_cache'][$board] > 5) |
|
1076 | - $_SESSION['topicseen_cache'][$board]--; |
|
1107 | + if (isset($_REQUEST['topicseen']) && isset($_SESSION['topicseen_cache'][$board]) && $_SESSION['topicseen_cache'][$board] > 5) { |
|
1108 | + $_SESSION['topicseen_cache'][$board]--; |
|
1109 | + } |
|
1077 | 1110 | // Mark board as seen if this is the only new topic. |
1078 | 1111 | elseif (isset($_REQUEST['topicseen'])) |
1079 | 1112 | { |
@@ -1097,14 +1130,16 @@ discard block |
||
1097 | 1130 | $smcFunc['db_free_result']($request); |
1098 | 1131 | |
1099 | 1132 | // If there're no real new topics in this board, mark the board as seen. |
1100 | - if (empty($numNewTopics)) |
|
1101 | - $_REQUEST['boardseen'] = true; |
|
1102 | - else |
|
1103 | - $_SESSION['topicseen_cache'][$board] = $numNewTopics; |
|
1133 | + if (empty($numNewTopics)) { |
|
1134 | + $_REQUEST['boardseen'] = true; |
|
1135 | + } else { |
|
1136 | + $_SESSION['topicseen_cache'][$board] = $numNewTopics; |
|
1137 | + } |
|
1104 | 1138 | } |
1105 | 1139 | // Probably one less topic - maybe not, but even if we decrease this too fast it will only make us look more often. |
1106 | - elseif (isset($_SESSION['topicseen_cache'][$board])) |
|
1107 | - $_SESSION['topicseen_cache'][$board]--; |
|
1140 | + elseif (isset($_SESSION['topicseen_cache'][$board])) { |
|
1141 | + $_SESSION['topicseen_cache'][$board]--; |
|
1142 | + } |
|
1108 | 1143 | |
1109 | 1144 | // Mark board as seen if we came using last post link from BoardIndex. (or other places...) |
1110 | 1145 | if (isset($_REQUEST['boardseen'])) |
@@ -1161,23 +1196,26 @@ discard block |
||
1161 | 1196 | $temp = array(); |
1162 | 1197 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1163 | 1198 | { |
1164 | - if (!$row['approved'] && $modSettings['postmod_active'] && !allowedTo('approve_posts') && (!isset($all_posters[$row['id_msg']]) || $all_posters[$row['id_msg']] != $user_info['id'])) |
|
1165 | - continue; |
|
1199 | + if (!$row['approved'] && $modSettings['postmod_active'] && !allowedTo('approve_posts') && (!isset($all_posters[$row['id_msg']]) || $all_posters[$row['id_msg']] != $user_info['id'])) { |
|
1200 | + continue; |
|
1201 | + } |
|
1166 | 1202 | |
1167 | 1203 | $temp[$row['id_attach']] = $row; |
1168 | 1204 | $temp[$row['id_attach']]['topic'] = $topic; |
1169 | 1205 | $temp[$row['id_attach']]['board'] = $board; |
1170 | 1206 | |
1171 | - if (!isset($context['loaded_attachments'][$row['id_msg']])) |
|
1172 | - $context['loaded_attachments'][$row['id_msg']] = array(); |
|
1207 | + if (!isset($context['loaded_attachments'][$row['id_msg']])) { |
|
1208 | + $context['loaded_attachments'][$row['id_msg']] = array(); |
|
1209 | + } |
|
1173 | 1210 | } |
1174 | 1211 | $smcFunc['db_free_result']($request); |
1175 | 1212 | |
1176 | 1213 | // This is better than sorting it with the query... |
1177 | 1214 | ksort($temp); |
1178 | 1215 | |
1179 | - foreach ($temp as $row) |
|
1180 | - $context['loaded_attachments'][$row['id_msg']][] = $row; |
|
1216 | + foreach ($temp as $row) { |
|
1217 | + $context['loaded_attachments'][$row['id_msg']][] = $row; |
|
1218 | + } |
|
1181 | 1219 | } |
1182 | 1220 | |
1183 | 1221 | $msg_parameters = array( |
@@ -1204,21 +1242,23 @@ discard block |
||
1204 | 1242 | ); |
1205 | 1243 | |
1206 | 1244 | // And the likes |
1207 | - if (!empty($modSettings['enable_likes'])) |
|
1208 | - $context['my_likes'] = $context['user']['is_guest'] ? array() : prepareLikesContext($topic); |
|
1245 | + if (!empty($modSettings['enable_likes'])) { |
|
1246 | + $context['my_likes'] = $context['user']['is_guest'] ? array() : prepareLikesContext($topic); |
|
1247 | + } |
|
1209 | 1248 | |
1210 | 1249 | // Go to the last message if the given time is beyond the time of the last message. |
1211 | - if (isset($context['start_from']) && $context['start_from'] >= $context['topicinfo']['num_replies']) |
|
1212 | - $context['start_from'] = $context['topicinfo']['num_replies']; |
|
1250 | + if (isset($context['start_from']) && $context['start_from'] >= $context['topicinfo']['num_replies']) { |
|
1251 | + $context['start_from'] = $context['topicinfo']['num_replies']; |
|
1252 | + } |
|
1213 | 1253 | |
1214 | 1254 | // Since the anchor information is needed on the top of the page we load these variables beforehand. |
1215 | 1255 | $context['first_message'] = isset($messages[$firstIndex]) ? $messages[$firstIndex] : $messages[0]; |
1216 | - if (empty($options['view_newest_first'])) |
|
1217 | - $context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['start_from']; |
|
1218 | - else |
|
1219 | - $context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['topicinfo']['num_replies'] - $context['start_from']; |
|
1220 | - } |
|
1221 | - else |
|
1256 | + if (empty($options['view_newest_first'])) { |
|
1257 | + $context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['start_from']; |
|
1258 | + } else { |
|
1259 | + $context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['topicinfo']['num_replies'] - $context['start_from']; |
|
1260 | + } |
|
1261 | + } else |
|
1222 | 1262 | { |
1223 | 1263 | $messages_request = false; |
1224 | 1264 | $context['first_message'] = 0; |
@@ -1253,8 +1293,9 @@ discard block |
||
1253 | 1293 | 'can_restore_msg' => 'move_any', |
1254 | 1294 | 'can_like' => 'likes_like', |
1255 | 1295 | ); |
1256 | - foreach ($common_permissions as $contextual => $perm) |
|
1257 | - $context[$contextual] = allowedTo($perm); |
|
1296 | + foreach ($common_permissions as $contextual => $perm) { |
|
1297 | + $context[$contextual] = allowedTo($perm); |
|
1298 | + } |
|
1258 | 1299 | |
1259 | 1300 | // Permissions with _any/_own versions. $context[YYY] => ZZZ_any/_own. |
1260 | 1301 | $anyown_permissions = array( |
@@ -1267,8 +1308,9 @@ discard block |
||
1267 | 1308 | 'can_reply_unapproved' => 'post_unapproved_replies', |
1268 | 1309 | 'can_view_warning' => 'profile_warning', |
1269 | 1310 | ); |
1270 | - foreach ($anyown_permissions as $contextual => $perm) |
|
1271 | - $context[$contextual] = allowedTo($perm . '_any') || ($context['user']['started'] && allowedTo($perm . '_own')); |
|
1311 | + foreach ($anyown_permissions as $contextual => $perm) { |
|
1312 | + $context[$contextual] = allowedTo($perm . '_any') || ($context['user']['started'] && allowedTo($perm . '_own')); |
|
1313 | + } |
|
1272 | 1314 | |
1273 | 1315 | if (!$user_info['is_admin'] && !$modSettings['topic_move_any']) |
1274 | 1316 | { |
@@ -1314,8 +1356,9 @@ discard block |
||
1314 | 1356 | // Check if the draft functions are enabled and that they have permission to use them (for quick reply.) |
1315 | 1357 | $context['drafts_save'] = !empty($modSettings['drafts_post_enabled']) && allowedTo('post_draft') && $context['can_reply']; |
1316 | 1358 | $context['drafts_autosave'] = !empty($context['drafts_save']) && !empty($modSettings['drafts_autosave_enabled']); |
1317 | - if (!empty($context['drafts_save'])) |
|
1318 | - loadLanguage('Drafts'); |
|
1359 | + if (!empty($context['drafts_save'])) { |
|
1360 | + loadLanguage('Drafts'); |
|
1361 | + } |
|
1319 | 1362 | |
1320 | 1363 | // When was the last time this topic was replied to? Should we warn them about it? |
1321 | 1364 | if (!empty($modSettings['oldTopicDays']) && ($context['can_reply'] || $context['can_reply_unapproved']) && empty($context['topicinfo']['is_sticky'])) |
@@ -1376,26 +1419,31 @@ discard block |
||
1376 | 1419 | // Message icons - customized icons are off? |
1377 | 1420 | $context['icons'] = getMessageIcons($board); |
1378 | 1421 | |
1379 | - if (!empty($context['icons'])) |
|
1380 | - $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
1422 | + if (!empty($context['icons'])) { |
|
1423 | + $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
1424 | + } |
|
1381 | 1425 | |
1382 | 1426 | // Build the normal button array. |
1383 | 1427 | $context['normal_buttons'] = array(); |
1384 | 1428 | |
1385 | - if ($context['can_reply']) |
|
1386 | - $context['normal_buttons']['reply'] = array('text' => 'reply', 'image' => 'reply.png', 'url' => $scripturl . '?action=post;topic=' . $context['current_topic'] . '.' . $context['start'] . ';last_msg=' . $context['topic_last_message'], 'active' => true); |
|
1429 | + if ($context['can_reply']) { |
|
1430 | + $context['normal_buttons']['reply'] = array('text' => 'reply', 'image' => 'reply.png', 'url' => $scripturl . '?action=post;topic=' . $context['current_topic'] . '.' . $context['start'] . ';last_msg=' . $context['topic_last_message'], 'active' => true); |
|
1431 | + } |
|
1387 | 1432 | |
1388 | - if ($context['can_add_poll']) |
|
1389 | - $context['normal_buttons']['add_poll'] = array('text' => 'add_poll', 'image' => 'add_poll.png', 'url' => $scripturl . '?action=editpoll;add;topic=' . $context['current_topic'] . '.' . $context['start']); |
|
1433 | + if ($context['can_add_poll']) { |
|
1434 | + $context['normal_buttons']['add_poll'] = array('text' => 'add_poll', 'image' => 'add_poll.png', 'url' => $scripturl . '?action=editpoll;add;topic=' . $context['current_topic'] . '.' . $context['start']); |
|
1435 | + } |
|
1390 | 1436 | |
1391 | - if ($context['can_mark_unread']) |
|
1392 | - $context['normal_buttons']['mark_unread'] = array('text' => 'mark_unread', 'image' => 'markunread.png', 'url' => $scripturl . '?action=markasread;sa=topic;t=' . $context['mark_unread_time'] . ';topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1437 | + if ($context['can_mark_unread']) { |
|
1438 | + $context['normal_buttons']['mark_unread'] = array('text' => 'mark_unread', 'image' => 'markunread.png', 'url' => $scripturl . '?action=markasread;sa=topic;t=' . $context['mark_unread_time'] . ';topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1439 | + } |
|
1393 | 1440 | |
1394 | - if ($context['can_print']) |
|
1395 | - $context['normal_buttons']['print'] = array('text' => 'print', 'image' => 'print.png', 'custom' => 'rel="nofollow"', 'url' => $scripturl . '?action=printpage;topic=' . $context['current_topic'] . '.0'); |
|
1441 | + if ($context['can_print']) { |
|
1442 | + $context['normal_buttons']['print'] = array('text' => 'print', 'image' => 'print.png', 'custom' => 'rel="nofollow"', 'url' => $scripturl . '?action=printpage;topic=' . $context['current_topic'] . '.0'); |
|
1443 | + } |
|
1396 | 1444 | |
1397 | - if ($context['can_set_notify']) |
|
1398 | - $context['normal_buttons']['notify'] = array( |
|
1445 | + if ($context['can_set_notify']) { |
|
1446 | + $context['normal_buttons']['notify'] = array( |
|
1399 | 1447 | 'text' => 'notify_topic_' . $context['topic_notification_mode'], |
1400 | 1448 | 'sub_buttons' => array( |
1401 | 1449 | array( |
@@ -1417,38 +1465,47 @@ discard block |
||
1417 | 1465 | ), |
1418 | 1466 | ), |
1419 | 1467 | ); |
1468 | + } |
|
1420 | 1469 | |
1421 | 1470 | // Build the mod button array |
1422 | 1471 | $context['mod_buttons'] = array(); |
1423 | 1472 | |
1424 | - if ($context['can_move']) |
|
1425 | - $context['mod_buttons']['move'] = array('text' => 'move_topic', 'image' => 'admin_move.png', 'url' => $scripturl . '?action=movetopic;current_board=' . $context['current_board'] . ';topic=' . $context['current_topic'] . '.0'); |
|
1473 | + if ($context['can_move']) { |
|
1474 | + $context['mod_buttons']['move'] = array('text' => 'move_topic', 'image' => 'admin_move.png', 'url' => $scripturl . '?action=movetopic;current_board=' . $context['current_board'] . ';topic=' . $context['current_topic'] . '.0'); |
|
1475 | + } |
|
1426 | 1476 | |
1427 | - if ($context['can_delete']) |
|
1428 | - $context['mod_buttons']['delete'] = array('text' => 'remove_topic', 'image' => 'admin_rem.png', 'custom' => 'data-confirm="' . $txt['are_sure_remove_topic'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removetopic2;topic=' . $context['current_topic'] . '.0;' . $context['session_var'] . '=' . $context['session_id']); |
|
1477 | + if ($context['can_delete']) { |
|
1478 | + $context['mod_buttons']['delete'] = array('text' => 'remove_topic', 'image' => 'admin_rem.png', 'custom' => 'data-confirm="' . $txt['are_sure_remove_topic'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removetopic2;topic=' . $context['current_topic'] . '.0;' . $context['session_var'] . '=' . $context['session_id']); |
|
1479 | + } |
|
1429 | 1480 | |
1430 | - if ($context['can_lock']) |
|
1431 | - $context['mod_buttons']['lock'] = array('text' => empty($context['is_locked']) ? 'set_lock' : 'set_unlock', 'image' => 'admin_lock.png', 'url' => $scripturl . '?action=lock;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1481 | + if ($context['can_lock']) { |
|
1482 | + $context['mod_buttons']['lock'] = array('text' => empty($context['is_locked']) ? 'set_lock' : 'set_unlock', 'image' => 'admin_lock.png', 'url' => $scripturl . '?action=lock;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1483 | + } |
|
1432 | 1484 | |
1433 | - if ($context['can_sticky']) |
|
1434 | - $context['mod_buttons']['sticky'] = array('text' => empty($context['is_sticky']) ? 'set_sticky' : 'set_nonsticky', 'image' => 'admin_sticky.png', 'url' => $scripturl . '?action=sticky;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1485 | + if ($context['can_sticky']) { |
|
1486 | + $context['mod_buttons']['sticky'] = array('text' => empty($context['is_sticky']) ? 'set_sticky' : 'set_nonsticky', 'image' => 'admin_sticky.png', 'url' => $scripturl . '?action=sticky;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1487 | + } |
|
1435 | 1488 | |
1436 | - if ($context['can_merge']) |
|
1437 | - $context['mod_buttons']['merge'] = array('text' => 'merge', 'image' => 'merge.png', 'url' => $scripturl . '?action=mergetopics;board=' . $context['current_board'] . '.0;from=' . $context['current_topic']); |
|
1489 | + if ($context['can_merge']) { |
|
1490 | + $context['mod_buttons']['merge'] = array('text' => 'merge', 'image' => 'merge.png', 'url' => $scripturl . '?action=mergetopics;board=' . $context['current_board'] . '.0;from=' . $context['current_topic']); |
|
1491 | + } |
|
1438 | 1492 | |
1439 | - if ($context['calendar_post']) |
|
1440 | - $context['mod_buttons']['calendar'] = array('text' => 'calendar_link', 'image' => 'linktocal.png', 'url' => $scripturl . '?action=post;calendar;msg=' . $context['topic_first_message'] . ';topic=' . $context['current_topic'] . '.0'); |
|
1493 | + if ($context['calendar_post']) { |
|
1494 | + $context['mod_buttons']['calendar'] = array('text' => 'calendar_link', 'image' => 'linktocal.png', 'url' => $scripturl . '?action=post;calendar;msg=' . $context['topic_first_message'] . ';topic=' . $context['current_topic'] . '.0'); |
|
1495 | + } |
|
1441 | 1496 | |
1442 | 1497 | // Restore topic. eh? No monkey business. |
1443 | - if ($context['can_restore_topic']) |
|
1444 | - $context['mod_buttons']['restore_topic'] = array('text' => 'restore_topic', 'image' => '', 'url' => $scripturl . '?action=restoretopic;topics=' . $context['current_topic'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1498 | + if ($context['can_restore_topic']) { |
|
1499 | + $context['mod_buttons']['restore_topic'] = array('text' => 'restore_topic', 'image' => '', 'url' => $scripturl . '?action=restoretopic;topics=' . $context['current_topic'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1500 | + } |
|
1445 | 1501 | |
1446 | 1502 | // Show a message in case a recently posted message became unapproved. |
1447 | 1503 | $context['becomesUnapproved'] = !empty($_SESSION['becomesUnapproved']) ? true : false; |
1448 | 1504 | |
1449 | 1505 | // Don't want to show this forever... |
1450 | - if ($context['becomesUnapproved']) |
|
1451 | - unset($_SESSION['becomesUnapproved']); |
|
1506 | + if ($context['becomesUnapproved']) { |
|
1507 | + unset($_SESSION['becomesUnapproved']); |
|
1508 | + } |
|
1452 | 1509 | |
1453 | 1510 | // Allow adding new mod buttons easily. |
1454 | 1511 | // Note: $context['normal_buttons'] and $context['mod_buttons'] are added for backward compatibility with 2.0, but are deprecated and should not be used |
@@ -1457,12 +1514,14 @@ discard block |
||
1457 | 1514 | call_integration_hook('integrate_mod_buttons', array(&$context['mod_buttons'])); |
1458 | 1515 | |
1459 | 1516 | // Load the drafts js file |
1460 | - if ($context['drafts_autosave']) |
|
1461 | - loadJavaScriptFile('drafts.js', array('defer' => false), 'smf_drafts'); |
|
1517 | + if ($context['drafts_autosave']) { |
|
1518 | + loadJavaScriptFile('drafts.js', array('defer' => false), 'smf_drafts'); |
|
1519 | + } |
|
1462 | 1520 | |
1463 | 1521 | // Spellcheck |
1464 | - if ($context['show_spellchecking']) |
|
1465 | - loadJavaScriptFile('spellcheck.js', array('defer' => false), 'smf_spellcheck'); |
|
1522 | + if ($context['show_spellchecking']) { |
|
1523 | + loadJavaScriptFile('spellcheck.js', array('defer' => false), 'smf_spellcheck'); |
|
1524 | + } |
|
1466 | 1525 | |
1467 | 1526 | // topic.js |
1468 | 1527 | loadJavaScriptFile('topic.js', array('defer' => false), 'smf_topic'); |
@@ -1496,16 +1555,19 @@ discard block |
||
1496 | 1555 | static $counter = null; |
1497 | 1556 | |
1498 | 1557 | // If the query returned false, bail. |
1499 | - if ($messages_request == false) |
|
1500 | - return false; |
|
1558 | + if ($messages_request == false) { |
|
1559 | + return false; |
|
1560 | + } |
|
1501 | 1561 | |
1502 | 1562 | // Remember which message this is. (ie. reply #83) |
1503 | - if ($counter === null || $reset) |
|
1504 | - $counter = empty($options['view_newest_first']) ? $context['start'] : $context['total_visible_posts'] - $context['start']; |
|
1563 | + if ($counter === null || $reset) { |
|
1564 | + $counter = empty($options['view_newest_first']) ? $context['start'] : $context['total_visible_posts'] - $context['start']; |
|
1565 | + } |
|
1505 | 1566 | |
1506 | 1567 | // Start from the beginning... |
1507 | - if ($reset) |
|
1508 | - return @$smcFunc['db_data_seek']($messages_request, 0); |
|
1568 | + if ($reset) { |
|
1569 | + return @$smcFunc['db_data_seek']($messages_request, 0); |
|
1570 | + } |
|
1509 | 1571 | |
1510 | 1572 | // Attempt to get the next message. |
1511 | 1573 | $message = $smcFunc['db_fetch_assoc']($messages_request); |
@@ -1519,19 +1581,21 @@ discard block |
||
1519 | 1581 | if (empty($context['icon_sources'])) |
1520 | 1582 | { |
1521 | 1583 | $context['icon_sources'] = array(); |
1522 | - foreach ($context['stable_icons'] as $icon) |
|
1523 | - $context['icon_sources'][$icon] = 'images_url'; |
|
1584 | + foreach ($context['stable_icons'] as $icon) { |
|
1585 | + $context['icon_sources'][$icon] = 'images_url'; |
|
1586 | + } |
|
1524 | 1587 | } |
1525 | 1588 | |
1526 | 1589 | // Message Icon Management... check the images exist. |
1527 | 1590 | if (empty($modSettings['messageIconChecks_disable'])) |
1528 | 1591 | { |
1529 | 1592 | // If the current icon isn't known, then we need to do something... |
1530 | - if (!isset($context['icon_sources'][$message['icon']])) |
|
1531 | - $context['icon_sources'][$message['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
1593 | + if (!isset($context['icon_sources'][$message['icon']])) { |
|
1594 | + $context['icon_sources'][$message['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
1595 | + } |
|
1596 | + } elseif (!isset($context['icon_sources'][$message['icon']])) { |
|
1597 | + $context['icon_sources'][$message['icon']] = 'images_url'; |
|
1532 | 1598 | } |
1533 | - elseif (!isset($context['icon_sources'][$message['icon']])) |
|
1534 | - $context['icon_sources'][$message['icon']] = 'images_url'; |
|
1535 | 1599 | |
1536 | 1600 | // If you're a lazy bum, you probably didn't give a subject... |
1537 | 1601 | $message['subject'] = $message['subject'] != '' ? $message['subject'] : $txt['no_subject']; |
@@ -1556,8 +1620,7 @@ discard block |
||
1556 | 1620 | $memberContext[$message['id_member']]['email'] = $message['poster_email']; |
1557 | 1621 | $memberContext[$message['id_member']]['show_email'] = allowedTo('moderate_forum'); |
1558 | 1622 | $memberContext[$message['id_member']]['is_guest'] = true; |
1559 | - } |
|
1560 | - else |
|
1623 | + } else |
|
1561 | 1624 | { |
1562 | 1625 | // Define this here to make things a bit more readable |
1563 | 1626 | $can_view_warning = $context['user']['can_mod'] || allowedTo('view_warning_any') || ($message['id_member'] == $user_info['id'] && allowedTo('view_warning_own')); |
@@ -1580,8 +1643,9 @@ discard block |
||
1580 | 1643 | $message['body'] = parse_bbc($message['body'], $message['smileys_enabled'], $message['id_msg']); |
1581 | 1644 | |
1582 | 1645 | // If it's in the recycle bin we need to override whatever icon we did have. |
1583 | - if (!empty($board_info['recycle'])) |
|
1584 | - $message['icon'] = 'recycled'; |
|
1646 | + if (!empty($board_info['recycle'])) { |
|
1647 | + $message['icon'] = 'recycled'; |
|
1648 | + } |
|
1585 | 1649 | |
1586 | 1650 | require_once($sourcedir . '/Subs-Attachments.php'); |
1587 | 1651 | |
@@ -1625,32 +1689,36 @@ discard block |
||
1625 | 1689 | } |
1626 | 1690 | |
1627 | 1691 | // Are likes enable? |
1628 | - if (!empty($modSettings['enable_likes'])) |
|
1629 | - $output['likes'] = array( |
|
1692 | + if (!empty($modSettings['enable_likes'])) { |
|
1693 | + $output['likes'] = array( |
|
1630 | 1694 | 'count' => $message['likes'], |
1631 | 1695 | 'you' => in_array($message['id_msg'], $context['my_likes']), |
1632 | 1696 | 'can_like' => !$context['user']['is_guest'] && $message['id_member'] != $context['user']['id'] && !empty($context['can_like']), |
1633 | 1697 | ); |
1698 | + } |
|
1634 | 1699 | |
1635 | 1700 | // Is this user the message author? |
1636 | 1701 | $output['is_message_author'] = $message['id_member'] == $user_info['id']; |
1637 | - if (!empty($output['modified']['name'])) |
|
1638 | - $output['modified']['last_edit_text'] = sprintf($txt['last_edit_by'], $output['modified']['time'], $output['modified']['name']); |
|
1702 | + if (!empty($output['modified']['name'])) { |
|
1703 | + $output['modified']['last_edit_text'] = sprintf($txt['last_edit_by'], $output['modified']['time'], $output['modified']['name']); |
|
1704 | + } |
|
1639 | 1705 | |
1640 | 1706 | // Did they give a reason for editing? |
1641 | - if (!empty($output['modified']['name']) && !empty($output['modified']['reason'])) |
|
1642 | - $output['modified']['last_edit_text'] .= ' ' . sprintf($txt['last_edit_reason'], $output['modified']['reason']); |
|
1707 | + if (!empty($output['modified']['name']) && !empty($output['modified']['reason'])) { |
|
1708 | + $output['modified']['last_edit_text'] .= ' ' . sprintf($txt['last_edit_reason'], $output['modified']['reason']); |
|
1709 | + } |
|
1643 | 1710 | |
1644 | 1711 | // Any custom profile fields? |
1645 | - if (!empty($memberContext[$message['id_member']]['custom_fields'])) |
|
1646 | - foreach ($memberContext[$message['id_member']]['custom_fields'] as $custom) |
|
1712 | + if (!empty($memberContext[$message['id_member']]['custom_fields'])) { |
|
1713 | + foreach ($memberContext[$message['id_member']]['custom_fields'] as $custom) |
|
1647 | 1714 | $output['custom_fields'][$context['cust_profile_fields_placement'][$custom['placement']]][] = $custom; |
1715 | + } |
|
1648 | 1716 | |
1649 | - if (empty($options['view_newest_first'])) |
|
1650 | - $counter++; |
|
1651 | - |
|
1652 | - else |
|
1653 | - $counter--; |
|
1717 | + if (empty($options['view_newest_first'])) { |
|
1718 | + $counter++; |
|
1719 | + } else { |
|
1720 | + $counter--; |
|
1721 | + } |
|
1654 | 1722 | |
1655 | 1723 | call_integration_hook('integrate_prepare_display_context', array(&$output, &$message, $counter)); |
1656 | 1724 | |
@@ -1676,8 +1744,9 @@ discard block |
||
1676 | 1744 | */ |
1677 | 1745 | function approved_attach_sort($a, $b) |
1678 | 1746 | { |
1679 | - if ($a['is_approved'] == $b['is_approved']) |
|
1680 | - return 0; |
|
1747 | + if ($a['is_approved'] == $b['is_approved']) { |
|
1748 | + return 0; |
|
1749 | + } |
|
1681 | 1750 | |
1682 | 1751 | return $a['is_approved'] > $b['is_approved'] ? -1 : 1; |
1683 | 1752 | } |
@@ -1694,16 +1763,19 @@ discard block |
||
1694 | 1763 | |
1695 | 1764 | require_once($sourcedir . '/RemoveTopic.php'); |
1696 | 1765 | |
1697 | - if (empty($_REQUEST['msgs'])) |
|
1698 | - redirectexit('topic=' . $topic . '.' . $_REQUEST['start']); |
|
1766 | + if (empty($_REQUEST['msgs'])) { |
|
1767 | + redirectexit('topic=' . $topic . '.' . $_REQUEST['start']); |
|
1768 | + } |
|
1699 | 1769 | |
1700 | 1770 | $messages = array(); |
1701 | - foreach ($_REQUEST['msgs'] as $dummy) |
|
1702 | - $messages[] = (int) $dummy; |
|
1771 | + foreach ($_REQUEST['msgs'] as $dummy) { |
|
1772 | + $messages[] = (int) $dummy; |
|
1773 | + } |
|
1703 | 1774 | |
1704 | 1775 | // We are restoring messages. We handle this in another place. |
1705 | - if (isset($_REQUEST['restore_selected'])) |
|
1706 | - redirectexit('action=restoretopic;msgs=' . implode(',', $messages) . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1776 | + if (isset($_REQUEST['restore_selected'])) { |
|
1777 | + redirectexit('action=restoretopic;msgs=' . implode(',', $messages) . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1778 | + } |
|
1707 | 1779 | if (isset($_REQUEST['split_selection'])) |
1708 | 1780 | { |
1709 | 1781 | $request = $smcFunc['db_query']('', ' |
@@ -1722,8 +1794,9 @@ discard block |
||
1722 | 1794 | } |
1723 | 1795 | |
1724 | 1796 | // Allowed to delete any message? |
1725 | - if (allowedTo('delete_any')) |
|
1726 | - $allowed_all = true; |
|
1797 | + if (allowedTo('delete_any')) { |
|
1798 | + $allowed_all = true; |
|
1799 | + } |
|
1727 | 1800 | // Allowed to delete replies to their messages? |
1728 | 1801 | elseif (allowedTo('delete_replies')) |
1729 | 1802 | { |
@@ -1740,13 +1813,14 @@ discard block |
||
1740 | 1813 | $smcFunc['db_free_result']($request); |
1741 | 1814 | |
1742 | 1815 | $allowed_all = $starter == $user_info['id']; |
1816 | + } else { |
|
1817 | + $allowed_all = false; |
|
1743 | 1818 | } |
1744 | - else |
|
1745 | - $allowed_all = false; |
|
1746 | 1819 | |
1747 | 1820 | // Make sure they're allowed to delete their own messages, if not any. |
1748 | - if (!$allowed_all) |
|
1749 | - isAllowedTo('delete_own'); |
|
1821 | + if (!$allowed_all) { |
|
1822 | + isAllowedTo('delete_own'); |
|
1823 | + } |
|
1750 | 1824 | |
1751 | 1825 | // Allowed to remove which messages? |
1752 | 1826 | $request = $smcFunc['db_query']('', ' |
@@ -1766,8 +1840,9 @@ discard block |
||
1766 | 1840 | $messages = array(); |
1767 | 1841 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1768 | 1842 | { |
1769 | - if (!$allowed_all && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + $modSettings['edit_disable_time'] * 60 < time()) |
|
1770 | - continue; |
|
1843 | + if (!$allowed_all && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + $modSettings['edit_disable_time'] * 60 < time()) { |
|
1844 | + continue; |
|
1845 | + } |
|
1771 | 1846 | |
1772 | 1847 | $messages[$row['id_msg']] = array($row['subject'], $row['id_member']); |
1773 | 1848 | } |
@@ -1790,17 +1865,20 @@ discard block |
||
1790 | 1865 | foreach ($messages as $message => $info) |
1791 | 1866 | { |
1792 | 1867 | // Just skip the first message - if it's not the last. |
1793 | - if ($message == $first_message && $message != $last_message) |
|
1794 | - continue; |
|
1868 | + if ($message == $first_message && $message != $last_message) { |
|
1869 | + continue; |
|
1870 | + } |
|
1795 | 1871 | // If the first message is going then don't bother going back to the topic as we're effectively deleting it. |
1796 | - elseif ($message == $first_message) |
|
1797 | - $topicGone = true; |
|
1872 | + elseif ($message == $first_message) { |
|
1873 | + $topicGone = true; |
|
1874 | + } |
|
1798 | 1875 | |
1799 | 1876 | removeMessage($message); |
1800 | 1877 | |
1801 | 1878 | // Log this moderation action ;). |
1802 | - if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) |
|
1803 | - logAction('delete', array('topic' => $topic, 'subject' => $info[0], 'member' => $info[1], 'board' => $board)); |
|
1879 | + if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) { |
|
1880 | + logAction('delete', array('topic' => $topic, 'subject' => $info[0], 'member' => $info[1], 'board' => $board)); |
|
1881 | + } |
|
1804 | 1882 | } |
1805 | 1883 | |
1806 | 1884 | redirectexit(!empty($topicGone) ? 'board=' . $board : 'topic=' . $topic . '.' . $_REQUEST['start']); |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * The main admin handling function.<br> |
@@ -444,8 +445,9 @@ discard block |
||
444 | 445 | foreach ($admin_includes as $include) |
445 | 446 | { |
446 | 447 | $include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
447 | - if (file_exists($include)) |
|
448 | - require_once($include); |
|
448 | + if (file_exists($include)) { |
|
449 | + require_once($include); |
|
450 | + } |
|
449 | 451 | } |
450 | 452 | } |
451 | 453 | |
@@ -457,24 +459,27 @@ discard block |
||
457 | 459 | unset($admin_areas); |
458 | 460 | |
459 | 461 | // Nothing valid? |
460 | - if ($admin_include_data == false) |
|
461 | - fatal_lang_error('no_access', false); |
|
462 | + if ($admin_include_data == false) { |
|
463 | + fatal_lang_error('no_access', false); |
|
464 | + } |
|
462 | 465 | |
463 | 466 | // Build the link tree. |
464 | 467 | $context['linktree'][] = array( |
465 | 468 | 'url' => $scripturl . '?action=admin', |
466 | 469 | 'name' => $txt['admin_center'], |
467 | 470 | ); |
468 | - if (isset($admin_include_data['current_area']) && $admin_include_data['current_area'] != 'index') |
|
469 | - $context['linktree'][] = array( |
|
471 | + if (isset($admin_include_data['current_area']) && $admin_include_data['current_area'] != 'index') { |
|
472 | + $context['linktree'][] = array( |
|
470 | 473 | 'url' => $scripturl . '?action=admin;area=' . $admin_include_data['current_area'] . ';' . $context['session_var'] . '=' . $context['session_id'], |
471 | 474 | 'name' => $admin_include_data['label'], |
472 | 475 | ); |
473 | - if (!empty($admin_include_data['current_subsection']) && $admin_include_data['subsections'][$admin_include_data['current_subsection']][0] != $admin_include_data['label']) |
|
474 | - $context['linktree'][] = array( |
|
476 | + } |
|
477 | + if (!empty($admin_include_data['current_subsection']) && $admin_include_data['subsections'][$admin_include_data['current_subsection']][0] != $admin_include_data['label']) { |
|
478 | + $context['linktree'][] = array( |
|
475 | 479 | 'url' => $scripturl . '?action=admin;area=' . $admin_include_data['current_area'] . ';sa=' . $admin_include_data['current_subsection'] . ';' . $context['session_var'] . '=' . $context['session_id'], |
476 | 480 | 'name' => $admin_include_data['subsections'][$admin_include_data['current_subsection']][0], |
477 | 481 | ); |
482 | + } |
|
478 | 483 | |
479 | 484 | // Make a note of the Unique ID for this menu. |
480 | 485 | $context['admin_menu_id'] = $context['max_menu_id']; |
@@ -484,16 +489,18 @@ discard block |
||
484 | 489 | $context['admin_area'] = $admin_include_data['current_area']; |
485 | 490 | |
486 | 491 | // Now - finally - call the right place! |
487 | - if (isset($admin_include_data['file'])) |
|
488 | - require_once($sourcedir . '/' . $admin_include_data['file']); |
|
492 | + if (isset($admin_include_data['file'])) { |
|
493 | + require_once($sourcedir . '/' . $admin_include_data['file']); |
|
494 | + } |
|
489 | 495 | |
490 | 496 | // Get the right callable. |
491 | 497 | $call = call_helper($admin_include_data['function'], true); |
492 | 498 | |
493 | 499 | // Is it valid? |
494 | - if (!empty($call)) |
|
495 | - call_user_func($call); |
|
496 | -} |
|
500 | + if (!empty($call)) { |
|
501 | + call_user_func($call); |
|
502 | + } |
|
503 | + } |
|
497 | 504 | |
498 | 505 | /** |
499 | 506 | * The main administration section. |
@@ -547,13 +554,14 @@ discard block |
||
547 | 554 | |
548 | 555 | $context['sub_template'] = $context['admin_area'] == 'credits' ? 'credits' : 'admin'; |
549 | 556 | $context['page_title'] = $context['admin_area'] == 'credits' ? $txt['support_credits_title'] : $txt['admin_center']; |
550 | - if ($context['admin_area'] != 'credits') |
|
551 | - $context[$context['admin_menu_name']]['tab_data'] = array( |
|
557 | + if ($context['admin_area'] != 'credits') { |
|
558 | + $context[$context['admin_menu_name']]['tab_data'] = array( |
|
552 | 559 | 'title' => $txt['admin_center'], |
553 | 560 | 'help' => '', |
554 | 561 | 'description' => '<strong>' . $txt['hello_guest'] . ' ' . $context['user']['name'] . '!</strong> |
555 | 562 | ' . sprintf($txt['admin_main_welcome'], $txt['admin_center'], $txt['help'], $txt['help']), |
556 | 563 | ); |
564 | + } |
|
557 | 565 | |
558 | 566 | // Lastly, fill in the blanks in the support resources paragraphs. |
559 | 567 | $txt['support_resources_p1'] = sprintf($txt['support_resources_p1'], |
@@ -571,9 +579,10 @@ discard block |
||
571 | 579 | 'https://www.simplemachines.org/redirect/customize_support' |
572 | 580 | ); |
573 | 581 | |
574 | - if ($context['admin_area'] == 'admin') |
|
575 | - loadJavaScriptFile('admin.js', array('defer' => false), 'smf_admin'); |
|
576 | -} |
|
582 | + if ($context['admin_area'] == 'admin') { |
|
583 | + loadJavaScriptFile('admin.js', array('defer' => false), 'smf_admin'); |
|
584 | + } |
|
585 | + } |
|
577 | 586 | |
578 | 587 | /** |
579 | 588 | * Get one of the admin information files from Simple Machines. |
@@ -584,8 +593,9 @@ discard block |
||
584 | 593 | |
585 | 594 | setMemoryLimit('32M'); |
586 | 595 | |
587 | - if (empty($_REQUEST['filename']) || !is_string($_REQUEST['filename'])) |
|
588 | - fatal_lang_error('no_access', false); |
|
596 | + if (empty($_REQUEST['filename']) || !is_string($_REQUEST['filename'])) { |
|
597 | + fatal_lang_error('no_access', false); |
|
598 | + } |
|
589 | 599 | |
590 | 600 | // Strip off the forum cache part or we won't find it... |
591 | 601 | $_REQUEST['filename'] = str_replace($modSettings['browser_cache'], '', $_REQUEST['filename']); |
@@ -600,27 +610,30 @@ discard block |
||
600 | 610 | ) |
601 | 611 | ); |
602 | 612 | |
603 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
604 | - fatal_lang_error('admin_file_not_found', true, array($_REQUEST['filename']), 404); |
|
613 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
614 | + fatal_lang_error('admin_file_not_found', true, array($_REQUEST['filename']), 404); |
|
615 | + } |
|
605 | 616 | |
606 | 617 | list ($file_data, $filetype) = $smcFunc['db_fetch_row']($request); |
607 | 618 | $smcFunc['db_free_result']($request); |
608 | 619 | |
609 | 620 | // @todo Temp |
610 | 621 | // Figure out if sesc is still being used. |
611 | - if (strpos($file_data, ';sesc=') !== false && $filetype == 'text/javascript') |
|
612 | - $file_data = ' |
|
622 | + if (strpos($file_data, ';sesc=') !== false && $filetype == 'text/javascript') { |
|
623 | + $file_data = ' |
|
613 | 624 | if (!(\'smfForum_sessionvar\' in window)) |
614 | 625 | window.smfForum_sessionvar = \'sesc\'; |
615 | 626 | ' . strtr($file_data, array(';sesc=' => ';\' + window.smfForum_sessionvar + \'=')); |
627 | + } |
|
616 | 628 | |
617 | 629 | $context['template_layers'] = array(); |
618 | 630 | // Lets make sure we aren't going to output anything nasty. |
619 | 631 | @ob_end_clean(); |
620 | - if (!empty($modSettings['enableCompressedOutput'])) |
|
621 | - @ob_start('ob_gzhandler'); |
|
622 | - else |
|
623 | - @ob_start(); |
|
632 | + if (!empty($modSettings['enableCompressedOutput'])) { |
|
633 | + @ob_start('ob_gzhandler'); |
|
634 | + } else { |
|
635 | + @ob_start(); |
|
636 | + } |
|
624 | 637 | |
625 | 638 | // Make sure they know what type of file we are. |
626 | 639 | header('Content-Type: ' . $filetype); |
@@ -660,11 +673,12 @@ discard block |
||
660 | 673 | updateAdminPreferences(); |
661 | 674 | } |
662 | 675 | |
663 | - if (trim($context['search_term']) == '') |
|
664 | - $context['search_results'] = array(); |
|
665 | - else |
|
666 | - call_helper($subActions[$context['search_type']]); |
|
667 | -} |
|
676 | + if (trim($context['search_term']) == '') { |
|
677 | + $context['search_results'] = array(); |
|
678 | + } else { |
|
679 | + call_helper($subActions[$context['search_type']]); |
|
680 | + } |
|
681 | + } |
|
668 | 682 | |
669 | 683 | /** |
670 | 684 | * A complicated but relatively quick internal search. |
@@ -728,8 +742,9 @@ discard block |
||
728 | 742 | |
729 | 743 | loadLanguage(implode('+', $language_files)); |
730 | 744 | |
731 | - foreach ($include_files as $file) |
|
732 | - require_once($sourcedir . '/' . $file . '.php'); |
|
745 | + foreach ($include_files as $file) { |
|
746 | + require_once($sourcedir . '/' . $file . '.php'); |
|
747 | + } |
|
733 | 748 | |
734 | 749 | /* This is the huge array that defines everything... it's a huge array of items formatted as follows: |
735 | 750 | 0 = Language index (Can be array of indexes) to search through for this setting. |
@@ -753,11 +768,12 @@ discard block |
||
753 | 768 | foreach ($section['areas'] as $menu_key => $menu_item) |
754 | 769 | { |
755 | 770 | $search_data['sections'][] = array($menu_item['label'], 'area=' . $menu_key); |
756 | - if (!empty($menu_item['subsections'])) |
|
757 | - foreach ($menu_item['subsections'] as $key => $sublabel) |
|
771 | + if (!empty($menu_item['subsections'])) { |
|
772 | + foreach ($menu_item['subsections'] as $key => $sublabel) |
|
758 | 773 | { |
759 | 774 | if (isset($sublabel['label'])) |
760 | 775 | $search_data['sections'][] = array($sublabel['label'], 'area=' . $menu_key . ';sa=' . $key); |
776 | + } |
|
761 | 777 | } |
762 | 778 | } |
763 | 779 | } |
@@ -767,9 +783,10 @@ discard block |
||
767 | 783 | // Get a list of their variables. |
768 | 784 | $config_vars = $setting_area[0](true); |
769 | 785 | |
770 | - foreach ($config_vars as $var) |
|
771 | - if (!empty($var[1]) && !in_array($var[0], array('permissions', 'switch', 'desc'))) |
|
786 | + foreach ($config_vars as $var) { |
|
787 | + if (!empty($var[1]) && !in_array($var[0], array('permissions', 'switch', 'desc'))) |
|
772 | 788 | $search_data['settings'][] = array($var[(isset($var[2]) && in_array($var[2], array('file', 'db'))) ? 0 : 1], $setting_area[1], 'alttxt' => (isset($var[2]) && in_array($var[2], array('file', 'db'))) || isset($var[3]) ? (in_array($var[2], array('file', 'db')) ? $var[1] : $var[3]) : ''); |
789 | + } |
|
773 | 790 | } |
774 | 791 | |
775 | 792 | $context['page_title'] = $txt['admin_search_results']; |
@@ -782,8 +799,9 @@ discard block |
||
782 | 799 | foreach ($data as $item) |
783 | 800 | { |
784 | 801 | $found = false; |
785 | - if (!is_array($item[0])) |
|
786 | - $item[0] = array($item[0]); |
|
802 | + if (!is_array($item[0])) { |
|
803 | + $item[0] = array($item[0]); |
|
804 | + } |
|
787 | 805 | foreach ($item[0] as $term) |
788 | 806 | { |
789 | 807 | if (stripos($term, $search_term) !== false || (isset($txt[$term]) && stripos($txt[$term], $search_term) !== false) || (isset($txt['setting_' . $term]) && stripos($txt['setting_' . $term], $search_term) !== false)) |
@@ -841,8 +859,9 @@ discard block |
||
841 | 859 | $postVars = explode(' ', $context['search_term']); |
842 | 860 | |
843 | 861 | // Encode the search data. |
844 | - foreach ($postVars as $k => $v) |
|
845 | - $postVars[$k] = urlencode($v); |
|
862 | + foreach ($postVars as $k => $v) { |
|
863 | + $postVars[$k] = urlencode($v); |
|
864 | + } |
|
846 | 865 | |
847 | 866 | // This is what we will send. |
848 | 867 | $postVars = implode('+', $postVars); |
@@ -854,8 +873,9 @@ discard block |
||
854 | 873 | $search_results = fetch_web_data($context['doc_apiurl'] . '?action=query&list=search&srprop=timestamp|snippet&format=xml&srwhat=text&srsearch=' . $postVars); |
855 | 874 | |
856 | 875 | // If we didn't get any xml back we are in trouble - perhaps the doc site is overloaded? |
857 | - if (!$search_results || preg_match('~<' . '\?xml\sversion="\d+\.\d+"\?' . '>\s*(<api>.+?</api>)~is', $search_results, $matches) != true) |
|
858 | - fatal_lang_error('cannot_connect_doc_site'); |
|
876 | + if (!$search_results || preg_match('~<' . '\?xml\sversion="\d+\.\d+"\?' . '>\s*(<api>.+?</api>)~is', $search_results, $matches) != true) { |
|
877 | + fatal_lang_error('cannot_connect_doc_site'); |
|
878 | + } |
|
859 | 879 | |
860 | 880 | $search_results = $matches[1]; |
861 | 881 | |
@@ -867,8 +887,9 @@ discard block |
||
867 | 887 | $results = new xmlArray($search_results, false); |
868 | 888 | |
869 | 889 | // Move through the api layer. |
870 | - if (!$results->exists('api')) |
|
871 | - fatal_lang_error('cannot_connect_doc_site'); |
|
890 | + if (!$results->exists('api')) { |
|
891 | + fatal_lang_error('cannot_connect_doc_site'); |
|
892 | + } |
|
872 | 893 | |
873 | 894 | // Are there actually some results? |
874 | 895 | if ($results->exists('api/query/search/p')) |
@@ -904,8 +925,9 @@ discard block |
||
904 | 925 | ); |
905 | 926 | |
906 | 927 | // If it's not got a sa set it must have come here for first time, pretend error log should be reversed. |
907 | - if (!isset($_REQUEST['sa'])) |
|
908 | - $_REQUEST['desc'] = true; |
|
928 | + if (!isset($_REQUEST['sa'])) { |
|
929 | + $_REQUEST['desc'] = true; |
|
930 | + } |
|
909 | 931 | |
910 | 932 | // Setup some tab stuff. |
911 | 933 | $context[$context['admin_menu_name']]['tab_data'] = array( |
@@ -955,9 +977,10 @@ discard block |
||
955 | 977 | unset($_SESSION['admin_time']); |
956 | 978 | |
957 | 979 | // Clean any admin tokens as well. |
958 | - foreach ($_SESSION['token'] as $key => $token) |
|
959 | - if (strpos($key, '-admin') !== false) |
|
980 | + foreach ($_SESSION['token'] as $key => $token) { |
|
981 | + if (strpos($key, '-admin') !== false) |
|
960 | 982 | unset($_SESSION['token'][$key]); |
983 | + } |
|
961 | 984 | |
962 | 985 | redirectexit(); |
963 | 986 | } |
@@ -122,9 +122,10 @@ discard block |
||
122 | 122 | <h3 class="catbg">', $txt['attachment_transfer'], '</h3> |
123 | 123 | </div>'; |
124 | 124 | |
125 | - if (!empty($context['results'])) |
|
126 | - echo ' |
|
125 | + if (!empty($context['results'])) { |
|
126 | + echo ' |
|
127 | 127 | <div class="noticebox">', $context['results'], '</div>'; |
128 | + } |
|
128 | 129 | |
129 | 130 | echo ' |
130 | 131 | <div class="windowbg2 noup"> |
@@ -136,9 +137,10 @@ discard block |
||
136 | 137 | <select name="from"> |
137 | 138 | <option value="0">', $txt['attachment_transfer_select'], '</option>'; |
138 | 139 | |
139 | - foreach ($context['attach_dirs'] as $id => $dir) |
|
140 | - echo ' |
|
140 | + foreach ($context['attach_dirs'] as $id => $dir) { |
|
141 | + echo ' |
|
141 | 142 | <option value="', $id, '">', $dir, '</option>'; |
143 | + } |
|
142 | 144 | |
143 | 145 | echo ' |
144 | 146 | </select> |
@@ -149,13 +151,14 @@ discard block |
||
149 | 151 | <option value="0">', $txt['attachment_transfer_auto_select'], '</option> |
150 | 152 | <option value="-1">', $txt['attachment_transfer_forum_root'], '</option>'; |
151 | 153 | |
152 | - if (!empty($context['base_dirs'])) |
|
153 | - foreach ($context['base_dirs'] as $id => $dir) |
|
154 | + if (!empty($context['base_dirs'])) { |
|
155 | + foreach ($context['base_dirs'] as $id => $dir) |
|
154 | 156 | echo ' |
155 | 157 | <option value="', $id, '">', $dir, '</option>'; |
156 | - else |
|
157 | - echo ' |
|
158 | + } else { |
|
159 | + echo ' |
|
158 | 160 | <option value="0" disabled>', $txt['attachment_transfer_no_base'], '</option>'; |
161 | + } |
|
159 | 162 | |
160 | 163 | echo ' |
161 | 164 | </select> |
@@ -165,18 +168,20 @@ discard block |
||
165 | 168 | <select name="to"> |
166 | 169 | <option value="0">', $txt['attachment_transfer_select'], '</option>'; |
167 | 170 | |
168 | - foreach ($context['attach_dirs'] as $id => $dir) |
|
169 | - echo ' |
|
171 | + foreach ($context['attach_dirs'] as $id => $dir) { |
|
172 | + echo ' |
|
170 | 173 | <option value="', $id, '">', $dir, '</option>'; |
174 | + } |
|
171 | 175 | |
172 | 176 | echo ' |
173 | 177 | </select> |
174 | 178 | </dd>'; |
175 | 179 | |
176 | - if (!empty($modSettings['attachmentDirFileLimit'])) |
|
177 | - echo ' |
|
180 | + if (!empty($modSettings['attachmentDirFileLimit'])) { |
|
181 | + echo ' |
|
178 | 182 | <dt>', $txt['attachment_transfer_empty'], '</dt> |
179 | 183 | <dd><input type="checkbox" name="empty_it"', $context['checked'] ? ' checked' : '', '></dd>'; |
184 | + } |
|
180 | 185 | |
181 | 186 | echo ' |
182 | 187 | </dl> |
@@ -253,10 +258,11 @@ discard block |
||
253 | 258 | // Loop through each error reporting the status |
254 | 259 | foreach ($context['repair_errors'] as $error => $number) |
255 | 260 | { |
256 | - if (!empty($number)) |
|
257 | - echo ' |
|
261 | + if (!empty($number)) { |
|
262 | + echo ' |
|
258 | 263 | <input type="checkbox" name="to_fix[]" id="', $error, '" value="', $error, '"> |
259 | 264 | <label for="', $error, '">', sprintf($txt['attach_repair_' . $error], $number), '</label><br>'; |
265 | + } |
|
260 | 266 | } |
261 | 267 | |
262 | 268 | echo ' |
@@ -24,11 +24,12 @@ discard block |
||
24 | 24 | <h3 class="catbg">', $txt['paid_' . $context['action_type'] . '_subscription'], '</h3> |
25 | 25 | </div>'; |
26 | 26 | |
27 | - if (!empty($context['disable_groups'])) |
|
28 | - echo ' |
|
27 | + if (!empty($context['disable_groups'])) { |
|
28 | + echo ' |
|
29 | 29 | <div class="information"> |
30 | 30 | <span class="alert">', $txt['paid_mod_edit_note'], '</span> |
31 | 31 | </div>'; |
32 | + } |
|
32 | 33 | |
33 | 34 | echo ' |
34 | 35 | <div class="windowbg2"> |
@@ -69,9 +70,10 @@ discard block |
||
69 | 70 | <option value="0"', $context['sub']['prim_group'] == 0 ? ' selected' : '', '>', $txt['paid_mod_no_group'], '</option>'; |
70 | 71 | |
71 | 72 | // Put each group into the box. |
72 | - foreach ($context['groups'] as $id => $name) |
|
73 | - echo ' |
|
73 | + foreach ($context['groups'] as $id => $name) { |
|
74 | + echo ' |
|
74 | 75 | <option value="', $id, '"', $context['sub']['prim_group'] == $id ? ' selected' : '', '>', $name, '</option>'; |
76 | + } |
|
75 | 77 | |
76 | 78 | echo ' |
77 | 79 | </select> |
@@ -83,11 +85,12 @@ discard block |
||
83 | 85 | <dd>'; |
84 | 86 | |
85 | 87 | // Put a checkbox in for each group |
86 | - foreach ($context['groups'] as $id => $name) |
|
87 | - echo ' |
|
88 | + foreach ($context['groups'] as $id => $name) { |
|
89 | + echo ' |
|
88 | 90 | <label for="addgroup_', $id, '"> |
89 | 91 | <input type="checkbox" id="addgroup_', $id, '" name="addgroup[', $id, ']"', in_array($id, $context['sub']['add_groups']) ? ' checked' : '', !empty($context['disable_groups']) ? ' disabled' : '', '> <span class="smalltext">', $name, '</span> |
90 | 92 | </label><br>'; |
93 | + } |
|
91 | 94 | |
92 | 95 | echo ' |
93 | 96 | </dd> |
@@ -141,8 +144,8 @@ discard block |
||
141 | 144 | <fieldset>'; |
142 | 145 | |
143 | 146 | //!! Removed until implemented |
144 | - if (!empty($sdflsdhglsdjgs)) |
|
145 | - echo ' |
|
147 | + if (!empty($sdflsdhglsdjgs)) { |
|
148 | + echo ' |
|
146 | 149 | <dl class="settings"> |
147 | 150 | <dt> |
148 | 151 | <label for="allow_partial_check">', $txt['paid_mod_allow_partial'], '</label>:<br><span class="smalltext">', $txt['paid_mod_allow_partial_desc'], '</span> |
@@ -151,6 +154,7 @@ discard block |
||
151 | 154 | <input type="checkbox" name="allow_partial" id="allow_partial_check"', empty($context['sub']['allow_partial']) ? '' : ' checked', '> |
152 | 155 | </dd> |
153 | 156 | </dl>'; |
157 | + } |
|
154 | 158 | |
155 | 159 | echo ' |
156 | 160 | <div class="information"> |
@@ -251,8 +255,8 @@ discard block |
||
251 | 255 | <dl class="settings">'; |
252 | 256 | |
253 | 257 | // Do we need a username? |
254 | - if ($context['action_type'] == 'add') |
|
255 | - echo ' |
|
258 | + if ($context['action_type'] == 'add') { |
|
259 | + echo ' |
|
256 | 260 | <dt> |
257 | 261 | <strong>', $txt['paid_username'], ':</strong><br> |
258 | 262 | <span class="smalltext">', $txt['one_username'], '</span> |
@@ -260,6 +264,7 @@ discard block |
||
260 | 264 | <dd> |
261 | 265 | <input type="text" name="name" id="name_control" value="', $context['sub']['username'], '" size="30"> |
262 | 266 | </dd>'; |
267 | + } |
|
263 | 268 | |
264 | 269 | echo ' |
265 | 270 | <dt> |
@@ -277,9 +282,10 @@ discard block |
||
277 | 282 | <select name="year" id="year" onchange="generateDays();">'; |
278 | 283 | |
279 | 284 | // Show a list of all the years we allow... |
280 | - for ($year = 2005; $year <= 2030; $year++) |
|
281 | - echo ' |
|
285 | + for ($year = 2005; $year <= 2030; $year++) { |
|
286 | + echo ' |
|
282 | 287 | <option value="', $year, '"', $year == $context['sub']['start']['year'] ? ' selected' : '', '>', $year, '</option>'; |
288 | + } |
|
283 | 289 | |
284 | 290 | echo ' |
285 | 291 | </select> |
@@ -287,9 +293,10 @@ discard block |
||
287 | 293 | <select name="month" id="month" onchange="generateDays();">'; |
288 | 294 | |
289 | 295 | // There are 12 months per year - ensure that they all get listed. |
290 | - for ($month = 1; $month <= 12; $month++) |
|
291 | - echo ' |
|
296 | + for ($month = 1; $month <= 12; $month++) { |
|
297 | + echo ' |
|
292 | 298 | <option value="', $month, '"', $month == $context['sub']['start']['month'] ? ' selected' : '', '>', $txt['months'][$month], '</option>'; |
299 | + } |
|
293 | 300 | |
294 | 301 | echo ' |
295 | 302 | </select> |
@@ -297,9 +304,10 @@ discard block |
||
297 | 304 | <select name="day" id="day">'; |
298 | 305 | |
299 | 306 | // This prints out all the days in the current month - this changes dynamically as we switch months. |
300 | - for ($day = 1; $day <= $context['sub']['start']['last_day']; $day++) |
|
301 | - echo ' |
|
307 | + for ($day = 1; $day <= $context['sub']['start']['last_day']; $day++) { |
|
308 | + echo ' |
|
302 | 309 | <option value="', $day, '"', $day == $context['sub']['start']['day'] ? ' selected' : '', '>', $day, '</option>'; |
310 | + } |
|
303 | 311 | |
304 | 312 | echo ' |
305 | 313 | </select> |
@@ -311,9 +319,10 @@ discard block |
||
311 | 319 | <select name="yearend" id="yearend" onchange="generateDays(\'end\');">'; |
312 | 320 | |
313 | 321 | // Show a list of all the years we allow... |
314 | - for ($year = 2005; $year <= 2030; $year++) |
|
315 | - echo ' |
|
322 | + for ($year = 2005; $year <= 2030; $year++) { |
|
323 | + echo ' |
|
316 | 324 | <option value="', $year, '"', $year == $context['sub']['end']['year'] ? ' selected' : '', '>', $year, '</option>'; |
325 | + } |
|
317 | 326 | |
318 | 327 | echo ' |
319 | 328 | </select> |
@@ -321,9 +330,10 @@ discard block |
||
321 | 330 | <select name="monthend" id="monthend" onchange="generateDays(\'end\');">'; |
322 | 331 | |
323 | 332 | // There are 12 months per year - ensure that they all get listed. |
324 | - for ($month = 1; $month <= 12; $month++) |
|
325 | - echo ' |
|
333 | + for ($month = 1; $month <= 12; $month++) { |
|
334 | + echo ' |
|
326 | 335 | <option value="', $month, '"', $month == $context['sub']['end']['month'] ? ' selected' : '', '>', $txt['months'][$month], '</option>'; |
336 | + } |
|
327 | 337 | |
328 | 338 | echo ' |
329 | 339 | </select> |
@@ -331,9 +341,10 @@ discard block |
||
331 | 341 | <select name="dayend" id="dayend">'; |
332 | 342 | |
333 | 343 | // This prints out all the days in the current month - this changes dynamically as we switch months. |
334 | - for ($day = 1; $day <= $context['sub']['end']['last_day']; $day++) |
|
335 | - echo ' |
|
344 | + for ($day = 1; $day <= $context['sub']['end']['last_day']; $day++) { |
|
345 | + echo ' |
|
336 | 346 | <option value="', $day, '"', $day == $context['sub']['end']['day'] ? ' selected' : '', '>', $day, '</option>'; |
347 | + } |
|
337 | 348 | |
338 | 349 | echo ' |
339 | 350 | </select> |
@@ -415,8 +426,7 @@ discard block |
||
415 | 426 | <div class="information"> |
416 | 427 | ', $txt['paid_subs_none'], ' |
417 | 428 | </div>'; |
418 | - } |
|
419 | - else |
|
429 | + } else |
|
420 | 430 | { |
421 | 431 | echo ' |
422 | 432 | <div class="information"> |
@@ -428,8 +438,9 @@ discard block |
||
428 | 438 | { |
429 | 439 | |
430 | 440 | // Ignore the inactive ones... |
431 | - if (empty($subscription['active'])) |
|
432 | - continue; |
|
441 | + if (empty($subscription['active'])) { |
|
442 | + continue; |
|
443 | + } |
|
433 | 444 | |
434 | 445 | echo ' |
435 | 446 | <div class="cat_bar"> |
@@ -439,9 +450,10 @@ discard block |
||
439 | 450 | <p><strong>', $subscription['name'], '</strong></p> |
440 | 451 | <p class="smalltext">', $subscription['desc'], '</p>'; |
441 | 452 | |
442 | - if (!$subscription['flexible']) |
|
443 | - echo ' |
|
453 | + if (!$subscription['flexible']) { |
|
454 | + echo ' |
|
444 | 455 | <div><strong>', $txt['paid_duration'], ':</strong> ', $subscription['length'], '</div>'; |
456 | + } |
|
445 | 457 | |
446 | 458 | if ($context['user']['is_owner']) |
447 | 459 | { |
@@ -454,24 +466,25 @@ discard block |
||
454 | 466 | <select name="cur[', $subscription['id'], ']">'; |
455 | 467 | |
456 | 468 | // Print out the costs for this one. |
457 | - foreach ($subscription['costs'] as $duration => $value) |
|
458 | - echo ' |
|
469 | + foreach ($subscription['costs'] as $duration => $value) { |
|
470 | + echo ' |
|
459 | 471 | <option value="', $duration, '">', sprintf($modSettings['paid_currency_symbol'], $value), '/', $txt[$duration], '</option>'; |
472 | + } |
|
460 | 473 | |
461 | 474 | echo ' |
462 | 475 | </select>'; |
463 | - } |
|
464 | - else |
|
465 | - echo ' |
|
476 | + } else { |
|
477 | + echo ' |
|
466 | 478 | ', sprintf($modSettings['paid_currency_symbol'], $subscription['costs']['fixed']); |
479 | + } |
|
467 | 480 | |
468 | 481 | echo ' |
469 | 482 | <hr> |
470 | 483 | <input type="submit" name="sub_id[', $subscription['id'], ']" value="', $txt['paid_order'], '" class="button">'; |
471 | - } |
|
472 | - else |
|
473 | - echo ' |
|
484 | + } else { |
|
485 | + echo ' |
|
474 | 486 | <a href="', $scripturl, '?action=admin;area=paidsubscribe;sa=modifyuser;sid=', $subscription['id'], ';uid=', $context['member']['id'], (empty($context['current'][$subscription['id']]) ? '' : ';lid=' . $context['current'][$subscription['id']]['id']), '">', empty($context['current'][$subscription['id']]) ? $txt['paid_admin_add'] : $txt['paid_edit_subscription'], '</a>'; |
487 | + } |
|
475 | 488 | |
476 | 489 | echo ' |
477 | 490 | </div><!-- .windowbg -->'; |
@@ -498,19 +511,20 @@ discard block |
||
498 | 511 | </thead> |
499 | 512 | <tbody>'; |
500 | 513 | |
501 | - if (empty($context['current'])) |
|
502 | - echo ' |
|
514 | + if (empty($context['current'])) { |
|
515 | + echo ' |
|
503 | 516 | <tr class="windowbg"> |
504 | 517 | <td colspan="4"> |
505 | 518 | ', $txt['paid_none_yet'], ' |
506 | 519 | </td> |
507 | 520 | </tr>'; |
521 | + } |
|
508 | 522 | |
509 | 523 | foreach ($context['current'] as $sub) |
510 | 524 | { |
511 | 525 | |
512 | - if (!$sub['hide']) |
|
513 | - echo ' |
|
526 | + if (!$sub['hide']) { |
|
527 | + echo ' |
|
514 | 528 | <tr class="windowbg"> |
515 | 529 | <td> |
516 | 530 | ', (allowedTo('admin_forum') ? '<a href="' . $scripturl . '?action=admin;area=paidsubscribe;sa=modifyuser;lid=' . $sub['id'] . '">' . $sub['name'] . '</a>' : $sub['name']), ' |
@@ -521,6 +535,7 @@ discard block |
||
521 | 535 | <td>', $sub['start'], '</td> |
522 | 536 | <td>', $sub['end'], '</td> |
523 | 537 | </tr>'; |
538 | + } |
|
524 | 539 | } |
525 | 540 | echo ' |
526 | 541 | </tbody> |
@@ -571,15 +586,17 @@ discard block |
||
571 | 586 | ', $gateway['desc'], '<br> |
572 | 587 | <form action="', $gateway['form'], '" method="post">'; |
573 | 588 | |
574 | - if (!empty($gateway['javascript'])) |
|
575 | - echo ' |
|
589 | + if (!empty($gateway['javascript'])) { |
|
590 | + echo ' |
|
576 | 591 | <script> |
577 | 592 | ', $gateway['javascript'], ' |
578 | 593 | </script>'; |
594 | + } |
|
579 | 595 | |
580 | - foreach ($gateway['hidden'] as $name => $value) |
|
581 | - echo ' |
|
596 | + foreach ($gateway['hidden'] as $name => $value) { |
|
597 | + echo ' |
|
582 | 598 | <input type="hidden" id="', $gateway['id'], '_', $name, '" name="', $name, '" value="', $value, '">'; |
599 | + } |
|
583 | 600 | |
584 | 601 | echo ' |
585 | 602 | <br> |