@@ -324,7 +324,7 @@ discard block |
||
| 324 | 324 | ' . (empty($sort_methods_table[$context['sort_by']]) ? '' : $sort_methods_table[$context['sort_by']]) . ' |
| 325 | 325 | WHERE t.id_board = {int:current_board} ' |
| 326 | 326 | . (!$modSettings['postmod_active'] || $context['can_approve_posts'] ? '' : ' |
| 327 | - AND (t.approved = {int:is_approved}' . ($user_info['is_guest'] ? '' : ' OR t.id_member_started = {int:current_member}') . ')') .' |
|
| 327 | + AND (t.approved = {int:is_approved}' . ($user_info['is_guest'] ? '' : ' OR t.id_member_started = {int:current_member}') . ')') . ' |
|
| 328 | 328 | ORDER BY is_sticky' . ($fake_ascending ? '' : ' DESC') . ', ' . $_REQUEST['sort'] . ($ascending ? '' : ' DESC') . ' |
| 329 | 329 | LIMIT {int:maxindex} |
| 330 | 330 | OFFSET {int:start} '; |
@@ -333,7 +333,7 @@ discard block |
||
| 333 | 333 | SELECT |
| 334 | 334 | t.id_topic, t.num_replies, t.locked, t.num_views, t.is_sticky, t.id_poll, t.id_previous_board, |
| 335 | 335 | ' . ($user_info['is_guest'] ? '0' : 'COALESCE(lt.id_msg, COALESCE(lmr.id_msg, -1)) + 1') . ' AS new_from, |
| 336 | - ' . ( $enableParticipation ? ' COALESCE(( SELECT 1 FROM {db_prefix}messages AS parti WHERE t.id_topic = parti.id_topic and parti.id_member = {int:current_member} LIMIT 1) , 0) as is_posted_in, |
|
| 336 | + ' . ($enableParticipation ? ' COALESCE(( SELECT 1 FROM {db_prefix}messages AS parti WHERE t.id_topic = parti.id_topic and parti.id_member = {int:current_member} LIMIT 1) , 0) as is_posted_in, |
|
| 337 | 337 | ' : '') . ' |
| 338 | 338 | t.id_last_msg, t.approved, t.unapproved_posts, ml.poster_time AS last_poster_time, t.id_redirect_topic, |
| 339 | 339 | ml.id_msg_modified, ml.subject AS last_subject, ml.icon AS last_icon, |
@@ -357,7 +357,7 @@ discard block |
||
| 357 | 357 | LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = {int:current_board} AND lmr.id_member = {int:current_member})') . ' |
| 358 | 358 | ' . (!empty($message_index_tables) ? implode("\n\t\t\t\t", $message_index_tables) : '') . ' |
| 359 | 359 | ' . (!empty($message_index_wheres) ? ' WHERE ' . implode("\n\t\t\t\tAND ", $message_index_wheres) : '') . ' |
| 360 | - ORDER BY is_sticky' . ($fake_ascending ? '' : ' DESC') . ', ' . $_REQUEST['sort'] . ($ascending ? '' : ' DESC') , |
|
| 360 | + ORDER BY is_sticky' . ($fake_ascending ? '' : ' DESC') . ', ' . $_REQUEST['sort'] . ($ascending ? '' : ' DESC'), |
|
| 361 | 361 | $message_index_parameters |
| 362 | 362 | ); |
| 363 | 363 | |
@@ -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); |
@@ -273,8 +286,9 @@ discard block |
||
| 273 | 286 | // Bring in any changes we want to make before the query. |
| 274 | 287 | call_integration_hook('integrate_pre_messageindex', array(&$sort_methods)); |
| 275 | 288 | |
| 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>'; |
|
| 289 | + foreach ($sort_methods as $key => $val) { |
|
| 290 | + $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>'; |
|
| 291 | + } |
|
| 278 | 292 | |
| 279 | 293 | // Calculate the fastest way to get the topics. |
| 280 | 294 | $start = (int) $_REQUEST['start']; |
@@ -284,14 +298,15 @@ discard block |
||
| 284 | 298 | $fake_ascending = true; |
| 285 | 299 | $context['maxindex'] = $board_info['total_topics'] < $start + $context['maxindex'] + 1 ? $board_info['total_topics'] - $start : $context['maxindex']; |
| 286 | 300 | $start = $board_info['total_topics'] < $start + $context['maxindex'] + 1 ? 0 : $board_info['total_topics'] - $start - $context['maxindex']; |
| 301 | + } else { |
|
| 302 | + $fake_ascending = false; |
|
| 287 | 303 | } |
| 288 | - else |
|
| 289 | - $fake_ascending = false; |
|
| 290 | 304 | |
| 291 | 305 | // Setup the default topic icons... |
| 292 | 306 | $context['icon_sources'] = array(); |
| 293 | - foreach ($context['stable_icons'] as $icon) |
|
| 294 | - $context['icon_sources'][$icon] = 'images_url'; |
|
| 307 | + foreach ($context['stable_icons'] as $icon) { |
|
| 308 | + $context['icon_sources'][$icon] = 'images_url'; |
|
| 309 | + } |
|
| 295 | 310 | |
| 296 | 311 | $topic_ids = array(); |
| 297 | 312 | $context['topics'] = array(); |
@@ -314,10 +329,11 @@ discard block |
||
| 314 | 329 | $message_index_wheres = array(); |
| 315 | 330 | call_integration_hook('integrate_message_index', array(&$message_index_selects, &$message_index_tables, &$message_index_parameters, &$message_index_wheres, &$topic_ids)); |
| 316 | 331 | |
| 317 | - if (!empty($modSettings['enableParticipation']) && !$user_info['is_guest']) |
|
| 318 | - $enableParticipation = true; |
|
| 319 | - else |
|
| 320 | - $enableParticipation = false; |
|
| 332 | + if (!empty($modSettings['enableParticipation']) && !$user_info['is_guest']) { |
|
| 333 | + $enableParticipation = true; |
|
| 334 | + } else { |
|
| 335 | + $enableParticipation = false; |
|
| 336 | + } |
|
| 321 | 337 | |
| 322 | 338 | $sort_table = 'SELECT t.id_topic, t.id_first_msg, t.id_last_msg |
| 323 | 339 | FROM {db_prefix}topics t |
@@ -364,8 +380,9 @@ discard block |
||
| 364 | 380 | // Begin 'printing' the message index for current board. |
| 365 | 381 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 366 | 382 | { |
| 367 | - if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') |
|
| 368 | - continue; |
|
| 383 | + if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') { |
|
| 384 | + continue; |
|
| 385 | + } |
|
| 369 | 386 | |
| 370 | 387 | $topic_ids[] = $row['id_topic']; |
| 371 | 388 | |
@@ -377,8 +394,9 @@ discard block |
||
| 377 | 394 | { |
| 378 | 395 | // Limit them to $modSettings['preview_characters'] characters |
| 379 | 396 | $row['first_body'] = strip_tags(strtr(parse_bbc($row['first_body'], $row['first_smileys'], $row['id_first_msg']), array('<br>' => ' '))); |
| 380 | - if ($smcFunc['strlen']($row['first_body']) > $modSettings['preview_characters']) |
|
| 381 | - $row['first_body'] = $smcFunc['substr']($row['first_body'], 0, $modSettings['preview_characters']) . '...'; |
|
| 397 | + if ($smcFunc['strlen']($row['first_body']) > $modSettings['preview_characters']) { |
|
| 398 | + $row['first_body'] = $smcFunc['substr']($row['first_body'], 0, $modSettings['preview_characters']) . '...'; |
|
| 399 | + } |
|
| 382 | 400 | |
| 383 | 401 | // Censor the subject and message preview. |
| 384 | 402 | censorText($row['first_subject']); |
@@ -389,27 +407,27 @@ discard block |
||
| 389 | 407 | { |
| 390 | 408 | $row['last_subject'] = $row['first_subject']; |
| 391 | 409 | $row['last_body'] = $row['first_body']; |
| 392 | - } |
|
| 393 | - else |
|
| 410 | + } else |
|
| 394 | 411 | { |
| 395 | 412 | $row['last_body'] = strip_tags(strtr(parse_bbc($row['last_body'], $row['last_smileys'], $row['id_last_msg']), array('<br>' => ' '))); |
| 396 | - if ($smcFunc['strlen']($row['last_body']) > $modSettings['preview_characters']) |
|
| 397 | - $row['last_body'] = $smcFunc['substr']($row['last_body'], 0, $modSettings['preview_characters']) . '...'; |
|
| 413 | + if ($smcFunc['strlen']($row['last_body']) > $modSettings['preview_characters']) { |
|
| 414 | + $row['last_body'] = $smcFunc['substr']($row['last_body'], 0, $modSettings['preview_characters']) . '...'; |
|
| 415 | + } |
|
| 398 | 416 | |
| 399 | 417 | censorText($row['last_subject']); |
| 400 | 418 | censorText($row['last_body']); |
| 401 | 419 | } |
| 402 | - } |
|
| 403 | - else |
|
| 420 | + } else |
|
| 404 | 421 | { |
| 405 | 422 | $row['first_body'] = ''; |
| 406 | 423 | $row['last_body'] = ''; |
| 407 | 424 | censorText($row['first_subject']); |
| 408 | 425 | |
| 409 | - if ($row['id_first_msg'] == $row['id_last_msg']) |
|
| 410 | - $row['last_subject'] = $row['first_subject']; |
|
| 411 | - else |
|
| 412 | - censorText($row['last_subject']); |
|
| 426 | + if ($row['id_first_msg'] == $row['id_last_msg']) { |
|
| 427 | + $row['last_subject'] = $row['first_subject']; |
|
| 428 | + } else { |
|
| 429 | + censorText($row['last_subject']); |
|
| 430 | + } |
|
| 413 | 431 | } |
| 414 | 432 | |
| 415 | 433 | // Decide how many pages the topic should have. |
@@ -420,42 +438,50 @@ discard block |
||
| 420 | 438 | $pages = constructPageIndex($scripturl . '?topic=' . $row['id_topic'] . '.%1$d', $start, $row['num_replies'] + 1, $context['messages_per_page'], true, false); |
| 421 | 439 | |
| 422 | 440 | // If we can use all, show all. |
| 423 | - if (!empty($modSettings['enableAllMessages']) && $row['num_replies'] + 1 < $modSettings['enableAllMessages']) |
|
| 424 | - $pages .= ' <a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>'; |
|
| 441 | + if (!empty($modSettings['enableAllMessages']) && $row['num_replies'] + 1 < $modSettings['enableAllMessages']) { |
|
| 442 | + $pages .= ' <a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>'; |
|
| 443 | + } |
|
| 444 | + } else { |
|
| 445 | + $pages = ''; |
|
| 425 | 446 | } |
| 426 | - else |
|
| 427 | - $pages = ''; |
|
| 428 | 447 | |
| 429 | 448 | // We need to check the topic icons exist... |
| 430 | 449 | if (!empty($modSettings['messageIconChecks_enable'])) |
| 431 | 450 | { |
| 432 | - if (!isset($context['icon_sources'][$row['first_icon']])) |
|
| 433 | - $context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 434 | - if (!isset($context['icon_sources'][$row['last_icon']])) |
|
| 435 | - $context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 436 | - } |
|
| 437 | - else |
|
| 451 | + if (!isset($context['icon_sources'][$row['first_icon']])) { |
|
| 452 | + $context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 453 | + } |
|
| 454 | + if (!isset($context['icon_sources'][$row['last_icon']])) { |
|
| 455 | + $context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 456 | + } |
|
| 457 | + } else |
|
| 438 | 458 | { |
| 439 | - if (!isset($context['icon_sources'][$row['first_icon']])) |
|
| 440 | - $context['icon_sources'][$row['first_icon']] = 'images_url'; |
|
| 441 | - if (!isset($context['icon_sources'][$row['last_icon']])) |
|
| 442 | - $context['icon_sources'][$row['last_icon']] = 'images_url'; |
|
| 459 | + if (!isset($context['icon_sources'][$row['first_icon']])) { |
|
| 460 | + $context['icon_sources'][$row['first_icon']] = 'images_url'; |
|
| 461 | + } |
|
| 462 | + if (!isset($context['icon_sources'][$row['last_icon']])) { |
|
| 463 | + $context['icon_sources'][$row['last_icon']] = 'images_url'; |
|
| 464 | + } |
|
| 443 | 465 | } |
| 444 | 466 | |
| 445 | - if (!empty($board_info['recycle'])) |
|
| 446 | - $row['first_icon'] = 'recycled'; |
|
| 467 | + if (!empty($board_info['recycle'])) { |
|
| 468 | + $row['first_icon'] = 'recycled'; |
|
| 469 | + } |
|
| 447 | 470 | |
| 448 | 471 | // Is this topic pending approval, or does it have any posts pending approval? |
| 449 | - if ($context['can_approve_posts'] && $row['unapproved_posts']) |
|
| 450 | - $colorClass .= (!$row['approved'] ? ' approvetopic' : ' approvepost'); |
|
| 472 | + if ($context['can_approve_posts'] && $row['unapproved_posts']) { |
|
| 473 | + $colorClass .= (!$row['approved'] ? ' approvetopic' : ' approvepost'); |
|
| 474 | + } |
|
| 451 | 475 | |
| 452 | 476 | // Sticky topics should get a different color, too. |
| 453 | - if ($row['is_sticky']) |
|
| 454 | - $colorClass .= ' sticky'; |
|
| 477 | + if ($row['is_sticky']) { |
|
| 478 | + $colorClass .= ' sticky'; |
|
| 479 | + } |
|
| 455 | 480 | |
| 456 | 481 | // Locked topics get special treatment as well. |
| 457 | - if ($row['locked']) |
|
| 458 | - $colorClass .= ' locked'; |
|
| 482 | + if ($row['locked']) { |
|
| 483 | + $colorClass .= ' locked'; |
|
| 484 | + } |
|
| 459 | 485 | |
| 460 | 486 | // 'Print' the topic info. |
| 461 | 487 | $context['topics'][$row['id_topic']] = array_merge($row, array( |
@@ -536,8 +562,9 @@ discard block |
||
| 536 | 562 | $smcFunc['db_free_result']($result); |
| 537 | 563 | |
| 538 | 564 | // Fix the sequence of topics if they were retrieved in the wrong order. (for speed reasons...) |
| 539 | - if ($fake_ascending) |
|
| 540 | - $context['topics'] = array_reverse($context['topics'], true); |
|
| 565 | + if ($fake_ascending) { |
|
| 566 | + $context['topics'] = array_reverse($context['topics'], true); |
|
| 567 | + } |
|
| 541 | 568 | |
| 542 | 569 | |
| 543 | 570 | $context['jump_to'] = array( |
@@ -560,9 +587,9 @@ discard block |
||
| 560 | 587 | // Can we restore topics? |
| 561 | 588 | $context['can_restore'] = allowedTo('move_any') && !empty($board_info['recycle']); |
| 562 | 589 | |
| 563 | - if ($user_info['is_admin'] || $modSettings['topic_move_any']) |
|
| 564 | - $context['can_move_any'] = true; |
|
| 565 | - else |
|
| 590 | + if ($user_info['is_admin'] || $modSettings['topic_move_any']) { |
|
| 591 | + $context['can_move_any'] = true; |
|
| 592 | + } else |
|
| 566 | 593 | { |
| 567 | 594 | // We'll use this in a minute |
| 568 | 595 | $boards_allowed = boardsAllowedTo('post_new'); |
@@ -589,11 +616,13 @@ discard block |
||
| 589 | 616 | } |
| 590 | 617 | |
| 591 | 618 | // Can we use quick moderation checkboxes? |
| 592 | - if ($options['display_quick_mod'] == 1) |
|
| 593 | - $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']; |
|
| 619 | + if ($options['display_quick_mod'] == 1) { |
|
| 620 | + $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']; |
|
| 621 | + } |
|
| 594 | 622 | // Or the icons? |
| 595 | - else |
|
| 596 | - $context['can_quick_mod'] = $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move']; |
|
| 623 | + else { |
|
| 624 | + $context['can_quick_mod'] = $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move']; |
|
| 625 | + } |
|
| 597 | 626 | } |
| 598 | 627 | |
| 599 | 628 | if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1) |
@@ -627,13 +656,15 @@ discard block |
||
| 627 | 656 | ); |
| 628 | 657 | |
| 629 | 658 | // We've seen all these boards now! |
| 630 | - foreach ($board_info['parent_boards'] as $k => $dummy) |
|
| 631 | - if (isset($_SESSION['topicseen_cache'][$k])) |
|
| 659 | + foreach ($board_info['parent_boards'] as $k => $dummy) { |
|
| 660 | + if (isset($_SESSION['topicseen_cache'][$k])) |
|
| 632 | 661 | unset($_SESSION['topicseen_cache'][$k]); |
| 662 | + } |
|
| 633 | 663 | } |
| 634 | 664 | |
| 635 | - if (isset($_SESSION['topicseen_cache'][$board])) |
|
| 636 | - unset($_SESSION['topicseen_cache'][$board]); |
|
| 665 | + if (isset($_SESSION['topicseen_cache'][$board])) { |
|
| 666 | + unset($_SESSION['topicseen_cache'][$board]); |
|
| 667 | + } |
|
| 637 | 668 | |
| 638 | 669 | $request = $smcFunc['db_query']('', ' |
| 639 | 670 | SELECT id_topic, id_board, sent |
@@ -654,8 +685,9 @@ discard block |
||
| 654 | 685 | $context['is_marked_notify'] = true; |
| 655 | 686 | $board_sent = $row['sent']; |
| 656 | 687 | } |
| 657 | - if (!empty($row['id_topic'])) |
|
| 658 | - $context['topics'][$row['id_topic']]['is_watched'] = true; |
|
| 688 | + if (!empty($row['id_topic'])) { |
|
| 689 | + $context['topics'][$row['id_topic']]['is_watched'] = true; |
|
| 690 | + } |
|
| 659 | 691 | } |
| 660 | 692 | $smcFunc['db_free_result']($request); |
| 661 | 693 | |
@@ -679,8 +711,7 @@ discard block |
||
| 679 | 711 | $pref = !empty($pref[$user_info['id']]) ? $pref[$user_info['id']] : array(); |
| 680 | 712 | $pref = isset($pref['board_notify_' . $board]) ? $pref['board_notify_' . $board] : (!empty($pref['board_notify']) ? $pref['board_notify'] : 0); |
| 681 | 713 | $context['board_notification_mode'] = !$context['is_marked_notify'] ? 1 : ($pref & 0x02 ? 3 : ($pref & 0x01 ? 2 : 1)); |
| 682 | - } |
|
| 683 | - else |
|
| 714 | + } else |
|
| 684 | 715 | { |
| 685 | 716 | $context['is_marked_notify'] = false; |
| 686 | 717 | $context['board_notification_mode'] = 1; |
@@ -693,23 +724,27 @@ discard block |
||
| 693 | 724 | $context['becomesUnapproved'] = !empty($_SESSION['becomesUnapproved']) ? true : false; |
| 694 | 725 | |
| 695 | 726 | // Don't want to show this forever... |
| 696 | - if ($context['becomesUnapproved']) |
|
| 697 | - unset($_SESSION['becomesUnapproved']); |
|
| 727 | + if ($context['becomesUnapproved']) { |
|
| 728 | + unset($_SESSION['becomesUnapproved']); |
|
| 729 | + } |
|
| 698 | 730 | |
| 699 | 731 | // Build the message index button array. |
| 700 | 732 | $context['normal_buttons'] = array(); |
| 701 | 733 | |
| 702 | - if ($context['can_post_new']) |
|
| 703 | - $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); |
|
| 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); |
|
| 736 | + } |
|
| 704 | 737 | |
| 705 | - if ($context['can_post_poll']) |
|
| 706 | - $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'); |
|
| 738 | + if ($context['can_post_poll']) { |
|
| 739 | + $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'); |
|
| 740 | + } |
|
| 707 | 741 | |
| 708 | - if ($context['user']['is_logged']) |
|
| 709 | - $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']); |
|
| 742 | + if ($context['user']['is_logged']) { |
|
| 743 | + $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']); |
|
| 744 | + } |
|
| 710 | 745 | |
| 711 | - if ($context['can_mark_notify']) |
|
| 712 | - $context['normal_buttons']['notify'] = array( |
|
| 746 | + if ($context['can_mark_notify']) { |
|
| 747 | + $context['normal_buttons']['notify'] = array( |
|
| 713 | 748 | 'lang' => true, |
| 714 | 749 | 'text' => 'notify_board_' . $context['board_notification_mode'], |
| 715 | 750 | 'sub_buttons' => array( |
@@ -727,6 +762,7 @@ discard block |
||
| 727 | 762 | ), |
| 728 | 763 | ), |
| 729 | 764 | ); |
| 765 | + } |
|
| 730 | 766 | |
| 731 | 767 | // Javascript for inline editing. |
| 732 | 768 | loadJavaScriptFile('topic.js', array('defer' => false, 'minimize' => true), 'smf_topic'); |
@@ -748,18 +784,21 @@ discard block |
||
| 748 | 784 | checkSession('request'); |
| 749 | 785 | |
| 750 | 786 | // Lets go straight to the restore area. |
| 751 | - if (isset($_REQUEST['qaction']) && $_REQUEST['qaction'] == 'restore' && !empty($_REQUEST['topics'])) |
|
| 752 | - redirectexit('action=restoretopic;topics=' . implode(',', $_REQUEST['topics']) . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 787 | + if (isset($_REQUEST['qaction']) && $_REQUEST['qaction'] == 'restore' && !empty($_REQUEST['topics'])) { |
|
| 788 | + redirectexit('action=restoretopic;topics=' . implode(',', $_REQUEST['topics']) . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 789 | + } |
|
| 753 | 790 | |
| 754 | - if (isset($_SESSION['topicseen_cache'])) |
|
| 755 | - $_SESSION['topicseen_cache'] = array(); |
|
| 791 | + if (isset($_SESSION['topicseen_cache'])) { |
|
| 792 | + $_SESSION['topicseen_cache'] = array(); |
|
| 793 | + } |
|
| 756 | 794 | |
| 757 | 795 | // This is going to be needed to send off the notifications and for updateLastMessages(). |
| 758 | 796 | require_once($sourcedir . '/Subs-Post.php'); |
| 759 | 797 | |
| 760 | 798 | // Remember the last board they moved things to. |
| 761 | - if (isset($_REQUEST['move_to'])) |
|
| 762 | - $_SESSION['move_to_topic'] = $_REQUEST['move_to']; |
|
| 799 | + if (isset($_REQUEST['move_to'])) { |
|
| 800 | + $_SESSION['move_to_topic'] = $_REQUEST['move_to']; |
|
| 801 | + } |
|
| 763 | 802 | |
| 764 | 803 | // Only a few possible actions. |
| 765 | 804 | $possibleActions = array(); |
@@ -779,8 +818,7 @@ discard block |
||
| 779 | 818 | ); |
| 780 | 819 | |
| 781 | 820 | $redirect_url = 'board=' . $board . '.' . $_REQUEST['start']; |
| 782 | - } |
|
| 783 | - else |
|
| 821 | + } else |
|
| 784 | 822 | { |
| 785 | 823 | /** |
| 786 | 824 | * @todo Ugly. There's no getting around this, is there? |
@@ -798,8 +836,7 @@ discard block |
||
| 798 | 836 | if (!empty($board)) |
| 799 | 837 | { |
| 800 | 838 | $boards_can['post_new'] = array_diff(boardsAllowedTo('post_new'), array($board)); |
| 801 | - } |
|
| 802 | - else |
|
| 839 | + } else |
|
| 803 | 840 | { |
| 804 | 841 | $boards_can['post_new'] = boardsAllowedTo('post_new'); |
| 805 | 842 | } |
@@ -810,55 +847,67 @@ discard block |
||
| 810 | 847 | } |
| 811 | 848 | } |
| 812 | 849 | |
| 813 | - if (!$user_info['is_guest']) |
|
| 814 | - $possibleActions[] = 'markread'; |
|
| 815 | - if (!empty($boards_can['make_sticky'])) |
|
| 816 | - $possibleActions[] = 'sticky'; |
|
| 817 | - if (!empty($boards_can['move_any']) || !empty($boards_can['move_own'])) |
|
| 818 | - $possibleActions[] = 'move'; |
|
| 819 | - if (!empty($boards_can['remove_any']) || !empty($boards_can['remove_own'])) |
|
| 820 | - $possibleActions[] = 'remove'; |
|
| 821 | - if (!empty($boards_can['lock_any']) || !empty($boards_can['lock_own'])) |
|
| 822 | - $possibleActions[] = 'lock'; |
|
| 823 | - if (!empty($boards_can['merge_any'])) |
|
| 824 | - $possibleActions[] = 'merge'; |
|
| 825 | - if (!empty($boards_can['approve_posts'])) |
|
| 826 | - $possibleActions[] = 'approve'; |
|
| 850 | + if (!$user_info['is_guest']) { |
|
| 851 | + $possibleActions[] = 'markread'; |
|
| 852 | + } |
|
| 853 | + if (!empty($boards_can['make_sticky'])) { |
|
| 854 | + $possibleActions[] = 'sticky'; |
|
| 855 | + } |
|
| 856 | + if (!empty($boards_can['move_any']) || !empty($boards_can['move_own'])) { |
|
| 857 | + $possibleActions[] = 'move'; |
|
| 858 | + } |
|
| 859 | + if (!empty($boards_can['remove_any']) || !empty($boards_can['remove_own'])) { |
|
| 860 | + $possibleActions[] = 'remove'; |
|
| 861 | + } |
|
| 862 | + if (!empty($boards_can['lock_any']) || !empty($boards_can['lock_own'])) { |
|
| 863 | + $possibleActions[] = 'lock'; |
|
| 864 | + } |
|
| 865 | + if (!empty($boards_can['merge_any'])) { |
|
| 866 | + $possibleActions[] = 'merge'; |
|
| 867 | + } |
|
| 868 | + if (!empty($boards_can['approve_posts'])) { |
|
| 869 | + $possibleActions[] = 'approve'; |
|
| 870 | + } |
|
| 827 | 871 | |
| 828 | 872 | // Two methods: $_REQUEST['actions'] (id_topic => action), and $_REQUEST['topics'] and $_REQUEST['qaction']. |
| 829 | 873 | // (if action is 'move', $_REQUEST['move_to'] or $_REQUEST['move_tos'][$topic] is used.) |
| 830 | 874 | if (!empty($_REQUEST['topics'])) |
| 831 | 875 | { |
| 832 | 876 | // If the action isn't valid, just quit now. |
| 833 | - if (empty($_REQUEST['qaction']) || !in_array($_REQUEST['qaction'], $possibleActions)) |
|
| 834 | - redirectexit($redirect_url); |
|
| 877 | + if (empty($_REQUEST['qaction']) || !in_array($_REQUEST['qaction'], $possibleActions)) { |
|
| 878 | + redirectexit($redirect_url); |
|
| 879 | + } |
|
| 835 | 880 | |
| 836 | 881 | // Merge requires all topics as one parameter and can be done at once. |
| 837 | 882 | if ($_REQUEST['qaction'] == 'merge') |
| 838 | 883 | { |
| 839 | 884 | // Merge requires at least two topics. |
| 840 | - if (empty($_REQUEST['topics']) || count($_REQUEST['topics']) < 2) |
|
| 841 | - redirectexit($redirect_url); |
|
| 885 | + if (empty($_REQUEST['topics']) || count($_REQUEST['topics']) < 2) { |
|
| 886 | + redirectexit($redirect_url); |
|
| 887 | + } |
|
| 842 | 888 | |
| 843 | 889 | require_once($sourcedir . '/SplitTopics.php'); |
| 844 | 890 | return MergeExecute($_REQUEST['topics']); |
| 845 | 891 | } |
| 846 | 892 | |
| 847 | 893 | // Just convert to the other method, to make it easier. |
| 848 | - foreach ($_REQUEST['topics'] as $topic) |
|
| 849 | - $_REQUEST['actions'][(int) $topic] = $_REQUEST['qaction']; |
|
| 894 | + foreach ($_REQUEST['topics'] as $topic) { |
|
| 895 | + $_REQUEST['actions'][(int) $topic] = $_REQUEST['qaction']; |
|
| 896 | + } |
|
| 850 | 897 | } |
| 851 | 898 | |
| 852 | 899 | // Weird... how'd you get here? |
| 853 | - if (empty($_REQUEST['actions'])) |
|
| 854 | - redirectexit($redirect_url); |
|
| 900 | + if (empty($_REQUEST['actions'])) { |
|
| 901 | + redirectexit($redirect_url); |
|
| 902 | + } |
|
| 855 | 903 | |
| 856 | 904 | // Validate each action. |
| 857 | 905 | $temp = array(); |
| 858 | 906 | foreach ($_REQUEST['actions'] as $topic => $action) |
| 859 | 907 | { |
| 860 | - if (in_array($action, $possibleActions)) |
|
| 861 | - $temp[(int) $topic] = $action; |
|
| 908 | + if (in_array($action, $possibleActions)) { |
|
| 909 | + $temp[(int) $topic] = $action; |
|
| 910 | + } |
|
| 862 | 911 | } |
| 863 | 912 | $_REQUEST['actions'] = $temp; |
| 864 | 913 | |
@@ -879,27 +928,31 @@ discard block |
||
| 879 | 928 | { |
| 880 | 929 | if (!empty($board)) |
| 881 | 930 | { |
| 882 | - if ($row['id_board'] != $board || ($modSettings['postmod_active'] && !$row['approved'] && !allowedTo('approve_posts'))) |
|
| 883 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 884 | - } |
|
| 885 | - else |
|
| 931 | + if ($row['id_board'] != $board || ($modSettings['postmod_active'] && !$row['approved'] && !allowedTo('approve_posts'))) { |
|
| 932 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 933 | + } |
|
| 934 | + } else |
|
| 886 | 935 | { |
| 887 | 936 | // Don't allow them to act on unapproved posts they can't see... |
| 888 | - if ($modSettings['postmod_active'] && !$row['approved'] && !in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])) |
|
| 889 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 937 | + if ($modSettings['postmod_active'] && !$row['approved'] && !in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])) { |
|
| 938 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 939 | + } |
|
| 890 | 940 | // Goodness, this is fun. We need to validate the action. |
| 891 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'sticky' && !in_array(0, $boards_can['make_sticky']) && !in_array($row['id_board'], $boards_can['make_sticky'])) |
|
| 892 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 893 | - 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'])))) |
|
| 894 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 895 | - 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'])))) |
|
| 896 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 941 | + elseif ($_REQUEST['actions'][$row['id_topic']] == 'sticky' && !in_array(0, $boards_can['make_sticky']) && !in_array($row['id_board'], $boards_can['make_sticky'])) { |
|
| 942 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 943 | + } 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'])))) { |
|
| 944 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 945 | + } 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'])))) { |
|
| 946 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 947 | + } |
|
| 897 | 948 | // @todo $locked is not set, what are you trying to do? (taking the change it is supposed to be $row['locked']) |
| 898 | - 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'])))) |
|
| 899 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 949 | + 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'])))) { |
|
| 950 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 951 | + } |
|
| 900 | 952 | // If the topic is approved then you need permission to approve the posts within. |
| 901 | - 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'])))) |
|
| 902 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 953 | + 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'])))) { |
|
| 954 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 955 | + } |
|
| 903 | 956 | } |
| 904 | 957 | } |
| 905 | 958 | $smcFunc['db_free_result']($request); |
@@ -917,11 +970,11 @@ discard block |
||
| 917 | 970 | { |
| 918 | 971 | $topic = (int) $topic; |
| 919 | 972 | |
| 920 | - if ($action == 'markread') |
|
| 921 | - $markCache[] = $topic; |
|
| 922 | - elseif ($action == 'sticky') |
|
| 923 | - $stickyCache[] = $topic; |
|
| 924 | - elseif ($action == 'move') |
|
| 973 | + if ($action == 'markread') { |
|
| 974 | + $markCache[] = $topic; |
|
| 975 | + } elseif ($action == 'sticky') { |
|
| 976 | + $stickyCache[] = $topic; |
|
| 977 | + } elseif ($action == 'move') |
|
| 925 | 978 | { |
| 926 | 979 | require_once($sourcedir . '/MoveTopic.php'); |
| 927 | 980 | moveTopicConcurrence(); |
@@ -929,23 +982,25 @@ discard block |
||
| 929 | 982 | // $moveCache[0] is the topic, $moveCache[1] is the board to move to. |
| 930 | 983 | $moveCache[1][$topic] = (int) (isset($_REQUEST['move_tos'][$topic]) ? $_REQUEST['move_tos'][$topic] : $_REQUEST['move_to']); |
| 931 | 984 | |
| 932 | - if (empty($moveCache[1][$topic])) |
|
| 933 | - continue; |
|
| 985 | + if (empty($moveCache[1][$topic])) { |
|
| 986 | + continue; |
|
| 987 | + } |
|
| 934 | 988 | |
| 935 | 989 | $moveCache[0][] = $topic; |
| 990 | + } elseif ($action == 'remove') { |
|
| 991 | + $removeCache[] = $topic; |
|
| 992 | + } elseif ($action == 'lock') { |
|
| 993 | + $lockCache[] = $topic; |
|
| 994 | + } elseif ($action == 'approve') { |
|
| 995 | + $approveCache[] = $topic; |
|
| 936 | 996 | } |
| 937 | - elseif ($action == 'remove') |
|
| 938 | - $removeCache[] = $topic; |
|
| 939 | - elseif ($action == 'lock') |
|
| 940 | - $lockCache[] = $topic; |
|
| 941 | - elseif ($action == 'approve') |
|
| 942 | - $approveCache[] = $topic; |
|
| 943 | 997 | } |
| 944 | 998 | |
| 945 | - if (empty($board)) |
|
| 946 | - $affectedBoards = array(); |
|
| 947 | - else |
|
| 948 | - $affectedBoards = array($board => array(0, 0)); |
|
| 999 | + if (empty($board)) { |
|
| 1000 | + $affectedBoards = array(); |
|
| 1001 | + } else { |
|
| 1002 | + $affectedBoards = array($board => array(0, 0)); |
|
| 1003 | + } |
|
| 949 | 1004 | |
| 950 | 1005 | // Do all the stickies... |
| 951 | 1006 | if (!empty($stickyCache)) |
@@ -1005,14 +1060,16 @@ discard block |
||
| 1005 | 1060 | { |
| 1006 | 1061 | $to = $moveCache[1][$row['id_topic']]; |
| 1007 | 1062 | |
| 1008 | - if (empty($to)) |
|
| 1009 | - continue; |
|
| 1063 | + if (empty($to)) { |
|
| 1064 | + continue; |
|
| 1065 | + } |
|
| 1010 | 1066 | |
| 1011 | 1067 | // Does this topic's board count the posts or not? |
| 1012 | 1068 | $countPosts[$row['id_topic']] = empty($row['count_posts']); |
| 1013 | 1069 | |
| 1014 | - if (!isset($moveTos[$to])) |
|
| 1015 | - $moveTos[$to] = array(); |
|
| 1070 | + if (!isset($moveTos[$to])) { |
|
| 1071 | + $moveTos[$to] = array(); |
|
| 1072 | + } |
|
| 1016 | 1073 | |
| 1017 | 1074 | $moveTos[$to][] = $row['id_topic']; |
| 1018 | 1075 | |
@@ -1026,8 +1083,9 @@ discard block |
||
| 1026 | 1083 | require_once($sourcedir . '/MoveTopic.php'); |
| 1027 | 1084 | |
| 1028 | 1085 | // Do the actual moves... |
| 1029 | - foreach ($moveTos as $to => $topics) |
|
| 1030 | - moveTopics($topics, $to); |
|
| 1086 | + foreach ($moveTos as $to => $topics) { |
|
| 1087 | + moveTopics($topics, $to); |
|
| 1088 | + } |
|
| 1031 | 1089 | |
| 1032 | 1090 | // Does the post counts need to be updated? |
| 1033 | 1091 | if (!empty($moveTos)) |
@@ -1076,20 +1134,23 @@ discard block |
||
| 1076 | 1134 | |
| 1077 | 1135 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1078 | 1136 | { |
| 1079 | - if (!isset($members[$row['id_member']])) |
|
| 1080 | - $members[$row['id_member']] = 0; |
|
| 1137 | + if (!isset($members[$row['id_member']])) { |
|
| 1138 | + $members[$row['id_member']] = 0; |
|
| 1139 | + } |
|
| 1081 | 1140 | |
| 1082 | - if ($topicRecounts[$row['id_topic']] === '+') |
|
| 1083 | - $members[$row['id_member']] += 1; |
|
| 1084 | - else |
|
| 1085 | - $members[$row['id_member']] -= 1; |
|
| 1141 | + if ($topicRecounts[$row['id_topic']] === '+') { |
|
| 1142 | + $members[$row['id_member']] += 1; |
|
| 1143 | + } else { |
|
| 1144 | + $members[$row['id_member']] -= 1; |
|
| 1145 | + } |
|
| 1086 | 1146 | } |
| 1087 | 1147 | |
| 1088 | 1148 | $smcFunc['db_free_result']($request); |
| 1089 | 1149 | |
| 1090 | 1150 | // And now update them member's post counts |
| 1091 | - foreach ($members as $id_member => $post_adj) |
|
| 1092 | - updateMemberData($id_member, array('posts' => 'posts + ' . $post_adj)); |
|
| 1151 | + foreach ($members as $id_member => $post_adj) { |
|
| 1152 | + updateMemberData($id_member, array('posts' => 'posts + ' . $post_adj)); |
|
| 1153 | + } |
|
| 1093 | 1154 | } |
| 1094 | 1155 | } |
| 1095 | 1156 | } |
@@ -1168,8 +1229,9 @@ discard block |
||
| 1168 | 1229 | approveTopics($approveCache); |
| 1169 | 1230 | |
| 1170 | 1231 | // Time for some logging! |
| 1171 | - foreach ($approveCache as $topic) |
|
| 1172 | - logAction('approve_topic', array('topic' => $topic, 'member' => $approveCacheMembers[$topic])); |
|
| 1232 | + foreach ($approveCache as $topic) { |
|
| 1233 | + logAction('approve_topic', array('topic' => $topic, 'member' => $approveCacheMembers[$topic])); |
|
| 1234 | + } |
|
| 1173 | 1235 | } |
| 1174 | 1236 | } |
| 1175 | 1237 | |
@@ -1204,8 +1266,7 @@ discard block |
||
| 1204 | 1266 | $lockStatus[$row['id_topic']] = empty($row['locked']); |
| 1205 | 1267 | } |
| 1206 | 1268 | $smcFunc['db_free_result']($result); |
| 1207 | - } |
|
| 1208 | - else |
|
| 1269 | + } else |
|
| 1209 | 1270 | { |
| 1210 | 1271 | $result = $smcFunc['db_query']('', ' |
| 1211 | 1272 | SELECT id_topic, locked, id_board |
@@ -1255,13 +1316,15 @@ discard block |
||
| 1255 | 1316 | ) |
| 1256 | 1317 | ); |
| 1257 | 1318 | $logged_topics = array(); |
| 1258 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1259 | - $logged_topics[$row['id_topic']] = $row['unwatched']; |
|
| 1319 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1320 | + $logged_topics[$row['id_topic']] = $row['unwatched']; |
|
| 1321 | + } |
|
| 1260 | 1322 | $smcFunc['db_free_result']($request); |
| 1261 | 1323 | |
| 1262 | 1324 | $markArray = array(); |
| 1263 | - foreach ($markCache as $topic) |
|
| 1264 | - $markArray[] = array($modSettings['maxMsgID'], $user_info['id'], $topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0)); |
|
| 1325 | + foreach ($markCache as $topic) { |
|
| 1326 | + $markArray[] = array($modSettings['maxMsgID'], $user_info['id'], $topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0)); |
|
| 1327 | + } |
|
| 1265 | 1328 | |
| 1266 | 1329 | $smcFunc['db_insert']('replace', |
| 1267 | 1330 | '{db_prefix}log_topics', |
@@ -1274,8 +1337,9 @@ discard block |
||
| 1274 | 1337 | foreach ($moveCache as $topic) |
| 1275 | 1338 | { |
| 1276 | 1339 | // Didn't actually move anything! |
| 1277 | - if (!isset($topic[0])) |
|
| 1278 | - break; |
|
| 1340 | + if (!isset($topic[0])) { |
|
| 1341 | + break; |
|
| 1342 | + } |
|
| 1279 | 1343 | |
| 1280 | 1344 | logAction('move', array('topic' => $topic[0], 'board_from' => $topic[1], 'board_to' => $topic[2])); |
| 1281 | 1345 | sendNotifications($topic[0], 'move'); |
@@ -1297,8 +1361,9 @@ discard block |
||
| 1297 | 1361 | 'calendar_updated' => time(), |
| 1298 | 1362 | )); |
| 1299 | 1363 | |
| 1300 | - if (!empty($affectedBoards)) |
|
| 1301 | - updateLastMessages(array_keys($affectedBoards)); |
|
| 1364 | + if (!empty($affectedBoards)) { |
|
| 1365 | + updateLastMessages(array_keys($affectedBoards)); |
|
| 1366 | + } |
|
| 1302 | 1367 | |
| 1303 | 1368 | redirectexit($redirect_url); |
| 1304 | 1369 | } |