@@ -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 | * Mark a board or multiple boards read. |
@@ -28,14 +29,16 @@ discard block |
||
28 | 29 | global $user_info, $modSettings, $smcFunc; |
29 | 30 | |
30 | 31 | // Force $boards to be an array. |
31 | - if (!is_array($boards)) |
|
32 | - $boards = array($boards); |
|
33 | - else |
|
34 | - $boards = array_unique($boards); |
|
32 | + if (!is_array($boards)) { |
|
33 | + $boards = array($boards); |
|
34 | + } else { |
|
35 | + $boards = array_unique($boards); |
|
36 | + } |
|
35 | 37 | |
36 | 38 | // No boards, nothing to mark as read. |
37 | - if (empty($boards)) |
|
38 | - return; |
|
39 | + if (empty($boards)) { |
|
40 | + return; |
|
41 | + } |
|
39 | 42 | |
40 | 43 | // Allow the user to mark a board as unread. |
41 | 44 | if ($unread) |
@@ -65,8 +68,9 @@ discard block |
||
65 | 68 | else |
66 | 69 | { |
67 | 70 | $markRead = array(); |
68 | - foreach ($boards as $board) |
|
69 | - $markRead[] = array($modSettings['maxMsgID'], $user_info['id'], $board); |
|
71 | + foreach ($boards as $board) { |
|
72 | + $markRead[] = array($modSettings['maxMsgID'], $user_info['id'], $board); |
|
73 | + } |
|
70 | 74 | |
71 | 75 | // Update log_mark_read and log_boards. |
72 | 76 | $smcFunc['db_insert']('replace', |
@@ -99,8 +103,9 @@ discard block |
||
99 | 103 | list ($lowest_topic) = $smcFunc['db_fetch_row']($result); |
100 | 104 | $smcFunc['db_free_result']($result); |
101 | 105 | |
102 | - if (empty($lowest_topic)) |
|
103 | - return; |
|
106 | + if (empty($lowest_topic)) { |
|
107 | + return; |
|
108 | + } |
|
104 | 109 | |
105 | 110 | // @todo SLOW This query seems to eat it sometimes. |
106 | 111 | $result = $smcFunc['db_query']('', ' |
@@ -118,12 +123,13 @@ discard block |
||
118 | 123 | ) |
119 | 124 | ); |
120 | 125 | $topics = array(); |
121 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
122 | - $topics[] = $row['id_topic']; |
|
126 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
127 | + $topics[] = $row['id_topic']; |
|
128 | + } |
|
123 | 129 | $smcFunc['db_free_result']($result); |
124 | 130 | |
125 | - if (!empty($topics)) |
|
126 | - $smcFunc['db_query']('', ' |
|
131 | + if (!empty($topics)) { |
|
132 | + $smcFunc['db_query']('', ' |
|
127 | 133 | DELETE FROM {db_prefix}log_topics |
128 | 134 | WHERE id_member = {int:current_member} |
129 | 135 | AND id_topic IN ({array_int:topic_list})', |
@@ -132,7 +138,8 @@ discard block |
||
132 | 138 | 'topic_list' => $topics, |
133 | 139 | ) |
134 | 140 | ); |
135 | -} |
|
141 | + } |
|
142 | + } |
|
136 | 143 | |
137 | 144 | /** |
138 | 145 | * Mark one or more boards as read. |
@@ -157,23 +164,26 @@ discard block |
||
157 | 164 | ) |
158 | 165 | ); |
159 | 166 | $boards = array(); |
160 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
161 | - $boards[] = $row['id_board']; |
|
167 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
168 | + $boards[] = $row['id_board']; |
|
169 | + } |
|
162 | 170 | $smcFunc['db_free_result']($result); |
163 | 171 | |
164 | - if (!empty($boards)) |
|
165 | - markBoardsRead($boards, isset($_REQUEST['unread'])); |
|
172 | + if (!empty($boards)) { |
|
173 | + markBoardsRead($boards, isset($_REQUEST['unread'])); |
|
174 | + } |
|
166 | 175 | |
167 | 176 | $_SESSION['id_msg_last_visit'] = $modSettings['maxMsgID']; |
168 | - if (!empty($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'action=unread') !== false) |
|
169 | - redirectexit('action=unread'); |
|
177 | + if (!empty($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'action=unread') !== false) { |
|
178 | + redirectexit('action=unread'); |
|
179 | + } |
|
170 | 180 | |
171 | - if (isset($_SESSION['topicseen_cache'])) |
|
172 | - $_SESSION['topicseen_cache'] = array(); |
|
181 | + if (isset($_SESSION['topicseen_cache'])) { |
|
182 | + $_SESSION['topicseen_cache'] = array(); |
|
183 | + } |
|
173 | 184 | |
174 | 185 | redirectexit(); |
175 | - } |
|
176 | - elseif (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'unreadreplies') |
|
186 | + } elseif (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'unreadreplies') |
|
177 | 187 | { |
178 | 188 | // Make sure all the topics are integers! |
179 | 189 | $topics = array_map('intval', explode('-', $_REQUEST['topics'])); |
@@ -189,13 +199,15 @@ discard block |
||
189 | 199 | ) |
190 | 200 | ); |
191 | 201 | $logged_topics = array(); |
192 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
193 | - $logged_topics[$row['id_topic']] = $row['unwatched']; |
|
202 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
203 | + $logged_topics[$row['id_topic']] = $row['unwatched']; |
|
204 | + } |
|
194 | 205 | $smcFunc['db_free_result']($request); |
195 | 206 | |
196 | 207 | $markRead = array(); |
197 | - foreach ($topics as $id_topic) |
|
198 | - $markRead[] = array($modSettings['maxMsgID'], $user_info['id'], $id_topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0)); |
|
208 | + foreach ($topics as $id_topic) { |
|
209 | + $markRead[] = array($modSettings['maxMsgID'], $user_info['id'], $id_topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0)); |
|
210 | + } |
|
199 | 211 | |
200 | 212 | $smcFunc['db_insert']('replace', |
201 | 213 | '{db_prefix}log_topics', |
@@ -204,8 +216,9 @@ discard block |
||
204 | 216 | array('id_member', 'id_topic') |
205 | 217 | ); |
206 | 218 | |
207 | - if (isset($_SESSION['topicseen_cache'])) |
|
208 | - $_SESSION['topicseen_cache'] = array(); |
|
219 | + if (isset($_SESSION['topicseen_cache'])) { |
|
220 | + $_SESSION['topicseen_cache'] = array(); |
|
221 | + } |
|
209 | 222 | |
210 | 223 | redirectexit('action=unreadreplies'); |
211 | 224 | } |
@@ -230,11 +243,13 @@ discard block |
||
230 | 243 | if (!empty($_GET['t'])) |
231 | 244 | { |
232 | 245 | // If they read the whole topic, go back to the beginning. |
233 | - if ($_GET['t'] >= $topicinfo['id_last_msg']) |
|
234 | - $earlyMsg = 0; |
|
246 | + if ($_GET['t'] >= $topicinfo['id_last_msg']) { |
|
247 | + $earlyMsg = 0; |
|
248 | + } |
|
235 | 249 | // If they want to mark the whole thing read, same. |
236 | - elseif ($_GET['t'] <= $topicinfo['id_first_msg']) |
|
237 | - $earlyMsg = 0; |
|
250 | + elseif ($_GET['t'] <= $topicinfo['id_first_msg']) { |
|
251 | + $earlyMsg = 0; |
|
252 | + } |
|
238 | 253 | // Otherwise, get the latest message before the named one. |
239 | 254 | else |
240 | 255 | { |
@@ -255,9 +270,9 @@ discard block |
||
255 | 270 | } |
256 | 271 | } |
257 | 272 | // Marking read from first page? That's the whole topic. |
258 | - elseif ($_REQUEST['start'] == 0) |
|
259 | - $earlyMsg = 0; |
|
260 | - else |
|
273 | + elseif ($_REQUEST['start'] == 0) { |
|
274 | + $earlyMsg = 0; |
|
275 | + } else |
|
261 | 276 | { |
262 | 277 | $result = $smcFunc['db_query']('', ' |
263 | 278 | SELECT id_msg |
@@ -285,8 +300,7 @@ discard block |
||
285 | 300 | ); |
286 | 301 | |
287 | 302 | redirectexit('board=' . $board . '.0'); |
288 | - } |
|
289 | - else |
|
303 | + } else |
|
290 | 304 | { |
291 | 305 | $categories = array(); |
292 | 306 | $boards = array(); |
@@ -294,17 +308,20 @@ discard block |
||
294 | 308 | if (isset($_REQUEST['c'])) |
295 | 309 | { |
296 | 310 | $_REQUEST['c'] = explode(',', $_REQUEST['c']); |
297 | - foreach ($_REQUEST['c'] as $c) |
|
298 | - $categories[] = (int) $c; |
|
311 | + foreach ($_REQUEST['c'] as $c) { |
|
312 | + $categories[] = (int) $c; |
|
313 | + } |
|
299 | 314 | } |
300 | 315 | if (isset($_REQUEST['boards'])) |
301 | 316 | { |
302 | 317 | $_REQUEST['boards'] = explode(',', $_REQUEST['boards']); |
303 | - foreach ($_REQUEST['boards'] as $b) |
|
304 | - $boards[] = (int) $b; |
|
318 | + foreach ($_REQUEST['boards'] as $b) { |
|
319 | + $boards[] = (int) $b; |
|
320 | + } |
|
321 | + } |
|
322 | + if (!empty($board)) { |
|
323 | + $boards[] = (int) $board; |
|
305 | 324 | } |
306 | - if (!empty($board)) |
|
307 | - $boards[] = (int) $board; |
|
308 | 325 | |
309 | 326 | if (isset($_REQUEST['children']) && !empty($boards)) |
310 | 327 | { |
@@ -324,9 +341,10 @@ discard block |
||
324 | 341 | 'board_list' => $boards, |
325 | 342 | ) |
326 | 343 | ); |
327 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
328 | - if (in_array($row['id_parent'], $boards)) |
|
344 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
345 | + if (in_array($row['id_parent'], $boards)) |
|
329 | 346 | $boards[] = $row['id_board']; |
347 | + } |
|
330 | 348 | $smcFunc['db_free_result']($request); |
331 | 349 | } |
332 | 350 | |
@@ -343,8 +361,9 @@ discard block |
||
343 | 361 | $clauseParameters['board_list'] = $boards; |
344 | 362 | } |
345 | 363 | |
346 | - if (empty($clauses)) |
|
347 | - redirectexit(); |
|
364 | + if (empty($clauses)) { |
|
365 | + redirectexit(); |
|
366 | + } |
|
348 | 367 | |
349 | 368 | $request = $smcFunc['db_query']('', ' |
350 | 369 | SELECT b.id_board |
@@ -355,19 +374,22 @@ discard block |
||
355 | 374 | )) |
356 | 375 | ); |
357 | 376 | $boards = array(); |
358 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
359 | - $boards[] = $row['id_board']; |
|
377 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
378 | + $boards[] = $row['id_board']; |
|
379 | + } |
|
360 | 380 | $smcFunc['db_free_result']($request); |
361 | 381 | |
362 | - if (empty($boards)) |
|
363 | - redirectexit(); |
|
382 | + if (empty($boards)) { |
|
383 | + redirectexit(); |
|
384 | + } |
|
364 | 385 | |
365 | 386 | markBoardsRead($boards, isset($_REQUEST['unread'])); |
366 | 387 | |
367 | 388 | foreach ($boards as $b) |
368 | 389 | { |
369 | - if (isset($_SESSION['topicseen_cache'][$b])) |
|
370 | - $_SESSION['topicseen_cache'][$b] = array(); |
|
390 | + if (isset($_SESSION['topicseen_cache'][$b])) { |
|
391 | + $_SESSION['topicseen_cache'][$b] = array(); |
|
392 | + } |
|
371 | 393 | } |
372 | 394 | |
373 | 395 | if (!isset($_REQUEST['unread'])) |
@@ -385,8 +407,9 @@ discard block |
||
385 | 407 | if ($smcFunc['db_num_rows']($result) > 0) |
386 | 408 | { |
387 | 409 | $logBoardInserts = array(); |
388 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
389 | - $logBoardInserts[] = array($modSettings['maxMsgID'], $user_info['id'], $row['id_board']); |
|
410 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
411 | + $logBoardInserts[] = array($modSettings['maxMsgID'], $user_info['id'], $row['id_board']); |
|
412 | + } |
|
390 | 413 | |
391 | 414 | $smcFunc['db_insert']('replace', |
392 | 415 | '{db_prefix}log_boards', |
@@ -397,17 +420,18 @@ discard block |
||
397 | 420 | } |
398 | 421 | $smcFunc['db_free_result']($result); |
399 | 422 | |
400 | - if (empty($board)) |
|
401 | - redirectexit(); |
|
402 | - else |
|
403 | - redirectexit('board=' . $board . '.0'); |
|
404 | - } |
|
405 | - else |
|
423 | + if (empty($board)) { |
|
424 | + redirectexit(); |
|
425 | + } else { |
|
426 | + redirectexit('board=' . $board . '.0'); |
|
427 | + } |
|
428 | + } else |
|
406 | 429 | { |
407 | - if (empty($board_info['parent'])) |
|
408 | - redirectexit(); |
|
409 | - else |
|
410 | - redirectexit('board=' . $board_info['parent'] . '.0'); |
|
430 | + if (empty($board_info['parent'])) { |
|
431 | + redirectexit(); |
|
432 | + } else { |
|
433 | + redirectexit('board=' . $board_info['parent'] . '.0'); |
|
434 | + } |
|
411 | 435 | } |
412 | 436 | } |
413 | 437 | } |
@@ -432,11 +456,13 @@ discard block |
||
432 | 456 | 'selected_message' => (int) $messageID, |
433 | 457 | ) |
434 | 458 | ); |
435 | - if ($smcFunc['db_num_rows']($result) > 0) |
|
436 | - list ($memberID) = $smcFunc['db_fetch_row']($result); |
|
459 | + if ($smcFunc['db_num_rows']($result) > 0) { |
|
460 | + list ($memberID) = $smcFunc['db_fetch_row']($result); |
|
461 | + } |
|
437 | 462 | // The message doesn't even exist. |
438 | - else |
|
439 | - $memberID = 0; |
|
463 | + else { |
|
464 | + $memberID = 0; |
|
465 | + } |
|
440 | 466 | $smcFunc['db_free_result']($result); |
441 | 467 | |
442 | 468 | return (int) $memberID; |
@@ -457,8 +483,9 @@ discard block |
||
457 | 483 | getBoardTree(); |
458 | 484 | |
459 | 485 | // Make sure given boards and categories exist. |
460 | - if (!isset($boards[$board_id]) || (isset($boardOptions['target_board']) && !isset($boards[$boardOptions['target_board']])) || (isset($boardOptions['target_category']) && !isset($cat_tree[$boardOptions['target_category']]))) |
|
461 | - fatal_lang_error('no_board'); |
|
486 | + if (!isset($boards[$board_id]) || (isset($boardOptions['target_board']) && !isset($boards[$boardOptions['target_board']])) || (isset($boardOptions['target_category']) && !isset($cat_tree[$boardOptions['target_category']]))) { |
|
487 | + fatal_lang_error('no_board'); |
|
488 | + } |
|
462 | 489 | |
463 | 490 | $id = $board_id; |
464 | 491 | call_integration_hook('integrate_pre_modify_board', array($id, &$boardOptions)); |
@@ -486,8 +513,9 @@ discard block |
||
486 | 513 | $child_level = 0; |
487 | 514 | $id_parent = 0; |
488 | 515 | $after = 0; |
489 | - foreach ($cat_tree[$id_cat]['children'] as $id_board => $dummy) |
|
490 | - $after = max($after, $boards[$id_board]['order']); |
|
516 | + foreach ($cat_tree[$id_cat]['children'] as $id_board => $dummy) { |
|
517 | + $after = max($after, $boards[$id_board]['order']); |
|
518 | + } |
|
491 | 519 | } |
492 | 520 | |
493 | 521 | // Make the board a child of a given board. |
@@ -498,17 +526,19 @@ discard block |
||
498 | 526 | $id_parent = $boardOptions['target_board']; |
499 | 527 | |
500 | 528 | // People can be creative, in many ways... |
501 | - if (isChildOf($id_parent, $board_id)) |
|
502 | - fatal_lang_error('mboards_parent_own_child_error', false); |
|
503 | - elseif ($id_parent == $board_id) |
|
504 | - fatal_lang_error('mboards_board_own_child_error', false); |
|
529 | + if (isChildOf($id_parent, $board_id)) { |
|
530 | + fatal_lang_error('mboards_parent_own_child_error', false); |
|
531 | + } elseif ($id_parent == $board_id) { |
|
532 | + fatal_lang_error('mboards_board_own_child_error', false); |
|
533 | + } |
|
505 | 534 | |
506 | 535 | $after = $boards[$boardOptions['target_board']]['order']; |
507 | 536 | |
508 | 537 | // Check if there are already children and (if so) get the max board order. |
509 | - if (!empty($boards[$id_parent]['tree']['children']) && empty($boardOptions['move_first_child'])) |
|
510 | - foreach ($boards[$id_parent]['tree']['children'] as $childBoard_id => $dummy) |
|
538 | + if (!empty($boards[$id_parent]['tree']['children']) && empty($boardOptions['move_first_child'])) { |
|
539 | + foreach ($boards[$id_parent]['tree']['children'] as $childBoard_id => $dummy) |
|
511 | 540 | $after = max($after, $boards[$childBoard_id]['order']); |
541 | + } |
|
512 | 542 | } |
513 | 543 | |
514 | 544 | // Place a board before or after another board, on the same child level. |
@@ -521,8 +551,9 @@ discard block |
||
521 | 551 | } |
522 | 552 | |
523 | 553 | // Oops...? |
524 | - else |
|
525 | - trigger_error('modifyBoard(): The move_to value \'' . $boardOptions['move_to'] . '\' is incorrect', E_USER_ERROR); |
|
554 | + else { |
|
555 | + trigger_error('modifyBoard(): The move_to value \'' . $boardOptions['move_to'] . '\' is incorrect', E_USER_ERROR); |
|
556 | + } |
|
526 | 557 | |
527 | 558 | // Get a list of children of this board. |
528 | 559 | $childList = array(); |
@@ -531,14 +562,16 @@ discard block |
||
531 | 562 | // See if there are changes that affect children. |
532 | 563 | $childUpdates = array(); |
533 | 564 | $levelDiff = $child_level - $boards[$board_id]['level']; |
534 | - if ($levelDiff != 0) |
|
535 | - $childUpdates[] = 'child_level = child_level ' . ($levelDiff > 0 ? '+ ' : '') . '{int:level_diff}'; |
|
536 | - if ($id_cat != $boards[$board_id]['category']) |
|
537 | - $childUpdates[] = 'id_cat = {int:category}'; |
|
565 | + if ($levelDiff != 0) { |
|
566 | + $childUpdates[] = 'child_level = child_level ' . ($levelDiff > 0 ? '+ ' : '') . '{int:level_diff}'; |
|
567 | + } |
|
568 | + if ($id_cat != $boards[$board_id]['category']) { |
|
569 | + $childUpdates[] = 'id_cat = {int:category}'; |
|
570 | + } |
|
538 | 571 | |
539 | 572 | // Fix the children of this board. |
540 | - if (!empty($childList) && !empty($childUpdates)) |
|
541 | - $smcFunc['db_query']('', ' |
|
573 | + if (!empty($childList) && !empty($childUpdates)) { |
|
574 | + $smcFunc['db_query']('', ' |
|
542 | 575 | UPDATE {db_prefix}boards |
543 | 576 | SET ' . implode(', |
544 | 577 | ', $childUpdates) . ' |
@@ -549,6 +582,7 @@ discard block |
||
549 | 582 | 'level_diff' => $levelDiff, |
550 | 583 | ) |
551 | 584 | ); |
585 | + } |
|
552 | 586 | |
553 | 587 | // Make some room for this spot. |
554 | 588 | $smcFunc['db_query']('', ' |
@@ -644,8 +678,8 @@ discard block |
||
644 | 678 | call_integration_hook('integrate_modify_board', array($id, $boardOptions, &$boardUpdates, &$boardUpdateParameters)); |
645 | 679 | |
646 | 680 | // Do the updates (if any). |
647 | - if (!empty($boardUpdates)) |
|
648 | - $smcFunc['db_query']('', ' |
|
681 | + if (!empty($boardUpdates)) { |
|
682 | + $smcFunc['db_query']('', ' |
|
649 | 683 | UPDATE {db_prefix}boards |
650 | 684 | SET |
651 | 685 | ' . implode(', |
@@ -655,13 +689,15 @@ discard block |
||
655 | 689 | 'selected_board' => $board_id, |
656 | 690 | )) |
657 | 691 | ); |
692 | + } |
|
658 | 693 | |
659 | 694 | // Do permission sync |
660 | 695 | if (!empty($boardUpdateParameters['deny_groups'])) |
661 | 696 | { |
662 | 697 | $insert = array(); |
663 | - foreach($boardOptions['deny_groups'] as $value) |
|
664 | - $insert[] = array($value, $board_id, 1); |
|
698 | + foreach($boardOptions['deny_groups'] as $value) { |
|
699 | + $insert[] = array($value, $board_id, 1); |
|
700 | + } |
|
665 | 701 | |
666 | 702 | $smcFunc['db_query']('', ' |
667 | 703 | DELETE FROM {db_prefix}board_permissions_view |
@@ -681,8 +717,9 @@ discard block |
||
681 | 717 | if (!empty($boardUpdateParameters['member_groups'])) |
682 | 718 | { |
683 | 719 | $insert = array(); |
684 | - foreach($boardOptions['access_groups'] as $value) |
|
685 | - $insert[] = array($value, $board_id, 0); |
|
720 | + foreach($boardOptions['access_groups'] as $value) { |
|
721 | + $insert[] = array($value, $board_id, 0); |
|
722 | + } |
|
686 | 723 | $smcFunc['db_query']('', ' |
687 | 724 | DELETE FROM {db_prefix}board_permissions_view |
688 | 725 | WHERE id_board = {int:selected_board} AND deny = 0', |
@@ -722,13 +759,15 @@ discard block |
||
722 | 759 | { |
723 | 760 | $moderators[$k] = trim($moderators[$k]); |
724 | 761 | |
725 | - if (strlen($moderators[$k]) == 0) |
|
726 | - unset($moderators[$k]); |
|
762 | + if (strlen($moderators[$k]) == 0) { |
|
763 | + unset($moderators[$k]); |
|
764 | + } |
|
727 | 765 | } |
728 | 766 | |
729 | 767 | // Find all the id_member's for the member_name's in the list. |
730 | - if (empty($boardOptions['moderators'])) |
|
731 | - $boardOptions['moderators'] = array(); |
|
768 | + if (empty($boardOptions['moderators'])) { |
|
769 | + $boardOptions['moderators'] = array(); |
|
770 | + } |
|
732 | 771 | if (!empty($moderators)) |
733 | 772 | { |
734 | 773 | $request = $smcFunc['db_query']('', ' |
@@ -741,8 +780,9 @@ discard block |
||
741 | 780 | 'limit' => count($moderators), |
742 | 781 | ) |
743 | 782 | ); |
744 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
745 | - $boardOptions['moderators'][] = $row['id_member']; |
|
783 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
784 | + $boardOptions['moderators'][] = $row['id_member']; |
|
785 | + } |
|
746 | 786 | $smcFunc['db_free_result']($request); |
747 | 787 | } |
748 | 788 | } |
@@ -751,8 +791,9 @@ discard block |
||
751 | 791 | if (!empty($boardOptions['moderators'])) |
752 | 792 | { |
753 | 793 | $inserts = array(); |
754 | - foreach ($boardOptions['moderators'] as $moderator) |
|
755 | - $inserts[] = array($board_id, $moderator); |
|
794 | + foreach ($boardOptions['moderators'] as $moderator) { |
|
795 | + $inserts[] = array($board_id, $moderator); |
|
796 | + } |
|
756 | 797 | |
757 | 798 | $smcFunc['db_insert']('insert', |
758 | 799 | '{db_prefix}moderators', |
@@ -782,14 +823,16 @@ discard block |
||
782 | 823 | { |
783 | 824 | $moderator_groups[$k] = trim($moderator_groups[$k]); |
784 | 825 | |
785 | - if (strlen($moderator_groups[$k]) == 0) |
|
786 | - unset($moderator_groups[$k]); |
|
826 | + if (strlen($moderator_groups[$k]) == 0) { |
|
827 | + unset($moderator_groups[$k]); |
|
828 | + } |
|
787 | 829 | } |
788 | 830 | |
789 | 831 | /* Find all the id_group's for all the group names in the list |
790 | 832 | But skip any invalid ones (invisible/post groups/Administrator/Moderator) */ |
791 | - if (empty($boardOptions['moderator_groups'])) |
|
792 | - $boardOptions['moderator_groups'] = array(); |
|
833 | + if (empty($boardOptions['moderator_groups'])) { |
|
834 | + $boardOptions['moderator_groups'] = array(); |
|
835 | + } |
|
793 | 836 | if (!empty($moderator_groups)) |
794 | 837 | { |
795 | 838 | $request = $smcFunc['db_query']('', ' |
@@ -820,8 +863,9 @@ discard block |
||
820 | 863 | if (!empty($boardOptions['moderator_groups'])) |
821 | 864 | { |
822 | 865 | $inserts = array(); |
823 | - foreach ($boardOptions['moderator_groups'] as $moderator_group) |
|
824 | - $inserts[] = array($board_id, $moderator_group); |
|
866 | + foreach ($boardOptions['moderator_groups'] as $moderator_group) { |
|
867 | + $inserts[] = array($board_id, $moderator_group); |
|
868 | + } |
|
825 | 869 | |
826 | 870 | $smcFunc['db_insert']('insert', |
827 | 871 | '{db_prefix}moderator_groups', |
@@ -835,14 +879,16 @@ discard block |
||
835 | 879 | updateSettings(array('settings_updated' => time())); |
836 | 880 | } |
837 | 881 | |
838 | - if (isset($boardOptions['move_to'])) |
|
839 | - reorderBoards(); |
|
882 | + if (isset($boardOptions['move_to'])) { |
|
883 | + reorderBoards(); |
|
884 | + } |
|
840 | 885 | |
841 | 886 | clean_cache('data'); |
842 | 887 | |
843 | - if (empty($boardOptions['dont_log'])) |
|
844 | - logAction('edit_board', array('board' => $board_id), 'admin'); |
|
845 | -} |
|
888 | + if (empty($boardOptions['dont_log'])) { |
|
889 | + logAction('edit_board', array('board' => $board_id), 'admin'); |
|
890 | + } |
|
891 | + } |
|
846 | 892 | |
847 | 893 | /** |
848 | 894 | * Create a new board and set its properties and position. |
@@ -858,11 +904,13 @@ discard block |
||
858 | 904 | global $boards, $smcFunc; |
859 | 905 | |
860 | 906 | // Trigger an error if one of the required values is not set. |
861 | - if (!isset($boardOptions['board_name']) || trim($boardOptions['board_name']) == '' || !isset($boardOptions['move_to']) || !isset($boardOptions['target_category'])) |
|
862 | - trigger_error('createBoard(): One or more of the required options is not set', E_USER_ERROR); |
|
907 | + if (!isset($boardOptions['board_name']) || trim($boardOptions['board_name']) == '' || !isset($boardOptions['move_to']) || !isset($boardOptions['target_category'])) { |
|
908 | + trigger_error('createBoard(): One or more of the required options is not set', E_USER_ERROR); |
|
909 | + } |
|
863 | 910 | |
864 | - if (in_array($boardOptions['move_to'], array('child', 'before', 'after')) && !isset($boardOptions['target_board'])) |
|
865 | - trigger_error('createBoard(): Target board is not set', E_USER_ERROR); |
|
911 | + if (in_array($boardOptions['move_to'], array('child', 'before', 'after')) && !isset($boardOptions['target_board'])) { |
|
912 | + trigger_error('createBoard(): Target board is not set', E_USER_ERROR); |
|
913 | + } |
|
866 | 914 | |
867 | 915 | // Set every optional value to its default value. |
868 | 916 | $boardOptions += array( |
@@ -901,8 +949,9 @@ discard block |
||
901 | 949 | |
902 | 950 | $insert = array(); |
903 | 951 | |
904 | - foreach(explode(',', $default_memgrps) as $value) |
|
905 | - $insert[] = array($value, $board_id, 0); |
|
952 | + foreach(explode(',', $default_memgrps) as $value) { |
|
953 | + $insert[] = array($value, $board_id, 0); |
|
954 | + } |
|
906 | 955 | |
907 | 956 | $smcFunc['db_insert']('', |
908 | 957 | '{db_prefix}board_permissions_view', |
@@ -912,8 +961,9 @@ discard block |
||
912 | 961 | 1 |
913 | 962 | ); |
914 | 963 | |
915 | - if (empty($board_id)) |
|
916 | - return 0; |
|
964 | + if (empty($board_id)) { |
|
965 | + return 0; |
|
966 | + } |
|
917 | 967 | |
918 | 968 | // Change the board according to the given specifications. |
919 | 969 | modifyBoard($board_id, $boardOptions); |
@@ -976,8 +1026,9 @@ discard block |
||
976 | 1026 | global $sourcedir, $boards, $smcFunc; |
977 | 1027 | |
978 | 1028 | // No boards to delete? Return! |
979 | - if (empty($boards_to_remove)) |
|
980 | - return; |
|
1029 | + if (empty($boards_to_remove)) { |
|
1030 | + return; |
|
1031 | + } |
|
981 | 1032 | |
982 | 1033 | getBoardTree(); |
983 | 1034 | |
@@ -988,12 +1039,14 @@ discard block |
||
988 | 1039 | { |
989 | 1040 | // Get a list of the child boards that will also be removed. |
990 | 1041 | $child_boards_to_remove = array(); |
991 | - foreach ($boards_to_remove as $board_to_remove) |
|
992 | - recursiveBoards($child_boards_to_remove, $boards[$board_to_remove]['tree']); |
|
1042 | + foreach ($boards_to_remove as $board_to_remove) { |
|
1043 | + recursiveBoards($child_boards_to_remove, $boards[$board_to_remove]['tree']); |
|
1044 | + } |
|
993 | 1045 | |
994 | 1046 | // Merge the children with their parents. |
995 | - if (!empty($child_boards_to_remove)) |
|
996 | - $boards_to_remove = array_unique(array_merge($boards_to_remove, $child_boards_to_remove)); |
|
1047 | + if (!empty($child_boards_to_remove)) { |
|
1048 | + $boards_to_remove = array_unique(array_merge($boards_to_remove, $child_boards_to_remove)); |
|
1049 | + } |
|
997 | 1050 | } |
998 | 1051 | // Move the children to a safe home. |
999 | 1052 | else |
@@ -1001,10 +1054,11 @@ discard block |
||
1001 | 1054 | foreach ($boards_to_remove as $id_board) |
1002 | 1055 | { |
1003 | 1056 | // @todo Separate category? |
1004 | - if ($moveChildrenTo === 0) |
|
1005 | - fixChildren($id_board, 0, 0); |
|
1006 | - else |
|
1007 | - fixChildren($id_board, $boards[$moveChildrenTo]['level'] + 1, $moveChildrenTo); |
|
1057 | + if ($moveChildrenTo === 0) { |
|
1058 | + fixChildren($id_board, 0, 0); |
|
1059 | + } else { |
|
1060 | + fixChildren($id_board, $boards[$moveChildrenTo]['level'] + 1, $moveChildrenTo); |
|
1061 | + } |
|
1008 | 1062 | } |
1009 | 1063 | } |
1010 | 1064 | |
@@ -1018,8 +1072,9 @@ discard block |
||
1018 | 1072 | ) |
1019 | 1073 | ); |
1020 | 1074 | $topics = array(); |
1021 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1022 | - $topics[] = $row['id_topic']; |
|
1075 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1076 | + $topics[] = $row['id_topic']; |
|
1077 | + } |
|
1023 | 1078 | $smcFunc['db_free_result']($request); |
1024 | 1079 | |
1025 | 1080 | require_once($sourcedir . '/RemoveTopic.php'); |
@@ -1116,8 +1171,9 @@ discard block |
||
1116 | 1171 | clean_cache('data'); |
1117 | 1172 | |
1118 | 1173 | // Let's do some serious logging. |
1119 | - foreach ($boards_to_remove as $id_board) |
|
1120 | - logAction('delete_board', array('boardname' => $boards[$id_board]['name']), 'admin'); |
|
1174 | + foreach ($boards_to_remove as $id_board) { |
|
1175 | + logAction('delete_board', array('boardname' => $boards[$id_board]['name']), 'admin'); |
|
1176 | + } |
|
1121 | 1177 | |
1122 | 1178 | reorderBoards(); |
1123 | 1179 | } |
@@ -1136,8 +1192,8 @@ discard block |
||
1136 | 1192 | $board_order = 0; |
1137 | 1193 | foreach ($cat_tree as $catID => $dummy) |
1138 | 1194 | { |
1139 | - foreach ($boardList[$catID] as $boardID) |
|
1140 | - if ($boards[$boardID]['order'] != ++$board_order) |
|
1195 | + foreach ($boardList[$catID] as $boardID) { |
|
1196 | + if ($boards[$boardID]['order'] != ++$board_order) |
|
1141 | 1197 | $smcFunc['db_query']('', ' |
1142 | 1198 | UPDATE {db_prefix}boards |
1143 | 1199 | SET board_order = {int:new_order} |
@@ -1147,6 +1203,7 @@ discard block |
||
1147 | 1203 | 'selected_board' => $boardID, |
1148 | 1204 | ) |
1149 | 1205 | ); |
1206 | + } |
|
1150 | 1207 | } |
1151 | 1208 | |
1152 | 1209 | // Empty the board order cache |
@@ -1175,8 +1232,9 @@ discard block |
||
1175 | 1232 | ) |
1176 | 1233 | ); |
1177 | 1234 | $children = array(); |
1178 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
1179 | - $children[] = $row['id_board']; |
|
1235 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
1236 | + $children[] = $row['id_board']; |
|
1237 | + } |
|
1180 | 1238 | $smcFunc['db_free_result']($result); |
1181 | 1239 | |
1182 | 1240 | // ...and set it to a new parent and child_level. |
@@ -1192,9 +1250,10 @@ discard block |
||
1192 | 1250 | ); |
1193 | 1251 | |
1194 | 1252 | // Recursively fix the children of the children. |
1195 | - foreach ($children as $child) |
|
1196 | - fixChildren($child, $newLevel + 1, $child); |
|
1197 | -} |
|
1253 | + foreach ($children as $child) { |
|
1254 | + fixChildren($child, $newLevel + 1, $child); |
|
1255 | + } |
|
1256 | + } |
|
1198 | 1257 | |
1199 | 1258 | /** |
1200 | 1259 | * Tries to load up the entire board order and category very very quickly |
@@ -1211,8 +1270,9 @@ discard block |
||
1211 | 1270 | 'boards' => array(), |
1212 | 1271 | ); |
1213 | 1272 | |
1214 | - if (!empty($tree_order['boards'])) |
|
1215 | - return $tree_order; |
|
1273 | + if (!empty($tree_order['boards'])) { |
|
1274 | + return $tree_order; |
|
1275 | + } |
|
1216 | 1276 | |
1217 | 1277 | if (($cached = cache_get_data('board_order', 86400)) !== null) |
1218 | 1278 | { |
@@ -1228,8 +1288,9 @@ discard block |
||
1228 | 1288 | ); |
1229 | 1289 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1230 | 1290 | { |
1231 | - if (!in_array($row['id_cat'], $tree_order['cats'])) |
|
1232 | - $tree_order['cats'][] = $row['id_cat']; |
|
1291 | + if (!in_array($row['id_cat'], $tree_order['cats'])) { |
|
1292 | + $tree_order['cats'][] = $row['id_cat']; |
|
1293 | + } |
|
1233 | 1294 | $tree_order['boards'][] = $row['id_board']; |
1234 | 1295 | } |
1235 | 1296 | $smcFunc['db_free_result']($request); |
@@ -1249,16 +1310,19 @@ discard block |
||
1249 | 1310 | $tree = getTreeOrder(); |
1250 | 1311 | |
1251 | 1312 | $ordered = array(); |
1252 | - foreach ($tree['boards'] as $board) |
|
1253 | - if (!empty($boards[$board])) |
|
1313 | + foreach ($tree['boards'] as $board) { |
|
1314 | + if (!empty($boards[$board])) |
|
1254 | 1315 | { |
1255 | 1316 | $ordered[$board] = $boards[$board]; |
1317 | + } |
|
1256 | 1318 | |
1257 | - if (is_array($ordered[$board]) && !empty($ordered[$board]['boards'])) |
|
1258 | - sortBoards($ordered[$board]['boards']); |
|
1319 | + if (is_array($ordered[$board]) && !empty($ordered[$board]['boards'])) { |
|
1320 | + sortBoards($ordered[$board]['boards']); |
|
1321 | + } |
|
1259 | 1322 | |
1260 | - if (is_array($ordered[$board]) && !empty($ordered[$board]['children'])) |
|
1261 | - sortBoards($ordered[$board]['children']); |
|
1323 | + if (is_array($ordered[$board]) && !empty($ordered[$board]['children'])) { |
|
1324 | + sortBoards($ordered[$board]['children']); |
|
1325 | + } |
|
1262 | 1326 | } |
1263 | 1327 | |
1264 | 1328 | $boards = $ordered; |
@@ -1274,12 +1338,14 @@ discard block |
||
1274 | 1338 | $tree = getTreeOrder(); |
1275 | 1339 | |
1276 | 1340 | $ordered = array(); |
1277 | - foreach ($tree['cats'] as $cat) |
|
1278 | - if (!empty($categories[$cat])) |
|
1341 | + foreach ($tree['cats'] as $cat) { |
|
1342 | + if (!empty($categories[$cat])) |
|
1279 | 1343 | { |
1280 | 1344 | $ordered[$cat] = $categories[$cat]; |
1281 | - if (!empty($ordered[$cat]['boards'])) |
|
1282 | - sortBoards($ordered[$cat]['boards']); |
|
1345 | + } |
|
1346 | + if (!empty($ordered[$cat]['boards'])) { |
|
1347 | + sortBoards($ordered[$cat]['boards']); |
|
1348 | + } |
|
1283 | 1349 | } |
1284 | 1350 | |
1285 | 1351 | $categories = $ordered; |
@@ -1295,8 +1361,9 @@ discard block |
||
1295 | 1361 | { |
1296 | 1362 | global $smcFunc, $scripturl, $txt; |
1297 | 1363 | |
1298 | - if (empty($boards)) |
|
1299 | - return array(); |
|
1364 | + if (empty($boards)) { |
|
1365 | + return array(); |
|
1366 | + } |
|
1300 | 1367 | |
1301 | 1368 | $request = $smcFunc['db_query']('', ' |
1302 | 1369 | SELECT mem.id_member, mem.real_name, mo.id_board |
@@ -1310,8 +1377,9 @@ discard block |
||
1310 | 1377 | $moderators = array(); |
1311 | 1378 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1312 | 1379 | { |
1313 | - if (empty($moderators[$row['id_board']])) |
|
1314 | - $moderators[$row['id_board']] = array(); |
|
1380 | + if (empty($moderators[$row['id_board']])) { |
|
1381 | + $moderators[$row['id_board']] = array(); |
|
1382 | + } |
|
1315 | 1383 | |
1316 | 1384 | $moderators[$row['id_board']][] = array( |
1317 | 1385 | 'id' => $row['id_member'], |
@@ -1335,8 +1403,9 @@ discard block |
||
1335 | 1403 | { |
1336 | 1404 | global $smcFunc, $scripturl, $txt; |
1337 | 1405 | |
1338 | - if (empty($boards)) |
|
1339 | - return array(); |
|
1406 | + if (empty($boards)) { |
|
1407 | + return array(); |
|
1408 | + } |
|
1340 | 1409 | |
1341 | 1410 | $request = $smcFunc['db_query']('', ' |
1342 | 1411 | SELECT mg.id_group, mg.group_name, bg.id_board |
@@ -1350,8 +1419,9 @@ discard block |
||
1350 | 1419 | $groups = array(); |
1351 | 1420 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1352 | 1421 | { |
1353 | - if (empty($groups[$row['id_board']])) |
|
1354 | - $groups[$row['id_board']] = array(); |
|
1422 | + if (empty($groups[$row['id_board']])) { |
|
1423 | + $groups[$row['id_board']] = array(); |
|
1424 | + } |
|
1355 | 1425 | |
1356 | 1426 | $groups[$row['id_board']][] = array( |
1357 | 1427 | 'id' => $row['id_group'], |
@@ -1426,8 +1496,9 @@ discard block |
||
1426 | 1496 | |
1427 | 1497 | if (!empty($row['id_board'])) |
1428 | 1498 | { |
1429 | - if ($row['child_level'] != $curLevel) |
|
1430 | - $prevBoard = 0; |
|
1499 | + if ($row['child_level'] != $curLevel) { |
|
1500 | + $prevBoard = 0; |
|
1501 | + } |
|
1431 | 1502 | |
1432 | 1503 | $boards[$row['id_board']] = array( |
1433 | 1504 | 'id' => $row['id_board'], |
@@ -1459,16 +1530,16 @@ discard block |
||
1459 | 1530 | 'children' => array() |
1460 | 1531 | ); |
1461 | 1532 | $boards[$row['id_board']]['tree'] = &$cat_tree[$row['id_cat']]['children'][$row['id_board']]; |
1462 | - } |
|
1463 | - else |
|
1533 | + } else |
|
1464 | 1534 | { |
1465 | 1535 | // Parent doesn't exist! |
1466 | - if (!isset($boards[$row['id_parent']]['tree'])) |
|
1467 | - fatal_lang_error('no_valid_parent', false, array($row['board_name'])); |
|
1536 | + if (!isset($boards[$row['id_parent']]['tree'])) { |
|
1537 | + fatal_lang_error('no_valid_parent', false, array($row['board_name'])); |
|
1538 | + } |
|
1468 | 1539 | |
1469 | 1540 | // Wrong childlevel...we can silently fix this... |
1470 | - if ($boards[$row['id_parent']]['tree']['node']['level'] != $row['child_level'] - 1) |
|
1471 | - $smcFunc['db_query']('', ' |
|
1541 | + if ($boards[$row['id_parent']]['tree']['node']['level'] != $row['child_level'] - 1) { |
|
1542 | + $smcFunc['db_query']('', ' |
|
1472 | 1543 | UPDATE {db_prefix}boards |
1473 | 1544 | SET child_level = {int:new_child_level} |
1474 | 1545 | WHERE id_board = {int:selected_board}', |
@@ -1477,6 +1548,7 @@ discard block |
||
1477 | 1548 | 'selected_board' => $row['id_board'], |
1478 | 1549 | ) |
1479 | 1550 | ); |
1551 | + } |
|
1480 | 1552 | |
1481 | 1553 | $boards[$row['id_parent']]['tree']['children'][$row['id_board']] = array( |
1482 | 1554 | 'node' => &$boards[$row['id_board']], |
@@ -1510,8 +1582,9 @@ discard block |
||
1510 | 1582 | */ |
1511 | 1583 | function recursiveBoards(&$_boardList, &$_tree) |
1512 | 1584 | { |
1513 | - if (empty($_tree['children'])) |
|
1514 | - return; |
|
1585 | + if (empty($_tree['children'])) { |
|
1586 | + return; |
|
1587 | + } |
|
1515 | 1588 | |
1516 | 1589 | foreach ($_tree['children'] as $id => $node) |
1517 | 1590 | { |
@@ -1530,11 +1603,13 @@ discard block |
||
1530 | 1603 | { |
1531 | 1604 | global $boards; |
1532 | 1605 | |
1533 | - if (empty($boards[$child]['parent'])) |
|
1534 | - return false; |
|
1606 | + if (empty($boards[$child]['parent'])) { |
|
1607 | + return false; |
|
1608 | + } |
|
1535 | 1609 | |
1536 | - if ($boards[$child]['parent'] == $parent) |
|
1537 | - return true; |
|
1610 | + if ($boards[$child]['parent'] == $parent) { |
|
1611 | + return true; |
|
1612 | + } |
|
1538 | 1613 | |
1539 | 1614 | return isChildOf($boards[$child]['parent'], $parent); |
1540 | 1615 | } |
@@ -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 | * This helps organize things... |
@@ -37,13 +38,14 @@ discard block |
||
37 | 38 | |
38 | 39 | loadLanguage('PersonalMessage+Drafts'); |
39 | 40 | |
40 | - if (!isset($_REQUEST['xml'])) |
|
41 | - loadTemplate('PersonalMessage'); |
|
41 | + if (!isset($_REQUEST['xml'])) { |
|
42 | + loadTemplate('PersonalMessage'); |
|
43 | + } |
|
42 | 44 | |
43 | 45 | // Load up the members maximum message capacity. |
44 | - if ($user_info['is_admin']) |
|
45 | - $context['message_limit'] = 0; |
|
46 | - elseif (($context['message_limit'] = cache_get_data('msgLimit:' . $user_info['id'], 360)) === null) |
|
46 | + if ($user_info['is_admin']) { |
|
47 | + $context['message_limit'] = 0; |
|
48 | + } elseif (($context['message_limit'] = cache_get_data('msgLimit:' . $user_info['id'], 360)) === null) |
|
47 | 49 | { |
48 | 50 | // @todo Why do we do this? It seems like if they have any limit we should use it. |
49 | 51 | $request = $smcFunc['db_query']('', ' |
@@ -78,8 +80,9 @@ discard block |
||
78 | 80 | } |
79 | 81 | |
80 | 82 | // a previous message was sent successfully? show a small indication. |
81 | - if (isset($_GET['done']) && ($_GET['done'] == 'sent')) |
|
82 | - $context['pm_sent'] = true; |
|
83 | + if (isset($_GET['done']) && ($_GET['done'] == 'sent')) { |
|
84 | + $context['pm_sent'] = true; |
|
85 | + } |
|
83 | 86 | |
84 | 87 | $context['labels'] = array(); |
85 | 88 | |
@@ -210,11 +213,11 @@ discard block |
||
210 | 213 | { |
211 | 214 | $_REQUEST['sa'] = ''; |
212 | 215 | MessageFolder(); |
213 | - } |
|
214 | - else |
|
216 | + } else |
|
215 | 217 | { |
216 | - if (!isset($_REQUEST['xml']) && $_REQUEST['sa'] != 'popup') |
|
217 | - messageIndexBar($_REQUEST['sa']); |
|
218 | + if (!isset($_REQUEST['xml']) && $_REQUEST['sa'] != 'popup') { |
|
219 | + messageIndexBar($_REQUEST['sa']); |
|
220 | + } |
|
218 | 221 | |
219 | 222 | call_helper($subActions[$_REQUEST['sa']]); |
220 | 223 | } |
@@ -297,15 +300,16 @@ discard block |
||
297 | 300 | ); |
298 | 301 | |
299 | 302 | // Handle labels. |
300 | - if (empty($context['currently_using_labels'])) |
|
301 | - unset($pm_areas['labels']); |
|
302 | - else |
|
303 | + if (empty($context['currently_using_labels'])) { |
|
304 | + unset($pm_areas['labels']); |
|
305 | + } else |
|
303 | 306 | { |
304 | 307 | // Note we send labels by id as it will have less problems in the querystring. |
305 | 308 | foreach ($context['labels'] as $label) |
306 | 309 | { |
307 | - if ($label['id'] == -1) |
|
308 | - continue; |
|
310 | + if ($label['id'] == -1) { |
|
311 | + continue; |
|
312 | + } |
|
309 | 313 | |
310 | 314 | // Count the amount of unread items in labels. |
311 | 315 | $pm_areas['labels']['amt'] += $label['unread_messages']; |
@@ -356,8 +360,9 @@ discard block |
||
356 | 360 | unset($pm_areas); |
357 | 361 | |
358 | 362 | // No menu means no access. |
359 | - if (!$pm_include_data && (!$user_info['is_guest'] || validateSession())) |
|
360 | - fatal_lang_error('no_access', false); |
|
363 | + if (!$pm_include_data && (!$user_info['is_guest'] || validateSession())) { |
|
364 | + fatal_lang_error('no_access', false); |
|
365 | + } |
|
361 | 366 | |
362 | 367 | // Make a note of the Unique ID for this menu. |
363 | 368 | $context['pm_menu_id'] = $context['max_menu_id']; |
@@ -368,9 +373,10 @@ discard block |
||
368 | 373 | $context['menu_item_selected'] = $current_area; |
369 | 374 | |
370 | 375 | // Set the template for this area and add the profile layer. |
371 | - if (!isset($_REQUEST['xml'])) |
|
372 | - $context['template_layers'][] = 'pm'; |
|
373 | -} |
|
376 | + if (!isset($_REQUEST['xml'])) { |
|
377 | + $context['template_layers'][] = 'pm'; |
|
378 | + } |
|
379 | + } |
|
374 | 380 | |
375 | 381 | /** |
376 | 382 | * The popup for when we ask for the popup from the user. |
@@ -402,8 +408,9 @@ discard block |
||
402 | 408 | ) |
403 | 409 | ); |
404 | 410 | $pms = array(); |
405 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
406 | - $pms[] = $row[0]; |
|
411 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
412 | + $pms[] = $row[0]; |
|
413 | + } |
|
407 | 414 | $smcFunc['db_free_result']($request); |
408 | 415 | |
409 | 416 | if (!empty($pms)) |
@@ -431,8 +438,9 @@ discard block |
||
431 | 438 | ); |
432 | 439 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
433 | 440 | { |
434 | - if (!empty($row['id_member_from'])) |
|
435 | - $senders[] = $row['id_member_from']; |
|
441 | + if (!empty($row['id_member_from'])) { |
|
442 | + $senders[] = $row['id_member_from']; |
|
443 | + } |
|
436 | 444 | |
437 | 445 | $row['replied_to_you'] = $row['id_pm'] != $row['id_pm_head']; |
438 | 446 | $row['time'] = timeformat($row['timestamp']); |
@@ -442,13 +450,15 @@ discard block |
||
442 | 450 | $smcFunc['db_free_result']($request); |
443 | 451 | |
444 | 452 | $senders = loadMemberData($senders); |
445 | - foreach ($senders as $member) |
|
446 | - loadMemberContext($member); |
|
453 | + foreach ($senders as $member) { |
|
454 | + loadMemberContext($member); |
|
455 | + } |
|
447 | 456 | |
448 | 457 | // Having loaded everyone, attach them to the PMs. |
449 | - foreach ($context['unread_pms'] as $id_pm => $details) |
|
450 | - if (!empty($memberContext[$details['id_member_from']])) |
|
458 | + foreach ($context['unread_pms'] as $id_pm => $details) { |
|
459 | + if (!empty($memberContext[$details['id_member_from']])) |
|
451 | 460 | $context['unread_pms'][$id_pm]['member'] = &$memberContext[$details['id_member_from']]; |
461 | + } |
|
452 | 462 | } |
453 | 463 | } |
454 | 464 | |
@@ -468,12 +478,13 @@ discard block |
||
468 | 478 | } |
469 | 479 | |
470 | 480 | // Make sure the starting location is valid. |
471 | - if (isset($_GET['start']) && $_GET['start'] != 'new') |
|
472 | - $_GET['start'] = (int) $_GET['start']; |
|
473 | - elseif (!isset($_GET['start']) && !empty($options['view_newest_pm_first'])) |
|
474 | - $_GET['start'] = 0; |
|
475 | - else |
|
476 | - $_GET['start'] = 'new'; |
|
481 | + if (isset($_GET['start']) && $_GET['start'] != 'new') { |
|
482 | + $_GET['start'] = (int) $_GET['start']; |
|
483 | + } elseif (!isset($_GET['start']) && !empty($options['view_newest_pm_first'])) { |
|
484 | + $_GET['start'] = 0; |
|
485 | + } else { |
|
486 | + $_GET['start'] = 'new'; |
|
487 | + } |
|
477 | 488 | |
478 | 489 | // Set up some basic theme stuff. |
479 | 490 | $context['from_or_to'] = $context['folder'] != 'sent' ? 'from' : 'to'; |
@@ -487,9 +498,10 @@ discard block |
||
487 | 498 | list ($sig_limits, $sig_bbc) = explode(':', $modSettings['signature_settings']); |
488 | 499 | $sig_limits = explode(',', $sig_limits); |
489 | 500 | |
490 | - if (!empty($sig_limits[5]) || !empty($sig_limits[6])) |
|
491 | - addInlineCss(' |
|
501 | + if (!empty($sig_limits[5]) || !empty($sig_limits[6])) { |
|
502 | + addInlineCss(' |
|
492 | 503 | .signature img { ' . (!empty($sig_limits[5]) ? 'max-width: ' . (int) $sig_limits[5] . 'px; ' : '') . (!empty($sig_limits[6]) ? 'max-height: ' . (int) $sig_limits[6] . 'px; ' : '') . '}'); |
504 | + } |
|
493 | 505 | } |
494 | 506 | |
495 | 507 | $labelJoin = ''; |
@@ -501,8 +513,7 @@ discard block |
||
501 | 513 | { |
502 | 514 | $labelQuery = ' |
503 | 515 | AND pmr.in_inbox = 1'; |
504 | - } |
|
505 | - elseif ($context['folder'] != 'sent') |
|
516 | + } elseif ($context['folder'] != 'sent') |
|
506 | 517 | { |
507 | 518 | $labelJoin = ' |
508 | 519 | INNER JOIN {db_prefix}pm_labeled_messages AS pl ON (pl.id_pm = pmr.id_pm)'; |
@@ -544,22 +555,24 @@ discard block |
||
544 | 555 | $txt['delete_all'] = str_replace('PMBOX', $pmbox, $txt['delete_all']); |
545 | 556 | |
546 | 557 | // Now, build the link tree! |
547 | - if ($context['current_label_id'] == -1) |
|
548 | - $context['linktree'][] = array( |
|
558 | + if ($context['current_label_id'] == -1) { |
|
559 | + $context['linktree'][] = array( |
|
549 | 560 | 'url' => $scripturl . '?action=pm;f=' . $context['folder'], |
550 | 561 | 'name' => $pmbox |
551 | 562 | ); |
563 | + } |
|
552 | 564 | |
553 | 565 | // Build it further for a label. |
554 | - if ($context['current_label_id'] != -1) |
|
555 | - $context['linktree'][] = array( |
|
566 | + if ($context['current_label_id'] != -1) { |
|
567 | + $context['linktree'][] = array( |
|
556 | 568 | 'url' => $scripturl . '?action=pm;f=' . $context['folder'] . ';l=' . $context['current_label_id'], |
557 | 569 | 'name' => $txt['pm_current_label'] . ': ' . $context['current_label'] |
558 | 570 | ); |
571 | + } |
|
559 | 572 | |
560 | 573 | // Figure out how many messages there are. |
561 | - if ($context['folder'] == 'sent') |
|
562 | - $request = $smcFunc['db_query']('', ' |
|
574 | + if ($context['folder'] == 'sent') { |
|
575 | + $request = $smcFunc['db_query']('', ' |
|
563 | 576 | SELECT COUNT(' . ($context['display_mode'] == 2 ? 'DISTINCT pm.id_pm_head' : '*') . ') |
564 | 577 | FROM {db_prefix}personal_messages AS pm |
565 | 578 | WHERE pm.id_member_from = {int:current_member} |
@@ -569,8 +582,8 @@ discard block |
||
569 | 582 | 'not_deleted' => 0, |
570 | 583 | ) |
571 | 584 | ); |
572 | - else |
|
573 | - $request = $smcFunc['db_query']('', ' |
|
585 | + } else { |
|
586 | + $request = $smcFunc['db_query']('', ' |
|
574 | 587 | SELECT COUNT(' . ($context['display_mode'] == 2 ? 'DISTINCT pm.id_pm_head' : '*') . ') |
575 | 588 | FROM {db_prefix}pm_recipients AS pmr' . ($context['display_mode'] == 2 ? ' |
576 | 589 | INNER JOIN {db_prefix}personal_messages AS pm ON (pm.id_pm = pmr.id_pm)' : '') . $labelJoin . ' |
@@ -581,6 +594,7 @@ discard block |
||
581 | 594 | 'not_deleted' => 0, |
582 | 595 | ) |
583 | 596 | ); |
597 | + } |
|
584 | 598 | list ($max_messages) = $smcFunc['db_fetch_row']($request); |
585 | 599 | $smcFunc['db_free_result']($request); |
586 | 600 | |
@@ -589,10 +603,11 @@ discard block |
||
589 | 603 | $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages']; |
590 | 604 | |
591 | 605 | // Start on the last page. |
592 | - if (!is_numeric($_GET['start']) || $_GET['start'] >= $max_messages) |
|
593 | - $_GET['start'] = ($max_messages - 1) - (($max_messages - 1) % $maxPerPage); |
|
594 | - elseif ($_GET['start'] < 0) |
|
595 | - $_GET['start'] = 0; |
|
606 | + if (!is_numeric($_GET['start']) || $_GET['start'] >= $max_messages) { |
|
607 | + $_GET['start'] = ($max_messages - 1) - (($max_messages - 1) % $maxPerPage); |
|
608 | + } elseif ($_GET['start'] < 0) { |
|
609 | + $_GET['start'] = 0; |
|
610 | + } |
|
596 | 611 | |
597 | 612 | // ... but wait - what if we want to start from a specific message? |
598 | 613 | if (isset($_GET['pmid'])) |
@@ -600,19 +615,21 @@ discard block |
||
600 | 615 | $pmID = (int) $_GET['pmid']; |
601 | 616 | |
602 | 617 | // Make sure you have access to this PM. |
603 | - if (!isAccessiblePM($pmID, $context['folder'] == 'sent' ? 'outbox' : 'inbox')) |
|
604 | - fatal_lang_error('no_access', false); |
|
618 | + if (!isAccessiblePM($pmID, $context['folder'] == 'sent' ? 'outbox' : 'inbox')) { |
|
619 | + fatal_lang_error('no_access', false); |
|
620 | + } |
|
605 | 621 | |
606 | 622 | $context['current_pm'] = $pmID; |
607 | 623 | |
608 | 624 | // With only one page of PM's we're gonna want page 1. |
609 | - if ($max_messages <= $maxPerPage) |
|
610 | - $_GET['start'] = 0; |
|
625 | + if ($max_messages <= $maxPerPage) { |
|
626 | + $_GET['start'] = 0; |
|
627 | + } |
|
611 | 628 | // If we pass kstart we assume we're in the right place. |
612 | 629 | elseif (!isset($_GET['kstart'])) |
613 | 630 | { |
614 | - if ($context['folder'] == 'sent') |
|
615 | - $request = $smcFunc['db_query']('', ' |
|
631 | + if ($context['folder'] == 'sent') { |
|
632 | + $request = $smcFunc['db_query']('', ' |
|
616 | 633 | SELECT COUNT(' . ($context['display_mode'] == 2 ? 'DISTINCT pm.id_pm_head' : '*') . ') |
617 | 634 | FROM {db_prefix}personal_messages |
618 | 635 | WHERE id_member_from = {int:current_member} |
@@ -624,8 +641,8 @@ discard block |
||
624 | 641 | 'id_pm' => $pmID, |
625 | 642 | ) |
626 | 643 | ); |
627 | - else |
|
628 | - $request = $smcFunc['db_query']('', ' |
|
644 | + } else { |
|
645 | + $request = $smcFunc['db_query']('', ' |
|
629 | 646 | SELECT COUNT(' . ($context['display_mode'] == 2 ? 'DISTINCT pm.id_pm_head' : '*') . ') |
630 | 647 | FROM {db_prefix}pm_recipients AS pmr' . ($context['display_mode'] == 2 ? ' |
631 | 648 | INNER JOIN {db_prefix}personal_messages AS pm ON (pm.id_pm = pmr.id_pm)' : '') . $labelJoin . ' |
@@ -638,6 +655,7 @@ discard block |
||
638 | 655 | 'id_pm' => $pmID, |
639 | 656 | ) |
640 | 657 | ); |
658 | + } |
|
641 | 659 | |
642 | 660 | list ($_GET['start']) = $smcFunc['db_fetch_row']($request); |
643 | 661 | $smcFunc['db_free_result']($request); |
@@ -652,8 +670,9 @@ discard block |
||
652 | 670 | { |
653 | 671 | $pmsg = (int) $_GET['pmsg']; |
654 | 672 | |
655 | - if (!isAccessiblePM($pmsg, $context['folder'] == 'sent' ? 'outbox' : 'inbox')) |
|
656 | - fatal_lang_error('no_access', false); |
|
673 | + if (!isAccessiblePM($pmsg, $context['folder'] == 'sent' ? 'outbox' : 'inbox')) { |
|
674 | + fatal_lang_error('no_access', false); |
|
675 | + } |
|
657 | 676 | } |
658 | 677 | |
659 | 678 | // Set up the page index. |
@@ -747,8 +766,9 @@ discard block |
||
747 | 766 | { |
748 | 767 | if (!isset($recipients[$row['id_pm']])) |
749 | 768 | { |
750 | - if (isset($row['id_member_from'])) |
|
751 | - $posters[$row['id_pm']] = $row['id_member_from']; |
|
769 | + if (isset($row['id_member_from'])) { |
|
770 | + $posters[$row['id_pm']] = $row['id_member_from']; |
|
771 | + } |
|
752 | 772 | $pms[$row['id_pm']] = $row['id_pm']; |
753 | 773 | $recipients[$row['id_pm']] = array( |
754 | 774 | 'to' => array(), |
@@ -757,29 +777,33 @@ discard block |
||
757 | 777 | } |
758 | 778 | |
759 | 779 | // Keep track of the last message so we know what the head is without another query! |
760 | - if ((empty($pmID) && (empty($options['view_newest_pm_first']) || !isset($lastData))) || empty($lastData) || (!empty($pmID) && $pmID == $row['id_pm'])) |
|
761 | - $lastData = array( |
|
780 | + if ((empty($pmID) && (empty($options['view_newest_pm_first']) || !isset($lastData))) || empty($lastData) || (!empty($pmID) && $pmID == $row['id_pm'])) { |
|
781 | + $lastData = array( |
|
762 | 782 | 'id' => $row['id_pm'], |
763 | 783 | 'head' => $row['id_pm_head'], |
764 | 784 | ); |
785 | + } |
|
765 | 786 | } |
766 | 787 | $smcFunc['db_free_result']($request); |
767 | 788 | |
768 | 789 | // Make sure that we have been given a correct head pm id! |
769 | - if ($context['display_mode'] == 2 && !empty($pmID) && $pmID != $lastData['id']) |
|
770 | - fatal_lang_error('no_access', false); |
|
790 | + if ($context['display_mode'] == 2 && !empty($pmID) && $pmID != $lastData['id']) { |
|
791 | + fatal_lang_error('no_access', false); |
|
792 | + } |
|
771 | 793 | |
772 | 794 | if (!empty($pms)) |
773 | 795 | { |
774 | 796 | // Select the correct current message. |
775 | - if (empty($pmID)) |
|
776 | - $context['current_pm'] = $lastData['id']; |
|
797 | + if (empty($pmID)) { |
|
798 | + $context['current_pm'] = $lastData['id']; |
|
799 | + } |
|
777 | 800 | |
778 | 801 | // This is a list of the pm's that are used for "full" display. |
779 | - if ($context['display_mode'] == 0) |
|
780 | - $display_pms = $pms; |
|
781 | - else |
|
782 | - $display_pms = array($context['current_pm']); |
|
802 | + if ($context['display_mode'] == 0) { |
|
803 | + $display_pms = $pms; |
|
804 | + } else { |
|
805 | + $display_pms = array($context['current_pm']); |
|
806 | + } |
|
783 | 807 | |
784 | 808 | // At this point we know the main id_pm's. But - if we are looking at conversations we need the others! |
785 | 809 | if ($context['display_mode'] == 2) |
@@ -801,16 +825,18 @@ discard block |
||
801 | 825 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
802 | 826 | { |
803 | 827 | // This is, frankly, a joke. We will put in a workaround for people sending to themselves - yawn! |
804 | - if ($context['folder'] == 'sent' && $row['id_member_from'] == $user_info['id'] && $row['deleted_by_sender'] == 1) |
|
805 | - continue; |
|
806 | - elseif ($row['id_member'] == $user_info['id'] & $row['deleted'] == 1) |
|
807 | - continue; |
|
828 | + if ($context['folder'] == 'sent' && $row['id_member_from'] == $user_info['id'] && $row['deleted_by_sender'] == 1) { |
|
829 | + continue; |
|
830 | + } elseif ($row['id_member'] == $user_info['id'] & $row['deleted'] == 1) { |
|
831 | + continue; |
|
832 | + } |
|
808 | 833 | |
809 | - if (!isset($recipients[$row['id_pm']])) |
|
810 | - $recipients[$row['id_pm']] = array( |
|
834 | + if (!isset($recipients[$row['id_pm']])) { |
|
835 | + $recipients[$row['id_pm']] = array( |
|
811 | 836 | 'to' => array(), |
812 | 837 | 'bcc' => array() |
813 | 838 | ); |
839 | + } |
|
814 | 840 | $display_pms[] = $row['id_pm']; |
815 | 841 | $posters[$row['id_pm']] = $row['id_member_from']; |
816 | 842 | } |
@@ -861,8 +887,9 @@ discard block |
||
861 | 887 | while ($row2 = $smcFunc['db_fetch_assoc']($request2)) |
862 | 888 | { |
863 | 889 | $l_id = $row2['id_label']; |
864 | - if (isset($context['labels'][$l_id])) |
|
865 | - $context['message_labels'][$row['id_pm']][$l_id] = array('id' => $l_id, 'name' => $context['labels'][$l_id]['name']); |
|
890 | + if (isset($context['labels'][$l_id])) { |
|
891 | + $context['message_labels'][$row['id_pm']][$l_id] = array('id' => $l_id, 'name' => $context['labels'][$l_id]['name']); |
|
892 | + } |
|
866 | 893 | } |
867 | 894 | |
868 | 895 | $smcFunc['db_free_result']($request2); |
@@ -879,9 +906,10 @@ discard block |
||
879 | 906 | // Make sure we don't load unnecessary data. |
880 | 907 | if ($context['display_mode'] == 1) |
881 | 908 | { |
882 | - foreach ($posters as $k => $v) |
|
883 | - if (!in_array($k, $display_pms)) |
|
909 | + foreach ($posters as $k => $v) { |
|
910 | + if (!in_array($k, $display_pms)) |
|
884 | 911 | unset($posters[$k]); |
912 | + } |
|
885 | 913 | } |
886 | 914 | |
887 | 915 | // Load any users.... |
@@ -892,8 +920,9 @@ discard block |
||
892 | 920 | { |
893 | 921 | // Get the order right. |
894 | 922 | $orderBy = array(); |
895 | - foreach (array_reverse($pms) as $pm) |
|
896 | - $orderBy[] = 'pm.id_pm = ' . $pm; |
|
923 | + foreach (array_reverse($pms) as $pm) { |
|
924 | + $orderBy[] = 'pm.id_pm = ' . $pm; |
|
925 | + } |
|
897 | 926 | |
898 | 927 | // Seperate query for these bits! |
899 | 928 | $subjects_request = $smcFunc['db_query']('', ' |
@@ -939,9 +968,9 @@ discard block |
||
939 | 968 | // Allow mods to add additional buttons here |
940 | 969 | call_integration_hook('integrate_conversation_buttons'); |
941 | 970 | } |
971 | + } else { |
|
972 | + $messages_request = false; |
|
942 | 973 | } |
943 | - else |
|
944 | - $messages_request = false; |
|
945 | 974 | |
946 | 975 | $context['can_send_pm'] = allowedTo('pm_send'); |
947 | 976 | $context['can_send_email'] = allowedTo('moderate_forum'); |
@@ -952,11 +981,13 @@ discard block |
||
952 | 981 | if ($context['folder'] != 'sent' && !empty($context['labels'][(int) $context['current_label_id']]['unread_messages'])) |
953 | 982 | { |
954 | 983 | // If the display mode is "old sk00l" do them all... |
955 | - if ($context['display_mode'] == 0) |
|
956 | - markMessages(null, $context['current_label_id']); |
|
984 | + if ($context['display_mode'] == 0) { |
|
985 | + markMessages(null, $context['current_label_id']); |
|
986 | + } |
|
957 | 987 | // Otherwise do just the current one! |
958 | - elseif (!empty($context['current_pm'])) |
|
959 | - markMessages($display_pms, $context['current_label_id']); |
|
988 | + elseif (!empty($context['current_pm'])) { |
|
989 | + markMessages($display_pms, $context['current_label_id']); |
|
990 | + } |
|
960 | 991 | } |
961 | 992 | } |
962 | 993 | |
@@ -974,8 +1005,9 @@ discard block |
||
974 | 1005 | |
975 | 1006 | // Count the current message number.... |
976 | 1007 | static $counter = null; |
977 | - if ($counter === null || $reset) |
|
978 | - $counter = $context['start']; |
|
1008 | + if ($counter === null || $reset) { |
|
1009 | + $counter = $context['start']; |
|
1010 | + } |
|
979 | 1011 | |
980 | 1012 | static $temp_pm_selected = null; |
981 | 1013 | if ($temp_pm_selected === null) |
@@ -1020,19 +1052,22 @@ discard block |
||
1020 | 1052 | } |
1021 | 1053 | |
1022 | 1054 | // Bail if it's false, ie. no messages. |
1023 | - if ($messages_request == false) |
|
1024 | - return false; |
|
1055 | + if ($messages_request == false) { |
|
1056 | + return false; |
|
1057 | + } |
|
1025 | 1058 | |
1026 | 1059 | // Reset the data? |
1027 | - if ($reset == true) |
|
1028 | - return @$smcFunc['db_data_seek']($messages_request, 0); |
|
1060 | + if ($reset == true) { |
|
1061 | + return @$smcFunc['db_data_seek']($messages_request, 0); |
|
1062 | + } |
|
1029 | 1063 | |
1030 | 1064 | // Get the next one... bail if anything goes wrong. |
1031 | 1065 | $message = $smcFunc['db_fetch_assoc']($messages_request); |
1032 | 1066 | if (!$message) |
1033 | 1067 | { |
1034 | - if ($type != 'subject') |
|
1035 | - $smcFunc['db_free_result']($messages_request); |
|
1068 | + if ($type != 'subject') { |
|
1069 | + $smcFunc['db_free_result']($messages_request); |
|
1070 | + } |
|
1036 | 1071 | |
1037 | 1072 | return false; |
1038 | 1073 | } |
@@ -1052,8 +1087,7 @@ discard block |
||
1052 | 1087 | $memberContext[$message['id_member_from']]['email'] = ''; |
1053 | 1088 | $memberContext[$message['id_member_from']]['show_email'] = false; |
1054 | 1089 | $memberContext[$message['id_member_from']]['is_guest'] = true; |
1055 | - } |
|
1056 | - else |
|
1090 | + } else |
|
1057 | 1091 | { |
1058 | 1092 | $memberContext[$message['id_member_from']]['can_view_profile'] = allowedTo('profile_view') || ($message['id_member_from'] == $user_info['id'] && !$user_info['is_guest']); |
1059 | 1093 | $memberContext[$message['id_member_from']]['can_see_warning'] = !isset($context['disabled_fields']['warning_status']) && $memberContext[$message['id_member_from']]['warning_status'] && ($context['user']['can_mod'] || (!empty($modSettings['warning_show']) && ($modSettings['warning_show'] > 1 || $message['id_member_from'] == $user_info['id']))); |
@@ -1094,9 +1128,10 @@ discard block |
||
1094 | 1128 | $counter++; |
1095 | 1129 | |
1096 | 1130 | // Any custom profile fields? |
1097 | - if (!empty($memberContext[$message['id_member_from']]['custom_fields'])) |
|
1098 | - foreach ($memberContext[$message['id_member_from']]['custom_fields'] as $custom) |
|
1131 | + if (!empty($memberContext[$message['id_member_from']]['custom_fields'])) { |
|
1132 | + foreach ($memberContext[$message['id_member_from']]['custom_fields'] as $custom) |
|
1099 | 1133 | $output['custom_fields'][$context['cust_profile_fields_placement'][$custom['placement']]][] = $custom; |
1134 | + } |
|
1100 | 1135 | |
1101 | 1136 | call_integration_hook('integrate_prepare_pm_context', array(&$output, &$message, $counter)); |
1102 | 1137 | |
@@ -1120,22 +1155,28 @@ discard block |
||
1120 | 1155 | $context['search_params'][$k] = $v; |
1121 | 1156 | } |
1122 | 1157 | } |
1123 | - if (isset($_REQUEST['search'])) |
|
1124 | - $context['search_params']['search'] = un_htmlspecialchars($_REQUEST['search']); |
|
1158 | + if (isset($_REQUEST['search'])) { |
|
1159 | + $context['search_params']['search'] = un_htmlspecialchars($_REQUEST['search']); |
|
1160 | + } |
|
1125 | 1161 | |
1126 | - if (isset($context['search_params']['search'])) |
|
1127 | - $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']); |
|
1128 | - if (isset($context['search_params']['userspec'])) |
|
1129 | - $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']); |
|
1162 | + if (isset($context['search_params']['search'])) { |
|
1163 | + $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']); |
|
1164 | + } |
|
1165 | + if (isset($context['search_params']['userspec'])) { |
|
1166 | + $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']); |
|
1167 | + } |
|
1130 | 1168 | |
1131 | - if (!empty($context['search_params']['searchtype'])) |
|
1132 | - $context['search_params']['searchtype'] = 2; |
|
1169 | + if (!empty($context['search_params']['searchtype'])) { |
|
1170 | + $context['search_params']['searchtype'] = 2; |
|
1171 | + } |
|
1133 | 1172 | |
1134 | - if (!empty($context['search_params']['minage'])) |
|
1135 | - $context['search_params']['minage'] = (int) $context['search_params']['minage']; |
|
1173 | + if (!empty($context['search_params']['minage'])) { |
|
1174 | + $context['search_params']['minage'] = (int) $context['search_params']['minage']; |
|
1175 | + } |
|
1136 | 1176 | |
1137 | - if (!empty($context['search_params']['maxage'])) |
|
1138 | - $context['search_params']['maxage'] = (int) $context['search_params']['maxage']; |
|
1177 | + if (!empty($context['search_params']['maxage'])) { |
|
1178 | + $context['search_params']['maxage'] = (int) $context['search_params']['maxage']; |
|
1179 | + } |
|
1139 | 1180 | |
1140 | 1181 | $context['search_params']['subject_only'] = !empty($context['search_params']['subject_only']); |
1141 | 1182 | $context['search_params']['show_complete'] = !empty($context['search_params']['show_complete']); |
@@ -1162,8 +1203,9 @@ discard block |
||
1162 | 1203 | $context['search_errors']['messages'] = array(); |
1163 | 1204 | foreach ($context['search_errors'] as $search_error => $dummy) |
1164 | 1205 | { |
1165 | - if ($search_error == 'messages') |
|
1166 | - continue; |
|
1206 | + if ($search_error == 'messages') { |
|
1207 | + continue; |
|
1208 | + } |
|
1167 | 1209 | |
1168 | 1210 | $context['search_errors']['messages'][] = $txt['error_' . $search_error]; |
1169 | 1211 | } |
@@ -1185,8 +1227,9 @@ discard block |
||
1185 | 1227 | global $scripturl, $modSettings, $user_info, $context, $txt; |
1186 | 1228 | global $memberContext, $smcFunc; |
1187 | 1229 | |
1188 | - if (!empty($context['load_average']) && !empty($modSettings['loadavg_search']) && $context['load_average'] >= $modSettings['loadavg_search']) |
|
1189 | - fatal_lang_error('loadavg_search_disabled', false); |
|
1230 | + if (!empty($context['load_average']) && !empty($modSettings['loadavg_search']) && $context['load_average'] >= $modSettings['loadavg_search']) { |
|
1231 | + fatal_lang_error('loadavg_search_disabled', false); |
|
1232 | + } |
|
1190 | 1233 | |
1191 | 1234 | /** |
1192 | 1235 | * @todo For the moment force the folder to the inbox. |
@@ -1215,35 +1258,40 @@ discard block |
||
1215 | 1258 | $context['start'] = isset($_GET['start']) ? (int) $_GET['start'] : 0; |
1216 | 1259 | |
1217 | 1260 | // Store whether simple search was used (needed if the user wants to do another query). |
1218 | - if (!isset($search_params['advanced'])) |
|
1219 | - $search_params['advanced'] = empty($_REQUEST['advanced']) ? 0 : 1; |
|
1261 | + if (!isset($search_params['advanced'])) { |
|
1262 | + $search_params['advanced'] = empty($_REQUEST['advanced']) ? 0 : 1; |
|
1263 | + } |
|
1220 | 1264 | |
1221 | 1265 | // 1 => 'allwords' (default, don't set as param) / 2 => 'anywords'. |
1222 | - if (!empty($search_params['searchtype']) || (!empty($_REQUEST['searchtype']) && $_REQUEST['searchtype'] == 2)) |
|
1223 | - $search_params['searchtype'] = 2; |
|
1266 | + if (!empty($search_params['searchtype']) || (!empty($_REQUEST['searchtype']) && $_REQUEST['searchtype'] == 2)) { |
|
1267 | + $search_params['searchtype'] = 2; |
|
1268 | + } |
|
1224 | 1269 | |
1225 | 1270 | // Minimum age of messages. Default to zero (don't set param in that case). |
1226 | - if (!empty($search_params['minage']) || (!empty($_REQUEST['minage']) && $_REQUEST['minage'] > 0)) |
|
1227 | - $search_params['minage'] = !empty($search_params['minage']) ? (int) $search_params['minage'] : (int) $_REQUEST['minage']; |
|
1271 | + if (!empty($search_params['minage']) || (!empty($_REQUEST['minage']) && $_REQUEST['minage'] > 0)) { |
|
1272 | + $search_params['minage'] = !empty($search_params['minage']) ? (int) $search_params['minage'] : (int) $_REQUEST['minage']; |
|
1273 | + } |
|
1228 | 1274 | |
1229 | 1275 | // Maximum age of messages. Default to infinite (9999 days: param not set). |
1230 | - if (!empty($search_params['maxage']) || (!empty($_REQUEST['maxage']) && $_REQUEST['maxage'] != 9999)) |
|
1231 | - $search_params['maxage'] = !empty($search_params['maxage']) ? (int) $search_params['maxage'] : (int) $_REQUEST['maxage']; |
|
1276 | + if (!empty($search_params['maxage']) || (!empty($_REQUEST['maxage']) && $_REQUEST['maxage'] != 9999)) { |
|
1277 | + $search_params['maxage'] = !empty($search_params['maxage']) ? (int) $search_params['maxage'] : (int) $_REQUEST['maxage']; |
|
1278 | + } |
|
1232 | 1279 | |
1233 | 1280 | $search_params['subject_only'] = !empty($search_params['subject_only']) || !empty($_REQUEST['subject_only']); |
1234 | 1281 | $search_params['show_complete'] = !empty($search_params['show_complete']) || !empty($_REQUEST['show_complete']); |
1235 | 1282 | |
1236 | 1283 | // Default the user name to a wildcard matching every user (*). |
1237 | - if (!empty($search_params['user_spec']) || (!empty($_REQUEST['userspec']) && $_REQUEST['userspec'] != '*')) |
|
1238 | - $search_params['userspec'] = isset($search_params['userspec']) ? $search_params['userspec'] : $_REQUEST['userspec']; |
|
1284 | + if (!empty($search_params['user_spec']) || (!empty($_REQUEST['userspec']) && $_REQUEST['userspec'] != '*')) { |
|
1285 | + $search_params['userspec'] = isset($search_params['userspec']) ? $search_params['userspec'] : $_REQUEST['userspec']; |
|
1286 | + } |
|
1239 | 1287 | |
1240 | 1288 | // This will be full of all kinds of parameters! |
1241 | 1289 | $searchq_parameters = array(); |
1242 | 1290 | |
1243 | 1291 | // If there's no specific user, then don't mention it in the main query. |
1244 | - if (empty($search_params['userspec'])) |
|
1245 | - $userQuery = ''; |
|
1246 | - else |
|
1292 | + if (empty($search_params['userspec'])) { |
|
1293 | + $userQuery = ''; |
|
1294 | + } else |
|
1247 | 1295 | { |
1248 | 1296 | $userString = strtr($smcFunc['htmlspecialchars']($search_params['userspec'], ENT_QUOTES), array('"' => '"')); |
1249 | 1297 | $userString = strtr($userString, array('%' => '\%', '_' => '\_', '*' => '%', '?' => '_')); |
@@ -1255,8 +1303,9 @@ discard block |
||
1255 | 1303 | { |
1256 | 1304 | $possible_users[$k] = trim($possible_users[$k]); |
1257 | 1305 | |
1258 | - if (strlen($possible_users[$k]) == 0) |
|
1259 | - unset($possible_users[$k]); |
|
1306 | + if (strlen($possible_users[$k]) == 0) { |
|
1307 | + unset($possible_users[$k]); |
|
1308 | + } |
|
1260 | 1309 | } |
1261 | 1310 | |
1262 | 1311 | if (!empty($possible_users)) |
@@ -1268,8 +1317,9 @@ discard block |
||
1268 | 1317 | { |
1269 | 1318 | $where_params['name_' . $k] = $v; |
1270 | 1319 | $where_clause[] = '{raw:real_name} LIKE {string:name_' . $k . '}'; |
1271 | - if (!isset($where_params['real_name'])) |
|
1272 | - $where_params['real_name'] = $smcFunc['db_case_sensitive'] ? 'LOWER(real_name)' : 'real_name'; |
|
1320 | + if (!isset($where_params['real_name'])) { |
|
1321 | + $where_params['real_name'] = $smcFunc['db_case_sensitive'] ? 'LOWER(real_name)' : 'real_name'; |
|
1322 | + } |
|
1273 | 1323 | } |
1274 | 1324 | |
1275 | 1325 | // Who matches those criteria? |
@@ -1282,28 +1332,28 @@ discard block |
||
1282 | 1332 | ); |
1283 | 1333 | |
1284 | 1334 | // Simply do nothing if there're too many members matching the criteria. |
1285 | - if ($smcFunc['db_num_rows']($request) > $maxMembersToSearch) |
|
1286 | - $userQuery = ''; |
|
1287 | - elseif ($smcFunc['db_num_rows']($request) == 0) |
|
1335 | + if ($smcFunc['db_num_rows']($request) > $maxMembersToSearch) { |
|
1336 | + $userQuery = ''; |
|
1337 | + } elseif ($smcFunc['db_num_rows']($request) == 0) |
|
1288 | 1338 | { |
1289 | 1339 | $userQuery = 'AND pm.id_member_from = 0 AND ({raw:pm_from_name} LIKE {raw:guest_user_name_implode})'; |
1290 | 1340 | $searchq_parameters['guest_user_name_implode'] = '\'' . implode('\' OR ' . ($smcFunc['db_case_sensitive'] ? 'LOWER(pm.from_name)' : 'pm.from_name') . ' LIKE \'', $possible_users) . '\''; |
1291 | 1341 | $searchq_parameters['pm_from_name'] = $smcFunc['db_case_sensitive'] ? 'LOWER(pm.from_name)' : 'pm.from_name'; |
1292 | - } |
|
1293 | - else |
|
1342 | + } else |
|
1294 | 1343 | { |
1295 | 1344 | $memberlist = array(); |
1296 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1297 | - $memberlist[] = $row['id_member']; |
|
1345 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1346 | + $memberlist[] = $row['id_member']; |
|
1347 | + } |
|
1298 | 1348 | $userQuery = 'AND (pm.id_member_from IN ({array_int:member_list}) OR (pm.id_member_from = 0 AND ({raw:pm_from_name} LIKE {raw:guest_user_name_implode})))'; |
1299 | 1349 | $searchq_parameters['guest_user_name_implode'] = '\'' . implode('\' OR ' . ($smcFunc['db_case_sensitive'] ? 'LOWER(pm.from_name)' : 'pm.from_name') . ' LIKE \'', $possible_users) . '\''; |
1300 | 1350 | $searchq_parameters['member_list'] = $memberlist; |
1301 | 1351 | $searchq_parameters['pm_from_name'] = $smcFunc['db_case_sensitive'] ? 'LOWER(pm.from_name)' : 'pm.from_name'; |
1302 | 1352 | } |
1303 | 1353 | $smcFunc['db_free_result']($request); |
1354 | + } else { |
|
1355 | + $userQuery = ''; |
|
1304 | 1356 | } |
1305 | - else |
|
1306 | - $userQuery = ''; |
|
1307 | 1357 | } |
1308 | 1358 | |
1309 | 1359 | // Setup the sorting variables... |
@@ -1311,8 +1361,9 @@ discard block |
||
1311 | 1361 | $sort_columns = array( |
1312 | 1362 | 'pm.id_pm', |
1313 | 1363 | ); |
1314 | - if (empty($search_params['sort']) && !empty($_REQUEST['sort'])) |
|
1315 | - list ($search_params['sort'], $search_params['sort_dir']) = array_pad(explode('|', $_REQUEST['sort']), 2, ''); |
|
1364 | + if (empty($search_params['sort']) && !empty($_REQUEST['sort'])) { |
|
1365 | + list ($search_params['sort'], $search_params['sort_dir']) = array_pad(explode('|', $_REQUEST['sort']), 2, ''); |
|
1366 | + } |
|
1316 | 1367 | $search_params['sort'] = !empty($search_params['sort']) && in_array($search_params['sort'], $sort_columns) ? $search_params['sort'] : 'pm.id_pm'; |
1317 | 1368 | $search_params['sort_dir'] = !empty($search_params['sort_dir']) && $search_params['sort_dir'] == 'asc' ? 'asc' : 'desc'; |
1318 | 1369 | |
@@ -1322,24 +1373,27 @@ discard block |
||
1322 | 1373 | if ($context['folder'] == 'inbox' && !empty($search_params['advanced']) && $context['currently_using_labels']) |
1323 | 1374 | { |
1324 | 1375 | // Came here from pagination? Put them back into $_REQUEST for sanitization. |
1325 | - if (isset($search_params['labels'])) |
|
1326 | - $_REQUEST['searchlabel'] = explode(',', $search_params['labels']); |
|
1376 | + if (isset($search_params['labels'])) { |
|
1377 | + $_REQUEST['searchlabel'] = explode(',', $search_params['labels']); |
|
1378 | + } |
|
1327 | 1379 | |
1328 | 1380 | // Assuming we have some labels - make them all integers. |
1329 | 1381 | if (!empty($_REQUEST['searchlabel']) && is_array($_REQUEST['searchlabel'])) |
1330 | 1382 | { |
1331 | - foreach ($_REQUEST['searchlabel'] as $key => $id) |
|
1332 | - $_REQUEST['searchlabel'][$key] = (int) $id; |
|
1383 | + foreach ($_REQUEST['searchlabel'] as $key => $id) { |
|
1384 | + $_REQUEST['searchlabel'][$key] = (int) $id; |
|
1385 | + } |
|
1386 | + } else { |
|
1387 | + $_REQUEST['searchlabel'] = array(); |
|
1333 | 1388 | } |
1334 | - else |
|
1335 | - $_REQUEST['searchlabel'] = array(); |
|
1336 | 1389 | |
1337 | 1390 | // Now that everything is cleaned up a bit, make the labels a param. |
1338 | 1391 | $search_params['labels'] = implode(',', $_REQUEST['searchlabel']); |
1339 | 1392 | |
1340 | 1393 | // No labels selected? That must be an error! |
1341 | - if (empty($_REQUEST['searchlabel'])) |
|
1342 | - $context['search_errors']['no_labels_selected'] = true; |
|
1394 | + if (empty($_REQUEST['searchlabel'])) { |
|
1395 | + $context['search_errors']['no_labels_selected'] = true; |
|
1396 | + } |
|
1343 | 1397 | // Otherwise prepare the query! |
1344 | 1398 | elseif (count($_REQUEST['searchlabel']) != count($context['labels'])) |
1345 | 1399 | { |
@@ -1362,8 +1416,7 @@ discard block |
||
1362 | 1416 | // Not searching the inbox - PM must be labeled |
1363 | 1417 | $labelQuery = ' AND pml.id_label IN ({array_int:labels})'; |
1364 | 1418 | $labelJoin = ' INNER JOIN {db_prefix}pm_labeled_messages AS pml ON (pml.id_pm = pmr.id_pm)'; |
1365 | - } |
|
1366 | - else |
|
1419 | + } else |
|
1367 | 1420 | { |
1368 | 1421 | // Searching the inbox - PM doesn't have to be labeled |
1369 | 1422 | $labelQuery = ' AND (' . substr($labelQuery, 5) . ' OR pml.id_label IN ({array_int:labels}))'; |
@@ -1378,8 +1431,9 @@ discard block |
||
1378 | 1431 | // What are we actually searching for? |
1379 | 1432 | $search_params['search'] = !empty($search_params['search']) ? $search_params['search'] : (isset($_REQUEST['search']) ? $_REQUEST['search'] : ''); |
1380 | 1433 | // If we ain't got nothing - we should error! |
1381 | - if (!isset($search_params['search']) || $search_params['search'] == '') |
|
1382 | - $context['search_errors']['invalid_search_string'] = true; |
|
1434 | + if (!isset($search_params['search']) || $search_params['search'] == '') { |
|
1435 | + $context['search_errors']['invalid_search_string'] = true; |
|
1436 | + } |
|
1383 | 1437 | |
1384 | 1438 | // Extract phrase parts first (e.g. some words "this is a phrase" some more words.) |
1385 | 1439 | preg_match_all('~(?:^|\s)([-]?)"([^"]+)"(?:$|\s)~' . ($context['utf8'] ? 'u' : ''), $search_params['search'], $matches, PREG_PATTERN_ORDER); |
@@ -1392,12 +1446,14 @@ discard block |
||
1392 | 1446 | $excludedWords = array(); |
1393 | 1447 | |
1394 | 1448 | // .. first, we check for things like -"some words", but not "-some words". |
1395 | - foreach ($matches[1] as $index => $word) |
|
1396 | - if ($word == '-') |
|
1449 | + foreach ($matches[1] as $index => $word) { |
|
1450 | + if ($word == '-') |
|
1397 | 1451 | { |
1398 | 1452 | $word = $smcFunc['strtolower'](trim($searchArray[$index])); |
1399 | - if (strlen($word) > 0) |
|
1400 | - $excludedWords[] = $word; |
|
1453 | + } |
|
1454 | + if (strlen($word) > 0) { |
|
1455 | + $excludedWords[] = $word; |
|
1456 | + } |
|
1401 | 1457 | unset($searchArray[$index]); |
1402 | 1458 | } |
1403 | 1459 | |
@@ -1407,8 +1463,9 @@ discard block |
||
1407 | 1463 | if (strpos(trim($word), '-') === 0) |
1408 | 1464 | { |
1409 | 1465 | $word = substr($smcFunc['strtolower']($word), 1); |
1410 | - if (strlen($word) > 0) |
|
1411 | - $excludedWords[] = $word; |
|
1466 | + if (strlen($word) > 0) { |
|
1467 | + $excludedWords[] = $word; |
|
1468 | + } |
|
1412 | 1469 | unset($tempSearch[$index]); |
1413 | 1470 | } |
1414 | 1471 | } |
@@ -1419,9 +1476,9 @@ discard block |
||
1419 | 1476 | foreach ($searchArray as $index => $value) |
1420 | 1477 | { |
1421 | 1478 | $searchArray[$index] = $smcFunc['strtolower'](trim($value)); |
1422 | - if ($searchArray[$index] == '') |
|
1423 | - unset($searchArray[$index]); |
|
1424 | - else |
|
1479 | + if ($searchArray[$index] == '') { |
|
1480 | + unset($searchArray[$index]); |
|
1481 | + } else |
|
1425 | 1482 | { |
1426 | 1483 | // Sort out entities first. |
1427 | 1484 | $searchArray[$index] = $smcFunc['htmlspecialchars']($searchArray[$index]); |
@@ -1431,27 +1488,32 @@ discard block |
||
1431 | 1488 | |
1432 | 1489 | // Create an array of replacements for highlighting. |
1433 | 1490 | $context['mark'] = array(); |
1434 | - foreach ($searchArray as $word) |
|
1435 | - $context['mark'][$word] = '<strong class="highlight">' . $word . '</strong>'; |
|
1491 | + foreach ($searchArray as $word) { |
|
1492 | + $context['mark'][$word] = '<strong class="highlight">' . $word . '</strong>'; |
|
1493 | + } |
|
1436 | 1494 | |
1437 | 1495 | // This contains *everything* |
1438 | 1496 | $searchWords = array_merge($searchArray, $excludedWords); |
1439 | 1497 | |
1440 | 1498 | // Make sure at least one word is being searched for. |
1441 | - if (empty($searchArray)) |
|
1442 | - $context['search_errors']['invalid_search_string'] = true; |
|
1499 | + if (empty($searchArray)) { |
|
1500 | + $context['search_errors']['invalid_search_string'] = true; |
|
1501 | + } |
|
1443 | 1502 | |
1444 | 1503 | // Sort out the search query so the user can edit it - if they want. |
1445 | 1504 | $context['search_params'] = $search_params; |
1446 | - if (isset($context['search_params']['search'])) |
|
1447 | - $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']); |
|
1448 | - if (isset($context['search_params']['userspec'])) |
|
1449 | - $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']); |
|
1505 | + if (isset($context['search_params']['search'])) { |
|
1506 | + $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']); |
|
1507 | + } |
|
1508 | + if (isset($context['search_params']['userspec'])) { |
|
1509 | + $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']); |
|
1510 | + } |
|
1450 | 1511 | |
1451 | 1512 | // Now we have all the parameters, combine them together for pagination and the like... |
1452 | 1513 | $context['params'] = array(); |
1453 | - foreach ($search_params as $k => $v) |
|
1454 | - $context['params'][] = $k . '|\'|' . $v; |
|
1514 | + foreach ($search_params as $k => $v) { |
|
1515 | + $context['params'][] = $k . '|\'|' . $v; |
|
1516 | + } |
|
1455 | 1517 | $context['params'] = base64_encode(implode('|"|', $context['params'])); |
1456 | 1518 | |
1457 | 1519 | // Compile the subject query part. |
@@ -1459,26 +1521,31 @@ discard block |
||
1459 | 1521 | |
1460 | 1522 | foreach ($searchWords as $index => $word) |
1461 | 1523 | { |
1462 | - if ($word == '') |
|
1463 | - continue; |
|
1524 | + if ($word == '') { |
|
1525 | + continue; |
|
1526 | + } |
|
1464 | 1527 | |
1465 | - if ($search_params['subject_only']) |
|
1466 | - $andQueryParts[] = 'pm.subject' . (in_array($word, $excludedWords) ? ' NOT' : '') . ' LIKE {string:search_' . $index . '}'; |
|
1467 | - else |
|
1468 | - $andQueryParts[] = '(pm.subject' . (in_array($word, $excludedWords) ? ' NOT' : '') . ' LIKE {string:search_' . $index . '} ' . (in_array($word, $excludedWords) ? 'AND pm.body NOT' : 'OR pm.body') . ' LIKE {string:search_' . $index . '})'; |
|
1528 | + if ($search_params['subject_only']) { |
|
1529 | + $andQueryParts[] = 'pm.subject' . (in_array($word, $excludedWords) ? ' NOT' : '') . ' LIKE {string:search_' . $index . '}'; |
|
1530 | + } else { |
|
1531 | + $andQueryParts[] = '(pm.subject' . (in_array($word, $excludedWords) ? ' NOT' : '') . ' LIKE {string:search_' . $index . '} ' . (in_array($word, $excludedWords) ? 'AND pm.body NOT' : 'OR pm.body') . ' LIKE {string:search_' . $index . '})'; |
|
1532 | + } |
|
1469 | 1533 | $searchq_parameters['search_' . $index] = '%' . strtr($word, array('_' => '\\_', '%' => '\\%')) . '%'; |
1470 | 1534 | } |
1471 | 1535 | |
1472 | 1536 | $searchQuery = ' 1=1'; |
1473 | - if (!empty($andQueryParts)) |
|
1474 | - $searchQuery = implode(!empty($search_params['searchtype']) && $search_params['searchtype'] == 2 ? ' OR ' : ' AND ', $andQueryParts); |
|
1537 | + if (!empty($andQueryParts)) { |
|
1538 | + $searchQuery = implode(!empty($search_params['searchtype']) && $search_params['searchtype'] == 2 ? ' OR ' : ' AND ', $andQueryParts); |
|
1539 | + } |
|
1475 | 1540 | |
1476 | 1541 | // Age limits? |
1477 | 1542 | $timeQuery = ''; |
1478 | - if (!empty($search_params['minage'])) |
|
1479 | - $timeQuery .= ' AND pm.msgtime < ' . (time() - $search_params['minage'] * 86400); |
|
1480 | - if (!empty($search_params['maxage'])) |
|
1481 | - $timeQuery .= ' AND pm.msgtime > ' . (time() - $search_params['maxage'] * 86400); |
|
1543 | + if (!empty($search_params['minage'])) { |
|
1544 | + $timeQuery .= ' AND pm.msgtime < ' . (time() - $search_params['minage'] * 86400); |
|
1545 | + } |
|
1546 | + if (!empty($search_params['maxage'])) { |
|
1547 | + $timeQuery .= ' AND pm.msgtime > ' . (time() - $search_params['maxage'] * 86400); |
|
1548 | + } |
|
1482 | 1549 | |
1483 | 1550 | // If we have errors - return back to the first screen... |
1484 | 1551 | if (!empty($context['search_errors'])) |
@@ -1564,8 +1631,9 @@ discard block |
||
1564 | 1631 | ) |
1565 | 1632 | ); |
1566 | 1633 | $real_pm_ids = array(); |
1567 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1568 | - $real_pm_ids[$row['id_pm_head']] = $row['id_pm']; |
|
1634 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1635 | + $real_pm_ids[$row['id_pm_head']] = $row['id_pm']; |
|
1636 | + } |
|
1569 | 1637 | $smcFunc['db_free_result']($request); |
1570 | 1638 | } |
1571 | 1639 | |
@@ -1595,8 +1663,9 @@ discard block |
||
1595 | 1663 | ); |
1596 | 1664 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1597 | 1665 | { |
1598 | - if ($context['folder'] == 'sent' || empty($row['bcc'])) |
|
1599 | - $recipients[$row['id_pm']][empty($row['bcc']) ? 'to' : 'bcc'][] = empty($row['id_member_to']) ? $txt['guest_title'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member_to'] . '">' . $row['to_name'] . '</a>'; |
|
1666 | + if ($context['folder'] == 'sent' || empty($row['bcc'])) { |
|
1667 | + $recipients[$row['id_pm']][empty($row['bcc']) ? 'to' : 'bcc'][] = empty($row['id_member_to']) ? $txt['guest_title'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member_to'] . '">' . $row['to_name'] . '</a>'; |
|
1668 | + } |
|
1600 | 1669 | |
1601 | 1670 | if ($row['id_member_to'] == $user_info['id'] && $context['folder'] != 'sent') |
1602 | 1671 | { |
@@ -1617,12 +1686,14 @@ discard block |
||
1617 | 1686 | while ($row2 = $smcFunc['db_fetch_assoc']($request2)) |
1618 | 1687 | { |
1619 | 1688 | $l_id = $row2['id_label']; |
1620 | - if (isset($context['labels'][$l_id])) |
|
1621 | - $context['message_labels'][$row['id_pm']][$l_id] = array('id' => $l_id, 'name' => $context['labels'][$l_id]['name']); |
|
1689 | + if (isset($context['labels'][$l_id])) { |
|
1690 | + $context['message_labels'][$row['id_pm']][$l_id] = array('id' => $l_id, 'name' => $context['labels'][$l_id]['name']); |
|
1691 | + } |
|
1622 | 1692 | |
1623 | 1693 | // Here we find the first label on a message - for linking to posts in results |
1624 | - if (!isset($context['first_label'][$row['id_pm']]) && $row['in_inbox'] != 1) |
|
1625 | - $context['first_label'][$row['id_pm']] = $l_id; |
|
1694 | + if (!isset($context['first_label'][$row['id_pm']]) && $row['in_inbox'] != 1) { |
|
1695 | + $context['first_label'][$row['id_pm']] = $l_id; |
|
1696 | + } |
|
1626 | 1697 | } |
1627 | 1698 | |
1628 | 1699 | $smcFunc['db_free_result']($request2); |
@@ -1749,8 +1820,9 @@ discard block |
||
1749 | 1820 | list ($postCount) = $smcFunc['db_fetch_row']($request); |
1750 | 1821 | $smcFunc['db_free_result']($request); |
1751 | 1822 | |
1752 | - if (!empty($postCount) && $postCount >= $modSettings['pm_posts_per_hour']) |
|
1753 | - fatal_lang_error('pm_too_many_per_hour', true, array($modSettings['pm_posts_per_hour'])); |
|
1823 | + if (!empty($postCount) && $postCount >= $modSettings['pm_posts_per_hour']) { |
|
1824 | + fatal_lang_error('pm_too_many_per_hour', true, array($modSettings['pm_posts_per_hour'])); |
|
1825 | + } |
|
1754 | 1826 | } |
1755 | 1827 | |
1756 | 1828 | // Quoting/Replying to a message? |
@@ -1759,8 +1831,9 @@ discard block |
||
1759 | 1831 | $pmsg = (int) $_REQUEST['pmsg']; |
1760 | 1832 | |
1761 | 1833 | // Make sure this is yours. |
1762 | - if (!isAccessiblePM($pmsg)) |
|
1763 | - fatal_lang_error('no_access', false); |
|
1834 | + if (!isAccessiblePM($pmsg)) { |
|
1835 | + fatal_lang_error('no_access', false); |
|
1836 | + } |
|
1764 | 1837 | |
1765 | 1838 | // Work out whether this is one you've received? |
1766 | 1839 | $request = $smcFunc['db_query']('', ' |
@@ -1797,8 +1870,9 @@ discard block |
||
1797 | 1870 | 'id_pm' => $pmsg, |
1798 | 1871 | ) |
1799 | 1872 | ); |
1800 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1801 | - fatal_lang_error('pm_not_yours', false); |
|
1873 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1874 | + fatal_lang_error('pm_not_yours', false); |
|
1875 | + } |
|
1802 | 1876 | $row_quoted = $smcFunc['db_fetch_assoc']($request); |
1803 | 1877 | $smcFunc['db_free_result']($request); |
1804 | 1878 | |
@@ -1809,9 +1883,9 @@ discard block |
||
1809 | 1883 | // Add 'Re: ' to it.... |
1810 | 1884 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
1811 | 1885 | { |
1812 | - if ($language === $user_info['language']) |
|
1813 | - $context['response_prefix'] = $txt['response_prefix']; |
|
1814 | - else |
|
1886 | + if ($language === $user_info['language']) { |
|
1887 | + $context['response_prefix'] = $txt['response_prefix']; |
|
1888 | + } else |
|
1815 | 1889 | { |
1816 | 1890 | loadLanguage('index', $language, false); |
1817 | 1891 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -1820,22 +1894,25 @@ discard block |
||
1820 | 1894 | cache_put_data('response_prefix', $context['response_prefix'], 600); |
1821 | 1895 | } |
1822 | 1896 | $form_subject = $row_quoted['subject']; |
1823 | - if ($context['reply'] && trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) |
|
1824 | - $form_subject = $context['response_prefix'] . $form_subject; |
|
1897 | + if ($context['reply'] && trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) { |
|
1898 | + $form_subject = $context['response_prefix'] . $form_subject; |
|
1899 | + } |
|
1825 | 1900 | |
1826 | 1901 | if (isset($_REQUEST['quote'])) |
1827 | 1902 | { |
1828 | 1903 | // Remove any nested quotes and <br>... |
1829 | 1904 | $form_message = preg_replace('~<br ?/?' . '>~i', "\n", $row_quoted['body']); |
1830 | - if (!empty($modSettings['removeNestedQuotes'])) |
|
1831 | - $form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message); |
|
1832 | - if (empty($row_quoted['id_member'])) |
|
1833 | - $form_message = '[quote author="' . $row_quoted['real_name'] . '"]' . "\n" . $form_message . "\n" . '[/quote]'; |
|
1834 | - else |
|
1835 | - $form_message = '[quote author=' . $row_quoted['real_name'] . ' link=action=profile;u=' . $row_quoted['id_member'] . ' date=' . $row_quoted['msgtime'] . ']' . "\n" . $form_message . "\n" . '[/quote]'; |
|
1905 | + if (!empty($modSettings['removeNestedQuotes'])) { |
|
1906 | + $form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message); |
|
1907 | + } |
|
1908 | + if (empty($row_quoted['id_member'])) { |
|
1909 | + $form_message = '[quote author="' . $row_quoted['real_name'] . '"]' . "\n" . $form_message . "\n" . '[/quote]'; |
|
1910 | + } else { |
|
1911 | + $form_message = '[quote author=' . $row_quoted['real_name'] . ' link=action=profile;u=' . $row_quoted['id_member'] . ' date=' . $row_quoted['msgtime'] . ']' . "\n" . $form_message . "\n" . '[/quote]'; |
|
1912 | + } |
|
1913 | + } else { |
|
1914 | + $form_message = ''; |
|
1836 | 1915 | } |
1837 | - else |
|
1838 | - $form_message = ''; |
|
1839 | 1916 | |
1840 | 1917 | // Do the BBC thang on the message. |
1841 | 1918 | $row_quoted['body'] = parse_bbc($row_quoted['body'], true, 'pm' . $row_quoted['id_pm']); |
@@ -1856,8 +1933,7 @@ discard block |
||
1856 | 1933 | 'timestamp' => forum_time(true, $row_quoted['msgtime']), |
1857 | 1934 | 'body' => $row_quoted['body'] |
1858 | 1935 | ); |
1859 | - } |
|
1860 | - else |
|
1936 | + } else |
|
1861 | 1937 | { |
1862 | 1938 | $context['quoted_message'] = false; |
1863 | 1939 | $form_subject = ''; |
@@ -1876,11 +1952,12 @@ discard block |
||
1876 | 1952 | if ($_REQUEST['u'] == 'all' && isset($row_quoted)) |
1877 | 1953 | { |
1878 | 1954 | // Firstly, to reply to all we clearly already have $row_quoted - so have the original member from. |
1879 | - if ($row_quoted['id_member'] != $user_info['id']) |
|
1880 | - $context['recipients']['to'][] = array( |
|
1955 | + if ($row_quoted['id_member'] != $user_info['id']) { |
|
1956 | + $context['recipients']['to'][] = array( |
|
1881 | 1957 | 'id' => $row_quoted['id_member'], |
1882 | 1958 | 'name' => $smcFunc['htmlspecialchars']($row_quoted['real_name']), |
1883 | 1959 | ); |
1960 | + } |
|
1884 | 1961 | |
1885 | 1962 | // Now to get the others. |
1886 | 1963 | $request = $smcFunc['db_query']('', ' |
@@ -1896,18 +1973,19 @@ discard block |
||
1896 | 1973 | 'not_bcc' => 0, |
1897 | 1974 | ) |
1898 | 1975 | ); |
1899 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1900 | - $context['recipients']['to'][] = array( |
|
1976 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1977 | + $context['recipients']['to'][] = array( |
|
1901 | 1978 | 'id' => $row['id_member'], |
1902 | 1979 | 'name' => $row['real_name'], |
1903 | 1980 | ); |
1981 | + } |
|
1904 | 1982 | $smcFunc['db_free_result']($request); |
1905 | - } |
|
1906 | - else |
|
1983 | + } else |
|
1907 | 1984 | { |
1908 | 1985 | $_REQUEST['u'] = explode(',', $_REQUEST['u']); |
1909 | - foreach ($_REQUEST['u'] as $key => $uID) |
|
1910 | - $_REQUEST['u'][$key] = (int) $uID; |
|
1986 | + foreach ($_REQUEST['u'] as $key => $uID) { |
|
1987 | + $_REQUEST['u'][$key] = (int) $uID; |
|
1988 | + } |
|
1911 | 1989 | |
1912 | 1990 | $_REQUEST['u'] = array_unique($_REQUEST['u']); |
1913 | 1991 | |
@@ -1921,22 +1999,24 @@ discard block |
||
1921 | 1999 | 'limit' => count($_REQUEST['u']), |
1922 | 2000 | ) |
1923 | 2001 | ); |
1924 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1925 | - $context['recipients']['to'][] = array( |
|
2002 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2003 | + $context['recipients']['to'][] = array( |
|
1926 | 2004 | 'id' => $row['id_member'], |
1927 | 2005 | 'name' => $row['real_name'], |
1928 | 2006 | ); |
2007 | + } |
|
1929 | 2008 | $smcFunc['db_free_result']($request); |
1930 | 2009 | } |
1931 | 2010 | |
1932 | 2011 | // Get a literal name list in case the user has JavaScript disabled. |
1933 | 2012 | $names = array(); |
1934 | - foreach ($context['recipients']['to'] as $to) |
|
1935 | - $names[] = $to['name']; |
|
2013 | + foreach ($context['recipients']['to'] as $to) { |
|
2014 | + $names[] = $to['name']; |
|
2015 | + } |
|
1936 | 2016 | $context['to_value'] = empty($names) ? '' : '"' . implode('", "', $names) . '"'; |
2017 | + } else { |
|
2018 | + $context['to_value'] = ''; |
|
1937 | 2019 | } |
1938 | - else |
|
1939 | - $context['to_value'] = ''; |
|
1940 | 2020 | |
1941 | 2021 | // Set the defaults... |
1942 | 2022 | $context['subject'] = $form_subject; |
@@ -2006,8 +2086,9 @@ discard block |
||
2006 | 2086 | |
2007 | 2087 | // validate with loadMemberData() |
2008 | 2088 | $memberResult = loadMemberData($user_info['id'], false); |
2009 | - if (!$memberResult) |
|
2010 | - fatal_lang_error('not_a_user', false); |
|
2089 | + if (!$memberResult) { |
|
2090 | + fatal_lang_error('not_a_user', false); |
|
2091 | + } |
|
2011 | 2092 | list ($memID) = $memberResult; |
2012 | 2093 | |
2013 | 2094 | // drafts is where the functions reside |
@@ -2033,9 +2114,9 @@ discard block |
||
2033 | 2114 | $context['sub_template'] = 'send'; |
2034 | 2115 | loadJavaScriptFile('PersonalMessage.js', array('defer' => false, 'minimize' => true), 'smf_pms'); |
2035 | 2116 | loadJavaScriptFile('suggest.js', array('defer' => false, 'minimize' => true), 'smf_suggest'); |
2117 | + } else { |
|
2118 | + $context['sub_template'] = 'pm'; |
|
2036 | 2119 | } |
2037 | - else |
|
2038 | - $context['sub_template'] = 'pm'; |
|
2039 | 2120 | |
2040 | 2121 | $context['page_title'] = $txt['send_message']; |
2041 | 2122 | |
@@ -2096,10 +2177,11 @@ discard block |
||
2096 | 2177 | ); |
2097 | 2178 | if ($smcFunc['db_num_rows']($request) == 0) |
2098 | 2179 | { |
2099 | - if (!isset($_REQUEST['xml'])) |
|
2100 | - fatal_lang_error('pm_not_yours', false); |
|
2101 | - else |
|
2102 | - $error_types[] = 'pm_not_yours'; |
|
2180 | + if (!isset($_REQUEST['xml'])) { |
|
2181 | + fatal_lang_error('pm_not_yours', false); |
|
2182 | + } else { |
|
2183 | + $error_types[] = 'pm_not_yours'; |
|
2184 | + } |
|
2103 | 2185 | } |
2104 | 2186 | $row_quoted = $smcFunc['db_fetch_assoc']($request); |
2105 | 2187 | $smcFunc['db_free_result']($request); |
@@ -2146,14 +2228,16 @@ discard block |
||
2146 | 2228 | $context['post_error'][$error_type] = true; |
2147 | 2229 | if (isset($txt['error_' . $error_type])) |
2148 | 2230 | { |
2149 | - if ($error_type == 'long_message') |
|
2150 | - $txt['error_' . $error_type] = sprintf($txt['error_' . $error_type], $modSettings['max_messageLength']); |
|
2231 | + if ($error_type == 'long_message') { |
|
2232 | + $txt['error_' . $error_type] = sprintf($txt['error_' . $error_type], $modSettings['max_messageLength']); |
|
2233 | + } |
|
2151 | 2234 | $context['post_error']['messages'][] = $txt['error_' . $error_type]; |
2152 | 2235 | } |
2153 | 2236 | |
2154 | 2237 | // If it's not a minor error flag it as such. |
2155 | - if (!in_array($error_type, array('new_reply', 'not_approved', 'new_replies', 'old_topic', 'need_qr_verification', 'no_subject'))) |
|
2156 | - $context['error_type'] = 'serious'; |
|
2238 | + if (!in_array($error_type, array('new_reply', 'not_approved', 'new_replies', 'old_topic', 'need_qr_verification', 'no_subject'))) { |
|
2239 | + $context['error_type'] = 'serious'; |
|
2240 | + } |
|
2157 | 2241 | } |
2158 | 2242 | |
2159 | 2243 | // We need to load the editor once more. |
@@ -2211,8 +2295,9 @@ discard block |
||
2211 | 2295 | require_once($sourcedir . '/Subs-Auth.php'); |
2212 | 2296 | |
2213 | 2297 | // PM Drafts enabled and needed? |
2214 | - if ($context['drafts_pm_save'] && (isset($_POST['save_draft']) || isset($_POST['id_pm_draft']))) |
|
2215 | - require_once($sourcedir . '/Drafts.php'); |
|
2298 | + if ($context['drafts_pm_save'] && (isset($_POST['save_draft']) || isset($_POST['id_pm_draft']))) { |
|
2299 | + require_once($sourcedir . '/Drafts.php'); |
|
2300 | + } |
|
2216 | 2301 | |
2217 | 2302 | loadLanguage('PersonalMessage', '', false); |
2218 | 2303 | |
@@ -2242,24 +2327,27 @@ discard block |
||
2242 | 2327 | |
2243 | 2328 | if (!empty($postCount) && $postCount >= $modSettings['pm_posts_per_hour']) |
2244 | 2329 | { |
2245 | - if (!isset($_REQUEST['xml'])) |
|
2246 | - fatal_lang_error('pm_too_many_per_hour', true, array($modSettings['pm_posts_per_hour'])); |
|
2247 | - else |
|
2248 | - $post_errors[] = 'pm_too_many_per_hour'; |
|
2330 | + if (!isset($_REQUEST['xml'])) { |
|
2331 | + fatal_lang_error('pm_too_many_per_hour', true, array($modSettings['pm_posts_per_hour'])); |
|
2332 | + } else { |
|
2333 | + $post_errors[] = 'pm_too_many_per_hour'; |
|
2334 | + } |
|
2249 | 2335 | } |
2250 | 2336 | } |
2251 | 2337 | |
2252 | 2338 | // If your session timed out, show an error, but do allow to re-submit. |
2253 | - if (!isset($_REQUEST['xml']) && checkSession('post', '', false) != '') |
|
2254 | - $post_errors[] = 'session_timeout'; |
|
2339 | + if (!isset($_REQUEST['xml']) && checkSession('post', '', false) != '') { |
|
2340 | + $post_errors[] = 'session_timeout'; |
|
2341 | + } |
|
2255 | 2342 | |
2256 | 2343 | $_REQUEST['subject'] = isset($_REQUEST['subject']) ? trim($_REQUEST['subject']) : ''; |
2257 | 2344 | $_REQUEST['to'] = empty($_POST['to']) ? (empty($_GET['to']) ? '' : $_GET['to']) : $_POST['to']; |
2258 | 2345 | $_REQUEST['bcc'] = empty($_POST['bcc']) ? (empty($_GET['bcc']) ? '' : $_GET['bcc']) : $_POST['bcc']; |
2259 | 2346 | |
2260 | 2347 | // Route the input from the 'u' parameter to the 'to'-list. |
2261 | - if (!empty($_POST['u'])) |
|
2262 | - $_POST['recipient_to'] = explode(',', $_POST['u']); |
|
2348 | + if (!empty($_POST['u'])) { |
|
2349 | + $_POST['recipient_to'] = explode(',', $_POST['u']); |
|
2350 | + } |
|
2263 | 2351 | |
2264 | 2352 | // Construct the list of recipients. |
2265 | 2353 | $recipientList = array(); |
@@ -2271,8 +2359,9 @@ discard block |
||
2271 | 2359 | $recipientList[$recipientType] = array(); |
2272 | 2360 | if (!empty($_POST['recipient_' . $recipientType]) && is_array($_POST['recipient_' . $recipientType])) |
2273 | 2361 | { |
2274 | - foreach ($_POST['recipient_' . $recipientType] as $recipient) |
|
2275 | - $recipientList[$recipientType][] = (int) $recipient; |
|
2362 | + foreach ($_POST['recipient_' . $recipientType] as $recipient) { |
|
2363 | + $recipientList[$recipientType][] = (int) $recipient; |
|
2364 | + } |
|
2276 | 2365 | } |
2277 | 2366 | |
2278 | 2367 | // Are there also literal names set? |
@@ -2286,10 +2375,11 @@ discard block |
||
2286 | 2375 | |
2287 | 2376 | foreach ($namedRecipientList[$recipientType] as $index => $recipient) |
2288 | 2377 | { |
2289 | - if (strlen(trim($recipient)) > 0) |
|
2290 | - $namedRecipientList[$recipientType][$index] = $smcFunc['htmlspecialchars']($smcFunc['strtolower'](trim($recipient))); |
|
2291 | - else |
|
2292 | - unset($namedRecipientList[$recipientType][$index]); |
|
2378 | + if (strlen(trim($recipient)) > 0) { |
|
2379 | + $namedRecipientList[$recipientType][$index] = $smcFunc['htmlspecialchars']($smcFunc['strtolower'](trim($recipient))); |
|
2380 | + } else { |
|
2381 | + unset($namedRecipientList[$recipientType][$index]); |
|
2382 | + } |
|
2293 | 2383 | } |
2294 | 2384 | |
2295 | 2385 | if (!empty($namedRecipientList[$recipientType])) |
@@ -2319,8 +2409,9 @@ discard block |
||
2319 | 2409 | } |
2320 | 2410 | |
2321 | 2411 | // Selected a recipient to be deleted? Remove them now. |
2322 | - if (!empty($_POST['delete_recipient'])) |
|
2323 | - $recipientList[$recipientType] = array_diff($recipientList[$recipientType], array((int) $_POST['delete_recipient'])); |
|
2412 | + if (!empty($_POST['delete_recipient'])) { |
|
2413 | + $recipientList[$recipientType] = array_diff($recipientList[$recipientType], array((int) $_POST['delete_recipient'])); |
|
2414 | + } |
|
2324 | 2415 | |
2325 | 2416 | // Make sure we don't include the same name twice |
2326 | 2417 | $recipientList[$recipientType] = array_unique($recipientList[$recipientType]); |
@@ -2330,8 +2421,9 @@ discard block |
||
2330 | 2421 | $is_recipient_change = !empty($_POST['delete_recipient']) || !empty($_POST['to_submit']) || !empty($_POST['bcc_submit']); |
2331 | 2422 | |
2332 | 2423 | // Check if there's at least one recipient. |
2333 | - if (empty($recipientList['to']) && empty($recipientList['bcc'])) |
|
2334 | - $post_errors[] = 'no_to'; |
|
2424 | + if (empty($recipientList['to']) && empty($recipientList['bcc'])) { |
|
2425 | + $post_errors[] = 'no_to'; |
|
2426 | + } |
|
2335 | 2427 | |
2336 | 2428 | // Make sure that we remove the members who did get it from the screen. |
2337 | 2429 | if (!$is_recipient_change) |
@@ -2345,28 +2437,31 @@ discard block |
||
2345 | 2437 | // Since we already have a post error, remove the previous one. |
2346 | 2438 | $post_errors = array_diff($post_errors, array('no_to')); |
2347 | 2439 | |
2348 | - foreach ($namesNotFound[$recipientType] as $name) |
|
2349 | - $context['send_log']['failed'][] = sprintf($txt['pm_error_user_not_found'], $name); |
|
2440 | + foreach ($namesNotFound[$recipientType] as $name) { |
|
2441 | + $context['send_log']['failed'][] = sprintf($txt['pm_error_user_not_found'], $name); |
|
2442 | + } |
|
2350 | 2443 | } |
2351 | 2444 | } |
2352 | 2445 | } |
2353 | 2446 | |
2354 | 2447 | // Did they make any mistakes? |
2355 | - if ($_REQUEST['subject'] == '') |
|
2356 | - $post_errors[] = 'no_subject'; |
|
2357 | - if (!isset($_REQUEST['message']) || $_REQUEST['message'] == '') |
|
2358 | - $post_errors[] = 'no_message'; |
|
2359 | - elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_REQUEST['message']) > $modSettings['max_messageLength']) |
|
2360 | - $post_errors[] = 'long_message'; |
|
2361 | - else |
|
2448 | + if ($_REQUEST['subject'] == '') { |
|
2449 | + $post_errors[] = 'no_subject'; |
|
2450 | + } |
|
2451 | + if (!isset($_REQUEST['message']) || $_REQUEST['message'] == '') { |
|
2452 | + $post_errors[] = 'no_message'; |
|
2453 | + } elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_REQUEST['message']) > $modSettings['max_messageLength']) { |
|
2454 | + $post_errors[] = 'long_message'; |
|
2455 | + } else |
|
2362 | 2456 | { |
2363 | 2457 | // Preparse the message. |
2364 | 2458 | $message = $_REQUEST['message']; |
2365 | 2459 | preparsecode($message); |
2366 | 2460 | |
2367 | 2461 | // Make sure there's still some content left without the tags. |
2368 | - if ($smcFunc['htmltrim'](strip_tags(parse_bbc($smcFunc['htmlspecialchars']($message, ENT_QUOTES), false), '<img>')) === '' && (!allowedTo('admin_forum') || strpos($message, '[html]') === false)) |
|
2369 | - $post_errors[] = 'no_message'; |
|
2462 | + if ($smcFunc['htmltrim'](strip_tags(parse_bbc($smcFunc['htmlspecialchars']($message, ENT_QUOTES), false), '<img>')) === '' && (!allowedTo('admin_forum') || strpos($message, '[html]') === false)) { |
|
2463 | + $post_errors[] = 'no_message'; |
|
2464 | + } |
|
2370 | 2465 | } |
2371 | 2466 | |
2372 | 2467 | // Wrong verification code? |
@@ -2378,13 +2473,15 @@ discard block |
||
2378 | 2473 | ); |
2379 | 2474 | $context['require_verification'] = create_control_verification($verificationOptions, true); |
2380 | 2475 | |
2381 | - if (is_array($context['require_verification'])) |
|
2382 | - $post_errors = array_merge($post_errors, $context['require_verification']); |
|
2476 | + if (is_array($context['require_verification'])) { |
|
2477 | + $post_errors = array_merge($post_errors, $context['require_verification']); |
|
2478 | + } |
|
2383 | 2479 | } |
2384 | 2480 | |
2385 | 2481 | // If they did, give a chance to make ammends. |
2386 | - if (!empty($post_errors) && !$is_recipient_change && !isset($_REQUEST['preview']) && !isset($_REQUEST['xml'])) |
|
2387 | - return messagePostError($post_errors, $namedRecipientList, $recipientList); |
|
2482 | + if (!empty($post_errors) && !$is_recipient_change && !isset($_REQUEST['preview']) && !isset($_REQUEST['xml'])) { |
|
2483 | + return messagePostError($post_errors, $namedRecipientList, $recipientList); |
|
2484 | + } |
|
2388 | 2485 | |
2389 | 2486 | // Want to take a second glance before you send? |
2390 | 2487 | if (isset($_REQUEST['preview'])) |
@@ -2415,8 +2512,9 @@ discard block |
||
2415 | 2512 | foreach ($namesNotFound as $recipientType => $names) |
2416 | 2513 | { |
2417 | 2514 | $post_errors[] = 'bad_' . $recipientType; |
2418 | - foreach ($names as $name) |
|
2419 | - $context['send_log']['failed'][] = sprintf($txt['pm_error_user_not_found'], $name); |
|
2515 | + foreach ($names as $name) { |
|
2516 | + $context['send_log']['failed'][] = sprintf($txt['pm_error_user_not_found'], $name); |
|
2517 | + } |
|
2420 | 2518 | } |
2421 | 2519 | |
2422 | 2520 | return messagePostError(array(), $namedRecipientList, $recipientList); |
@@ -2446,13 +2544,14 @@ discard block |
||
2446 | 2544 | checkSubmitOnce('check'); |
2447 | 2545 | |
2448 | 2546 | // Do the actual sending of the PM. |
2449 | - if (!empty($recipientList['to']) || !empty($recipientList['bcc'])) |
|
2450 | - $context['send_log'] = sendpm($recipientList, $_REQUEST['subject'], $_REQUEST['message'], true, null, !empty($_REQUEST['pm_head']) ? (int) $_REQUEST['pm_head'] : 0); |
|
2451 | - else |
|
2452 | - $context['send_log'] = array( |
|
2547 | + if (!empty($recipientList['to']) || !empty($recipientList['bcc'])) { |
|
2548 | + $context['send_log'] = sendpm($recipientList, $_REQUEST['subject'], $_REQUEST['message'], true, null, !empty($_REQUEST['pm_head']) ? (int) $_REQUEST['pm_head'] : 0); |
|
2549 | + } else { |
|
2550 | + $context['send_log'] = array( |
|
2453 | 2551 | 'sent' => array(), |
2454 | 2552 | 'failed' => array() |
2455 | 2553 | ); |
2554 | + } |
|
2456 | 2555 | |
2457 | 2556 | // Mark the message as "replied to". |
2458 | 2557 | if (!empty($context['send_log']['sent']) && !empty($_REQUEST['replied_to']) && isset($_REQUEST['f']) && $_REQUEST['f'] == 'inbox') |
@@ -2470,11 +2569,12 @@ discard block |
||
2470 | 2569 | } |
2471 | 2570 | |
2472 | 2571 | // If one or more of the recipient were invalid, go back to the post screen with the failed usernames. |
2473 | - if (!empty($context['send_log']['failed'])) |
|
2474 | - return messagePostError($post_errors, $namesNotFound, array( |
|
2572 | + if (!empty($context['send_log']['failed'])) { |
|
2573 | + return messagePostError($post_errors, $namesNotFound, array( |
|
2475 | 2574 | 'to' => array_intersect($recipientList['to'], $context['send_log']['failed']), |
2476 | 2575 | 'bcc' => array_intersect($recipientList['bcc'], $context['send_log']['failed']) |
2477 | 2576 | )); |
2577 | + } |
|
2478 | 2578 | |
2479 | 2579 | // Message sent successfully? |
2480 | 2580 | if (!empty($context['send_log']) && empty($context['send_log']['failed'])) |
@@ -2482,8 +2582,9 @@ discard block |
||
2482 | 2582 | $context['current_label_redirect'] = $context['current_label_redirect'] . ';done=sent'; |
2483 | 2583 | |
2484 | 2584 | // If we had a PM draft for this one, then its time to remove it since it was just sent |
2485 | - if ($context['drafts_pm_save'] && !empty($_POST['id_pm_draft'])) |
|
2486 | - DeleteDraft($_POST['id_pm_draft']); |
|
2585 | + if ($context['drafts_pm_save'] && !empty($_POST['id_pm_draft'])) { |
|
2586 | + DeleteDraft($_POST['id_pm_draft']); |
|
2587 | + } |
|
2487 | 2588 | } |
2488 | 2589 | |
2489 | 2590 | // Go back to the where they sent from, if possible... |
@@ -2498,24 +2599,28 @@ discard block |
||
2498 | 2599 | |
2499 | 2600 | checkSession('request'); |
2500 | 2601 | |
2501 | - if (isset($_REQUEST['del_selected'])) |
|
2502 | - $_REQUEST['pm_action'] = 'delete'; |
|
2602 | + if (isset($_REQUEST['del_selected'])) { |
|
2603 | + $_REQUEST['pm_action'] = 'delete'; |
|
2604 | + } |
|
2503 | 2605 | |
2504 | 2606 | if (isset($_REQUEST['pm_action']) && $_REQUEST['pm_action'] != '' && !empty($_REQUEST['pms']) && is_array($_REQUEST['pms'])) |
2505 | 2607 | { |
2506 | - foreach ($_REQUEST['pms'] as $pm) |
|
2507 | - $_REQUEST['pm_actions'][(int) $pm] = $_REQUEST['pm_action']; |
|
2608 | + foreach ($_REQUEST['pms'] as $pm) { |
|
2609 | + $_REQUEST['pm_actions'][(int) $pm] = $_REQUEST['pm_action']; |
|
2610 | + } |
|
2508 | 2611 | } |
2509 | 2612 | |
2510 | - if (empty($_REQUEST['pm_actions'])) |
|
2511 | - redirectexit($context['current_label_redirect']); |
|
2613 | + if (empty($_REQUEST['pm_actions'])) { |
|
2614 | + redirectexit($context['current_label_redirect']); |
|
2615 | + } |
|
2512 | 2616 | |
2513 | 2617 | // If we are in conversation, we may need to apply this to every message in the conversation. |
2514 | 2618 | if ($context['display_mode'] == 2 && isset($_REQUEST['conversation'])) |
2515 | 2619 | { |
2516 | 2620 | $id_pms = array(); |
2517 | - foreach ($_REQUEST['pm_actions'] as $pm => $dummy) |
|
2518 | - $id_pms[] = (int) $pm; |
|
2621 | + foreach ($_REQUEST['pm_actions'] as $pm => $dummy) { |
|
2622 | + $id_pms[] = (int) $pm; |
|
2623 | + } |
|
2519 | 2624 | |
2520 | 2625 | $request = $smcFunc['db_query']('', ' |
2521 | 2626 | SELECT id_pm_head, id_pm |
@@ -2526,8 +2631,9 @@ discard block |
||
2526 | 2631 | ) |
2527 | 2632 | ); |
2528 | 2633 | $pm_heads = array(); |
2529 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2530 | - $pm_heads[$row['id_pm_head']] = $row['id_pm']; |
|
2634 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2635 | + $pm_heads[$row['id_pm_head']] = $row['id_pm']; |
|
2636 | + } |
|
2531 | 2637 | $smcFunc['db_free_result']($request); |
2532 | 2638 | |
2533 | 2639 | $request = $smcFunc['db_query']('', ' |
@@ -2541,8 +2647,9 @@ discard block |
||
2541 | 2647 | // Copy the action from the single to PM to the others. |
2542 | 2648 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2543 | 2649 | { |
2544 | - if (isset($pm_heads[$row['id_pm_head']]) && isset($_REQUEST['pm_actions'][$pm_heads[$row['id_pm_head']]])) |
|
2545 | - $_REQUEST['pm_actions'][$row['id_pm']] = $_REQUEST['pm_actions'][$pm_heads[$row['id_pm_head']]]; |
|
2650 | + if (isset($pm_heads[$row['id_pm_head']]) && isset($_REQUEST['pm_actions'][$pm_heads[$row['id_pm_head']]])) { |
|
2651 | + $_REQUEST['pm_actions'][$row['id_pm']] = $_REQUEST['pm_actions'][$pm_heads[$row['id_pm_head']]]; |
|
2652 | + } |
|
2546 | 2653 | } |
2547 | 2654 | $smcFunc['db_free_result']($request); |
2548 | 2655 | } |
@@ -2553,22 +2660,21 @@ discard block |
||
2553 | 2660 | $labels = array(); |
2554 | 2661 | foreach ($_REQUEST['pm_actions'] as $pm => $action) |
2555 | 2662 | { |
2556 | - if ($action === 'delete') |
|
2557 | - $to_delete[] = (int) $pm; |
|
2558 | - else |
|
2663 | + if ($action === 'delete') { |
|
2664 | + $to_delete[] = (int) $pm; |
|
2665 | + } else |
|
2559 | 2666 | { |
2560 | 2667 | if (substr($action, 0, 4) == 'add_') |
2561 | 2668 | { |
2562 | 2669 | $type = 'add'; |
2563 | 2670 | $action = substr($action, 4); |
2564 | - } |
|
2565 | - elseif (substr($action, 0, 4) == 'rem_') |
|
2671 | + } elseif (substr($action, 0, 4) == 'rem_') |
|
2566 | 2672 | { |
2567 | 2673 | $type = 'rem'; |
2568 | 2674 | $action = substr($action, 4); |
2675 | + } else { |
|
2676 | + $type = 'unk'; |
|
2569 | 2677 | } |
2570 | - else |
|
2571 | - $type = 'unk'; |
|
2572 | 2678 | |
2573 | 2679 | if ($action == '-1' || (int) $action > 0) |
2574 | 2680 | { |
@@ -2579,8 +2685,9 @@ discard block |
||
2579 | 2685 | } |
2580 | 2686 | |
2581 | 2687 | // Deleting, it looks like? |
2582 | - if (!empty($to_delete)) |
|
2583 | - deleteMessages($to_delete, $context['display_mode'] == 2 ? null : $context['folder']); |
|
2688 | + if (!empty($to_delete)) { |
|
2689 | + deleteMessages($to_delete, $context['display_mode'] == 2 ? null : $context['folder']); |
|
2690 | + } |
|
2584 | 2691 | |
2585 | 2692 | // Are we labeling anything? |
2586 | 2693 | if (!empty($to_label) && $context['folder'] == 'inbox') |
@@ -2646,8 +2753,7 @@ discard block |
||
2646 | 2753 | } |
2647 | 2754 | |
2648 | 2755 | $smcFunc['db_free_result']($request2); |
2649 | - } |
|
2650 | - elseif ($type == 'rem') |
|
2756 | + } elseif ($type == 'rem') |
|
2651 | 2757 | { |
2652 | 2758 | // If we're removing from the inbox, see if we have at least one other label. |
2653 | 2759 | // This query is faster than the one above |
@@ -2679,21 +2785,25 @@ discard block |
||
2679 | 2785 | if ($to_label[$row['id_pm']] != '-1') |
2680 | 2786 | { |
2681 | 2787 | // If this label is in the list and we're not adding it, remove it |
2682 | - if (array_key_exists($to_label[$row['id_pm']], $labels) && $type !== 'add') |
|
2683 | - unset($labels[$to_label[$row['id_pm']]]); |
|
2684 | - else if ($type !== 'rem') |
|
2685 | - $labels[$to_label[$row['id_pm']]] = $to_label[$row['id_pm']]; |
|
2788 | + if (array_key_exists($to_label[$row['id_pm']], $labels) && $type !== 'add') { |
|
2789 | + unset($labels[$to_label[$row['id_pm']]]); |
|
2790 | + } else if ($type !== 'rem') { |
|
2791 | + $labels[$to_label[$row['id_pm']]] = $to_label[$row['id_pm']]; |
|
2792 | + } |
|
2686 | 2793 | } |
2687 | 2794 | |
2688 | 2795 | // Removing all labels or just removing the inbox label |
2689 | - if ($type == 'rem' && empty($labels)) |
|
2690 | - $in_inbox = (empty($context['can_remove_inbox']) ? 1 : 0); |
|
2796 | + if ($type == 'rem' && empty($labels)) { |
|
2797 | + $in_inbox = (empty($context['can_remove_inbox']) ? 1 : 0); |
|
2798 | + } |
|
2691 | 2799 | // Adding new labels, but removing inbox and applying new ones |
2692 | - elseif ($type == 'add' && !empty($options['pm_remove_inbox_label']) && !empty($labels)) |
|
2693 | - $in_inbox = 0; |
|
2800 | + elseif ($type == 'add' && !empty($options['pm_remove_inbox_label']) && !empty($labels)) { |
|
2801 | + $in_inbox = 0; |
|
2802 | + } |
|
2694 | 2803 | // Just adding it to the inbox |
2695 | - else |
|
2696 | - $in_inbox = 1; |
|
2804 | + else { |
|
2805 | + $in_inbox = 1; |
|
2806 | + } |
|
2697 | 2807 | |
2698 | 2808 | // Are we adding it to or removing it from the inbox? |
2699 | 2809 | if ($in_inbox != $row['in_inbox']) |
@@ -2735,8 +2845,9 @@ discard block |
||
2735 | 2845 | if (!empty($labels_to_apply)) |
2736 | 2846 | { |
2737 | 2847 | $inserts = array(); |
2738 | - foreach ($labels_to_apply as $label) |
|
2739 | - $inserts[] = array($row['id_pm'], $label); |
|
2848 | + foreach ($labels_to_apply as $label) { |
|
2849 | + $inserts[] = array($row['id_pm'], $label); |
|
2850 | + } |
|
2740 | 2851 | |
2741 | 2852 | $smcFunc['db_insert']('', |
2742 | 2853 | '{db_prefix}pm_labeled_messages', |
@@ -2780,11 +2891,13 @@ discard block |
||
2780 | 2891 | checkSession('get'); |
2781 | 2892 | |
2782 | 2893 | // If all then delete all messages the user has. |
2783 | - if ($_REQUEST['f'] == 'all') |
|
2784 | - deleteMessages(null, null); |
|
2894 | + if ($_REQUEST['f'] == 'all') { |
|
2895 | + deleteMessages(null, null); |
|
2896 | + } |
|
2785 | 2897 | // Otherwise just the selected folder. |
2786 | - else |
|
2787 | - deleteMessages(null, $_REQUEST['f'] != 'sent' ? 'inbox' : 'sent'); |
|
2898 | + else { |
|
2899 | + deleteMessages(null, $_REQUEST['f'] != 'sent' ? 'inbox' : 'sent'); |
|
2900 | + } |
|
2788 | 2901 | |
2789 | 2902 | // Done... all gone. |
2790 | 2903 | redirectexit($context['current_label_redirect']); |
@@ -2821,8 +2934,9 @@ discard block |
||
2821 | 2934 | 'msgtime' => $deleteTime, |
2822 | 2935 | ) |
2823 | 2936 | ); |
2824 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
2825 | - $toDelete[] = $row[0]; |
|
2937 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
2938 | + $toDelete[] = $row[0]; |
|
2939 | + } |
|
2826 | 2940 | $smcFunc['db_free_result']($request); |
2827 | 2941 | |
2828 | 2942 | // Select all messages in their inbox older than $deleteTime. |
@@ -2839,8 +2953,9 @@ discard block |
||
2839 | 2953 | 'msgtime' => $deleteTime, |
2840 | 2954 | ) |
2841 | 2955 | ); |
2842 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2843 | - $toDelete[] = $row['id_pm']; |
|
2956 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2957 | + $toDelete[] = $row['id_pm']; |
|
2958 | + } |
|
2844 | 2959 | $smcFunc['db_free_result']($request); |
2845 | 2960 | |
2846 | 2961 | // Delete the actual messages. |
@@ -2871,26 +2986,29 @@ discard block |
||
2871 | 2986 | { |
2872 | 2987 | global $user_info, $smcFunc; |
2873 | 2988 | |
2874 | - if ($owner === null) |
|
2875 | - $owner = array($user_info['id']); |
|
2876 | - elseif (empty($owner)) |
|
2877 | - return; |
|
2878 | - elseif (!is_array($owner)) |
|
2879 | - $owner = array($owner); |
|
2989 | + if ($owner === null) { |
|
2990 | + $owner = array($user_info['id']); |
|
2991 | + } elseif (empty($owner)) { |
|
2992 | + return; |
|
2993 | + } elseif (!is_array($owner)) { |
|
2994 | + $owner = array($owner); |
|
2995 | + } |
|
2880 | 2996 | |
2881 | 2997 | if ($personal_messages !== null) |
2882 | 2998 | { |
2883 | - if (empty($personal_messages) || !is_array($personal_messages)) |
|
2884 | - return; |
|
2999 | + if (empty($personal_messages) || !is_array($personal_messages)) { |
|
3000 | + return; |
|
3001 | + } |
|
2885 | 3002 | |
2886 | - foreach ($personal_messages as $index => $delete_id) |
|
2887 | - $personal_messages[$index] = (int) $delete_id; |
|
3003 | + foreach ($personal_messages as $index => $delete_id) { |
|
3004 | + $personal_messages[$index] = (int) $delete_id; |
|
3005 | + } |
|
2888 | 3006 | |
2889 | 3007 | $where = ' |
2890 | 3008 | AND id_pm IN ({array_int:pm_list})'; |
3009 | + } else { |
|
3010 | + $where = ''; |
|
2891 | 3011 | } |
2892 | - else |
|
2893 | - $where = ''; |
|
2894 | 3012 | |
2895 | 3013 | if ($folder == 'sent' || $folder === null) |
2896 | 3014 | { |
@@ -2925,17 +3043,19 @@ discard block |
||
2925 | 3043 | // ...And update the statistics accordingly - now including unread messages!. |
2926 | 3044 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2927 | 3045 | { |
2928 | - if ($row['is_read']) |
|
2929 | - updateMemberData($row['id_member'], array('instant_messages' => $where == '' ? 0 : 'instant_messages - ' . $row['num_deleted_messages'])); |
|
2930 | - else |
|
2931 | - updateMemberData($row['id_member'], array('instant_messages' => $where == '' ? 0 : 'instant_messages - ' . $row['num_deleted_messages'], 'unread_messages' => $where == '' ? 0 : 'unread_messages - ' . $row['num_deleted_messages'])); |
|
3046 | + if ($row['is_read']) { |
|
3047 | + updateMemberData($row['id_member'], array('instant_messages' => $where == '' ? 0 : 'instant_messages - ' . $row['num_deleted_messages'])); |
|
3048 | + } else { |
|
3049 | + updateMemberData($row['id_member'], array('instant_messages' => $where == '' ? 0 : 'instant_messages - ' . $row['num_deleted_messages'], 'unread_messages' => $where == '' ? 0 : 'unread_messages - ' . $row['num_deleted_messages'])); |
|
3050 | + } |
|
2932 | 3051 | |
2933 | 3052 | // If this is the current member we need to make their message count correct. |
2934 | 3053 | if ($user_info['id'] == $row['id_member']) |
2935 | 3054 | { |
2936 | 3055 | $user_info['messages'] -= $row['num_deleted_messages']; |
2937 | - if (!($row['is_read'])) |
|
2938 | - $user_info['unread_messages'] -= $row['num_deleted_messages']; |
|
3056 | + if (!($row['is_read'])) { |
|
3057 | + $user_info['unread_messages'] -= $row['num_deleted_messages']; |
|
3058 | + } |
|
2939 | 3059 | } |
2940 | 3060 | } |
2941 | 3061 | $smcFunc['db_free_result']($request); |
@@ -3003,8 +3123,9 @@ discard block |
||
3003 | 3123 | ) |
3004 | 3124 | ); |
3005 | 3125 | $remove_pms = array(); |
3006 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
3007 | - $remove_pms[] = $row['sender']; |
|
3126 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
3127 | + $remove_pms[] = $row['sender']; |
|
3128 | + } |
|
3008 | 3129 | $smcFunc['db_free_result']($request); |
3009 | 3130 | |
3010 | 3131 | if (!empty($remove_pms)) |
@@ -3049,8 +3170,9 @@ discard block |
||
3049 | 3170 | { |
3050 | 3171 | global $user_info, $context, $smcFunc; |
3051 | 3172 | |
3052 | - if ($owner === null) |
|
3053 | - $owner = $user_info['id']; |
|
3173 | + if ($owner === null) { |
|
3174 | + $owner = $user_info['id']; |
|
3175 | + } |
|
3054 | 3176 | |
3055 | 3177 | $in_inbox = ''; |
3056 | 3178 | |
@@ -3074,8 +3196,7 @@ discard block |
||
3074 | 3196 | } |
3075 | 3197 | |
3076 | 3198 | $smcFunc['db_free_result']($get_messages); |
3077 | - } |
|
3078 | - elseif ($label = '-1') |
|
3199 | + } elseif ($label = '-1') |
|
3079 | 3200 | { |
3080 | 3201 | // Marking all PMs in your inbox read |
3081 | 3202 | $in_inbox = ' |
@@ -3100,8 +3221,9 @@ discard block |
||
3100 | 3221 | { |
3101 | 3222 | if ($owner == $user_info['id']) |
3102 | 3223 | { |
3103 | - foreach ($context['labels'] as $label) |
|
3104 | - $context['labels'][(int) $label['id']]['unread_messages'] = 0; |
|
3224 | + foreach ($context['labels'] as $label) { |
|
3225 | + $context['labels'][(int) $label['id']]['unread_messages'] = 0; |
|
3226 | + } |
|
3105 | 3227 | } |
3106 | 3228 | |
3107 | 3229 | $result = $smcFunc['db_query']('', ' |
@@ -3121,8 +3243,9 @@ discard block |
||
3121 | 3243 | { |
3122 | 3244 | $total_unread += $row['num']; |
3123 | 3245 | |
3124 | - if ($owner != $user_info['id'] || empty($row['id_pm'])) |
|
3125 | - continue; |
|
3246 | + if ($owner != $user_info['id'] || empty($row['id_pm'])) { |
|
3247 | + continue; |
|
3248 | + } |
|
3126 | 3249 | |
3127 | 3250 | $this_labels = array(); |
3128 | 3251 | |
@@ -3146,11 +3269,13 @@ discard block |
||
3146 | 3269 | |
3147 | 3270 | $smcFunc['db_free_result']($result2); |
3148 | 3271 | |
3149 | - foreach ($this_labels as $this_label) |
|
3150 | - $context['labels'][$this_label]['unread_messages'] += $row['num']; |
|
3272 | + foreach ($this_labels as $this_label) { |
|
3273 | + $context['labels'][$this_label]['unread_messages'] += $row['num']; |
|
3274 | + } |
|
3151 | 3275 | |
3152 | - if ($row['in_inbox'] == 1) |
|
3153 | - $context['labels'][-1]['unread_messages'] += $row['num']; |
|
3276 | + if ($row['in_inbox'] == 1) { |
|
3277 | + $context['labels'][-1]['unread_messages'] += $row['num']; |
|
3278 | + } |
|
3154 | 3279 | } |
3155 | 3280 | $smcFunc['db_free_result']($result); |
3156 | 3281 | |
@@ -3159,8 +3284,9 @@ discard block |
||
3159 | 3284 | updateMemberData($owner, array('unread_messages' => $total_unread)); |
3160 | 3285 | |
3161 | 3286 | // If it was for the current member, reflect this in the $user_info array too. |
3162 | - if ($owner == $user_info['id']) |
|
3163 | - $user_info['unread_messages'] = $total_unread; |
|
3287 | + if ($owner == $user_info['id']) { |
|
3288 | + $user_info['unread_messages'] = $total_unread; |
|
3289 | + } |
|
3164 | 3290 | } |
3165 | 3291 | } |
3166 | 3292 | |
@@ -3188,8 +3314,9 @@ discard block |
||
3188 | 3314 | // Add all existing labels to the array to save, slashing them as necessary... |
3189 | 3315 | foreach ($context['labels'] as $label) |
3190 | 3316 | { |
3191 | - if ($label['id'] != -1) |
|
3192 | - $the_labels[$label['id']] = $label['name']; |
|
3317 | + if ($label['id'] != -1) { |
|
3318 | + $the_labels[$label['id']] = $label['name']; |
|
3319 | + } |
|
3193 | 3320 | } |
3194 | 3321 | |
3195 | 3322 | if (isset($_POST[$context['session_var']])) |
@@ -3208,8 +3335,9 @@ discard block |
||
3208 | 3335 | { |
3209 | 3336 | $_POST['label'] = strtr($smcFunc['htmlspecialchars'](trim($_POST['label'])), array(',' => ',')); |
3210 | 3337 | |
3211 | - if ($smcFunc['strlen']($_POST['label']) > 30) |
|
3212 | - $_POST['label'] = $smcFunc['substr']($_POST['label'], 0, 30); |
|
3338 | + if ($smcFunc['strlen']($_POST['label']) > 30) { |
|
3339 | + $_POST['label'] = $smcFunc['substr']($_POST['label'], 0, 30); |
|
3340 | + } |
|
3213 | 3341 | if ($_POST['label'] != '') |
3214 | 3342 | { |
3215 | 3343 | $the_labels[] = $_POST['label']; |
@@ -3230,23 +3358,24 @@ discard block |
||
3230 | 3358 | { |
3231 | 3359 | foreach ($the_labels as $id => $name) |
3232 | 3360 | { |
3233 | - if ($id == -1) |
|
3234 | - continue; |
|
3235 | - elseif (isset($_POST['label_name'][$id])) |
|
3361 | + if ($id == -1) { |
|
3362 | + continue; |
|
3363 | + } elseif (isset($_POST['label_name'][$id])) |
|
3236 | 3364 | { |
3237 | 3365 | $_POST['label_name'][$id] = trim(strtr($smcFunc['htmlspecialchars']($_POST['label_name'][$id]), array(',' => ','))); |
3238 | 3366 | |
3239 | - if ($smcFunc['strlen']($_POST['label_name'][$id]) > 30) |
|
3240 | - $_POST['label_name'][$id] = $smcFunc['substr']($_POST['label_name'][$id], 0, 30); |
|
3367 | + if ($smcFunc['strlen']($_POST['label_name'][$id]) > 30) { |
|
3368 | + $_POST['label_name'][$id] = $smcFunc['substr']($_POST['label_name'][$id], 0, 30); |
|
3369 | + } |
|
3241 | 3370 | if ($_POST['label_name'][$id] != '') |
3242 | 3371 | { |
3243 | 3372 | // Changing the name of this label? |
3244 | - if ($the_labels[$id] != $_POST['label_name'][$id]) |
|
3245 | - $label_updates[$id] = $_POST['label_name'][$id]; |
|
3373 | + if ($the_labels[$id] != $_POST['label_name'][$id]) { |
|
3374 | + $label_updates[$id] = $_POST['label_name'][$id]; |
|
3375 | + } |
|
3246 | 3376 | |
3247 | 3377 | $the_labels[(int) $id] = $_POST['label_name'][$id]; |
3248 | - } |
|
3249 | - else |
|
3378 | + } else |
|
3250 | 3379 | { |
3251 | 3380 | unset($the_labels[(int) $id]); |
3252 | 3381 | $labels_to_remove[] = $id; |
@@ -3260,8 +3389,9 @@ discard block |
||
3260 | 3389 | if (!empty($labels_to_add)) |
3261 | 3390 | { |
3262 | 3391 | $inserts = array(); |
3263 | - foreach ($labels_to_add AS $label) |
|
3264 | - $inserts[] = array($user_info['id'], $label); |
|
3392 | + foreach ($labels_to_add AS $label) { |
|
3393 | + $inserts[] = array($user_info['id'], $label); |
|
3394 | + } |
|
3265 | 3395 | |
3266 | 3396 | $smcFunc['db_insert']('', '{db_prefix}pm_labels', array('id_member' => 'int', 'name' => 'string-30'), $inserts, array()); |
3267 | 3397 | } |
@@ -3351,8 +3481,9 @@ discard block |
||
3351 | 3481 | // Each action... |
3352 | 3482 | foreach ($rule['actions'] as $k2 => $action) |
3353 | 3483 | { |
3354 | - if ($action['t'] != 'lab' || !in_array($action['v'], $labels_to_remove)) |
|
3355 | - continue; |
|
3484 | + if ($action['t'] != 'lab' || !in_array($action['v'], $labels_to_remove)) { |
|
3485 | + continue; |
|
3486 | + } |
|
3356 | 3487 | |
3357 | 3488 | $rule_changes[] = $rule['id']; |
3358 | 3489 | |
@@ -3367,8 +3498,8 @@ discard block |
||
3367 | 3498 | { |
3368 | 3499 | $rule_changes = array_unique($rule_changes); |
3369 | 3500 | // Update/delete as appropriate. |
3370 | - foreach ($rule_changes as $k => $id) |
|
3371 | - if (!empty($context['rules'][$id]['actions'])) |
|
3501 | + foreach ($rule_changes as $k => $id) { |
|
3502 | + if (!empty($context['rules'][$id]['actions'])) |
|
3372 | 3503 | { |
3373 | 3504 | $smcFunc['db_query']('', ' |
3374 | 3505 | UPDATE {db_prefix}pm_rules |
@@ -3381,12 +3512,13 @@ discard block |
||
3381 | 3512 | 'actions' => $smcFunc['json_encode']($context['rules'][$id]['actions']), |
3382 | 3513 | ) |
3383 | 3514 | ); |
3515 | + } |
|
3384 | 3516 | unset($rule_changes[$k]); |
3385 | 3517 | } |
3386 | 3518 | |
3387 | 3519 | // Anything left here means it's lost all actions... |
3388 | - if (!empty($rule_changes)) |
|
3389 | - $smcFunc['db_query']('', ' |
|
3520 | + if (!empty($rule_changes)) { |
|
3521 | + $smcFunc['db_query']('', ' |
|
3390 | 3522 | DELETE FROM {db_prefix}pm_rules |
3391 | 3523 | WHERE id_rule IN ({array_int:rule_list}) |
3392 | 3524 | AND id_member = {int:current_member}', |
@@ -3395,6 +3527,7 @@ discard block |
||
3395 | 3527 | 'rule_list' => $rule_changes, |
3396 | 3528 | ) |
3397 | 3529 | ); |
3530 | + } |
|
3398 | 3531 | } |
3399 | 3532 | |
3400 | 3533 | // Make sure we're not caching this! |
@@ -3464,8 +3597,9 @@ discard block |
||
3464 | 3597 | // Save the fields. |
3465 | 3598 | saveProfileFields(); |
3466 | 3599 | |
3467 | - if (!empty($profile_vars)) |
|
3468 | - updateMemberData($user_info['id'], $profile_vars); |
|
3600 | + if (!empty($profile_vars)) { |
|
3601 | + updateMemberData($user_info['id'], $profile_vars); |
|
3602 | + } |
|
3469 | 3603 | } |
3470 | 3604 | |
3471 | 3605 | setupProfileContext( |
@@ -3490,13 +3624,15 @@ discard block |
||
3490 | 3624 | global $user_info, $language, $modSettings, $smcFunc; |
3491 | 3625 | |
3492 | 3626 | // Check that this feature is even enabled! |
3493 | - if (empty($modSettings['enableReportPM']) || empty($_REQUEST['pmsg'])) |
|
3494 | - fatal_lang_error('no_access', false); |
|
3627 | + if (empty($modSettings['enableReportPM']) || empty($_REQUEST['pmsg'])) { |
|
3628 | + fatal_lang_error('no_access', false); |
|
3629 | + } |
|
3495 | 3630 | |
3496 | 3631 | $pmsg = (int) $_REQUEST['pmsg']; |
3497 | 3632 | |
3498 | - if (!isAccessiblePM($pmsg, 'inbox')) |
|
3499 | - fatal_lang_error('no_access', false); |
|
3633 | + if (!isAccessiblePM($pmsg, 'inbox')) { |
|
3634 | + fatal_lang_error('no_access', false); |
|
3635 | + } |
|
3500 | 3636 | |
3501 | 3637 | $context['pm_id'] = $pmsg; |
3502 | 3638 | $context['page_title'] = $txt['pm_report_title']; |
@@ -3518,8 +3654,9 @@ discard block |
||
3518 | 3654 | ) |
3519 | 3655 | ); |
3520 | 3656 | $context['admins'] = array(); |
3521 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
3522 | - $context['admins'][$row['id_member']] = $row['real_name']; |
|
3657 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
3658 | + $context['admins'][$row['id_member']] = $row['real_name']; |
|
3659 | + } |
|
3523 | 3660 | $smcFunc['db_free_result']($request); |
3524 | 3661 | |
3525 | 3662 | // How many admins in total? |
@@ -3548,8 +3685,9 @@ discard block |
||
3548 | 3685 | ) |
3549 | 3686 | ); |
3550 | 3687 | // Can only be a hacker here! |
3551 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
3552 | - fatal_lang_error('no_access', false); |
|
3688 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
3689 | + fatal_lang_error('no_access', false); |
|
3690 | + } |
|
3553 | 3691 | list ($subject, $body, $time, $memberFromID, $memberFromName) = $smcFunc['db_fetch_row']($request); |
3554 | 3692 | $smcFunc['db_free_result']($request); |
3555 | 3693 | |
@@ -3573,15 +3711,17 @@ discard block |
||
3573 | 3711 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
3574 | 3712 | { |
3575 | 3713 | // If it's hidden still don't reveal their names - privacy after all ;) |
3576 | - if ($row['bcc']) |
|
3577 | - $hidden_recipients++; |
|
3578 | - else |
|
3579 | - $recipients[] = '[url=' . $scripturl . '?action=profile;u=' . $row['id_member_to'] . ']' . $row['to_name'] . '[/url]'; |
|
3714 | + if ($row['bcc']) { |
|
3715 | + $hidden_recipients++; |
|
3716 | + } else { |
|
3717 | + $recipients[] = '[url=' . $scripturl . '?action=profile;u=' . $row['id_member_to'] . ']' . $row['to_name'] . '[/url]'; |
|
3718 | + } |
|
3580 | 3719 | } |
3581 | 3720 | $smcFunc['db_free_result']($request); |
3582 | 3721 | |
3583 | - if ($hidden_recipients) |
|
3584 | - $recipients[] = sprintf($txt['pm_report_pm_hidden'], $hidden_recipients); |
|
3722 | + if ($hidden_recipients) { |
|
3723 | + $recipients[] = sprintf($txt['pm_report_pm_hidden'], $hidden_recipients); |
|
3724 | + } |
|
3585 | 3725 | |
3586 | 3726 | // Now let's get out and loop through the admins. |
3587 | 3727 | $request = $smcFunc['db_query']('', ' |
@@ -3597,8 +3737,9 @@ discard block |
||
3597 | 3737 | ); |
3598 | 3738 | |
3599 | 3739 | // Maybe we shouldn't advertise this? |
3600 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
3601 | - fatal_lang_error('no_access', false); |
|
3740 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
3741 | + fatal_lang_error('no_access', false); |
|
3742 | + } |
|
3602 | 3743 | |
3603 | 3744 | $memberFromName = un_htmlspecialchars($memberFromName); |
3604 | 3745 | |
@@ -3617,8 +3758,9 @@ discard block |
||
3617 | 3758 | // Make the body. |
3618 | 3759 | $report_body = str_replace(array('{REPORTER}', '{SENDER}'), array(un_htmlspecialchars($user_info['name']), $memberFromName), $txt['pm_report_pm_user_sent']); |
3619 | 3760 | $report_body .= "\n" . '[b]' . $_POST['reason'] . '[/b]' . "\n\n"; |
3620 | - if (!empty($recipients)) |
|
3621 | - $report_body .= $txt['pm_report_pm_other_recipients'] . ' ' . implode(', ', $recipients) . "\n\n"; |
|
3761 | + if (!empty($recipients)) { |
|
3762 | + $report_body .= $txt['pm_report_pm_other_recipients'] . ' ' . implode(', ', $recipients) . "\n\n"; |
|
3763 | + } |
|
3622 | 3764 | $report_body .= $txt['pm_report_pm_unedited_below'] . "\n" . '[quote author=' . (empty($memberFromID) ? '"' . $memberFromName . '"' : $memberFromName . ' link=action=profile;u=' . $memberFromID . ' date=' . $time) . ']' . "\n" . un_htmlspecialchars($body) . '[/quote]'; |
3623 | 3765 | |
3624 | 3766 | // Plonk it in the array ;) |
@@ -3638,12 +3780,14 @@ discard block |
||
3638 | 3780 | $smcFunc['db_free_result']($request); |
3639 | 3781 | |
3640 | 3782 | // Send a different email for each language. |
3641 | - foreach ($messagesToSend as $lang => $message) |
|
3642 | - sendpm($message['recipients'], $message['subject'], $message['body']); |
|
3783 | + foreach ($messagesToSend as $lang => $message) { |
|
3784 | + sendpm($message['recipients'], $message['subject'], $message['body']); |
|
3785 | + } |
|
3643 | 3786 | |
3644 | 3787 | // Give the user their own language back! |
3645 | - if (!empty($modSettings['userLanguage'])) |
|
3646 | - loadLanguage('PersonalMessage', '', false); |
|
3788 | + if (!empty($modSettings['userLanguage'])) { |
|
3789 | + loadLanguage('PersonalMessage', '', false); |
|
3790 | + } |
|
3647 | 3791 | |
3648 | 3792 | // Leave them with a template. |
3649 | 3793 | $context['sub_template'] = 'report_message_complete'; |
@@ -3689,8 +3833,9 @@ discard block |
||
3689 | 3833 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
3690 | 3834 | { |
3691 | 3835 | // Hide hidden groups! |
3692 | - if ($row['hidden'] && !$row['can_moderate'] && !allowedTo('manage_membergroups')) |
|
3693 | - continue; |
|
3836 | + if ($row['hidden'] && !$row['can_moderate'] && !allowedTo('manage_membergroups')) { |
|
3837 | + continue; |
|
3838 | + } |
|
3694 | 3839 | |
3695 | 3840 | $context['groups'][$row['id_group']] = $row['group_name']; |
3696 | 3841 | } |
@@ -3716,9 +3861,10 @@ discard block |
||
3716 | 3861 | $context['rule'] = $context['rules'][$context['rid']]; |
3717 | 3862 | $members = array(); |
3718 | 3863 | // Need to get member names! |
3719 | - foreach ($context['rule']['criteria'] as $k => $criteria) |
|
3720 | - if ($criteria['t'] == 'mid' && !empty($criteria['v'])) |
|
3864 | + foreach ($context['rule']['criteria'] as $k => $criteria) { |
|
3865 | + if ($criteria['t'] == 'mid' && !empty($criteria['v'])) |
|
3721 | 3866 | $members[(int) $criteria['v']] = $k; |
3867 | + } |
|
3722 | 3868 | |
3723 | 3869 | if (!empty($members)) |
3724 | 3870 | { |
@@ -3730,19 +3876,20 @@ discard block |
||
3730 | 3876 | 'member_list' => array_keys($members), |
3731 | 3877 | ) |
3732 | 3878 | ); |
3733 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
3734 | - $context['rule']['criteria'][$members[$row['id_member']]]['v'] = $row['member_name']; |
|
3879 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
3880 | + $context['rule']['criteria'][$members[$row['id_member']]]['v'] = $row['member_name']; |
|
3881 | + } |
|
3735 | 3882 | $smcFunc['db_free_result']($request); |
3736 | 3883 | } |
3737 | - } |
|
3738 | - else |
|
3739 | - $context['rule'] = array( |
|
3884 | + } else { |
|
3885 | + $context['rule'] = array( |
|
3740 | 3886 | 'id' => '', |
3741 | 3887 | 'name' => '', |
3742 | 3888 | 'criteria' => array(), |
3743 | 3889 | 'actions' => array(), |
3744 | 3890 | 'logic' => 'and', |
3745 | 3891 | ); |
3892 | + } |
|
3746 | 3893 | } |
3747 | 3894 | // Saving? |
3748 | 3895 | elseif (isset($_GET['save'])) |
@@ -3752,22 +3899,25 @@ discard block |
||
3752 | 3899 | |
3753 | 3900 | // Name is easy! |
3754 | 3901 | $ruleName = $smcFunc['htmlspecialchars'](trim($_POST['rule_name'])); |
3755 | - if (empty($ruleName)) |
|
3756 | - fatal_lang_error('pm_rule_no_name', false); |
|
3902 | + if (empty($ruleName)) { |
|
3903 | + fatal_lang_error('pm_rule_no_name', false); |
|
3904 | + } |
|
3757 | 3905 | |
3758 | 3906 | // Sanity check... |
3759 | - if (empty($_POST['ruletype']) || empty($_POST['acttype'])) |
|
3760 | - fatal_lang_error('pm_rule_no_criteria', false); |
|
3907 | + if (empty($_POST['ruletype']) || empty($_POST['acttype'])) { |
|
3908 | + fatal_lang_error('pm_rule_no_criteria', false); |
|
3909 | + } |
|
3761 | 3910 | |
3762 | 3911 | // Let's do the criteria first - it's also hardest! |
3763 | 3912 | $criteria = array(); |
3764 | 3913 | foreach ($_POST['ruletype'] as $ind => $type) |
3765 | 3914 | { |
3766 | 3915 | // Check everything is here... |
3767 | - if ($type == 'gid' && (!isset($_POST['ruledefgroup'][$ind]) || !isset($context['groups'][$_POST['ruledefgroup'][$ind]]))) |
|
3768 | - continue; |
|
3769 | - elseif ($type != 'bud' && !isset($_POST['ruledef'][$ind])) |
|
3770 | - continue; |
|
3916 | + if ($type == 'gid' && (!isset($_POST['ruledefgroup'][$ind]) || !isset($context['groups'][$_POST['ruledefgroup'][$ind]]))) { |
|
3917 | + continue; |
|
3918 | + } elseif ($type != 'bud' && !isset($_POST['ruledef'][$ind])) { |
|
3919 | + continue; |
|
3920 | + } |
|
3771 | 3921 | |
3772 | 3922 | // Members need to be found. |
3773 | 3923 | if ($type == 'mid') |
@@ -3791,13 +3941,13 @@ discard block |
||
3791 | 3941 | $smcFunc['db_free_result']($request); |
3792 | 3942 | |
3793 | 3943 | $criteria[] = array('t' => 'mid', 'v' => $memID); |
3944 | + } elseif ($type == 'bud') { |
|
3945 | + $criteria[] = array('t' => 'bud', 'v' => 1); |
|
3946 | + } elseif ($type == 'gid') { |
|
3947 | + $criteria[] = array('t' => 'gid', 'v' => (int) $_POST['ruledefgroup'][$ind]); |
|
3948 | + } elseif (in_array($type, array('sub', 'msg')) && trim($_POST['ruledef'][$ind]) != '') { |
|
3949 | + $criteria[] = array('t' => $type, 'v' => $smcFunc['htmlspecialchars'](trim($_POST['ruledef'][$ind]))); |
|
3794 | 3950 | } |
3795 | - elseif ($type == 'bud') |
|
3796 | - $criteria[] = array('t' => 'bud', 'v' => 1); |
|
3797 | - elseif ($type == 'gid') |
|
3798 | - $criteria[] = array('t' => 'gid', 'v' => (int) $_POST['ruledefgroup'][$ind]); |
|
3799 | - elseif (in_array($type, array('sub', 'msg')) && trim($_POST['ruledef'][$ind]) != '') |
|
3800 | - $criteria[] = array('t' => $type, 'v' => $smcFunc['htmlspecialchars'](trim($_POST['ruledef'][$ind]))); |
|
3801 | 3951 | } |
3802 | 3952 | |
3803 | 3953 | // Also do the actions! |
@@ -3807,26 +3957,29 @@ discard block |
||
3807 | 3957 | foreach ($_POST['acttype'] as $ind => $type) |
3808 | 3958 | { |
3809 | 3959 | // Picking a valid label? |
3810 | - if ($type == 'lab' && (!isset($_POST['labdef'][$ind]) || !isset($context['labels'][$_POST['labdef'][$ind]]))) |
|
3811 | - continue; |
|
3960 | + if ($type == 'lab' && (!isset($_POST['labdef'][$ind]) || !isset($context['labels'][$_POST['labdef'][$ind]]))) { |
|
3961 | + continue; |
|
3962 | + } |
|
3812 | 3963 | |
3813 | 3964 | // Record what we're doing. |
3814 | - if ($type == 'del') |
|
3815 | - $doDelete = 1; |
|
3816 | - elseif ($type == 'lab') |
|
3817 | - $actions[] = array('t' => 'lab', 'v' => (int) $_POST['labdef'][$ind]); |
|
3965 | + if ($type == 'del') { |
|
3966 | + $doDelete = 1; |
|
3967 | + } elseif ($type == 'lab') { |
|
3968 | + $actions[] = array('t' => 'lab', 'v' => (int) $_POST['labdef'][$ind]); |
|
3969 | + } |
|
3818 | 3970 | } |
3819 | 3971 | |
3820 | - if (empty($criteria) || (empty($actions) && !$doDelete)) |
|
3821 | - fatal_lang_error('pm_rule_no_criteria', false); |
|
3972 | + if (empty($criteria) || (empty($actions) && !$doDelete)) { |
|
3973 | + fatal_lang_error('pm_rule_no_criteria', false); |
|
3974 | + } |
|
3822 | 3975 | |
3823 | 3976 | // What are we storing? |
3824 | 3977 | $criteria = $smcFunc['json_encode']($criteria); |
3825 | 3978 | $actions = $smcFunc['json_encode']($actions); |
3826 | 3979 | |
3827 | 3980 | // Create the rule? |
3828 | - if (empty($context['rid'])) |
|
3829 | - $smcFunc['db_insert']('', |
|
3981 | + if (empty($context['rid'])) { |
|
3982 | + $smcFunc['db_insert']('', |
|
3830 | 3983 | '{db_prefix}pm_rules', |
3831 | 3984 | array( |
3832 | 3985 | 'id_member' => 'int', 'rule_name' => 'string', 'criteria' => 'string', 'actions' => 'string', |
@@ -3837,8 +3990,8 @@ discard block |
||
3837 | 3990 | ), |
3838 | 3991 | array('id_rule') |
3839 | 3992 | ); |
3840 | - else |
|
3841 | - $smcFunc['db_query']('', ' |
|
3993 | + } else { |
|
3994 | + $smcFunc['db_query']('', ' |
|
3842 | 3995 | UPDATE {db_prefix}pm_rules |
3843 | 3996 | SET rule_name = {string:rule_name}, criteria = {string:criteria}, actions = {string:actions}, |
3844 | 3997 | delete_pm = {int:delete_pm}, is_or = {int:is_or} |
@@ -3854,6 +4007,7 @@ discard block |
||
3854 | 4007 | 'actions' => $actions, |
3855 | 4008 | ) |
3856 | 4009 | ); |
4010 | + } |
|
3857 | 4011 | |
3858 | 4012 | redirectexit('action=pm;sa=manrules'); |
3859 | 4013 | } |
@@ -3862,11 +4016,12 @@ discard block |
||
3862 | 4016 | { |
3863 | 4017 | checkSession(); |
3864 | 4018 | $toDelete = array(); |
3865 | - foreach ($_POST['delrule'] as $k => $v) |
|
3866 | - $toDelete[] = (int) $k; |
|
4019 | + foreach ($_POST['delrule'] as $k => $v) { |
|
4020 | + $toDelete[] = (int) $k; |
|
4021 | + } |
|
3867 | 4022 | |
3868 | - if (!empty($toDelete)) |
|
3869 | - $smcFunc['db_query']('', ' |
|
4023 | + if (!empty($toDelete)) { |
|
4024 | + $smcFunc['db_query']('', ' |
|
3870 | 4025 | DELETE FROM {db_prefix}pm_rules |
3871 | 4026 | WHERE id_rule IN ({array_int:delete_list}) |
3872 | 4027 | AND id_member = {int:current_member}', |
@@ -3875,6 +4030,7 @@ discard block |
||
3875 | 4030 | 'delete_list' => $toDelete, |
3876 | 4031 | ) |
3877 | 4032 | ); |
4033 | + } |
|
3878 | 4034 | |
3879 | 4035 | redirectexit('action=pm;sa=manrules'); |
3880 | 4036 | } |
@@ -3893,8 +4049,9 @@ discard block |
||
3893 | 4049 | loadRules(); |
3894 | 4050 | |
3895 | 4051 | // No rules? |
3896 | - if (empty($context['rules'])) |
|
3897 | - return; |
|
4052 | + if (empty($context['rules'])) { |
|
4053 | + return; |
|
4054 | + } |
|
3898 | 4055 | |
3899 | 4056 | // Just unread ones? |
3900 | 4057 | $ruleQuery = $all_messages ? '' : ' AND pmr.is_new = 1'; |
@@ -3924,8 +4081,9 @@ discard block |
||
3924 | 4081 | // Loop through all the criteria hoping to make a match. |
3925 | 4082 | foreach ($rule['criteria'] as $criterium) |
3926 | 4083 | { |
3927 | - if (($criterium['t'] == 'mid' && $criterium['v'] == $row['id_member_from']) || ($criterium['t'] == 'gid' && $criterium['v'] == $row['id_group']) || ($criterium['t'] == 'sub' && strpos($row['subject'], $criterium['v']) !== false) || ($criterium['t'] == 'msg' && strpos($row['body'], $criterium['v']) !== false)) |
|
3928 | - $match = true; |
|
4084 | + if (($criterium['t'] == 'mid' && $criterium['v'] == $row['id_member_from']) || ($criterium['t'] == 'gid' && $criterium['v'] == $row['id_group']) || ($criterium['t'] == 'sub' && strpos($row['subject'], $criterium['v']) !== false) || ($criterium['t'] == 'msg' && strpos($row['body'], $criterium['v']) !== false)) { |
|
4085 | + $match = true; |
|
4086 | + } |
|
3929 | 4087 | // If we're adding and one criteria don't match then we stop! |
3930 | 4088 | elseif ($rule['logic'] == 'and') |
3931 | 4089 | { |
@@ -3937,17 +4095,18 @@ discard block |
||
3937 | 4095 | // If we have a match the rule must be true - act! |
3938 | 4096 | if ($match) |
3939 | 4097 | { |
3940 | - if ($rule['delete']) |
|
3941 | - $actions['deletes'][] = $row['id_pm']; |
|
3942 | - else |
|
4098 | + if ($rule['delete']) { |
|
4099 | + $actions['deletes'][] = $row['id_pm']; |
|
4100 | + } else |
|
3943 | 4101 | { |
3944 | 4102 | foreach ($rule['actions'] as $ruleAction) |
3945 | 4103 | { |
3946 | 4104 | if ($ruleAction['t'] == 'lab') |
3947 | 4105 | { |
3948 | 4106 | // Get a basic pot started! |
3949 | - if (!isset($actions['labels'][$row['id_pm']])) |
|
3950 | - $actions['labels'][$row['id_pm']] = array(); |
|
4107 | + if (!isset($actions['labels'][$row['id_pm']])) { |
|
4108 | + $actions['labels'][$row['id_pm']] = array(); |
|
4109 | + } |
|
3951 | 4110 | $actions['labels'][$row['id_pm']][] = $ruleAction['v']; |
3952 | 4111 | } |
3953 | 4112 | } |
@@ -3958,8 +4117,9 @@ discard block |
||
3958 | 4117 | $smcFunc['db_free_result']($request); |
3959 | 4118 | |
3960 | 4119 | // Deletes are easy! |
3961 | - if (!empty($actions['deletes'])) |
|
3962 | - deleteMessages($actions['deletes']); |
|
4120 | + if (!empty($actions['deletes'])) { |
|
4121 | + deleteMessages($actions['deletes']); |
|
4122 | + } |
|
3963 | 4123 | |
3964 | 4124 | // Relabel? |
3965 | 4125 | if (!empty($actions['labels'])) |
@@ -3986,8 +4146,7 @@ discard block |
||
3986 | 4146 | 'current_member' => $user_info['id'], |
3987 | 4147 | ) |
3988 | 4148 | ); |
3989 | - } |
|
3990 | - else |
|
4149 | + } else |
|
3991 | 4150 | { |
3992 | 4151 | $realLabels[] = $label['id']; |
3993 | 4152 | } |
@@ -3996,8 +4155,9 @@ discard block |
||
3996 | 4155 | |
3997 | 4156 | $inserts = array(); |
3998 | 4157 | // Now we insert the label info |
3999 | - foreach ($realLabels as $a_label) |
|
4000 | - $inserts[] = array($pm, $a_label); |
|
4158 | + foreach ($realLabels as $a_label) { |
|
4159 | + $inserts[] = array($pm, $a_label); |
|
4160 | + } |
|
4001 | 4161 | |
4002 | 4162 | $smcFunc['db_insert']('ignore', |
4003 | 4163 | '{db_prefix}pm_labeled_messages', |
@@ -4018,8 +4178,9 @@ discard block |
||
4018 | 4178 | { |
4019 | 4179 | global $user_info, $context, $smcFunc; |
4020 | 4180 | |
4021 | - if (isset($context['rules']) && !$reload) |
|
4022 | - return; |
|
4181 | + if (isset($context['rules']) && !$reload) { |
|
4182 | + return; |
|
4183 | + } |
|
4023 | 4184 | |
4024 | 4185 | $request = $smcFunc['db_query']('', ' |
4025 | 4186 | SELECT |
@@ -4043,8 +4204,9 @@ discard block |
||
4043 | 4204 | 'logic' => $row['is_or'] ? 'or' : 'and', |
4044 | 4205 | ); |
4045 | 4206 | |
4046 | - if ($row['delete_pm']) |
|
4047 | - $context['rules'][$row['id_rule']]['actions'][] = array('t' => 'del', 'v' => 1); |
|
4207 | + if ($row['delete_pm']) { |
|
4208 | + $context['rules'][$row['id_rule']]['actions'][] = array('t' => 'del', 'v' => 1); |
|
4209 | + } |
|
4048 | 4210 | } |
4049 | 4211 | $smcFunc['db_free_result']($request); |
4050 | 4212 | } |
@@ -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 | * Create a menu. |
@@ -64,22 +65,26 @@ discard block |
||
64 | 65 | $menu_context['current_action'] = isset($menuOptions['action']) ? $menuOptions['action'] : $context['current_action']; |
65 | 66 | |
66 | 67 | // Allow extend *any* menu with a single hook |
67 | - if (!empty($menu_context['current_action'])) |
|
68 | - call_integration_hook('integrate_' . $menu_context['current_action'] . '_areas', array(&$menuData)); |
|
68 | + if (!empty($menu_context['current_action'])) { |
|
69 | + call_integration_hook('integrate_' . $menu_context['current_action'] . '_areas', array(&$menuData)); |
|
70 | + } |
|
69 | 71 | |
70 | 72 | // What is the current area selected? |
71 | - if (isset($menuOptions['current_area']) || isset($_GET['area'])) |
|
72 | - $menu_context['current_area'] = isset($menuOptions['current_area']) ? $menuOptions['current_area'] : $_GET['area']; |
|
73 | + if (isset($menuOptions['current_area']) || isset($_GET['area'])) { |
|
74 | + $menu_context['current_area'] = isset($menuOptions['current_area']) ? $menuOptions['current_area'] : $_GET['area']; |
|
75 | + } |
|
73 | 76 | |
74 | 77 | // Build a list of additional parameters that should go in the URL. |
75 | 78 | $menu_context['extra_parameters'] = ''; |
76 | - if (!empty($menuOptions['extra_url_parameters'])) |
|
77 | - foreach ($menuOptions['extra_url_parameters'] as $key => $value) |
|
79 | + if (!empty($menuOptions['extra_url_parameters'])) { |
|
80 | + foreach ($menuOptions['extra_url_parameters'] as $key => $value) |
|
78 | 81 | $menu_context['extra_parameters'] .= ';' . $key . '=' . $value; |
82 | + } |
|
79 | 83 | |
80 | 84 | // Only include the session ID in the URL if it's strictly necessary. |
81 | - if (empty($menuOptions['disable_url_session_check'])) |
|
82 | - $menu_context['extra_parameters'] .= ';' . $context['session_var'] . '=' . $context['session_id']; |
|
85 | + if (empty($menuOptions['disable_url_session_check'])) { |
|
86 | + $menu_context['extra_parameters'] .= ';' . $context['session_var'] . '=' . $context['session_id']; |
|
87 | + } |
|
83 | 88 | |
84 | 89 | $include_data = array(); |
85 | 90 | |
@@ -87,8 +92,9 @@ discard block |
||
87 | 92 | foreach ($menuData as $section_id => $section) |
88 | 93 | { |
89 | 94 | // Is this enabled - or has as permission check - which fails? |
90 | - if ((isset($section['enabled']) && $section['enabled'] == false) || (isset($section['permission']) && !allowedTo($section['permission']))) |
|
91 | - continue; |
|
95 | + if ((isset($section['enabled']) && $section['enabled'] == false) || (isset($section['permission']) && !allowedTo($section['permission']))) { |
|
96 | + continue; |
|
97 | + } |
|
92 | 98 | |
93 | 99 | // Now we cycle through the sections to pick the right area. |
94 | 100 | foreach ($section['areas'] as $area_id => $area) |
@@ -110,67 +116,67 @@ discard block |
||
110 | 116 | if (empty($area['hidden'])) |
111 | 117 | { |
112 | 118 | // First time this section? |
113 | - if (!isset($menu_context['sections'][$section_id])) |
|
114 | - $menu_context['sections'][$section_id]['title'] = $section['title']; |
|
119 | + if (!isset($menu_context['sections'][$section_id])) { |
|
120 | + $menu_context['sections'][$section_id]['title'] = $section['title']; |
|
121 | + } |
|
115 | 122 | |
116 | 123 | // Is there a counter amount to show for this section? |
117 | - if (!empty($section['amt'])) |
|
118 | - $menu_context['sections'][$section_id]['amt'] = $section['amt']; |
|
124 | + if (!empty($section['amt'])) { |
|
125 | + $menu_context['sections'][$section_id]['amt'] = $section['amt']; |
|
126 | + } |
|
119 | 127 | |
120 | 128 | $menu_context['sections'][$section_id]['areas'][$area_id] = array('label' => isset($area['label']) ? $area['label'] : $txt[$area_id]); |
121 | 129 | // We'll need the ID as well... |
122 | 130 | $menu_context['sections'][$section_id]['id'] = $section_id; |
123 | 131 | // Does it have a custom URL? |
124 | - if (isset($area['custom_url'])) |
|
125 | - $menu_context['sections'][$section_id]['areas'][$area_id]['url'] = $area['custom_url']; |
|
132 | + if (isset($area['custom_url'])) { |
|
133 | + $menu_context['sections'][$section_id]['areas'][$area_id]['url'] = $area['custom_url']; |
|
134 | + } |
|
126 | 135 | |
127 | 136 | // Is there a counter amount to show for this area? |
128 | - if (!empty($area['amt'])) |
|
129 | - $menu_context['sections'][$section_id]['areas'][$area_id]['amt'] = $area['amt']; |
|
137 | + if (!empty($area['amt'])) { |
|
138 | + $menu_context['sections'][$section_id]['areas'][$area_id]['amt'] = $area['amt']; |
|
139 | + } |
|
130 | 140 | |
131 | 141 | // Does this area have its own icon? |
132 | 142 | if (!isset($area['force_menu_into_arms_of_another_menu']) && $user_info['name'] == 'iamanoompaloompa') |
133 | 143 | { |
134 | 144 | $menu_context['sections'][$section_id]['areas'][$area_id] = $smcFunc['json_decode'](base64_decode('eyJsYWJlbCI6Ik9vbXBhIExvb21wYSIsInVybCI6Imh0dHBzOlwvXC9lbi53aWtpcGVkaWEub3JnXC93aWtpXC9Pb21wYV9Mb29tcGFzPyIsImljb24iOiI8aW1nIHNyYz1cImh0dHBzOlwvXC93d3cuc2ltcGxlbWFjaGluZXMub3JnXC9pbWFnZXNcL29vbXBhLmdpZlwiIGFsdD1cIkknbSBhbiBPb21wYSBMb29tcGFcIiBcLz4ifQ=='), true); |
135 | - } |
|
136 | - elseif (isset($area['icon'])) |
|
145 | + } elseif (isset($area['icon'])) |
|
137 | 146 | { |
138 | 147 | if (file_exists($settings['theme_dir'] . '/images/admin/' . $area['icon'])) |
139 | 148 | { |
140 | 149 | $menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<img src="' . $settings['images_url'] . '/admin/' . $area['icon'] . '" alt="">'; |
141 | - } |
|
142 | - elseif (file_exists($settings['default_theme_dir'] . '/images/admin/' . $area['icon'])) |
|
150 | + } elseif (file_exists($settings['default_theme_dir'] . '/images/admin/' . $area['icon'])) |
|
143 | 151 | { |
144 | 152 | $menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<img src="' . $settings['default_images_url'] . '/admin/' . $area['icon'] . '" alt="">'; |
153 | + } else { |
|
154 | + $menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<span class="generic_icons ' . $area['icon'] . '"></span>'; |
|
145 | 155 | } |
146 | - else |
|
147 | - $menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<span class="generic_icons ' . $area['icon'] . '"></span>'; |
|
156 | + } else { |
|
157 | + $menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<span class="generic_icons ' . $area_id . '"></span>'; |
|
148 | 158 | } |
149 | - else |
|
150 | - $menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<span class="generic_icons ' . $area_id . '"></span>'; |
|
151 | 159 | |
152 | 160 | if (isset($area['icon_class']) && empty($menu_context['sections'][$section_id]['areas'][$area_id]['icon'])) |
153 | 161 | { |
154 | 162 | $menu_context['sections'][$section_id]['areas'][$area_id]['icon_class'] = $menu_context['current_action'] . '_menu_icon ' . $area['icon_class']; |
155 | - } |
|
156 | - elseif (isset($area['icon'])) |
|
163 | + } elseif (isset($area['icon'])) |
|
157 | 164 | { |
158 | 165 | if (substr($area['icon'], -4) === '.png' || substr($area['icon'], -4) === '.gif') |
159 | 166 | { |
160 | 167 | if (file_exists($settings['theme_dir'] . '/images/admin/big/' . $area['icon'])) |
161 | 168 | { |
162 | 169 | $menu_context['sections'][$section_id]['areas'][$area_id]['icon_file'] = $settings['theme_url'] . '/images/admin/big/' . $area['icon']; |
163 | - } |
|
164 | - elseif (file_exists($settings['default_theme_dir'] . '/images/admin/big/' . $area['icon'])) |
|
170 | + } elseif (file_exists($settings['default_theme_dir'] . '/images/admin/big/' . $area['icon'])) |
|
165 | 171 | { |
166 | 172 | $menu_context['sections'][$section_id]['areas'][$area_id]['icon_file'] = $settings['default_theme_url'] . '/images/admin/big/' . $area['icon']; |
167 | 173 | } |
168 | 174 | } |
169 | 175 | |
170 | 176 | $menu_context['sections'][$section_id]['areas'][$area_id]['icon_class'] = $menu_context['current_action'] . '_menu_icon ' . str_replace(array('.png', '.gif'), '', $area['icon']); |
177 | + } else { |
|
178 | + $menu_context['sections'][$section_id]['areas'][$area_id]['icon_class'] = $menu_context['current_action'] . '_menu_icon ' . str_replace(array('.png', '.gif'), '', $area_id); |
|
171 | 179 | } |
172 | - else |
|
173 | - $menu_context['sections'][$section_id]['areas'][$area_id]['icon_class'] = $menu_context['current_action'] . '_menu_icon ' . str_replace(array('.png', '.gif'), '', $area_id); |
|
174 | 180 | |
175 | 181 | // This is a shortcut for Font-Icon users so they don't have to re-do whole CSS. |
176 | 182 | $menu_context['sections'][$section_id]['areas'][$area_id]['plain_class'] = !empty($area['icon']) ? $area['icon'] : ''; |
@@ -187,39 +193,46 @@ discard block |
||
187 | 193 | { |
188 | 194 | if ((empty($sub[1]) || allowedTo($sub[1])) && (!isset($sub['enabled']) || !empty($sub['enabled']))) |
189 | 195 | { |
190 | - if ($first_sa == null) |
|
191 | - $first_sa = $sa; |
|
196 | + if ($first_sa == null) { |
|
197 | + $first_sa = $sa; |
|
198 | + } |
|
192 | 199 | |
193 | 200 | $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa] = array('label' => $sub[0]); |
194 | 201 | // Custom URL? |
195 | - if (isset($sub['url'])) |
|
196 | - $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa]['url'] = $sub['url']; |
|
202 | + if (isset($sub['url'])) { |
|
203 | + $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa]['url'] = $sub['url']; |
|
204 | + } |
|
197 | 205 | |
198 | 206 | // Is there a counter amount to show for this subsection? |
199 | - if (!empty($sub['amt'])) |
|
200 | - $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa]['amt'] = $sub['amt']; |
|
207 | + if (!empty($sub['amt'])) { |
|
208 | + $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa]['amt'] = $sub['amt']; |
|
209 | + } |
|
201 | 210 | |
202 | 211 | // A bit complicated - but is this set? |
203 | 212 | if ($menu_context['current_area'] == $area_id) |
204 | 213 | { |
205 | 214 | // Save which is the first... |
206 | - if (empty($first_sa)) |
|
207 | - $first_sa = $sa; |
|
215 | + if (empty($first_sa)) { |
|
216 | + $first_sa = $sa; |
|
217 | + } |
|
208 | 218 | |
209 | 219 | // Is this the current subsection? |
210 | - if (isset($_REQUEST['sa']) && $_REQUEST['sa'] == $sa) |
|
211 | - $menu_context['current_subsection'] = $sa; |
|
220 | + if (isset($_REQUEST['sa']) && $_REQUEST['sa'] == $sa) { |
|
221 | + $menu_context['current_subsection'] = $sa; |
|
222 | + } |
|
212 | 223 | // Otherwise is it the default? |
213 | - elseif (!isset($menu_context['current_subsection']) && !empty($sub[2])) |
|
214 | - $menu_context['current_subsection'] = $sa; |
|
224 | + elseif (!isset($menu_context['current_subsection']) && !empty($sub[2])) { |
|
225 | + $menu_context['current_subsection'] = $sa; |
|
226 | + } |
|
215 | 227 | } |
216 | 228 | |
217 | 229 | // Let's assume this is the last, for now. |
218 | 230 | $last_sa = $sa; |
219 | 231 | } |
220 | 232 | // Mark it as disabled... |
221 | - else |
|
222 | - $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa]['disabled'] = true; |
|
233 | + else { |
|
234 | + $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa]['disabled'] = true; |
|
235 | + } |
|
223 | 236 | } |
224 | 237 | |
225 | 238 | // Set which one is first, last and selected in the group. |
@@ -228,8 +241,9 @@ discard block |
||
228 | 241 | $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$context['right_to_left'] ? $last_sa : $first_sa]['is_first'] = true; |
229 | 242 | $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$context['right_to_left'] ? $first_sa : $last_sa]['is_last'] = true; |
230 | 243 | |
231 | - if ($menu_context['current_area'] == $area_id && !isset($menu_context['current_subsection'])) |
|
232 | - $menu_context['current_subsection'] = $first_sa; |
|
244 | + if ($menu_context['current_area'] == $area_id && !isset($menu_context['current_subsection'])) { |
|
245 | + $menu_context['current_subsection'] = $first_sa; |
|
246 | + } |
|
233 | 247 | } |
234 | 248 | } |
235 | 249 | } |
@@ -263,23 +277,26 @@ discard block |
||
263 | 277 | $menu_context['base_url'] = isset($menuOptions['base_url']) ? $menuOptions['base_url'] : $scripturl . '?action=' . $menu_context['current_action']; |
264 | 278 | |
265 | 279 | // If we didn't find the area we were looking for go to a default one. |
266 | - if (isset($backup_area) && empty($found_section)) |
|
267 | - $menu_context['current_area'] = $backup_area; |
|
280 | + if (isset($backup_area) && empty($found_section)) { |
|
281 | + $menu_context['current_area'] = $backup_area; |
|
282 | + } |
|
268 | 283 | |
269 | 284 | // If there are sections quickly goes through all the sections to check if the base menu has an url |
270 | 285 | if (!empty($menu_context['current_section'])) |
271 | 286 | { |
272 | 287 | $menu_context['sections'][$menu_context['current_section']]['selected'] = true; |
273 | 288 | $menu_context['sections'][$menu_context['current_section']]['areas'][$menu_context['current_area']]['selected'] = true; |
274 | - if (!empty($menu_context['sections'][$menu_context['current_section']]['areas'][$menu_context['current_area']]['subsections'][$context['current_subaction']])) |
|
275 | - $menu_context['sections'][$menu_context['current_section']]['areas'][$menu_context['current_area']]['subsections'][$context['current_subaction']]['selected'] = true; |
|
289 | + if (!empty($menu_context['sections'][$menu_context['current_section']]['areas'][$menu_context['current_area']]['subsections'][$context['current_subaction']])) { |
|
290 | + $menu_context['sections'][$menu_context['current_section']]['areas'][$menu_context['current_area']]['subsections'][$context['current_subaction']]['selected'] = true; |
|
291 | + } |
|
276 | 292 | |
277 | - foreach ($menu_context['sections'] as $section_id => $section) |
|
278 | - foreach ($section['areas'] as $area_id => $area) |
|
293 | + foreach ($menu_context['sections'] as $section_id => $section) { |
|
294 | + foreach ($section['areas'] as $area_id => $area) |
|
279 | 295 | { |
280 | 296 | if (!isset($menu_context['sections'][$section_id]['url'])) |
281 | 297 | { |
282 | 298 | $menu_context['sections'][$section_id]['url'] = isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $area_id; |
299 | + } |
|
283 | 300 | break; |
284 | 301 | } |
285 | 302 | } |
@@ -290,8 +307,9 @@ discard block |
||
290 | 307 | { |
291 | 308 | // Never happened! |
292 | 309 | $context['max_menu_id']--; |
293 | - if ($context['max_menu_id'] == 0) |
|
294 | - unset($context['max_menu_id']); |
|
310 | + if ($context['max_menu_id'] == 0) { |
|
311 | + unset($context['max_menu_id']); |
|
312 | + } |
|
295 | 313 | |
296 | 314 | return false; |
297 | 315 | } |
@@ -302,8 +320,9 @@ discard block |
||
302 | 320 | $context['template_layers'][] = $menu_context['layer_name']; |
303 | 321 | |
304 | 322 | // Check we had something - for sanity sake. |
305 | - if (empty($include_data)) |
|
306 | - return false; |
|
323 | + if (empty($include_data)) { |
|
324 | + return false; |
|
325 | + } |
|
307 | 326 | |
308 | 327 | // Finally - return information on the selected item. |
309 | 328 | $include_data += array( |
@@ -326,12 +345,14 @@ discard block |
||
326 | 345 | global $context; |
327 | 346 | |
328 | 347 | $menu_name = $menu_id == 'last' && isset($context['max_menu_id']) && isset($context['menu_data_' . $context['max_menu_id']]) ? 'menu_data_' . $context['max_menu_id'] : 'menu_data_' . $menu_id; |
329 | - if (!isset($context[$menu_name])) |
|
330 | - return false; |
|
348 | + if (!isset($context[$menu_name])) { |
|
349 | + return false; |
|
350 | + } |
|
331 | 351 | |
332 | 352 | $layer_index = array_search($context[$menu_name]['layer_name'], $context['template_layers']); |
333 | - if ($layer_index !== false) |
|
334 | - unset($context['template_layers'][$layer_index]); |
|
353 | + if ($layer_index !== false) { |
|
354 | + unset($context['template_layers'][$layer_index]); |
|
355 | + } |
|
335 | 356 | |
336 | 357 | unset($context[$menu_name]); |
337 | 358 | } |
@@ -83,16 +83,18 @@ discard block |
||
83 | 83 | foreach ($section['areas'] as $i => $area) |
84 | 84 | { |
85 | 85 | // Not supposed to be printed? |
86 | - if (empty($area['label'])) |
|
87 | - continue; |
|
86 | + if (empty($area['label'])) { |
|
87 | + continue; |
|
88 | + } |
|
88 | 89 | |
89 | 90 | echo ' |
90 | 91 | <li', !empty($area['subsections']) ? ' class="subsections"' : '', '> |
91 | 92 | <a class="', $area['icon_class'], !empty($area['selected']) ? ' chosen ' : '', '" href="', (isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $i), $menu_context['extra_parameters'], '">', $area['icon'], $area['label'], !empty($area['amt']) ? ' <span class="amt">' . $area['amt'] . '</span>' : '', '</a>'; |
92 | 93 | |
93 | 94 | // Is this the current area, or just some area? |
94 | - if (!empty($area['selected']) && empty($context['tabs'])) |
|
95 | - $context['tabs'] = isset($area['subsections']) ? $area['subsections'] : array(); |
|
95 | + if (!empty($area['selected']) && empty($context['tabs'])) { |
|
96 | + $context['tabs'] = isset($area['subsections']) ? $area['subsections'] : array(); |
|
97 | + } |
|
96 | 98 | |
97 | 99 | // Are there any subsections? |
98 | 100 | if (!empty($area['subsections'])) |
@@ -102,8 +104,9 @@ discard block |
||
102 | 104 | |
103 | 105 | foreach ($area['subsections'] as $sa => $sub) |
104 | 106 | { |
105 | - if (!empty($sub['disabled'])) |
|
106 | - continue; |
|
107 | + if (!empty($sub['disabled'])) { |
|
108 | + continue; |
|
109 | + } |
|
107 | 110 | |
108 | 111 | $url = isset($sub['url']) ? $sub['url'] : (isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $i) . ';sa=' . $sa; |
109 | 112 | |
@@ -150,8 +153,9 @@ discard block |
||
150 | 153 | <h3 class="catbg">'; |
151 | 154 | |
152 | 155 | // The function is in Admin.template.php, but since this template is used elsewhere too better check if the function is available |
153 | - if (function_exists('template_admin_quick_search')) |
|
154 | - template_admin_quick_search(); |
|
156 | + if (function_exists('template_admin_quick_search')) { |
|
157 | + template_admin_quick_search(); |
|
158 | + } |
|
155 | 159 | |
156 | 160 | // Exactly how many tabs do we have? |
157 | 161 | if (!empty($context['tabs'])) |
@@ -166,30 +170,36 @@ discard block |
||
166 | 170 | } |
167 | 171 | |
168 | 172 | // Did this not even exist - or do we not have a label? |
169 | - if (!isset($tab_context['tabs'][$id])) |
|
170 | - $tab_context['tabs'][$id] = array('label' => $tab['label']); |
|
171 | - elseif (!isset($tab_context['tabs'][$id]['label'])) |
|
172 | - $tab_context['tabs'][$id]['label'] = $tab['label']; |
|
173 | + if (!isset($tab_context['tabs'][$id])) { |
|
174 | + $tab_context['tabs'][$id] = array('label' => $tab['label']); |
|
175 | + } elseif (!isset($tab_context['tabs'][$id]['label'])) { |
|
176 | + $tab_context['tabs'][$id]['label'] = $tab['label']; |
|
177 | + } |
|
173 | 178 | |
174 | 179 | // Has a custom URL defined in the main admin structure? |
175 | - if (isset($tab['url']) && !isset($tab_context['tabs'][$id]['url'])) |
|
176 | - $tab_context['tabs'][$id]['url'] = $tab['url']; |
|
180 | + if (isset($tab['url']) && !isset($tab_context['tabs'][$id]['url'])) { |
|
181 | + $tab_context['tabs'][$id]['url'] = $tab['url']; |
|
182 | + } |
|
177 | 183 | |
178 | 184 | // Any additional paramaters for the url? |
179 | - if (isset($tab['add_params']) && !isset($tab_context['tabs'][$id]['add_params'])) |
|
180 | - $tab_context['tabs'][$id]['add_params'] = $tab['add_params']; |
|
185 | + if (isset($tab['add_params']) && !isset($tab_context['tabs'][$id]['add_params'])) { |
|
186 | + $tab_context['tabs'][$id]['add_params'] = $tab['add_params']; |
|
187 | + } |
|
181 | 188 | |
182 | 189 | // Has it been deemed selected? |
183 | - if (!empty($tab['is_selected'])) |
|
184 | - $tab_context['tabs'][$id]['is_selected'] = true; |
|
190 | + if (!empty($tab['is_selected'])) { |
|
191 | + $tab_context['tabs'][$id]['is_selected'] = true; |
|
192 | + } |
|
185 | 193 | |
186 | 194 | // Does it have its own help? |
187 | - if (!empty($tab['help'])) |
|
188 | - $tab_context['tabs'][$id]['help'] = $tab['help']; |
|
195 | + if (!empty($tab['help'])) { |
|
196 | + $tab_context['tabs'][$id]['help'] = $tab['help']; |
|
197 | + } |
|
189 | 198 | |
190 | 199 | // Is this the last one? |
191 | - if (!empty($tab['is_last']) && !isset($tab_context['override_last'])) |
|
192 | - $tab_context['tabs'][$id]['is_last'] = true; |
|
200 | + if (!empty($tab['is_last']) && !isset($tab_context['override_last'])) { |
|
201 | + $tab_context['tabs'][$id]['is_last'] = true; |
|
202 | + } |
|
193 | 203 | } |
194 | 204 | |
195 | 205 | // Find the selected tab |
@@ -206,22 +216,24 @@ discard block |
||
206 | 216 | // Show an icon and/or a help item? |
207 | 217 | if (!empty($selected_tab['icon_class']) || !empty($tab_context['icon_class']) || !empty($selected_tab['icon']) || !empty($tab_context['icon']) || !empty($selected_tab['help']) || !empty($tab_context['help'])) |
208 | 218 | { |
209 | - if (!empty($selected_tab['icon_class']) || !empty($tab_context['icon_class'])) |
|
210 | - echo ' |
|
219 | + if (!empty($selected_tab['icon_class']) || !empty($tab_context['icon_class'])) { |
|
220 | + echo ' |
|
211 | 221 | <span class="', !empty($selected_tab['icon_class']) ? $selected_tab['icon_class'] : $tab_context['icon_class'], ' icon"></span>'; |
212 | - elseif (!empty($selected_tab['icon']) || !empty($tab_context['icon'])) |
|
213 | - echo ' |
|
222 | + } elseif (!empty($selected_tab['icon']) || !empty($tab_context['icon'])) { |
|
223 | + echo ' |
|
214 | 224 | <img src="', $settings['images_url'], '/icons/', !empty($selected_tab['icon']) ? $selected_tab['icon'] : $tab_context['icon'], '" alt="" class="icon">'; |
225 | + } |
|
215 | 226 | |
216 | - if (!empty($selected_tab['help']) || !empty($tab_context['help'])) |
|
217 | - echo ' |
|
227 | + if (!empty($selected_tab['help']) || !empty($tab_context['help'])) { |
|
228 | + echo ' |
|
218 | 229 | <a href="', $scripturl, '?action=helpadmin;help=', !empty($selected_tab['help']) ? $selected_tab['help'] : $tab_context['help'], '" onclick="return reqOverlayDiv(this.href);" class="help"><span class="generic_icons help" title="', $txt['help'], '"></span></a>'; |
230 | + } |
|
219 | 231 | |
220 | 232 | echo $tab_context['title']; |
221 | - } |
|
222 | - else |
|
223 | - echo ' |
|
233 | + } else { |
|
234 | + echo ' |
|
224 | 235 | ', $tab_context['title']; |
236 | + } |
|
225 | 237 | |
226 | 238 | echo ' |
227 | 239 | </h3>', (function_exists('template_admin_quick_search') ? ' |
@@ -230,11 +242,12 @@ discard block |
||
230 | 242 | } |
231 | 243 | |
232 | 244 | // Shall we use the tabs? Yes, it's the only known way! |
233 | - if (!empty($selected_tab['description']) || !empty($tab_context['description'])) |
|
234 | - echo ' |
|
245 | + if (!empty($selected_tab['description']) || !empty($tab_context['description'])) { |
|
246 | + echo ' |
|
235 | 247 | <p class="information"> |
236 | 248 | ', !empty($selected_tab['description']) ? $selected_tab['description'] : $tab_context['description'], ' |
237 | 249 | </p>'; |
250 | + } |
|
238 | 251 | |
239 | 252 | // Print out all the items in this tab (if any). |
240 | 253 | if (!empty($context['tabs'])) |
@@ -246,19 +259,21 @@ discard block |
||
246 | 259 | |
247 | 260 | foreach ($tab_context['tabs'] as $sa => $tab) |
248 | 261 | { |
249 | - if (!empty($tab['disabled'])) |
|
250 | - continue; |
|
262 | + if (!empty($tab['disabled'])) { |
|
263 | + continue; |
|
264 | + } |
|
251 | 265 | |
252 | - if (!empty($tab['is_selected'])) |
|
253 | - echo ' |
|
266 | + if (!empty($tab['is_selected'])) { |
|
267 | + echo ' |
|
254 | 268 | <li> |
255 | 269 | <a class="active" href="', isset($tab['url']) ? $tab['url'] : $menu_context['base_url'] . ';area=' . $menu_context['current_area'] . ';sa=' . $sa, $menu_context['extra_parameters'], isset($tab['add_params']) ? $tab['add_params'] : '', '">', $tab['label'], '</a> |
256 | 270 | </li>'; |
257 | - else |
|
258 | - echo ' |
|
271 | + } else { |
|
272 | + echo ' |
|
259 | 273 | <li> |
260 | 274 | <a href="', isset($tab['url']) ? $tab['url'] : $menu_context['base_url'] . ';area=' . $menu_context['current_area'] . ';sa=' . $sa, $menu_context['extra_parameters'], isset($tab['add_params']) ? $tab['add_params'] : '', '">', $tab['label'], '</a> |
261 | 275 | </li>'; |
276 | + } |
|
262 | 277 | } |
263 | 278 | |
264 | 279 | // The end of tabs |
@@ -72,9 +72,10 @@ discard block |
||
72 | 72 | |
73 | 73 | // Allow css/js files to be disabled for this specific theme. |
74 | 74 | // Add the identifier as an array key. IE array('smf_script'); Some external files might not add identifiers, on those cases SMF uses its filename as reference. |
75 | - if (!isset($settings['disable_files'])) |
|
76 | - $settings['disable_files'] = array(); |
|
77 | -} |
|
75 | + if (!isset($settings['disable_files'])) { |
|
76 | + $settings['disable_files'] = array(); |
|
77 | + } |
|
78 | + } |
|
78 | 79 | |
79 | 80 | /** |
80 | 81 | * The main sub template above the content. |
@@ -121,8 +122,9 @@ discard block |
||
121 | 122 | echo ' |
122 | 123 | <meta'; |
123 | 124 | |
124 | - foreach ($meta_tag as $meta_key => $meta_value) |
|
125 | - echo ' ', $meta_key, '="', $meta_value, '"'; |
|
125 | + foreach ($meta_tag as $meta_key => $meta_value) { |
|
126 | + echo ' ', $meta_key, '="', $meta_value, '"'; |
|
127 | + } |
|
126 | 128 | |
127 | 129 | echo '>'; |
128 | 130 | } |
@@ -133,14 +135,16 @@ discard block |
||
133 | 135 | <meta name="theme-color" content="#557EA0">'; |
134 | 136 | |
135 | 137 | // Please don't index these Mr Robot. |
136 | - if (!empty($context['robot_no_index'])) |
|
137 | - echo ' |
|
138 | + if (!empty($context['robot_no_index'])) { |
|
139 | + echo ' |
|
138 | 140 | <meta name="robots" content="noindex">'; |
141 | + } |
|
139 | 142 | |
140 | 143 | // Present a canonical url for search engines to prevent duplicate content in their indices. |
141 | - if (!empty($context['canonical_url'])) |
|
142 | - echo ' |
|
144 | + if (!empty($context['canonical_url'])) { |
|
145 | + echo ' |
|
143 | 146 | <link rel="canonical" href="', $context['canonical_url'], '">'; |
147 | + } |
|
144 | 148 | |
145 | 149 | // Show all the relative links, such as help, search, contents, and the like. |
146 | 150 | echo ' |
@@ -149,24 +153,28 @@ discard block |
||
149 | 153 | <link rel="search" href="' . $scripturl . '?action=search">' : ''); |
150 | 154 | |
151 | 155 | // If RSS feeds are enabled, advertise the presence of one. |
152 | - if (!empty($modSettings['xmlnews_enable']) && (!empty($modSettings['allow_guestAccess']) || $context['user']['is_logged'])) |
|
153 | - echo ' |
|
156 | + if (!empty($modSettings['xmlnews_enable']) && (!empty($modSettings['allow_guestAccess']) || $context['user']['is_logged'])) { |
|
157 | + echo ' |
|
154 | 158 | <link rel="alternate" type="application/rss+xml" title="', $context['forum_name_html_safe'], ' - ', $txt['rss'], '" href="', $scripturl, '?action=.xml;type=rss2', !empty($context['current_board']) ? ';board=' . $context['current_board'] : '', '"> |
155 | 159 | <link rel="alternate" type="application/atom+xml" title="', $context['forum_name_html_safe'], ' - ', $txt['atom'], '" href="', $scripturl, '?action=.xml;type=atom', !empty($context['current_board']) ? ';board=' . $context['current_board'] : '', '">'; |
160 | + } |
|
156 | 161 | |
157 | 162 | // If we're viewing a topic, these should be the previous and next topics, respectively. |
158 | - if (!empty($context['links']['next'])) |
|
159 | - echo ' |
|
163 | + if (!empty($context['links']['next'])) { |
|
164 | + echo ' |
|
160 | 165 | <link rel="next" href="', $context['links']['next'], '">'; |
166 | + } |
|
161 | 167 | |
162 | - if (!empty($context['links']['prev'])) |
|
163 | - echo ' |
|
168 | + if (!empty($context['links']['prev'])) { |
|
169 | + echo ' |
|
164 | 170 | <link rel="prev" href="', $context['links']['prev'], '">'; |
171 | + } |
|
165 | 172 | |
166 | 173 | // If we're in a board, or a topic for that matter, the index will be the board's index. |
167 | - if (!empty($context['current_board'])) |
|
168 | - echo ' |
|
174 | + if (!empty($context['current_board'])) { |
|
175 | + echo ' |
|
169 | 176 | <link rel="index" href="', $scripturl, '?board=', $context['current_board'], '.0">'; |
177 | + } |
|
170 | 178 | |
171 | 179 | // Output any remaining HTML headers. (from mods, maybe?) |
172 | 180 | echo $context['html_headers']; |
@@ -199,20 +207,22 @@ discard block |
||
199 | 207 | <li> |
200 | 208 | <a href="', $scripturl, '?action=profile"', !empty($context['self_profile']) ? ' class="active"' : '', ' id="profile_menu_top" onclick="return false;">'; |
201 | 209 | |
202 | - if (!empty($context['user']['avatar'])) |
|
203 | - echo $context['user']['avatar']['image']; |
|
210 | + if (!empty($context['user']['avatar'])) { |
|
211 | + echo $context['user']['avatar']['image']; |
|
212 | + } |
|
204 | 213 | |
205 | 214 | echo $context['user']['name'], '</a> |
206 | 215 | <div id="profile_menu" class="top_menu"></div> |
207 | 216 | </li>'; |
208 | 217 | |
209 | 218 | // Secondly, PMs if we're doing them |
210 | - if ($context['allow_pm']) |
|
211 | - echo ' |
|
219 | + if ($context['allow_pm']) { |
|
220 | + echo ' |
|
212 | 221 | <li> |
213 | 222 | <a href="', $scripturl, '?action=pm"', !empty($context['self_pm']) ? ' class="active"' : '', ' id="pm_menu_top">', $txt['pm_short'], !empty($context['user']['unread_messages']) ? ' <span class="amt">' . $context['user']['unread_messages'] . '</span>' : '', '</a> |
214 | 223 | <div id="pm_menu" class="top_menu scrollable"></div> |
215 | 224 | </li>'; |
225 | + } |
|
216 | 226 | |
217 | 227 | // Thirdly, alerts |
218 | 228 | echo ' |
@@ -227,17 +237,18 @@ discard block |
||
227 | 237 | } |
228 | 238 | // Otherwise they're a guest. Ask them to either register or login. |
229 | 239 | else |
230 | - if (empty($maintenance)) |
|
231 | - echo ' |
|
240 | + if (empty($maintenance)) { |
|
241 | + echo ' |
|
232 | 242 | <ul class="floatleft welcome"> |
233 | 243 | <li>', sprintf($txt[$context['can_register'] ? 'welcome_guest_register' : 'welcome_guest'], $txt['guest_title'], $context['forum_name_html_safe'], $scripturl . '?action=login', 'return reqOverlayDiv(this.href, ' . JavaScriptEscape($txt['login']) . ');', $scripturl . '?action=signup'), '</li> |
234 | 244 | </ul>'; |
235 | - else |
|
236 | - // In maintenance mode, only login is allowed and don't show OverlayDiv |
|
245 | + } else { |
|
246 | + // In maintenance mode, only login is allowed and don't show OverlayDiv |
|
237 | 247 | echo ' |
238 | 248 | <ul class="floatleft welcome"> |
239 | 249 | <li>', sprintf($txt['welcome_guest'], $txt['guest_title'], '', $scripturl. '?action=login', 'return true;'), '</li> |
240 | 250 | </ul>'; |
251 | + } |
|
241 | 252 | |
242 | 253 | if (!empty($modSettings['userLanguage']) && !empty($context['languages']) && count($context['languages']) > 1) |
243 | 254 | { |
@@ -245,9 +256,10 @@ discard block |
||
245 | 256 | <form id="languages_form" method="get" class="floatright"> |
246 | 257 | <select id="language_select" name="language" onchange="this.form.submit()">'; |
247 | 258 | |
248 | - foreach ($context['languages'] as $language) |
|
249 | - echo ' |
|
259 | + foreach ($context['languages'] as $language) { |
|
260 | + echo ' |
|
250 | 261 | <option value="', $language['filename'], '"', isset($context['user']['language']) && $context['user']['language'] == $language['filename'] ? ' selected="selected"' : '', '>', str_replace('-utf8', '', $language['name']), '</option>'; |
262 | + } |
|
251 | 263 | |
252 | 264 | echo ' |
253 | 265 | </select> |
@@ -271,32 +283,37 @@ discard block |
||
271 | 283 | <option value="all"', ($selected == 'all' ? ' selected' : ''), '>', $txt['search_entireforum'], ' </option>'; |
272 | 284 | |
273 | 285 | // Can't limit it to a specific topic if we are not in one |
274 | - if (!empty($context['current_topic'])) |
|
275 | - echo ' |
|
286 | + if (!empty($context['current_topic'])) { |
|
287 | + echo ' |
|
276 | 288 | <option value="topic"', ($selected == 'current_topic' ? ' selected' : ''), '>', $txt['search_thistopic'], '</option>'; |
289 | + } |
|
277 | 290 | |
278 | 291 | // Can't limit it to a specific board if we are not in one |
279 | - if (!empty($context['current_board'])) |
|
280 | - echo ' |
|
292 | + if (!empty($context['current_board'])) { |
|
293 | + echo ' |
|
281 | 294 | <option value="board"', ($selected == 'current_board' ? ' selected' : ''), '>', $txt['search_thisbrd'], '</option>'; |
295 | + } |
|
282 | 296 | |
283 | 297 | // Can't search for members if we can't see the memberlist |
284 | - if (!empty($context['allow_memberlist'])) |
|
285 | - echo ' |
|
298 | + if (!empty($context['allow_memberlist'])) { |
|
299 | + echo ' |
|
286 | 300 | <option value="members"', ($selected == 'members' ? ' selected' : ''), '>', $txt['search_members'], ' </option>'; |
301 | + } |
|
287 | 302 | |
288 | 303 | echo ' |
289 | 304 | </select>'; |
290 | 305 | |
291 | 306 | // Search within current topic? |
292 | - if (!empty($context['current_topic'])) |
|
293 | - echo ' |
|
307 | + if (!empty($context['current_topic'])) { |
|
308 | + echo ' |
|
294 | 309 | <input type="hidden" name="sd_topic" value="', $context['current_topic'], '">'; |
310 | + } |
|
295 | 311 | |
296 | 312 | // If we're on a certain board, limit it to this board ;). |
297 | - elseif (!empty($context['current_board'])) |
|
298 | - echo ' |
|
313 | + elseif (!empty($context['current_board'])) { |
|
314 | + echo ' |
|
299 | 315 | <input type="hidden" name="sd_brd" value="', $context['current_board'], '">'; |
316 | + } |
|
300 | 317 | |
301 | 318 | echo ' |
302 | 319 | <input type="submit" name="search2" value="', $txt['search'], '" class="button"> |
@@ -328,12 +345,13 @@ discard block |
||
328 | 345 | </div>'; |
329 | 346 | |
330 | 347 | // Show a random news item? (or you could pick one from news_lines...) |
331 | - if (!empty($settings['enable_news']) && !empty($context['random_news_line'])) |
|
332 | - echo ' |
|
348 | + if (!empty($settings['enable_news']) && !empty($context['random_news_line'])) { |
|
349 | + echo ' |
|
333 | 350 | <div class="news"> |
334 | 351 | <h2>', $txt['news'], ': </h2> |
335 | 352 | <p>', $context['random_news_line'], '</p> |
336 | 353 | </div>'; |
354 | + } |
|
337 | 355 | |
338 | 356 | echo ' |
339 | 357 | <hr class="clear"> |
@@ -392,9 +410,10 @@ discard block |
||
392 | 410 | </ul>'; |
393 | 411 | |
394 | 412 | // Show the load time? |
395 | - if ($context['show_load_time']) |
|
396 | - echo ' |
|
413 | + if ($context['show_load_time']) { |
|
414 | + echo ' |
|
397 | 415 | <p>', sprintf($txt['page_created_full'], $context['load_time'], $context['load_queries']), '</p>'; |
416 | + } |
|
398 | 417 | |
399 | 418 | echo ' |
400 | 419 | </div> |
@@ -425,18 +444,20 @@ discard block |
||
425 | 444 | global $context, $shown_linktree, $scripturl, $txt; |
426 | 445 | |
427 | 446 | // If linktree is empty, just return - also allow an override. |
428 | - if (empty($context['linktree']) || (!empty($context['dont_default_linktree']) && !$force_show)) |
|
429 | - return; |
|
447 | + if (empty($context['linktree']) || (!empty($context['dont_default_linktree']) && !$force_show)) { |
|
448 | + return; |
|
449 | + } |
|
430 | 450 | echo ' |
431 | 451 | <div class="navigate_section"> |
432 | 452 | <ul>'; |
433 | 453 | |
434 | - if ($context['user']['is_logged']) |
|
435 | - echo ' |
|
454 | + if ($context['user']['is_logged']) { |
|
455 | + echo ' |
|
436 | 456 | <li class="unread_links"> |
437 | 457 | <a href="', $scripturl, '?action=unread" title="', $txt['unread_since_visit'], '">', $txt['view_unread_category'], '</a> |
438 | 458 | <a href="', $scripturl, '?action=unreadreplies" title="', $txt['show_unread_replies'], '">', $txt['unread_replies'], '</a> |
439 | 459 | </li>'; |
460 | + } |
|
440 | 461 | |
441 | 462 | // Each tree item has a URL and name. Some may have extra_before and extra_after. |
442 | 463 | foreach ($context['linktree'] as $link_num => $tree) |
@@ -447,25 +468,29 @@ discard block |
||
447 | 468 | // Don't show a separator for the first one. |
448 | 469 | // Better here. Always points to the next level when the linktree breaks to a second line. |
449 | 470 | // Picked a better looking HTML entity, and added support for RTL plus a span for styling. |
450 | - if ($link_num != 0) |
|
451 | - echo ' |
|
471 | + if ($link_num != 0) { |
|
472 | + echo ' |
|
452 | 473 | <span class="dividers">', $context['right_to_left'] ? ' ◄ ' : ' ► ', '</span>'; |
474 | + } |
|
453 | 475 | |
454 | 476 | // Show something before the link? |
455 | - if (isset($tree['extra_before'])) |
|
456 | - echo $tree['extra_before'], ' '; |
|
477 | + if (isset($tree['extra_before'])) { |
|
478 | + echo $tree['extra_before'], ' '; |
|
479 | + } |
|
457 | 480 | |
458 | 481 | // Show the link, including a URL if it should have one. |
459 | - if (isset($tree['url'])) |
|
460 | - echo ' |
|
482 | + if (isset($tree['url'])) { |
|
483 | + echo ' |
|
461 | 484 | <a href="' . $tree['url'] . '"><span>' . $tree['name'] . '</span></a>'; |
462 | - else |
|
463 | - echo ' |
|
485 | + } else { |
|
486 | + echo ' |
|
464 | 487 | <span>' . $tree['name'] . '</span>'; |
488 | + } |
|
465 | 489 | |
466 | 490 | // Show something after the link...? |
467 | - if (isset($tree['extra_after'])) |
|
468 | - echo ' ', $tree['extra_after']; |
|
491 | + if (isset($tree['extra_after'])) { |
|
492 | + echo ' ', $tree['extra_after']; |
|
493 | + } |
|
469 | 494 | |
470 | 495 | echo ' |
471 | 496 | </li>'; |
@@ -516,13 +541,14 @@ discard block |
||
516 | 541 | echo ' |
517 | 542 | <ul>'; |
518 | 543 | |
519 | - foreach ($childbutton['sub_buttons'] as $grandchildbutton) |
|
520 | - echo ' |
|
544 | + foreach ($childbutton['sub_buttons'] as $grandchildbutton) { |
|
545 | + echo ' |
|
521 | 546 | <li> |
522 | 547 | <a href="', $grandchildbutton['href'], '"', isset($grandchildbutton['target']) ? ' target="' . $grandchildbutton['target'] . '"' : '', '> |
523 | 548 | ', $grandchildbutton['title'], !empty($grandchildbutton['amt']) ? ' <span class="amt">' . $grandchildbutton['amt'] . '</span>' : '', ' |
524 | 549 | </a> |
525 | 550 | </li>'; |
551 | + } |
|
526 | 552 | |
527 | 553 | echo ' |
528 | 554 | </ul>'; |
@@ -553,8 +579,9 @@ discard block |
||
553 | 579 | { |
554 | 580 | global $context, $txt; |
555 | 581 | |
556 | - if (!is_array($strip_options)) |
|
557 | - $strip_options = array(); |
|
582 | + if (!is_array($strip_options)) { |
|
583 | + $strip_options = array(); |
|
584 | + } |
|
558 | 585 | |
559 | 586 | // Create the buttons... |
560 | 587 | $buttons = array(); |
@@ -563,8 +590,9 @@ discard block |
||
563 | 590 | // As of 2.1, the 'test' for each button happens while the array is being generated. The extra 'test' check here is deprecated but kept for backward compatibility (update your mods, folks!) |
564 | 591 | if (!isset($value['test']) || !empty($context[$value['test']])) |
565 | 592 | { |
566 | - if (!isset($value['id'])) |
|
567 | - $value['id'] = $key; |
|
593 | + if (!isset($value['id'])) { |
|
594 | + $value['id'] = $key; |
|
595 | + } |
|
568 | 596 | |
569 | 597 | $button = ' |
570 | 598 | <a class="button button_strip_' . $key . (!empty($value['active']) ? ' active' : '') . (isset($value['class']) ? ' ' . $value['class'] : '') . '" ' . (!empty($value['url']) ? 'href="' . $value['url'] . '"' : '') . ' ' . (isset($value['custom']) ? ' ' . $value['custom'] : '') . '>' . $txt[$value['text']] . '</a>'; |
@@ -577,13 +605,15 @@ discard block |
||
577 | 605 | <div class="overview">'; |
578 | 606 | foreach ($value['sub_buttons'] as $element) |
579 | 607 | { |
580 | - if (isset($element['test']) && empty($context[$element['test']])) |
|
581 | - continue; |
|
608 | + if (isset($element['test']) && empty($context[$element['test']])) { |
|
609 | + continue; |
|
610 | + } |
|
582 | 611 | |
583 | 612 | $button .= ' |
584 | 613 | <a href="' . $element['url'] . '"><strong>' . $txt[$element['text']] . '</strong>'; |
585 | - if (isset($txt[$element['text'] . '_desc'])) |
|
586 | - $button .= '<br><span>' . $txt[$element['text'] . '_desc'] . '</span>'; |
|
614 | + if (isset($txt[$element['text'] . '_desc'])) { |
|
615 | + $button .= '<br><span>' . $txt[$element['text'] . '_desc'] . '</span>'; |
|
616 | + } |
|
587 | 617 | $button .= '</a>'; |
588 | 618 | } |
589 | 619 | $button .= ' |
@@ -597,8 +627,9 @@ discard block |
||
597 | 627 | } |
598 | 628 | |
599 | 629 | // No buttons? No button strip either. |
600 | - if (empty($buttons)) |
|
601 | - return; |
|
630 | + if (empty($buttons)) { |
|
631 | + return; |
|
632 | + } |
|
602 | 633 | |
603 | 634 | echo ' |
604 | 635 | <div class="buttonlist', !empty($direction) ? ' float' . $direction : '', '"', (empty($buttons) ? ' style="display: none;"' : ''), (!empty($strip_options['id']) ? ' id="' . $strip_options['id'] . '"' : ''), '> |
@@ -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 | * Takes a message and parses it, returning nothing. |
@@ -31,8 +32,9 @@ discard block |
||
31 | 32 | global $user_info, $modSettings, $context, $sourcedir; |
32 | 33 | |
33 | 34 | // This line makes all languages *theoretically* work even with the wrong charset ;). |
34 | - if (empty($context['utf8'])) |
|
35 | - $message = preg_replace('~&#(\d{4,5}|[2-9]\d{2,4}|1[2-9]\d);~', '&#$1;', $message); |
|
35 | + if (empty($context['utf8'])) { |
|
36 | + $message = preg_replace('~&#(\d{4,5}|[2-9]\d{2,4}|1[2-9]\d);~', '&#$1;', $message); |
|
37 | + } |
|
36 | 38 | |
37 | 39 | // Clean up after nobbc ;). |
38 | 40 | $message = preg_replace_callback('~\[nobbc\](.+?)\[/nobbc\]~is', function($a) |
@@ -47,17 +49,19 @@ discard block |
||
47 | 49 | $message = preg_replace('~\.{100,}~', '...', $message); |
48 | 50 | |
49 | 51 | // Trim off trailing quotes - these often happen by accident. |
50 | - while (substr($message, -7) == '[quote]') |
|
51 | - $message = substr($message, 0, -7); |
|
52 | - while (substr($message, 0, 8) == '[/quote]') |
|
53 | - $message = substr($message, 8); |
|
52 | + while (substr($message, -7) == '[quote]') { |
|
53 | + $message = substr($message, 0, -7); |
|
54 | + } |
|
55 | + while (substr($message, 0, 8) == '[/quote]') { |
|
56 | + $message = substr($message, 8); |
|
57 | + } |
|
54 | 58 | |
55 | 59 | // Find all code blocks, work out whether we'd be parsing them, then ensure they are all closed. |
56 | 60 | $in_tag = false; |
57 | 61 | $had_tag = false; |
58 | 62 | $codeopen = 0; |
59 | - if (preg_match_all('~(\[(/)*code(?:=[^\]]+)?\])~is', $message, $matches)) |
|
60 | - foreach ($matches[0] as $index => $dummy) |
|
63 | + if (preg_match_all('~(\[(/)*code(?:=[^\]]+)?\])~is', $message, $matches)) { |
|
64 | + foreach ($matches[0] as $index => $dummy) |
|
61 | 65 | { |
62 | 66 | // Closing? |
63 | 67 | if (!empty($matches[2][$index])) |
@@ -65,6 +69,7 @@ discard block |
||
65 | 69 | // If it's closing and we're not in a tag we need to open it... |
66 | 70 | if (!$in_tag) |
67 | 71 | $codeopen = true; |
72 | + } |
|
68 | 73 | // Either way we ain't in one any more. |
69 | 74 | $in_tag = false; |
70 | 75 | } |
@@ -73,17 +78,20 @@ discard block |
||
73 | 78 | { |
74 | 79 | $had_tag = true; |
75 | 80 | // If we're in a tag don't do nought! |
76 | - if (!$in_tag) |
|
77 | - $in_tag = true; |
|
81 | + if (!$in_tag) { |
|
82 | + $in_tag = true; |
|
83 | + } |
|
78 | 84 | } |
79 | 85 | } |
80 | 86 | |
81 | 87 | // If we have an open tag, close it. |
82 | - if ($in_tag) |
|
83 | - $message .= '[/code]'; |
|
88 | + if ($in_tag) { |
|
89 | + $message .= '[/code]'; |
|
90 | + } |
|
84 | 91 | // Open any ones that need to be open, only if we've never had a tag. |
85 | - if ($codeopen && !$had_tag) |
|
86 | - $message = '[code]' . $message; |
|
92 | + if ($codeopen && !$had_tag) { |
|
93 | + $message = '[code]' . $message; |
|
94 | + } |
|
87 | 95 | |
88 | 96 | // Replace code BBC with placeholders. We'll restore them at the end. |
89 | 97 | $parts = preg_split('~(\[/code\]|\[code(?:=[^\]]+)?\])~i', $message, -1, PREG_SPLIT_DELIM_CAPTURE); |
@@ -108,23 +116,26 @@ discard block |
||
108 | 116 | fixTags($message); |
109 | 117 | |
110 | 118 | // Replace /me.+?\n with [me=name]dsf[/me]\n. |
111 | - if (strpos($user_info['name'], '[') !== false || strpos($user_info['name'], ']') !== false || strpos($user_info['name'], '\'') !== false || strpos($user_info['name'], '"') !== false) |
|
112 | - $message = preg_replace('~(\A|\n)/me(?: | )([^\n]*)(?:\z)?~i', '$1[me="' . $user_info['name'] . '"]$2[/me]', $message); |
|
113 | - else |
|
114 | - $message = preg_replace('~(\A|\n)/me(?: | )([^\n]*)(?:\z)?~i', '$1[me=' . $user_info['name'] . ']$2[/me]', $message); |
|
119 | + if (strpos($user_info['name'], '[') !== false || strpos($user_info['name'], ']') !== false || strpos($user_info['name'], '\'') !== false || strpos($user_info['name'], '"') !== false) { |
|
120 | + $message = preg_replace('~(\A|\n)/me(?: | )([^\n]*)(?:\z)?~i', '$1[me="' . $user_info['name'] . '"]$2[/me]', $message); |
|
121 | + } else { |
|
122 | + $message = preg_replace('~(\A|\n)/me(?: | )([^\n]*)(?:\z)?~i', '$1[me=' . $user_info['name'] . ']$2[/me]', $message); |
|
123 | + } |
|
115 | 124 | |
116 | 125 | if (!$previewing && strpos($message, '[html]') !== false) |
117 | 126 | { |
118 | - if (allowedTo('admin_forum')) |
|
119 | - $message = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m) { |
|
127 | + if (allowedTo('admin_forum')) { |
|
128 | + $message = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m) { |
|
120 | 129 | return '[html]' . strtr(un_htmlspecialchars($m[1]), array("\n" => ' ', ' ' => '  ', '[' => '[', ']' => ']')) . '[/html]'; |
130 | + } |
|
121 | 131 | }, $message); |
122 | 132 | |
123 | 133 | // We should edit them out, or else if an admin edits the message they will get shown... |
124 | 134 | else |
125 | 135 | { |
126 | - while (strpos($message, '[html]') !== false) |
|
127 | - $message = preg_replace('~\[[/]?html\]~i', '', $message); |
|
136 | + while (strpos($message, '[html]') !== false) { |
|
137 | + $message = preg_replace('~\[[/]?html\]~i', '', $message); |
|
138 | + } |
|
128 | 139 | } |
129 | 140 | } |
130 | 141 | |
@@ -146,10 +157,12 @@ discard block |
||
146 | 157 | |
147 | 158 | $list_open = substr_count($message, '[list]') + substr_count($message, '[list '); |
148 | 159 | $list_close = substr_count($message, '[/list]'); |
149 | - if ($list_close - $list_open > 0) |
|
150 | - $message = str_repeat('[list]', $list_close - $list_open) . $message; |
|
151 | - if ($list_open - $list_close > 0) |
|
152 | - $message = $message . str_repeat('[/list]', $list_open - $list_close); |
|
160 | + if ($list_close - $list_open > 0) { |
|
161 | + $message = str_repeat('[list]', $list_close - $list_open) . $message; |
|
162 | + } |
|
163 | + if ($list_open - $list_close > 0) { |
|
164 | + $message = $message . str_repeat('[/list]', $list_open - $list_close); |
|
165 | + } |
|
153 | 166 | |
154 | 167 | $mistake_fixes = array( |
155 | 168 | // Find [table]s not followed by [tr]. |
@@ -198,8 +211,9 @@ discard block |
||
198 | 211 | ); |
199 | 212 | |
200 | 213 | // Fix up some use of tables without [tr]s, etc. (it has to be done more than once to catch it all.) |
201 | - for ($j = 0; $j < 3; $j++) |
|
202 | - $message = preg_replace(array_keys($mistake_fixes), $mistake_fixes, $message); |
|
214 | + for ($j = 0; $j < 3; $j++) { |
|
215 | + $message = preg_replace(array_keys($mistake_fixes), $mistake_fixes, $message); |
|
216 | + } |
|
203 | 217 | |
204 | 218 | // Remove empty bbc from the sections outside the code tags |
205 | 219 | $allowedEmpty = array( |
@@ -210,24 +224,28 @@ discard block |
||
210 | 224 | require_once($sourcedir . '/Subs.php'); |
211 | 225 | |
212 | 226 | $alltags = array(); |
213 | - foreach (($codes = parse_bbc(false)) as $code) |
|
214 | - if (!in_array($code['tag'], $allowedEmpty)) |
|
227 | + foreach (($codes = parse_bbc(false)) as $code) { |
|
228 | + if (!in_array($code['tag'], $allowedEmpty)) |
|
215 | 229 | $alltags[] = $code['tag']; |
230 | + } |
|
216 | 231 | |
217 | 232 | $alltags_regex = '\b' . implode("\b|\b", array_unique($alltags)) . '\b'; |
218 | 233 | |
219 | - while (preg_match('~\[(' . $alltags_regex . ')[^\]]*\]\s*\[/\1\]\s?~i', $message)) |
|
220 | - $message = preg_replace('~\[(' . $alltags_regex . ')[^\]]*\]\s*\[/\1\]\s?~i', '', $message); |
|
234 | + while (preg_match('~\[(' . $alltags_regex . ')[^\]]*\]\s*\[/\1\]\s?~i', $message)) { |
|
235 | + $message = preg_replace('~\[(' . $alltags_regex . ')[^\]]*\]\s*\[/\1\]\s?~i', '', $message); |
|
236 | + } |
|
221 | 237 | |
222 | 238 | // Restore code blocks |
223 | - if (!empty($code_tags)) |
|
224 | - $message = str_replace(array_keys($code_tags), array_values($code_tags), $message); |
|
239 | + if (!empty($code_tags)) { |
|
240 | + $message = str_replace(array_keys($code_tags), array_values($code_tags), $message); |
|
241 | + } |
|
225 | 242 | |
226 | 243 | // Restore white space entities |
227 | - if (!$previewing) |
|
228 | - $message = strtr($message, array(' ' => ' ', "\n" => '<br>', $context['utf8'] ? "\xC2\xA0" : "\xA0" => ' ')); |
|
229 | - else |
|
230 | - $message = strtr($message, array(' ' => ' ', $context['utf8'] ? "\xC2\xA0" : "\xA0" => ' ')); |
|
244 | + if (!$previewing) { |
|
245 | + $message = strtr($message, array(' ' => ' ', "\n" => '<br>', $context['utf8'] ? "\xC2\xA0" : "\xA0" => ' ')); |
|
246 | + } else { |
|
247 | + $message = strtr($message, array(' ' => ' ', $context['utf8'] ? "\xC2\xA0" : "\xA0" => ' ')); |
|
248 | + } |
|
231 | 249 | |
232 | 250 | // Now let's quickly clean up things that will slow our parser (which are common in posted code.) |
233 | 251 | $message = strtr($message, array('[]' => '[]', '['' => '['')); |
@@ -270,8 +288,9 @@ discard block |
||
270 | 288 | return "[time]" . timeformat("$m[1]", false) . "[/time]"; |
271 | 289 | }, $message); |
272 | 290 | |
273 | - if (!empty($code_tags)) |
|
274 | - $message = str_replace(array_keys($code_tags), array_values($code_tags), $message); |
|
291 | + if (!empty($code_tags)) { |
|
292 | + $message = str_replace(array_keys($code_tags), array_values($code_tags), $message); |
|
293 | + } |
|
275 | 294 | |
276 | 295 | // Change breaks back to \n's and &nsbp; back to spaces. |
277 | 296 | return preg_replace('~<br( /)?' . '>~', "\n", str_replace(' ', ' ', $message)); |
@@ -352,8 +371,9 @@ discard block |
||
352 | 371 | ); |
353 | 372 | |
354 | 373 | // Fix each type of tag. |
355 | - foreach ($fixArray as $param) |
|
356 | - fixTag($message, $param['tag'], $param['protocols'], $param['embeddedUrl'], $param['hasEqualSign'], !empty($param['hasExtra'])); |
|
374 | + foreach ($fixArray as $param) { |
|
375 | + fixTag($message, $param['tag'], $param['protocols'], $param['embeddedUrl'], $param['hasEqualSign'], !empty($param['hasExtra'])); |
|
376 | + } |
|
357 | 377 | |
358 | 378 | // Now fix possible security problems with images loading links automatically... |
359 | 379 | $message = preg_replace_callback('~(\[img.*?\])(.+?)\[/img\]~is', function($m) |
@@ -378,10 +398,11 @@ discard block |
||
378 | 398 | { |
379 | 399 | global $boardurl, $scripturl; |
380 | 400 | |
381 | - if (preg_match('~^([^:]+://[^/]+)~', $boardurl, $match) != 0) |
|
382 | - $domain_url = $match[1]; |
|
383 | - else |
|
384 | - $domain_url = $boardurl . '/'; |
|
401 | + if (preg_match('~^([^:]+://[^/]+)~', $boardurl, $match) != 0) { |
|
402 | + $domain_url = $match[1]; |
|
403 | + } else { |
|
404 | + $domain_url = $boardurl . '/'; |
|
405 | + } |
|
385 | 406 | |
386 | 407 | $replaces = array(); |
387 | 408 | |
@@ -389,11 +410,11 @@ discard block |
||
389 | 410 | { |
390 | 411 | $quoted = preg_match('~\[(' . $myTag . ')="~', $message); |
391 | 412 | preg_match_all('~\[(' . $myTag . ')=' . ($quoted ? '"(.*?)"' : '([^\]]*?)') . '\](?:(.+?)\[/(' . $myTag . ')\])?~is', $message, $matches); |
413 | + } elseif ($hasEqualSign) { |
|
414 | + preg_match_all('~\[(' . $myTag . ')=([^\]]*?)\](?:(.+?)\[/(' . $myTag . ')\])?~is', $message, $matches); |
|
415 | + } else { |
|
416 | + preg_match_all('~\[(' . $myTag . ($hasExtra ? '(?:[^\]]*?)' : '') . ')\](.+?)\[/(' . $myTag . ')\]~is', $message, $matches); |
|
392 | 417 | } |
393 | - elseif ($hasEqualSign) |
|
394 | - preg_match_all('~\[(' . $myTag . ')=([^\]]*?)\](?:(.+?)\[/(' . $myTag . ')\])?~is', $message, $matches); |
|
395 | - else |
|
396 | - preg_match_all('~\[(' . $myTag . ($hasExtra ? '(?:[^\]]*?)' : '') . ')\](.+?)\[/(' . $myTag . ')\]~is', $message, $matches); |
|
397 | 418 | |
398 | 419 | foreach ($matches[0] as $k => $dummy) |
399 | 420 | { |
@@ -406,49 +427,53 @@ discard block |
||
406 | 427 | foreach ($protocols as $protocol) |
407 | 428 | { |
408 | 429 | $found = strncasecmp($replace, $protocol . '://', strlen($protocol) + 3) === 0; |
409 | - if ($found) |
|
410 | - break; |
|
430 | + if ($found) { |
|
431 | + break; |
|
432 | + } |
|
411 | 433 | } |
412 | 434 | |
413 | 435 | if (!$found && $protocols[0] == 'http') |
414 | 436 | { |
415 | - if (substr($replace, 0, 1) == '/' && substr($replace, 0, 2) != '//') |
|
416 | - $replace = $domain_url . $replace; |
|
417 | - elseif (substr($replace, 0, 1) == '?') |
|
418 | - $replace = $scripturl . $replace; |
|
419 | - elseif (substr($replace, 0, 1) == '#' && $embeddedUrl) |
|
437 | + if (substr($replace, 0, 1) == '/' && substr($replace, 0, 2) != '//') { |
|
438 | + $replace = $domain_url . $replace; |
|
439 | + } elseif (substr($replace, 0, 1) == '?') { |
|
440 | + $replace = $scripturl . $replace; |
|
441 | + } elseif (substr($replace, 0, 1) == '#' && $embeddedUrl) |
|
420 | 442 | { |
421 | 443 | $replace = '#' . preg_replace('~[^A-Za-z0-9_\-#]~', '', substr($replace, 1)); |
422 | 444 | $this_tag = 'iurl'; |
423 | 445 | $this_close = 'iurl'; |
446 | + } elseif (substr($replace, 0, 2) != '//') { |
|
447 | + $replace = $protocols[0] . '://' . $replace; |
|
424 | 448 | } |
425 | - elseif (substr($replace, 0, 2) != '//') |
|
426 | - $replace = $protocols[0] . '://' . $replace; |
|
427 | - } |
|
428 | - elseif (!$found && $protocols[0] == 'ftp') |
|
429 | - $replace = $protocols[0] . '://' . preg_replace('~^(?!ftps?)[^:]+://~', '', $replace); |
|
430 | - elseif (!$found) |
|
431 | - $replace = $protocols[0] . '://' . $replace; |
|
432 | - |
|
433 | - if ($hasEqualSign && $embeddedUrl) |
|
434 | - $replaces[$matches[0][$k]] = '[' . $this_tag . '="' . $replace . '"]' . (empty($matches[4][$k]) ? '' : $matches[3][$k] . '[/' . $this_close . ']'); |
|
435 | - elseif ($hasEqualSign) |
|
436 | - $replaces['[' . $matches[1][$k] . '=' . $matches[2][$k] . ']'] = '[' . $this_tag . '=' . $replace . ']'; |
|
437 | - elseif ($embeddedUrl) |
|
438 | - $replaces['[' . $matches[1][$k] . ']' . $matches[2][$k] . '[/' . $matches[3][$k] . ']'] = '[' . $this_tag . '=' . $replace . ']' . $matches[2][$k] . '[/' . $this_close . ']'; |
|
439 | - else |
|
440 | - $replaces['[' . $matches[1][$k] . ']' . $matches[2][$k] . '[/' . $matches[3][$k] . ']'] = '[' . $this_tag . ']' . $replace . '[/' . $this_close . ']'; |
|
449 | + } elseif (!$found && $protocols[0] == 'ftp') { |
|
450 | + $replace = $protocols[0] . '://' . preg_replace('~^(?!ftps?)[^:]+://~', '', $replace); |
|
451 | + } elseif (!$found) { |
|
452 | + $replace = $protocols[0] . '://' . $replace; |
|
453 | + } |
|
454 | + |
|
455 | + if ($hasEqualSign && $embeddedUrl) { |
|
456 | + $replaces[$matches[0][$k]] = '[' . $this_tag . '="' . $replace . '"]' . (empty($matches[4][$k]) ? '' : $matches[3][$k] . '[/' . $this_close . ']'); |
|
457 | + } elseif ($hasEqualSign) { |
|
458 | + $replaces['[' . $matches[1][$k] . '=' . $matches[2][$k] . ']'] = '[' . $this_tag . '=' . $replace . ']'; |
|
459 | + } elseif ($embeddedUrl) { |
|
460 | + $replaces['[' . $matches[1][$k] . ']' . $matches[2][$k] . '[/' . $matches[3][$k] . ']'] = '[' . $this_tag . '=' . $replace . ']' . $matches[2][$k] . '[/' . $this_close . ']'; |
|
461 | + } else { |
|
462 | + $replaces['[' . $matches[1][$k] . ']' . $matches[2][$k] . '[/' . $matches[3][$k] . ']'] = '[' . $this_tag . ']' . $replace . '[/' . $this_close . ']'; |
|
463 | + } |
|
441 | 464 | } |
442 | 465 | |
443 | 466 | foreach ($replaces as $k => $v) |
444 | 467 | { |
445 | - if ($k == $v) |
|
446 | - unset($replaces[$k]); |
|
468 | + if ($k == $v) { |
|
469 | + unset($replaces[$k]); |
|
470 | + } |
|
447 | 471 | } |
448 | 472 | |
449 | - if (!empty($replaces)) |
|
450 | - $message = strtr($message, $replaces); |
|
451 | -} |
|
473 | + if (!empty($replaces)) { |
|
474 | + $message = strtr($message, $replaces); |
|
475 | + } |
|
476 | + } |
|
452 | 477 | |
453 | 478 | /** |
454 | 479 | * This function sends an email to the specified recipient(s). |
@@ -492,8 +517,9 @@ discard block |
||
492 | 517 | } |
493 | 518 | |
494 | 519 | // Nothing left? Nothing else to do |
495 | - if (empty($to_array)) |
|
496 | - return true; |
|
520 | + if (empty($to_array)) { |
|
521 | + return true; |
|
522 | + } |
|
497 | 523 | |
498 | 524 | // Once upon a time, Hotmail could not interpret non-ASCII mails. |
499 | 525 | // In honour of those days, it's still called the 'hotmail fix'. |
@@ -510,15 +536,17 @@ discard block |
||
510 | 536 | } |
511 | 537 | |
512 | 538 | // Call this function recursively for the hotmail addresses. |
513 | - if (!empty($hotmail_to)) |
|
514 | - $mail_result = sendmail($hotmail_to, $subject, $message, $from, $message_id, $send_html, $priority, true, $is_private); |
|
539 | + if (!empty($hotmail_to)) { |
|
540 | + $mail_result = sendmail($hotmail_to, $subject, $message, $from, $message_id, $send_html, $priority, true, $is_private); |
|
541 | + } |
|
515 | 542 | |
516 | 543 | // The remaining addresses no longer need the fix. |
517 | 544 | $hotmail_fix = false; |
518 | 545 | |
519 | 546 | // No other addresses left? Return instantly. |
520 | - if (empty($to_array)) |
|
521 | - return $mail_result; |
|
547 | + if (empty($to_array)) { |
|
548 | + return $mail_result; |
|
549 | + } |
|
522 | 550 | } |
523 | 551 | |
524 | 552 | // Get rid of entities. |
@@ -543,13 +571,15 @@ discard block |
||
543 | 571 | $headers .= 'Return-Path: ' . (empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from']) . $line_break; |
544 | 572 | $headers .= 'Date: ' . gmdate('D, d M Y H:i:s') . ' -0000' . $line_break; |
545 | 573 | |
546 | - if ($message_id !== null && empty($modSettings['mail_no_message_id'])) |
|
547 | - $headers .= 'Message-ID: <' . md5($scripturl . microtime()) . '-' . $message_id . strstr(empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from'], '@') . '>' . $line_break; |
|
574 | + if ($message_id !== null && empty($modSettings['mail_no_message_id'])) { |
|
575 | + $headers .= 'Message-ID: <' . md5($scripturl . microtime()) . '-' . $message_id . strstr(empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from'], '@') . '>' . $line_break; |
|
576 | + } |
|
548 | 577 | $headers .= 'X-Mailer: SMF' . $line_break; |
549 | 578 | |
550 | 579 | // Pass this to the integration before we start modifying the output -- it'll make it easier later. |
551 | - if (in_array(false, call_integration_hook('integrate_outgoing_email', array(&$subject, &$message, &$headers, &$to_array)), true)) |
|
552 | - return false; |
|
580 | + if (in_array(false, call_integration_hook('integrate_outgoing_email', array(&$subject, &$message, &$headers, &$to_array)), true)) { |
|
581 | + return false; |
|
582 | + } |
|
553 | 583 | |
554 | 584 | // Save the original message... |
555 | 585 | $orig_message = $message; |
@@ -598,17 +628,19 @@ discard block |
||
598 | 628 | } |
599 | 629 | |
600 | 630 | // Are we using the mail queue, if so this is where we butt in... |
601 | - if ($priority != 0) |
|
602 | - return AddMailQueue(false, $to_array, $subject, $message, $headers, $send_html, $priority, $is_private); |
|
631 | + if ($priority != 0) { |
|
632 | + return AddMailQueue(false, $to_array, $subject, $message, $headers, $send_html, $priority, $is_private); |
|
633 | + } |
|
603 | 634 | |
604 | 635 | // If it's a priority mail, send it now - note though that this should NOT be used for sending many at once. |
605 | 636 | elseif (!empty($modSettings['mail_limit'])) |
606 | 637 | { |
607 | 638 | list ($last_mail_time, $mails_this_minute) = @explode('|', $modSettings['mail_recent']); |
608 | - if (empty($mails_this_minute) || time() > $last_mail_time + 60) |
|
609 | - $new_queue_stat = time() . '|' . 1; |
|
610 | - else |
|
611 | - $new_queue_stat = $last_mail_time . '|' . ((int) $mails_this_minute + 1); |
|
639 | + if (empty($mails_this_minute) || time() > $last_mail_time + 60) { |
|
640 | + $new_queue_stat = time() . '|' . 1; |
|
641 | + } else { |
|
642 | + $new_queue_stat = $last_mail_time . '|' . ((int) $mails_this_minute + 1); |
|
643 | + } |
|
612 | 644 | |
613 | 645 | updateSettings(array('mail_recent' => $new_queue_stat)); |
614 | 646 | } |
@@ -642,8 +674,7 @@ discard block |
||
642 | 674 | log_error(sprintf($txt['mail_send_unable'], $to)); |
643 | 675 | $mail_result = false; |
644 | 676 | } |
645 | - } |
|
646 | - catch(ErrorException $e) |
|
677 | + } catch(ErrorException $e) |
|
647 | 678 | { |
648 | 679 | log_error($e->getMessage(), 'general', $e->getFile(), $e->getLine()); |
649 | 680 | log_error(sprintf($txt['mail_send_unable'], $to)); |
@@ -653,12 +684,13 @@ discard block |
||
653 | 684 | |
654 | 685 | // Wait, wait, I'm still sending here! |
655 | 686 | @set_time_limit(300); |
656 | - if (function_exists('apache_reset_timeout')) |
|
657 | - @apache_reset_timeout(); |
|
687 | + if (function_exists('apache_reset_timeout')) { |
|
688 | + @apache_reset_timeout(); |
|
689 | + } |
|
658 | 690 | } |
691 | + } else { |
|
692 | + $mail_result = $mail_result && smtp_mail($to_array, $subject, $message, $headers); |
|
659 | 693 | } |
660 | - else |
|
661 | - $mail_result = $mail_result && smtp_mail($to_array, $subject, $message, $headers); |
|
662 | 694 | |
663 | 695 | // Everything go smoothly? |
664 | 696 | return $mail_result; |
@@ -684,8 +716,9 @@ discard block |
||
684 | 716 | static $cur_insert = array(); |
685 | 717 | static $cur_insert_len = 0; |
686 | 718 | |
687 | - if ($cur_insert_len == 0) |
|
688 | - $cur_insert = array(); |
|
719 | + if ($cur_insert_len == 0) { |
|
720 | + $cur_insert = array(); |
|
721 | + } |
|
689 | 722 | |
690 | 723 | // If we're flushing, make the final inserts - also if we're near the MySQL length limit! |
691 | 724 | if (($flush || $cur_insert_len > 800000) && !empty($cur_insert)) |
@@ -760,8 +793,9 @@ discard block |
||
760 | 793 | } |
761 | 794 | |
762 | 795 | // If they are using SSI there is a good chance obExit will never be called. So lets be nice and flush it for them. |
763 | - if (SMF === 'SSI' || SMF === 'BACKGROUND') |
|
764 | - return AddMailQueue(true); |
|
796 | + if (SMF === 'SSI' || SMF === 'BACKGROUND') { |
|
797 | + return AddMailQueue(true); |
|
798 | + } |
|
765 | 799 | |
766 | 800 | return true; |
767 | 801 | } |
@@ -792,23 +826,26 @@ discard block |
||
792 | 826 | 'sent' => array() |
793 | 827 | ); |
794 | 828 | |
795 | - if ($from === null) |
|
796 | - $from = array( |
|
829 | + if ($from === null) { |
|
830 | + $from = array( |
|
797 | 831 | 'id' => $user_info['id'], |
798 | 832 | 'name' => $user_info['name'], |
799 | 833 | 'username' => $user_info['username'] |
800 | 834 | ); |
835 | + } |
|
801 | 836 | |
802 | 837 | // This is the one that will go in their inbox. |
803 | 838 | $htmlmessage = $smcFunc['htmlspecialchars']($message, ENT_QUOTES); |
804 | 839 | preparsecode($htmlmessage); |
805 | 840 | $htmlsubject = strtr($smcFunc['htmlspecialchars']($subject), array("\r" => '', "\n" => '', "\t" => '')); |
806 | - if ($smcFunc['strlen']($htmlsubject) > 100) |
|
807 | - $htmlsubject = $smcFunc['substr']($htmlsubject, 0, 100); |
|
841 | + if ($smcFunc['strlen']($htmlsubject) > 100) { |
|
842 | + $htmlsubject = $smcFunc['substr']($htmlsubject, 0, 100); |
|
843 | + } |
|
808 | 844 | |
809 | 845 | // Make sure is an array |
810 | - if (!is_array($recipients)) |
|
811 | - $recipients = array($recipients); |
|
846 | + if (!is_array($recipients)) { |
|
847 | + $recipients = array($recipients); |
|
848 | + } |
|
812 | 849 | |
813 | 850 | // Integrated PMs |
814 | 851 | call_integration_hook('integrate_personal_message', array(&$recipients, &$from, &$subject, &$message)); |
@@ -836,21 +873,23 @@ discard block |
||
836 | 873 | 'usernames' => array_keys($usernames), |
837 | 874 | ) |
838 | 875 | ); |
839 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
840 | - if (isset($usernames[$smcFunc['strtolower']($row['member_name'])])) |
|
876 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
877 | + if (isset($usernames[$smcFunc['strtolower']($row['member_name'])])) |
|
841 | 878 | $usernames[$smcFunc['strtolower']($row['member_name'])] = $row['id_member']; |
879 | + } |
|
842 | 880 | $smcFunc['db_free_result']($request); |
843 | 881 | |
844 | 882 | // Replace the usernames with IDs. Drop usernames that couldn't be found. |
845 | - foreach ($recipients as $rec_type => $rec) |
|
846 | - foreach ($rec as $id => $member) |
|
883 | + foreach ($recipients as $rec_type => $rec) { |
|
884 | + foreach ($rec as $id => $member) |
|
847 | 885 | { |
848 | 886 | if (is_numeric($recipients[$rec_type][$id])) |
849 | 887 | continue; |
888 | + } |
|
850 | 889 | |
851 | - if (!empty($usernames[$member])) |
|
852 | - $recipients[$rec_type][$id] = $usernames[$member]; |
|
853 | - else |
|
890 | + if (!empty($usernames[$member])) { |
|
891 | + $recipients[$rec_type][$id] = $usernames[$member]; |
|
892 | + } else |
|
854 | 893 | { |
855 | 894 | $log['failed'][$id] = sprintf($txt['pm_error_user_not_found'], $recipients[$rec_type][$id]); |
856 | 895 | unset($recipients[$rec_type][$id]); |
@@ -888,8 +927,9 @@ discard block |
||
888 | 927 | $delete = false; |
889 | 928 | foreach ($criteria as $criterium) |
890 | 929 | { |
891 | - if (($criterium['t'] == 'mid' && $criterium['v'] == $from['id']) || ($criterium['t'] == 'gid' && in_array($criterium['v'], $user_info['groups'])) || ($criterium['t'] == 'sub' && strpos($subject, $criterium['v']) !== false) || ($criterium['t'] == 'msg' && strpos($message, $criterium['v']) !== false)) |
|
892 | - $delete = true; |
|
930 | + if (($criterium['t'] == 'mid' && $criterium['v'] == $from['id']) || ($criterium['t'] == 'gid' && in_array($criterium['v'], $user_info['groups'])) || ($criterium['t'] == 'sub' && strpos($subject, $criterium['v']) !== false) || ($criterium['t'] == 'msg' && strpos($message, $criterium['v']) !== false)) { |
|
931 | + $delete = true; |
|
932 | + } |
|
893 | 933 | // If we're adding and one criteria don't match then we stop! |
894 | 934 | elseif (!$row['is_or']) |
895 | 935 | { |
@@ -897,8 +937,9 @@ discard block |
||
897 | 937 | break; |
898 | 938 | } |
899 | 939 | } |
900 | - if ($delete) |
|
901 | - $deletes[$row['id_member']] = 1; |
|
940 | + if ($delete) { |
|
941 | + $deletes[$row['id_member']] = 1; |
|
942 | + } |
|
902 | 943 | } |
903 | 944 | $smcFunc['db_free_result']($request); |
904 | 945 | |
@@ -913,8 +954,9 @@ discard block |
||
913 | 954 | array( |
914 | 955 | ) |
915 | 956 | ); |
916 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
917 | - $message_limit_cache[$row['id_group']] = $row['max_messages']; |
|
957 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
958 | + $message_limit_cache[$row['id_group']] = $row['max_messages']; |
|
959 | + } |
|
918 | 960 | $smcFunc['db_free_result']($request); |
919 | 961 | } |
920 | 962 | |
@@ -922,8 +964,9 @@ discard block |
||
922 | 964 | require_once($sourcedir . '/Subs-Members.php'); |
923 | 965 | $pmReadGroups = groupsAllowedTo('pm_read'); |
924 | 966 | |
925 | - if (empty($modSettings['permission_enable_deny'])) |
|
926 | - $pmReadGroups['denied'] = array(); |
|
967 | + if (empty($modSettings['permission_enable_deny'])) { |
|
968 | + $pmReadGroups['denied'] = array(); |
|
969 | + } |
|
927 | 970 | |
928 | 971 | // Load their alert preferences |
929 | 972 | require_once($sourcedir . '/Subs-Notify.php'); |
@@ -955,8 +998,9 @@ discard block |
||
955 | 998 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
956 | 999 | { |
957 | 1000 | // Don't do anything for members to be deleted! |
958 | - if (isset($deletes[$row['id_member']])) |
|
959 | - continue; |
|
1001 | + if (isset($deletes[$row['id_member']])) { |
|
1002 | + continue; |
|
1003 | + } |
|
960 | 1004 | |
961 | 1005 | // Load the preferences for this member (if any) |
962 | 1006 | $prefs = !empty($notifyPrefs[$row['id_member']]) ? $notifyPrefs[$row['id_member']] : array(); |
@@ -977,8 +1021,9 @@ discard block |
||
977 | 1021 | { |
978 | 1022 | foreach ($groups as $id) |
979 | 1023 | { |
980 | - if (isset($message_limit_cache[$id]) && $message_limit != 0 && $message_limit < $message_limit_cache[$id]) |
|
981 | - $message_limit = $message_limit_cache[$id]; |
|
1024 | + if (isset($message_limit_cache[$id]) && $message_limit != 0 && $message_limit < $message_limit_cache[$id]) { |
|
1025 | + $message_limit = $message_limit_cache[$id]; |
|
1026 | + } |
|
982 | 1027 | } |
983 | 1028 | |
984 | 1029 | if ($message_limit > 0 && $message_limit <= $row['instant_messages']) |
@@ -1026,8 +1071,9 @@ discard block |
||
1026 | 1071 | $smcFunc['db_free_result']($request); |
1027 | 1072 | |
1028 | 1073 | // Only 'send' the message if there are any recipients left. |
1029 | - if (empty($all_to)) |
|
1030 | - return $log; |
|
1074 | + if (empty($all_to)) { |
|
1075 | + return $log; |
|
1076 | + } |
|
1031 | 1077 | |
1032 | 1078 | // Insert the message itself and then grab the last insert id. |
1033 | 1079 | $id_pm = $smcFunc['db_insert']('', |
@@ -1048,8 +1094,8 @@ discard block |
||
1048 | 1094 | if (!empty($id_pm)) |
1049 | 1095 | { |
1050 | 1096 | // If this is new we need to set it part of it's own conversation. |
1051 | - if (empty($pm_head)) |
|
1052 | - $smcFunc['db_query']('', ' |
|
1097 | + if (empty($pm_head)) { |
|
1098 | + $smcFunc['db_query']('', ' |
|
1053 | 1099 | UPDATE {db_prefix}personal_messages |
1054 | 1100 | SET id_pm_head = {int:id_pm_head} |
1055 | 1101 | WHERE id_pm = {int:id_pm_head}', |
@@ -1057,6 +1103,7 @@ discard block |
||
1057 | 1103 | 'id_pm_head' => $id_pm, |
1058 | 1104 | ) |
1059 | 1105 | ); |
1106 | + } |
|
1060 | 1107 | |
1061 | 1108 | // Some people think manually deleting personal_messages is fun... it's not. We protect against it though :) |
1062 | 1109 | $smcFunc['db_query']('', ' |
@@ -1072,8 +1119,9 @@ discard block |
||
1072 | 1119 | foreach ($all_to as $to) |
1073 | 1120 | { |
1074 | 1121 | $insertRows[] = array($id_pm, $to, in_array($to, $recipients['bcc']) ? 1 : 0, isset($deletes[$to]) ? 1 : 0, 1); |
1075 | - if (!in_array($to, $recipients['bcc'])) |
|
1076 | - $to_list[] = $to; |
|
1122 | + if (!in_array($to, $recipients['bcc'])) { |
|
1123 | + $to_list[] = $to; |
|
1124 | + } |
|
1077 | 1125 | } |
1078 | 1126 | |
1079 | 1127 | $smcFunc['db_insert']('insert', |
@@ -1091,9 +1139,9 @@ discard block |
||
1091 | 1139 | { |
1092 | 1140 | censorText($message); |
1093 | 1141 | $message = trim(un_htmlspecialchars(strip_tags(strtr(parse_bbc($smcFunc['htmlspecialchars']($message), false), array('<br>' => "\n", '</div>' => "\n", '</li>' => "\n", '[' => '[', ']' => ']'))))); |
1142 | + } else { |
|
1143 | + $message = ''; |
|
1094 | 1144 | } |
1095 | - else |
|
1096 | - $message = ''; |
|
1097 | 1145 | |
1098 | 1146 | $to_names = array(); |
1099 | 1147 | if (count($to_list) > 1) |
@@ -1106,8 +1154,9 @@ discard block |
||
1106 | 1154 | 'to_members' => $to_list, |
1107 | 1155 | ) |
1108 | 1156 | ); |
1109 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1110 | - $to_names[] = un_htmlspecialchars($row['real_name']); |
|
1157 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1158 | + $to_names[] = un_htmlspecialchars($row['real_name']); |
|
1159 | + } |
|
1111 | 1160 | $smcFunc['db_free_result']($request); |
1112 | 1161 | } |
1113 | 1162 | $replacements = array( |
@@ -1135,11 +1184,13 @@ discard block |
||
1135 | 1184 | loadLanguage('index+PersonalMessage'); |
1136 | 1185 | |
1137 | 1186 | // Add one to their unread and read message counts. |
1138 | - foreach ($all_to as $k => $id) |
|
1139 | - if (isset($deletes[$id])) |
|
1187 | + foreach ($all_to as $k => $id) { |
|
1188 | + if (isset($deletes[$id])) |
|
1140 | 1189 | unset($all_to[$k]); |
1141 | - if (!empty($all_to)) |
|
1142 | - updateMemberData($all_to, array('instant_messages' => '+', 'unread_messages' => '+', 'new_pm' => 1)); |
|
1190 | + } |
|
1191 | + if (!empty($all_to)) { |
|
1192 | + updateMemberData($all_to, array('instant_messages' => '+', 'unread_messages' => '+', 'new_pm' => 1)); |
|
1193 | + } |
|
1143 | 1194 | |
1144 | 1195 | return $log; |
1145 | 1196 | } |
@@ -1169,15 +1220,17 @@ discard block |
||
1169 | 1220 | // Let's, for now, assume there are only 'ish characters. |
1170 | 1221 | $simple = true; |
1171 | 1222 | |
1172 | - foreach ($matches[1] as $entity) |
|
1173 | - if ($entity > 128) |
|
1223 | + foreach ($matches[1] as $entity) { |
|
1224 | + if ($entity > 128) |
|
1174 | 1225 | $simple = false; |
1226 | + } |
|
1175 | 1227 | unset($matches); |
1176 | 1228 | |
1177 | - if ($simple) |
|
1178 | - $string = preg_replace_callback('~&#(\d{3,8});~', function($m) |
|
1229 | + if ($simple) { |
|
1230 | + $string = preg_replace_callback('~&#(\d{3,8});~', function($m) |
|
1179 | 1231 | { |
1180 | 1232 | return chr("$m[1]"); |
1233 | + } |
|
1181 | 1234 | }, $string); |
1182 | 1235 | else |
1183 | 1236 | { |
@@ -1185,8 +1238,9 @@ discard block |
||
1185 | 1238 | if (!$context['utf8'] && function_exists('iconv')) |
1186 | 1239 | { |
1187 | 1240 | $newstring = @iconv($context['character_set'], 'UTF-8', $string); |
1188 | - if ($newstring) |
|
1189 | - $string = $newstring; |
|
1241 | + if ($newstring) { |
|
1242 | + $string = $newstring; |
|
1243 | + } |
|
1190 | 1244 | } |
1191 | 1245 | |
1192 | 1246 | $string = preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $string); |
@@ -1202,23 +1256,25 @@ discard block |
||
1202 | 1256 | if (!$context['utf8'] && function_exists('iconv')) |
1203 | 1257 | { |
1204 | 1258 | $newstring = @iconv($context['character_set'], 'UTF-8', $string); |
1205 | - if ($newstring) |
|
1206 | - $string = $newstring; |
|
1259 | + if ($newstring) { |
|
1260 | + $string = $newstring; |
|
1261 | + } |
|
1207 | 1262 | } |
1208 | 1263 | |
1209 | 1264 | $entityConvert = function($m) |
1210 | 1265 | { |
1211 | 1266 | $c = $m[1]; |
1212 | - if (strlen($c) === 1 && ord($c[0]) <= 0x7F) |
|
1213 | - return $c; |
|
1214 | - elseif (strlen($c) === 2 && ord($c[0]) >= 0xC0 && ord($c[0]) <= 0xDF) |
|
1215 | - return "&#" . (((ord($c[0]) ^ 0xC0) << 6) + (ord($c[1]) ^ 0x80)) . ";"; |
|
1216 | - elseif (strlen($c) === 3 && ord($c[0]) >= 0xE0 && ord($c[0]) <= 0xEF) |
|
1217 | - return "&#" . (((ord($c[0]) ^ 0xE0) << 12) + ((ord($c[1]) ^ 0x80) << 6) + (ord($c[2]) ^ 0x80)) . ";"; |
|
1218 | - elseif (strlen($c) === 4 && ord($c[0]) >= 0xF0 && ord($c[0]) <= 0xF7) |
|
1219 | - return "&#" . (((ord($c[0]) ^ 0xF0) << 18) + ((ord($c[1]) ^ 0x80) << 12) + ((ord($c[2]) ^ 0x80) << 6) + (ord($c[3]) ^ 0x80)) . ";"; |
|
1220 | - else |
|
1221 | - return ""; |
|
1267 | + if (strlen($c) === 1 && ord($c[0]) <= 0x7F) { |
|
1268 | + return $c; |
|
1269 | + } elseif (strlen($c) === 2 && ord($c[0]) >= 0xC0 && ord($c[0]) <= 0xDF) { |
|
1270 | + return "&#" . (((ord($c[0]) ^ 0xC0) << 6) + (ord($c[1]) ^ 0x80)) . ";"; |
|
1271 | + } elseif (strlen($c) === 3 && ord($c[0]) >= 0xE0 && ord($c[0]) <= 0xEF) { |
|
1272 | + return "&#" . (((ord($c[0]) ^ 0xE0) << 12) + ((ord($c[1]) ^ 0x80) << 6) + (ord($c[2]) ^ 0x80)) . ";"; |
|
1273 | + } elseif (strlen($c) === 4 && ord($c[0]) >= 0xF0 && ord($c[0]) <= 0xF7) { |
|
1274 | + return "&#" . (((ord($c[0]) ^ 0xF0) << 18) + ((ord($c[1]) ^ 0x80) << 12) + ((ord($c[2]) ^ 0x80) << 6) + (ord($c[3]) ^ 0x80)) . ";"; |
|
1275 | + } else { |
|
1276 | + return ""; |
|
1277 | + } |
|
1222 | 1278 | }; |
1223 | 1279 | |
1224 | 1280 | // Convert all 'special' characters to HTML entities. |
@@ -1232,19 +1288,20 @@ discard block |
||
1232 | 1288 | $string = base64_encode($string); |
1233 | 1289 | |
1234 | 1290 | // Show the characterset and the transfer-encoding for header strings. |
1235 | - if ($with_charset) |
|
1236 | - $string = '=?' . $charset . '?B?' . $string . '?='; |
|
1291 | + if ($with_charset) { |
|
1292 | + $string = '=?' . $charset . '?B?' . $string . '?='; |
|
1293 | + } |
|
1237 | 1294 | |
1238 | 1295 | // Break it up in lines (mail body). |
1239 | - else |
|
1240 | - $string = chunk_split($string, 76, $line_break); |
|
1296 | + else { |
|
1297 | + $string = chunk_split($string, 76, $line_break); |
|
1298 | + } |
|
1241 | 1299 | |
1242 | 1300 | return array($charset, $string, 'base64'); |
1301 | + } else { |
|
1302 | + return array($charset, $string, '7bit'); |
|
1303 | + } |
|
1243 | 1304 | } |
1244 | - |
|
1245 | - else |
|
1246 | - return array($charset, $string, '7bit'); |
|
1247 | -} |
|
1248 | 1305 | |
1249 | 1306 | /** |
1250 | 1307 | * Sends mail, like mail() but over SMTP. |
@@ -1270,8 +1327,9 @@ discard block |
||
1270 | 1327 | if ($modSettings['mail_type'] == 3 && $modSettings['smtp_username'] != '' && $modSettings['smtp_password'] != '') |
1271 | 1328 | { |
1272 | 1329 | $socket = fsockopen($modSettings['smtp_host'], 110, $errno, $errstr, 2); |
1273 | - if (!$socket && (substr($modSettings['smtp_host'], 0, 5) == 'smtp.' || substr($modSettings['smtp_host'], 0, 11) == 'ssl://smtp.')) |
|
1274 | - $socket = fsockopen(strtr($modSettings['smtp_host'], array('smtp.' => 'pop.')), 110, $errno, $errstr, 2); |
|
1330 | + if (!$socket && (substr($modSettings['smtp_host'], 0, 5) == 'smtp.' || substr($modSettings['smtp_host'], 0, 11) == 'ssl://smtp.')) { |
|
1331 | + $socket = fsockopen(strtr($modSettings['smtp_host'], array('smtp.' => 'pop.')), 110, $errno, $errstr, 2); |
|
1332 | + } |
|
1275 | 1333 | |
1276 | 1334 | if ($socket) |
1277 | 1335 | { |
@@ -1293,11 +1351,13 @@ discard block |
||
1293 | 1351 | if (substr($modSettings['smtp_host'], 0, 4) == 'ssl:' && (empty($modSettings['smtp_port']) || $modSettings['smtp_port'] == 25)) |
1294 | 1352 | { |
1295 | 1353 | // ssl:hostname can cause fsocketopen to fail with a lookup failure, ensure it exists for this test. |
1296 | - if (substr($modSettings['smtp_host'], 0, 6) != 'ssl://') |
|
1297 | - $modSettings['smtp_host'] = str_replace('ssl:', 'ss://', $modSettings['smtp_host']); |
|
1354 | + if (substr($modSettings['smtp_host'], 0, 6) != 'ssl://') { |
|
1355 | + $modSettings['smtp_host'] = str_replace('ssl:', 'ss://', $modSettings['smtp_host']); |
|
1356 | + } |
|
1298 | 1357 | |
1299 | - if ($socket = fsockopen($modSettings['smtp_host'], 465, $errno, $errstr, 3)) |
|
1300 | - log_error($txt['smtp_port_ssl']); |
|
1358 | + if ($socket = fsockopen($modSettings['smtp_host'], 465, $errno, $errstr, 3)) { |
|
1359 | + log_error($txt['smtp_port_ssl']); |
|
1360 | + } |
|
1301 | 1361 | } |
1302 | 1362 | |
1303 | 1363 | // Unable to connect! Don't show any error message, but just log one and try to continue anyway. |
@@ -1309,26 +1369,30 @@ discard block |
||
1309 | 1369 | } |
1310 | 1370 | |
1311 | 1371 | // Wait for a response of 220, without "-" continuer. |
1312 | - if (!server_parse(null, $socket, '220')) |
|
1313 | - return false; |
|
1372 | + if (!server_parse(null, $socket, '220')) { |
|
1373 | + return false; |
|
1374 | + } |
|
1314 | 1375 | |
1315 | 1376 | // Try to determine the server's fully qualified domain name |
1316 | 1377 | // Can't rely on $_SERVER['SERVER_NAME'] because it can be spoofed on Apache |
1317 | 1378 | if (empty($helo)) |
1318 | 1379 | { |
1319 | 1380 | // See if we can get the domain name from the host itself |
1320 | - if (function_exists('gethostname')) |
|
1321 | - $helo = gethostname(); |
|
1322 | - elseif (function_exists('php_uname')) |
|
1323 | - $helo = php_uname('n'); |
|
1381 | + if (function_exists('gethostname')) { |
|
1382 | + $helo = gethostname(); |
|
1383 | + } elseif (function_exists('php_uname')) { |
|
1384 | + $helo = php_uname('n'); |
|
1385 | + } |
|
1324 | 1386 | |
1325 | 1387 | // If the hostname isn't a fully qualified domain name, we can use the host name from $boardurl instead |
1326 | - if (empty($helo) || strpos($helo, '.') === false || substr_compare($helo, '.local', -6) === 0 || (!empty($modSettings['tld_regex']) && !preg_match('/\.' . $modSettings['tld_regex'] . '$/u', $helo))) |
|
1327 | - $helo = parse_url($boardurl, PHP_URL_HOST); |
|
1388 | + if (empty($helo) || strpos($helo, '.') === false || substr_compare($helo, '.local', -6) === 0 || (!empty($modSettings['tld_regex']) && !preg_match('/\.' . $modSettings['tld_regex'] . '$/u', $helo))) { |
|
1389 | + $helo = parse_url($boardurl, PHP_URL_HOST); |
|
1390 | + } |
|
1328 | 1391 | |
1329 | 1392 | // This is one of those situations where 'www.' is undesirable |
1330 | - if (strpos($helo, 'www.') === 0) |
|
1331 | - $helo = substr($helo, 4); |
|
1393 | + if (strpos($helo, 'www.') === 0) { |
|
1394 | + $helo = substr($helo, 4); |
|
1395 | + } |
|
1332 | 1396 | } |
1333 | 1397 | |
1334 | 1398 | // SMTP = 1, SMTP - STARTTLS = 2 |
@@ -1341,8 +1405,9 @@ discard block |
||
1341 | 1405 | if ($modSettings['mail_type'] == 2 && preg_match("~250( |-)STARTTLS~mi", $response)) |
1342 | 1406 | { |
1343 | 1407 | // Send STARTTLS to enable encryption |
1344 | - if (!server_parse('STARTTLS', $socket, '220')) |
|
1345 | - return false; |
|
1408 | + if (!server_parse('STARTTLS', $socket, '220')) { |
|
1409 | + return false; |
|
1410 | + } |
|
1346 | 1411 | // Enable the encryption |
1347 | 1412 | // php 5.6+ fix |
1348 | 1413 | $crypto_method = STREAM_CRYPTO_METHOD_TLS_CLIENT; |
@@ -1353,30 +1418,35 @@ discard block |
||
1353 | 1418 | $crypto_method |= STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT; |
1354 | 1419 | } |
1355 | 1420 | |
1356 | - if (!@stream_socket_enable_crypto($socket, true, $crypto_method)) |
|
1357 | - return false; |
|
1421 | + if (!@stream_socket_enable_crypto($socket, true, $crypto_method)) { |
|
1422 | + return false; |
|
1423 | + } |
|
1358 | 1424 | // Send the EHLO command again |
1359 | - if (!server_parse('EHLO ' . $helo, $socket, null) == '250') |
|
1360 | - return false; |
|
1425 | + if (!server_parse('EHLO ' . $helo, $socket, null) == '250') { |
|
1426 | + return false; |
|
1427 | + } |
|
1361 | 1428 | } |
1362 | 1429 | |
1363 | - if (!server_parse('AUTH LOGIN', $socket, '334')) |
|
1364 | - return false; |
|
1430 | + if (!server_parse('AUTH LOGIN', $socket, '334')) { |
|
1431 | + return false; |
|
1432 | + } |
|
1365 | 1433 | // Send the username and password, encoded. |
1366 | - if (!server_parse(base64_encode($modSettings['smtp_username']), $socket, '334')) |
|
1367 | - return false; |
|
1434 | + if (!server_parse(base64_encode($modSettings['smtp_username']), $socket, '334')) { |
|
1435 | + return false; |
|
1436 | + } |
|
1368 | 1437 | // The password is already encoded ;) |
1369 | - if (!server_parse($modSettings['smtp_password'], $socket, '235')) |
|
1370 | - return false; |
|
1438 | + if (!server_parse($modSettings['smtp_password'], $socket, '235')) { |
|
1439 | + return false; |
|
1440 | + } |
|
1441 | + } elseif (!server_parse('HELO ' . $helo, $socket, '250')) { |
|
1442 | + return false; |
|
1371 | 1443 | } |
1372 | - elseif (!server_parse('HELO ' . $helo, $socket, '250')) |
|
1373 | - return false; |
|
1374 | - } |
|
1375 | - else |
|
1444 | + } else |
|
1376 | 1445 | { |
1377 | 1446 | // Just say "helo". |
1378 | - if (!server_parse('HELO ' . $helo, $socket, '250')) |
|
1379 | - return false; |
|
1447 | + if (!server_parse('HELO ' . $helo, $socket, '250')) { |
|
1448 | + return false; |
|
1449 | + } |
|
1380 | 1450 | } |
1381 | 1451 | |
1382 | 1452 | // Fix the message for any lines beginning with a period! (the first is ignored, you see.) |
@@ -1389,31 +1459,38 @@ discard block |
||
1389 | 1459 | // Reset the connection to send another email. |
1390 | 1460 | if ($i != 0) |
1391 | 1461 | { |
1392 | - if (!server_parse('RSET', $socket, '250')) |
|
1393 | - return false; |
|
1462 | + if (!server_parse('RSET', $socket, '250')) { |
|
1463 | + return false; |
|
1464 | + } |
|
1394 | 1465 | } |
1395 | 1466 | |
1396 | 1467 | // From, to, and then start the data... |
1397 | - if (!server_parse('MAIL FROM: <' . (empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from']) . '>', $socket, '250')) |
|
1398 | - return false; |
|
1399 | - if (!server_parse('RCPT TO: <' . $mail_to . '>', $socket, '250')) |
|
1400 | - return false; |
|
1401 | - if (!server_parse('DATA', $socket, '354')) |
|
1402 | - return false; |
|
1468 | + if (!server_parse('MAIL FROM: <' . (empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from']) . '>', $socket, '250')) { |
|
1469 | + return false; |
|
1470 | + } |
|
1471 | + if (!server_parse('RCPT TO: <' . $mail_to . '>', $socket, '250')) { |
|
1472 | + return false; |
|
1473 | + } |
|
1474 | + if (!server_parse('DATA', $socket, '354')) { |
|
1475 | + return false; |
|
1476 | + } |
|
1403 | 1477 | fputs($socket, 'Subject: ' . $subject . "\r\n"); |
1404 | - if (strlen($mail_to) > 0) |
|
1405 | - fputs($socket, 'To: <' . $mail_to . '>' . "\r\n"); |
|
1478 | + if (strlen($mail_to) > 0) { |
|
1479 | + fputs($socket, 'To: <' . $mail_to . '>' . "\r\n"); |
|
1480 | + } |
|
1406 | 1481 | fputs($socket, $headers . "\r\n\r\n"); |
1407 | 1482 | fputs($socket, $message . "\r\n"); |
1408 | 1483 | |
1409 | 1484 | // Send a ., or in other words "end of data". |
1410 | - if (!server_parse('.', $socket, '250')) |
|
1411 | - return false; |
|
1485 | + if (!server_parse('.', $socket, '250')) { |
|
1486 | + return false; |
|
1487 | + } |
|
1412 | 1488 | |
1413 | 1489 | // Almost done, almost done... don't stop me just yet! |
1414 | 1490 | @set_time_limit(300); |
1415 | - if (function_exists('apache_reset_timeout')) |
|
1416 | - @apache_reset_timeout(); |
|
1491 | + if (function_exists('apache_reset_timeout')) { |
|
1492 | + @apache_reset_timeout(); |
|
1493 | + } |
|
1417 | 1494 | } |
1418 | 1495 | fputs($socket, 'QUIT' . "\r\n"); |
1419 | 1496 | fclose($socket); |
@@ -1437,8 +1514,9 @@ discard block |
||
1437 | 1514 | { |
1438 | 1515 | global $txt; |
1439 | 1516 | |
1440 | - if ($message !== null) |
|
1441 | - fputs($socket, $message . "\r\n"); |
|
1517 | + if ($message !== null) { |
|
1518 | + fputs($socket, $message . "\r\n"); |
|
1519 | + } |
|
1442 | 1520 | |
1443 | 1521 | // No response yet. |
1444 | 1522 | $server_response = ''; |
@@ -1454,8 +1532,9 @@ discard block |
||
1454 | 1532 | $response .= $server_response; |
1455 | 1533 | } |
1456 | 1534 | |
1457 | - if ($code === null) |
|
1458 | - return substr($server_response, 0, 3); |
|
1535 | + if ($code === null) { |
|
1536 | + return substr($server_response, 0, 3); |
|
1537 | + } |
|
1459 | 1538 | |
1460 | 1539 | if (substr($server_response, 0, 3) != $code) |
1461 | 1540 | { |
@@ -1485,8 +1564,9 @@ discard block |
||
1485 | 1564 | // Create a pspell or enchant dictionary resource |
1486 | 1565 | $dict = spell_init(); |
1487 | 1566 | |
1488 | - if (!isset($_POST['spellstring']) || !$dict) |
|
1489 | - die; |
|
1567 | + if (!isset($_POST['spellstring']) || !$dict) { |
|
1568 | + die; |
|
1569 | + } |
|
1490 | 1570 | |
1491 | 1571 | // Construct a bit of Javascript code. |
1492 | 1572 | $context['spell_js'] = ' |
@@ -1504,8 +1584,9 @@ discard block |
||
1504 | 1584 | $check_word = explode('|', $alphas[$i]); |
1505 | 1585 | |
1506 | 1586 | // If the word is a known word, or spelled right... |
1507 | - if (in_array($smcFunc['strtolower']($check_word[0]), $known_words) || spell_check($dict, $check_word[0]) || !isset($check_word[2])) |
|
1508 | - continue; |
|
1587 | + if (in_array($smcFunc['strtolower']($check_word[0]), $known_words) || spell_check($dict, $check_word[0]) || !isset($check_word[2])) { |
|
1588 | + continue; |
|
1589 | + } |
|
1509 | 1590 | |
1510 | 1591 | // Find the word, and move up the "last occurrence" to here. |
1511 | 1592 | $found_words = true; |
@@ -1519,20 +1600,23 @@ discard block |
||
1519 | 1600 | if (!empty($suggestions)) |
1520 | 1601 | { |
1521 | 1602 | // But first check they aren't going to be censored - no naughty words! |
1522 | - foreach ($suggestions as $k => $word) |
|
1523 | - if ($suggestions[$k] != censorText($word)) |
|
1603 | + foreach ($suggestions as $k => $word) { |
|
1604 | + if ($suggestions[$k] != censorText($word)) |
|
1524 | 1605 | unset($suggestions[$k]); |
1606 | + } |
|
1525 | 1607 | |
1526 | - if (!empty($suggestions)) |
|
1527 | - $context['spell_js'] .= '"' . implode('", "', $suggestions) . '"'; |
|
1608 | + if (!empty($suggestions)) { |
|
1609 | + $context['spell_js'] .= '"' . implode('", "', $suggestions) . '"'; |
|
1610 | + } |
|
1528 | 1611 | } |
1529 | 1612 | |
1530 | 1613 | $context['spell_js'] .= ']),'; |
1531 | 1614 | } |
1532 | 1615 | |
1533 | 1616 | // If words were found, take off the last comma. |
1534 | - if ($found_words) |
|
1535 | - $context['spell_js'] = substr($context['spell_js'], 0, -1); |
|
1617 | + if ($found_words) { |
|
1618 | + $context['spell_js'] = substr($context['spell_js'], 0, -1); |
|
1619 | + } |
|
1536 | 1620 | |
1537 | 1621 | $context['spell_js'] .= ' |
1538 | 1622 | );'; |
@@ -1567,11 +1651,13 @@ discard block |
||
1567 | 1651 | global $user_info, $smcFunc; |
1568 | 1652 | |
1569 | 1653 | // Can't do it if there's no topics. |
1570 | - if (empty($topics)) |
|
1571 | - return; |
|
1654 | + if (empty($topics)) { |
|
1655 | + return; |
|
1656 | + } |
|
1572 | 1657 | // It must be an array - it must! |
1573 | - if (!is_array($topics)) |
|
1574 | - $topics = array($topics); |
|
1658 | + if (!is_array($topics)) { |
|
1659 | + $topics = array($topics); |
|
1660 | + } |
|
1575 | 1661 | |
1576 | 1662 | // Get the subject and body... |
1577 | 1663 | $result = $smcFunc['db_query']('', ' |
@@ -1619,14 +1705,15 @@ discard block |
||
1619 | 1705 | } |
1620 | 1706 | $smcFunc['db_free_result']($result); |
1621 | 1707 | |
1622 | - if (!empty($task_rows)) |
|
1623 | - $smcFunc['db_insert']('', |
|
1708 | + if (!empty($task_rows)) { |
|
1709 | + $smcFunc['db_insert']('', |
|
1624 | 1710 | '{db_prefix}background_tasks', |
1625 | 1711 | array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'), |
1626 | 1712 | $task_rows, |
1627 | 1713 | array('id_task') |
1628 | 1714 | ); |
1629 | -} |
|
1715 | + } |
|
1716 | + } |
|
1630 | 1717 | |
1631 | 1718 | /** |
1632 | 1719 | * Create a post, either as new topic (id_topic = 0) or in an existing one. |
@@ -1664,9 +1751,9 @@ discard block |
||
1664 | 1751 | $msgOptions['send_notifications'] = isset($msgOptions['send_notifications']) ? (bool) $msgOptions['send_notifications'] : true; |
1665 | 1752 | |
1666 | 1753 | // We need to know if the topic is approved. If we're told that's great - if not find out. |
1667 | - if (!$modSettings['postmod_active']) |
|
1668 | - $topicOptions['is_approved'] = true; |
|
1669 | - elseif (!empty($topicOptions['id']) && !isset($topicOptions['is_approved'])) |
|
1754 | + if (!$modSettings['postmod_active']) { |
|
1755 | + $topicOptions['is_approved'] = true; |
|
1756 | + } elseif (!empty($topicOptions['id']) && !isset($topicOptions['is_approved'])) |
|
1670 | 1757 | { |
1671 | 1758 | $request = $smcFunc['db_query']('', ' |
1672 | 1759 | SELECT approved |
@@ -1689,8 +1776,7 @@ discard block |
||
1689 | 1776 | $posterOptions['id'] = 0; |
1690 | 1777 | $posterOptions['name'] = $txt['guest_title']; |
1691 | 1778 | $posterOptions['email'] = ''; |
1692 | - } |
|
1693 | - elseif ($posterOptions['id'] != $user_info['id']) |
|
1779 | + } elseif ($posterOptions['id'] != $user_info['id']) |
|
1694 | 1780 | { |
1695 | 1781 | $request = $smcFunc['db_query']('', ' |
1696 | 1782 | SELECT member_name, email_address |
@@ -1708,12 +1794,11 @@ discard block |
||
1708 | 1794 | $posterOptions['id'] = 0; |
1709 | 1795 | $posterOptions['name'] = $txt['guest_title']; |
1710 | 1796 | $posterOptions['email'] = ''; |
1797 | + } else { |
|
1798 | + list ($posterOptions['name'], $posterOptions['email']) = $smcFunc['db_fetch_row']($request); |
|
1711 | 1799 | } |
1712 | - else |
|
1713 | - list ($posterOptions['name'], $posterOptions['email']) = $smcFunc['db_fetch_row']($request); |
|
1714 | 1800 | $smcFunc['db_free_result']($request); |
1715 | - } |
|
1716 | - else |
|
1801 | + } else |
|
1717 | 1802 | { |
1718 | 1803 | $posterOptions['name'] = $user_info['name']; |
1719 | 1804 | $posterOptions['email'] = $user_info['email']; |
@@ -1723,8 +1808,9 @@ discard block |
||
1723 | 1808 | if (!empty($modSettings['enable_mentions'])) |
1724 | 1809 | { |
1725 | 1810 | $msgOptions['mentioned_members'] = Mentions::getMentionedMembers($msgOptions['body']); |
1726 | - if (!empty($msgOptions['mentioned_members'])) |
|
1727 | - $msgOptions['body'] = Mentions::getBody($msgOptions['body'], $msgOptions['mentioned_members']); |
|
1811 | + if (!empty($msgOptions['mentioned_members'])) { |
|
1812 | + $msgOptions['body'] = Mentions::getBody($msgOptions['body'], $msgOptions['mentioned_members']); |
|
1813 | + } |
|
1728 | 1814 | } |
1729 | 1815 | |
1730 | 1816 | // It's do or die time: forget any user aborts! |
@@ -1757,12 +1843,13 @@ discard block |
||
1757 | 1843 | ); |
1758 | 1844 | |
1759 | 1845 | // Something went wrong creating the message... |
1760 | - if (empty($msgOptions['id'])) |
|
1761 | - return false; |
|
1846 | + if (empty($msgOptions['id'])) { |
|
1847 | + return false; |
|
1848 | + } |
|
1762 | 1849 | |
1763 | 1850 | // Fix the attachments. |
1764 | - if (!empty($msgOptions['attachments'])) |
|
1765 | - $smcFunc['db_query']('', ' |
|
1851 | + if (!empty($msgOptions['attachments'])) { |
|
1852 | + $smcFunc['db_query']('', ' |
|
1766 | 1853 | UPDATE {db_prefix}attachments |
1767 | 1854 | SET id_msg = {int:id_msg} |
1768 | 1855 | WHERE id_attach IN ({array_int:attachment_list})', |
@@ -1771,6 +1858,7 @@ discard block |
||
1771 | 1858 | 'id_msg' => $msgOptions['id'], |
1772 | 1859 | ) |
1773 | 1860 | ); |
1861 | + } |
|
1774 | 1862 | |
1775 | 1863 | // What if we want to export new posts out to a CMS? |
1776 | 1864 | call_integration_hook('integrate_after_create_post', array($msgOptions, $topicOptions, $posterOptions, $message_columns, $message_parameters)); |
@@ -1847,20 +1935,23 @@ discard block |
||
1847 | 1935 | 'id_topic' => $topicOptions['id'], |
1848 | 1936 | 'counter_increment' => 1, |
1849 | 1937 | ); |
1850 | - if ($msgOptions['approved']) |
|
1851 | - $topics_columns = array( |
|
1938 | + if ($msgOptions['approved']) { |
|
1939 | + $topics_columns = array( |
|
1852 | 1940 | 'id_member_updated = {int:poster_id}', |
1853 | 1941 | 'id_last_msg = {int:id_msg}', |
1854 | 1942 | 'num_replies = num_replies + {int:counter_increment}', |
1855 | 1943 | ); |
1856 | - else |
|
1857 | - $topics_columns = array( |
|
1944 | + } else { |
|
1945 | + $topics_columns = array( |
|
1858 | 1946 | 'unapproved_posts = unapproved_posts + {int:counter_increment}', |
1859 | 1947 | ); |
1860 | - if ($topicOptions['lock_mode'] !== null) |
|
1861 | - $topics_columns[] = 'locked = {int:locked}'; |
|
1862 | - if ($topicOptions['sticky_mode'] !== null) |
|
1863 | - $topics_columns[] = 'is_sticky = {int:is_sticky}'; |
|
1948 | + } |
|
1949 | + if ($topicOptions['lock_mode'] !== null) { |
|
1950 | + $topics_columns[] = 'locked = {int:locked}'; |
|
1951 | + } |
|
1952 | + if ($topicOptions['sticky_mode'] !== null) { |
|
1953 | + $topics_columns[] = 'is_sticky = {int:is_sticky}'; |
|
1954 | + } |
|
1864 | 1955 | |
1865 | 1956 | call_integration_hook('integrate_modify_topic', array(&$topics_columns, &$update_parameters, &$msgOptions, &$topicOptions, &$posterOptions)); |
1866 | 1957 | |
@@ -1889,8 +1980,8 @@ discard block |
||
1889 | 1980 | ); |
1890 | 1981 | |
1891 | 1982 | // Increase the number of posts and topics on the board. |
1892 | - if ($msgOptions['approved']) |
|
1893 | - $smcFunc['db_query']('', ' |
|
1983 | + if ($msgOptions['approved']) { |
|
1984 | + $smcFunc['db_query']('', ' |
|
1894 | 1985 | UPDATE {db_prefix}boards |
1895 | 1986 | SET num_posts = num_posts + 1' . ($new_topic ? ', num_topics = num_topics + 1' : '') . ' |
1896 | 1987 | WHERE id_board = {int:id_board}', |
@@ -1898,7 +1989,7 @@ discard block |
||
1898 | 1989 | 'id_board' => $topicOptions['board'], |
1899 | 1990 | ) |
1900 | 1991 | ); |
1901 | - else |
|
1992 | + } else |
|
1902 | 1993 | { |
1903 | 1994 | $smcFunc['db_query']('', ' |
1904 | 1995 | UPDATE {db_prefix}boards |
@@ -1968,8 +2059,8 @@ discard block |
||
1968 | 2059 | } |
1969 | 2060 | } |
1970 | 2061 | |
1971 | - if ($msgOptions['approved'] && empty($topicOptions['is_approved'])) |
|
1972 | - $smcFunc['db_insert']('', |
|
2062 | + if ($msgOptions['approved'] && empty($topicOptions['is_approved'])) { |
|
2063 | + $smcFunc['db_insert']('', |
|
1973 | 2064 | '{db_prefix}background_tasks', |
1974 | 2065 | array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'), |
1975 | 2066 | array( |
@@ -1981,19 +2072,22 @@ discard block |
||
1981 | 2072 | ), |
1982 | 2073 | array('id_task') |
1983 | 2074 | ); |
2075 | + } |
|
1984 | 2076 | |
1985 | 2077 | // If there's a custom search index, it may need updating... |
1986 | 2078 | require_once($sourcedir . '/Search.php'); |
1987 | 2079 | $searchAPI = findSearchAPI(); |
1988 | - if (is_callable(array($searchAPI, 'postCreated'))) |
|
1989 | - $searchAPI->postCreated($msgOptions, $topicOptions, $posterOptions); |
|
2080 | + if (is_callable(array($searchAPI, 'postCreated'))) { |
|
2081 | + $searchAPI->postCreated($msgOptions, $topicOptions, $posterOptions); |
|
2082 | + } |
|
1990 | 2083 | |
1991 | 2084 | // Increase the post counter for the user that created the post. |
1992 | 2085 | if (!empty($posterOptions['update_post_count']) && !empty($posterOptions['id']) && $msgOptions['approved']) |
1993 | 2086 | { |
1994 | 2087 | // Are you the one that happened to create this post? |
1995 | - if ($user_info['id'] == $posterOptions['id']) |
|
1996 | - $user_info['posts']++; |
|
2088 | + if ($user_info['id'] == $posterOptions['id']) { |
|
2089 | + $user_info['posts']++; |
|
2090 | + } |
|
1997 | 2091 | updateMemberData($posterOptions['id'], array('posts' => '+')); |
1998 | 2092 | } |
1999 | 2093 | |
@@ -2001,19 +2095,21 @@ discard block |
||
2001 | 2095 | $_SESSION['last_read_topic'] = 0; |
2002 | 2096 | |
2003 | 2097 | // Better safe than sorry. |
2004 | - if (isset($_SESSION['topicseen_cache'][$topicOptions['board']])) |
|
2005 | - $_SESSION['topicseen_cache'][$topicOptions['board']]--; |
|
2098 | + if (isset($_SESSION['topicseen_cache'][$topicOptions['board']])) { |
|
2099 | + $_SESSION['topicseen_cache'][$topicOptions['board']]--; |
|
2100 | + } |
|
2006 | 2101 | |
2007 | 2102 | // Update all the stats so everyone knows about this new topic and message. |
2008 | 2103 | updateStats('message', true, $msgOptions['id']); |
2009 | 2104 | |
2010 | 2105 | // Update the last message on the board assuming it's approved AND the topic is. |
2011 | - if ($msgOptions['approved']) |
|
2012 | - updateLastMessages($topicOptions['board'], $new_topic || !empty($topicOptions['is_approved']) ? $msgOptions['id'] : 0); |
|
2106 | + if ($msgOptions['approved']) { |
|
2107 | + updateLastMessages($topicOptions['board'], $new_topic || !empty($topicOptions['is_approved']) ? $msgOptions['id'] : 0); |
|
2108 | + } |
|
2013 | 2109 | |
2014 | 2110 | // Queue createPost background notification |
2015 | - if ($msgOptions['send_notifications'] && $msgOptions['approved']) |
|
2016 | - $smcFunc['db_insert']('', |
|
2111 | + if ($msgOptions['send_notifications'] && $msgOptions['approved']) { |
|
2112 | + $smcFunc['db_insert']('', |
|
2017 | 2113 | '{db_prefix}background_tasks', |
2018 | 2114 | array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'), |
2019 | 2115 | array('$sourcedir/tasks/CreatePost-Notify.php', 'CreatePost_Notify_Background', $smcFunc['json_encode'](array( |
@@ -2024,6 +2120,7 @@ discard block |
||
2024 | 2120 | )), 0), |
2025 | 2121 | array('id_task') |
2026 | 2122 | ); |
2123 | + } |
|
2027 | 2124 | |
2028 | 2125 | // Alright, done now... we can abort now, I guess... at least this much is done. |
2029 | 2126 | ignore_user_abort($previous_ignore_user_abort); |
@@ -2050,14 +2147,18 @@ discard block |
||
2050 | 2147 | |
2051 | 2148 | // This is longer than it has to be, but makes it so we only set/change what we have to. |
2052 | 2149 | $messages_columns = array(); |
2053 | - if (isset($posterOptions['name'])) |
|
2054 | - $messages_columns['poster_name'] = $posterOptions['name']; |
|
2055 | - if (isset($posterOptions['email'])) |
|
2056 | - $messages_columns['poster_email'] = $posterOptions['email']; |
|
2057 | - if (isset($msgOptions['icon'])) |
|
2058 | - $messages_columns['icon'] = $msgOptions['icon']; |
|
2059 | - if (isset($msgOptions['subject'])) |
|
2060 | - $messages_columns['subject'] = $msgOptions['subject']; |
|
2150 | + if (isset($posterOptions['name'])) { |
|
2151 | + $messages_columns['poster_name'] = $posterOptions['name']; |
|
2152 | + } |
|
2153 | + if (isset($posterOptions['email'])) { |
|
2154 | + $messages_columns['poster_email'] = $posterOptions['email']; |
|
2155 | + } |
|
2156 | + if (isset($msgOptions['icon'])) { |
|
2157 | + $messages_columns['icon'] = $msgOptions['icon']; |
|
2158 | + } |
|
2159 | + if (isset($msgOptions['subject'])) { |
|
2160 | + $messages_columns['subject'] = $msgOptions['subject']; |
|
2161 | + } |
|
2061 | 2162 | if (isset($msgOptions['body'])) |
2062 | 2163 | { |
2063 | 2164 | $messages_columns['body'] = $msgOptions['body']; |
@@ -2084,8 +2185,9 @@ discard block |
||
2084 | 2185 | $messages_columns['modified_reason'] = $msgOptions['modify_reason']; |
2085 | 2186 | $messages_columns['id_msg_modified'] = $modSettings['maxMsgID']; |
2086 | 2187 | } |
2087 | - if (isset($msgOptions['smileys_enabled'])) |
|
2088 | - $messages_columns['smileys_enabled'] = empty($msgOptions['smileys_enabled']) ? 0 : 1; |
|
2188 | + if (isset($msgOptions['smileys_enabled'])) { |
|
2189 | + $messages_columns['smileys_enabled'] = empty($msgOptions['smileys_enabled']) ? 0 : 1; |
|
2190 | + } |
|
2089 | 2191 | |
2090 | 2192 | // Which columns need to be ints? |
2091 | 2193 | $messageInts = array('modified_time', 'id_msg_modified', 'smileys_enabled'); |
@@ -2096,8 +2198,9 @@ discard block |
||
2096 | 2198 | // Update search api |
2097 | 2199 | require_once($sourcedir . '/Search.php'); |
2098 | 2200 | $searchAPI = findSearchAPI(); |
2099 | - if ($searchAPI->supportsMethod('postRemoved')) |
|
2100 | - $searchAPI->postRemoved($msgOptions['id']); |
|
2201 | + if ($searchAPI->supportsMethod('postRemoved')) { |
|
2202 | + $searchAPI->postRemoved($msgOptions['id']); |
|
2203 | + } |
|
2101 | 2204 | |
2102 | 2205 | if (!empty($modSettings['enable_mentions']) && isset($msgOptions['body'])) |
2103 | 2206 | { |
@@ -2109,23 +2212,27 @@ discard block |
||
2109 | 2212 | { |
2110 | 2213 | preg_match_all('/\[member\=([0-9]+)\]([^\[]*)\[\/member\]/U', $msgOptions['old_body'], $match); |
2111 | 2214 | |
2112 | - if (isset($match[1]) && isset($match[2]) && is_array($match[1]) && is_array($match[2])) |
|
2113 | - foreach ($match[1] as $i => $oldID) |
|
2215 | + if (isset($match[1]) && isset($match[2]) && is_array($match[1]) && is_array($match[2])) { |
|
2216 | + foreach ($match[1] as $i => $oldID) |
|
2114 | 2217 | $oldmentions[$oldID] = array('id' => $oldID, 'real_name' => $match[2][$i]); |
2218 | + } |
|
2115 | 2219 | |
2116 | - if (empty($modSettings['search_custom_index_config'])) |
|
2117 | - unset($msgOptions['old_body']); |
|
2220 | + if (empty($modSettings['search_custom_index_config'])) { |
|
2221 | + unset($msgOptions['old_body']); |
|
2222 | + } |
|
2118 | 2223 | } |
2119 | 2224 | |
2120 | 2225 | $mentions = Mentions::getMentionedMembers($msgOptions['body']); |
2121 | 2226 | $messages_columns['body'] = $msgOptions['body'] = Mentions::getBody($msgOptions['body'], $mentions); |
2122 | 2227 | |
2123 | 2228 | // Remove the poster. |
2124 | - if (isset($mentions[$user_info['id']])) |
|
2125 | - unset($mentions[$user_info['id']]); |
|
2229 | + if (isset($mentions[$user_info['id']])) { |
|
2230 | + unset($mentions[$user_info['id']]); |
|
2231 | + } |
|
2126 | 2232 | |
2127 | - if (isset($oldmentions[$user_info['id']])) |
|
2128 | - unset($oldmentions[$user_info['id']]); |
|
2233 | + if (isset($oldmentions[$user_info['id']])) { |
|
2234 | + unset($oldmentions[$user_info['id']]); |
|
2235 | + } |
|
2129 | 2236 | |
2130 | 2237 | if (is_array($mentions) && is_array($oldmentions) && count(array_diff_key($mentions, $oldmentions)) > 0 && count($mentions) > count($oldmentions)) |
2131 | 2238 | { |
@@ -2155,8 +2262,9 @@ discard block |
||
2155 | 2262 | } |
2156 | 2263 | |
2157 | 2264 | // Nothing to do? |
2158 | - if (empty($messages_columns)) |
|
2159 | - return true; |
|
2265 | + if (empty($messages_columns)) { |
|
2266 | + return true; |
|
2267 | + } |
|
2160 | 2268 | |
2161 | 2269 | // Change the post. |
2162 | 2270 | $smcFunc['db_query']('', ' |
@@ -2217,8 +2325,9 @@ discard block |
||
2217 | 2325 | // If there's a custom search index, it needs to be modified... |
2218 | 2326 | require_once($sourcedir . '/Search.php'); |
2219 | 2327 | $searchAPI = findSearchAPI(); |
2220 | - if (is_callable(array($searchAPI, 'postModified'))) |
|
2221 | - $searchAPI->postModified($msgOptions, $topicOptions, $posterOptions); |
|
2328 | + if (is_callable(array($searchAPI, 'postModified'))) { |
|
2329 | + $searchAPI->postModified($msgOptions, $topicOptions, $posterOptions); |
|
2330 | + } |
|
2222 | 2331 | |
2223 | 2332 | if (isset($msgOptions['subject'])) |
2224 | 2333 | { |
@@ -2232,14 +2341,16 @@ discard block |
||
2232 | 2341 | 'id_first_msg' => $msgOptions['id'], |
2233 | 2342 | ) |
2234 | 2343 | ); |
2235 | - if ($smcFunc['db_num_rows']($request) == 1) |
|
2236 | - updateStats('subject', $topicOptions['id'], $msgOptions['subject']); |
|
2344 | + if ($smcFunc['db_num_rows']($request) == 1) { |
|
2345 | + updateStats('subject', $topicOptions['id'], $msgOptions['subject']); |
|
2346 | + } |
|
2237 | 2347 | $smcFunc['db_free_result']($request); |
2238 | 2348 | } |
2239 | 2349 | |
2240 | 2350 | // Finally, if we are setting the approved state we need to do much more work :( |
2241 | - if ($modSettings['postmod_active'] && isset($msgOptions['approved'])) |
|
2242 | - approvePosts($msgOptions['id'], $msgOptions['approved']); |
|
2351 | + if ($modSettings['postmod_active'] && isset($msgOptions['approved'])) { |
|
2352 | + approvePosts($msgOptions['id'], $msgOptions['approved']); |
|
2353 | + } |
|
2243 | 2354 | |
2244 | 2355 | return true; |
2245 | 2356 | } |
@@ -2256,11 +2367,13 @@ discard block |
||
2256 | 2367 | { |
2257 | 2368 | global $smcFunc; |
2258 | 2369 | |
2259 | - if (!is_array($msgs)) |
|
2260 | - $msgs = array($msgs); |
|
2370 | + if (!is_array($msgs)) { |
|
2371 | + $msgs = array($msgs); |
|
2372 | + } |
|
2261 | 2373 | |
2262 | - if (empty($msgs)) |
|
2263 | - return false; |
|
2374 | + if (empty($msgs)) { |
|
2375 | + return false; |
|
2376 | + } |
|
2264 | 2377 | |
2265 | 2378 | // May as well start at the beginning, working out *what* we need to change. |
2266 | 2379 | $request = $smcFunc['db_query']('', ' |
@@ -2292,20 +2405,22 @@ discard block |
||
2292 | 2405 | $topics[] = $row['id_topic']; |
2293 | 2406 | |
2294 | 2407 | // Ensure our change array exists already. |
2295 | - if (!isset($topic_changes[$row['id_topic']])) |
|
2296 | - $topic_changes[$row['id_topic']] = array( |
|
2408 | + if (!isset($topic_changes[$row['id_topic']])) { |
|
2409 | + $topic_changes[$row['id_topic']] = array( |
|
2297 | 2410 | 'id_last_msg' => $row['id_last_msg'], |
2298 | 2411 | 'approved' => $row['topic_approved'], |
2299 | 2412 | 'replies' => 0, |
2300 | 2413 | 'unapproved_posts' => 0, |
2301 | 2414 | ); |
2302 | - if (!isset($board_changes[$row['id_board']])) |
|
2303 | - $board_changes[$row['id_board']] = array( |
|
2415 | + } |
|
2416 | + if (!isset($board_changes[$row['id_board']])) { |
|
2417 | + $board_changes[$row['id_board']] = array( |
|
2304 | 2418 | 'posts' => 0, |
2305 | 2419 | 'topics' => 0, |
2306 | 2420 | 'unapproved_posts' => 0, |
2307 | 2421 | 'unapproved_topics' => 0, |
2308 | 2422 | ); |
2423 | + } |
|
2309 | 2424 | |
2310 | 2425 | // If it's the first message then the topic state changes! |
2311 | 2426 | if ($row['id_msg'] == $row['id_first_msg']) |
@@ -2326,14 +2441,13 @@ discard block |
||
2326 | 2441 | 'poster' => $row['id_member'], |
2327 | 2442 | 'new_topic' => true, |
2328 | 2443 | ); |
2329 | - } |
|
2330 | - else |
|
2444 | + } else |
|
2331 | 2445 | { |
2332 | 2446 | $topic_changes[$row['id_topic']]['replies'] += $approve ? 1 : -1; |
2333 | 2447 | |
2334 | 2448 | // This will be a post... but don't notify unless it's not followed by approved ones. |
2335 | - if ($row['id_msg'] > $row['id_last_msg']) |
|
2336 | - $notification_posts[$row['id_topic']] = array( |
|
2449 | + if ($row['id_msg'] > $row['id_last_msg']) { |
|
2450 | + $notification_posts[$row['id_topic']] = array( |
|
2337 | 2451 | 'id' => $row['id_msg'], |
2338 | 2452 | 'body' => $row['body'], |
2339 | 2453 | 'subject' => $row['subject'], |
@@ -2344,28 +2458,33 @@ discard block |
||
2344 | 2458 | 'new_topic' => false, |
2345 | 2459 | 'msg' => $row['id_msg'], |
2346 | 2460 | ); |
2461 | + } |
|
2347 | 2462 | } |
2348 | 2463 | |
2349 | 2464 | // If this is being approved and id_msg is higher than the current id_last_msg then it changes. |
2350 | - if ($approve && $row['id_msg'] > $topic_changes[$row['id_topic']]['id_last_msg']) |
|
2351 | - $topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_msg']; |
|
2465 | + if ($approve && $row['id_msg'] > $topic_changes[$row['id_topic']]['id_last_msg']) { |
|
2466 | + $topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_msg']; |
|
2467 | + } |
|
2352 | 2468 | // If this is being unapproved, and it's equal to the id_last_msg we need to find a new one! |
2353 | - elseif (!$approve) |
|
2354 | - // Default to the first message and then we'll override in a bit ;) |
|
2469 | + elseif (!$approve) { |
|
2470 | + // Default to the first message and then we'll override in a bit ;) |
|
2355 | 2471 | $topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_first_msg']; |
2472 | + } |
|
2356 | 2473 | |
2357 | 2474 | $topic_changes[$row['id_topic']]['unapproved_posts'] += $approve ? -1 : 1; |
2358 | 2475 | $board_changes[$row['id_board']]['unapproved_posts'] += $approve ? -1 : 1; |
2359 | 2476 | $board_changes[$row['id_board']]['posts'] += $approve ? 1 : -1; |
2360 | 2477 | |
2361 | 2478 | // Post count for the user? |
2362 | - if ($row['id_member'] && empty($row['count_posts'])) |
|
2363 | - $member_post_changes[$row['id_member']] = isset($member_post_changes[$row['id_member']]) ? $member_post_changes[$row['id_member']] + 1 : 1; |
|
2479 | + if ($row['id_member'] && empty($row['count_posts'])) { |
|
2480 | + $member_post_changes[$row['id_member']] = isset($member_post_changes[$row['id_member']]) ? $member_post_changes[$row['id_member']] + 1 : 1; |
|
2481 | + } |
|
2364 | 2482 | } |
2365 | 2483 | $smcFunc['db_free_result']($request); |
2366 | 2484 | |
2367 | - if (empty($msgs)) |
|
2368 | - return; |
|
2485 | + if (empty($msgs)) { |
|
2486 | + return; |
|
2487 | + } |
|
2369 | 2488 | |
2370 | 2489 | // Now we have the differences make the changes, first the easy one. |
2371 | 2490 | $smcFunc['db_query']('', ' |
@@ -2392,14 +2511,15 @@ discard block |
||
2392 | 2511 | 'approved' => 1, |
2393 | 2512 | ) |
2394 | 2513 | ); |
2395 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2396 | - $topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_last_msg']; |
|
2514 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2515 | + $topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_last_msg']; |
|
2516 | + } |
|
2397 | 2517 | $smcFunc['db_free_result']($request); |
2398 | 2518 | } |
2399 | 2519 | |
2400 | 2520 | // ... next the topics... |
2401 | - foreach ($topic_changes as $id => $changes) |
|
2402 | - $smcFunc['db_query']('', ' |
|
2521 | + foreach ($topic_changes as $id => $changes) { |
|
2522 | + $smcFunc['db_query']('', ' |
|
2403 | 2523 | UPDATE {db_prefix}topics |
2404 | 2524 | SET approved = {int:approved}, unapproved_posts = unapproved_posts + {int:unapproved_posts}, |
2405 | 2525 | num_replies = num_replies + {int:num_replies}, id_last_msg = {int:id_last_msg} |
@@ -2412,10 +2532,11 @@ discard block |
||
2412 | 2532 | 'id_topic' => $id, |
2413 | 2533 | ) |
2414 | 2534 | ); |
2535 | + } |
|
2415 | 2536 | |
2416 | 2537 | // ... finally the boards... |
2417 | - foreach ($board_changes as $id => $changes) |
|
2418 | - $smcFunc['db_query']('', ' |
|
2538 | + foreach ($board_changes as $id => $changes) { |
|
2539 | + $smcFunc['db_query']('', ' |
|
2419 | 2540 | UPDATE {db_prefix}boards |
2420 | 2541 | SET num_posts = num_posts + {int:num_posts}, unapproved_posts = unapproved_posts + {int:unapproved_posts}, |
2421 | 2542 | num_topics = num_topics + {int:num_topics}, unapproved_topics = unapproved_topics + {int:unapproved_topics} |
@@ -2428,13 +2549,14 @@ discard block |
||
2428 | 2549 | 'id_board' => $id, |
2429 | 2550 | ) |
2430 | 2551 | ); |
2552 | + } |
|
2431 | 2553 | |
2432 | 2554 | // Finally, least importantly, notifications! |
2433 | 2555 | if ($approve) |
2434 | 2556 | { |
2435 | 2557 | $task_rows = array(); |
2436 | - foreach (array_merge($notification_topics, $notification_posts) as $topic) |
|
2437 | - $task_rows[] = array( |
|
2558 | + foreach (array_merge($notification_topics, $notification_posts) as $topic) { |
|
2559 | + $task_rows[] = array( |
|
2438 | 2560 | '$sourcedir/tasks/CreatePost-Notify.php', 'CreatePost_Notify_Background', $smcFunc['json_encode'](array( |
2439 | 2561 | 'msgOptions' => array( |
2440 | 2562 | 'id' => $topic['msg'], |
@@ -2452,14 +2574,16 @@ discard block |
||
2452 | 2574 | 'type' => $topic['new_topic'] ? 'topic' : 'reply', |
2453 | 2575 | )), 0 |
2454 | 2576 | ); |
2577 | + } |
|
2455 | 2578 | |
2456 | - if ($notify) |
|
2457 | - $smcFunc['db_insert']('', |
|
2579 | + if ($notify) { |
|
2580 | + $smcFunc['db_insert']('', |
|
2458 | 2581 | '{db_prefix}background_tasks', |
2459 | 2582 | array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'), |
2460 | 2583 | $task_rows, |
2461 | 2584 | array('id_task') |
2462 | 2585 | ); |
2586 | + } |
|
2463 | 2587 | |
2464 | 2588 | $smcFunc['db_query']('', ' |
2465 | 2589 | DELETE FROM {db_prefix}approval_queue |
@@ -2475,8 +2599,9 @@ discard block |
||
2475 | 2599 | else |
2476 | 2600 | { |
2477 | 2601 | $msgInserts = array(); |
2478 | - foreach ($msgs as $msg) |
|
2479 | - $msgInserts[] = array($msg); |
|
2602 | + foreach ($msgs as $msg) { |
|
2603 | + $msgInserts[] = array($msg); |
|
2604 | + } |
|
2480 | 2605 | |
2481 | 2606 | $smcFunc['db_insert']('ignore', |
2482 | 2607 | '{db_prefix}approval_queue', |
@@ -2490,9 +2615,10 @@ discard block |
||
2490 | 2615 | updateLastMessages(array_keys($board_changes)); |
2491 | 2616 | |
2492 | 2617 | // Post count for the members? |
2493 | - if (!empty($member_post_changes)) |
|
2494 | - foreach ($member_post_changes as $id_member => $count_change) |
|
2618 | + if (!empty($member_post_changes)) { |
|
2619 | + foreach ($member_post_changes as $id_member => $count_change) |
|
2495 | 2620 | updateMemberData($id_member, array('posts' => 'posts ' . ($approve ? '+' : '-') . ' ' . $count_change)); |
2621 | + } |
|
2496 | 2622 | |
2497 | 2623 | return true; |
2498 | 2624 | } |
@@ -2509,11 +2635,13 @@ discard block |
||
2509 | 2635 | { |
2510 | 2636 | global $smcFunc; |
2511 | 2637 | |
2512 | - if (!is_array($topics)) |
|
2513 | - $topics = array($topics); |
|
2638 | + if (!is_array($topics)) { |
|
2639 | + $topics = array($topics); |
|
2640 | + } |
|
2514 | 2641 | |
2515 | - if (empty($topics)) |
|
2516 | - return false; |
|
2642 | + if (empty($topics)) { |
|
2643 | + return false; |
|
2644 | + } |
|
2517 | 2645 | |
2518 | 2646 | $approve_type = $approve ? 0 : 1; |
2519 | 2647 | |
@@ -2529,8 +2657,9 @@ discard block |
||
2529 | 2657 | ) |
2530 | 2658 | ); |
2531 | 2659 | $msgs = array(); |
2532 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2533 | - $msgs[] = $row['id_msg']; |
|
2660 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2661 | + $msgs[] = $row['id_msg']; |
|
2662 | + } |
|
2534 | 2663 | $smcFunc['db_free_result']($request); |
2535 | 2664 | |
2536 | 2665 | return approvePosts($msgs, $approve); |
@@ -2553,11 +2682,13 @@ discard block |
||
2553 | 2682 | global $board_info, $board, $smcFunc; |
2554 | 2683 | |
2555 | 2684 | // Please - let's be sane. |
2556 | - if (empty($setboards)) |
|
2557 | - return false; |
|
2685 | + if (empty($setboards)) { |
|
2686 | + return false; |
|
2687 | + } |
|
2558 | 2688 | |
2559 | - if (!is_array($setboards)) |
|
2560 | - $setboards = array($setboards); |
|
2689 | + if (!is_array($setboards)) { |
|
2690 | + $setboards = array($setboards); |
|
2691 | + } |
|
2561 | 2692 | |
2562 | 2693 | // If we don't know the id_msg we need to find it. |
2563 | 2694 | if (!$id_msg) |
@@ -2575,15 +2706,16 @@ discard block |
||
2575 | 2706 | ) |
2576 | 2707 | ); |
2577 | 2708 | $lastMsg = array(); |
2578 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2579 | - $lastMsg[$row['id_board']] = $row['id_msg']; |
|
2709 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2710 | + $lastMsg[$row['id_board']] = $row['id_msg']; |
|
2711 | + } |
|
2580 | 2712 | $smcFunc['db_free_result']($request); |
2581 | - } |
|
2582 | - else |
|
2713 | + } else |
|
2583 | 2714 | { |
2584 | 2715 | // Just to note - there should only be one board passed if we are doing this. |
2585 | - foreach ($setboards as $id_board) |
|
2586 | - $lastMsg[$id_board] = $id_msg; |
|
2716 | + foreach ($setboards as $id_board) { |
|
2717 | + $lastMsg[$id_board] = $id_msg; |
|
2718 | + } |
|
2587 | 2719 | } |
2588 | 2720 | |
2589 | 2721 | $parent_boards = array(); |
@@ -2598,10 +2730,11 @@ discard block |
||
2598 | 2730 | $lastModified[$id_board] = 0; |
2599 | 2731 | } |
2600 | 2732 | |
2601 | - if (!empty($board) && $id_board == $board) |
|
2602 | - $parents = $board_info['parent_boards']; |
|
2603 | - else |
|
2604 | - $parents = getBoardParents($id_board); |
|
2733 | + if (!empty($board) && $id_board == $board) { |
|
2734 | + $parents = $board_info['parent_boards']; |
|
2735 | + } else { |
|
2736 | + $parents = getBoardParents($id_board); |
|
2737 | + } |
|
2605 | 2738 | |
2606 | 2739 | // Ignore any parents on the top child level. |
2607 | 2740 | // @todo Why? |
@@ -2610,10 +2743,11 @@ discard block |
||
2610 | 2743 | if ($parent['level'] != 0) |
2611 | 2744 | { |
2612 | 2745 | // If we're already doing this one as a board, is this a higher last modified? |
2613 | - if (isset($lastModified[$id]) && $lastModified[$id_board] > $lastModified[$id]) |
|
2614 | - $lastModified[$id] = $lastModified[$id_board]; |
|
2615 | - elseif (!isset($lastModified[$id]) && (!isset($parent_boards[$id]) || $parent_boards[$id] < $lastModified[$id_board])) |
|
2616 | - $parent_boards[$id] = $lastModified[$id_board]; |
|
2746 | + if (isset($lastModified[$id]) && $lastModified[$id_board] > $lastModified[$id]) { |
|
2747 | + $lastModified[$id] = $lastModified[$id_board]; |
|
2748 | + } elseif (!isset($lastModified[$id]) && (!isset($parent_boards[$id]) || $parent_boards[$id] < $lastModified[$id_board])) { |
|
2749 | + $parent_boards[$id] = $lastModified[$id_board]; |
|
2750 | + } |
|
2617 | 2751 | } |
2618 | 2752 | } |
2619 | 2753 | } |
@@ -2626,23 +2760,24 @@ discard block |
||
2626 | 2760 | // Finally, to save on queries make the changes... |
2627 | 2761 | foreach ($parent_boards as $id => $msg) |
2628 | 2762 | { |
2629 | - if (!isset($parent_updates[$msg])) |
|
2630 | - $parent_updates[$msg] = array($id); |
|
2631 | - else |
|
2632 | - $parent_updates[$msg][] = $id; |
|
2763 | + if (!isset($parent_updates[$msg])) { |
|
2764 | + $parent_updates[$msg] = array($id); |
|
2765 | + } else { |
|
2766 | + $parent_updates[$msg][] = $id; |
|
2767 | + } |
|
2633 | 2768 | } |
2634 | 2769 | |
2635 | 2770 | foreach ($lastMsg as $id => $msg) |
2636 | 2771 | { |
2637 | - if (!isset($board_updates[$msg . '-' . $lastModified[$id]])) |
|
2638 | - $board_updates[$msg . '-' . $lastModified[$id]] = array( |
|
2772 | + if (!isset($board_updates[$msg . '-' . $lastModified[$id]])) { |
|
2773 | + $board_updates[$msg . '-' . $lastModified[$id]] = array( |
|
2639 | 2774 | 'id' => $msg, |
2640 | 2775 | 'updated' => $lastModified[$id], |
2641 | 2776 | 'boards' => array($id) |
2642 | 2777 | ); |
2643 | - |
|
2644 | - else |
|
2645 | - $board_updates[$msg . '-' . $lastModified[$id]]['boards'][] = $id; |
|
2778 | + } else { |
|
2779 | + $board_updates[$msg . '-' . $lastModified[$id]]['boards'][] = $id; |
|
2780 | + } |
|
2646 | 2781 | } |
2647 | 2782 | |
2648 | 2783 | // Now commit the changes! |
@@ -2734,11 +2869,13 @@ discard block |
||
2734 | 2869 | global $txt, $mbname, $scripturl, $settings; |
2735 | 2870 | |
2736 | 2871 | // First things first, load up the email templates language file, if we need to. |
2737 | - if ($loadLang) |
|
2738 | - loadLanguage('EmailTemplates', $lang); |
|
2872 | + if ($loadLang) { |
|
2873 | + loadLanguage('EmailTemplates', $lang); |
|
2874 | + } |
|
2739 | 2875 | |
2740 | - if (!isset($txt[$template . '_subject']) || !isset($txt[$template . '_body'])) |
|
2741 | - fatal_lang_error('email_no_template', 'template', array($template)); |
|
2876 | + if (!isset($txt[$template . '_subject']) || !isset($txt[$template . '_body'])) { |
|
2877 | + fatal_lang_error('email_no_template', 'template', array($template)); |
|
2878 | + } |
|
2742 | 2879 | |
2743 | 2880 | $ret = array( |
2744 | 2881 | 'subject' => $txt[$template . '_subject'], |
@@ -2788,17 +2925,18 @@ discard block |
||
2788 | 2925 | function user_info_callback($matches) |
2789 | 2926 | { |
2790 | 2927 | global $user_info; |
2791 | - if (empty($matches[1])) |
|
2792 | - return ''; |
|
2928 | + if (empty($matches[1])) { |
|
2929 | + return ''; |
|
2930 | + } |
|
2793 | 2931 | |
2794 | 2932 | $use_ref = true; |
2795 | 2933 | $ref = &$user_info; |
2796 | 2934 | |
2797 | 2935 | foreach (explode('.', $matches[1]) as $index) |
2798 | 2936 | { |
2799 | - if ($use_ref && isset($ref[$index])) |
|
2800 | - $ref = &$ref[$index]; |
|
2801 | - else |
|
2937 | + if ($use_ref && isset($ref[$index])) { |
|
2938 | + $ref = &$ref[$index]; |
|
2939 | + } else |
|
2802 | 2940 | { |
2803 | 2941 | $use_ref = false; |
2804 | 2942 | break; |
@@ -2835,8 +2973,7 @@ discard block |
||
2835 | 2973 | if (!empty($lang_locale) && enchant_broker_dict_exists($context['enchant_broker'], $lang_locale)) |
2836 | 2974 | { |
2837 | 2975 | $enchant_link = enchant_broker_request_dict($context['enchant_broker'], $lang_locale); |
2838 | - } |
|
2839 | - elseif (enchant_broker_dict_exists($context['enchant_broker'], $txt['lang_dictionary'])) |
|
2976 | + } elseif (enchant_broker_dict_exists($context['enchant_broker'], $txt['lang_dictionary'])) |
|
2840 | 2977 | { |
2841 | 2978 | $enchant_link = enchant_broker_request_dict($context['enchant_broker'], $txt['lang_dictionary']); |
2842 | 2979 | } |
@@ -2846,8 +2983,7 @@ discard block |
||
2846 | 2983 | { |
2847 | 2984 | $context['provider'] = 'enchant'; |
2848 | 2985 | return $enchant_link; |
2849 | - } |
|
2850 | - else |
|
2986 | + } else |
|
2851 | 2987 | { |
2852 | 2988 | // Free up any resources used... |
2853 | 2989 | @enchant_broker_free($context['enchant_broker']); |
@@ -2868,8 +3004,9 @@ discard block |
||
2868 | 3004 | $pspell_link = pspell_new($txt['lang_dictionary'], $txt['lang_spelling'], '', strtr($context['character_set'], array('iso-' => 'iso', 'ISO-' => 'iso')), PSPELL_FAST | PSPELL_RUN_TOGETHER); |
2869 | 3005 | |
2870 | 3006 | // Most people don't have anything but English installed... So we use English as a last resort. |
2871 | - if (!$pspell_link) |
|
2872 | - $pspell_link = pspell_new('en', '', '', '', PSPELL_FAST | PSPELL_RUN_TOGETHER); |
|
3007 | + if (!$pspell_link) { |
|
3008 | + $pspell_link = pspell_new('en', '', '', '', PSPELL_FAST | PSPELL_RUN_TOGETHER); |
|
3009 | + } |
|
2873 | 3010 | |
2874 | 3011 | error_reporting($old); |
2875 | 3012 | ob_end_clean(); |
@@ -2909,8 +3046,7 @@ discard block |
||
2909 | 3046 | $word = iconv($txt['lang_character_set'], 'UTF-8', $word); |
2910 | 3047 | } |
2911 | 3048 | return enchant_dict_check($dict, $word); |
2912 | - } |
|
2913 | - elseif ($context['provider'] == 'pspell') |
|
3049 | + } elseif ($context['provider'] == 'pspell') |
|
2914 | 3050 | { |
2915 | 3051 | return pspell_check($dict, $word); |
2916 | 3052 | } |
@@ -2946,13 +3082,11 @@ discard block |
||
2946 | 3082 | } |
2947 | 3083 | |
2948 | 3084 | return $suggestions; |
2949 | - } |
|
2950 | - else |
|
3085 | + } else |
|
2951 | 3086 | { |
2952 | 3087 | return enchant_dict_suggest($dict, $word); |
2953 | 3088 | } |
2954 | - } |
|
2955 | - elseif ($context['provider'] == 'pspell') |
|
3089 | + } elseif ($context['provider'] == 'pspell') |
|
2956 | 3090 | { |
2957 | 3091 | return pspell_suggest($dict, $word); |
2958 | 3092 | } |
@@ -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 | * Get the latest post made on the system |
@@ -44,8 +45,9 @@ discard block |
||
44 | 45 | 'is_approved' => 1, |
45 | 46 | ) |
46 | 47 | ); |
47 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
48 | - return array(); |
|
48 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
49 | + return array(); |
|
50 | + } |
|
49 | 51 | $row = $smcFunc['db_fetch_assoc']($request); |
50 | 52 | $smcFunc['db_free_result']($request); |
51 | 53 | |
@@ -54,8 +56,9 @@ discard block |
||
54 | 56 | censorText($row['body']); |
55 | 57 | |
56 | 58 | $row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled']), array('<br>' => ' '))); |
57 | - if ($smcFunc['strlen']($row['body']) > 128) |
|
58 | - $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; |
|
59 | + if ($smcFunc['strlen']($row['body']) > 128) { |
|
60 | + $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; |
|
61 | + } |
|
59 | 62 | |
60 | 63 | // Send the data. |
61 | 64 | return array( |
@@ -83,8 +86,9 @@ discard block |
||
83 | 86 | |
84 | 87 | $context['is_redirect'] = false; |
85 | 88 | |
86 | - if (isset($_REQUEST['start']) && $_REQUEST['start'] > 95) |
|
87 | - $_REQUEST['start'] = 95; |
|
89 | + if (isset($_REQUEST['start']) && $_REQUEST['start'] > 95) { |
|
90 | + $_REQUEST['start'] = 95; |
|
91 | + } |
|
88 | 92 | |
89 | 93 | $_REQUEST['start'] = (int) $_REQUEST['start']; |
90 | 94 | |
@@ -92,8 +96,9 @@ discard block |
||
92 | 96 | if (!empty($_REQUEST['c']) && empty($board)) |
93 | 97 | { |
94 | 98 | $_REQUEST['c'] = explode(',', $_REQUEST['c']); |
95 | - foreach ($_REQUEST['c'] as $i => $c) |
|
96 | - $_REQUEST['c'][$i] = (int) $c; |
|
99 | + foreach ($_REQUEST['c'] as $i => $c) { |
|
100 | + $_REQUEST['c'][$i] = (int) $c; |
|
101 | + } |
|
97 | 102 | |
98 | 103 | if (count($_REQUEST['c']) == 1) |
99 | 104 | { |
@@ -109,8 +114,9 @@ discard block |
||
109 | 114 | list ($name) = $smcFunc['db_fetch_row']($request); |
110 | 115 | $smcFunc['db_free_result']($request); |
111 | 116 | |
112 | - if (empty($name)) |
|
113 | - fatal_lang_error('no_access', false); |
|
117 | + if (empty($name)) { |
|
118 | + fatal_lang_error('no_access', false); |
|
119 | + } |
|
114 | 120 | |
115 | 121 | $context['linktree'][] = array( |
116 | 122 | 'url' => $scripturl . '#c' . (int) $_REQUEST['c'], |
@@ -142,8 +148,9 @@ discard block |
||
142 | 148 | } |
143 | 149 | $smcFunc['db_free_result']($request); |
144 | 150 | |
145 | - if (empty($boards)) |
|
146 | - fatal_lang_error('error_no_boards_selected'); |
|
151 | + if (empty($boards)) { |
|
152 | + fatal_lang_error('error_no_boards_selected'); |
|
153 | + } |
|
147 | 154 | |
148 | 155 | $query_this_board = 'b.id_board IN ({array_int:boards})'; |
149 | 156 | $query_parameters['boards'] = $boards; |
@@ -157,12 +164,12 @@ discard block |
||
157 | 164 | } |
158 | 165 | |
159 | 166 | $context['page_index'] = constructPageIndex($scripturl . '?action=recent;c=' . implode(',', $_REQUEST['c']), $_REQUEST['start'], min(100, $total_cat_posts), 10, false); |
160 | - } |
|
161 | - elseif (!empty($_REQUEST['boards'])) |
|
167 | + } elseif (!empty($_REQUEST['boards'])) |
|
162 | 168 | { |
163 | 169 | $_REQUEST['boards'] = explode(',', $_REQUEST['boards']); |
164 | - foreach ($_REQUEST['boards'] as $i => $b) |
|
165 | - $_REQUEST['boards'][$i] = (int) $b; |
|
170 | + foreach ($_REQUEST['boards'] as $i => $b) { |
|
171 | + $_REQUEST['boards'][$i] = (int) $b; |
|
172 | + } |
|
166 | 173 | |
167 | 174 | $request = $smcFunc['db_query']('', ' |
168 | 175 | SELECT b.id_board, b.num_posts |
@@ -186,8 +193,9 @@ discard block |
||
186 | 193 | } |
187 | 194 | $smcFunc['db_free_result']($request); |
188 | 195 | |
189 | - if (empty($boards)) |
|
190 | - fatal_lang_error('error_no_boards_selected'); |
|
196 | + if (empty($boards)) { |
|
197 | + fatal_lang_error('error_no_boards_selected'); |
|
198 | + } |
|
191 | 199 | |
192 | 200 | $query_this_board = 'b.id_board IN ({array_int:boards})'; |
193 | 201 | $query_parameters['boards'] = $boards; |
@@ -201,8 +209,7 @@ discard block |
||
201 | 209 | } |
202 | 210 | |
203 | 211 | $context['page_index'] = constructPageIndex($scripturl . '?action=recent;boards=' . implode(',', $_REQUEST['boards']), $_REQUEST['start'], min(100, $total_posts), 10, false); |
204 | - } |
|
205 | - elseif (!empty($board)) |
|
212 | + } elseif (!empty($board)) |
|
206 | 213 | { |
207 | 214 | $request = $smcFunc['db_query']('', ' |
208 | 215 | SELECT num_posts, redirect |
@@ -235,8 +242,7 @@ discard block |
||
235 | 242 | } |
236 | 243 | |
237 | 244 | $context['page_index'] = constructPageIndex($scripturl . '?action=recent;board=' . $board . '.%1$d', $_REQUEST['start'], min(100, $total_posts), 10, true); |
238 | - } |
|
239 | - else |
|
245 | + } else |
|
240 | 246 | { |
241 | 247 | $query_this_board = '{query_wanna_see_board}' . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? ' |
242 | 248 | AND b.id_board != {int:recycle_board}' : ''). ' |
@@ -271,8 +277,9 @@ discard block |
||
271 | 277 | ); |
272 | 278 | |
273 | 279 | // If you selected a redirection board, don't try getting posts for it... |
274 | - if ($context['is_redirect']) |
|
275 | - $messages = 0; |
|
280 | + if ($context['is_redirect']) { |
|
281 | + $messages = 0; |
|
282 | + } |
|
276 | 283 | |
277 | 284 | $key = 'recent-' . $user_info['id'] . '-' . md5($smcFunc['json_encode'](array_diff_key($query_parameters, array('max_id_msg' => 0)))) . '-' . (int) $_REQUEST['start']; |
278 | 285 | if (!$context['is_redirect'] && (empty($modSettings['cache_enable']) || ($messages = cache_get_data($key, 120)) == null)) |
@@ -303,16 +310,18 @@ discard block |
||
303 | 310 | $query_this_board = str_replace('AND m.id_msg >= {int:max_id_msg}', '', $query_this_board); |
304 | 311 | $cache_results = true; |
305 | 312 | unset($query_parameters['max_id_msg']); |
313 | + } else { |
|
314 | + $done = true; |
|
306 | 315 | } |
307 | - else |
|
308 | - $done = true; |
|
309 | 316 | } |
310 | 317 | $messages = array(); |
311 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
312 | - $messages[] = $row['id_msg']; |
|
318 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
319 | + $messages[] = $row['id_msg']; |
|
320 | + } |
|
313 | 321 | $smcFunc['db_free_result']($request); |
314 | - if (!empty($cache_results)) |
|
315 | - cache_put_data($key, $messages, 120); |
|
322 | + if (!empty($cache_results)) { |
|
323 | + cache_put_data($key, $messages, 120); |
|
324 | + } |
|
316 | 325 | } |
317 | 326 | |
318 | 327 | // Nothing here... Or at least, nothing you can see... |
@@ -399,8 +408,9 @@ discard block |
||
399 | 408 | 'css_class' => 'windowbg', |
400 | 409 | ); |
401 | 410 | |
402 | - if ($user_info['id'] == $row['id_first_member']) |
|
403 | - $board_ids['own'][$row['id_board']][] = $row['id_msg']; |
|
411 | + if ($user_info['id'] == $row['id_first_member']) { |
|
412 | + $board_ids['own'][$row['id_board']][] = $row['id_msg']; |
|
413 | + } |
|
404 | 414 | $board_ids['any'][$row['id_board']][] = $row['id_msg']; |
405 | 415 | } |
406 | 416 | $smcFunc['db_free_result']($request); |
@@ -426,20 +436,23 @@ discard block |
||
426 | 436 | $boards = boardsAllowedTo($permission); |
427 | 437 | |
428 | 438 | // If 0 is the only thing in the array, they can do it everywhere! |
429 | - if (!empty($boards) && $boards[0] == 0) |
|
430 | - $boards = array_keys($board_ids[$type]); |
|
439 | + if (!empty($boards) && $boards[0] == 0) { |
|
440 | + $boards = array_keys($board_ids[$type]); |
|
441 | + } |
|
431 | 442 | |
432 | 443 | // Go through the boards, and look for posts they can do this on. |
433 | 444 | foreach ($boards as $board_id) |
434 | 445 | { |
435 | 446 | // Hmm, they have permission, but there are no topics from that board on this page. |
436 | - if (!isset($board_ids[$type][$board_id])) |
|
437 | - continue; |
|
447 | + if (!isset($board_ids[$type][$board_id])) { |
|
448 | + continue; |
|
449 | + } |
|
438 | 450 | |
439 | 451 | // Okay, looks like they can do it for these posts. |
440 | - foreach ($board_ids[$type][$board_id] as $counter) |
|
441 | - if ($type == 'any' || $context['posts'][$counter]['poster']['id'] == $user_info['id']) |
|
452 | + foreach ($board_ids[$type][$board_id] as $counter) { |
|
453 | + if ($type == 'any' || $context['posts'][$counter]['poster']['id'] == $user_info['id']) |
|
442 | 454 | $context['posts'][$counter][$allowed] = true; |
455 | + } |
|
443 | 456 | } |
444 | 457 | } |
445 | 458 | } |
@@ -482,17 +495,19 @@ discard block |
||
482 | 495 | $context['showing_all_topics'] = isset($_GET['all']); |
483 | 496 | $context['start'] = (int) $_REQUEST['start']; |
484 | 497 | $context['topics_per_page'] = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) ? $options['topics_per_page'] : $modSettings['defaultMaxTopics']; |
485 | - if ($_REQUEST['action'] == 'unread') |
|
486 | - $context['page_title'] = $context['showing_all_topics'] ? $txt['unread_topics_all'] : $txt['unread_topics_visit']; |
|
487 | - else |
|
488 | - $context['page_title'] = $txt['unread_replies']; |
|
498 | + if ($_REQUEST['action'] == 'unread') { |
|
499 | + $context['page_title'] = $context['showing_all_topics'] ? $txt['unread_topics_all'] : $txt['unread_topics_visit']; |
|
500 | + } else { |
|
501 | + $context['page_title'] = $txt['unread_replies']; |
|
502 | + } |
|
489 | 503 | |
490 | - if ($context['showing_all_topics'] && !empty($context['load_average']) && !empty($modSettings['loadavg_allunread']) && $context['load_average'] >= $modSettings['loadavg_allunread']) |
|
491 | - fatal_lang_error('loadavg_allunread_disabled', false); |
|
492 | - elseif ($_REQUEST['action'] != 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unreadreplies']) && $context['load_average'] >= $modSettings['loadavg_unreadreplies']) |
|
493 | - fatal_lang_error('loadavg_unreadreplies_disabled', false); |
|
494 | - elseif (!$context['showing_all_topics'] && $_REQUEST['action'] == 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unread']) && $context['load_average'] >= $modSettings['loadavg_unread']) |
|
495 | - fatal_lang_error('loadavg_unread_disabled', false); |
|
504 | + if ($context['showing_all_topics'] && !empty($context['load_average']) && !empty($modSettings['loadavg_allunread']) && $context['load_average'] >= $modSettings['loadavg_allunread']) { |
|
505 | + fatal_lang_error('loadavg_allunread_disabled', false); |
|
506 | + } elseif ($_REQUEST['action'] != 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unreadreplies']) && $context['load_average'] >= $modSettings['loadavg_unreadreplies']) { |
|
507 | + fatal_lang_error('loadavg_unreadreplies_disabled', false); |
|
508 | + } elseif (!$context['showing_all_topics'] && $_REQUEST['action'] == 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unread']) && $context['load_average'] >= $modSettings['loadavg_unread']) { |
|
509 | + fatal_lang_error('loadavg_unread_disabled', false); |
|
510 | + } |
|
496 | 511 | |
497 | 512 | // Parameters for the main query. |
498 | 513 | $query_parameters = array(); |
@@ -505,12 +520,14 @@ discard block |
||
505 | 520 | if (!empty($_REQUEST['boards'])) |
506 | 521 | { |
507 | 522 | $_REQUEST['boards'] = explode(',', $_REQUEST['boards']); |
508 | - foreach ($_REQUEST['boards'] as $b) |
|
509 | - $boards[] = (int) $b; |
|
523 | + foreach ($_REQUEST['boards'] as $b) { |
|
524 | + $boards[] = (int) $b; |
|
525 | + } |
|
510 | 526 | } |
511 | 527 | |
512 | - if (!empty($board)) |
|
513 | - $boards[] = (int) $board; |
|
528 | + if (!empty($board)) { |
|
529 | + $boards[] = (int) $board; |
|
530 | + } |
|
514 | 531 | |
515 | 532 | // The easiest thing is to just get all the boards they can see, but since we've specified the top of tree we ignore some of them |
516 | 533 | $request = $smcFunc['db_query']('', ' |
@@ -527,30 +544,31 @@ discard block |
||
527 | 544 | ) |
528 | 545 | ); |
529 | 546 | |
530 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
531 | - if (in_array($row['id_parent'], $boards)) |
|
547 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
548 | + if (in_array($row['id_parent'], $boards)) |
|
532 | 549 | $boards[] = $row['id_board']; |
550 | + } |
|
533 | 551 | |
534 | 552 | $smcFunc['db_free_result']($request); |
535 | 553 | |
536 | - if (empty($boards)) |
|
537 | - fatal_lang_error('error_no_boards_selected'); |
|
554 | + if (empty($boards)) { |
|
555 | + fatal_lang_error('error_no_boards_selected'); |
|
556 | + } |
|
538 | 557 | |
539 | 558 | $query_this_board = 'id_board IN ({array_int:boards})'; |
540 | 559 | $query_parameters['boards'] = $boards; |
541 | 560 | $context['querystring_board_limits'] = ';boards=' . implode(',', $boards) . ';start=%d'; |
542 | - } |
|
543 | - elseif (!empty($board)) |
|
561 | + } elseif (!empty($board)) |
|
544 | 562 | { |
545 | 563 | $query_this_board = 'id_board = {int:board}'; |
546 | 564 | $query_parameters['board'] = $board; |
547 | 565 | $context['querystring_board_limits'] = ';board=' . $board . '.%1$d'; |
548 | - } |
|
549 | - elseif (!empty($_REQUEST['boards'])) |
|
566 | + } elseif (!empty($_REQUEST['boards'])) |
|
550 | 567 | { |
551 | 568 | $_REQUEST['boards'] = explode(',', $_REQUEST['boards']); |
552 | - foreach ($_REQUEST['boards'] as $i => $b) |
|
553 | - $_REQUEST['boards'][$i] = (int) $b; |
|
569 | + foreach ($_REQUEST['boards'] as $i => $b) { |
|
570 | + $_REQUEST['boards'][$i] = (int) $b; |
|
571 | + } |
|
554 | 572 | |
555 | 573 | $request = $smcFunc['db_query']('', ' |
556 | 574 | SELECT b.id_board |
@@ -562,22 +580,24 @@ discard block |
||
562 | 580 | ) |
563 | 581 | ); |
564 | 582 | $boards = array(); |
565 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
566 | - $boards[] = $row['id_board']; |
|
583 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
584 | + $boards[] = $row['id_board']; |
|
585 | + } |
|
567 | 586 | $smcFunc['db_free_result']($request); |
568 | 587 | |
569 | - if (empty($boards)) |
|
570 | - fatal_lang_error('error_no_boards_selected'); |
|
588 | + if (empty($boards)) { |
|
589 | + fatal_lang_error('error_no_boards_selected'); |
|
590 | + } |
|
571 | 591 | |
572 | 592 | $query_this_board = 'id_board IN ({array_int:boards})'; |
573 | 593 | $query_parameters['boards'] = $boards; |
574 | 594 | $context['querystring_board_limits'] = ';boards=' . implode(',', $boards) . ';start=%1$d'; |
575 | - } |
|
576 | - elseif (!empty($_REQUEST['c'])) |
|
595 | + } elseif (!empty($_REQUEST['c'])) |
|
577 | 596 | { |
578 | 597 | $_REQUEST['c'] = explode(',', $_REQUEST['c']); |
579 | - foreach ($_REQUEST['c'] as $i => $c) |
|
580 | - $_REQUEST['c'][$i] = (int) $c; |
|
598 | + foreach ($_REQUEST['c'] as $i => $c) { |
|
599 | + $_REQUEST['c'][$i] = (int) $c; |
|
600 | + } |
|
581 | 601 | |
582 | 602 | $see_board = isset($_REQUEST['action']) && $_REQUEST['action'] == 'unreadreplies' ? 'query_see_board' : 'query_wanna_see_board'; |
583 | 603 | $request = $smcFunc['db_query']('', ' |
@@ -590,18 +610,19 @@ discard block |
||
590 | 610 | ) |
591 | 611 | ); |
592 | 612 | $boards = array(); |
593 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
594 | - $boards[] = $row['id_board']; |
|
613 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
614 | + $boards[] = $row['id_board']; |
|
615 | + } |
|
595 | 616 | $smcFunc['db_free_result']($request); |
596 | 617 | |
597 | - if (empty($boards)) |
|
598 | - fatal_lang_error('error_no_boards_selected'); |
|
618 | + if (empty($boards)) { |
|
619 | + fatal_lang_error('error_no_boards_selected'); |
|
620 | + } |
|
599 | 621 | |
600 | 622 | $query_this_board = 'id_board IN ({array_int:boards})'; |
601 | 623 | $query_parameters['boards'] = $boards; |
602 | 624 | $context['querystring_board_limits'] = ';c=' . implode(',', $_REQUEST['c']) . ';start=%1$d'; |
603 | - } |
|
604 | - else |
|
625 | + } else |
|
605 | 626 | { |
606 | 627 | $see_board = isset($_REQUEST['action']) && $_REQUEST['action'] == 'unreadreplies' ? 'query_see_board' : 'query_wanna_see_board'; |
607 | 628 | // Don't bother to show deleted posts! |
@@ -615,12 +636,14 @@ discard block |
||
615 | 636 | ) |
616 | 637 | ); |
617 | 638 | $boards = array(); |
618 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
619 | - $boards[] = $row['id_board']; |
|
639 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
640 | + $boards[] = $row['id_board']; |
|
641 | + } |
|
620 | 642 | $smcFunc['db_free_result']($request); |
621 | 643 | |
622 | - if (empty($boards)) |
|
623 | - fatal_lang_error('error_no_boards_available', false); |
|
644 | + if (empty($boards)) { |
|
645 | + fatal_lang_error('error_no_boards_available', false); |
|
646 | + } |
|
624 | 647 | |
625 | 648 | $query_this_board = 'id_board IN ({array_int:boards})'; |
626 | 649 | $query_parameters['boards'] = $boards; |
@@ -682,13 +705,14 @@ discard block |
||
682 | 705 | 'name' => $_REQUEST['action'] == 'unread' ? $txt['unread_topics_visit'] : $txt['unread_replies'] |
683 | 706 | ); |
684 | 707 | |
685 | - if ($context['showing_all_topics']) |
|
686 | - $context['linktree'][] = array( |
|
708 | + if ($context['showing_all_topics']) { |
|
709 | + $context['linktree'][] = array( |
|
687 | 710 | 'url' => $scripturl . '?action=' . $_REQUEST['action'] . ';all' . sprintf($context['querystring_board_limits'], 0) . $context['querystring_sort_limits'], |
688 | 711 | 'name' => $txt['unread_topics_all'] |
689 | 712 | ); |
690 | - else |
|
691 | - $txt['unread_topics_visit_none'] = strtr($txt['unread_topics_visit_none'], array('?action=unread;all' => '?action=unread;all' . sprintf($context['querystring_board_limits'], 0) . $context['querystring_sort_limits'])); |
|
713 | + } else { |
|
714 | + $txt['unread_topics_visit_none'] = strtr($txt['unread_topics_visit_none'], array('?action=unread;all' => '?action=unread;all' . sprintf($context['querystring_board_limits'], 0) . $context['querystring_sort_limits'])); |
|
715 | + } |
|
692 | 716 | |
693 | 717 | loadTemplate('Recent'); |
694 | 718 | loadTemplate('MessageIndex'); |
@@ -696,8 +720,9 @@ discard block |
||
696 | 720 | |
697 | 721 | // Setup the default topic icons... for checking they exist and the like ;) |
698 | 722 | $context['icon_sources'] = array(); |
699 | - foreach ($context['stable_icons'] as $icon) |
|
700 | - $context['icon_sources'][$icon] = 'images_url'; |
|
723 | + foreach ($context['stable_icons'] as $icon) { |
|
724 | + $context['icon_sources'][$icon] = 'images_url'; |
|
725 | + } |
|
701 | 726 | |
702 | 727 | $is_topics = $_REQUEST['action'] == 'unread'; |
703 | 728 | |
@@ -727,8 +752,7 @@ discard block |
||
727 | 752 | ); |
728 | 753 | list ($earliest_msg) = $smcFunc['db_fetch_row']($request); |
729 | 754 | $smcFunc['db_free_result']($request); |
730 | - } |
|
731 | - else |
|
755 | + } else |
|
732 | 756 | { |
733 | 757 | $request = $smcFunc['db_query']('', ' |
734 | 758 | SELECT MIN(lmr.id_msg) |
@@ -744,14 +768,14 @@ discard block |
||
744 | 768 | } |
745 | 769 | |
746 | 770 | // This is needed in case of topics marked unread. |
747 | - if (empty($earliest_msg)) |
|
748 | - $earliest_msg = 0; |
|
749 | - else |
|
771 | + if (empty($earliest_msg)) { |
|
772 | + $earliest_msg = 0; |
|
773 | + } else |
|
750 | 774 | { |
751 | 775 | // Using caching, when possible, to ignore the below slow query. |
752 | - if (isset($_SESSION['cached_log_time']) && $_SESSION['cached_log_time'][0] + 45 > time()) |
|
753 | - $earliest_msg2 = $_SESSION['cached_log_time'][1]; |
|
754 | - else |
|
776 | + if (isset($_SESSION['cached_log_time']) && $_SESSION['cached_log_time'][0] + 45 > time()) { |
|
777 | + $earliest_msg2 = $_SESSION['cached_log_time'][1]; |
|
778 | + } else |
|
755 | 779 | { |
756 | 780 | // This query is pretty slow, but it's needed to ensure nothing crucial is ignored. |
757 | 781 | $request = $smcFunc['db_query']('', ' |
@@ -766,8 +790,9 @@ discard block |
||
766 | 790 | $smcFunc['db_free_result']($request); |
767 | 791 | |
768 | 792 | // In theory this could be zero, if the first ever post is unread, so fudge it ;) |
769 | - if ($earliest_msg2 == 0) |
|
770 | - $earliest_msg2 = -1; |
|
793 | + if ($earliest_msg2 == 0) { |
|
794 | + $earliest_msg2 = -1; |
|
795 | + } |
|
771 | 796 | |
772 | 797 | $_SESSION['cached_log_time'] = array(time(), $earliest_msg2); |
773 | 798 | } |
@@ -805,9 +830,9 @@ discard block |
||
805 | 830 | 'db_error_skip' => true, |
806 | 831 | )) |
807 | 832 | ) !== false; |
833 | + } else { |
|
834 | + $have_temp_table = false; |
|
808 | 835 | } |
809 | - else |
|
810 | - $have_temp_table = false; |
|
811 | 836 | |
812 | 837 | if ($context['showing_all_topics'] && $have_temp_table) |
813 | 838 | { |
@@ -853,14 +878,15 @@ discard block |
||
853 | 878 | |
854 | 879 | $context['topics'] = array(); |
855 | 880 | $context['no_topic_listing'] = true; |
856 | - if ($context['querystring_board_limits'] == ';start=%1$d') |
|
857 | - $context['querystring_board_limits'] = ''; |
|
858 | - else |
|
859 | - $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
881 | + if ($context['querystring_board_limits'] == ';start=%1$d') { |
|
882 | + $context['querystring_board_limits'] = ''; |
|
883 | + } else { |
|
884 | + $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
885 | + } |
|
860 | 886 | return; |
887 | + } else { |
|
888 | + $min_message = (int) $min_message; |
|
861 | 889 | } |
862 | - else |
|
863 | - $min_message = (int) $min_message; |
|
864 | 890 | |
865 | 891 | $request = $smcFunc['db_query']('substring', ' |
866 | 892 | SELECT ' . $select_clause . ' |
@@ -889,8 +915,7 @@ discard block |
||
889 | 915 | 'limit' => $context['topics_per_page'], |
890 | 916 | )) |
891 | 917 | ); |
892 | - } |
|
893 | - elseif ($is_topics) |
|
918 | + } elseif ($is_topics) |
|
894 | 919 | { |
895 | 920 | $request = $smcFunc['db_query']('', ' |
896 | 921 | SELECT COUNT(*), MIN(t.id_last_msg) |
@@ -941,14 +966,15 @@ discard block |
||
941 | 966 | |
942 | 967 | $context['topics'] = array(); |
943 | 968 | $context['no_topic_listing'] = true; |
944 | - if ($context['querystring_board_limits'] == ';start=%d') |
|
945 | - $context['querystring_board_limits'] = ''; |
|
946 | - else |
|
947 | - $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
969 | + if ($context['querystring_board_limits'] == ';start=%d') { |
|
970 | + $context['querystring_board_limits'] = ''; |
|
971 | + } else { |
|
972 | + $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
973 | + } |
|
948 | 974 | return; |
975 | + } else { |
|
976 | + $min_message = (int) $min_message; |
|
949 | 977 | } |
950 | - else |
|
951 | - $min_message = (int) $min_message; |
|
952 | 978 | |
953 | 979 | $request = $smcFunc['db_query']('substring', ' |
954 | 980 | SELECT ' . $select_clause . ' |
@@ -978,8 +1004,7 @@ discard block |
||
978 | 1004 | 'limit' => $context['topics_per_page'], |
979 | 1005 | )) |
980 | 1006 | ); |
981 | - } |
|
982 | - else |
|
1007 | + } else |
|
983 | 1008 | { |
984 | 1009 | if ($modSettings['totalMessages'] > 100000) |
985 | 1010 | { |
@@ -1031,8 +1056,8 @@ discard block |
||
1031 | 1056 | ) !== false; |
1032 | 1057 | |
1033 | 1058 | // If that worked, create a sample of the log_topics table too. |
1034 | - if ($have_temp_table) |
|
1035 | - $have_temp_table = $smcFunc['db_query']('', ' |
|
1059 | + if ($have_temp_table) { |
|
1060 | + $have_temp_table = $smcFunc['db_query']('', ' |
|
1036 | 1061 | CREATE TEMPORARY TABLE {db_prefix}log_topics_posted_in ( |
1037 | 1062 | PRIMARY KEY (id_topic) |
1038 | 1063 | ) |
@@ -1045,6 +1070,7 @@ discard block |
||
1045 | 1070 | 'db_error_skip' => true, |
1046 | 1071 | ) |
1047 | 1072 | ) !== false; |
1073 | + } |
|
1048 | 1074 | } |
1049 | 1075 | |
1050 | 1076 | if (!empty($have_temp_table)) |
@@ -1060,8 +1086,7 @@ discard block |
||
1060 | 1086 | ); |
1061 | 1087 | list ($num_topics) = $smcFunc['db_fetch_row']($request); |
1062 | 1088 | $smcFunc['db_free_result']($request); |
1063 | - } |
|
1064 | - else |
|
1089 | + } else |
|
1065 | 1090 | { |
1066 | 1091 | $request = $smcFunc['db_query']('unread_fetch_topic_count', ' |
1067 | 1092 | SELECT COUNT(DISTINCT t.id_topic), MIN(t.id_last_msg) |
@@ -1102,15 +1127,16 @@ discard block |
||
1102 | 1127 | { |
1103 | 1128 | $context['topics'] = array(); |
1104 | 1129 | $context['no_topic_listing'] = true; |
1105 | - if ($context['querystring_board_limits'] == ';start=%d') |
|
1106 | - $context['querystring_board_limits'] = ''; |
|
1107 | - else |
|
1108 | - $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
1130 | + if ($context['querystring_board_limits'] == ';start=%d') { |
|
1131 | + $context['querystring_board_limits'] = ''; |
|
1132 | + } else { |
|
1133 | + $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
1134 | + } |
|
1109 | 1135 | return; |
1110 | 1136 | } |
1111 | 1137 | |
1112 | - if (!empty($have_temp_table)) |
|
1113 | - $request = $smcFunc['db_query']('', ' |
|
1138 | + if (!empty($have_temp_table)) { |
|
1139 | + $request = $smcFunc['db_query']('', ' |
|
1114 | 1140 | SELECT t.id_topic |
1115 | 1141 | FROM {db_prefix}topics_posted_in AS t |
1116 | 1142 | LEFT JOIN {db_prefix}log_topics_posted_in AS lt ON (lt.id_topic = t.id_topic) |
@@ -1124,8 +1150,8 @@ discard block |
||
1124 | 1150 | 'limit' => $context['topics_per_page'], |
1125 | 1151 | )) |
1126 | 1152 | ); |
1127 | - else |
|
1128 | - $request = $smcFunc['db_query']('', ' |
|
1153 | + } else { |
|
1154 | + $request = $smcFunc['db_query']('', ' |
|
1129 | 1155 | SELECT DISTINCT t.id_topic,'.$_REQUEST['sort'].' |
1130 | 1156 | FROM {db_prefix}topics AS t |
1131 | 1157 | INNER JOIN {db_prefix}messages AS m ON (m.id_topic = t.id_topic AND m.id_member = {int:current_member})' . (strpos($_REQUEST['sort'], 'ms.') === false ? '' : ' |
@@ -1149,10 +1175,12 @@ discard block |
||
1149 | 1175 | 'sort' => $_REQUEST['sort'], |
1150 | 1176 | )) |
1151 | 1177 | ); |
1178 | + } |
|
1152 | 1179 | |
1153 | 1180 | $topics = array(); |
1154 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1155 | - $topics[] = $row['id_topic']; |
|
1181 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1182 | + $topics[] = $row['id_topic']; |
|
1183 | + } |
|
1156 | 1184 | $smcFunc['db_free_result']($request); |
1157 | 1185 | |
1158 | 1186 | // Sanity... where have you gone? |
@@ -1160,10 +1188,11 @@ discard block |
||
1160 | 1188 | { |
1161 | 1189 | $context['topics'] = array(); |
1162 | 1190 | $context['no_topic_listing'] = true; |
1163 | - if ($context['querystring_board_limits'] == ';start=%d') |
|
1164 | - $context['querystring_board_limits'] = ''; |
|
1165 | - else |
|
1166 | - $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
1191 | + if ($context['querystring_board_limits'] == ';start=%d') { |
|
1192 | + $context['querystring_board_limits'] = ''; |
|
1193 | + } else { |
|
1194 | + $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
1195 | + } |
|
1167 | 1196 | return; |
1168 | 1197 | } |
1169 | 1198 | |
@@ -1197,8 +1226,9 @@ discard block |
||
1197 | 1226 | |
1198 | 1227 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1199 | 1228 | { |
1200 | - if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') |
|
1201 | - continue; |
|
1229 | + if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') { |
|
1230 | + continue; |
|
1231 | + } |
|
1202 | 1232 | |
1203 | 1233 | $topic_ids[] = $row['id_topic']; |
1204 | 1234 | |
@@ -1206,11 +1236,13 @@ discard block |
||
1206 | 1236 | { |
1207 | 1237 | // Limit them to 128 characters - do this FIRST because it's a lot of wasted censoring otherwise. |
1208 | 1238 | $row['first_body'] = strip_tags(strtr(parse_bbc($row['first_body'], $row['first_smileys'], $row['id_first_msg']), array('<br>' => ' '))); |
1209 | - if ($smcFunc['strlen']($row['first_body']) > 128) |
|
1210 | - $row['first_body'] = $smcFunc['substr']($row['first_body'], 0, 128) . '...'; |
|
1239 | + if ($smcFunc['strlen']($row['first_body']) > 128) { |
|
1240 | + $row['first_body'] = $smcFunc['substr']($row['first_body'], 0, 128) . '...'; |
|
1241 | + } |
|
1211 | 1242 | $row['last_body'] = strip_tags(strtr(parse_bbc($row['last_body'], $row['last_smileys'], $row['id_last_msg']), array('<br>' => ' '))); |
1212 | - if ($smcFunc['strlen']($row['last_body']) > 128) |
|
1213 | - $row['last_body'] = $smcFunc['substr']($row['last_body'], 0, 128) . '...'; |
|
1243 | + if ($smcFunc['strlen']($row['last_body']) > 128) { |
|
1244 | + $row['last_body'] = $smcFunc['substr']($row['last_body'], 0, 128) . '...'; |
|
1245 | + } |
|
1214 | 1246 | |
1215 | 1247 | // Censor the subject and message preview. |
1216 | 1248 | censorText($row['first_subject']); |
@@ -1221,23 +1253,22 @@ discard block |
||
1221 | 1253 | { |
1222 | 1254 | $row['last_subject'] = $row['first_subject']; |
1223 | 1255 | $row['last_body'] = $row['first_body']; |
1224 | - } |
|
1225 | - else |
|
1256 | + } else |
|
1226 | 1257 | { |
1227 | 1258 | censorText($row['last_subject']); |
1228 | 1259 | censorText($row['last_body']); |
1229 | 1260 | } |
1230 | - } |
|
1231 | - else |
|
1261 | + } else |
|
1232 | 1262 | { |
1233 | 1263 | $row['first_body'] = ''; |
1234 | 1264 | $row['last_body'] = ''; |
1235 | 1265 | censorText($row['first_subject']); |
1236 | 1266 | |
1237 | - if ($row['id_first_msg'] == $row['id_last_msg']) |
|
1238 | - $row['last_subject'] = $row['first_subject']; |
|
1239 | - else |
|
1240 | - censorText($row['last_subject']); |
|
1267 | + if ($row['id_first_msg'] == $row['id_last_msg']) { |
|
1268 | + $row['last_subject'] = $row['first_subject']; |
|
1269 | + } else { |
|
1270 | + censorText($row['last_subject']); |
|
1271 | + } |
|
1241 | 1272 | } |
1242 | 1273 | |
1243 | 1274 | // Decide how many pages the topic should have. |
@@ -1249,29 +1280,32 @@ discard block |
||
1249 | 1280 | $pages = constructPageIndex($scripturl . '?topic=' . $row['id_topic'] . '.%1$d', $start, $topic_length, $messages_per_page, true, false); |
1250 | 1281 | |
1251 | 1282 | // If we can use all, show all. |
1252 | - if (!empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages']) |
|
1253 | - $pages .= ' <a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>'; |
|
1283 | + if (!empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages']) { |
|
1284 | + $pages .= ' <a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>'; |
|
1285 | + } |
|
1286 | + } else { |
|
1287 | + $pages = ''; |
|
1254 | 1288 | } |
1255 | 1289 | |
1256 | - else |
|
1257 | - $pages = ''; |
|
1258 | - |
|
1259 | 1290 | // We need to check the topic icons exist... you can never be too sure! |
1260 | 1291 | if (!empty($modSettings['messageIconChecks_enable'])) |
1261 | 1292 | { |
1262 | 1293 | // First icon first... as you'd expect. |
1263 | - if (!isset($context['icon_sources'][$row['first_icon']])) |
|
1264 | - $context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
1294 | + if (!isset($context['icon_sources'][$row['first_icon']])) { |
|
1295 | + $context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
1296 | + } |
|
1265 | 1297 | // Last icon... last... duh. |
1266 | - if (!isset($context['icon_sources'][$row['last_icon']])) |
|
1267 | - $context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
1268 | - } |
|
1269 | - else |
|
1298 | + if (!isset($context['icon_sources'][$row['last_icon']])) { |
|
1299 | + $context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
1300 | + } |
|
1301 | + } else |
|
1270 | 1302 | { |
1271 | - if (!isset($context['icon_sources'][$row['first_icon']])) |
|
1272 | - $context['icon_sources'][$row['first_icon']] = 'images_url'; |
|
1273 | - if (!isset($context['icon_sources'][$row['last_icon']])) |
|
1274 | - $context['icon_sources'][$row['last_icon']] = 'images_url'; |
|
1303 | + if (!isset($context['icon_sources'][$row['first_icon']])) { |
|
1304 | + $context['icon_sources'][$row['first_icon']] = 'images_url'; |
|
1305 | + } |
|
1306 | + if (!isset($context['icon_sources'][$row['last_icon']])) { |
|
1307 | + $context['icon_sources'][$row['last_icon']] = 'images_url'; |
|
1308 | + } |
|
1275 | 1309 | } |
1276 | 1310 | |
1277 | 1311 | // Force the recycling icon if appropriate |
@@ -1285,12 +1319,14 @@ discard block |
||
1285 | 1319 | $colorClass = 'windowbg'; |
1286 | 1320 | |
1287 | 1321 | // Sticky topics should get a different color, too. |
1288 | - if ($row['is_sticky']) |
|
1289 | - $colorClass .= ' sticky'; |
|
1322 | + if ($row['is_sticky']) { |
|
1323 | + $colorClass .= ' sticky'; |
|
1324 | + } |
|
1290 | 1325 | |
1291 | 1326 | // Locked topics get special treatment as well. |
1292 | - if ($row['locked']) |
|
1293 | - $colorClass .= ' locked'; |
|
1327 | + if ($row['locked']) { |
|
1328 | + $colorClass .= ' locked'; |
|
1329 | + } |
|
1294 | 1330 | |
1295 | 1331 | // And build the array. |
1296 | 1332 | $context['topics'][$row['id_topic']] = array( |
@@ -1387,8 +1423,9 @@ discard block |
||
1387 | 1423 | ); |
1388 | 1424 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
1389 | 1425 | { |
1390 | - if (empty($context['topics'][$row['id_topic']]['is_posted_in'])) |
|
1391 | - $context['topics'][$row['id_topic']]['is_posted_in'] = true; |
|
1426 | + if (empty($context['topics'][$row['id_topic']]['is_posted_in'])) { |
|
1427 | + $context['topics'][$row['id_topic']]['is_posted_in'] = true; |
|
1428 | + } |
|
1392 | 1429 | } |
1393 | 1430 | $smcFunc['db_free_result']($result); |
1394 | 1431 | } |
@@ -1403,28 +1440,30 @@ discard block |
||
1403 | 1440 | 'markread' => array('text' => !empty($context['no_board_limits']) ? 'mark_as_read' : 'mark_read_short', 'image' => 'markread.png', 'custom' => 'data-confirm="'. $txt['are_sure_mark_read'] .'"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=' . (!empty($context['no_board_limits']) ? 'all' : 'board' . $context['querystring_board_limits']) . ';' . $context['session_var'] . '=' . $context['session_id']), |
1404 | 1441 | ); |
1405 | 1442 | |
1406 | - if ($context['showCheckboxes']) |
|
1407 | - $context['recent_buttons']['markselectread'] = array( |
|
1443 | + if ($context['showCheckboxes']) { |
|
1444 | + $context['recent_buttons']['markselectread'] = array( |
|
1408 | 1445 | 'text' => 'quick_mod_markread', |
1409 | 1446 | 'image' => 'markselectedread.png', |
1410 | 1447 | 'url' => 'javascript:document.quickModForm.submit();', |
1411 | 1448 | ); |
1449 | + } |
|
1412 | 1450 | |
1413 | - if (!empty($context['topics']) && !$context['showing_all_topics']) |
|
1414 | - $context['recent_buttons']['readall'] = array('text' => 'unread_topics_all', 'image' => 'markreadall.png', 'url' => $scripturl . '?action=unread;all' . $context['querystring_board_limits'], 'active' => true); |
|
1415 | - } |
|
1416 | - elseif (!$is_topics && isset($context['topics_to_mark'])) |
|
1451 | + if (!empty($context['topics']) && !$context['showing_all_topics']) { |
|
1452 | + $context['recent_buttons']['readall'] = array('text' => 'unread_topics_all', 'image' => 'markreadall.png', 'url' => $scripturl . '?action=unread;all' . $context['querystring_board_limits'], 'active' => true); |
|
1453 | + } |
|
1454 | + } elseif (!$is_topics && isset($context['topics_to_mark'])) |
|
1417 | 1455 | { |
1418 | 1456 | $context['recent_buttons'] = array( |
1419 | 1457 | 'markread' => array('text' => 'mark_as_read', 'image' => 'markread.png', 'custom' => 'data-confirm="'. $txt['are_sure_mark_read'] .'"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=unreadreplies;topics=' . $context['topics_to_mark'] . ';' . $context['session_var'] . '=' . $context['session_id']), |
1420 | 1458 | ); |
1421 | 1459 | |
1422 | - if ($context['showCheckboxes']) |
|
1423 | - $context['recent_buttons']['markselectread'] = array( |
|
1460 | + if ($context['showCheckboxes']) { |
|
1461 | + $context['recent_buttons']['markselectread'] = array( |
|
1424 | 1462 | 'text' => 'quick_mod_markread', |
1425 | 1463 | 'image' => 'markselectedread.png', |
1426 | 1464 | 'url' => 'javascript:document.quickModForm.submit();', |
1427 | 1465 | ); |
1466 | + } |
|
1428 | 1467 | } |
1429 | 1468 | |
1430 | 1469 | // Allow mods to add additional buttons here |
@@ -12,8 +12,9 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Don't do anything if SMF is already loaded. |
15 | -if (defined('SMF')) |
|
15 | +if (defined('SMF')) { |
|
16 | 16 | return true; |
17 | +} |
|
17 | 18 | |
18 | 19 | define('SMF', 'SSI'); |
19 | 20 | |
@@ -28,16 +29,18 @@ discard block |
||
28 | 29 | $time_start = microtime(true); |
29 | 30 | |
30 | 31 | // Just being safe... |
31 | -foreach (array('db_character_set', 'cachedir') as $variable) |
|
32 | +foreach (array('db_character_set', 'cachedir') as $variable) { |
|
32 | 33 | if (isset($GLOBALS[$variable])) |
33 | 34 | unset($GLOBALS[$variable]); |
35 | +} |
|
34 | 36 | |
35 | 37 | // Get the forum's settings for database and file paths. |
36 | 38 | require_once(dirname(__FILE__) . '/Settings.php'); |
37 | 39 | |
38 | 40 | // Make absolutely sure the cache directory is defined. |
39 | -if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) |
|
41 | +if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) { |
|
40 | 42 | $cachedir = $boarddir . '/cache'; |
43 | +} |
|
41 | 44 | |
42 | 45 | $ssi_error_reporting = error_reporting(E_ALL); |
43 | 46 | /* Set this to one of three values depending on what you want to happen in the case of a fatal error. |
@@ -48,12 +51,14 @@ discard block |
||
48 | 51 | $ssi_on_error_method = false; |
49 | 52 | |
50 | 53 | // Don't do john didley if the forum's been shut down completely. |
51 | -if ($maintenance == 2 && (!isset($ssi_maintenance_off) || $ssi_maintenance_off !== true)) |
|
54 | +if ($maintenance == 2 && (!isset($ssi_maintenance_off) || $ssi_maintenance_off !== true)) { |
|
52 | 55 | die($mmessage); |
56 | +} |
|
53 | 57 | |
54 | 58 | // Fix for using the current directory as a path. |
55 | -if (substr($sourcedir, 0, 1) == '.' && substr($sourcedir, 1, 1) != '.') |
|
59 | +if (substr($sourcedir, 0, 1) == '.' && substr($sourcedir, 1, 1) != '.') { |
|
56 | 60 | $sourcedir = dirname(__FILE__) . substr($sourcedir, 1); |
61 | +} |
|
57 | 62 | |
58 | 63 | // Load the important includes. |
59 | 64 | require_once($sourcedir . '/QueryString.php'); |
@@ -78,26 +83,30 @@ discard block |
||
78 | 83 | cleanRequest(); |
79 | 84 | |
80 | 85 | // Seed the random generator? |
81 | -if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69) |
|
86 | +if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69) { |
|
82 | 87 | smf_seed_generator(); |
88 | +} |
|
83 | 89 | |
84 | 90 | // Check on any hacking attempts. |
85 | -if (isset($_REQUEST['GLOBALS']) || isset($_COOKIE['GLOBALS'])) |
|
91 | +if (isset($_REQUEST['GLOBALS']) || isset($_COOKIE['GLOBALS'])) { |
|
86 | 92 | die('No direct access...'); |
87 | -elseif (isset($_REQUEST['ssi_theme']) && (int) $_REQUEST['ssi_theme'] == (int) $ssi_theme) |
|
93 | +} elseif (isset($_REQUEST['ssi_theme']) && (int) $_REQUEST['ssi_theme'] == (int) $ssi_theme) { |
|
88 | 94 | die('No direct access...'); |
89 | -elseif (isset($_COOKIE['ssi_theme']) && (int) $_COOKIE['ssi_theme'] == (int) $ssi_theme) |
|
95 | +} elseif (isset($_COOKIE['ssi_theme']) && (int) $_COOKIE['ssi_theme'] == (int) $ssi_theme) { |
|
90 | 96 | die('No direct access...'); |
91 | -elseif (isset($_REQUEST['ssi_layers'], $ssi_layers) && (@get_magic_quotes_gpc() ? stripslashes($_REQUEST['ssi_layers']) : $_REQUEST['ssi_layers']) == $ssi_layers) |
|
97 | +} elseif (isset($_REQUEST['ssi_layers'], $ssi_layers) && (@get_magic_quotes_gpc() ? stripslashes($_REQUEST['ssi_layers']) : $_REQUEST['ssi_layers']) == $ssi_layers) { |
|
92 | 98 | die('No direct access...'); |
93 | -if (isset($_REQUEST['context'])) |
|
99 | +} |
|
100 | +if (isset($_REQUEST['context'])) { |
|
94 | 101 | die('No direct access...'); |
102 | +} |
|
95 | 103 | |
96 | 104 | // Gzip output? (because it must be boolean and true, this can't be hacked.) |
97 | -if (isset($ssi_gzip) && $ssi_gzip === true && ini_get('zlib.output_compression') != '1' && ini_get('output_handler') != 'ob_gzhandler' && version_compare(PHP_VERSION, '4.2.0', '>=')) |
|
105 | +if (isset($ssi_gzip) && $ssi_gzip === true && ini_get('zlib.output_compression') != '1' && ini_get('output_handler') != 'ob_gzhandler' && version_compare(PHP_VERSION, '4.2.0', '>=')) { |
|
98 | 106 | ob_start('ob_gzhandler'); |
99 | -else |
|
107 | +} else { |
|
100 | 108 | $modSettings['enableCompressedOutput'] = '0'; |
109 | +} |
|
101 | 110 | |
102 | 111 | /** |
103 | 112 | * An autoloader for certain classes. |
@@ -146,9 +155,9 @@ discard block |
||
146 | 155 | ob_start('ob_sessrewrite'); |
147 | 156 | |
148 | 157 | // Start the session... known to scramble SSI includes in cases... |
149 | -if (!headers_sent()) |
|
158 | +if (!headers_sent()) { |
|
150 | 159 | loadSession(); |
151 | -else |
|
160 | +} else |
|
152 | 161 | { |
153 | 162 | if (isset($_COOKIE[session_name()]) || isset($_REQUEST[session_name()])) |
154 | 163 | { |
@@ -182,12 +191,14 @@ discard block |
||
182 | 191 | loadTheme(isset($ssi_theme) ? (int) $ssi_theme : 0); |
183 | 192 | |
184 | 193 | // @todo: probably not the best place, but somewhere it should be set... |
185 | -if (!headers_sent()) |
|
194 | +if (!headers_sent()) { |
|
186 | 195 | header('content-type: text/html; charset=' . (empty($modSettings['global_character_set']) ? (empty($txt['lang_character_set']) ? 'ISO-8859-1' : $txt['lang_character_set']) : $modSettings['global_character_set'])); |
196 | +} |
|
187 | 197 | |
188 | 198 | // Take care of any banning that needs to be done. |
189 | -if (isset($_REQUEST['ssi_ban']) || (isset($ssi_ban) && $ssi_ban === true)) |
|
199 | +if (isset($_REQUEST['ssi_ban']) || (isset($ssi_ban) && $ssi_ban === true)) { |
|
190 | 200 | is_not_banned(); |
201 | +} |
|
191 | 202 | |
192 | 203 | // Do we allow guests in here? |
193 | 204 | if (empty($ssi_guest_access) && empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && basename($_SERVER['PHP_SELF']) != 'SSI.php') |
@@ -202,17 +213,19 @@ discard block |
||
202 | 213 | { |
203 | 214 | $context['template_layers'] = $ssi_layers; |
204 | 215 | template_header(); |
205 | -} |
|
206 | -else |
|
216 | +} else { |
|
207 | 217 | setupThemeContext(); |
218 | +} |
|
208 | 219 | |
209 | 220 | // Make sure they didn't muss around with the settings... but only if it's not cli. |
210 | -if (isset($_SERVER['REMOTE_ADDR']) && !isset($_SERVER['is_cli']) && session_id() == '') |
|
221 | +if (isset($_SERVER['REMOTE_ADDR']) && !isset($_SERVER['is_cli']) && session_id() == '') { |
|
211 | 222 | trigger_error($txt['ssi_session_broken'], E_USER_NOTICE); |
223 | +} |
|
212 | 224 | |
213 | 225 | // Without visiting the forum this session variable might not be set on submit. |
214 | -if (!isset($_SESSION['USER_AGENT']) && (!isset($_GET['ssi_function']) || $_GET['ssi_function'] !== 'pollVote')) |
|
226 | +if (!isset($_SESSION['USER_AGENT']) && (!isset($_GET['ssi_function']) || $_GET['ssi_function'] !== 'pollVote')) { |
|
215 | 227 | $_SESSION['USER_AGENT'] = $_SERVER['HTTP_USER_AGENT']; |
228 | +} |
|
216 | 229 | |
217 | 230 | // Have the ability to easily add functions to SSI. |
218 | 231 | call_integration_hook('integrate_SSI'); |
@@ -221,11 +234,13 @@ discard block |
||
221 | 234 | if (basename($_SERVER['PHP_SELF']) == 'SSI.php') |
222 | 235 | { |
223 | 236 | // You shouldn't just access SSI.php directly by URL!! |
224 | - if (!isset($_GET['ssi_function'])) |
|
225 | - die(sprintf($txt['ssi_not_direct'], $user_info['is_admin'] ? '\'' . addslashes(__FILE__) . '\'' : '\'SSI.php\'')); |
|
237 | + if (!isset($_GET['ssi_function'])) { |
|
238 | + die(sprintf($txt['ssi_not_direct'], $user_info['is_admin'] ? '\'' . addslashes(__FILE__) . '\'' : '\'SSI.php\'')); |
|
239 | + } |
|
226 | 240 | // Call a function passed by GET. |
227 | - if (function_exists('ssi_' . $_GET['ssi_function']) && (!empty($modSettings['allow_guestAccess']) || !$user_info['is_guest'])) |
|
228 | - call_user_func('ssi_' . $_GET['ssi_function']); |
|
241 | + if (function_exists('ssi_' . $_GET['ssi_function']) && (!empty($modSettings['allow_guestAccess']) || !$user_info['is_guest'])) { |
|
242 | + call_user_func('ssi_' . $_GET['ssi_function']); |
|
243 | + } |
|
229 | 244 | exit; |
230 | 245 | } |
231 | 246 | |
@@ -242,9 +257,10 @@ discard block |
||
242 | 257 | */ |
243 | 258 | function ssi_shutdown() |
244 | 259 | { |
245 | - if (!isset($_GET['ssi_function']) || $_GET['ssi_function'] != 'shutdown') |
|
246 | - template_footer(); |
|
247 | -} |
|
260 | + if (!isset($_GET['ssi_function']) || $_GET['ssi_function'] != 'shutdown') { |
|
261 | + template_footer(); |
|
262 | + } |
|
263 | + } |
|
248 | 264 | |
249 | 265 | /** |
250 | 266 | * Display a welcome message, like: Hey, User, you have 0 messages, 0 are new. |
@@ -257,15 +273,17 @@ discard block |
||
257 | 273 | |
258 | 274 | if ($output_method == 'echo') |
259 | 275 | { |
260 | - if ($context['user']['is_guest']) |
|
261 | - echo sprintf($txt[$context['can_register'] ? 'welcome_guest_register' : 'welcome_guest'], $txt['guest_title'], $context['forum_name_html_safe'], $scripturl . '?action=login', 'return reqOverlayDiv(this.href, ' . JavaScriptEscape($txt['login']) . ');', $scripturl . '?action=signup'); |
|
262 | - else |
|
263 | - echo $txt['hello_member'], ' <strong>', $context['user']['name'], '</strong>', allowedTo('pm_read') ? ', ' . (empty($context['user']['messages']) ? $txt['msg_alert_no_messages'] : (($context['user']['messages'] == 1 ? sprintf($txt['msg_alert_one_message'], $scripturl . '?action=pm') : sprintf($txt['msg_alert_many_message'], $scripturl . '?action=pm', $context['user']['messages'])) . ', ' . ($context['user']['unread_messages'] == 1 ? $txt['msg_alert_one_new'] : sprintf($txt['msg_alert_many_new'], $context['user']['unread_messages'])))) : ''; |
|
276 | + if ($context['user']['is_guest']) { |
|
277 | + echo sprintf($txt[$context['can_register'] ? 'welcome_guest_register' : 'welcome_guest'], $txt['guest_title'], $context['forum_name_html_safe'], $scripturl . '?action=login', 'return reqOverlayDiv(this.href, ' . JavaScriptEscape($txt['login']) . ');', $scripturl . '?action=signup'); |
|
278 | + } else { |
|
279 | + echo $txt['hello_member'], ' <strong>', $context['user']['name'], '</strong>', allowedTo('pm_read') ? ', ' . (empty($context['user']['messages']) ? $txt['msg_alert_no_messages'] : (($context['user']['messages'] == 1 ? sprintf($txt['msg_alert_one_message'], $scripturl . '?action=pm') : sprintf($txt['msg_alert_many_message'], $scripturl . '?action=pm', $context['user']['messages'])) . ', ' . ($context['user']['unread_messages'] == 1 ? $txt['msg_alert_one_new'] : sprintf($txt['msg_alert_many_new'], $context['user']['unread_messages'])))) : ''; |
|
280 | + } |
|
264 | 281 | } |
265 | 282 | // Don't echo... then do what?! |
266 | - else |
|
267 | - return $context['user']; |
|
268 | -} |
|
283 | + else { |
|
284 | + return $context['user']; |
|
285 | + } |
|
286 | + } |
|
269 | 287 | |
270 | 288 | /** |
271 | 289 | * Display a menu bar, like is displayed at the top of the forum. |
@@ -276,12 +294,14 @@ discard block |
||
276 | 294 | { |
277 | 295 | global $context; |
278 | 296 | |
279 | - if ($output_method == 'echo') |
|
280 | - template_menu(); |
|
297 | + if ($output_method == 'echo') { |
|
298 | + template_menu(); |
|
299 | + } |
|
281 | 300 | // What else could this do? |
282 | - else |
|
283 | - return $context['menu_buttons']; |
|
284 | -} |
|
301 | + else { |
|
302 | + return $context['menu_buttons']; |
|
303 | + } |
|
304 | + } |
|
285 | 305 | |
286 | 306 | /** |
287 | 307 | * Show a logout link. |
@@ -293,20 +313,23 @@ discard block |
||
293 | 313 | { |
294 | 314 | global $context, $txt, $scripturl; |
295 | 315 | |
296 | - if ($redirect_to != '') |
|
297 | - $_SESSION['logout_url'] = $redirect_to; |
|
316 | + if ($redirect_to != '') { |
|
317 | + $_SESSION['logout_url'] = $redirect_to; |
|
318 | + } |
|
298 | 319 | |
299 | 320 | // Guests can't log out. |
300 | - if ($context['user']['is_guest']) |
|
301 | - return false; |
|
321 | + if ($context['user']['is_guest']) { |
|
322 | + return false; |
|
323 | + } |
|
302 | 324 | |
303 | 325 | $link = '<a href="' . $scripturl . '?action=logout;' . $context['session_var'] . '=' . $context['session_id'] . '">' . $txt['logout'] . '</a>'; |
304 | 326 | |
305 | - if ($output_method == 'echo') |
|
306 | - echo $link; |
|
307 | - else |
|
308 | - return $link; |
|
309 | -} |
|
327 | + if ($output_method == 'echo') { |
|
328 | + echo $link; |
|
329 | + } else { |
|
330 | + return $link; |
|
331 | + } |
|
332 | + } |
|
310 | 333 | |
311 | 334 | /** |
312 | 335 | * Recent post list: [board] Subject by Poster Date |
@@ -322,17 +345,17 @@ discard block |
||
322 | 345 | global $modSettings, $context; |
323 | 346 | |
324 | 347 | // Excluding certain boards... |
325 | - if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) |
|
326 | - $exclude_boards = array($modSettings['recycle_board']); |
|
327 | - else |
|
328 | - $exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards)); |
|
348 | + if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) { |
|
349 | + $exclude_boards = array($modSettings['recycle_board']); |
|
350 | + } else { |
|
351 | + $exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards)); |
|
352 | + } |
|
329 | 353 | |
330 | 354 | // What about including certain boards - note we do some protection here as pre-2.0 didn't have this parameter. |
331 | 355 | if (is_array($include_boards) || (int) $include_boards === $include_boards) |
332 | 356 | { |
333 | 357 | $include_boards = is_array($include_boards) ? $include_boards : array($include_boards); |
334 | - } |
|
335 | - elseif ($include_boards != null) |
|
358 | + } elseif ($include_boards != null) |
|
336 | 359 | { |
337 | 360 | $include_boards = array(); |
338 | 361 | } |
@@ -369,8 +392,9 @@ discard block |
||
369 | 392 | { |
370 | 393 | global $modSettings; |
371 | 394 | |
372 | - if (empty($post_ids)) |
|
373 | - return; |
|
395 | + if (empty($post_ids)) { |
|
396 | + return; |
|
397 | + } |
|
374 | 398 | |
375 | 399 | // Allow the user to request more than one - why not? |
376 | 400 | $post_ids = is_array($post_ids) ? $post_ids : array($post_ids); |
@@ -405,8 +429,9 @@ discard block |
||
405 | 429 | global $scripturl, $txt, $user_info; |
406 | 430 | global $modSettings, $smcFunc, $context; |
407 | 431 | |
408 | - if (!empty($modSettings['enable_likes'])) |
|
409 | - $context['can_like'] = allowedTo('likes_like'); |
|
432 | + if (!empty($modSettings['enable_likes'])) { |
|
433 | + $context['can_like'] = allowedTo('likes_like'); |
|
434 | + } |
|
410 | 435 | |
411 | 436 | // Find all the posts. Newer ones will have higher IDs. |
412 | 437 | $request = $smcFunc['db_query']('substring', ' |
@@ -472,12 +497,13 @@ discard block |
||
472 | 497 | ); |
473 | 498 | |
474 | 499 | // Get the likes for each message. |
475 | - if (!empty($modSettings['enable_likes'])) |
|
476 | - $posts[$row['id_msg']]['likes'] = array( |
|
500 | + if (!empty($modSettings['enable_likes'])) { |
|
501 | + $posts[$row['id_msg']]['likes'] = array( |
|
477 | 502 | 'count' => $row['likes'], |
478 | 503 | 'you' => in_array($row['id_msg'], prepareLikesContext($row['id_topic'])), |
479 | 504 | 'can_like' => !$context['user']['is_guest'] && $row['id_member'] != $context['user']['id'] && !empty($context['can_like']), |
480 | 505 | ); |
506 | + } |
|
481 | 507 | } |
482 | 508 | $smcFunc['db_free_result']($request); |
483 | 509 | |
@@ -485,13 +511,14 @@ discard block |
||
485 | 511 | call_integration_hook('integrate_ssi_queryPosts', array(&$posts)); |
486 | 512 | |
487 | 513 | // Just return it. |
488 | - if ($output_method != 'echo' || empty($posts)) |
|
489 | - return $posts; |
|
514 | + if ($output_method != 'echo' || empty($posts)) { |
|
515 | + return $posts; |
|
516 | + } |
|
490 | 517 | |
491 | 518 | echo ' |
492 | 519 | <table style="border: none" class="ssi_table">'; |
493 | - foreach ($posts as $post) |
|
494 | - echo ' |
|
520 | + foreach ($posts as $post) { |
|
521 | + echo ' |
|
495 | 522 | <tr> |
496 | 523 | <td style="text-align: right; vertical-align: top; white-space: nowrap"> |
497 | 524 | [', $post['board']['link'], '] |
@@ -505,6 +532,7 @@ discard block |
||
505 | 532 | ', $post['time'], ' |
506 | 533 | </td> |
507 | 534 | </tr>'; |
535 | + } |
|
508 | 536 | echo ' |
509 | 537 | </table>'; |
510 | 538 | } |
@@ -522,25 +550,26 @@ discard block |
||
522 | 550 | global $settings, $scripturl, $txt, $user_info; |
523 | 551 | global $modSettings, $smcFunc, $context; |
524 | 552 | |
525 | - if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) |
|
526 | - $exclude_boards = array($modSettings['recycle_board']); |
|
527 | - else |
|
528 | - $exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards)); |
|
553 | + if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) { |
|
554 | + $exclude_boards = array($modSettings['recycle_board']); |
|
555 | + } else { |
|
556 | + $exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards)); |
|
557 | + } |
|
529 | 558 | |
530 | 559 | // Only some boards?. |
531 | 560 | if (is_array($include_boards) || (int) $include_boards === $include_boards) |
532 | 561 | { |
533 | 562 | $include_boards = is_array($include_boards) ? $include_boards : array($include_boards); |
534 | - } |
|
535 | - elseif ($include_boards != null) |
|
563 | + } elseif ($include_boards != null) |
|
536 | 564 | { |
537 | 565 | $output_method = $include_boards; |
538 | 566 | $include_boards = array(); |
539 | 567 | } |
540 | 568 | |
541 | 569 | $icon_sources = array(); |
542 | - foreach ($context['stable_icons'] as $icon) |
|
543 | - $icon_sources[$icon] = 'images_url'; |
|
570 | + foreach ($context['stable_icons'] as $icon) { |
|
571 | + $icon_sources[$icon] = 'images_url'; |
|
572 | + } |
|
544 | 573 | |
545 | 574 | // Find all the posts in distinct topics. Newer ones will have higher IDs. |
546 | 575 | $request = $smcFunc['db_query']('substring', ' |
@@ -565,13 +594,15 @@ discard block |
||
565 | 594 | ) |
566 | 595 | ); |
567 | 596 | $topics = array(); |
568 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
569 | - $topics[$row['id_topic']] = $row; |
|
597 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
598 | + $topics[$row['id_topic']] = $row; |
|
599 | + } |
|
570 | 600 | $smcFunc['db_free_result']($request); |
571 | 601 | |
572 | 602 | // Did we find anything? If not, bail. |
573 | - if (empty($topics)) |
|
574 | - return array(); |
|
603 | + if (empty($topics)) { |
|
604 | + return array(); |
|
605 | + } |
|
575 | 606 | |
576 | 607 | $recycle_board = !empty($modSettings['recycle_enable']) && !empty($modSettings['recycle_board']) ? (int) $modSettings['recycle_board'] : 0; |
577 | 608 | |
@@ -599,21 +630,24 @@ discard block |
||
599 | 630 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
600 | 631 | { |
601 | 632 | $row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']), array('<br>' => ' '))); |
602 | - if ($smcFunc['strlen']($row['body']) > 128) |
|
603 | - $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; |
|
633 | + if ($smcFunc['strlen']($row['body']) > 128) { |
|
634 | + $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; |
|
635 | + } |
|
604 | 636 | |
605 | 637 | // Censor the subject. |
606 | 638 | censorText($row['subject']); |
607 | 639 | censorText($row['body']); |
608 | 640 | |
609 | 641 | // Recycled icon |
610 | - if (!empty($recycle_board) && $topics[$row['id_topic']]['id_board']) |
|
611 | - $row['icon'] = 'recycled'; |
|
642 | + if (!empty($recycle_board) && $topics[$row['id_topic']]['id_board']) { |
|
643 | + $row['icon'] = 'recycled'; |
|
644 | + } |
|
612 | 645 | |
613 | - if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) |
|
614 | - $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
615 | - elseif (!isset($icon_sources[$row['icon']])) |
|
616 | - $icon_sources[$row['icon']] = 'images_url'; |
|
646 | + if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) { |
|
647 | + $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
648 | + } elseif (!isset($icon_sources[$row['icon']])) { |
|
649 | + $icon_sources[$row['icon']] = 'images_url'; |
|
650 | + } |
|
617 | 651 | |
618 | 652 | // Build the array. |
619 | 653 | $posts[] = array( |
@@ -652,13 +686,14 @@ discard block |
||
652 | 686 | call_integration_hook('integrate_ssi_recentTopics', array(&$posts)); |
653 | 687 | |
654 | 688 | // Just return it. |
655 | - if ($output_method != 'echo' || empty($posts)) |
|
656 | - return $posts; |
|
689 | + if ($output_method != 'echo' || empty($posts)) { |
|
690 | + return $posts; |
|
691 | + } |
|
657 | 692 | |
658 | 693 | echo ' |
659 | 694 | <table style="border: none" class="ssi_table">'; |
660 | - foreach ($posts as $post) |
|
661 | - echo ' |
|
695 | + foreach ($posts as $post) { |
|
696 | + echo ' |
|
662 | 697 | <tr> |
663 | 698 | <td style="text-align: right; vertical-align: top; white-space: nowrap"> |
664 | 699 | [', $post['board']['link'], '] |
@@ -672,6 +707,7 @@ discard block |
||
672 | 707 | ', $post['time'], ' |
673 | 708 | </td> |
674 | 709 | </tr>'; |
710 | + } |
|
675 | 711 | echo ' |
676 | 712 | </table>'; |
677 | 713 | } |
@@ -696,27 +732,30 @@ discard block |
||
696 | 732 | ) |
697 | 733 | ); |
698 | 734 | $return = array(); |
699 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
700 | - $return[] = array( |
|
735 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
736 | + $return[] = array( |
|
701 | 737 | 'id' => $row['id_member'], |
702 | 738 | 'name' => $row['real_name'], |
703 | 739 | 'href' => $scripturl . '?action=profile;u=' . $row['id_member'], |
704 | 740 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>', |
705 | 741 | 'posts' => $row['posts'] |
706 | 742 | ); |
743 | + } |
|
707 | 744 | $smcFunc['db_free_result']($request); |
708 | 745 | |
709 | 746 | // If mods want to do somthing with this list of members, let them do that now. |
710 | 747 | call_integration_hook('integrate_ssi_topPoster', array(&$return)); |
711 | 748 | |
712 | 749 | // Just return all the top posters. |
713 | - if ($output_method != 'echo') |
|
714 | - return $return; |
|
750 | + if ($output_method != 'echo') { |
|
751 | + return $return; |
|
752 | + } |
|
715 | 753 | |
716 | 754 | // Make a quick array to list the links in. |
717 | 755 | $temp_array = array(); |
718 | - foreach ($return as $member) |
|
719 | - $temp_array[] = $member['link']; |
|
756 | + foreach ($return as $member) { |
|
757 | + $temp_array[] = $member['link']; |
|
758 | + } |
|
720 | 759 | |
721 | 760 | echo implode(', ', $temp_array); |
722 | 761 | } |
@@ -748,8 +787,8 @@ discard block |
||
748 | 787 | ) |
749 | 788 | ); |
750 | 789 | $boards = array(); |
751 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
752 | - $boards[] = array( |
|
790 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
791 | + $boards[] = array( |
|
753 | 792 | 'id' => $row['id_board'], |
754 | 793 | 'num_posts' => $row['num_posts'], |
755 | 794 | 'num_topics' => $row['num_topics'], |
@@ -758,14 +797,16 @@ discard block |
||
758 | 797 | 'href' => $scripturl . '?board=' . $row['id_board'] . '.0', |
759 | 798 | 'link' => '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>' |
760 | 799 | ); |
800 | + } |
|
761 | 801 | $smcFunc['db_free_result']($request); |
762 | 802 | |
763 | 803 | // If mods want to do somthing with this list of boards, let them do that now. |
764 | 804 | call_integration_hook('integrate_ssi_topBoards', array(&$boards)); |
765 | 805 | |
766 | 806 | // If we shouldn't output or have nothing to output, just jump out. |
767 | - if ($output_method != 'echo' || empty($boards)) |
|
768 | - return $boards; |
|
807 | + if ($output_method != 'echo' || empty($boards)) { |
|
808 | + return $boards; |
|
809 | + } |
|
769 | 810 | |
770 | 811 | echo ' |
771 | 812 | <table class="ssi_table"> |
@@ -774,13 +815,14 @@ discard block |
||
774 | 815 | <th style="text-align: left">', $txt['board_topics'], '</th> |
775 | 816 | <th style="text-align: left">', $txt['posts'], '</th> |
776 | 817 | </tr>'; |
777 | - foreach ($boards as $sBoard) |
|
778 | - echo ' |
|
818 | + foreach ($boards as $sBoard) { |
|
819 | + echo ' |
|
779 | 820 | <tr> |
780 | 821 | <td>', $sBoard['link'], $sBoard['new'] ? ' <a href="' . $sBoard['href'] . '" class="new_posts">' . $txt['new'] . '</a>' : '', '</td> |
781 | 822 | <td style="text-align: right">', comma_format($sBoard['num_topics']), '</td> |
782 | 823 | <td style="text-align: right">', comma_format($sBoard['num_posts']), '</td> |
783 | 824 | </tr>'; |
825 | + } |
|
784 | 826 | echo ' |
785 | 827 | </table>'; |
786 | 828 | } |
@@ -813,12 +855,13 @@ discard block |
||
813 | 855 | ) |
814 | 856 | ); |
815 | 857 | $topic_ids = array(); |
816 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
817 | - $topic_ids[] = $row['id_topic']; |
|
858 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
859 | + $topic_ids[] = $row['id_topic']; |
|
860 | + } |
|
818 | 861 | $smcFunc['db_free_result']($request); |
862 | + } else { |
|
863 | + $topic_ids = array(); |
|
819 | 864 | } |
820 | - else |
|
821 | - $topic_ids = array(); |
|
822 | 865 | |
823 | 866 | $request = $smcFunc['db_query']('', ' |
824 | 867 | SELECT m.subject, m.id_topic, t.num_views, t.num_replies |
@@ -857,8 +900,9 @@ discard block |
||
857 | 900 | // If mods want to do somthing with this list of topics, let them do that now. |
858 | 901 | call_integration_hook('integrate_ssi_topTopics', array(&$topics, $type)); |
859 | 902 | |
860 | - if ($output_method != 'echo' || empty($topics)) |
|
861 | - return $topics; |
|
903 | + if ($output_method != 'echo' || empty($topics)) { |
|
904 | + return $topics; |
|
905 | + } |
|
862 | 906 | |
863 | 907 | echo ' |
864 | 908 | <table class="ssi_table"> |
@@ -867,8 +911,8 @@ discard block |
||
867 | 911 | <th style="text-align: left">', $txt['views'], '</th> |
868 | 912 | <th style="text-align: left">', $txt['replies'], '</th> |
869 | 913 | </tr>'; |
870 | - foreach ($topics as $sTopic) |
|
871 | - echo ' |
|
914 | + foreach ($topics as $sTopic) { |
|
915 | + echo ' |
|
872 | 916 | <tr> |
873 | 917 | <td style="text-align: left"> |
874 | 918 | ', $sTopic['link'], ' |
@@ -876,6 +920,7 @@ discard block |
||
876 | 920 | <td style="text-align: right">', comma_format($sTopic['num_views']), '</td> |
877 | 921 | <td style="text-align: right">', comma_format($sTopic['num_replies']), '</td> |
878 | 922 | </tr>'; |
923 | + } |
|
879 | 924 | echo ' |
880 | 925 | </table>'; |
881 | 926 | } |
@@ -911,12 +956,13 @@ discard block |
||
911 | 956 | { |
912 | 957 | global $txt, $context; |
913 | 958 | |
914 | - if ($output_method == 'echo') |
|
915 | - echo ' |
|
959 | + if ($output_method == 'echo') { |
|
960 | + echo ' |
|
916 | 961 | ', sprintf($txt['welcome_newest_member'], $context['common_stats']['latest_member']['link']), '<br>'; |
917 | - else |
|
918 | - return $context['common_stats']['latest_member']; |
|
919 | -} |
|
962 | + } else { |
|
963 | + return $context['common_stats']['latest_member']; |
|
964 | + } |
|
965 | + } |
|
920 | 966 | |
921 | 967 | /** |
922 | 968 | * Fetches a random member. |
@@ -965,8 +1011,9 @@ discard block |
||
965 | 1011 | } |
966 | 1012 | |
967 | 1013 | // Just to be sure put the random generator back to something... random. |
968 | - if ($random_type != '') |
|
969 | - mt_srand(time()); |
|
1014 | + if ($random_type != '') { |
|
1015 | + mt_srand(time()); |
|
1016 | + } |
|
970 | 1017 | |
971 | 1018 | return $result; |
972 | 1019 | } |
@@ -979,8 +1026,9 @@ discard block |
||
979 | 1026 | */ |
980 | 1027 | function ssi_fetchMember($member_ids = array(), $output_method = 'echo') |
981 | 1028 | { |
982 | - if (empty($member_ids)) |
|
983 | - return; |
|
1029 | + if (empty($member_ids)) { |
|
1030 | + return; |
|
1031 | + } |
|
984 | 1032 | |
985 | 1033 | // Can have more than one member if you really want... |
986 | 1034 | $member_ids = is_array($member_ids) ? $member_ids : array($member_ids); |
@@ -1005,8 +1053,9 @@ discard block |
||
1005 | 1053 | */ |
1006 | 1054 | function ssi_fetchGroupMembers($group_id = null, $output_method = 'echo') |
1007 | 1055 | { |
1008 | - if ($group_id === null) |
|
1009 | - return; |
|
1056 | + if ($group_id === null) { |
|
1057 | + return; |
|
1058 | + } |
|
1010 | 1059 | |
1011 | 1060 | $query_where = ' |
1012 | 1061 | id_group = {int:id_group} |
@@ -1033,8 +1082,9 @@ discard block |
||
1033 | 1082 | { |
1034 | 1083 | global $smcFunc, $memberContext; |
1035 | 1084 | |
1036 | - if ($query_where === null) |
|
1037 | - return; |
|
1085 | + if ($query_where === null) { |
|
1086 | + return; |
|
1087 | + } |
|
1038 | 1088 | |
1039 | 1089 | // Fetch the members in question. |
1040 | 1090 | $request = $smcFunc['db_query']('', ' |
@@ -1047,12 +1097,14 @@ discard block |
||
1047 | 1097 | )) |
1048 | 1098 | ); |
1049 | 1099 | $members = array(); |
1050 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1051 | - $members[] = $row['id_member']; |
|
1100 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1101 | + $members[] = $row['id_member']; |
|
1102 | + } |
|
1052 | 1103 | $smcFunc['db_free_result']($request); |
1053 | 1104 | |
1054 | - if (empty($members)) |
|
1055 | - return array(); |
|
1105 | + if (empty($members)) { |
|
1106 | + return array(); |
|
1107 | + } |
|
1056 | 1108 | |
1057 | 1109 | // If mods want to do somthing with this list of members, let them do that now. |
1058 | 1110 | call_integration_hook('integrate_ssi_queryMembers', array(&$members)); |
@@ -1061,23 +1113,25 @@ discard block |
||
1061 | 1113 | loadMemberData($members); |
1062 | 1114 | |
1063 | 1115 | // Draw the table! |
1064 | - if ($output_method == 'echo') |
|
1065 | - echo ' |
|
1116 | + if ($output_method == 'echo') { |
|
1117 | + echo ' |
|
1066 | 1118 | <table style="border: none" class="ssi_table">'; |
1119 | + } |
|
1067 | 1120 | |
1068 | 1121 | $query_members = array(); |
1069 | 1122 | foreach ($members as $member) |
1070 | 1123 | { |
1071 | 1124 | // Load their context data. |
1072 | - if (!loadMemberContext($member)) |
|
1073 | - continue; |
|
1125 | + if (!loadMemberContext($member)) { |
|
1126 | + continue; |
|
1127 | + } |
|
1074 | 1128 | |
1075 | 1129 | // Store this member's information. |
1076 | 1130 | $query_members[$member] = $memberContext[$member]; |
1077 | 1131 | |
1078 | 1132 | // Only do something if we're echo'ing. |
1079 | - if ($output_method == 'echo') |
|
1080 | - echo ' |
|
1133 | + if ($output_method == 'echo') { |
|
1134 | + echo ' |
|
1081 | 1135 | <tr> |
1082 | 1136 | <td style="text-align: right; vertical-align: top; white-space: nowrap"> |
1083 | 1137 | ', $query_members[$member]['link'], ' |
@@ -1085,12 +1139,14 @@ discard block |
||
1085 | 1139 | <br>', $query_members[$member]['avatar']['image'], ' |
1086 | 1140 | </td> |
1087 | 1141 | </tr>'; |
1142 | + } |
|
1088 | 1143 | } |
1089 | 1144 | |
1090 | 1145 | // End the table if appropriate. |
1091 | - if ($output_method == 'echo') |
|
1092 | - echo ' |
|
1146 | + if ($output_method == 'echo') { |
|
1147 | + echo ' |
|
1093 | 1148 | </table>'; |
1149 | + } |
|
1094 | 1150 | |
1095 | 1151 | // Send back the data. |
1096 | 1152 | return $query_members; |
@@ -1105,8 +1161,9 @@ discard block |
||
1105 | 1161 | { |
1106 | 1162 | global $txt, $scripturl, $modSettings, $smcFunc; |
1107 | 1163 | |
1108 | - if (!allowedTo('view_stats')) |
|
1109 | - return; |
|
1164 | + if (!allowedTo('view_stats')) { |
|
1165 | + return; |
|
1166 | + } |
|
1110 | 1167 | |
1111 | 1168 | $totals = array( |
1112 | 1169 | 'members' => $modSettings['totalMembers'], |
@@ -1135,8 +1192,9 @@ discard block |
||
1135 | 1192 | // If mods want to do somthing with the board stats, let them do that now. |
1136 | 1193 | call_integration_hook('integrate_ssi_boardStats', array(&$totals)); |
1137 | 1194 | |
1138 | - if ($output_method != 'echo') |
|
1139 | - return $totals; |
|
1195 | + if ($output_method != 'echo') { |
|
1196 | + return $totals; |
|
1197 | + } |
|
1140 | 1198 | |
1141 | 1199 | echo ' |
1142 | 1200 | ', $txt['total_members'], ': <a href="', $scripturl . '?action=mlist">', comma_format($totals['members']), '</a><br> |
@@ -1165,8 +1223,8 @@ discard block |
||
1165 | 1223 | call_integration_hook('integrate_ssi_whosOnline', array(&$return)); |
1166 | 1224 | |
1167 | 1225 | // Add some redundancy for backwards compatibility reasons. |
1168 | - if ($output_method != 'echo') |
|
1169 | - return $return + array( |
|
1226 | + if ($output_method != 'echo') { |
|
1227 | + return $return + array( |
|
1170 | 1228 | 'users' => $return['users_online'], |
1171 | 1229 | 'guests' => $return['num_guests'], |
1172 | 1230 | 'hidden' => $return['num_users_hidden'], |
@@ -1174,29 +1232,35 @@ discard block |
||
1174 | 1232 | 'num_users' => $return['num_users_online'], |
1175 | 1233 | 'total_users' => $return['num_users_online'] + $return['num_guests'], |
1176 | 1234 | ); |
1235 | + } |
|
1177 | 1236 | |
1178 | 1237 | echo ' |
1179 | 1238 | ', comma_format($return['num_guests']), ' ', $return['num_guests'] == 1 ? $txt['guest'] : $txt['guests'], ', ', comma_format($return['num_users_online']), ' ', $return['num_users_online'] == 1 ? $txt['user'] : $txt['users']; |
1180 | 1239 | |
1181 | 1240 | $bracketList = array(); |
1182 | - if (!empty($user_info['buddies'])) |
|
1183 | - $bracketList[] = comma_format($return['num_buddies']) . ' ' . ($return['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']); |
|
1184 | - if (!empty($return['num_spiders'])) |
|
1185 | - $bracketList[] = comma_format($return['num_spiders']) . ' ' . ($return['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']); |
|
1186 | - if (!empty($return['num_users_hidden'])) |
|
1187 | - $bracketList[] = comma_format($return['num_users_hidden']) . ' ' . $txt['hidden']; |
|
1241 | + if (!empty($user_info['buddies'])) { |
|
1242 | + $bracketList[] = comma_format($return['num_buddies']) . ' ' . ($return['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']); |
|
1243 | + } |
|
1244 | + if (!empty($return['num_spiders'])) { |
|
1245 | + $bracketList[] = comma_format($return['num_spiders']) . ' ' . ($return['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']); |
|
1246 | + } |
|
1247 | + if (!empty($return['num_users_hidden'])) { |
|
1248 | + $bracketList[] = comma_format($return['num_users_hidden']) . ' ' . $txt['hidden']; |
|
1249 | + } |
|
1188 | 1250 | |
1189 | - if (!empty($bracketList)) |
|
1190 | - echo ' (' . implode(', ', $bracketList) . ')'; |
|
1251 | + if (!empty($bracketList)) { |
|
1252 | + echo ' (' . implode(', ', $bracketList) . ')'; |
|
1253 | + } |
|
1191 | 1254 | |
1192 | 1255 | echo '<br> |
1193 | 1256 | ', implode(', ', $return['list_users_online']); |
1194 | 1257 | |
1195 | 1258 | // Showing membergroups? |
1196 | - if (!empty($settings['show_group_key']) && !empty($return['membergroups'])) |
|
1197 | - echo '<br> |
|
1259 | + if (!empty($settings['show_group_key']) && !empty($return['membergroups'])) { |
|
1260 | + echo '<br> |
|
1198 | 1261 | [' . implode('] [', $return['membergroups']) . ']'; |
1199 | -} |
|
1262 | + } |
|
1263 | + } |
|
1200 | 1264 | |
1201 | 1265 | /** |
1202 | 1266 | * Just like whosOnline except it also logs the online presence. |
@@ -1207,11 +1271,12 @@ discard block |
||
1207 | 1271 | { |
1208 | 1272 | writeLog(); |
1209 | 1273 | |
1210 | - if ($output_method != 'echo') |
|
1211 | - return ssi_whosOnline($output_method); |
|
1212 | - else |
|
1213 | - ssi_whosOnline($output_method); |
|
1214 | -} |
|
1274 | + if ($output_method != 'echo') { |
|
1275 | + return ssi_whosOnline($output_method); |
|
1276 | + } else { |
|
1277 | + ssi_whosOnline($output_method); |
|
1278 | + } |
|
1279 | + } |
|
1215 | 1280 | |
1216 | 1281 | // Shows a login box. |
1217 | 1282 | /** |
@@ -1224,11 +1289,13 @@ discard block |
||
1224 | 1289 | { |
1225 | 1290 | global $scripturl, $txt, $user_info, $context; |
1226 | 1291 | |
1227 | - if ($redirect_to != '') |
|
1228 | - $_SESSION['login_url'] = $redirect_to; |
|
1292 | + if ($redirect_to != '') { |
|
1293 | + $_SESSION['login_url'] = $redirect_to; |
|
1294 | + } |
|
1229 | 1295 | |
1230 | - if ($output_method != 'echo' || !$user_info['is_guest']) |
|
1231 | - return $user_info['is_guest']; |
|
1296 | + if ($output_method != 'echo' || !$user_info['is_guest']) { |
|
1297 | + return $user_info['is_guest']; |
|
1298 | + } |
|
1232 | 1299 | |
1233 | 1300 | // Create a login token |
1234 | 1301 | createToken('login'); |
@@ -1280,8 +1347,9 @@ discard block |
||
1280 | 1347 | |
1281 | 1348 | $boardsAllowed = array_intersect(boardsAllowedTo('poll_view'), boardsAllowedTo('poll_vote')); |
1282 | 1349 | |
1283 | - if (empty($boardsAllowed)) |
|
1284 | - return array(); |
|
1350 | + if (empty($boardsAllowed)) { |
|
1351 | + return array(); |
|
1352 | + } |
|
1285 | 1353 | |
1286 | 1354 | $request = $smcFunc['db_query']('', ' |
1287 | 1355 | SELECT p.id_poll, p.question, t.id_topic, p.max_votes, p.guest_vote, p.hide_results, p.expire_time |
@@ -1314,12 +1382,14 @@ discard block |
||
1314 | 1382 | $smcFunc['db_free_result']($request); |
1315 | 1383 | |
1316 | 1384 | // This user has voted on all the polls. |
1317 | - if (empty($row) || !is_array($row)) |
|
1318 | - return array(); |
|
1385 | + if (empty($row) || !is_array($row)) { |
|
1386 | + return array(); |
|
1387 | + } |
|
1319 | 1388 | |
1320 | 1389 | // If this is a guest who's voted we'll through ourselves to show poll to show the results. |
1321 | - if ($user_info['is_guest'] && (!$row['guest_vote'] || (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))))) |
|
1322 | - return ssi_showPoll($row['id_topic'], $output_method); |
|
1390 | + if ($user_info['is_guest'] && (!$row['guest_vote'] || (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))))) { |
|
1391 | + return ssi_showPoll($row['id_topic'], $output_method); |
|
1392 | + } |
|
1323 | 1393 | |
1324 | 1394 | $request = $smcFunc['db_query']('', ' |
1325 | 1395 | SELECT COUNT(DISTINCT id_member) |
@@ -1383,8 +1453,9 @@ discard block |
||
1383 | 1453 | // If mods want to do somthing with this list of polls, let them do that now. |
1384 | 1454 | call_integration_hook('integrate_ssi_recentPoll', array(&$return, $topPollInstead)); |
1385 | 1455 | |
1386 | - if ($output_method != 'echo') |
|
1387 | - return $return; |
|
1456 | + if ($output_method != 'echo') { |
|
1457 | + return $return; |
|
1458 | + } |
|
1388 | 1459 | |
1389 | 1460 | if ($allow_view_results) |
1390 | 1461 | { |
@@ -1393,19 +1464,20 @@ discard block |
||
1393 | 1464 | <strong>', $return['question'], '</strong><br> |
1394 | 1465 | ', !empty($return['allowed_warning']) ? $return['allowed_warning'] . '<br>' : ''; |
1395 | 1466 | |
1396 | - foreach ($return['options'] as $option) |
|
1397 | - echo ' |
|
1467 | + foreach ($return['options'] as $option) { |
|
1468 | + echo ' |
|
1398 | 1469 | <label for="', $option['id'], '">', $option['vote_button'], ' ', $option['option'], '</label><br>'; |
1470 | + } |
|
1399 | 1471 | |
1400 | 1472 | echo ' |
1401 | 1473 | <input type="submit" value="', $txt['poll_vote'], '" class="button"> |
1402 | 1474 | <input type="hidden" name="poll" value="', $return['id'], '"> |
1403 | 1475 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
1404 | 1476 | </form>'; |
1477 | + } else { |
|
1478 | + echo $txt['poll_cannot_see']; |
|
1479 | + } |
|
1405 | 1480 | } |
1406 | - else |
|
1407 | - echo $txt['poll_cannot_see']; |
|
1408 | -} |
|
1409 | 1481 | |
1410 | 1482 | /** |
1411 | 1483 | * Shows the poll from the specified topic |
@@ -1419,13 +1491,15 @@ discard block |
||
1419 | 1491 | |
1420 | 1492 | $boardsAllowed = boardsAllowedTo('poll_view'); |
1421 | 1493 | |
1422 | - if (empty($boardsAllowed)) |
|
1423 | - return array(); |
|
1494 | + if (empty($boardsAllowed)) { |
|
1495 | + return array(); |
|
1496 | + } |
|
1424 | 1497 | |
1425 | - if ($topic === null && isset($_REQUEST['ssi_topic'])) |
|
1426 | - $topic = (int) $_REQUEST['ssi_topic']; |
|
1427 | - else |
|
1428 | - $topic = (int) $topic; |
|
1498 | + if ($topic === null && isset($_REQUEST['ssi_topic'])) { |
|
1499 | + $topic = (int) $_REQUEST['ssi_topic']; |
|
1500 | + } else { |
|
1501 | + $topic = (int) $topic; |
|
1502 | + } |
|
1429 | 1503 | |
1430 | 1504 | $request = $smcFunc['db_query']('', ' |
1431 | 1505 | SELECT |
@@ -1446,17 +1520,18 @@ discard block |
||
1446 | 1520 | ); |
1447 | 1521 | |
1448 | 1522 | // Either this topic has no poll, or the user cannot view it. |
1449 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1450 | - return array(); |
|
1523 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1524 | + return array(); |
|
1525 | + } |
|
1451 | 1526 | |
1452 | 1527 | $row = $smcFunc['db_fetch_assoc']($request); |
1453 | 1528 | $smcFunc['db_free_result']($request); |
1454 | 1529 | |
1455 | 1530 | // Check if they can vote. |
1456 | 1531 | $already_voted = false; |
1457 | - if (!empty($row['expire_time']) && $row['expire_time'] < time()) |
|
1458 | - $allow_vote = false; |
|
1459 | - elseif ($user_info['is_guest']) |
|
1532 | + if (!empty($row['expire_time']) && $row['expire_time'] < time()) { |
|
1533 | + $allow_vote = false; |
|
1534 | + } elseif ($user_info['is_guest']) |
|
1460 | 1535 | { |
1461 | 1536 | // There's a difference between "allowed to vote" and "already voted"... |
1462 | 1537 | $allow_vote = $row['guest_vote']; |
@@ -1466,10 +1541,9 @@ discard block |
||
1466 | 1541 | { |
1467 | 1542 | $already_voted = true; |
1468 | 1543 | } |
1469 | - } |
|
1470 | - elseif (!empty($row['voting_locked']) || !allowedTo('poll_vote', $row['id_board'])) |
|
1471 | - $allow_vote = false; |
|
1472 | - else |
|
1544 | + } elseif (!empty($row['voting_locked']) || !allowedTo('poll_vote', $row['id_board'])) { |
|
1545 | + $allow_vote = false; |
|
1546 | + } else |
|
1473 | 1547 | { |
1474 | 1548 | $request = $smcFunc['db_query']('', ' |
1475 | 1549 | SELECT id_member |
@@ -1551,8 +1625,9 @@ discard block |
||
1551 | 1625 | // If mods want to do somthing with this poll, let them do that now. |
1552 | 1626 | call_integration_hook('integrate_ssi_showPoll', array(&$return)); |
1553 | 1627 | |
1554 | - if ($output_method != 'echo') |
|
1555 | - return $return; |
|
1628 | + if ($output_method != 'echo') { |
|
1629 | + return $return; |
|
1630 | + } |
|
1556 | 1631 | |
1557 | 1632 | if ($return['allow_vote']) |
1558 | 1633 | { |
@@ -1561,17 +1636,17 @@ discard block |
||
1561 | 1636 | <strong>', $return['question'], '</strong><br> |
1562 | 1637 | ', !empty($return['allowed_warning']) ? $return['allowed_warning'] . '<br>' : ''; |
1563 | 1638 | |
1564 | - foreach ($return['options'] as $option) |
|
1565 | - echo ' |
|
1639 | + foreach ($return['options'] as $option) { |
|
1640 | + echo ' |
|
1566 | 1641 | <label for="', $option['id'], '">', $option['vote_button'], ' ', $option['option'], '</label><br>'; |
1642 | + } |
|
1567 | 1643 | |
1568 | 1644 | echo ' |
1569 | 1645 | <input type="submit" value="', $txt['poll_vote'], '" class="button"> |
1570 | 1646 | <input type="hidden" name="poll" value="', $return['id'], '"> |
1571 | 1647 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
1572 | 1648 | </form>'; |
1573 | - } |
|
1574 | - else |
|
1649 | + } else |
|
1575 | 1650 | { |
1576 | 1651 | echo ' |
1577 | 1652 | <div class="ssi_poll"> |
@@ -1651,27 +1726,32 @@ discard block |
||
1651 | 1726 | 'is_approved' => 1, |
1652 | 1727 | ) |
1653 | 1728 | ); |
1654 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1655 | - die; |
|
1729 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1730 | + die; |
|
1731 | + } |
|
1656 | 1732 | $row = $smcFunc['db_fetch_assoc']($request); |
1657 | 1733 | $smcFunc['db_free_result']($request); |
1658 | 1734 | |
1659 | - if (!empty($row['voting_locked']) || ($row['selected'] != -1 && !$user_info['is_guest']) || (!empty($row['expire_time']) && time() > $row['expire_time'])) |
|
1660 | - redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
1735 | + if (!empty($row['voting_locked']) || ($row['selected'] != -1 && !$user_info['is_guest']) || (!empty($row['expire_time']) && time() > $row['expire_time'])) { |
|
1736 | + redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
1737 | + } |
|
1661 | 1738 | |
1662 | 1739 | // Too many options checked? |
1663 | - if (count($_REQUEST['options']) > $row['max_votes']) |
|
1664 | - redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
1740 | + if (count($_REQUEST['options']) > $row['max_votes']) { |
|
1741 | + redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
1742 | + } |
|
1665 | 1743 | |
1666 | 1744 | // It's a guest who has already voted? |
1667 | 1745 | if ($user_info['is_guest']) |
1668 | 1746 | { |
1669 | 1747 | // Guest voting disabled? |
1670 | - if (!$row['guest_vote']) |
|
1671 | - redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
1748 | + if (!$row['guest_vote']) { |
|
1749 | + redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
1750 | + } |
|
1672 | 1751 | // Already voted? |
1673 | - elseif (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))) |
|
1674 | - redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
1752 | + elseif (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))) { |
|
1753 | + redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
1754 | + } |
|
1675 | 1755 | } |
1676 | 1756 | |
1677 | 1757 | $sOptions = array(); |
@@ -1725,11 +1805,13 @@ discard block |
||
1725 | 1805 | { |
1726 | 1806 | global $scripturl, $txt, $context; |
1727 | 1807 | |
1728 | - if (!allowedTo('search_posts')) |
|
1729 | - return; |
|
1808 | + if (!allowedTo('search_posts')) { |
|
1809 | + return; |
|
1810 | + } |
|
1730 | 1811 | |
1731 | - if ($output_method != 'echo') |
|
1732 | - return $scripturl . '?action=search'; |
|
1812 | + if ($output_method != 'echo') { |
|
1813 | + return $scripturl . '?action=search'; |
|
1814 | + } |
|
1733 | 1815 | |
1734 | 1816 | echo ' |
1735 | 1817 | <form action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '"> |
@@ -1751,8 +1833,9 @@ discard block |
||
1751 | 1833 | // If mods want to do somthing with the news, let them do that now. Don't need to pass the news line itself, since it is already in $context. |
1752 | 1834 | call_integration_hook('integrate_ssi_news'); |
1753 | 1835 | |
1754 | - if ($output_method != 'echo') |
|
1755 | - return $context['random_news_line']; |
|
1836 | + if ($output_method != 'echo') { |
|
1837 | + return $context['random_news_line']; |
|
1838 | + } |
|
1756 | 1839 | |
1757 | 1840 | echo $context['random_news_line']; |
1758 | 1841 | } |
@@ -1766,8 +1849,9 @@ discard block |
||
1766 | 1849 | { |
1767 | 1850 | global $scripturl, $modSettings, $user_info; |
1768 | 1851 | |
1769 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view') || !allowedTo('profile_view')) |
|
1770 | - return; |
|
1852 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view') || !allowedTo('profile_view')) { |
|
1853 | + return; |
|
1854 | + } |
|
1771 | 1855 | |
1772 | 1856 | $eventOptions = array( |
1773 | 1857 | 'include_birthdays' => true, |
@@ -1778,13 +1862,15 @@ discard block |
||
1778 | 1862 | // The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary |
1779 | 1863 | call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions)); |
1780 | 1864 | |
1781 | - if ($output_method != 'echo') |
|
1782 | - return $return['calendar_birthdays']; |
|
1865 | + if ($output_method != 'echo') { |
|
1866 | + return $return['calendar_birthdays']; |
|
1867 | + } |
|
1783 | 1868 | |
1784 | - foreach ($return['calendar_birthdays'] as $member) |
|
1785 | - echo ' |
|
1869 | + foreach ($return['calendar_birthdays'] as $member) { |
|
1870 | + echo ' |
|
1786 | 1871 | <a href="', $scripturl, '?action=profile;u=', $member['id'], '"><span class="fix_rtl_names">' . $member['name'] . '</span>' . (isset($member['age']) ? ' (' . $member['age'] . ')' : '') . '</a>' . (!$member['is_last'] ? ', ' : ''); |
1787 | -} |
|
1872 | + } |
|
1873 | + } |
|
1788 | 1874 | |
1789 | 1875 | /** |
1790 | 1876 | * Shows today's holidays. |
@@ -1795,8 +1881,9 @@ discard block |
||
1795 | 1881 | { |
1796 | 1882 | global $modSettings, $user_info; |
1797 | 1883 | |
1798 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) |
|
1799 | - return; |
|
1884 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) { |
|
1885 | + return; |
|
1886 | + } |
|
1800 | 1887 | |
1801 | 1888 | $eventOptions = array( |
1802 | 1889 | 'include_holidays' => true, |
@@ -1807,8 +1894,9 @@ discard block |
||
1807 | 1894 | // The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary |
1808 | 1895 | call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions)); |
1809 | 1896 | |
1810 | - if ($output_method != 'echo') |
|
1811 | - return $return['calendar_holidays']; |
|
1897 | + if ($output_method != 'echo') { |
|
1898 | + return $return['calendar_holidays']; |
|
1899 | + } |
|
1812 | 1900 | |
1813 | 1901 | echo ' |
1814 | 1902 | ', implode(', ', $return['calendar_holidays']); |
@@ -1822,8 +1910,9 @@ discard block |
||
1822 | 1910 | { |
1823 | 1911 | global $modSettings, $user_info; |
1824 | 1912 | |
1825 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) |
|
1826 | - return; |
|
1913 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) { |
|
1914 | + return; |
|
1915 | + } |
|
1827 | 1916 | |
1828 | 1917 | $eventOptions = array( |
1829 | 1918 | 'include_events' => true, |
@@ -1834,14 +1923,16 @@ discard block |
||
1834 | 1923 | // The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary |
1835 | 1924 | call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions)); |
1836 | 1925 | |
1837 | - if ($output_method != 'echo') |
|
1838 | - return $return['calendar_events']; |
|
1926 | + if ($output_method != 'echo') { |
|
1927 | + return $return['calendar_events']; |
|
1928 | + } |
|
1839 | 1929 | |
1840 | 1930 | foreach ($return['calendar_events'] as $event) |
1841 | 1931 | { |
1842 | - if ($event['can_edit']) |
|
1843 | - echo ' |
|
1932 | + if ($event['can_edit']) { |
|
1933 | + echo ' |
|
1844 | 1934 | <a href="' . $event['modify_href'] . '" style="color: #ff0000;">*</a> '; |
1935 | + } |
|
1845 | 1936 | echo ' |
1846 | 1937 | ' . $event['link'] . (!$event['is_last'] ? ', ' : ''); |
1847 | 1938 | } |
@@ -1856,8 +1947,9 @@ discard block |
||
1856 | 1947 | { |
1857 | 1948 | global $modSettings, $txt, $scripturl, $user_info; |
1858 | 1949 | |
1859 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) |
|
1860 | - return; |
|
1950 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) { |
|
1951 | + return; |
|
1952 | + } |
|
1861 | 1953 | |
1862 | 1954 | $eventOptions = array( |
1863 | 1955 | 'include_birthdays' => allowedTo('profile_view'), |
@@ -1870,19 +1962,22 @@ discard block |
||
1870 | 1962 | // The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary |
1871 | 1963 | call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions)); |
1872 | 1964 | |
1873 | - if ($output_method != 'echo') |
|
1874 | - return $return; |
|
1965 | + if ($output_method != 'echo') { |
|
1966 | + return $return; |
|
1967 | + } |
|
1875 | 1968 | |
1876 | - if (!empty($return['calendar_holidays'])) |
|
1877 | - echo ' |
|
1969 | + if (!empty($return['calendar_holidays'])) { |
|
1970 | + echo ' |
|
1878 | 1971 | <span class="holiday">' . $txt['calendar_prompt'] . ' ' . implode(', ', $return['calendar_holidays']) . '<br></span>'; |
1972 | + } |
|
1879 | 1973 | if (!empty($return['calendar_birthdays'])) |
1880 | 1974 | { |
1881 | 1975 | echo ' |
1882 | 1976 | <span class="birthday">' . $txt['birthdays_upcoming'] . '</span> '; |
1883 | - foreach ($return['calendar_birthdays'] as $member) |
|
1884 | - echo ' |
|
1977 | + foreach ($return['calendar_birthdays'] as $member) { |
|
1978 | + echo ' |
|
1885 | 1979 | <a href="', $scripturl, '?action=profile;u=', $member['id'], '"><span class="fix_rtl_names">', $member['name'], '</span>', isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a>', !$member['is_last'] ? ', ' : ''; |
1980 | + } |
|
1886 | 1981 | echo ' |
1887 | 1982 | <br>'; |
1888 | 1983 | } |
@@ -1892,9 +1987,10 @@ discard block |
||
1892 | 1987 | <span class="event">' . $txt['events_upcoming'] . '</span> '; |
1893 | 1988 | foreach ($return['calendar_events'] as $event) |
1894 | 1989 | { |
1895 | - if ($event['can_edit']) |
|
1896 | - echo ' |
|
1990 | + if ($event['can_edit']) { |
|
1991 | + echo ' |
|
1897 | 1992 | <a href="' . $event['modify_href'] . '" style="color: #ff0000;">*</a> '; |
1993 | + } |
|
1898 | 1994 | echo ' |
1899 | 1995 | ' . $event['link'] . (!$event['is_last'] ? ', ' : ''); |
1900 | 1996 | } |
@@ -1918,25 +2014,29 @@ discard block |
||
1918 | 2014 | loadLanguage('Stats'); |
1919 | 2015 | |
1920 | 2016 | // Must be integers.... |
1921 | - if ($limit === null) |
|
1922 | - $limit = isset($_GET['limit']) ? (int) $_GET['limit'] : 5; |
|
1923 | - else |
|
1924 | - $limit = (int) $limit; |
|
1925 | - |
|
1926 | - if ($start === null) |
|
1927 | - $start = isset($_GET['start']) ? (int) $_GET['start'] : 0; |
|
1928 | - else |
|
1929 | - $start = (int) $start; |
|
1930 | - |
|
1931 | - if ($board !== null) |
|
1932 | - $board = (int) $board; |
|
1933 | - elseif (isset($_GET['board'])) |
|
1934 | - $board = (int) $_GET['board']; |
|
1935 | - |
|
1936 | - if ($length === null) |
|
1937 | - $length = isset($_GET['length']) ? (int) $_GET['length'] : 0; |
|
1938 | - else |
|
1939 | - $length = (int) $length; |
|
2017 | + if ($limit === null) { |
|
2018 | + $limit = isset($_GET['limit']) ? (int) $_GET['limit'] : 5; |
|
2019 | + } else { |
|
2020 | + $limit = (int) $limit; |
|
2021 | + } |
|
2022 | + |
|
2023 | + if ($start === null) { |
|
2024 | + $start = isset($_GET['start']) ? (int) $_GET['start'] : 0; |
|
2025 | + } else { |
|
2026 | + $start = (int) $start; |
|
2027 | + } |
|
2028 | + |
|
2029 | + if ($board !== null) { |
|
2030 | + $board = (int) $board; |
|
2031 | + } elseif (isset($_GET['board'])) { |
|
2032 | + $board = (int) $_GET['board']; |
|
2033 | + } |
|
2034 | + |
|
2035 | + if ($length === null) { |
|
2036 | + $length = isset($_GET['length']) ? (int) $_GET['length'] : 0; |
|
2037 | + } else { |
|
2038 | + $length = (int) $length; |
|
2039 | + } |
|
1940 | 2040 | |
1941 | 2041 | $limit = max(0, $limit); |
1942 | 2042 | $start = max(0, $start); |
@@ -1954,17 +2054,19 @@ discard block |
||
1954 | 2054 | ); |
1955 | 2055 | if ($smcFunc['db_num_rows']($request) == 0) |
1956 | 2056 | { |
1957 | - if ($output_method == 'echo') |
|
1958 | - die($txt['ssi_no_guests']); |
|
1959 | - else |
|
1960 | - return array(); |
|
2057 | + if ($output_method == 'echo') { |
|
2058 | + die($txt['ssi_no_guests']); |
|
2059 | + } else { |
|
2060 | + return array(); |
|
2061 | + } |
|
1961 | 2062 | } |
1962 | 2063 | list ($board) = $smcFunc['db_fetch_row']($request); |
1963 | 2064 | $smcFunc['db_free_result']($request); |
1964 | 2065 | |
1965 | 2066 | $icon_sources = array(); |
1966 | - foreach ($context['stable_icons'] as $icon) |
|
1967 | - $icon_sources[$icon] = 'images_url'; |
|
2067 | + foreach ($context['stable_icons'] as $icon) { |
|
2068 | + $icon_sources[$icon] = 'images_url'; |
|
2069 | + } |
|
1968 | 2070 | |
1969 | 2071 | if (!empty($modSettings['enable_likes'])) |
1970 | 2072 | { |
@@ -1987,12 +2089,14 @@ discard block |
||
1987 | 2089 | ) |
1988 | 2090 | ); |
1989 | 2091 | $posts = array(); |
1990 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1991 | - $posts[] = $row['id_first_msg']; |
|
2092 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2093 | + $posts[] = $row['id_first_msg']; |
|
2094 | + } |
|
1992 | 2095 | $smcFunc['db_free_result']($request); |
1993 | 2096 | |
1994 | - if (empty($posts)) |
|
1995 | - return array(); |
|
2097 | + if (empty($posts)) { |
|
2098 | + return array(); |
|
2099 | + } |
|
1996 | 2100 | |
1997 | 2101 | // Find the posts. |
1998 | 2102 | $request = $smcFunc['db_query']('', ' |
@@ -2022,26 +2126,30 @@ discard block |
||
2022 | 2126 | $last_space = strrpos($row['body'], ' '); |
2023 | 2127 | $last_open = strrpos($row['body'], '<'); |
2024 | 2128 | $last_close = strrpos($row['body'], '>'); |
2025 | - if (empty($last_space) || ($last_space == $last_open + 3 && (empty($last_close) || (!empty($last_close) && $last_close < $last_open))) || $last_space < $last_open || $last_open == $length - 6) |
|
2026 | - $cutoff = $last_open; |
|
2027 | - elseif (empty($last_close) || $last_close < $last_open) |
|
2028 | - $cutoff = $last_space; |
|
2129 | + if (empty($last_space) || ($last_space == $last_open + 3 && (empty($last_close) || (!empty($last_close) && $last_close < $last_open))) || $last_space < $last_open || $last_open == $length - 6) { |
|
2130 | + $cutoff = $last_open; |
|
2131 | + } elseif (empty($last_close) || $last_close < $last_open) { |
|
2132 | + $cutoff = $last_space; |
|
2133 | + } |
|
2029 | 2134 | |
2030 | - if ($cutoff !== false) |
|
2031 | - $row['body'] = $smcFunc['substr']($row['body'], 0, $cutoff); |
|
2135 | + if ($cutoff !== false) { |
|
2136 | + $row['body'] = $smcFunc['substr']($row['body'], 0, $cutoff); |
|
2137 | + } |
|
2032 | 2138 | $row['body'] .= '...'; |
2033 | 2139 | } |
2034 | 2140 | |
2035 | 2141 | $row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']); |
2036 | 2142 | |
2037 | - if (!empty($recycle_board) && $row['id_board'] == $recycle_board) |
|
2038 | - $row['icon'] = 'recycled'; |
|
2143 | + if (!empty($recycle_board) && $row['id_board'] == $recycle_board) { |
|
2144 | + $row['icon'] = 'recycled'; |
|
2145 | + } |
|
2039 | 2146 | |
2040 | 2147 | // Check that this message icon is there... |
2041 | - if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) |
|
2042 | - $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
2043 | - elseif (!isset($icon_sources[$row['icon']])) |
|
2044 | - $icon_sources[$row['icon']] = 'images_url'; |
|
2148 | + if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) { |
|
2149 | + $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
2150 | + } elseif (!isset($icon_sources[$row['icon']])) { |
|
2151 | + $icon_sources[$row['icon']] = 'images_url'; |
|
2152 | + } |
|
2045 | 2153 | |
2046 | 2154 | censorText($row['subject']); |
2047 | 2155 | censorText($row['body']); |
@@ -2078,16 +2186,18 @@ discard block |
||
2078 | 2186 | } |
2079 | 2187 | $smcFunc['db_free_result']($request); |
2080 | 2188 | |
2081 | - if (empty($return)) |
|
2082 | - return $return; |
|
2189 | + if (empty($return)) { |
|
2190 | + return $return; |
|
2191 | + } |
|
2083 | 2192 | |
2084 | 2193 | $return[count($return) - 1]['is_last'] = true; |
2085 | 2194 | |
2086 | 2195 | // If mods want to do somthing with this list of posts, let them do that now. |
2087 | 2196 | call_integration_hook('integrate_ssi_boardNews', array(&$return)); |
2088 | 2197 | |
2089 | - if ($output_method != 'echo') |
|
2090 | - return $return; |
|
2198 | + if ($output_method != 'echo') { |
|
2199 | + return $return; |
|
2200 | + } |
|
2091 | 2201 | |
2092 | 2202 | foreach ($return as $news) |
2093 | 2203 | { |
@@ -2139,9 +2249,10 @@ discard block |
||
2139 | 2249 | echo ' |
2140 | 2250 | </div>'; |
2141 | 2251 | |
2142 | - if (!$news['is_last']) |
|
2143 | - echo ' |
|
2252 | + if (!$news['is_last']) { |
|
2253 | + echo ' |
|
2144 | 2254 | <hr>'; |
2255 | + } |
|
2145 | 2256 | } |
2146 | 2257 | } |
2147 | 2258 | |
@@ -2155,8 +2266,9 @@ discard block |
||
2155 | 2266 | { |
2156 | 2267 | global $user_info, $scripturl, $modSettings, $txt, $context, $smcFunc; |
2157 | 2268 | |
2158 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) |
|
2159 | - return; |
|
2269 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) { |
|
2270 | + return; |
|
2271 | + } |
|
2160 | 2272 | |
2161 | 2273 | // Find all events which are happening in the near future that the member can see. |
2162 | 2274 | $request = $smcFunc['db_query']('', ' |
@@ -2182,20 +2294,23 @@ discard block |
||
2182 | 2294 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2183 | 2295 | { |
2184 | 2296 | // Check if we've already come by an event linked to this same topic with the same title... and don't display it if we have. |
2185 | - if (!empty($duplicates[$row['title'] . $row['id_topic']])) |
|
2186 | - continue; |
|
2297 | + if (!empty($duplicates[$row['title'] . $row['id_topic']])) { |
|
2298 | + continue; |
|
2299 | + } |
|
2187 | 2300 | |
2188 | 2301 | // Censor the title. |
2189 | 2302 | censorText($row['title']); |
2190 | 2303 | |
2191 | - if ($row['start_date'] < strftime('%Y-%m-%d', forum_time(false))) |
|
2192 | - $date = strftime('%Y-%m-%d', forum_time(false)); |
|
2193 | - else |
|
2194 | - $date = $row['start_date']; |
|
2304 | + if ($row['start_date'] < strftime('%Y-%m-%d', forum_time(false))) { |
|
2305 | + $date = strftime('%Y-%m-%d', forum_time(false)); |
|
2306 | + } else { |
|
2307 | + $date = $row['start_date']; |
|
2308 | + } |
|
2195 | 2309 | |
2196 | 2310 | // If the topic it is attached to is not approved then don't link it. |
2197 | - if (!empty($row['id_first_msg']) && !$row['approved']) |
|
2198 | - $row['id_board'] = $row['id_topic'] = $row['id_first_msg'] = 0; |
|
2311 | + if (!empty($row['id_first_msg']) && !$row['approved']) { |
|
2312 | + $row['id_board'] = $row['id_topic'] = $row['id_first_msg'] = 0; |
|
2313 | + } |
|
2199 | 2314 | |
2200 | 2315 | $allday = (empty($row['start_time']) || empty($row['end_time']) || empty($row['timezone']) || !in_array($row['timezone'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) ? true : false; |
2201 | 2316 | |
@@ -2221,24 +2336,27 @@ discard block |
||
2221 | 2336 | } |
2222 | 2337 | $smcFunc['db_free_result']($request); |
2223 | 2338 | |
2224 | - foreach ($return as $mday => $array) |
|
2225 | - $return[$mday][count($array) - 1]['is_last'] = true; |
|
2339 | + foreach ($return as $mday => $array) { |
|
2340 | + $return[$mday][count($array) - 1]['is_last'] = true; |
|
2341 | + } |
|
2226 | 2342 | |
2227 | 2343 | // If mods want to do somthing with this list of events, let them do that now. |
2228 | 2344 | call_integration_hook('integrate_ssi_recentEvents', array(&$return)); |
2229 | 2345 | |
2230 | - if ($output_method != 'echo' || empty($return)) |
|
2231 | - return $return; |
|
2346 | + if ($output_method != 'echo' || empty($return)) { |
|
2347 | + return $return; |
|
2348 | + } |
|
2232 | 2349 | |
2233 | 2350 | // Well the output method is echo. |
2234 | 2351 | echo ' |
2235 | 2352 | <span class="event">' . $txt['events'] . '</span> '; |
2236 | - foreach ($return as $mday => $array) |
|
2237 | - foreach ($array as $event) |
|
2353 | + foreach ($return as $mday => $array) { |
|
2354 | + foreach ($array as $event) |
|
2238 | 2355 | { |
2239 | 2356 | if ($event['can_edit']) |
2240 | 2357 | echo ' |
2241 | 2358 | <a href="' . $event['modify_href'] . '" style="color: #ff0000;">*</a> '; |
2359 | + } |
|
2242 | 2360 | |
2243 | 2361 | echo ' |
2244 | 2362 | ' . $event['link'] . (!$event['is_last'] ? ', ' : ''); |
@@ -2257,8 +2375,9 @@ discard block |
||
2257 | 2375 | global $smcFunc; |
2258 | 2376 | |
2259 | 2377 | // If $id is null, this was most likely called from a query string and should do nothing. |
2260 | - if ($id === null) |
|
2261 | - return; |
|
2378 | + if ($id === null) { |
|
2379 | + return; |
|
2380 | + } |
|
2262 | 2381 | |
2263 | 2382 | $request = $smcFunc['db_query']('', ' |
2264 | 2383 | SELECT passwd, member_name, is_activated |
@@ -2290,8 +2409,9 @@ discard block |
||
2290 | 2409 | $attachments_boards = boardsAllowedTo('view_attachments'); |
2291 | 2410 | |
2292 | 2411 | // No boards? Adios amigo. |
2293 | - if (empty($attachments_boards)) |
|
2294 | - return array(); |
|
2412 | + if (empty($attachments_boards)) { |
|
2413 | + return array(); |
|
2414 | + } |
|
2295 | 2415 | |
2296 | 2416 | // Is it an array? |
2297 | 2417 | $attachment_ext = (array) $attachment_ext; |
@@ -2375,8 +2495,9 @@ discard block |
||
2375 | 2495 | call_integration_hook('integrate_ssi_recentAttachments', array(&$attachments)); |
2376 | 2496 | |
2377 | 2497 | // So you just want an array? Here you can have it. |
2378 | - if ($output_method == 'array' || empty($attachments)) |
|
2379 | - return $attachments; |
|
2498 | + if ($output_method == 'array' || empty($attachments)) { |
|
2499 | + return $attachments; |
|
2500 | + } |
|
2380 | 2501 | |
2381 | 2502 | // Give them the default. |
2382 | 2503 | echo ' |
@@ -2387,14 +2508,15 @@ discard block |
||
2387 | 2508 | <th style="text-align: left; padding: 2">', $txt['downloads'], '</th> |
2388 | 2509 | <th style="text-align: left; padding: 2">', $txt['filesize'], '</th> |
2389 | 2510 | </tr>'; |
2390 | - foreach ($attachments as $attach) |
|
2391 | - echo ' |
|
2511 | + foreach ($attachments as $attach) { |
|
2512 | + echo ' |
|
2392 | 2513 | <tr> |
2393 | 2514 | <td>', $attach['file']['link'], '</td> |
2394 | 2515 | <td>', $attach['member']['link'], '</td> |
2395 | 2516 | <td style="text-align: center">', $attach['file']['downloads'], '</td> |
2396 | 2517 | <td>', $attach['file']['filesize'], '</td> |
2397 | 2518 | </tr>'; |
2519 | + } |
|
2398 | 2520 | echo ' |
2399 | 2521 | </table>'; |
2400 | 2522 | } |
@@ -18,23 +18,25 @@ discard block |
||
18 | 18 | global $context; |
19 | 19 | |
20 | 20 | // Prevent Chrome from auto completing fields when viewing/editing other members profiles |
21 | - if (isBrowser('is_chrome') && !$context['user']['is_owner']) |
|
22 | - echo ' |
|
21 | + if (isBrowser('is_chrome') && !$context['user']['is_owner']) { |
|
22 | + echo ' |
|
23 | 23 | <script> |
24 | 24 | disableAutoComplete(); |
25 | 25 | </script>'; |
26 | + } |
|
26 | 27 | |
27 | 28 | // If an error occurred while trying to save previously, give the user a clue! |
28 | 29 | echo ' |
29 | 30 | ', template_error_message(); |
30 | 31 | |
31 | 32 | // If the profile was update successfully, let the user know this. |
32 | - if (!empty($context['profile_updated'])) |
|
33 | - echo ' |
|
33 | + if (!empty($context['profile_updated'])) { |
|
34 | + echo ' |
|
34 | 35 | <div class="infobox"> |
35 | 36 | ', $context['profile_updated'], ' |
36 | 37 | </div>'; |
37 | -} |
|
38 | + } |
|
39 | + } |
|
38 | 40 | |
39 | 41 | /** |
40 | 42 | * Template for any HTML needed below the profile (closing off divs/tables, etc.) |
@@ -99,19 +101,19 @@ discard block |
||
99 | 101 | </div> |
100 | 102 | <div class="alerts_unread">'; |
101 | 103 | |
102 | - if (empty($context['unread_alerts'])) |
|
103 | - template_alerts_all_read(); |
|
104 | - |
|
105 | - else |
|
104 | + if (empty($context['unread_alerts'])) { |
|
105 | + template_alerts_all_read(); |
|
106 | + } else |
|
106 | 107 | { |
107 | - foreach ($context['unread_alerts'] as $id_alert => $details) |
|
108 | - echo ' |
|
108 | + foreach ($context['unread_alerts'] as $id_alert => $details) { |
|
109 | + echo ' |
|
109 | 110 | <div class="unread"> |
110 | 111 | ', !empty($details['sender']) ? $details['sender']['avatar']['image'] : '', ' |
111 | 112 | <div class="details"> |
112 | 113 | ', !empty($details['icon']) ? $details['icon'] : '', '<span>', $details['text'], '</span> - ', $details['time'], ' |
113 | 114 | </div> |
114 | 115 | </div>'; |
116 | + } |
|
115 | 117 | } |
116 | 118 | |
117 | 119 | echo ' |
@@ -158,37 +160,41 @@ discard block |
||
158 | 160 | if (!empty($context['print_custom_fields']['above_member'])) |
159 | 161 | { |
160 | 162 | $fields = ''; |
161 | - foreach ($context['print_custom_fields']['above_member'] as $field) |
|
162 | - if (!empty($field['output_html'])) |
|
163 | + foreach ($context['print_custom_fields']['above_member'] as $field) { |
|
164 | + if (!empty($field['output_html'])) |
|
163 | 165 | $fields .= ' |
164 | 166 | <li>' . $field['output_html'] . '</li>'; |
167 | + } |
|
165 | 168 | |
166 | - if (!empty($fields)) |
|
167 | - echo ' |
|
169 | + if (!empty($fields)) { |
|
170 | + echo ' |
|
168 | 171 | <div class="custom_fields_above_name"> |
169 | 172 | <ul>', $fields, ' |
170 | 173 | </ul> |
171 | 174 | </div>'; |
175 | + } |
|
172 | 176 | } |
173 | 177 | |
174 | 178 | echo ' |
175 | 179 | <div class="username clear"> |
176 | 180 | <h4>'; |
177 | 181 | |
178 | - if (!empty($context['print_custom_fields']['before_member'])) |
|
179 | - foreach ($context['print_custom_fields']['before_member'] as $field) |
|
182 | + if (!empty($context['print_custom_fields']['before_member'])) { |
|
183 | + foreach ($context['print_custom_fields']['before_member'] as $field) |
|
180 | 184 | if (!empty($field['output_html'])) |
181 | 185 | echo ' |
182 | 186 | <span>', $field['output_html'], '</span>'; |
187 | + } |
|
183 | 188 | |
184 | 189 | echo ' |
185 | 190 | ', $context['member']['name']; |
186 | 191 | |
187 | - if (!empty($context['print_custom_fields']['after_member'])) |
|
188 | - foreach ($context['print_custom_fields']['after_member'] as $field) |
|
192 | + if (!empty($context['print_custom_fields']['after_member'])) { |
|
193 | + foreach ($context['print_custom_fields']['after_member'] as $field) |
|
189 | 194 | if (!empty($field['output_html'])) |
190 | 195 | echo ' |
191 | 196 | <span>', $field['output_html'], '</span>'; |
197 | + } |
|
192 | 198 | |
193 | 199 | |
194 | 200 | echo ' |
@@ -201,39 +207,44 @@ discard block |
||
201 | 207 | if (!empty($context['print_custom_fields']['below_avatar'])) |
202 | 208 | { |
203 | 209 | $fields = ''; |
204 | - foreach ($context['print_custom_fields']['below_avatar'] as $field) |
|
205 | - if (!empty($field['output_html'])) |
|
210 | + foreach ($context['print_custom_fields']['below_avatar'] as $field) { |
|
211 | + if (!empty($field['output_html'])) |
|
206 | 212 | $fields .= ' |
207 | 213 | <li>' . $field['output_html'] . '</li>'; |
214 | + } |
|
208 | 215 | |
209 | - if (!empty($fields)) |
|
210 | - echo ' |
|
216 | + if (!empty($fields)) { |
|
217 | + echo ' |
|
211 | 218 | <div class="custom_fields_below_avatar"> |
212 | 219 | <ul>', $fields, ' |
213 | 220 | </ul> |
214 | 221 | </div>'; |
222 | + } |
|
215 | 223 | } |
216 | 224 | |
217 | 225 | echo ' |
218 | 226 | <ul class="icon_fields clear">'; |
219 | 227 | |
220 | 228 | // Email is only visible if it's your profile or you have the moderate_forum permission |
221 | - if ($context['member']['show_email']) |
|
222 | - echo ' |
|
229 | + if ($context['member']['show_email']) { |
|
230 | + echo ' |
|
223 | 231 | <li><a href="mailto:', $context['member']['email'], '" title="', $context['member']['email'], '" rel="nofollow"><span class="generic_icons mail" title="' . $txt['email'] . '"></span></a></li>'; |
232 | + } |
|
224 | 233 | |
225 | 234 | // Don't show an icon if they haven't specified a website. |
226 | - if ($context['member']['website']['url'] !== '' && !isset($context['disabled_fields']['website'])) |
|
227 | - echo ' |
|
235 | + if ($context['member']['website']['url'] !== '' && !isset($context['disabled_fields']['website'])) { |
|
236 | + echo ' |
|
228 | 237 | <li><a href="', $context['member']['website']['url'], '" title="' . $context['member']['website']['title'] . '" target="_blank" rel="noopener">', ($settings['use_image_buttons'] ? '<span class="generic_icons www" title="' . $context['member']['website']['title'] . '"></span>' : $txt['www']), '</a></li>'; |
238 | + } |
|
229 | 239 | |
230 | 240 | // Are there any custom profile fields as icons? |
231 | 241 | if (!empty($context['print_custom_fields']['icons'])) |
232 | 242 | { |
233 | - foreach ($context['print_custom_fields']['icons'] as $field) |
|
234 | - if (!empty($field['output_html'])) |
|
243 | + foreach ($context['print_custom_fields']['icons'] as $field) { |
|
244 | + if (!empty($field['output_html'])) |
|
235 | 245 | echo ' |
236 | 246 | <li class="custom_field">', $field['output_html'], '</li>'; |
247 | + } |
|
237 | 248 | } |
238 | 249 | |
239 | 250 | echo ' |
@@ -242,24 +253,27 @@ discard block |
||
242 | 253 | ', $context['can_send_pm'] ? '<a href="' . $context['member']['online']['href'] . '" title="' . $context['member']['online']['text'] . '" rel="nofollow">' : '', $settings['use_image_buttons'] ? '<span class="' . ($context['member']['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $context['member']['online']['text'] . '"></span>' : $context['member']['online']['label'], $context['can_send_pm'] ? '</a>' : '', $settings['use_image_buttons'] ? '<span class="smalltext"> ' . $context['member']['online']['label'] . '</span>' : ''; |
243 | 254 | |
244 | 255 | // Can they add this member as a buddy? |
245 | - if (!empty($context['can_have_buddy']) && !$context['user']['is_owner']) |
|
246 | - echo ' |
|
256 | + if (!empty($context['can_have_buddy']) && !$context['user']['is_owner']) { |
|
257 | + echo ' |
|
247 | 258 | <br> |
248 | 259 | <a href="', $scripturl, '?action=buddy;u=', $context['id_member'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['buddy_' . ($context['member']['is_buddy'] ? 'remove' : 'add')], '</a>'; |
260 | + } |
|
249 | 261 | |
250 | 262 | echo ' |
251 | 263 | </span>'; |
252 | 264 | |
253 | - if (!$context['user']['is_owner'] && $context['can_send_pm']) |
|
254 | - echo ' |
|
265 | + if (!$context['user']['is_owner'] && $context['can_send_pm']) { |
|
266 | + echo ' |
|
255 | 267 | <a href="', $scripturl, '?action=pm;sa=send;u=', $context['id_member'], '" class="infolinks">', $txt['profile_sendpm_short'], '</a>'; |
268 | + } |
|
256 | 269 | |
257 | 270 | echo ' |
258 | 271 | <a href="', $scripturl, '?action=profile;area=showposts;u=', $context['id_member'], '" class="infolinks">', $txt['showPosts'], '</a>'; |
259 | 272 | |
260 | - if ($context['user']['is_owner'] && !empty($modSettings['drafts_post_enabled'])) |
|
261 | - echo ' |
|
273 | + if ($context['user']['is_owner'] && !empty($modSettings['drafts_post_enabled'])) { |
|
274 | + echo ' |
|
262 | 275 | <a href="', $scripturl, '?action=profile;area=showdrafts;u=', $context['id_member'], '" class="infolinks">', $txt['drafts_show'], '</a>'; |
276 | + } |
|
263 | 277 | |
264 | 278 | echo ' |
265 | 279 | <a href="', $scripturl, '?action=profile;area=statistics;u=', $context['id_member'], '" class="infolinks">', $txt['statPanel'], '</a>'; |
@@ -268,17 +282,19 @@ discard block |
||
268 | 282 | if (!empty($context['print_custom_fields']['bottom_poster'])) |
269 | 283 | { |
270 | 284 | $fields = ''; |
271 | - foreach ($context['print_custom_fields']['bottom_poster'] as $field) |
|
272 | - if (!empty($field['output_html'])) |
|
285 | + foreach ($context['print_custom_fields']['bottom_poster'] as $field) { |
|
286 | + if (!empty($field['output_html'])) |
|
273 | 287 | $fields .= ' |
274 | 288 | <li>' . $field['output_html'] . '</li>'; |
289 | + } |
|
275 | 290 | |
276 | - if (!empty($fields)) |
|
277 | - echo ' |
|
291 | + if (!empty($fields)) { |
|
292 | + echo ' |
|
278 | 293 | <div class="custom_fields_bottom"> |
279 | 294 | <ul class="nolist">', $fields, ' |
280 | 295 | </ul> |
281 | 296 | </div>'; |
297 | + } |
|
282 | 298 | } |
283 | 299 | |
284 | 300 | echo ' |
@@ -287,30 +303,35 @@ discard block |
||
287 | 303 | <div id="detailedinfo"> |
288 | 304 | <dl class="settings">'; |
289 | 305 | |
290 | - if ($context['user']['is_owner'] || $context['user']['is_admin']) |
|
291 | - echo ' |
|
306 | + if ($context['user']['is_owner'] || $context['user']['is_admin']) { |
|
307 | + echo ' |
|
292 | 308 | <dt>', $txt['username'], ': </dt> |
293 | 309 | <dd>', $context['member']['username'], '</dd>'; |
310 | + } |
|
294 | 311 | |
295 | - if (!isset($context['disabled_fields']['posts'])) |
|
296 | - echo ' |
|
312 | + if (!isset($context['disabled_fields']['posts'])) { |
|
313 | + echo ' |
|
297 | 314 | <dt>', $txt['profile_posts'], ': </dt> |
298 | 315 | <dd>', $context['member']['posts'], ' (', $context['member']['posts_per_day'], ' ', $txt['posts_per_day'], ')</dd>'; |
316 | + } |
|
299 | 317 | |
300 | - if ($context['member']['show_email']) |
|
301 | - echo ' |
|
318 | + if ($context['member']['show_email']) { |
|
319 | + echo ' |
|
302 | 320 | <dt>', $txt['email'], ': </dt> |
303 | 321 | <dd><a href="mailto:', $context['member']['email'], '">', $context['member']['email'], '</a></dd>'; |
322 | + } |
|
304 | 323 | |
305 | - if (!empty($modSettings['titlesEnable']) && !empty($context['member']['title'])) |
|
306 | - echo ' |
|
324 | + if (!empty($modSettings['titlesEnable']) && !empty($context['member']['title'])) { |
|
325 | + echo ' |
|
307 | 326 | <dt>', $txt['custom_title'], ': </dt> |
308 | 327 | <dd>', $context['member']['title'], '</dd>'; |
328 | + } |
|
309 | 329 | |
310 | - if (!empty($context['member']['blurb'])) |
|
311 | - echo ' |
|
330 | + if (!empty($context['member']['blurb'])) { |
|
331 | + echo ' |
|
312 | 332 | <dt>', $txt['personal_text'], ': </dt> |
313 | 333 | <dd>', $context['member']['blurb'], '</dd>'; |
334 | + } |
|
314 | 335 | |
315 | 336 | echo ' |
316 | 337 | <dt>', $txt['age'], ':</dt> |
@@ -324,19 +345,21 @@ discard block |
||
324 | 345 | { |
325 | 346 | $fields = array(); |
326 | 347 | |
327 | - foreach ($context['print_custom_fields']['standard'] as $field) |
|
328 | - if (!empty($field['output_html'])) |
|
348 | + foreach ($context['print_custom_fields']['standard'] as $field) { |
|
349 | + if (!empty($field['output_html'])) |
|
329 | 350 | $fields[] = $field; |
351 | + } |
|
330 | 352 | |
331 | 353 | if (count($fields) > 0) |
332 | 354 | { |
333 | 355 | echo ' |
334 | 356 | <dl class="settings">'; |
335 | 357 | |
336 | - foreach ($fields as $field) |
|
337 | - echo ' |
|
358 | + foreach ($fields as $field) { |
|
359 | + echo ' |
|
338 | 360 | <dt>', $field['name'], ':</dt> |
339 | 361 | <dd>', $field['output_html'], '</dd>'; |
362 | + } |
|
340 | 363 | |
341 | 364 | echo ' |
342 | 365 | </dl>'; |
@@ -355,9 +378,10 @@ discard block |
||
355 | 378 | <a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=', ($context['can_issue_warning'] && !$context['user']['is_owner'] ? 'issuewarning' : 'viewwarning'), '">', $context['member']['warning'], '%</a>'; |
356 | 379 | |
357 | 380 | // Can we provide information on what this means? |
358 | - if (!empty($context['warning_status'])) |
|
359 | - echo ' |
|
381 | + if (!empty($context['warning_status'])) { |
|
382 | + echo ' |
|
360 | 383 | <span class="smalltext">(', $context['warning_status'], ')</span>'; |
384 | + } |
|
361 | 385 | |
362 | 386 | echo ' |
363 | 387 | </dd>'; |
@@ -367,11 +391,12 @@ discard block |
||
367 | 391 | if (!empty($context['activate_message']) || !empty($context['member']['bans'])) |
368 | 392 | { |
369 | 393 | // If the person looking at the summary has permission, and the account isn't activated, give the viewer the ability to do it themselves. |
370 | - if (!empty($context['activate_message'])) |
|
371 | - echo ' |
|
394 | + if (!empty($context['activate_message'])) { |
|
395 | + echo ' |
|
372 | 396 | <dt class="clear"> |
373 | 397 | <span class="alert">', $context['activate_message'], '</span> (<a href="', $context['activate_link'], '"', ($context['activate_type'] == 4 ? ' class="you_sure" data-confirm="' . $txt['profileConfirm'] . '"' : ''), '>', $context['activate_link_text'], '</a>) |
374 | 398 | </dt>'; |
399 | + } |
|
375 | 400 | |
376 | 401 | // If the current member is banned, show a message and possibly a link to the ban. |
377 | 402 | if (!empty($context['member']['bans'])) |
@@ -383,10 +408,11 @@ discard block |
||
383 | 408 | <dt class="clear hidden" id="ban_info"> |
384 | 409 | <strong>', $txt['user_banned_by_following'], ':</strong>'; |
385 | 410 | |
386 | - foreach ($context['member']['bans'] as $ban) |
|
387 | - echo ' |
|
411 | + foreach ($context['member']['bans'] as $ban) { |
|
412 | + echo ' |
|
388 | 413 | <br> |
389 | 414 | <span class="smalltext">', $ban['explanation'], '</span>'; |
415 | + } |
|
390 | 416 | |
391 | 417 | echo ' |
392 | 418 | </dt>'; |
@@ -400,30 +426,34 @@ discard block |
||
400 | 426 | // If the person looking is allowed, they can check the members IP address and hostname. |
401 | 427 | if ($context['can_see_ip']) |
402 | 428 | { |
403 | - if (!empty($context['member']['ip'])) |
|
404 | - echo ' |
|
429 | + if (!empty($context['member']['ip'])) { |
|
430 | + echo ' |
|
405 | 431 | <dt>', $txt['ip'], ': </dt> |
406 | 432 | <dd><a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['member']['ip'], ';u=', $context['member']['id'], '">', $context['member']['ip'], '</a></dd>'; |
433 | + } |
|
407 | 434 | |
408 | - if (empty($modSettings['disableHostnameLookup']) && !empty($context['member']['ip'])) |
|
409 | - echo ' |
|
435 | + if (empty($modSettings['disableHostnameLookup']) && !empty($context['member']['ip'])) { |
|
436 | + echo ' |
|
410 | 437 | <dt>', $txt['hostname'], ': </dt> |
411 | 438 | <dd>', $context['member']['hostname'], '</dd>'; |
439 | + } |
|
412 | 440 | } |
413 | 441 | |
414 | 442 | echo ' |
415 | 443 | <dt>', $txt['local_time'], ':</dt> |
416 | 444 | <dd>', $context['member']['local_time'], '</dd>'; |
417 | 445 | |
418 | - if (!empty($modSettings['userLanguage']) && !empty($context['member']['language'])) |
|
419 | - echo ' |
|
446 | + if (!empty($modSettings['userLanguage']) && !empty($context['member']['language'])) { |
|
447 | + echo ' |
|
420 | 448 | <dt>', $txt['language'], ':</dt> |
421 | 449 | <dd>', $context['member']['language'], '</dd>'; |
450 | + } |
|
422 | 451 | |
423 | - if ($context['member']['show_last_login']) |
|
424 | - echo ' |
|
452 | + if ($context['member']['show_last_login']) { |
|
453 | + echo ' |
|
425 | 454 | <dt>', $txt['lastLoggedIn'], ': </dt> |
426 | 455 | <dd>', $context['member']['last_login'], (!empty($context['member']['is_hidden']) ? ' (' . $txt['hidden'] . ')' : ''), '</dd>'; |
456 | + } |
|
427 | 457 | |
428 | 458 | echo ' |
429 | 459 | </dl>'; |
@@ -432,42 +462,47 @@ discard block |
||
432 | 462 | if (!empty($context['print_custom_fields']['above_signature'])) |
433 | 463 | { |
434 | 464 | $fields = ''; |
435 | - foreach ($context['print_custom_fields']['above_signature'] as $field) |
|
436 | - if (!empty($field['output_html'])) |
|
465 | + foreach ($context['print_custom_fields']['above_signature'] as $field) { |
|
466 | + if (!empty($field['output_html'])) |
|
437 | 467 | $fields .= ' |
438 | 468 | <li>' . $field['output_html'] . '</li>'; |
469 | + } |
|
439 | 470 | |
440 | - if (!empty($fields)) |
|
441 | - echo ' |
|
471 | + if (!empty($fields)) { |
|
472 | + echo ' |
|
442 | 473 | <div class="custom_fields_above_signature"> |
443 | 474 | <ul class="nolist">', $fields, ' |
444 | 475 | </ul> |
445 | 476 | </div>'; |
477 | + } |
|
446 | 478 | } |
447 | 479 | |
448 | 480 | // Show the users signature. |
449 | - if ($context['signature_enabled'] && !empty($context['member']['signature'])) |
|
450 | - echo ' |
|
481 | + if ($context['signature_enabled'] && !empty($context['member']['signature'])) { |
|
482 | + echo ' |
|
451 | 483 | <div class="signature"> |
452 | 484 | <h5>', $txt['signature'], ':</h5> |
453 | 485 | ', $context['member']['signature'], ' |
454 | 486 | </div>'; |
487 | + } |
|
455 | 488 | |
456 | 489 | // Are there any custom profile fields for below the signature? |
457 | 490 | if (!empty($context['print_custom_fields']['below_signature'])) |
458 | 491 | { |
459 | 492 | $fields = ''; |
460 | - foreach ($context['print_custom_fields']['below_signature'] as $field) |
|
461 | - if (!empty($field['output_html'])) |
|
493 | + foreach ($context['print_custom_fields']['below_signature'] as $field) { |
|
494 | + if (!empty($field['output_html'])) |
|
462 | 495 | $fields .= ' |
463 | 496 | <li>' . $field['output_html'] . '</li>'; |
497 | + } |
|
464 | 498 | |
465 | - if (!empty($fields)) |
|
466 | - echo ' |
|
499 | + if (!empty($fields)) { |
|
500 | + echo ' |
|
467 | 501 | <div class="custom_fields_below_signature"> |
468 | 502 | <ul class="nolist">', $fields, ' |
469 | 503 | </ul> |
470 | 504 | </div>'; |
505 | + } |
|
471 | 506 | } |
472 | 507 | |
473 | 508 | echo ' |
@@ -509,62 +544,70 @@ discard block |
||
509 | 544 | </div> |
510 | 545 | <div class="list_posts">'; |
511 | 546 | |
512 | - if (!$post['approved']) |
|
513 | - echo ' |
|
547 | + if (!$post['approved']) { |
|
548 | + echo ' |
|
514 | 549 | <div class="approve_post"> |
515 | 550 | <em>', $txt['post_awaiting_approval'], '</em> |
516 | 551 | </div>'; |
552 | + } |
|
517 | 553 | |
518 | 554 | echo ' |
519 | 555 | ', $post['body'], ' |
520 | 556 | </div>'; |
521 | 557 | |
522 | - if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) |
|
523 | - echo ' |
|
558 | + if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) { |
|
559 | + echo ' |
|
524 | 560 | <div class="floatright"> |
525 | 561 | <ul class="quickbuttons">'; |
562 | + } |
|
526 | 563 | |
527 | 564 | // If they *can* reply? |
528 | - if ($post['can_reply']) |
|
529 | - echo ' |
|
565 | + if ($post['can_reply']) { |
|
566 | + echo ' |
|
530 | 567 | <li><a href="', $scripturl, '?action=post;topic=', $post['topic'], '.', $post['start'], '"><span class="generic_icons reply_button"></span>', $txt['reply'], '</a></li>'; |
568 | + } |
|
531 | 569 | |
532 | 570 | // If they *can* quote? |
533 | - if ($post['can_quote']) |
|
534 | - echo ' |
|
571 | + if ($post['can_quote']) { |
|
572 | + echo ' |
|
535 | 573 | <li><a href="', $scripturl . '?action=post;topic=', $post['topic'], '.', $post['start'], ';quote=', $post['id'], '"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li>'; |
574 | + } |
|
536 | 575 | |
537 | 576 | // How about... even... remove it entirely?! |
538 | - if ($post['can_delete']) |
|
539 | - echo ' |
|
577 | + if ($post['can_delete']) { |
|
578 | + echo ' |
|
540 | 579 | <li><a href="', $scripturl, '?action=deletemsg;msg=', $post['id'], ';topic=', $post['topic'], ';profile;u=', $context['member']['id'], ';start=', $context['start'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['remove_message'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove'], '</a></li>'; |
580 | + } |
|
541 | 581 | |
542 | - if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) |
|
543 | - echo ' |
|
582 | + if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) { |
|
583 | + echo ' |
|
544 | 584 | </ul> |
545 | 585 | </div><!-- .floatright -->'; |
586 | + } |
|
546 | 587 | |
547 | 588 | echo ' |
548 | 589 | </div><!-- $post[css_class] -->'; |
549 | 590 | } |
591 | + } else { |
|
592 | + template_show_list('attachments'); |
|
550 | 593 | } |
551 | - else |
|
552 | - template_show_list('attachments'); |
|
553 | 594 | |
554 | 595 | // No posts? Just end with a informative message. |
555 | - if ((isset($context['attachments']) && empty($context['attachments'])) || (!isset($context['attachments']) && empty($context['posts']))) |
|
556 | - echo ' |
|
596 | + if ((isset($context['attachments']) && empty($context['attachments'])) || (!isset($context['attachments']) && empty($context['posts']))) { |
|
597 | + echo ' |
|
557 | 598 | <div class="windowbg"> |
558 | 599 | ', isset($context['attachments']) ? $txt['show_attachments_none'] : ($context['is_topics'] ? $txt['show_topics_none'] : $txt['show_posts_none']), ' |
559 | 600 | </div>'; |
601 | + } |
|
560 | 602 | |
561 | 603 | // Show more page numbers. |
562 | - if (!empty($context['page_index'])) |
|
563 | - echo ' |
|
604 | + if (!empty($context['page_index'])) { |
|
605 | + echo ' |
|
564 | 606 | <div class="pagesection"> |
565 | 607 | <div class="pagelinks">', $context['page_index'], '</div> |
566 | 608 | </div>'; |
567 | -} |
|
609 | + } |
|
610 | + } |
|
568 | 611 | |
569 | 612 | /** |
570 | 613 | * Template for showing alerts within the alerts popup |
@@ -574,11 +617,12 @@ discard block |
||
574 | 617 | global $context, $txt, $scripturl; |
575 | 618 | |
576 | 619 | // Do we have an update message? |
577 | - if (!empty($context['update_message'])) |
|
578 | - echo ' |
|
620 | + if (!empty($context['update_message'])) { |
|
621 | + echo ' |
|
579 | 622 | <div class="infobox"> |
580 | 623 | ', $context['update_message'], ' |
581 | 624 | </div>'; |
625 | + } |
|
582 | 626 | |
583 | 627 | echo ' |
584 | 628 | <div class="cat_bar"> |
@@ -587,18 +631,18 @@ discard block |
||
587 | 631 | </h3> |
588 | 632 | </div>'; |
589 | 633 | |
590 | - if (empty($context['alerts'])) |
|
591 | - echo ' |
|
634 | + if (empty($context['alerts'])) { |
|
635 | + echo ' |
|
592 | 636 | <div class="information"> |
593 | 637 | ', $txt['alerts_none'], ' |
594 | 638 | </div>'; |
595 | - |
|
596 | - else |
|
639 | + } else |
|
597 | 640 | { |
598 | 641 | // Start the form if checkboxes are in use |
599 | - if ($context['showCheckboxes']) |
|
600 | - echo ' |
|
642 | + if ($context['showCheckboxes']) { |
|
643 | + echo ' |
|
601 | 644 | <form action="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=showalerts;save" method="post" accept-charset="', $context['character_set'], '" id="mark_all">'; |
645 | + } |
|
602 | 646 | |
603 | 647 | echo ' |
604 | 648 | <table id="alerts" class="table_grid">'; |
@@ -617,9 +661,10 @@ discard block |
||
617 | 661 | <li><a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=showalerts;do=remove;aid=', $id, ';', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['delete'], '</a></li> |
618 | 662 | <li><a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=showalerts;do=', ($alert['is_read'] != 0 ? 'unread' : 'read'), ';aid=', $id, ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons ', $alert['is_read'] != 0 ? 'unread_button' : 'read_button', '"></span>', ($alert['is_read'] != 0 ? $txt['mark_unread'] : $txt['mark_read_short']), '</a></li>'; |
619 | 663 | |
620 | - if ($context['showCheckboxes']) |
|
621 | - echo ' |
|
664 | + if ($context['showCheckboxes']) { |
|
665 | + echo ' |
|
622 | 666 | <li><input type="checkbox" name="mark[', $id, ']" value="', $id, '"></li>'; |
667 | + } |
|
623 | 668 | |
624 | 669 | echo ' |
625 | 670 | </ul> |
@@ -634,8 +679,8 @@ discard block |
||
634 | 679 | ', $context['pagination'], ' |
635 | 680 | </div>'; |
636 | 681 | |
637 | - if ($context['showCheckboxes']) |
|
638 | - echo ' |
|
682 | + if ($context['showCheckboxes']) { |
|
683 | + echo ' |
|
639 | 684 | <div class="floatright"> |
640 | 685 | ', $txt['check_all'], ': <input type="checkbox" name="select_all" id="select_all"> |
641 | 686 | <select name="mark_as"> |
@@ -646,14 +691,16 @@ discard block |
||
646 | 691 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
647 | 692 | <input type="submit" name="req" value="', $txt['quick_mod_go'], '" class="button you_sure"> |
648 | 693 | </div>'; |
694 | + } |
|
649 | 695 | |
650 | 696 | echo ' |
651 | 697 | </div>'; |
652 | 698 | |
653 | - if ($context['showCheckboxes']) |
|
654 | - echo ' |
|
699 | + if ($context['showCheckboxes']) { |
|
700 | + echo ' |
|
655 | 701 | </form>'; |
656 | 702 | } |
703 | + } |
|
657 | 704 | } |
658 | 705 | |
659 | 706 | /** |
@@ -674,12 +721,12 @@ discard block |
||
674 | 721 | </div>' : ''; |
675 | 722 | |
676 | 723 | // No drafts? Just show an informative message. |
677 | - if (empty($context['drafts'])) |
|
678 | - echo ' |
|
724 | + if (empty($context['drafts'])) { |
|
725 | + echo ' |
|
679 | 726 | <div class="windowbg centertext"> |
680 | 727 | ', $txt['draft_none'], ' |
681 | 728 | </div>'; |
682 | - else |
|
729 | + } else |
|
683 | 730 | { |
684 | 731 | // For every draft to be displayed, give it its own div, and show the important details of the draft. |
685 | 732 | foreach ($context['drafts'] as $draft) |
@@ -691,13 +738,15 @@ discard block |
||
691 | 738 | <h5> |
692 | 739 | <strong><a href="', $scripturl, '?board=', $draft['board']['id'], '.0">', $draft['board']['name'], '</a> / ', $draft['topic']['link'], '</strong> '; |
693 | 740 | |
694 | - if (!empty($draft['sticky'])) |
|
695 | - echo ' |
|
741 | + if (!empty($draft['sticky'])) { |
|
742 | + echo ' |
|
696 | 743 | <span class="generic_icons sticky" title="', $txt['sticky_topic'], '"></span>'; |
744 | + } |
|
697 | 745 | |
698 | - if (!empty($draft['locked'])) |
|
699 | - echo ' |
|
746 | + if (!empty($draft['locked'])) { |
|
747 | + echo ' |
|
700 | 748 | <span class="generic_icons lock" title="', $txt['locked_topic'], '"></span>'; |
749 | + } |
|
701 | 750 | |
702 | 751 | echo ' |
703 | 752 | </h5> |
@@ -730,13 +779,13 @@ discard block |
||
730 | 779 | { |
731 | 780 | global $context, $scripturl, $txt; |
732 | 781 | |
733 | - if (!empty($context['saved_successful'])) |
|
734 | - echo ' |
|
782 | + if (!empty($context['saved_successful'])) { |
|
783 | + echo ' |
|
735 | 784 | <div class="infobox">', $context['user']['is_owner'] ? $txt['profile_updated_own'] : sprintf($txt['profile_updated_else'], $context['member']['name']), '</div>'; |
736 | - |
|
737 | - elseif (!empty($context['saved_failed'])) |
|
738 | - echo ' |
|
785 | + } elseif (!empty($context['saved_failed'])) { |
|
786 | + echo ' |
|
739 | 787 | <div class="errorbox">', $context['saved_failed'], '</div>'; |
788 | + } |
|
740 | 789 | |
741 | 790 | echo ' |
742 | 791 | <div id="edit_buddies"> |
@@ -751,14 +800,16 @@ discard block |
||
751 | 800 | <th scope="col" class="quarter_table buddy_link">', $txt['name'], '</th> |
752 | 801 | <th scope="col" class="buddy_status">', $txt['status'], '</th>'; |
753 | 802 | |
754 | - if ($context['can_moderate_forum']) |
|
755 | - echo ' |
|
803 | + if ($context['can_moderate_forum']) { |
|
804 | + echo ' |
|
756 | 805 | <th scope="col" class="buddy_email">', $txt['email'], '</th>'; |
806 | + } |
|
757 | 807 | |
758 | - if (!empty($context['custom_pf'])) |
|
759 | - foreach ($context['custom_pf'] as $column) |
|
808 | + if (!empty($context['custom_pf'])) { |
|
809 | + foreach ($context['custom_pf'] as $column) |
|
760 | 810 | echo ' |
761 | 811 | <th scope="col" class="buddy_custom_fields">', $column['label'], '</th>'; |
812 | + } |
|
762 | 813 | |
763 | 814 | echo ' |
764 | 815 | <th scope="col" class="buddy_remove">', $txt['remove'], '</th> |
@@ -767,13 +818,14 @@ discard block |
||
767 | 818 | <tbody>'; |
768 | 819 | |
769 | 820 | // If they don't have any buddies don't list them! |
770 | - if (empty($context['buddies'])) |
|
771 | - echo ' |
|
821 | + if (empty($context['buddies'])) { |
|
822 | + echo ' |
|
772 | 823 | <tr class="windowbg"> |
773 | 824 | <td colspan="', $context['can_moderate_forum'] ? '10' : '9', '"> |
774 | 825 | <strong>', $txt['no_buddies'], '</strong> |
775 | 826 | </td> |
776 | 827 | </tr>'; |
828 | + } |
|
777 | 829 | |
778 | 830 | // Now loop through each buddy showing info on each. |
779 | 831 | else |
@@ -787,17 +839,19 @@ discard block |
||
787 | 839 | <a href="', $buddy['online']['href'], '"><span class="' . ($buddy['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $buddy['online']['text'] . '"></span></a> |
788 | 840 | </td>'; |
789 | 841 | |
790 | - if ($buddy['show_email']) |
|
791 | - echo ' |
|
842 | + if ($buddy['show_email']) { |
|
843 | + echo ' |
|
792 | 844 | <td class="buddy_email centertext"> |
793 | 845 | <a href="mailto:' . $buddy['email'] . '" rel="nofollow"><span class="generic_icons mail icon" title="' . $txt['email'] . ' ' . $buddy['name'] . '"></span></a> |
794 | 846 | </td>'; |
847 | + } |
|
795 | 848 | |
796 | 849 | // Show the custom profile fields for this user. |
797 | - if (!empty($context['custom_pf'])) |
|
798 | - foreach ($context['custom_pf'] as $key => $column) |
|
850 | + if (!empty($context['custom_pf'])) { |
|
851 | + foreach ($context['custom_pf'] as $key => $column) |
|
799 | 852 | echo ' |
800 | 853 | <td class="lefttext buddy_custom_fields">', $buddy['options'][$key], '</td>'; |
854 | + } |
|
801 | 855 | |
802 | 856 | echo ' |
803 | 857 | <td class="centertext buddy_remove"> |
@@ -830,9 +884,10 @@ discard block |
||
830 | 884 | </dl> |
831 | 885 | </div>'; |
832 | 886 | |
833 | - if (!empty($context['token_check'])) |
|
834 | - echo ' |
|
887 | + if (!empty($context['token_check'])) { |
|
888 | + echo ' |
|
835 | 889 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
890 | + } |
|
836 | 891 | |
837 | 892 | echo ' |
838 | 893 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -858,13 +913,13 @@ discard block |
||
858 | 913 | { |
859 | 914 | global $context, $scripturl, $txt; |
860 | 915 | |
861 | - if (!empty($context['saved_successful'])) |
|
862 | - echo ' |
|
916 | + if (!empty($context['saved_successful'])) { |
|
917 | + echo ' |
|
863 | 918 | <div class="infobox">', $context['user']['is_owner'] ? $txt['profile_updated_own'] : sprintf($txt['profile_updated_else'], $context['member']['name']), '</div>'; |
864 | - |
|
865 | - elseif (!empty($context['saved_failed'])) |
|
866 | - echo ' |
|
919 | + } elseif (!empty($context['saved_failed'])) { |
|
920 | + echo ' |
|
867 | 921 | <div class="errorbox">', $context['saved_failed'], '</div>'; |
922 | + } |
|
868 | 923 | |
869 | 924 | echo ' |
870 | 925 | <div id="edit_buddies"> |
@@ -879,9 +934,10 @@ discard block |
||
879 | 934 | <th scope="col" class="quarter_table buddy_link">', $txt['name'], '</th> |
880 | 935 | <th scope="col" class="buddy_status">', $txt['status'], '</th>'; |
881 | 936 | |
882 | - if ($context['can_moderate_forum']) |
|
883 | - echo ' |
|
937 | + if ($context['can_moderate_forum']) { |
|
938 | + echo ' |
|
884 | 939 | <th scope="col" class="buddy_email">', $txt['email'], '</th>'; |
940 | + } |
|
885 | 941 | |
886 | 942 | echo ' |
887 | 943 | <th scope="col" class="buddy_remove">', $txt['ignore_remove'], '</th> |
@@ -890,13 +946,14 @@ discard block |
||
890 | 946 | <tbody>'; |
891 | 947 | |
892 | 948 | // If they don't have anyone on their ignore list, don't list it! |
893 | - if (empty($context['ignore_list'])) |
|
894 | - echo ' |
|
949 | + if (empty($context['ignore_list'])) { |
|
950 | + echo ' |
|
895 | 951 | <tr class="windowbg"> |
896 | 952 | <td colspan="', $context['can_moderate_forum'] ? '4' : '3', '"> |
897 | 953 | <strong>', $txt['no_ignore'], '</strong> |
898 | 954 | </td> |
899 | 955 | </tr>'; |
956 | + } |
|
900 | 957 | |
901 | 958 | // Now loop through each buddy showing info on each. |
902 | 959 | foreach ($context['ignore_list'] as $member) |
@@ -908,11 +965,12 @@ discard block |
||
908 | 965 | <a href="', $member['online']['href'], '"><span class="' . ($member['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $member['online']['text'] . '"></span></a> |
909 | 966 | </td>'; |
910 | 967 | |
911 | - if ($context['can_moderate_forum']) |
|
912 | - echo ' |
|
968 | + if ($context['can_moderate_forum']) { |
|
969 | + echo ' |
|
913 | 970 | <td class="centertext buddy_email"> |
914 | 971 | <a href="mailto:' . $member['email'] . '" rel="nofollow"><span class="generic_icons mail icon" title="' . $txt['email'] . ' ' . $member['name'] . '"></span></a> |
915 | 972 | </td>'; |
973 | + } |
|
916 | 974 | echo ' |
917 | 975 | <td class="centertext buddy_remove"> |
918 | 976 | <a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=lists;sa=ignore;remove=', $member['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons delete" title="', $txt['ignore_remove'], '"></span></a> |
@@ -943,9 +1001,10 @@ discard block |
||
943 | 1001 | </dl> |
944 | 1002 | </div>'; |
945 | 1003 | |
946 | - if (!empty($context['token_check'])) |
|
947 | - echo ' |
|
1004 | + if (!empty($context['token_check'])) { |
|
1005 | + echo ' |
|
948 | 1006 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
1007 | + } |
|
949 | 1008 | |
950 | 1009 | echo ' |
951 | 1010 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -990,9 +1049,10 @@ discard block |
||
990 | 1049 | <a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['last_ip'], ';u=', $context['member']['id'], '">', $context['last_ip'], '</a>'; |
991 | 1050 | |
992 | 1051 | // Second address detected? |
993 | - if (!empty($context['last_ip2'])) |
|
994 | - echo ' |
|
1052 | + if (!empty($context['last_ip2'])) { |
|
1053 | + echo ' |
|
995 | 1054 | , <a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['last_ip2'], ';u=', $context['member']['id'], '">', $context['last_ip2'], '</a>'; |
1055 | + } |
|
996 | 1056 | |
997 | 1057 | echo ' |
998 | 1058 | </dd>'; |
@@ -1058,9 +1118,10 @@ discard block |
||
1058 | 1118 | </div> |
1059 | 1119 | <div class="windowbg">'; |
1060 | 1120 | |
1061 | - foreach ($context['whois_servers'] as $server) |
|
1062 | - echo ' |
|
1121 | + foreach ($context['whois_servers'] as $server) { |
|
1122 | + echo ' |
|
1063 | 1123 | <a href="', $server['url'], '" target="_blank" rel="noopener"', '>', $server['name'], '</a><br>'; |
1124 | + } |
|
1064 | 1125 | echo ' |
1065 | 1126 | </div> |
1066 | 1127 | <br>'; |
@@ -1072,13 +1133,12 @@ discard block |
||
1072 | 1133 | <h3 class="catbg">', $txt['members_from_ip'], ' ', $context['ip'], '</h3> |
1073 | 1134 | </div>'; |
1074 | 1135 | |
1075 | - if (empty($context['ips'])) |
|
1076 | - echo ' |
|
1136 | + if (empty($context['ips'])) { |
|
1137 | + echo ' |
|
1077 | 1138 | <p class="windowbg description"> |
1078 | 1139 | <em>', $txt['no_members_from_ip'], '</em> |
1079 | 1140 | </p>'; |
1080 | - |
|
1081 | - else |
|
1141 | + } else |
|
1082 | 1142 | { |
1083 | 1143 | echo ' |
1084 | 1144 | <table class="table_grid"> |
@@ -1091,12 +1151,13 @@ discard block |
||
1091 | 1151 | <tbody>'; |
1092 | 1152 | |
1093 | 1153 | // Loop through each of the members and display them. |
1094 | - foreach ($context['ips'] as $ip => $memberlist) |
|
1095 | - echo ' |
|
1154 | + foreach ($context['ips'] as $ip => $memberlist) { |
|
1155 | + echo ' |
|
1096 | 1156 | <tr class="windowbg"> |
1097 | 1157 | <td><a href="', $context['base_url'], ';searchip=', $ip, '">', $ip, '</a></td> |
1098 | 1158 | <td>', implode(', ', $memberlist), '</td> |
1099 | 1159 | </tr>'; |
1160 | + } |
|
1100 | 1161 | |
1101 | 1162 | echo ' |
1102 | 1163 | </tbody> |
@@ -1138,11 +1199,10 @@ discard block |
||
1138 | 1199 | </h3> |
1139 | 1200 | </div>'; |
1140 | 1201 | |
1141 | - if ($context['member']['has_all_permissions']) |
|
1142 | - echo ' |
|
1202 | + if ($context['member']['has_all_permissions']) { |
|
1203 | + echo ' |
|
1143 | 1204 | <div class="information">', $txt['showPermissions_all'], '</div>'; |
1144 | - |
|
1145 | - else |
|
1205 | + } else |
|
1146 | 1206 | { |
1147 | 1207 | echo ' |
1148 | 1208 | <div class="information">',$txt['showPermissions_help'], '</div> |
@@ -1157,9 +1217,10 @@ discard block |
||
1157 | 1217 | <div class="windowbg smalltext"> |
1158 | 1218 | ', $txt['showPermissions_restricted_boards_desc'], ':<br>'; |
1159 | 1219 | |
1160 | - foreach ($context['no_access_boards'] as $no_access_board) |
|
1161 | - echo ' |
|
1220 | + foreach ($context['no_access_boards'] as $no_access_board) { |
|
1221 | + echo ' |
|
1162 | 1222 | <a href="', $scripturl, '?board=', $no_access_board['id'], '.0">', $no_access_board['name'], '</a>', $no_access_board['is_last'] ? '' : ', '; |
1223 | + } |
|
1163 | 1224 | echo ' |
1164 | 1225 | </div>'; |
1165 | 1226 | } |
@@ -1191,12 +1252,13 @@ discard block |
||
1191 | 1252 | </td> |
1192 | 1253 | <td class="smalltext">'; |
1193 | 1254 | |
1194 | - if ($permission['is_denied']) |
|
1195 | - echo ' |
|
1255 | + if ($permission['is_denied']) { |
|
1256 | + echo ' |
|
1196 | 1257 | <span class="alert">', $txt['showPermissions_denied'], ': ', implode(', ', $permission['groups']['denied']), '</span>'; |
1197 | - else |
|
1198 | - echo ' |
|
1258 | + } else { |
|
1259 | + echo ' |
|
1199 | 1260 | ', $txt['showPermissions_given'], ': ', implode(', ', $permission['groups']['allowed']); |
1261 | + } |
|
1200 | 1262 | |
1201 | 1263 | echo ' |
1202 | 1264 | </td> |
@@ -1207,10 +1269,10 @@ discard block |
||
1207 | 1269 | </table> |
1208 | 1270 | </div><!-- .tborder --> |
1209 | 1271 | <br>'; |
1210 | - } |
|
1211 | - else |
|
1212 | - echo ' |
|
1272 | + } else { |
|
1273 | + echo ' |
|
1213 | 1274 | <p class="windowbg">', $txt['showPermissions_none_general'], '</p>'; |
1275 | + } |
|
1214 | 1276 | |
1215 | 1277 | // Board permission section. |
1216 | 1278 | echo ' |
@@ -1221,14 +1283,16 @@ discard block |
||
1221 | 1283 | <select name="board" onchange="if (this.options[this.selectedIndex].value) this.form.submit();"> |
1222 | 1284 | <option value="0"', $context['board'] == 0 ? ' selected' : '', '>', $txt['showPermissions_global'], '</option>'; |
1223 | 1285 | |
1224 | - if (!empty($context['boards'])) |
|
1225 | - echo ' |
|
1286 | + if (!empty($context['boards'])) { |
|
1287 | + echo ' |
|
1226 | 1288 | <option value="" disabled>---------------------------</option>'; |
1289 | + } |
|
1227 | 1290 | |
1228 | 1291 | // Fill the box with any local permission boards. |
1229 | - foreach ($context['boards'] as $board) |
|
1230 | - echo ' |
|
1292 | + foreach ($context['boards'] as $board) { |
|
1293 | + echo ' |
|
1231 | 1294 | <option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['name'], ' (', $board['profile_name'], ')</option>'; |
1295 | + } |
|
1232 | 1296 | |
1233 | 1297 | echo ' |
1234 | 1298 | </select> |
@@ -1257,13 +1321,13 @@ discard block |
||
1257 | 1321 | </td> |
1258 | 1322 | <td class="smalltext">'; |
1259 | 1323 | |
1260 | - if ($permission['is_denied']) |
|
1261 | - echo ' |
|
1324 | + if ($permission['is_denied']) { |
|
1325 | + echo ' |
|
1262 | 1326 | <span class="alert">', $txt['showPermissions_denied'], ': ', implode(', ', $permission['groups']['denied']), '</span>'; |
1263 | - |
|
1264 | - else |
|
1265 | - echo ' |
|
1327 | + } else { |
|
1328 | + echo ' |
|
1266 | 1329 | ', $txt['showPermissions_given'], ': ', implode(', ', $permission['groups']['allowed']); |
1330 | + } |
|
1267 | 1331 | |
1268 | 1332 | echo ' |
1269 | 1333 | </td> |
@@ -1272,10 +1336,10 @@ discard block |
||
1272 | 1336 | echo ' |
1273 | 1337 | </tbody> |
1274 | 1338 | </table>'; |
1275 | - } |
|
1276 | - else |
|
1277 | - echo ' |
|
1339 | + } else { |
|
1340 | + echo ' |
|
1278 | 1341 | <p class="windowbg">', $txt['showPermissions_none_board'], '</p>'; |
1342 | + } |
|
1279 | 1343 | echo ' |
1280 | 1344 | </div><!-- #permissions -->'; |
1281 | 1345 | } |
@@ -1299,12 +1363,13 @@ discard block |
||
1299 | 1363 | echo ' |
1300 | 1364 | <dt>', $txt['statPanel_' . $key], '</dt>'; |
1301 | 1365 | |
1302 | - if (!empty($stat['url'])) |
|
1303 | - echo ' |
|
1366 | + if (!empty($stat['url'])) { |
|
1367 | + echo ' |
|
1304 | 1368 | <dd><a href="', $stat['url'], '">', $stat['text'], '</a></dd>'; |
1305 | - else |
|
1306 | - echo ' |
|
1369 | + } else { |
|
1370 | + echo ' |
|
1307 | 1371 | <dd>', $stat['text'], '</dd>'; |
1372 | + } |
|
1308 | 1373 | } |
1309 | 1374 | |
1310 | 1375 | echo ' |
@@ -1321,9 +1386,10 @@ discard block |
||
1321 | 1386 | </div>'; |
1322 | 1387 | |
1323 | 1388 | // If they haven't post at all, don't draw the graph. |
1324 | - if (empty($context['posts_by_time'])) |
|
1325 | - echo ' |
|
1389 | + if (empty($context['posts_by_time'])) { |
|
1390 | + echo ' |
|
1326 | 1391 | <p class="centertext padding">', $txt['statPanel_noPosts'], '</p>'; |
1392 | + } |
|
1327 | 1393 | |
1328 | 1394 | // Otherwise do! |
1329 | 1395 | else |
@@ -1332,8 +1398,8 @@ discard block |
||
1332 | 1398 | <ul class="activity_stats flow_hidden">'; |
1333 | 1399 | |
1334 | 1400 | // The labels. |
1335 | - foreach ($context['posts_by_time'] as $time_of_day) |
|
1336 | - echo ' |
|
1401 | + foreach ($context['posts_by_time'] as $time_of_day) { |
|
1402 | + echo ' |
|
1337 | 1403 | <li> |
1338 | 1404 | <div class="generic_bar vertical"> |
1339 | 1405 | <div class="bar" style="height: ', (int) $time_of_day['relative_percent'], '%;"> |
@@ -1342,6 +1408,7 @@ discard block |
||
1342 | 1408 | </div> |
1343 | 1409 | <span class="stats_hour">', $time_of_day['hour_format'], '</span> |
1344 | 1410 | </li>'; |
1411 | + } |
|
1345 | 1412 | |
1346 | 1413 | echo ' |
1347 | 1414 | </ul>'; |
@@ -1360,11 +1427,10 @@ discard block |
||
1360 | 1427 | </h3> |
1361 | 1428 | </div>'; |
1362 | 1429 | |
1363 | - if (empty($context['popular_boards'])) |
|
1364 | - echo ' |
|
1430 | + if (empty($context['popular_boards'])) { |
|
1431 | + echo ' |
|
1365 | 1432 | <p class="centertext padding">', $txt['statPanel_noPosts'], '</p>'; |
1366 | - |
|
1367 | - else |
|
1433 | + } else |
|
1368 | 1434 | { |
1369 | 1435 | echo ' |
1370 | 1436 | <dl class="stats">'; |
@@ -1394,10 +1460,10 @@ discard block |
||
1394 | 1460 | </h3> |
1395 | 1461 | </div>'; |
1396 | 1462 | |
1397 | - if (empty($context['board_activity'])) |
|
1398 | - echo ' |
|
1463 | + if (empty($context['board_activity'])) { |
|
1464 | + echo ' |
|
1399 | 1465 | <p class="centertext padding">', $txt['statPanel_noPosts'], '</p>'; |
1400 | - else |
|
1466 | + } else |
|
1401 | 1467 | { |
1402 | 1468 | echo ' |
1403 | 1469 | <dl class="stats">'; |
@@ -1448,90 +1514,97 @@ discard block |
||
1448 | 1514 | <h3 class="catbg profile_hd">'; |
1449 | 1515 | |
1450 | 1516 | // Don't say "Profile" if this isn't the profile... |
1451 | - if (!empty($context['profile_header_text'])) |
|
1452 | - echo ' |
|
1517 | + if (!empty($context['profile_header_text'])) { |
|
1518 | + echo ' |
|
1453 | 1519 | ', $context['profile_header_text']; |
1454 | - else |
|
1455 | - echo ' |
|
1520 | + } else { |
|
1521 | + echo ' |
|
1456 | 1522 | ', $txt['profile']; |
1523 | + } |
|
1457 | 1524 | |
1458 | 1525 | echo ' |
1459 | 1526 | </h3> |
1460 | 1527 | </div>'; |
1461 | 1528 | |
1462 | 1529 | // Have we some description? |
1463 | - if ($context['page_desc']) |
|
1464 | - echo ' |
|
1530 | + if ($context['page_desc']) { |
|
1531 | + echo ' |
|
1465 | 1532 | <p class="information">', $context['page_desc'], '</p>'; |
1533 | + } |
|
1466 | 1534 | |
1467 | 1535 | echo ' |
1468 | 1536 | <div class="roundframe">'; |
1469 | 1537 | |
1470 | 1538 | // Any bits at the start? |
1471 | - if (!empty($context['profile_prehtml'])) |
|
1472 | - echo ' |
|
1539 | + if (!empty($context['profile_prehtml'])) { |
|
1540 | + echo ' |
|
1473 | 1541 | <div>', $context['profile_prehtml'], '</div>'; |
1542 | + } |
|
1474 | 1543 | |
1475 | - if (!empty($context['profile_fields'])) |
|
1476 | - echo ' |
|
1544 | + if (!empty($context['profile_fields'])) { |
|
1545 | + echo ' |
|
1477 | 1546 | <dl class="settings">'; |
1547 | + } |
|
1478 | 1548 | |
1479 | 1549 | // Start the big old loop 'of love. |
1480 | 1550 | $lastItem = 'hr'; |
1481 | 1551 | foreach ($context['profile_fields'] as $key => $field) |
1482 | 1552 | { |
1483 | 1553 | // We add a little hack to be sure we never get more than one hr in a row! |
1484 | - if ($lastItem == 'hr' && $field['type'] == 'hr') |
|
1485 | - continue; |
|
1554 | + if ($lastItem == 'hr' && $field['type'] == 'hr') { |
|
1555 | + continue; |
|
1556 | + } |
|
1486 | 1557 | |
1487 | 1558 | $lastItem = $field['type']; |
1488 | - if ($field['type'] == 'hr') |
|
1489 | - echo ' |
|
1559 | + if ($field['type'] == 'hr') { |
|
1560 | + echo ' |
|
1490 | 1561 | </dl> |
1491 | 1562 | <hr> |
1492 | 1563 | <dl class="settings">'; |
1493 | - |
|
1494 | - elseif ($field['type'] == 'callback') |
|
1564 | + } elseif ($field['type'] == 'callback') |
|
1495 | 1565 | { |
1496 | 1566 | if (isset($field['callback_func']) && function_exists('template_profile_' . $field['callback_func'])) |
1497 | 1567 | { |
1498 | 1568 | $callback_func = 'template_profile_' . $field['callback_func']; |
1499 | 1569 | $callback_func(); |
1500 | 1570 | } |
1501 | - } |
|
1502 | - else |
|
1571 | + } else |
|
1503 | 1572 | { |
1504 | 1573 | echo ' |
1505 | 1574 | <dt> |
1506 | 1575 | <strong', !empty($field['is_error']) ? ' class="error"' : '', '>', $field['type'] !== 'label' ? '<label for="' . $key . '">' : '', $field['label'], $field['type'] !== 'label' ? '</label>' : '', '</strong>'; |
1507 | 1576 | |
1508 | 1577 | // Does it have any subtext to show? |
1509 | - if (!empty($field['subtext'])) |
|
1510 | - echo ' |
|
1578 | + if (!empty($field['subtext'])) { |
|
1579 | + echo ' |
|
1511 | 1580 | <br> |
1512 | 1581 | <span class="smalltext">', $field['subtext'], '</span>'; |
1582 | + } |
|
1513 | 1583 | |
1514 | 1584 | echo ' |
1515 | 1585 | </dt> |
1516 | 1586 | <dd>'; |
1517 | 1587 | |
1518 | 1588 | // Want to put something infront of the box? |
1519 | - if (!empty($field['preinput'])) |
|
1520 | - echo ' |
|
1589 | + if (!empty($field['preinput'])) { |
|
1590 | + echo ' |
|
1521 | 1591 | ', $field['preinput']; |
1592 | + } |
|
1522 | 1593 | |
1523 | 1594 | // What type of data are we showing? |
1524 | - if ($field['type'] == 'label') |
|
1525 | - echo ' |
|
1595 | + if ($field['type'] == 'label') { |
|
1596 | + echo ' |
|
1526 | 1597 | ', $field['value']; |
1598 | + } |
|
1527 | 1599 | |
1528 | 1600 | // Maybe it's a text box - very likely! |
1529 | 1601 | elseif (in_array($field['type'], array('int', 'float', 'text', 'password', 'color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'number', 'time', 'url'))) |
1530 | 1602 | { |
1531 | - if ($field['type'] == 'int' || $field['type'] == 'float') |
|
1532 | - $type = 'number'; |
|
1533 | - else |
|
1534 | - $type = $field['type']; |
|
1603 | + if ($field['type'] == 'int' || $field['type'] == 'float') { |
|
1604 | + $type = 'number'; |
|
1605 | + } else { |
|
1606 | + $type = $field['type']; |
|
1607 | + } |
|
1535 | 1608 | $step = $field['type'] == 'float' ? ' step="0.1"' : ''; |
1536 | 1609 | |
1537 | 1610 | |
@@ -1539,10 +1612,11 @@ discard block |
||
1539 | 1612 | <input type="', $type, '" name="', $key, '" id="', $key, '" size="', empty($field['size']) ? 30 : $field['size'], '" value="', $field['value'], '" ', $field['input_attr'], ' ', $step, '>'; |
1540 | 1613 | } |
1541 | 1614 | // You "checking" me out? ;) |
1542 | - elseif ($field['type'] == 'check') |
|
1543 | - echo ' |
|
1615 | + elseif ($field['type'] == 'check') { |
|
1616 | + echo ' |
|
1544 | 1617 | <input type="hidden" name="', $key, '" value="0"> |
1545 | 1618 | <input type="checkbox" name="', $key, '" id="', $key, '"', !empty($field['value']) ? ' checked' : '', ' value="1" ', $field['input_attr'], '>'; |
1619 | + } |
|
1546 | 1620 | |
1547 | 1621 | // Always fun - select boxes! |
1548 | 1622 | elseif ($field['type'] == 'select') |
@@ -1553,14 +1627,16 @@ discard block |
||
1553 | 1627 | if (isset($field['options'])) |
1554 | 1628 | { |
1555 | 1629 | // Is this some code to generate the options? |
1556 | - if (!is_array($field['options'])) |
|
1557 | - $field['options'] = $field['options'](); |
|
1630 | + if (!is_array($field['options'])) { |
|
1631 | + $field['options'] = $field['options'](); |
|
1632 | + } |
|
1558 | 1633 | |
1559 | 1634 | // Assuming we now have some! |
1560 | - if (is_array($field['options'])) |
|
1561 | - foreach ($field['options'] as $value => $name) |
|
1635 | + if (is_array($field['options'])) { |
|
1636 | + foreach ($field['options'] as $value => $name) |
|
1562 | 1637 | echo ' |
1563 | 1638 | <option', is_numeric($value) ? ' value="" disabled' : ' value="' . $value . '"', $value === $field['value'] ? ' selected' : '', '>', $name, '</option>'; |
1639 | + } |
|
1564 | 1640 | } |
1565 | 1641 | |
1566 | 1642 | echo ' |
@@ -1568,31 +1644,34 @@ discard block |
||
1568 | 1644 | } |
1569 | 1645 | |
1570 | 1646 | // Something to end with? |
1571 | - if (!empty($field['postinput'])) |
|
1572 | - echo ' |
|
1647 | + if (!empty($field['postinput'])) { |
|
1648 | + echo ' |
|
1573 | 1649 | ', $field['postinput']; |
1650 | + } |
|
1574 | 1651 | |
1575 | 1652 | echo ' |
1576 | 1653 | </dd>'; |
1577 | 1654 | } |
1578 | 1655 | } |
1579 | 1656 | |
1580 | - if (!empty($context['profile_fields'])) |
|
1581 | - echo ' |
|
1657 | + if (!empty($context['profile_fields'])) { |
|
1658 | + echo ' |
|
1582 | 1659 | </dl>'; |
1660 | + } |
|
1583 | 1661 | |
1584 | 1662 | // Are there any custom profile fields - if so print them! |
1585 | 1663 | if (!empty($context['custom_fields'])) |
1586 | 1664 | { |
1587 | - if ($lastItem != 'hr') |
|
1588 | - echo ' |
|
1665 | + if ($lastItem != 'hr') { |
|
1666 | + echo ' |
|
1589 | 1667 | <hr>'; |
1668 | + } |
|
1590 | 1669 | |
1591 | 1670 | echo ' |
1592 | 1671 | <dl class="settings">'; |
1593 | 1672 | |
1594 | - foreach ($context['custom_fields'] as $field) |
|
1595 | - echo ' |
|
1673 | + foreach ($context['custom_fields'] as $field) { |
|
1674 | + echo ' |
|
1596 | 1675 | <dt> |
1597 | 1676 | <strong>', $field['name'], ': </strong><br> |
1598 | 1677 | <span class="smalltext">', $field['desc'], '</span> |
@@ -1600,19 +1679,21 @@ discard block |
||
1600 | 1679 | <dd> |
1601 | 1680 | ', $field['input_html'], ' |
1602 | 1681 | </dd>'; |
1682 | + } |
|
1603 | 1683 | |
1604 | 1684 | echo ' |
1605 | 1685 | </dl>'; |
1606 | 1686 | } |
1607 | 1687 | |
1608 | 1688 | // Any closing HTML? |
1609 | - if (!empty($context['profile_posthtml'])) |
|
1610 | - echo ' |
|
1689 | + if (!empty($context['profile_posthtml'])) { |
|
1690 | + echo ' |
|
1611 | 1691 | <div>', $context['profile_posthtml'], '</div>'; |
1692 | + } |
|
1612 | 1693 | |
1613 | 1694 | // Only show the password box if it's actually needed. |
1614 | - if ($context['require_password']) |
|
1615 | - echo ' |
|
1695 | + if ($context['require_password']) { |
|
1696 | + echo ' |
|
1616 | 1697 | <dl class="settings"> |
1617 | 1698 | <dt> |
1618 | 1699 | <strong', isset($context['modify_error']['bad_password']) || isset($context['modify_error']['no_password']) ? ' class="error"' : '', '><label for="oldpasswrd">', $txt['current_password'], ': </label></strong><br> |
@@ -1622,18 +1703,21 @@ discard block |
||
1622 | 1703 | <input type="password" name="oldpasswrd" id="oldpasswrd" size="20"> |
1623 | 1704 | </dd> |
1624 | 1705 | </dl>'; |
1706 | + } |
|
1625 | 1707 | |
1626 | 1708 | // The button shouldn't say "Change profile" unless we're changing the profile... |
1627 | - if (!empty($context['submit_button_text'])) |
|
1628 | - echo ' |
|
1709 | + if (!empty($context['submit_button_text'])) { |
|
1710 | + echo ' |
|
1629 | 1711 | <input type="submit" name="save" value="', $context['submit_button_text'], '" class="button floatright">'; |
1630 | - else |
|
1631 | - echo ' |
|
1712 | + } else { |
|
1713 | + echo ' |
|
1632 | 1714 | <input type="submit" name="save" value="', $txt['change_profile'], '" class="button floatright">'; |
1715 | + } |
|
1633 | 1716 | |
1634 | - if (!empty($context['token_check'])) |
|
1635 | - echo ' |
|
1717 | + if (!empty($context['token_check'])) { |
|
1718 | + echo ' |
|
1636 | 1719 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
1720 | + } |
|
1637 | 1721 | |
1638 | 1722 | echo ' |
1639 | 1723 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -1643,10 +1727,11 @@ discard block |
||
1643 | 1727 | </form>'; |
1644 | 1728 | |
1645 | 1729 | // Any final spellchecking stuff? |
1646 | - if (!empty($context['show_spellchecking'])) |
|
1647 | - echo ' |
|
1730 | + if (!empty($context['show_spellchecking'])) { |
|
1731 | + echo ' |
|
1648 | 1732 | <form name="spell_form" id="spell_form" method="post" accept-charset="', $context['character_set'], '" target="spellWindow" action="', $scripturl, '?action=spellcheck"><input type="hidden" name="spellstring" value=""></form>'; |
1649 | -} |
|
1733 | + } |
|
1734 | + } |
|
1650 | 1735 | |
1651 | 1736 | /** |
1652 | 1737 | * Personal Message settings. |
@@ -1683,10 +1768,11 @@ discard block |
||
1683 | 1768 | <select name="pm_receive_from" id="pm_receive_from"> |
1684 | 1769 | <option value="0"', empty($context['receive_from']) || (empty($modSettings['enable_buddylist']) && $context['receive_from'] < 3) ? ' selected' : '', '>', $txt['pm_receive_from_everyone'], '</option>'; |
1685 | 1770 | |
1686 | - if (!empty($modSettings['enable_buddylist'])) |
|
1687 | - echo ' |
|
1771 | + if (!empty($modSettings['enable_buddylist'])) { |
|
1772 | + echo ' |
|
1688 | 1773 | <option value="1"', !empty($context['receive_from']) && $context['receive_from'] == 1 ? ' selected' : '', '>', $txt['pm_receive_from_ignore'], '</option> |
1689 | 1774 | <option value="2"', !empty($context['receive_from']) && $context['receive_from'] == 2 ? ' selected' : '', '>', $txt['pm_receive_from_buddies'], '</option>'; |
1775 | + } |
|
1690 | 1776 | |
1691 | 1777 | echo ' |
1692 | 1778 | <option value="3"', !empty($context['receive_from']) && $context['receive_from'] > 2 ? ' selected' : '', '>', $txt['pm_receive_from_admins'], '</option> |
@@ -1729,11 +1815,12 @@ discard block |
||
1729 | 1815 | if (empty($setting) || !is_array($setting)) |
1730 | 1816 | { |
1731 | 1817 | // Insert a separator (unless this is the first item in the list) |
1732 | - if ($i !== $first_option_key) |
|
1733 | - echo ' |
|
1818 | + if ($i !== $first_option_key) { |
|
1819 | + echo ' |
|
1734 | 1820 | </dl> |
1735 | 1821 | <hr> |
1736 | 1822 | <dl class="settings">'; |
1823 | + } |
|
1737 | 1824 | |
1738 | 1825 | // Should we give a name to this section? |
1739 | 1826 | if (is_string($setting) && !empty($setting)) |
@@ -1742,51 +1829,55 @@ discard block |
||
1742 | 1829 | echo ' |
1743 | 1830 | <dt><strong>' . $setting . '</strong></dt> |
1744 | 1831 | <dd></dd>'; |
1832 | + } else { |
|
1833 | + $titled_section = false; |
|
1745 | 1834 | } |
1746 | - else |
|
1747 | - $titled_section = false; |
|
1748 | 1835 | |
1749 | 1836 | continue; |
1750 | 1837 | } |
1751 | 1838 | |
1752 | 1839 | // Is this disabled? |
1753 | - if (isset($setting['enabled']) && $setting['enabled'] === false) |
|
1754 | - continue; |
|
1840 | + if (isset($setting['enabled']) && $setting['enabled'] === false) { |
|
1841 | + continue; |
|
1842 | + } |
|
1755 | 1843 | |
1756 | 1844 | // Some of these may not be set... Set to defaults here |
1757 | 1845 | $opts = array('calendar_start_day', 'topics_per_page', 'messages_per_page', 'display_quick_mod'); |
1758 | - if (in_array($setting['id'], $opts) && !isset($context['member']['options'][$setting['id']])) |
|
1759 | - $context['member']['options'][$setting['id']] = 0; |
|
1760 | - |
|
1761 | - if (!isset($setting['type']) || $setting['type'] == 'bool') |
|
1762 | - $setting['type'] = 'checkbox'; |
|
1763 | - |
|
1764 | - elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') |
|
1765 | - $setting['type'] = 'number'; |
|
1846 | + if (in_array($setting['id'], $opts) && !isset($context['member']['options'][$setting['id']])) { |
|
1847 | + $context['member']['options'][$setting['id']] = 0; |
|
1848 | + } |
|
1766 | 1849 | |
1767 | - elseif ($setting['type'] == 'string') |
|
1768 | - $setting['type'] = 'text'; |
|
1850 | + if (!isset($setting['type']) || $setting['type'] == 'bool') { |
|
1851 | + $setting['type'] = 'checkbox'; |
|
1852 | + } elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') { |
|
1853 | + $setting['type'] = 'number'; |
|
1854 | + } elseif ($setting['type'] == 'string') { |
|
1855 | + $setting['type'] = 'text'; |
|
1856 | + } |
|
1769 | 1857 | |
1770 | - if (isset($setting['options'])) |
|
1771 | - $setting['type'] = 'list'; |
|
1858 | + if (isset($setting['options'])) { |
|
1859 | + $setting['type'] = 'list'; |
|
1860 | + } |
|
1772 | 1861 | |
1773 | 1862 | echo ' |
1774 | 1863 | <dt> |
1775 | 1864 | <label for="', $setting['id'], '">', !$titled_section ? '<strong>' : '', $setting['label'], !$titled_section ? '</strong>' : '', '</label>'; |
1776 | 1865 | |
1777 | - if (isset($setting['description'])) |
|
1778 | - echo ' |
|
1866 | + if (isset($setting['description'])) { |
|
1867 | + echo ' |
|
1779 | 1868 | <br> |
1780 | 1869 | <span class="smalltext">', $setting['description'], '</span>'; |
1870 | + } |
|
1781 | 1871 | echo ' |
1782 | 1872 | </dt> |
1783 | 1873 | <dd>'; |
1784 | 1874 | |
1785 | 1875 | // Display checkbox options |
1786 | - if ($setting['type'] == 'checkbox') |
|
1787 | - echo ' |
|
1876 | + if ($setting['type'] == 'checkbox') { |
|
1877 | + echo ' |
|
1788 | 1878 | <input type="hidden" name="default_options[' . $setting['id'] . ']" value="0"> |
1789 | 1879 | <input type="checkbox" name="default_options[', $setting['id'], ']" id="', $setting['id'], '"', !empty($context['member']['options'][$setting['id']]) ? ' checked' : '', ' value="1">'; |
1880 | + } |
|
1790 | 1881 | |
1791 | 1882 | // How about selection lists, we all love them |
1792 | 1883 | elseif ($setting['type'] == 'list') |
@@ -1794,9 +1885,10 @@ discard block |
||
1794 | 1885 | echo ' |
1795 | 1886 | <select name="default_options[', $setting['id'], ']" id="', $setting['id'], '"', '>'; |
1796 | 1887 | |
1797 | - foreach ($setting['options'] as $value => $label) |
|
1798 | - echo ' |
|
1888 | + foreach ($setting['options'] as $value => $label) { |
|
1889 | + echo ' |
|
1799 | 1890 | <option value="', $value, '"', $value == $context['member']['options'][$setting['id']] ? ' selected' : '', '>', $label, '</option>'; |
1891 | + } |
|
1800 | 1892 | |
1801 | 1893 | echo ' |
1802 | 1894 | </select>'; |
@@ -1812,14 +1904,13 @@ discard block |
||
1812 | 1904 | |
1813 | 1905 | echo ' |
1814 | 1906 | <input type="number"', $min . $max . $step; |
1815 | - } |
|
1816 | - elseif (isset($setting['type']) && $setting['type'] == 'url') |
|
1817 | - echo' |
|
1907 | + } elseif (isset($setting['type']) && $setting['type'] == 'url') { |
|
1908 | + echo' |
|
1818 | 1909 | <input type="url"'; |
1819 | - |
|
1820 | - else |
|
1821 | - echo ' |
|
1910 | + } else { |
|
1911 | + echo ' |
|
1822 | 1912 | <input type="text"'; |
1913 | + } |
|
1823 | 1914 | |
1824 | 1915 | echo ' name="default_options[', $setting['id'], ']" id="', $setting['id'], '" value="', isset($context['member']['options'][$setting['id']]) ? $context['member']['options'][$setting['id']] : $setting['value'], '"', $setting['type'] == 'number' ? ' size="5"' : '', '>'; |
1825 | 1916 | } |
@@ -1856,8 +1947,8 @@ discard block |
||
1856 | 1947 | <dl class="settings">'; |
1857 | 1948 | |
1858 | 1949 | // Allow notification on announcements to be disabled? |
1859 | - if (!empty($modSettings['allow_disableAnnounce'])) |
|
1860 | - echo ' |
|
1950 | + if (!empty($modSettings['allow_disableAnnounce'])) { |
|
1951 | + echo ' |
|
1861 | 1952 | <dt> |
1862 | 1953 | <label for="notify_announcements">', $txt['notify_important_email'], '</label> |
1863 | 1954 | </dt> |
@@ -1865,15 +1956,17 @@ discard block |
||
1865 | 1956 | <input type="hidden" name="notify_announcements" value="0"> |
1866 | 1957 | <input type="checkbox" id="notify_announcements" name="notify_announcements" value="1"', !empty($context['member']['notify_announcements']) ? ' checked' : '', '> |
1867 | 1958 | </dd>'; |
1959 | + } |
|
1868 | 1960 | |
1869 | - if (!empty($modSettings['enable_ajax_alerts'])) |
|
1870 | - echo ' |
|
1961 | + if (!empty($modSettings['enable_ajax_alerts'])) { |
|
1962 | + echo ' |
|
1871 | 1963 | <dt> |
1872 | 1964 | <label for="notify_send_body">', $txt['notify_alert_timeout'], '</label> |
1873 | 1965 | </dt> |
1874 | 1966 | <dd> |
1875 | 1967 | <input type="number" size="4" id="notify_alert_timeout" name="opt_alert_timeout" min="0" value="', $context['member']['alert_timeout'], '"> |
1876 | 1968 | </dd>'; |
1969 | + } |
|
1877 | 1970 | |
1878 | 1971 | echo ' |
1879 | 1972 | </dl> |
@@ -1905,9 +1998,10 @@ discard block |
||
1905 | 1998 | |
1906 | 1999 | $label = $txt['alert_opt_' . $opts[1]]; |
1907 | 2000 | $label_pos = isset($opts['label']) ? $opts['label'] : ''; |
1908 | - if ($label_pos == 'before') |
|
1909 | - echo ' |
|
2001 | + if ($label_pos == 'before') { |
|
2002 | + echo ' |
|
1910 | 2003 | <label for="opt_', $opts[1], '">', $label, '</label>'; |
2004 | + } |
|
1911 | 2005 | |
1912 | 2006 | $this_value = isset($context['alert_prefs'][$opts[1]]) ? $context['alert_prefs'][$opts[1]] : 0; |
1913 | 2007 | switch ($opts[0]) |
@@ -1921,17 +2015,19 @@ discard block |
||
1921 | 2015 | echo ' |
1922 | 2016 | <select name="opt_', $opts[1], '" id="opt_', $opts[1], '">'; |
1923 | 2017 | |
1924 | - foreach ($opts['opts'] as $k => $v) |
|
1925 | - echo ' |
|
2018 | + foreach ($opts['opts'] as $k => $v) { |
|
2019 | + echo ' |
|
1926 | 2020 | <option value="', $k, '"', $this_value == $k ? ' selected' : '', '>', $v, '</option>'; |
2021 | + } |
|
1927 | 2022 | echo ' |
1928 | 2023 | </select>'; |
1929 | 2024 | break; |
1930 | 2025 | } |
1931 | 2026 | |
1932 | - if ($label_pos == 'after') |
|
1933 | - echo ' |
|
2027 | + if ($label_pos == 'after') { |
|
2028 | + echo ' |
|
1934 | 2029 | <label for="opt_', $opts[1], '">', $label, '</label>'; |
2030 | + } |
|
1935 | 2031 | |
1936 | 2032 | echo ' |
1937 | 2033 | </td> |
@@ -2048,11 +2144,12 @@ discard block |
||
2048 | 2144 | <p class="information">', $txt['groupMembership_info'], '</p>'; |
2049 | 2145 | |
2050 | 2146 | // Do we have an update message? |
2051 | - if (!empty($context['update_message'])) |
|
2052 | - echo ' |
|
2147 | + if (!empty($context['update_message'])) { |
|
2148 | + echo ' |
|
2053 | 2149 | <div class="infobox"> |
2054 | 2150 | ', $context['update_message'], '. |
2055 | 2151 | </div>'; |
2152 | + } |
|
2056 | 2153 | |
2057 | 2154 | echo ' |
2058 | 2155 | <div id="groups">'; |
@@ -2074,8 +2171,7 @@ discard block |
||
2074 | 2171 | </div> |
2075 | 2172 | </div> |
2076 | 2173 | </div><!-- .groupmembership -->'; |
2077 | - } |
|
2078 | - else |
|
2174 | + } else |
|
2079 | 2175 | { |
2080 | 2176 | echo ' |
2081 | 2177 | <div class="title_bar"> |
@@ -2087,27 +2183,30 @@ discard block |
||
2087 | 2183 | echo ' |
2088 | 2184 | <div class="windowbg" id="primdiv_', $group['id'], '">'; |
2089 | 2185 | |
2090 | - if ($context['can_edit_primary']) |
|
2091 | - echo ' |
|
2186 | + if ($context['can_edit_primary']) { |
|
2187 | + echo ' |
|
2092 | 2188 | <input type="radio" name="primary" id="primary_', $group['id'], '" value="', $group['id'], '"', $group['is_primary'] ? ' checked' : '', ' onclick="highlightSelected(\'primdiv_' . $group['id'] . '\');"', $group['can_be_primary'] ? '' : ' disabled', '>'; |
2189 | + } |
|
2093 | 2190 | |
2094 | 2191 | echo ' |
2095 | 2192 | <label for="primary_', $group['id'], '"><strong>', (empty($group['color']) ? $group['name'] : '<span style="color: ' . $group['color'] . '">' . $group['name'] . '</span>'), '</strong>', (!empty($group['desc']) ? '<br><span class="smalltext">' . $group['desc'] . '</span>' : ''), '</label>'; |
2096 | 2193 | |
2097 | 2194 | // Can they leave their group? |
2098 | - if ($group['can_leave']) |
|
2099 | - echo ' |
|
2195 | + if ($group['can_leave']) { |
|
2196 | + echo ' |
|
2100 | 2197 | <a href="' . $scripturl . '?action=profile;save;u=' . $context['id_member'] . ';area=groupmembership;' . $context['session_var'] . '=' . $context['session_id'] . ';gid=' . $group['id'] . ';', $context[$context['token_check'] . '_token_var'], '=', $context[$context['token_check'] . '_token'], '">' . $txt['leave_group'] . '</a>'; |
2198 | + } |
|
2101 | 2199 | |
2102 | 2200 | echo ' |
2103 | 2201 | </div><!-- .windowbg -->'; |
2104 | 2202 | } |
2105 | 2203 | |
2106 | - if ($context['can_edit_primary']) |
|
2107 | - echo ' |
|
2204 | + if ($context['can_edit_primary']) { |
|
2205 | + echo ' |
|
2108 | 2206 | <div class="padding righttext"> |
2109 | 2207 | <input type="submit" value="', $txt['make_primary'], '" class="button"> |
2110 | 2208 | </div>'; |
2209 | + } |
|
2111 | 2210 | |
2112 | 2211 | // Any groups they can join? |
2113 | 2212 | if (!empty($context['groups']['available'])) |
@@ -2123,17 +2222,16 @@ discard block |
||
2123 | 2222 | <div class="windowbg"> |
2124 | 2223 | <strong>', (empty($group['color']) ? $group['name'] : '<span style="color: ' . $group['color'] . '">' . $group['name'] . '</span>'), '</strong>', (!empty($group['desc']) ? '<br><span class="smalltext">' . $group['desc'] . '</span>' : ''), ''; |
2125 | 2224 | |
2126 | - if ($group['type'] == 3) |
|
2127 | - echo ' |
|
2225 | + if ($group['type'] == 3) { |
|
2226 | + echo ' |
|
2128 | 2227 | <a href="', $scripturl, '?action=profile;save;u=', $context['id_member'], ';area=groupmembership;', $context['session_var'], '=', $context['session_id'], ';gid=', $group['id'], ';', $context[$context['token_check'] . '_token_var'], '=', $context[$context['token_check'] . '_token'], '" class="button floatright">', $txt['join_group'], '</a>'; |
2129 | - |
|
2130 | - elseif ($group['type'] == 2 && $group['pending']) |
|
2131 | - echo ' |
|
2228 | + } elseif ($group['type'] == 2 && $group['pending']) { |
|
2229 | + echo ' |
|
2132 | 2230 | <span class="floatright">', $txt['approval_pending'], '</span>'; |
2133 | - |
|
2134 | - elseif ($group['type'] == 2) |
|
2135 | - echo ' |
|
2231 | + } elseif ($group['type'] == 2) { |
|
2232 | + echo ' |
|
2136 | 2233 | <a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=groupmembership;request=', $group['id'], '" class="button floatright">', $txt['request_group'], '</a>'; |
2234 | + } |
|
2137 | 2235 | |
2138 | 2236 | echo ' |
2139 | 2237 | </div><!-- .windowbg -->'; |
@@ -2156,9 +2254,10 @@ discard block |
||
2156 | 2254 | |
2157 | 2255 | prevDiv.className = "windowbg"; |
2158 | 2256 | }'; |
2159 | - if (isset($context['groups']['member'][$context['primary_group']])) |
|
2160 | - echo ' |
|
2257 | + if (isset($context['groups']['member'][$context['primary_group']])) { |
|
2258 | + echo ' |
|
2161 | 2259 | highlightSelected("primdiv_' . $context['primary_group'] . '");'; |
2260 | + } |
|
2162 | 2261 | |
2163 | 2262 | echo ' |
2164 | 2263 | </script>'; |
@@ -2167,9 +2266,10 @@ discard block |
||
2167 | 2266 | echo ' |
2168 | 2267 | </div><!-- #groups -->'; |
2169 | 2268 | |
2170 | - if (!empty($context['token_check'])) |
|
2171 | - echo ' |
|
2269 | + if (!empty($context['token_check'])) { |
|
2270 | + echo ' |
|
2172 | 2271 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
2272 | + } |
|
2173 | 2273 | |
2174 | 2274 | echo ' |
2175 | 2275 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -2247,10 +2347,11 @@ discard block |
||
2247 | 2347 | |
2248 | 2348 | // Work out the starting warning. |
2249 | 2349 | $context['current_warning_mode'] = $context['warning_mode'][0]; |
2250 | - foreach ($context['warning_mode'] as $limit => $warning) |
|
2251 | - if ($context['member']['warning'] >= $limit) |
|
2350 | + foreach ($context['warning_mode'] as $limit => $warning) { |
|
2351 | + if ($context['member']['warning'] >= $limit) |
|
2252 | 2352 | $context['current_warning_mode'] = $warning; |
2253 | -} |
|
2353 | + } |
|
2354 | + } |
|
2254 | 2355 | |
2255 | 2356 | // Show all warnings of a user? |
2256 | 2357 | function template_viewWarning() |
@@ -2285,14 +2386,15 @@ discard block |
||
2285 | 2386 | </dd>'; |
2286 | 2387 | |
2287 | 2388 | // There's some impact of this? |
2288 | - if (!empty($context['level_effects'][$context['current_level']])) |
|
2289 | - echo ' |
|
2389 | + if (!empty($context['level_effects'][$context['current_level']])) { |
|
2390 | + echo ' |
|
2290 | 2391 | <dt> |
2291 | 2392 | <strong>', $txt['profile_viewwarning_impact'], ':</strong> |
2292 | 2393 | </dt> |
2293 | 2394 | <dd> |
2294 | 2395 | ', $context['level_effects'][$context['current_level']], ' |
2295 | 2396 | </dd>'; |
2397 | + } |
|
2296 | 2398 | |
2297 | 2399 | echo ' |
2298 | 2400 | </dl> |
@@ -2330,10 +2432,11 @@ discard block |
||
2330 | 2432 | |
2331 | 2433 | // Otherwise see what we can do...'; |
2332 | 2434 | |
2333 | - foreach ($context['notification_templates'] as $k => $type) |
|
2334 | - echo ' |
|
2435 | + foreach ($context['notification_templates'] as $k => $type) { |
|
2436 | + echo ' |
|
2335 | 2437 | if (index == ', $k, ') |
2336 | 2438 | document.getElementById(\'warn_body\').value = "', strtr($type['body'], array('"' => "'", "\n" => '\\n', "\r" => '')), '";'; |
2439 | + } |
|
2337 | 2440 | |
2338 | 2441 | echo ' |
2339 | 2442 | } |
@@ -2343,10 +2446,11 @@ discard block |
||
2343 | 2446 | // Also set the right effect. |
2344 | 2447 | effectText = "";'; |
2345 | 2448 | |
2346 | - foreach ($context['level_effects'] as $limit => $text) |
|
2347 | - echo ' |
|
2449 | + foreach ($context['level_effects'] as $limit => $text) { |
|
2450 | + echo ' |
|
2348 | 2451 | if (slideAmount >= ', $limit, ') |
2349 | 2452 | effectText = "', $text, '";'; |
2453 | + } |
|
2350 | 2454 | |
2351 | 2455 | echo ' |
2352 | 2456 | setInnerHTML(document.getElementById(\'cur_level_div\'), slideAmount + \'% (\' + effectText + \')\'); |
@@ -2361,32 +2465,35 @@ discard block |
||
2361 | 2465 | </h3> |
2362 | 2466 | </div>'; |
2363 | 2467 | |
2364 | - if (!$context['user']['is_owner']) |
|
2365 | - echo ' |
|
2468 | + if (!$context['user']['is_owner']) { |
|
2469 | + echo ' |
|
2366 | 2470 | <p class="information">', $txt['profile_warning_desc'], '</p>'; |
2471 | + } |
|
2367 | 2472 | |
2368 | 2473 | echo ' |
2369 | 2474 | <div class="windowbg"> |
2370 | 2475 | <dl class="settings">'; |
2371 | 2476 | |
2372 | - if (!$context['user']['is_owner']) |
|
2373 | - echo ' |
|
2477 | + if (!$context['user']['is_owner']) { |
|
2478 | + echo ' |
|
2374 | 2479 | <dt> |
2375 | 2480 | <strong>', $txt['profile_warning_name'], ':</strong> |
2376 | 2481 | </dt> |
2377 | 2482 | <dd> |
2378 | 2483 | <strong>', $context['member']['name'], '</strong> |
2379 | 2484 | </dd>'; |
2485 | + } |
|
2380 | 2486 | |
2381 | 2487 | echo ' |
2382 | 2488 | <dt> |
2383 | 2489 | <strong>', $txt['profile_warning_level'], ':</strong>'; |
2384 | 2490 | |
2385 | 2491 | // Is there only so much they can apply? |
2386 | - if ($context['warning_limit']) |
|
2387 | - echo ' |
|
2492 | + if ($context['warning_limit']) { |
|
2493 | + echo ' |
|
2388 | 2494 | <br> |
2389 | 2495 | <span class="smalltext">', sprintf($txt['profile_warning_limit_attribute'], $context['warning_limit']), '</span>'; |
2496 | + } |
|
2390 | 2497 | |
2391 | 2498 | echo ' |
2392 | 2499 | </dt> |
@@ -2441,9 +2548,10 @@ discard block |
||
2441 | 2548 | <option value="-1">', $txt['profile_warning_notify_template'], '</option> |
2442 | 2549 | <option value="-1" disabled>------------------------------</option>'; |
2443 | 2550 | |
2444 | - foreach ($context['notification_templates'] as $id_template => $template) |
|
2445 | - echo ' |
|
2551 | + foreach ($context['notification_templates'] as $id_template => $template) { |
|
2552 | + echo ' |
|
2446 | 2553 | <option value="', $id_template, '">', $template['title'], '</option>'; |
2554 | + } |
|
2447 | 2555 | |
2448 | 2556 | echo ' |
2449 | 2557 | </select> |
@@ -2456,9 +2564,10 @@ discard block |
||
2456 | 2564 | </dl> |
2457 | 2565 | <div class="righttext">'; |
2458 | 2566 | |
2459 | - if (!empty($context['token_check'])) |
|
2460 | - echo ' |
|
2567 | + if (!empty($context['token_check'])) { |
|
2568 | + echo ' |
|
2461 | 2569 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
2570 | + } |
|
2462 | 2571 | |
2463 | 2572 | echo ' |
2464 | 2573 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -2474,8 +2583,8 @@ discard block |
||
2474 | 2583 | echo ' |
2475 | 2584 | <script>'; |
2476 | 2585 | |
2477 | - if (!$context['user']['is_owner']) |
|
2478 | - echo ' |
|
2586 | + if (!$context['user']['is_owner']) { |
|
2587 | + echo ' |
|
2479 | 2588 | modifyWarnNotify(); |
2480 | 2589 | $(document).ready(function() { |
2481 | 2590 | $("#preview_button").click(function() { |
@@ -2514,6 +2623,7 @@ discard block |
||
2514 | 2623 | }); |
2515 | 2624 | return false; |
2516 | 2625 | }'; |
2626 | + } |
|
2517 | 2627 | |
2518 | 2628 | echo ' |
2519 | 2629 | </script>'; |
@@ -2536,17 +2646,19 @@ discard block |
||
2536 | 2646 | </div>'; |
2537 | 2647 | |
2538 | 2648 | // If deleting another account give them a lovely info box. |
2539 | - if (!$context['user']['is_owner']) |
|
2540 | - echo ' |
|
2649 | + if (!$context['user']['is_owner']) { |
|
2650 | + echo ' |
|
2541 | 2651 | <p class="information">', $txt['deleteAccount_desc'], '</p>'; |
2652 | + } |
|
2542 | 2653 | |
2543 | 2654 | echo ' |
2544 | 2655 | <div class="windowbg">'; |
2545 | 2656 | |
2546 | 2657 | // If they are deleting their account AND the admin needs to approve it - give them another piece of info ;) |
2547 | - if ($context['needs_approval']) |
|
2548 | - echo ' |
|
2658 | + if ($context['needs_approval']) { |
|
2659 | + echo ' |
|
2549 | 2660 | <div class="errorbox">', $txt['deleteAccount_approval'], '</div>'; |
2661 | + } |
|
2550 | 2662 | |
2551 | 2663 | // If the user is deleting their own account warn them first - and require a password! |
2552 | 2664 | if ($context['user']['is_owner']) |
@@ -2558,9 +2670,10 @@ discard block |
||
2558 | 2670 | <input type="password" name="oldpasswrd" size="20"> |
2559 | 2671 | <input type="submit" value="', $txt['yes'], '" class="button">'; |
2560 | 2672 | |
2561 | - if (!empty($context['token_check'])) |
|
2562 | - echo ' |
|
2673 | + if (!empty($context['token_check'])) { |
|
2674 | + echo ' |
|
2563 | 2675 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
2676 | + } |
|
2564 | 2677 | |
2565 | 2678 | echo ' |
2566 | 2679 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -2590,10 +2703,11 @@ discard block |
||
2590 | 2703 | <option value="topics">', $txt['deleteAccount_topics'], '</option> |
2591 | 2704 | </select>'; |
2592 | 2705 | |
2593 | - if ($context['show_perma_delete']) |
|
2594 | - echo ' |
|
2706 | + if ($context['show_perma_delete']) { |
|
2707 | + echo ' |
|
2595 | 2708 | <br> |
2596 | 2709 | <label for="perma_delete"><input type="checkbox" name="perma_delete" id="perma_delete" value="1">', $txt['deleteAccount_permanent'], ':</label>'; |
2710 | + } |
|
2597 | 2711 | |
2598 | 2712 | echo ' |
2599 | 2713 | </div>'; |
@@ -2606,9 +2720,10 @@ discard block |
||
2606 | 2720 | <div> |
2607 | 2721 | <input type="submit" value="', $txt['delete'], '" class="button">'; |
2608 | 2722 | |
2609 | - if (!empty($context['token_check'])) |
|
2610 | - echo ' |
|
2723 | + if (!empty($context['token_check'])) { |
|
2724 | + echo ' |
|
2611 | 2725 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
2726 | + } |
|
2612 | 2727 | |
2613 | 2728 | echo ' |
2614 | 2729 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -2634,8 +2749,8 @@ discard block |
||
2634 | 2749 | <hr>'; |
2635 | 2750 | |
2636 | 2751 | // Only show the password box if it's actually needed. |
2637 | - if ($context['require_password']) |
|
2638 | - echo ' |
|
2752 | + if ($context['require_password']) { |
|
2753 | + echo ' |
|
2639 | 2754 | <dl class="settings"> |
2640 | 2755 | <dt> |
2641 | 2756 | <strong', isset($context['modify_error']['bad_password']) || isset($context['modify_error']['no_password']) ? ' class="error"' : '', '>', $txt['current_password'], ': </strong><br> |
@@ -2645,13 +2760,15 @@ discard block |
||
2645 | 2760 | <input type="password" name="oldpasswrd" size="20"> |
2646 | 2761 | </dd> |
2647 | 2762 | </dl>'; |
2763 | + } |
|
2648 | 2764 | |
2649 | 2765 | echo ' |
2650 | 2766 | <div class="righttext">'; |
2651 | 2767 | |
2652 | - if (!empty($context['token_check'])) |
|
2653 | - echo ' |
|
2768 | + if (!empty($context['token_check'])) { |
|
2769 | + echo ' |
|
2654 | 2770 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
2771 | + } |
|
2655 | 2772 | |
2656 | 2773 | echo ' |
2657 | 2774 | <input type="submit" value="', $txt['change_profile'], '" class="button"> |
@@ -2678,9 +2795,10 @@ discard block |
||
2678 | 2795 | <ul id="list_errors">'; |
2679 | 2796 | |
2680 | 2797 | // Cycle through each error and display an error message. |
2681 | - foreach ($context['post_errors'] as $error) |
|
2682 | - echo ' |
|
2798 | + foreach ($context['post_errors'] as $error) { |
|
2799 | + echo ' |
|
2683 | 2800 | <li>', isset($txt['profile_error_' . $error]) ? $txt['profile_error_' . $error] : $error, '</li>'; |
2801 | + } |
|
2684 | 2802 | |
2685 | 2803 | echo ' |
2686 | 2804 | </ul>'; |
@@ -2706,12 +2824,13 @@ discard block |
||
2706 | 2824 | <select name="id_group" ', ($context['user']['is_owner'] && $context['member']['group_id'] == 1 ? 'onchange="if (this.value != 1 && !confirm(\'' . $txt['deadmin_confirm'] . '\')) this.value = 1;"' : ''), '>'; |
2707 | 2825 | |
2708 | 2826 | // Fill the select box with all primary member groups that can be assigned to a member. |
2709 | - foreach ($context['member_groups'] as $member_group) |
|
2710 | - if (!empty($member_group['can_be_primary'])) |
|
2827 | + foreach ($context['member_groups'] as $member_group) { |
|
2828 | + if (!empty($member_group['can_be_primary'])) |
|
2711 | 2829 | echo ' |
2712 | 2830 | <option value="', $member_group['id'], '"', $member_group['is_primary'] ? ' selected' : '', '> |
2713 | 2831 | ', $member_group['name'], ' |
2714 | 2832 | </option>'; |
2833 | + } |
|
2715 | 2834 | |
2716 | 2835 | echo ' |
2717 | 2836 | </select> |
@@ -2724,10 +2843,11 @@ discard block |
||
2724 | 2843 | <input type="hidden" name="additional_groups[]" value="0">'; |
2725 | 2844 | |
2726 | 2845 | // For each membergroup show a checkbox so members can be assigned to more than one group. |
2727 | - foreach ($context['member_groups'] as $member_group) |
|
2728 | - if ($member_group['can_be_additional']) |
|
2846 | + foreach ($context['member_groups'] as $member_group) { |
|
2847 | + if ($member_group['can_be_additional']) |
|
2729 | 2848 | echo ' |
2730 | 2849 | <label for="additional_groups-', $member_group['id'], '"><input type="checkbox" name="additional_groups[]" value="', $member_group['id'], '" id="additional_groups-', $member_group['id'], '"', $member_group['is_additional'] ? ' checked' : '', '> ', $member_group['name'], '</label><br>'; |
2850 | + } |
|
2731 | 2851 | |
2732 | 2852 | echo ' |
2733 | 2853 | </span> |
@@ -2787,9 +2907,10 @@ discard block |
||
2787 | 2907 | <span class="smalltext">', $txt['sig_info'], '</span><br> |
2788 | 2908 | <br>'; |
2789 | 2909 | |
2790 | - if ($context['show_spellchecking']) |
|
2791 | - echo ' |
|
2910 | + if ($context['show_spellchecking']) { |
|
2911 | + echo ' |
|
2792 | 2912 | <input type="button" value="', $txt['spell_check'], '" onclick="spellCheck(\'creator\', \'signature\');" class="button">'; |
2913 | + } |
|
2793 | 2914 | |
2794 | 2915 | echo ' |
2795 | 2916 | </dt> |
@@ -2797,17 +2918,20 @@ discard block |
||
2797 | 2918 | <textarea class="editor" onkeyup="calcCharLeft();" id="signature" name="signature" rows="5" cols="50">', $context['member']['signature'], '</textarea><br>'; |
2798 | 2919 | |
2799 | 2920 | // If there is a limit at all! |
2800 | - if (!empty($context['signature_limits']['max_length'])) |
|
2801 | - echo ' |
|
2921 | + if (!empty($context['signature_limits']['max_length'])) { |
|
2922 | + echo ' |
|
2802 | 2923 | <span class="smalltext">', sprintf($txt['max_sig_characters'], $context['signature_limits']['max_length']), ' <span id="signatureLeft">', $context['signature_limits']['max_length'], '</span></span><br>'; |
2924 | + } |
|
2803 | 2925 | |
2804 | - if (!empty($context['show_preview_button'])) |
|
2805 | - echo ' |
|
2926 | + if (!empty($context['show_preview_button'])) { |
|
2927 | + echo ' |
|
2806 | 2928 | <input type="button" name="preview_signature" id="preview_button" value="', $txt['preview_signature'], '" class="button floatright">'; |
2929 | + } |
|
2807 | 2930 | |
2808 | - if ($context['signature_warning']) |
|
2809 | - echo ' |
|
2931 | + if ($context['signature_warning']) { |
|
2932 | + echo ' |
|
2810 | 2933 | <span class="smalltext">', $context['signature_warning'], '</span>'; |
2934 | + } |
|
2811 | 2935 | |
2812 | 2936 | // Some javascript used to count how many characters have been used so far in the signature. |
2813 | 2937 | echo ' |
@@ -2838,38 +2962,43 @@ discard block |
||
2838 | 2962 | <label for="avatar_upload_box">', $txt['personal_picture'], '</label> |
2839 | 2963 | </strong>'; |
2840 | 2964 | |
2841 | - if (empty($modSettings['gravatarOverride'])) |
|
2842 | - echo ' |
|
2965 | + if (empty($modSettings['gravatarOverride'])) { |
|
2966 | + echo ' |
|
2843 | 2967 | <input type="radio" onclick="swap_avatar(this); return true;" name="avatar_choice" id="avatar_choice_none" value="none"' . ($context['member']['avatar']['choice'] == 'none' ? ' checked="checked"' : '') . '> |
2844 | 2968 | <label for="avatar_choice_none"' . (isset($context['modify_error']['bad_avatar']) ? ' class="error"' : '') . '> |
2845 | 2969 | ' . $txt['no_avatar'] . ' |
2846 | 2970 | </label><br>'; |
2971 | + } |
|
2847 | 2972 | |
2848 | - if (!empty($context['member']['avatar']['allow_server_stored'])) |
|
2849 | - echo ' |
|
2973 | + if (!empty($context['member']['avatar']['allow_server_stored'])) { |
|
2974 | + echo ' |
|
2850 | 2975 | <input type="radio" onclick="swap_avatar(this); return true;" name="avatar_choice" id="avatar_choice_server_stored" value="server_stored"' . ($context['member']['avatar']['choice'] == 'server_stored' ? ' checked="checked"' : '') . '> |
2851 | 2976 | <label for="avatar_choice_server_stored"' . (isset($context['modify_error']['bad_avatar']) ? ' class="error"' : '') . '> |
2852 | 2977 | ', $txt['choose_avatar_gallery'], ' |
2853 | 2978 | </label><br>'; |
2979 | + } |
|
2854 | 2980 | |
2855 | - if (!empty($context['member']['avatar']['allow_external'])) |
|
2856 | - echo ' |
|
2981 | + if (!empty($context['member']['avatar']['allow_external'])) { |
|
2982 | + echo ' |
|
2857 | 2983 | <input type="radio" onclick="swap_avatar(this); return true;" name="avatar_choice" id="avatar_choice_external" value="external"' . ($context['member']['avatar']['choice'] == 'external' ? ' checked="checked"' : '') . '> |
2858 | 2984 | <label for="avatar_choice_external"' . (isset($context['modify_error']['bad_avatar']) ? ' class="error"' : '') . '> |
2859 | 2985 | ', $txt['my_own_pic'], ' |
2860 | 2986 | </label><br>'; |
2987 | + } |
|
2861 | 2988 | |
2862 | - if (!empty($context['member']['avatar']['allow_upload'])) |
|
2863 | - echo ' |
|
2989 | + if (!empty($context['member']['avatar']['allow_upload'])) { |
|
2990 | + echo ' |
|
2864 | 2991 | <input type="radio" onclick="swap_avatar(this); return true;" name="avatar_choice" id="avatar_choice_upload" value="upload"' . ($context['member']['avatar']['choice'] == 'upload' ? ' checked="checked"' : '') . '> |
2865 | 2992 | <label for="avatar_choice_upload"' . (isset($context['modify_error']['bad_avatar']) ? ' class="error"' : '') . '> |
2866 | 2993 | ', $txt['avatar_will_upload'], ' |
2867 | 2994 | </label><br>'; |
2995 | + } |
|
2868 | 2996 | |
2869 | - if (!empty($context['member']['avatar']['allow_gravatar'])) |
|
2870 | - echo ' |
|
2997 | + if (!empty($context['member']['avatar']['allow_gravatar'])) { |
|
2998 | + echo ' |
|
2871 | 2999 | <input type="radio" onclick="swap_avatar(this); return true;" name="avatar_choice" id="avatar_choice_gravatar" value="gravatar"' . ($context['member']['avatar']['choice'] == 'gravatar' ? ' checked="checked"' : '') . '> |
2872 | 3000 | <label for="avatar_choice_gravatar"' . (isset($context['modify_error']['bad_avatar']) ? ' class="error"' : '') . '>' . $txt['use_gravatar'] . '</label>'; |
3001 | + } |
|
2873 | 3002 | |
2874 | 3003 | echo ' |
2875 | 3004 | </dt> |
@@ -2884,9 +3013,10 @@ discard block |
||
2884 | 3013 | <select name="cat" id="cat" size="10" onchange="changeSel(\'\');" onfocus="selectRadioByName(document.forms.creator.avatar_choice, \'server_stored\');">'; |
2885 | 3014 | |
2886 | 3015 | // This lists all the file categories. |
2887 | - foreach ($context['avatars'] as $avatar) |
|
2888 | - echo ' |
|
3016 | + foreach ($context['avatars'] as $avatar) { |
|
3017 | + echo ' |
|
2889 | 3018 | <option value="', $avatar['filename'] . ($avatar['is_dir'] ? '/' : ''), '"', ($avatar['checked'] ? ' selected' : ''), '>', $avatar['name'], '</option>'; |
3019 | + } |
|
2890 | 3020 | |
2891 | 3021 | echo ' |
2892 | 3022 | </select> |
@@ -2918,20 +3048,22 @@ discard block |
||
2918 | 3048 | } |
2919 | 3049 | |
2920 | 3050 | // If the user can link to an off server avatar, show them a box to input the address. |
2921 | - if (!empty($context['member']['avatar']['allow_external'])) |
|
2922 | - echo ' |
|
3051 | + if (!empty($context['member']['avatar']['allow_external'])) { |
|
3052 | + echo ' |
|
2923 | 3053 | <div id="avatar_external"> |
2924 | 3054 | <div class="smalltext">', $txt['avatar_by_url'], '</div>', !empty($modSettings['avatar_action_too_large']) && $modSettings['avatar_action_too_large'] == 'option_download_and_resize' ? template_max_size('external') : '', ' |
2925 | 3055 | <input type="text" name="userpicpersonal" size="45" value="', ((stristr($context['member']['avatar']['external'], 'http://') || stristr($context['member']['avatar']['external'], 'https://')) ? $context['member']['avatar']['external'] : 'http://'), '" onfocus="selectRadioByName(document.forms.creator.avatar_choice, \'external\');" onchange="if (typeof(previewExternalAvatar) != \'undefined\') previewExternalAvatar(this.value);"> |
2926 | 3056 | </div>'; |
3057 | + } |
|
2927 | 3058 | |
2928 | 3059 | // If the user is able to upload avatars to the server show them an upload box. |
2929 | - if (!empty($context['member']['avatar']['allow_upload'])) |
|
2930 | - echo ' |
|
3060 | + if (!empty($context['member']['avatar']['allow_upload'])) { |
|
3061 | + echo ' |
|
2931 | 3062 | <div id="avatar_upload"> |
2932 | 3063 | <input type="file" size="44" name="attachment" id="avatar_upload_box" value="" onchange="readfromUpload(this)" onfocus="selectRadioByName(document.forms.creator.avatar_choice, \'upload\');" accept="image/gif, image/jpeg, image/jpg, image/png">', template_max_size('upload'), ' |
2933 | 3064 | ', (!empty($context['member']['avatar']['id_attach']) ? '<br><img src="' . $context['member']['avatar']['href'] . (strpos($context['member']['avatar']['href'], '?') === false ? '?' : '&') . 'time=' . time() . '" alt="" id="attached_image"><input type="hidden" name="id_attach" value="' . $context['member']['avatar']['id_attach'] . '">' : ''), ' |
2934 | 3065 | </div>'; |
3066 | + } |
|
2935 | 3067 | |
2936 | 3068 | // if the user is able to use Gravatar avatars show then the image preview |
2937 | 3069 | if (!empty($context['member']['avatar']['allow_gravatar'])) |
@@ -2940,16 +3072,17 @@ discard block |
||
2940 | 3072 | <div id="avatar_gravatar"> |
2941 | 3073 | <img src="' . $context['member']['avatar']['href'] . '" alt="">'; |
2942 | 3074 | |
2943 | - if (empty($modSettings['gravatarAllowExtraEmail'])) |
|
2944 | - echo ' |
|
3075 | + if (empty($modSettings['gravatarAllowExtraEmail'])) { |
|
3076 | + echo ' |
|
2945 | 3077 | <div class="smalltext">', $txt['gravatar_noAlternateEmail'], '</div>'; |
2946 | - else |
|
3078 | + } else |
|
2947 | 3079 | { |
2948 | 3080 | // Depending on other stuff, the stored value here might have some odd things in it from other areas. |
2949 | - if ($context['member']['avatar']['external'] == $context['member']['email']) |
|
2950 | - $textbox_value = ''; |
|
2951 | - else |
|
2952 | - $textbox_value = $context['member']['avatar']['external']; |
|
3081 | + if ($context['member']['avatar']['external'] == $context['member']['email']) { |
|
3082 | + $textbox_value = ''; |
|
3083 | + } else { |
|
3084 | + $textbox_value = $context['member']['avatar']['external']; |
|
3085 | + } |
|
2953 | 3086 | |
2954 | 3087 | echo ' |
2955 | 3088 | <div class="smalltext">', $txt['gravatar_alternateEmail'], '</div> |
@@ -3021,8 +3154,9 @@ discard block |
||
3021 | 3154 | $h = !empty($modSettings['avatar_max_height_' . $type]) ? comma_format($modSettings['avatar_max_height_' . $type]) : 0; |
3022 | 3155 | |
3023 | 3156 | $suffix = (!empty($w) ? 'w' : '') . (!empty($h) ? 'h' : ''); |
3024 | - if (empty($suffix)) |
|
3025 | - return; |
|
3157 | + if (empty($suffix)) { |
|
3158 | + return; |
|
3159 | + } |
|
3026 | 3160 | |
3027 | 3161 | echo ' |
3028 | 3162 | <div class="smalltext">', sprintf($txt['avatar_max_size_' . $suffix], $w, $h), '</div>'; |
@@ -3047,9 +3181,10 @@ discard block |
||
3047 | 3181 | <select name="easyformat" id="easyformat" onchange="document.forms.creator.time_format.value = this.options[this.selectedIndex].value;">'; |
3048 | 3182 | |
3049 | 3183 | // Help the user by showing a list of common time formats. |
3050 | - foreach ($context['easy_timeformats'] as $time_format) |
|
3051 | - echo ' |
|
3184 | + foreach ($context['easy_timeformats'] as $time_format) { |
|
3185 | + echo ' |
|
3052 | 3186 | <option value="', $time_format['format'], '"', $time_format['format'] == $context['member']['time_format'] ? ' selected' : '', '>', $time_format['title'], '</option>'; |
3187 | + } |
|
3053 | 3188 | |
3054 | 3189 | echo ' |
3055 | 3190 | </select> |
@@ -3087,9 +3222,10 @@ discard block |
||
3087 | 3222 | <dd> |
3088 | 3223 | <select name="smiley_set" id="smiley_set">'; |
3089 | 3224 | |
3090 | - foreach ($context['smiley_sets'] as $set) |
|
3091 | - echo ' |
|
3225 | + foreach ($context['smiley_sets'] as $set) { |
|
3226 | + echo ' |
|
3092 | 3227 | <option value="', $set['id'], '"', $set['selected'] ? ' selected' : '', '>', $set['name'], '</option>'; |
3228 | + } |
|
3093 | 3229 | |
3094 | 3230 | echo ' |
3095 | 3231 | </select> |
@@ -3111,17 +3247,17 @@ discard block |
||
3111 | 3247 | <div class="roundframe"> |
3112 | 3248 | <div>'; |
3113 | 3249 | |
3114 | - if (!empty($context['tfa_backup'])) |
|
3115 | - echo ' |
|
3250 | + if (!empty($context['tfa_backup'])) { |
|
3251 | + echo ' |
|
3116 | 3252 | <div class="smalltext error"> |
3117 | 3253 | ', $txt['tfa_backup_used_desc'], ' |
3118 | 3254 | </div>'; |
3119 | - |
|
3120 | - elseif ($modSettings['tfa_mode'] == 2) |
|
3121 | - echo ' |
|
3255 | + } elseif ($modSettings['tfa_mode'] == 2) { |
|
3256 | + echo ' |
|
3122 | 3257 | <div class="smalltext"> |
3123 | 3258 | <strong>', $txt['tfa_forced_desc'], '</strong> |
3124 | 3259 | </div>'; |
3260 | + } |
|
3125 | 3261 | |
3126 | 3262 | echo ' |
3127 | 3263 | <div class="smalltext"> |
@@ -3132,11 +3268,12 @@ discard block |
||
3132 | 3268 | <div class="block"> |
3133 | 3269 | <strong>', $txt['tfa_step1'], '</strong><br>'; |
3134 | 3270 | |
3135 | - if (!empty($context['tfa_pass_error'])) |
|
3136 | - echo ' |
|
3271 | + if (!empty($context['tfa_pass_error'])) { |
|
3272 | + echo ' |
|
3137 | 3273 | <div class="error smalltext"> |
3138 | 3274 | ', $txt['tfa_pass_invalid'], ' |
3139 | 3275 | </div>'; |
3276 | + } |
|
3140 | 3277 | |
3141 | 3278 | echo ' |
3142 | 3279 | <input type="password" name="passwd" size="25"', !empty($context['tfa_pass_error']) ? ' class="error"' : '', !empty($context['tfa_pass_value']) ? ' value="' . $context['tfa_pass_value'] . '"' : '', '> |
@@ -3149,11 +3286,12 @@ discard block |
||
3149 | 3286 | <div class="block"> |
3150 | 3287 | <strong>', $txt['tfa_step3'], '</strong><br>'; |
3151 | 3288 | |
3152 | - if (!empty($context['tfa_error'])) |
|
3153 | - echo ' |
|
3289 | + if (!empty($context['tfa_error'])) { |
|
3290 | + echo ' |
|
3154 | 3291 | <div class="error smalltext"> |
3155 | 3292 | ', $txt['tfa_code_invalid'], ' |
3156 | 3293 | </div>'; |
3294 | + } |
|
3157 | 3295 | |
3158 | 3296 | echo ' |
3159 | 3297 | <input type="text" name="tfa_code" size="25"', !empty($context['tfa_error']) ? ' class="error"' : '', !empty($context['tfa_value']) ? ' value="' . $context['tfa_value'] . '"' : '', '> |
@@ -3167,10 +3305,11 @@ discard block |
||
3167 | 3305 | <img src="', $context['tfa_qr_url'], '" alt=""> |
3168 | 3306 | </div>'; |
3169 | 3307 | |
3170 | - if (!empty($context['from_ajax'])) |
|
3171 | - echo ' |
|
3308 | + if (!empty($context['from_ajax'])) { |
|
3309 | + echo ' |
|
3172 | 3310 | <br> |
3173 | 3311 | <a href="javascript:self.close();"></a>'; |
3312 | + } |
|
3174 | 3313 | |
3175 | 3314 | echo ' |
3176 | 3315 | </div> |
@@ -3210,17 +3349,16 @@ discard block |
||
3210 | 3349 | </dt> |
3211 | 3350 | <dd>'; |
3212 | 3351 | |
3213 | - if (!$context['tfa_enabled'] && $context['user']['is_owner']) |
|
3214 | - echo ' |
|
3352 | + if (!$context['tfa_enabled'] && $context['user']['is_owner']) { |
|
3353 | + echo ' |
|
3215 | 3354 | <a href="', !empty($modSettings['force_ssl']) ? strtr($scripturl, array('http://' => 'https://')) : $scripturl, '?action=profile;area=tfasetup" id="enable_tfa">', $txt['tfa_profile_enable'], '</a>'; |
3216 | - |
|
3217 | - elseif (!$context['tfa_enabled']) |
|
3218 | - echo ' |
|
3355 | + } elseif (!$context['tfa_enabled']) { |
|
3356 | + echo ' |
|
3219 | 3357 | ', $txt['tfa_profile_disabled']; |
3220 | - |
|
3221 | - else |
|
3222 | - echo ' |
|
3358 | + } else { |
|
3359 | + echo ' |
|
3223 | 3360 | ', sprintf($txt['tfa_profile_enabled'], $scripturl . '?action=profile;u=' . $context['id_member'] . ';area=tfasetup;disable'); |
3361 | + } |
|
3224 | 3362 | |
3225 | 3363 | echo ' |
3226 | 3364 | </dd>'; |