@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 3 |
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 = ''; |
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, &$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,6 +689,7 @@ discard block |
||
655 | 689 | 'selected_board' => $board_id, |
656 | 690 | )) |
657 | 691 | ); |
692 | + } |
|
658 | 693 | |
659 | 694 | // Set moderators of this board. |
660 | 695 | if (isset($boardOptions['moderators']) || isset($boardOptions['moderator_string']) || isset($boardOptions['moderator_groups']) || isset($boardOptions['moderator_group_string'])) |
@@ -679,13 +714,15 @@ discard block |
||
679 | 714 | { |
680 | 715 | $moderators[$k] = trim($moderators[$k]); |
681 | 716 | |
682 | - if (strlen($moderators[$k]) == 0) |
|
683 | - unset($moderators[$k]); |
|
717 | + if (strlen($moderators[$k]) == 0) { |
|
718 | + unset($moderators[$k]); |
|
719 | + } |
|
684 | 720 | } |
685 | 721 | |
686 | 722 | // Find all the id_member's for the member_name's in the list. |
687 | - if (empty($boardOptions['moderators'])) |
|
688 | - $boardOptions['moderators'] = array(); |
|
723 | + if (empty($boardOptions['moderators'])) { |
|
724 | + $boardOptions['moderators'] = array(); |
|
725 | + } |
|
689 | 726 | if (!empty($moderators)) |
690 | 727 | { |
691 | 728 | $request = $smcFunc['db_query']('', ' |
@@ -698,8 +735,9 @@ discard block |
||
698 | 735 | 'limit' => count($moderators), |
699 | 736 | ) |
700 | 737 | ); |
701 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
702 | - $boardOptions['moderators'][] = $row['id_member']; |
|
738 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
739 | + $boardOptions['moderators'][] = $row['id_member']; |
|
740 | + } |
|
703 | 741 | $smcFunc['db_free_result']($request); |
704 | 742 | } |
705 | 743 | } |
@@ -708,8 +746,9 @@ discard block |
||
708 | 746 | if (!empty($boardOptions['moderators'])) |
709 | 747 | { |
710 | 748 | $inserts = array(); |
711 | - foreach ($boardOptions['moderators'] as $moderator) |
|
712 | - $inserts[] = array($board_id, $moderator); |
|
749 | + foreach ($boardOptions['moderators'] as $moderator) { |
|
750 | + $inserts[] = array($board_id, $moderator); |
|
751 | + } |
|
713 | 752 | |
714 | 753 | $smcFunc['db_insert']('insert', |
715 | 754 | '{db_prefix}moderators', |
@@ -739,14 +778,16 @@ discard block |
||
739 | 778 | { |
740 | 779 | $moderator_groups[$k] = trim($moderator_groups[$k]); |
741 | 780 | |
742 | - if (strlen($moderator_groups[$k]) == 0) |
|
743 | - unset($moderator_groups[$k]); |
|
781 | + if (strlen($moderator_groups[$k]) == 0) { |
|
782 | + unset($moderator_groups[$k]); |
|
783 | + } |
|
744 | 784 | } |
745 | 785 | |
746 | 786 | /* Find all the id_group's for all the group names in the list |
747 | 787 | But skip any invalid ones (invisible/post groups/Administrator/Moderator) */ |
748 | - if (empty($boardOptions['moderator_groups'])) |
|
749 | - $boardOptions['moderator_groups'] = array(); |
|
788 | + if (empty($boardOptions['moderator_groups'])) { |
|
789 | + $boardOptions['moderator_groups'] = array(); |
|
790 | + } |
|
750 | 791 | if (!empty($moderator_groups)) |
751 | 792 | { |
752 | 793 | $request = $smcFunc['db_query']('', ' |
@@ -777,8 +818,9 @@ discard block |
||
777 | 818 | if (!empty($boardOptions['moderator_groups'])) |
778 | 819 | { |
779 | 820 | $inserts = array(); |
780 | - foreach ($boardOptions['moderator_groups'] as $moderator_group) |
|
781 | - $inserts[] = array($board_id, $moderator_group); |
|
821 | + foreach ($boardOptions['moderator_groups'] as $moderator_group) { |
|
822 | + $inserts[] = array($board_id, $moderator_group); |
|
823 | + } |
|
782 | 824 | |
783 | 825 | $smcFunc['db_insert']('insert', |
784 | 826 | '{db_prefix}moderator_groups', |
@@ -792,14 +834,16 @@ discard block |
||
792 | 834 | updateSettings(array('settings_updated' => time())); |
793 | 835 | } |
794 | 836 | |
795 | - if (isset($boardOptions['move_to'])) |
|
796 | - reorderBoards(); |
|
837 | + if (isset($boardOptions['move_to'])) { |
|
838 | + reorderBoards(); |
|
839 | + } |
|
797 | 840 | |
798 | 841 | clean_cache('data'); |
799 | 842 | |
800 | - if (empty($boardOptions['dont_log'])) |
|
801 | - logAction('edit_board', array('board' => $board_id), 'admin'); |
|
802 | -} |
|
843 | + if (empty($boardOptions['dont_log'])) { |
|
844 | + logAction('edit_board', array('board' => $board_id), 'admin'); |
|
845 | + } |
|
846 | + } |
|
803 | 847 | |
804 | 848 | /** |
805 | 849 | * Create a new board and set its properties and position. |
@@ -815,11 +859,13 @@ discard block |
||
815 | 859 | global $boards, $smcFunc; |
816 | 860 | |
817 | 861 | // Trigger an error if one of the required values is not set. |
818 | - if (!isset($boardOptions['board_name']) || trim($boardOptions['board_name']) == '' || !isset($boardOptions['move_to']) || !isset($boardOptions['target_category'])) |
|
819 | - trigger_error('createBoard(): One or more of the required options is not set', E_USER_ERROR); |
|
862 | + if (!isset($boardOptions['board_name']) || trim($boardOptions['board_name']) == '' || !isset($boardOptions['move_to']) || !isset($boardOptions['target_category'])) { |
|
863 | + trigger_error('createBoard(): One or more of the required options is not set', E_USER_ERROR); |
|
864 | + } |
|
820 | 865 | |
821 | - if (in_array($boardOptions['move_to'], array('child', 'before', 'after')) && !isset($boardOptions['target_board'])) |
|
822 | - trigger_error('createBoard(): Target board is not set', E_USER_ERROR); |
|
866 | + if (in_array($boardOptions['move_to'], array('child', 'before', 'after')) && !isset($boardOptions['target_board'])) { |
|
867 | + trigger_error('createBoard(): Target board is not set', E_USER_ERROR); |
|
868 | + } |
|
823 | 869 | |
824 | 870 | // Set every optional value to its default value. |
825 | 871 | $boardOptions += array( |
@@ -853,8 +899,9 @@ discard block |
||
853 | 899 | 1 |
854 | 900 | ); |
855 | 901 | |
856 | - if (empty($board_id)) |
|
857 | - return 0; |
|
902 | + if (empty($board_id)) { |
|
903 | + return 0; |
|
904 | + } |
|
858 | 905 | |
859 | 906 | // Change the board according to the given specifications. |
860 | 907 | modifyBoard($board_id, $boardOptions); |
@@ -917,8 +964,9 @@ discard block |
||
917 | 964 | global $sourcedir, $boards, $smcFunc; |
918 | 965 | |
919 | 966 | // No boards to delete? Return! |
920 | - if (empty($boards_to_remove)) |
|
921 | - return; |
|
967 | + if (empty($boards_to_remove)) { |
|
968 | + return; |
|
969 | + } |
|
922 | 970 | |
923 | 971 | getBoardTree(); |
924 | 972 | |
@@ -929,12 +977,14 @@ discard block |
||
929 | 977 | { |
930 | 978 | // Get a list of the child boards that will also be removed. |
931 | 979 | $child_boards_to_remove = array(); |
932 | - foreach ($boards_to_remove as $board_to_remove) |
|
933 | - recursiveBoards($child_boards_to_remove, $boards[$board_to_remove]['tree']); |
|
980 | + foreach ($boards_to_remove as $board_to_remove) { |
|
981 | + recursiveBoards($child_boards_to_remove, $boards[$board_to_remove]['tree']); |
|
982 | + } |
|
934 | 983 | |
935 | 984 | // Merge the children with their parents. |
936 | - if (!empty($child_boards_to_remove)) |
|
937 | - $boards_to_remove = array_unique(array_merge($boards_to_remove, $child_boards_to_remove)); |
|
985 | + if (!empty($child_boards_to_remove)) { |
|
986 | + $boards_to_remove = array_unique(array_merge($boards_to_remove, $child_boards_to_remove)); |
|
987 | + } |
|
938 | 988 | } |
939 | 989 | // Move the children to a safe home. |
940 | 990 | else |
@@ -942,10 +992,11 @@ discard block |
||
942 | 992 | foreach ($boards_to_remove as $id_board) |
943 | 993 | { |
944 | 994 | // @todo Separate category? |
945 | - if ($moveChildrenTo === 0) |
|
946 | - fixChildren($id_board, 0, 0); |
|
947 | - else |
|
948 | - fixChildren($id_board, $boards[$moveChildrenTo]['level'] + 1, $moveChildrenTo); |
|
995 | + if ($moveChildrenTo === 0) { |
|
996 | + fixChildren($id_board, 0, 0); |
|
997 | + } else { |
|
998 | + fixChildren($id_board, $boards[$moveChildrenTo]['level'] + 1, $moveChildrenTo); |
|
999 | + } |
|
949 | 1000 | } |
950 | 1001 | } |
951 | 1002 | |
@@ -959,8 +1010,9 @@ discard block |
||
959 | 1010 | ) |
960 | 1011 | ); |
961 | 1012 | $topics = array(); |
962 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
963 | - $topics[] = $row['id_topic']; |
|
1013 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1014 | + $topics[] = $row['id_topic']; |
|
1015 | + } |
|
964 | 1016 | $smcFunc['db_free_result']($request); |
965 | 1017 | |
966 | 1018 | require_once($sourcedir . '/RemoveTopic.php'); |
@@ -1048,8 +1100,9 @@ discard block |
||
1048 | 1100 | clean_cache('data'); |
1049 | 1101 | |
1050 | 1102 | // Let's do some serious logging. |
1051 | - foreach ($boards_to_remove as $id_board) |
|
1052 | - logAction('delete_board', array('boardname' => $boards[$id_board]['name']), 'admin'); |
|
1103 | + foreach ($boards_to_remove as $id_board) { |
|
1104 | + logAction('delete_board', array('boardname' => $boards[$id_board]['name']), 'admin'); |
|
1105 | + } |
|
1053 | 1106 | |
1054 | 1107 | reorderBoards(); |
1055 | 1108 | } |
@@ -1068,8 +1121,8 @@ discard block |
||
1068 | 1121 | $board_order = 0; |
1069 | 1122 | foreach ($cat_tree as $catID => $dummy) |
1070 | 1123 | { |
1071 | - foreach ($boardList[$catID] as $boardID) |
|
1072 | - if ($boards[$boardID]['order'] != ++$board_order) |
|
1124 | + foreach ($boardList[$catID] as $boardID) { |
|
1125 | + if ($boards[$boardID]['order'] != ++$board_order) |
|
1073 | 1126 | $smcFunc['db_query']('', ' |
1074 | 1127 | UPDATE {db_prefix}boards |
1075 | 1128 | SET board_order = {int:new_order} |
@@ -1079,6 +1132,7 @@ discard block |
||
1079 | 1132 | 'selected_board' => $boardID, |
1080 | 1133 | ) |
1081 | 1134 | ); |
1135 | + } |
|
1082 | 1136 | } |
1083 | 1137 | |
1084 | 1138 | // Empty the board order cache |
@@ -1107,8 +1161,9 @@ discard block |
||
1107 | 1161 | ) |
1108 | 1162 | ); |
1109 | 1163 | $children = array(); |
1110 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
1111 | - $children[] = $row['id_board']; |
|
1164 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
1165 | + $children[] = $row['id_board']; |
|
1166 | + } |
|
1112 | 1167 | $smcFunc['db_free_result']($result); |
1113 | 1168 | |
1114 | 1169 | // ...and set it to a new parent and child_level. |
@@ -1124,9 +1179,10 @@ discard block |
||
1124 | 1179 | ); |
1125 | 1180 | |
1126 | 1181 | // Recursively fix the children of the children. |
1127 | - foreach ($children as $child) |
|
1128 | - fixChildren($child, $newLevel + 1, $child); |
|
1129 | -} |
|
1182 | + foreach ($children as $child) { |
|
1183 | + fixChildren($child, $newLevel + 1, $child); |
|
1184 | + } |
|
1185 | + } |
|
1130 | 1186 | |
1131 | 1187 | /** |
1132 | 1188 | * Tries to load up the entire board order and category very very quickly |
@@ -1143,8 +1199,9 @@ discard block |
||
1143 | 1199 | 'boards' => array(), |
1144 | 1200 | ); |
1145 | 1201 | |
1146 | - if (!empty($tree_order['boards'])) |
|
1147 | - return $tree_order; |
|
1202 | + if (!empty($tree_order['boards'])) { |
|
1203 | + return $tree_order; |
|
1204 | + } |
|
1148 | 1205 | |
1149 | 1206 | if (($cached = cache_get_data('board_order', 86400)) !== null) |
1150 | 1207 | { |
@@ -1160,8 +1217,9 @@ discard block |
||
1160 | 1217 | ); |
1161 | 1218 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1162 | 1219 | { |
1163 | - if (!in_array($row['id_cat'], $tree_order['cats'])) |
|
1164 | - $tree_order['cats'][] = $row['id_cat']; |
|
1220 | + if (!in_array($row['id_cat'], $tree_order['cats'])) { |
|
1221 | + $tree_order['cats'][] = $row['id_cat']; |
|
1222 | + } |
|
1165 | 1223 | $tree_order['boards'][] = $row['id_board']; |
1166 | 1224 | } |
1167 | 1225 | $smcFunc['db_free_result']($request); |
@@ -1181,16 +1239,19 @@ discard block |
||
1181 | 1239 | $tree = getTreeOrder(); |
1182 | 1240 | |
1183 | 1241 | $ordered = array(); |
1184 | - foreach ($tree['boards'] as $board) |
|
1185 | - if (!empty($boards[$board])) |
|
1242 | + foreach ($tree['boards'] as $board) { |
|
1243 | + if (!empty($boards[$board])) |
|
1186 | 1244 | { |
1187 | 1245 | $ordered[$board] = $boards[$board]; |
1246 | + } |
|
1188 | 1247 | |
1189 | - if (is_array($ordered[$board]) && !empty($ordered[$board]['boards'])) |
|
1190 | - sortBoards($ordered[$board]['boards']); |
|
1248 | + if (is_array($ordered[$board]) && !empty($ordered[$board]['boards'])) { |
|
1249 | + sortBoards($ordered[$board]['boards']); |
|
1250 | + } |
|
1191 | 1251 | |
1192 | - if (is_array($ordered[$board]) && !empty($ordered[$board]['children'])) |
|
1193 | - sortBoards($ordered[$board]['children']); |
|
1252 | + if (is_array($ordered[$board]) && !empty($ordered[$board]['children'])) { |
|
1253 | + sortBoards($ordered[$board]['children']); |
|
1254 | + } |
|
1194 | 1255 | } |
1195 | 1256 | |
1196 | 1257 | $boards = $ordered; |
@@ -1206,12 +1267,14 @@ discard block |
||
1206 | 1267 | $tree = getTreeOrder(); |
1207 | 1268 | |
1208 | 1269 | $ordered = array(); |
1209 | - foreach ($tree['cats'] as $cat) |
|
1210 | - if (!empty($categories[$cat])) |
|
1270 | + foreach ($tree['cats'] as $cat) { |
|
1271 | + if (!empty($categories[$cat])) |
|
1211 | 1272 | { |
1212 | 1273 | $ordered[$cat] = $categories[$cat]; |
1213 | - if (!empty($ordered[$cat]['boards'])) |
|
1214 | - sortBoards($ordered[$cat]['boards']); |
|
1274 | + } |
|
1275 | + if (!empty($ordered[$cat]['boards'])) { |
|
1276 | + sortBoards($ordered[$cat]['boards']); |
|
1277 | + } |
|
1215 | 1278 | } |
1216 | 1279 | |
1217 | 1280 | $categories = $ordered; |
@@ -1227,8 +1290,9 @@ discard block |
||
1227 | 1290 | { |
1228 | 1291 | global $smcFunc, $scripturl, $txt; |
1229 | 1292 | |
1230 | - if (empty($boards)) |
|
1231 | - return array(); |
|
1293 | + if (empty($boards)) { |
|
1294 | + return array(); |
|
1295 | + } |
|
1232 | 1296 | |
1233 | 1297 | $request = $smcFunc['db_query']('', ' |
1234 | 1298 | SELECT mem.id_member, mem.real_name, mo.id_board |
@@ -1242,8 +1306,9 @@ discard block |
||
1242 | 1306 | $moderators = array(); |
1243 | 1307 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1244 | 1308 | { |
1245 | - if (empty($moderators[$row['id_board']])) |
|
1246 | - $moderators[$row['id_board']] = array(); |
|
1309 | + if (empty($moderators[$row['id_board']])) { |
|
1310 | + $moderators[$row['id_board']] = array(); |
|
1311 | + } |
|
1247 | 1312 | |
1248 | 1313 | $moderators[$row['id_board']][] = array( |
1249 | 1314 | 'id' => $row['id_member'], |
@@ -1267,8 +1332,9 @@ discard block |
||
1267 | 1332 | { |
1268 | 1333 | global $smcFunc, $scripturl, $txt; |
1269 | 1334 | |
1270 | - if (empty($boards)) |
|
1271 | - return array(); |
|
1335 | + if (empty($boards)) { |
|
1336 | + return array(); |
|
1337 | + } |
|
1272 | 1338 | |
1273 | 1339 | $request = $smcFunc['db_query']('', ' |
1274 | 1340 | SELECT mg.id_group, mg.group_name, bg.id_board |
@@ -1282,8 +1348,9 @@ discard block |
||
1282 | 1348 | $groups = array(); |
1283 | 1349 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1284 | 1350 | { |
1285 | - if (empty($groups[$row['id_board']])) |
|
1286 | - $groups[$row['id_board']] = array(); |
|
1351 | + if (empty($groups[$row['id_board']])) { |
|
1352 | + $groups[$row['id_board']] = array(); |
|
1353 | + } |
|
1287 | 1354 | |
1288 | 1355 | $groups[$row['id_board']][] = array( |
1289 | 1356 | 'id' => $row['id_group'], |
@@ -1345,8 +1412,9 @@ discard block |
||
1345 | 1412 | |
1346 | 1413 | if (!empty($row['id_board'])) |
1347 | 1414 | { |
1348 | - if ($row['child_level'] != $curLevel) |
|
1349 | - $prevBoard = 0; |
|
1415 | + if ($row['child_level'] != $curLevel) { |
|
1416 | + $prevBoard = 0; |
|
1417 | + } |
|
1350 | 1418 | |
1351 | 1419 | $boards[$row['id_board']] = array( |
1352 | 1420 | 'id' => $row['id_board'], |
@@ -1378,16 +1446,16 @@ discard block |
||
1378 | 1446 | 'children' => array() |
1379 | 1447 | ); |
1380 | 1448 | $boards[$row['id_board']]['tree'] = &$cat_tree[$row['id_cat']]['children'][$row['id_board']]; |
1381 | - } |
|
1382 | - else |
|
1449 | + } else |
|
1383 | 1450 | { |
1384 | 1451 | // Parent doesn't exist! |
1385 | - if (!isset($boards[$row['id_parent']]['tree'])) |
|
1386 | - fatal_lang_error('no_valid_parent', false, array($row['board_name'])); |
|
1452 | + if (!isset($boards[$row['id_parent']]['tree'])) { |
|
1453 | + fatal_lang_error('no_valid_parent', false, array($row['board_name'])); |
|
1454 | + } |
|
1387 | 1455 | |
1388 | 1456 | // Wrong childlevel...we can silently fix this... |
1389 | - if ($boards[$row['id_parent']]['tree']['node']['level'] != $row['child_level'] - 1) |
|
1390 | - $smcFunc['db_query']('', ' |
|
1457 | + if ($boards[$row['id_parent']]['tree']['node']['level'] != $row['child_level'] - 1) { |
|
1458 | + $smcFunc['db_query']('', ' |
|
1391 | 1459 | UPDATE {db_prefix}boards |
1392 | 1460 | SET child_level = {int:new_child_level} |
1393 | 1461 | WHERE id_board = {int:selected_board}', |
@@ -1396,6 +1464,7 @@ discard block |
||
1396 | 1464 | 'selected_board' => $row['id_board'], |
1397 | 1465 | ) |
1398 | 1466 | ); |
1467 | + } |
|
1399 | 1468 | |
1400 | 1469 | $boards[$row['id_parent']]['tree']['children'][$row['id_board']] = array( |
1401 | 1470 | 'node' => &$boards[$row['id_board']], |
@@ -1426,8 +1495,9 @@ discard block |
||
1426 | 1495 | */ |
1427 | 1496 | function recursiveBoards(&$_boardList, &$_tree) |
1428 | 1497 | { |
1429 | - if (empty($_tree['children'])) |
|
1430 | - return; |
|
1498 | + if (empty($_tree['children'])) { |
|
1499 | + return; |
|
1500 | + } |
|
1431 | 1501 | |
1432 | 1502 | foreach ($_tree['children'] as $id => $node) |
1433 | 1503 | { |
@@ -1446,11 +1516,13 @@ discard block |
||
1446 | 1516 | { |
1447 | 1517 | global $boards; |
1448 | 1518 | |
1449 | - if (empty($boards[$child]['parent'])) |
|
1450 | - return false; |
|
1519 | + if (empty($boards[$child]['parent'])) { |
|
1520 | + return false; |
|
1521 | + } |
|
1451 | 1522 | |
1452 | - if ($boards[$child]['parent'] == $parent) |
|
1453 | - return true; |
|
1523 | + if ($boards[$child]['parent'] == $parent) { |
|
1524 | + return true; |
|
1525 | + } |
|
1454 | 1526 | |
1455 | 1527 | return isChildOf($boards[$child]['parent'], $parent); |
1456 | 1528 | } |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
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 | * This is a handling function for all things post moderation. |
@@ -39,8 +40,9 @@ discard block |
||
39 | 40 | ); |
40 | 41 | |
41 | 42 | // Pick something valid... |
42 | - if (!isset($_REQUEST['sa']) || !isset($subActions[$_REQUEST['sa']])) |
|
43 | - $_REQUEST['sa'] = 'replies'; |
|
43 | + if (!isset($_REQUEST['sa']) || !isset($subActions[$_REQUEST['sa']])) { |
|
44 | + $_REQUEST['sa'] = 'replies'; |
|
45 | + } |
|
44 | 46 | |
45 | 47 | call_integration_hook('integrate_post_moderation', array(&$subActions)); |
46 | 48 | |
@@ -68,13 +70,15 @@ discard block |
||
68 | 70 | $approve_boards = $approve_boards == array(0) ? $filter_board : array_intersect($approve_boards, $filter_board); |
69 | 71 | } |
70 | 72 | |
71 | - if ($approve_boards == array(0)) |
|
72 | - $approve_query = ''; |
|
73 | - elseif (!empty($approve_boards)) |
|
74 | - $approve_query = ' AND m.id_board IN (' . implode(',', $approve_boards) . ')'; |
|
73 | + if ($approve_boards == array(0)) { |
|
74 | + $approve_query = ''; |
|
75 | + } elseif (!empty($approve_boards)) { |
|
76 | + $approve_query = ' AND m.id_board IN (' . implode(',', $approve_boards) . ')'; |
|
77 | + } |
|
75 | 78 | // Nada, zip, etc... |
76 | - else |
|
77 | - $approve_query = ' AND 1=0'; |
|
79 | + else { |
|
80 | + $approve_query = ' AND 1=0'; |
|
81 | + } |
|
78 | 82 | |
79 | 83 | // We also need to know where we can delete topics and/or replies to. |
80 | 84 | if ($context['current_view'] == 'topics') |
@@ -82,8 +86,7 @@ discard block |
||
82 | 86 | $delete_own_boards = boardsAllowedTo('remove_own'); |
83 | 87 | $delete_any_boards = boardsAllowedTo('remove_any'); |
84 | 88 | $delete_own_replies = array(); |
85 | - } |
|
86 | - else |
|
89 | + } else |
|
87 | 90 | { |
88 | 91 | $delete_own_boards = boardsAllowedTo('delete_own'); |
89 | 92 | $delete_any_boards = boardsAllowedTo('delete_any'); |
@@ -92,21 +95,25 @@ discard block |
||
92 | 95 | |
93 | 96 | $toAction = array(); |
94 | 97 | // Check if we have something to do? |
95 | - if (isset($_GET['approve'])) |
|
96 | - $toAction[] = (int) $_GET['approve']; |
|
98 | + if (isset($_GET['approve'])) { |
|
99 | + $toAction[] = (int) $_GET['approve']; |
|
100 | + } |
|
97 | 101 | // Just a deletion? |
98 | - elseif (isset($_GET['delete'])) |
|
99 | - $toAction[] = (int) $_GET['delete']; |
|
102 | + elseif (isset($_GET['delete'])) { |
|
103 | + $toAction[] = (int) $_GET['delete']; |
|
104 | + } |
|
100 | 105 | // Lots of approvals? |
101 | - elseif (isset($_POST['item'])) |
|
102 | - foreach ($_POST['item'] as $item) |
|
106 | + elseif (isset($_POST['item'])) { |
|
107 | + foreach ($_POST['item'] as $item) |
|
103 | 108 | $toAction[] = (int) $item; |
109 | + } |
|
104 | 110 | |
105 | 111 | // What are we actually doing. |
106 | - if (isset($_GET['approve']) || (isset($_POST['do']) && $_POST['do'] == 'approve')) |
|
107 | - $curAction = 'approve'; |
|
108 | - elseif (isset($_GET['delete']) || (isset($_POST['do']) && $_POST['do'] == 'delete')) |
|
109 | - $curAction = 'delete'; |
|
112 | + if (isset($_GET['approve']) || (isset($_POST['do']) && $_POST['do'] == 'approve')) { |
|
113 | + $curAction = 'approve'; |
|
114 | + } elseif (isset($_GET['delete']) || (isset($_POST['do']) && $_POST['do'] == 'delete')) { |
|
115 | + $curAction = 'delete'; |
|
116 | + } |
|
110 | 117 | |
111 | 118 | // Right, so we have something to do? |
112 | 119 | if (!empty($toAction) && isset($curAction)) |
@@ -135,8 +142,9 @@ discard block |
||
135 | 142 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
136 | 143 | { |
137 | 144 | // If it's not within what our view is ignore it... |
138 | - if (($row['id_msg'] == $row['id_first_msg'] && $context['current_view'] != 'topics') || ($row['id_msg'] != $row['id_first_msg'] && $context['current_view'] != 'replies')) |
|
139 | - continue; |
|
145 | + if (($row['id_msg'] == $row['id_first_msg'] && $context['current_view'] != 'topics') || ($row['id_msg'] != $row['id_first_msg'] && $context['current_view'] != 'replies')) { |
|
146 | + continue; |
|
147 | + } |
|
140 | 148 | |
141 | 149 | $can_add = false; |
142 | 150 | // If we're approving this is simple. |
@@ -148,18 +156,22 @@ discard block |
||
148 | 156 | elseif ($curAction == 'delete') |
149 | 157 | { |
150 | 158 | // Own post is easy! |
151 | - if ($row['id_member'] == $user_info['id'] && ($delete_own_boards == array(0) || in_array($row['id_board'], $delete_own_boards))) |
|
152 | - $can_add = true; |
|
159 | + if ($row['id_member'] == $user_info['id'] && ($delete_own_boards == array(0) || in_array($row['id_board'], $delete_own_boards))) { |
|
160 | + $can_add = true; |
|
161 | + } |
|
153 | 162 | // Is it a reply to their own topic? |
154 | - elseif ($row['id_member'] == $row['id_member_started'] && $row['id_msg'] != $row['id_first_msg'] && ($delete_own_replies == array(0) || in_array($row['id_board'], $delete_own_replies))) |
|
155 | - $can_add = true; |
|
163 | + elseif ($row['id_member'] == $row['id_member_started'] && $row['id_msg'] != $row['id_first_msg'] && ($delete_own_replies == array(0) || in_array($row['id_board'], $delete_own_replies))) { |
|
164 | + $can_add = true; |
|
165 | + } |
|
156 | 166 | // Someone elses? |
157 | - elseif ($row['id_member'] != $user_info['id'] && ($delete_any_boards == array(0) || in_array($row['id_board'], $delete_any_boards))) |
|
158 | - $can_add = true; |
|
167 | + elseif ($row['id_member'] != $user_info['id'] && ($delete_any_boards == array(0) || in_array($row['id_board'], $delete_any_boards))) { |
|
168 | + $can_add = true; |
|
169 | + } |
|
159 | 170 | } |
160 | 171 | |
161 | - if ($can_add) |
|
162 | - $anItem = $context['current_view'] == 'topics' ? $row['id_topic'] : $row['id_msg']; |
|
172 | + if ($can_add) { |
|
173 | + $anItem = $context['current_view'] == 'topics' ? $row['id_topic'] : $row['id_msg']; |
|
174 | + } |
|
163 | 175 | $toAction[] = $anItem; |
164 | 176 | |
165 | 177 | // All clear. What have we got now, what, what? |
@@ -177,8 +189,7 @@ discard block |
||
177 | 189 | if ($curAction == 'approve') |
178 | 190 | { |
179 | 191 | approveMessages($toAction, $details, $context['current_view']); |
180 | - } |
|
181 | - else |
|
192 | + } else |
|
182 | 193 | { |
183 | 194 | removeMessages($toAction, $details, $context['current_view']); |
184 | 195 | } |
@@ -265,16 +276,19 @@ discard block |
||
265 | 276 | for ($i = 1; $row = $smcFunc['db_fetch_assoc']($request); $i++) |
266 | 277 | { |
267 | 278 | // Can delete is complicated, let's solve it first... is it their own post? |
268 | - if ($row['id_member'] == $user_info['id'] && ($delete_own_boards == array(0) || in_array($row['id_board'], $delete_own_boards))) |
|
269 | - $can_delete = true; |
|
279 | + if ($row['id_member'] == $user_info['id'] && ($delete_own_boards == array(0) || in_array($row['id_board'], $delete_own_boards))) { |
|
280 | + $can_delete = true; |
|
281 | + } |
|
270 | 282 | // Is it a reply to their own topic? |
271 | - elseif ($row['id_member'] == $row['id_member_started'] && $row['id_msg'] != $row['id_first_msg'] && ($delete_own_replies == array(0) || in_array($row['id_board'], $delete_own_replies))) |
|
272 | - $can_delete = true; |
|
283 | + elseif ($row['id_member'] == $row['id_member_started'] && $row['id_msg'] != $row['id_first_msg'] && ($delete_own_replies == array(0) || in_array($row['id_board'], $delete_own_replies))) { |
|
284 | + $can_delete = true; |
|
285 | + } |
|
273 | 286 | // Someone elses? |
274 | - elseif ($row['id_member'] != $user_info['id'] && ($delete_any_boards == array(0) || in_array($row['id_board'], $delete_any_boards))) |
|
275 | - $can_delete = true; |
|
276 | - else |
|
277 | - $can_delete = false; |
|
287 | + elseif ($row['id_member'] != $user_info['id'] && ($delete_any_boards == array(0) || in_array($row['id_board'], $delete_any_boards))) { |
|
288 | + $can_delete = true; |
|
289 | + } else { |
|
290 | + $can_delete = false; |
|
291 | + } |
|
278 | 292 | |
279 | 293 | $context['unapproved_items'][] = array( |
280 | 294 | 'id' => $row['id_msg'], |
@@ -323,28 +337,31 @@ discard block |
||
323 | 337 | // Once again, permissions are king! |
324 | 338 | $approve_boards = boardsAllowedTo('approve_posts'); |
325 | 339 | |
326 | - if ($approve_boards == array(0)) |
|
327 | - $approve_query = ''; |
|
328 | - elseif (!empty($approve_boards)) |
|
329 | - $approve_query = ' AND m.id_board IN (' . implode(',', $approve_boards) . ')'; |
|
330 | - else |
|
331 | - $approve_query = ' AND 1=0'; |
|
340 | + if ($approve_boards == array(0)) { |
|
341 | + $approve_query = ''; |
|
342 | + } elseif (!empty($approve_boards)) { |
|
343 | + $approve_query = ' AND m.id_board IN (' . implode(',', $approve_boards) . ')'; |
|
344 | + } else { |
|
345 | + $approve_query = ' AND 1=0'; |
|
346 | + } |
|
332 | 347 | |
333 | 348 | // Get together the array of things to act on, if any. |
334 | 349 | $attachments = array(); |
335 | - if (isset($_GET['approve'])) |
|
336 | - $attachments[] = (int) $_GET['approve']; |
|
337 | - elseif (isset($_GET['delete'])) |
|
338 | - $attachments[] = (int) $_GET['delete']; |
|
339 | - elseif (isset($_POST['item'])) |
|
340 | - foreach ($_POST['item'] as $item) |
|
350 | + if (isset($_GET['approve'])) { |
|
351 | + $attachments[] = (int) $_GET['approve']; |
|
352 | + } elseif (isset($_GET['delete'])) { |
|
353 | + $attachments[] = (int) $_GET['delete']; |
|
354 | + } elseif (isset($_POST['item'])) { |
|
355 | + foreach ($_POST['item'] as $item) |
|
341 | 356 | $attachments[] = (int) $item; |
357 | + } |
|
342 | 358 | |
343 | 359 | // Are we approving or deleting? |
344 | - if (isset($_GET['approve']) || (isset($_POST['do']) && $_POST['do'] == 'approve')) |
|
345 | - $curAction = 'approve'; |
|
346 | - elseif (isset($_GET['delete']) || (isset($_POST['do']) && $_POST['do'] == 'delete')) |
|
347 | - $curAction = 'delete'; |
|
360 | + if (isset($_GET['approve']) || (isset($_POST['do']) && $_POST['do'] == 'approve')) { |
|
361 | + $curAction = 'approve'; |
|
362 | + } elseif (isset($_GET['delete']) || (isset($_POST['do']) && $_POST['do'] == 'delete')) { |
|
363 | + $curAction = 'delete'; |
|
364 | + } |
|
348 | 365 | |
349 | 366 | // Something to do, let's do it! |
350 | 367 | if (!empty($attachments) && isset($curAction)) |
@@ -372,17 +389,19 @@ discard block |
||
372 | 389 | ) |
373 | 390 | ); |
374 | 391 | $attachments = array(); |
375 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
376 | - $attachments[] = $row['id_attach']; |
|
392 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
393 | + $attachments[] = $row['id_attach']; |
|
394 | + } |
|
377 | 395 | $smcFunc['db_free_result']($request); |
378 | 396 | |
379 | 397 | // Assuming it wasn't all like, proper illegal, we can do the approving. |
380 | 398 | if (!empty($attachments)) |
381 | 399 | { |
382 | - if ($curAction == 'approve') |
|
383 | - ApproveAttachments($attachments); |
|
384 | - else |
|
385 | - removeAttachments(array('id_attach' => $attachments, 'do_logging' => true)); |
|
400 | + if ($curAction == 'approve') { |
|
401 | + ApproveAttachments($attachments); |
|
402 | + } else { |
|
403 | + removeAttachments(array('id_attach' => $attachments, 'do_logging' => true)); |
|
404 | + } |
|
386 | 405 | } |
387 | 406 | } |
388 | 407 | |
@@ -682,15 +701,16 @@ discard block |
||
682 | 701 | { |
683 | 702 | approveTopics($topic, !$approved); |
684 | 703 | |
685 | - if ($starter != $user_info['id']) |
|
686 | - logAction(($approved ? 'un' : '') . 'approve_topic', array('topic' => $topic, 'subject' => $subject, 'member' => $starter, 'board' => $board)); |
|
687 | - } |
|
688 | - else |
|
704 | + if ($starter != $user_info['id']) { |
|
705 | + logAction(($approved ? 'un' : '') . 'approve_topic', array('topic' => $topic, 'subject' => $subject, 'member' => $starter, 'board' => $board)); |
|
706 | + } |
|
707 | + } else |
|
689 | 708 | { |
690 | 709 | approvePosts($_REQUEST['msg'], !$approved); |
691 | 710 | |
692 | - if ($poster != $user_info['id']) |
|
693 | - logAction(($approved ? 'un' : '') . 'approve', array('topic' => $topic, 'subject' => $subject, 'member' => $poster, 'board' => $board)); |
|
711 | + if ($poster != $user_info['id']) { |
|
712 | + logAction(($approved ? 'un' : '') . 'approve', array('topic' => $topic, 'subject' => $subject, 'member' => $poster, 'board' => $board)); |
|
713 | + } |
|
694 | 714 | } |
695 | 715 | |
696 | 716 | redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg']); |
@@ -716,8 +736,7 @@ discard block |
||
716 | 736 | { |
717 | 737 | logAction('approve_topic', array('topic' => $topic, 'subject' => $messageDetails[$topic]['subject'], 'member' => $messageDetails[$topic]['member'], 'board' => $messageDetails[$topic]['board'])); |
718 | 738 | } |
719 | - } |
|
720 | - else |
|
739 | + } else |
|
721 | 740 | { |
722 | 741 | approvePosts($messages); |
723 | 742 | // and tell the world about it again |
@@ -745,8 +764,9 @@ discard block |
||
745 | 764 | ) |
746 | 765 | ); |
747 | 766 | $msgs = array(); |
748 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
749 | - $msgs[] = $row[0]; |
|
767 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
768 | + $msgs[] = $row[0]; |
|
769 | + } |
|
750 | 770 | $smcFunc['db_free_result']($request); |
751 | 771 | |
752 | 772 | if (!empty($msgs)) |
@@ -765,8 +785,9 @@ discard block |
||
765 | 785 | ) |
766 | 786 | ); |
767 | 787 | $attaches = array(); |
768 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
769 | - $attaches[] = $row[0]; |
|
788 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
789 | + $attaches[] = $row[0]; |
|
790 | + } |
|
770 | 791 | $smcFunc['db_free_result']($request); |
771 | 792 | |
772 | 793 | if (!empty($attaches)) |
@@ -794,12 +815,12 @@ discard block |
||
794 | 815 | { |
795 | 816 | removeTopics($messages); |
796 | 817 | // and tell the world about it |
797 | - foreach ($messages as $topic) |
|
798 | - // Note, only log topic ID in native form if it's not gone forever. |
|
818 | + foreach ($messages as $topic) { |
|
819 | + // Note, only log topic ID in native form if it's not gone forever. |
|
799 | 820 | logAction('remove', array( |
800 | 821 | (empty($modSettings['recycle_enable']) || $modSettings['recycle_board'] != $messageDetails[$topic]['board'] ? 'topic' : 'old_topic_id') => $topic, 'subject' => $messageDetails[$topic]['subject'], 'member' => $messageDetails[$topic]['member'], 'board' => $messageDetails[$topic]['board'])); |
801 | - } |
|
802 | - else |
|
822 | + } |
|
823 | + } else |
|
803 | 824 | { |
804 | 825 | foreach ($messages as $post) |
805 | 826 | { |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * The news dispatcher; doesn't do anything, just delegates. |
@@ -67,8 +68,9 @@ discard block |
||
67 | 68 | ); |
68 | 69 | |
69 | 70 | // Force the right area... |
70 | - if (substr($_REQUEST['sa'], 0, 7) == 'mailing') |
|
71 | - $context[$context['admin_menu_name']]['current_subsection'] = 'mailingmembers'; |
|
71 | + if (substr($_REQUEST['sa'], 0, 7) == 'mailing') { |
|
72 | + $context[$context['admin_menu_name']]['current_subsection'] = 'mailingmembers'; |
|
73 | + } |
|
72 | 74 | |
73 | 75 | call_helper($subActions[$_REQUEST['sa']][0]); |
74 | 76 | } |
@@ -99,9 +101,10 @@ discard block |
||
99 | 101 | $temp_news = explode("\n", $modSettings['news']); |
100 | 102 | |
101 | 103 | // Remove the items that were selected. |
102 | - foreach ($temp_news as $i => $news) |
|
103 | - if (in_array($i, $_POST['remove'])) |
|
104 | + foreach ($temp_news as $i => $news) { |
|
105 | + if (in_array($i, $_POST['remove'])) |
|
104 | 106 | unset($temp_news[$i]); |
107 | + } |
|
105 | 108 | |
106 | 109 | // Update the database. |
107 | 110 | updateSettings(array('news' => implode("\n", $temp_news))); |
@@ -117,9 +120,9 @@ discard block |
||
117 | 120 | |
118 | 121 | foreach ($_POST['news'] as $i => $news) |
119 | 122 | { |
120 | - if (trim($news) == '') |
|
121 | - unset($_POST['news'][$i]); |
|
122 | - else |
|
123 | + if (trim($news) == '') { |
|
124 | + unset($_POST['news'][$i]); |
|
125 | + } else |
|
123 | 126 | { |
124 | 127 | $_POST['news'][$i] = $smcFunc['htmlspecialchars']($_POST['news'][$i], ENT_QUOTES); |
125 | 128 | preparsecode($_POST['news'][$i]); |
@@ -154,11 +157,12 @@ discard block |
||
154 | 157 | 'data' => array( |
155 | 158 | 'function' => function($news) |
156 | 159 | { |
157 | - if (is_numeric($news['id'])) |
|
158 | - return '<textarea id="data_' . $news['id'] . '" rows="3" cols="50" name="news[]" class="padding block">' . $news['unparsed'] . '</textarea> |
|
160 | + if (is_numeric($news['id'])) { |
|
161 | + return '<textarea id="data_' . $news['id'] . '" rows="3" cols="50" name="news[]" class="padding block">' . $news['unparsed'] . '</textarea> |
|
159 | 162 | <div class="floatleft" id="preview_' . $news['id'] . '"></div>'; |
160 | - else |
|
161 | - return $news['unparsed']; |
|
163 | + } else { |
|
164 | + return $news['unparsed']; |
|
165 | + } |
|
162 | 166 | }, |
163 | 167 | 'style' => 'width: 50%;', |
164 | 168 | ), |
@@ -183,10 +187,11 @@ discard block |
||
183 | 187 | 'data' => array( |
184 | 188 | 'function' => function($news) |
185 | 189 | { |
186 | - if (is_numeric($news['id'])) |
|
187 | - return '<input type="checkbox" name="remove[]" value="' . $news['id'] . '" class="input_check">'; |
|
188 | - else |
|
189 | - return ''; |
|
190 | + if (is_numeric($news['id'])) { |
|
191 | + return '<input type="checkbox" name="remove[]" value="' . $news['id'] . '" class="input_check">'; |
|
192 | + } else { |
|
193 | + return ''; |
|
194 | + } |
|
190 | 195 | }, |
191 | 196 | 'class' => 'centercol', |
192 | 197 | ), |
@@ -280,12 +285,13 @@ discard block |
||
280 | 285 | |
281 | 286 | $admin_current_news = array(); |
282 | 287 | // Ready the current news. |
283 | - foreach (explode("\n", $modSettings['news']) as $id => $line) |
|
284 | - $admin_current_news[$id] = array( |
|
288 | + foreach (explode("\n", $modSettings['news']) as $id => $line) { |
|
289 | + $admin_current_news[$id] = array( |
|
285 | 290 | 'id' => $id, |
286 | 291 | 'unparsed' => un_preparsecode($line), |
287 | 292 | 'parsed' => preg_replace('~<([/]?)form[^>]*?[>]*>~i', '<em class="smalltext"><$1form></em>', parse_bbc($line)), |
288 | 293 | ); |
294 | + } |
|
289 | 295 | |
290 | 296 | $admin_current_news['last'] = array( |
291 | 297 | 'id' => 'last', |
@@ -352,10 +358,11 @@ discard block |
||
352 | 358 | 'member_count' => 0, |
353 | 359 | ); |
354 | 360 | |
355 | - if ($row['min_posts'] == -1) |
|
356 | - $normalGroups[$row['id_group']] = $row['id_group']; |
|
357 | - else |
|
358 | - $postGroups[$row['id_group']] = $row['id_group']; |
|
361 | + if ($row['min_posts'] == -1) { |
|
362 | + $normalGroups[$row['id_group']] = $row['id_group']; |
|
363 | + } else { |
|
364 | + $postGroups[$row['id_group']] = $row['id_group']; |
|
365 | + } |
|
359 | 366 | } |
360 | 367 | $smcFunc['db_free_result']($request); |
361 | 368 | |
@@ -371,8 +378,9 @@ discard block |
||
371 | 378 | 'post_group_list' => $postGroups, |
372 | 379 | ) |
373 | 380 | ); |
374 | - while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
375 | - $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
381 | + while ($row = $smcFunc['db_fetch_assoc']($query)) { |
|
382 | + $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
383 | + } |
|
376 | 384 | $smcFunc['db_free_result']($query); |
377 | 385 | } |
378 | 386 | |
@@ -388,8 +396,9 @@ discard block |
||
388 | 396 | 'normal_group_list' => $normalGroups, |
389 | 397 | ) |
390 | 398 | ); |
391 | - while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
392 | - $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
399 | + while ($row = $smcFunc['db_fetch_assoc']($query)) { |
|
400 | + $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
401 | + } |
|
393 | 402 | $smcFunc['db_free_result']($query); |
394 | 403 | |
395 | 404 | // Also do those who have it as an additional membergroup - this ones more yucky... |
@@ -406,8 +415,9 @@ discard block |
||
406 | 415 | 'blank_string' => '', |
407 | 416 | ) |
408 | 417 | ); |
409 | - while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
410 | - $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
418 | + while ($row = $smcFunc['db_fetch_assoc']($query)) { |
|
419 | + $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
420 | + } |
|
411 | 421 | $smcFunc['db_free_result']($query); |
412 | 422 | } |
413 | 423 | |
@@ -458,10 +468,11 @@ discard block |
||
458 | 468 | { |
459 | 469 | $context[$key] = !empty($_REQUEST[$post]) ? $_REQUEST[$post] : ''; |
460 | 470 | |
461 | - if (empty($context[$key]) && empty($_REQUEST['xml'])) |
|
462 | - $context['post_error']['messages'][] = $txt['error_no_' . $post]; |
|
463 | - elseif (!empty($_REQUEST['xml'])) |
|
464 | - continue; |
|
471 | + if (empty($context[$key]) && empty($_REQUEST['xml'])) { |
|
472 | + $context['post_error']['messages'][] = $txt['error_no_' . $post]; |
|
473 | + } elseif (!empty($_REQUEST['xml'])) { |
|
474 | + continue; |
|
475 | + } |
|
465 | 476 | |
466 | 477 | preparsecode($context[$key]); |
467 | 478 | if ($html) |
@@ -540,10 +551,12 @@ discard block |
||
540 | 551 | |
541 | 552 | // Start by finding any members! |
542 | 553 | $toClean = array(); |
543 | - if (!empty($_POST['members'])) |
|
544 | - $toClean[] = 'members'; |
|
545 | - if (!empty($_POST['exclude_members'])) |
|
546 | - $toClean[] = 'exclude_members'; |
|
554 | + if (!empty($_POST['members'])) { |
|
555 | + $toClean[] = 'members'; |
|
556 | + } |
|
557 | + if (!empty($_POST['exclude_members'])) { |
|
558 | + $toClean[] = 'exclude_members'; |
|
559 | + } |
|
547 | 560 | if (!empty($toClean)) |
548 | 561 | { |
549 | 562 | require_once($sourcedir . '/Subs-Auth.php'); |
@@ -555,11 +568,13 @@ discard block |
||
555 | 568 | preg_match_all('~"([^"]+)"~', $_POST[$type], $matches); |
556 | 569 | $_POST[$type] = array_unique(array_merge($matches[1], explode(',', preg_replace('~"[^"]+"~', '', $_POST[$type])))); |
557 | 570 | |
558 | - foreach ($_POST[$type] as $index => $member) |
|
559 | - if (strlen(trim($member)) > 0) |
|
571 | + foreach ($_POST[$type] as $index => $member) { |
|
572 | + if (strlen(trim($member)) > 0) |
|
560 | 573 | $_POST[$type][$index] = $smcFunc['htmlspecialchars']($smcFunc['strtolower'](trim($member))); |
561 | - else |
|
562 | - unset($_POST[$type][$index]); |
|
574 | + } |
|
575 | + else { |
|
576 | + unset($_POST[$type][$index]); |
|
577 | + } |
|
563 | 578 | |
564 | 579 | // Find the members |
565 | 580 | $_POST[$type] = implode(',', array_keys(findMembers($_POST[$type]))); |
@@ -569,16 +584,18 @@ discard block |
||
569 | 584 | if (isset($_POST['member_list']) && is_array($_POST['member_list'])) |
570 | 585 | { |
571 | 586 | $members = array(); |
572 | - foreach ($_POST['member_list'] as $member_id) |
|
573 | - $members[] = (int) $member_id; |
|
587 | + foreach ($_POST['member_list'] as $member_id) { |
|
588 | + $members[] = (int) $member_id; |
|
589 | + } |
|
574 | 590 | $_POST['members'] = implode(',', $members); |
575 | 591 | } |
576 | 592 | |
577 | 593 | if (isset($_POST['exclude_member_list']) && is_array($_POST['exclude_member_list'])) |
578 | 594 | { |
579 | 595 | $members = array(); |
580 | - foreach ($_POST['exclude_member_list'] as $member_id) |
|
581 | - $members[] = (int) $member_id; |
|
596 | + foreach ($_POST['exclude_member_list'] as $member_id) { |
|
597 | + $members[] = (int) $member_id; |
|
598 | + } |
|
582 | 599 | $_POST['exclude_members'] = implode(',', $members); |
583 | 600 | } |
584 | 601 | |
@@ -602,8 +619,9 @@ discard block |
||
602 | 619 | 'current_time' => time(), |
603 | 620 | ) |
604 | 621 | ); |
605 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
606 | - $context['recipients']['exclude_members'][] = $row['id_member']; |
|
622 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
623 | + $context['recipients']['exclude_members'][] = $row['id_member']; |
|
624 | + } |
|
607 | 625 | $smcFunc['db_free_result']($request); |
608 | 626 | |
609 | 627 | $request = $smcFunc['db_query']('', ' |
@@ -638,8 +656,9 @@ discard block |
||
638 | 656 | WHERE email_address IN(' . implode(', ', $condition_array) . ')', |
639 | 657 | $condition_array_params |
640 | 658 | ); |
641 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
642 | - $context['recipients']['exclude_members'][] = $row['id_member']; |
|
659 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
660 | + $context['recipients']['exclude_members'][] = $row['id_member']; |
|
661 | + } |
|
643 | 662 | $smcFunc['db_free_result']($request); |
644 | 663 | } |
645 | 664 | |
@@ -657,10 +676,11 @@ discard block |
||
657 | 676 | ); |
658 | 677 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
659 | 678 | { |
660 | - if (in_array(3, $context['recipients'])) |
|
661 | - $context['recipients']['exclude_members'][] = $row['identifier']; |
|
662 | - else |
|
663 | - $context['recipients']['members'][] = $row['identifier']; |
|
679 | + if (in_array(3, $context['recipients'])) { |
|
680 | + $context['recipients']['exclude_members'][] = $row['identifier']; |
|
681 | + } else { |
|
682 | + $context['recipients']['members'][] = $row['identifier']; |
|
683 | + } |
|
664 | 684 | } |
665 | 685 | $smcFunc['db_free_result']($request); |
666 | 686 | } |
@@ -707,8 +727,9 @@ discard block |
||
707 | 727 | $num_at_once = 1000; |
708 | 728 | |
709 | 729 | // If by PM's I suggest we half the above number. |
710 | - if (!empty($_POST['send_pm'])) |
|
711 | - $num_at_once /= 2; |
|
730 | + if (!empty($_POST['send_pm'])) { |
|
731 | + $num_at_once /= 2; |
|
732 | + } |
|
712 | 733 | |
713 | 734 | checkSession(); |
714 | 735 | |
@@ -731,8 +752,7 @@ discard block |
||
731 | 752 | ); |
732 | 753 | list ($context['total_members']) = $smcFunc['db_fetch_row']($request); |
733 | 754 | $smcFunc['db_free_result']($request); |
734 | - } |
|
735 | - else |
|
755 | + } else |
|
736 | 756 | { |
737 | 757 | $context['total_members'] = (int) $_REQUEST['total_members']; |
738 | 758 | } |
@@ -750,32 +770,35 @@ discard block |
||
750 | 770 | if (!empty($_POST['exclude_members'])) |
751 | 771 | { |
752 | 772 | $members = explode(',', $_POST['exclude_members']); |
753 | - foreach ($members as $member) |
|
754 | - if ($member >= $context['start']) |
|
773 | + foreach ($members as $member) { |
|
774 | + if ($member >= $context['start']) |
|
755 | 775 | $context['recipients']['exclude_members'][] = (int) $member; |
776 | + } |
|
756 | 777 | } |
757 | 778 | |
758 | 779 | // What about members we *must* do? |
759 | 780 | if (!empty($_POST['members'])) |
760 | 781 | { |
761 | 782 | $members = explode(',', $_POST['members']); |
762 | - foreach ($members as $member) |
|
763 | - if ($member >= $context['start']) |
|
783 | + foreach ($members as $member) { |
|
784 | + if ($member >= $context['start']) |
|
764 | 785 | $context['recipients']['members'][] = (int) $member; |
786 | + } |
|
765 | 787 | } |
766 | 788 | // Cleaning groups is simple - although deal with both checkbox and commas. |
767 | 789 | if (isset($_POST['groups'])) |
768 | 790 | { |
769 | 791 | if (is_array($_POST['groups'])) |
770 | 792 | { |
771 | - foreach ($_POST['groups'] as $group => $dummy) |
|
772 | - $context['recipients']['groups'][] = (int) $group; |
|
773 | - } |
|
774 | - else |
|
793 | + foreach ($_POST['groups'] as $group => $dummy) { |
|
794 | + $context['recipients']['groups'][] = (int) $group; |
|
795 | + } |
|
796 | + } else |
|
775 | 797 | { |
776 | 798 | $groups = explode(',', $_POST['groups']); |
777 | - foreach ($groups as $group) |
|
778 | - $context['recipients']['groups'][] = (int) $group; |
|
799 | + foreach ($groups as $group) { |
|
800 | + $context['recipients']['groups'][] = (int) $group; |
|
801 | + } |
|
779 | 802 | } |
780 | 803 | } |
781 | 804 | // Same for excluded groups |
@@ -783,14 +806,15 @@ discard block |
||
783 | 806 | { |
784 | 807 | if (is_array($_POST['exclude_groups'])) |
785 | 808 | { |
786 | - foreach ($_POST['exclude_groups'] as $group => $dummy) |
|
787 | - $context['recipients']['exclude_groups'][] = (int) $group; |
|
788 | - } |
|
789 | - else |
|
809 | + foreach ($_POST['exclude_groups'] as $group => $dummy) { |
|
810 | + $context['recipients']['exclude_groups'][] = (int) $group; |
|
811 | + } |
|
812 | + } else |
|
790 | 813 | { |
791 | 814 | $groups = explode(',', $_POST['exclude_groups']); |
792 | - foreach ($groups as $group) |
|
793 | - $context['recipients']['exclude_groups'][] = (int) $group; |
|
815 | + foreach ($groups as $group) { |
|
816 | + $context['recipients']['exclude_groups'][] = (int) $group; |
|
817 | + } |
|
794 | 818 | } |
795 | 819 | } |
796 | 820 | // Finally - emails! |
@@ -800,14 +824,16 @@ discard block |
||
800 | 824 | foreach ($addressed as $curmem) |
801 | 825 | { |
802 | 826 | $curmem = trim($curmem); |
803 | - if ($curmem != '' && filter_var($curmem, FILTER_VALIDATE_EMAIL)) |
|
804 | - $context['recipients']['emails'][$curmem] = $curmem; |
|
827 | + if ($curmem != '' && filter_var($curmem, FILTER_VALIDATE_EMAIL)) { |
|
828 | + $context['recipients']['emails'][$curmem] = $curmem; |
|
829 | + } |
|
805 | 830 | } |
806 | 831 | } |
807 | 832 | |
808 | 833 | // If we're only cleaning drop out here. |
809 | - if ($clean_only) |
|
810 | - return; |
|
834 | + if ($clean_only) { |
|
835 | + return; |
|
836 | + } |
|
811 | 837 | |
812 | 838 | require_once($sourcedir . '/Subs-Post.php'); |
813 | 839 | |
@@ -823,16 +849,18 @@ discard block |
||
823 | 849 | if (!$context['send_pm'] && !empty($_POST['send_html'])) |
824 | 850 | { |
825 | 851 | // Prepare the message for HTML. |
826 | - if (!empty($_POST['parse_html'])) |
|
827 | - $_POST['message'] = str_replace(array("\n", ' '), array('<br>' . "\n", ' '), $_POST['message']); |
|
852 | + if (!empty($_POST['parse_html'])) { |
|
853 | + $_POST['message'] = str_replace(array("\n", ' '), array('<br>' . "\n", ' '), $_POST['message']); |
|
854 | + } |
|
828 | 855 | |
829 | 856 | // This is here to prevent spam filters from tagging this as spam. |
830 | 857 | if (preg_match('~\<html~i', $_POST['message']) == 0) |
831 | 858 | { |
832 | - if (preg_match('~\<body~i', $_POST['message']) == 0) |
|
833 | - $_POST['message'] = '<html><head><title>' . $_POST['subject'] . '</title></head>' . "\n" . '<body>' . $_POST['message'] . '</body></html>'; |
|
834 | - else |
|
835 | - $_POST['message'] = '<html>' . $_POST['message'] . '</html>'; |
|
859 | + if (preg_match('~\<body~i', $_POST['message']) == 0) { |
|
860 | + $_POST['message'] = '<html><head><title>' . $_POST['subject'] . '</title></head>' . "\n" . '<body>' . $_POST['message'] . '</body></html>'; |
|
861 | + } else { |
|
862 | + $_POST['message'] = '<html>' . $_POST['message'] . '</html>'; |
|
863 | + } |
|
836 | 864 | } |
837 | 865 | } |
838 | 866 | |
@@ -886,15 +914,17 @@ discard block |
||
886 | 914 | foreach ($context['recipients']['emails'] as $k => $email) |
887 | 915 | { |
888 | 916 | // Done as many as we can? |
889 | - if ($i >= $num_at_once) |
|
890 | - break; |
|
917 | + if ($i >= $num_at_once) { |
|
918 | + break; |
|
919 | + } |
|
891 | 920 | |
892 | 921 | // Don't sent it twice! |
893 | 922 | unset($context['recipients']['emails'][$k]); |
894 | 923 | |
895 | 924 | // Dammit - can't PM emails! |
896 | - if ($context['send_pm']) |
|
897 | - continue; |
|
925 | + if ($context['send_pm']) { |
|
926 | + continue; |
|
927 | + } |
|
898 | 928 | |
899 | 929 | $to_member = array( |
900 | 930 | $email, |
@@ -928,8 +958,9 @@ discard block |
||
928 | 958 | $queryBuild[] = 'mem.id_post_group = {int:group_' . $group . '}'; |
929 | 959 | } |
930 | 960 | } |
931 | - if (!empty($queryBuild)) |
|
932 | - $sendQuery .= implode(' OR ', $queryBuild); |
|
961 | + if (!empty($queryBuild)) { |
|
962 | + $sendQuery .= implode(' OR ', $queryBuild); |
|
963 | + } |
|
933 | 964 | } |
934 | 965 | if (!empty($context['recipients']['members'])) |
935 | 966 | { |
@@ -948,8 +979,9 @@ discard block |
||
948 | 979 | } |
949 | 980 | |
950 | 981 | // Anything to exclude? |
951 | - if (!empty($context['recipients']['exclude_groups']) && in_array(0, $context['recipients']['exclude_groups'])) |
|
952 | - $sendQuery .= ' AND mem.id_group != {int:regular_group}'; |
|
982 | + if (!empty($context['recipients']['exclude_groups']) && in_array(0, $context['recipients']['exclude_groups'])) { |
|
983 | + $sendQuery .= ' AND mem.id_group != {int:regular_group}'; |
|
984 | + } |
|
953 | 985 | if (!empty($context['recipients']['exclude_members'])) |
954 | 986 | { |
955 | 987 | $sendQuery .= ' AND mem.id_member NOT IN ({array_int:exclude_members})'; |
@@ -985,21 +1017,24 @@ discard block |
||
985 | 1017 | foreach ($rows as $row) |
986 | 1018 | { |
987 | 1019 | // Force them to have it? |
988 | - if (empty($context['email_force']) || empty($prefs[$row['id_member']]['announcements'])) |
|
989 | - continue; |
|
1020 | + if (empty($context['email_force']) || empty($prefs[$row['id_member']]['announcements'])) { |
|
1021 | + continue; |
|
1022 | + } |
|
990 | 1023 | |
991 | 1024 | // What groups are we looking at here? |
992 | - if (empty($row['additional_groups'])) |
|
993 | - $groups = array($row['id_group'], $row['id_post_group']); |
|
994 | - else |
|
995 | - $groups = array_merge( |
|
1025 | + if (empty($row['additional_groups'])) { |
|
1026 | + $groups = array($row['id_group'], $row['id_post_group']); |
|
1027 | + } else { |
|
1028 | + $groups = array_merge( |
|
996 | 1029 | array($row['id_group'], $row['id_post_group']), |
997 | 1030 | explode(',', $row['additional_groups']) |
998 | 1031 | ); |
1032 | + } |
|
999 | 1033 | |
1000 | 1034 | // Excluded groups? |
1001 | - if (array_intersect($groups, $context['recipients']['exclude_groups'])) |
|
1002 | - continue; |
|
1035 | + if (array_intersect($groups, $context['recipients']['exclude_groups'])) { |
|
1036 | + continue; |
|
1037 | + } |
|
1003 | 1038 | |
1004 | 1039 | // We might need this |
1005 | 1040 | $cleanMemberName = empty($_POST['send_html']) || $context['send_pm'] ? un_htmlspecialchars($row['real_name']) : $row['real_name']; |
@@ -1022,10 +1057,11 @@ discard block |
||
1022 | 1057 | ), $_POST['subject']); |
1023 | 1058 | |
1024 | 1059 | // Send the actual email - or a PM! |
1025 | - if (!$context['send_pm']) |
|
1026 | - sendmail($row['email_address'], $subject, $message, null, 'news', !empty($_POST['send_html']), 5); |
|
1027 | - else |
|
1028 | - sendpm(array('to' => array($row['id_member']), 'bcc' => array()), $subject, $message); |
|
1060 | + if (!$context['send_pm']) { |
|
1061 | + sendmail($row['email_address'], $subject, $message, null, 'news', !empty($_POST['send_html']), 5); |
|
1062 | + } else { |
|
1063 | + sendpm(array('to' => array($row['id_member']), 'bcc' => array()), $subject, $message); |
|
1064 | + } |
|
1029 | 1065 | } |
1030 | 1066 | } |
1031 | 1067 | |
@@ -1075,8 +1111,9 @@ discard block |
||
1075 | 1111 | |
1076 | 1112 | call_integration_hook('integrate_modify_news_settings', array(&$config_vars)); |
1077 | 1113 | |
1078 | - if ($return_config) |
|
1079 | - return $config_vars; |
|
1114 | + if ($return_config) { |
|
1115 | + return $config_vars; |
|
1116 | + } |
|
1080 | 1117 | |
1081 | 1118 | $context['page_title'] = $txt['admin_edit_news'] . ' - ' . $txt['settings']; |
1082 | 1119 | $context['sub_template'] = 'show_settings'; |
@@ -1,9 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | // Try to handle it with the upper level index.php. (it should know what to do.) |
4 | -if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) |
|
4 | +if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) { |
|
5 | 5 | include (dirname(dirname(__FILE__)) . '/index.php'); |
6 | -else |
|
6 | +} else { |
|
7 | 7 | exit; |
8 | +} |
|
8 | 9 | |
9 | 10 | ?> |
10 | 11 | \ No newline at end of file |
@@ -1,9 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | // Try to handle it with the upper level index.php. (it should know what to do.) |
4 | -if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) |
|
4 | +if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) { |
|
5 | 5 | include (dirname(dirname(__FILE__)) . '/index.php'); |
6 | -else |
|
6 | +} else { |
|
7 | 7 | exit; |
8 | +} |
|
8 | 9 | |
9 | 10 | ?> |
10 | 11 | \ No newline at end of file |
@@ -12,7 +12,8 @@ |
||
12 | 12 | header('Location: ' . $boardurl); |
13 | 13 | } |
14 | 14 | // Can't find it... just forget it. |
15 | -else |
|
15 | +else { |
|
16 | 16 | exit; |
17 | +} |
|
17 | 18 | |
18 | 19 | ?> |
19 | 20 | \ No newline at end of file |
@@ -30,8 +30,9 @@ discard block |
||
30 | 30 | * @version 2.1 Beta 3 |
31 | 31 | */ |
32 | 32 | |
33 | -if (!defined('SMF')) |
|
33 | +if (!defined('SMF')) { |
|
34 | 34 | die('No direct access...'); |
35 | +} |
|
35 | 36 | |
36 | 37 | /** |
37 | 38 | * Subaction handler - manages the action and delegates control to the proper |
@@ -103,12 +104,12 @@ discard block |
||
103 | 104 | cache_put_data('minimized_css', null); |
104 | 105 | |
105 | 106 | // Follow the sa or just go to administration. |
106 | - if (isset($_GET['sa']) && !empty($subActions[$_GET['sa']])) |
|
107 | - call_helper($subActions[$_GET['sa']]); |
|
108 | - |
|
109 | - else |
|
110 | - call_helper($subActions['admin']); |
|
111 | -} |
|
107 | + if (isset($_GET['sa']) && !empty($subActions[$_GET['sa']])) { |
|
108 | + call_helper($subActions[$_GET['sa']]); |
|
109 | + } else { |
|
110 | + call_helper($subActions['admin']); |
|
111 | + } |
|
112 | + } |
|
112 | 113 | |
113 | 114 | /** |
114 | 115 | * This function allows administration of themes and their settings, |
@@ -130,15 +131,16 @@ discard block |
||
130 | 131 | checkSession(); |
131 | 132 | validateToken('admin-tm'); |
132 | 133 | |
133 | - if (isset($_POST['options']['known_themes'])) |
|
134 | - foreach ($_POST['options']['known_themes'] as $key => $id) |
|
134 | + if (isset($_POST['options']['known_themes'])) { |
|
135 | + foreach ($_POST['options']['known_themes'] as $key => $id) |
|
135 | 136 | $_POST['options']['known_themes'][$key] = (int) $id; |
137 | + } else { |
|
138 | + fatal_lang_error('themes_none_selectable', false); |
|
139 | + } |
|
136 | 140 | |
137 | - else |
|
138 | - fatal_lang_error('themes_none_selectable', false); |
|
139 | - |
|
140 | - if (!in_array($_POST['options']['theme_guests'], $_POST['options']['known_themes'])) |
|
141 | - fatal_lang_error('themes_default_selectable', false); |
|
141 | + if (!in_array($_POST['options']['theme_guests'], $_POST['options']['known_themes'])) { |
|
142 | + fatal_lang_error('themes_default_selectable', false); |
|
143 | + } |
|
142 | 144 | |
143 | 145 | // Commit the new settings. |
144 | 146 | updateSettings(array( |
@@ -146,8 +148,9 @@ discard block |
||
146 | 148 | 'theme_guests' => $_POST['options']['theme_guests'], |
147 | 149 | 'knownThemes' => implode(',', $_POST['options']['known_themes']), |
148 | 150 | )); |
149 | - if ((int) $_POST['theme_reset'] == 0 || in_array($_POST['theme_reset'], $_POST['options']['known_themes'])) |
|
150 | - updateMemberData(null, array('id_theme' => (int) $_POST['theme_reset'])); |
|
151 | + if ((int) $_POST['theme_reset'] == 0 || in_array($_POST['theme_reset'], $_POST['options']['known_themes'])) { |
|
152 | + updateMemberData(null, array('id_theme' => (int) $_POST['theme_reset'])); |
|
153 | + } |
|
151 | 154 | |
152 | 155 | redirectexit('action=admin;area=theme;' . $context['session_var'] . '=' . $context['session_id'] . ';sa=admin'); |
153 | 156 | } |
@@ -166,8 +169,9 @@ discard block |
||
166 | 169 | // Look for a non existent theme directory. (ie theme87.) |
167 | 170 | $theme_dir = $boarddir . '/Themes/theme'; |
168 | 171 | $i = 1; |
169 | - while (file_exists($theme_dir . $i)) |
|
170 | - $i++; |
|
172 | + while (file_exists($theme_dir . $i)) { |
|
173 | + $i++; |
|
174 | + } |
|
171 | 175 | |
172 | 176 | $context['new_theme_name'] = 'theme' . $i; |
173 | 177 | |
@@ -189,8 +193,9 @@ discard block |
||
189 | 193 | loadLanguage('Admin'); |
190 | 194 | isAllowedTo('admin_forum'); |
191 | 195 | |
192 | - if (isset($_REQUEST['th'])) |
|
193 | - return SetThemeSettings(); |
|
196 | + if (isset($_REQUEST['th'])) { |
|
197 | + return SetThemeSettings(); |
|
198 | + } |
|
194 | 199 | |
195 | 200 | if (isset($_POST['save'])) |
196 | 201 | { |
@@ -274,12 +279,13 @@ discard block |
||
274 | 279 | $context['themes'] = array(); |
275 | 280 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
276 | 281 | { |
277 | - if (!isset($context['themes'][$row['id_theme']])) |
|
278 | - $context['themes'][$row['id_theme']] = array( |
|
282 | + if (!isset($context['themes'][$row['id_theme']])) { |
|
283 | + $context['themes'][$row['id_theme']] = array( |
|
279 | 284 | 'id' => $row['id_theme'], |
280 | 285 | 'num_default_options' => 0, |
281 | 286 | 'num_members' => 0, |
282 | 287 | ); |
288 | + } |
|
283 | 289 | $context['themes'][$row['id_theme']][$row['variable']] = $row['value']; |
284 | 290 | } |
285 | 291 | $smcFunc['db_free_result']($request); |
@@ -293,8 +299,9 @@ discard block |
||
293 | 299 | 'guest_member' => -1, |
294 | 300 | ) |
295 | 301 | ); |
296 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
297 | - $context['themes'][$row['id_theme']]['num_default_options'] = $row['value']; |
|
302 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
303 | + $context['themes'][$row['id_theme']]['num_default_options'] = $row['value']; |
|
304 | + } |
|
298 | 305 | $smcFunc['db_free_result']($request); |
299 | 306 | |
300 | 307 | // Need to make sure we don't do custom fields. |
@@ -305,8 +312,9 @@ discard block |
||
305 | 312 | ) |
306 | 313 | ); |
307 | 314 | $customFields = array(); |
308 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
309 | - $customFields[] = $row['col_name']; |
|
315 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
316 | + $customFields[] = $row['col_name']; |
|
317 | + } |
|
310 | 318 | $smcFunc['db_free_result']($request); |
311 | 319 | $customFieldsQuery = empty($customFields) ? '' : ('AND variable NOT IN ({array_string:custom_fields})'); |
312 | 320 | |
@@ -321,14 +329,16 @@ discard block |
||
321 | 329 | 'custom_fields' => empty($customFields) ? array() : $customFields, |
322 | 330 | ) |
323 | 331 | ); |
324 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
325 | - $context['themes'][$row['id_theme']]['num_members'] = $row['value']; |
|
332 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
333 | + $context['themes'][$row['id_theme']]['num_members'] = $row['value']; |
|
334 | + } |
|
326 | 335 | $smcFunc['db_free_result']($request); |
327 | 336 | |
328 | 337 | // There has to be a Settings template! |
329 | - foreach ($context['themes'] as $k => $v) |
|
330 | - if (empty($v['theme_dir']) || (!file_exists($v['theme_dir'] . '/Settings.template.php') && empty($v['num_members']))) |
|
338 | + foreach ($context['themes'] as $k => $v) { |
|
339 | + if (empty($v['theme_dir']) || (!file_exists($v['theme_dir'] . '/Settings.template.php') && empty($v['num_members']))) |
|
331 | 340 | unset($context['themes'][$k]); |
341 | + } |
|
332 | 342 | |
333 | 343 | loadTemplate('Themes'); |
334 | 344 | $context['sub_template'] = 'reset_list'; |
@@ -343,16 +353,19 @@ discard block |
||
343 | 353 | checkSession(); |
344 | 354 | validateToken('admin-sto'); |
345 | 355 | |
346 | - if (empty($_POST['options'])) |
|
347 | - $_POST['options'] = array(); |
|
348 | - if (empty($_POST['default_options'])) |
|
349 | - $_POST['default_options'] = array(); |
|
356 | + if (empty($_POST['options'])) { |
|
357 | + $_POST['options'] = array(); |
|
358 | + } |
|
359 | + if (empty($_POST['default_options'])) { |
|
360 | + $_POST['default_options'] = array(); |
|
361 | + } |
|
350 | 362 | |
351 | 363 | // Set up the sql query. |
352 | 364 | $setValues = array(); |
353 | 365 | |
354 | - foreach ($_POST['options'] as $opt => $val) |
|
355 | - $setValues[] = array(-1, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val); |
|
366 | + foreach ($_POST['options'] as $opt => $val) { |
|
367 | + $setValues[] = array(-1, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val); |
|
368 | + } |
|
356 | 369 | |
357 | 370 | $old_settings = array(); |
358 | 371 | foreach ($_POST['default_options'] as $opt => $val) |
@@ -366,8 +379,8 @@ discard block |
||
366 | 379 | if (!empty($setValues)) |
367 | 380 | { |
368 | 381 | // Are there options in non-default themes set that should be cleared? |
369 | - if (!empty($old_settings)) |
|
370 | - $smcFunc['db_query']('', ' |
|
382 | + if (!empty($old_settings)) { |
|
383 | + $smcFunc['db_query']('', ' |
|
371 | 384 | DELETE FROM {db_prefix}themes |
372 | 385 | WHERE id_theme != {int:default_theme} |
373 | 386 | AND id_member = {int:guest_member} |
@@ -378,6 +391,7 @@ discard block |
||
378 | 391 | 'old_settings' => $old_settings, |
379 | 392 | ) |
380 | 393 | ); |
394 | + } |
|
381 | 395 | |
382 | 396 | $smcFunc['db_insert']('replace', |
383 | 397 | '{db_prefix}themes', |
@@ -391,8 +405,7 @@ discard block |
||
391 | 405 | cache_put_data('theme_settings-1', null, 90); |
392 | 406 | |
393 | 407 | redirectexit('action=admin;area=theme;' . $context['session_var'] . '=' . $context['session_id'] . ';sa=reset'); |
394 | - } |
|
395 | - elseif (isset($_POST['submit']) && $_POST['who'] == 1) |
|
408 | + } elseif (isset($_POST['submit']) && $_POST['who'] == 1) |
|
396 | 409 | { |
397 | 410 | checkSession(); |
398 | 411 | validateToken('admin-sto'); |
@@ -405,9 +418,9 @@ discard block |
||
405 | 418 | $old_settings = array(); |
406 | 419 | foreach ($_POST['default_options'] as $opt => $val) |
407 | 420 | { |
408 | - if ($_POST['default_options_master'][$opt] == 0) |
|
409 | - continue; |
|
410 | - elseif ($_POST['default_options_master'][$opt] == 1) |
|
421 | + if ($_POST['default_options_master'][$opt] == 0) { |
|
422 | + continue; |
|
423 | + } elseif ($_POST['default_options_master'][$opt] == 1) |
|
411 | 424 | { |
412 | 425 | // Delete then insert for ease of database compatibility! |
413 | 426 | $smcFunc['db_query']('substring', ' |
@@ -433,8 +446,7 @@ discard block |
||
433 | 446 | ); |
434 | 447 | |
435 | 448 | $old_settings[] = $opt; |
436 | - } |
|
437 | - elseif ($_POST['default_options_master'][$opt] == 2) |
|
449 | + } elseif ($_POST['default_options_master'][$opt] == 2) |
|
438 | 450 | { |
439 | 451 | $smcFunc['db_query']('', ' |
440 | 452 | DELETE FROM {db_prefix}themes |
@@ -449,8 +461,8 @@ discard block |
||
449 | 461 | } |
450 | 462 | |
451 | 463 | // Delete options from other themes. |
452 | - if (!empty($old_settings)) |
|
453 | - $smcFunc['db_query']('', ' |
|
464 | + if (!empty($old_settings)) { |
|
465 | + $smcFunc['db_query']('', ' |
|
454 | 466 | DELETE FROM {db_prefix}themes |
455 | 467 | WHERE id_theme != {int:default_theme} |
456 | 468 | AND id_member > {int:no_member} |
@@ -461,12 +473,13 @@ discard block |
||
461 | 473 | 'old_settings' => $old_settings, |
462 | 474 | ) |
463 | 475 | ); |
476 | + } |
|
464 | 477 | |
465 | 478 | foreach ($_POST['options'] as $opt => $val) |
466 | 479 | { |
467 | - if ($_POST['options_master'][$opt] == 0) |
|
468 | - continue; |
|
469 | - elseif ($_POST['options_master'][$opt] == 1) |
|
480 | + if ($_POST['options_master'][$opt] == 0) { |
|
481 | + continue; |
|
482 | + } elseif ($_POST['options_master'][$opt] == 1) |
|
470 | 483 | { |
471 | 484 | // Delete then insert for ease of database compatibility - again! |
472 | 485 | $smcFunc['db_query']('substring', ' |
@@ -491,8 +504,7 @@ discard block |
||
491 | 504 | 'value' => (is_array($val) ? implode(',', $val) : $val), |
492 | 505 | ) |
493 | 506 | ); |
494 | - } |
|
495 | - elseif ($_POST['options_master'][$opt] == 2) |
|
507 | + } elseif ($_POST['options_master'][$opt] == 2) |
|
496 | 508 | { |
497 | 509 | $smcFunc['db_query']('', ' |
498 | 510 | DELETE FROM {db_prefix}themes |
@@ -509,8 +521,7 @@ discard block |
||
509 | 521 | } |
510 | 522 | |
511 | 523 | redirectexit('action=admin;area=theme;' . $context['session_var'] . '=' . $context['session_id'] . ';sa=reset'); |
512 | - } |
|
513 | - elseif (!empty($_GET['who']) && $_GET['who'] == 2) |
|
524 | + } elseif (!empty($_GET['who']) && $_GET['who'] == 2) |
|
514 | 525 | { |
515 | 526 | checkSession('get'); |
516 | 527 | validateToken('admin-stor', 'request'); |
@@ -525,8 +536,9 @@ discard block |
||
525 | 536 | ) |
526 | 537 | ); |
527 | 538 | $customFields = array(); |
528 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
529 | - $customFields[] = $row['col_name']; |
|
539 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
540 | + $customFields[] = $row['col_name']; |
|
541 | + } |
|
530 | 542 | $smcFunc['db_free_result']($request); |
531 | 543 | } |
532 | 544 | $customFieldsQuery = empty($customFields) ? '' : ('AND variable NOT IN ({array_string:custom_fields})'); |
@@ -578,13 +590,13 @@ discard block |
||
578 | 590 | ) |
579 | 591 | ); |
580 | 592 | $context['theme_options'] = array(); |
581 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
582 | - $context['theme_options'][$row['variable']] = $row['value']; |
|
593 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
594 | + $context['theme_options'][$row['variable']] = $row['value']; |
|
595 | + } |
|
583 | 596 | $smcFunc['db_free_result']($request); |
584 | 597 | |
585 | 598 | $context['theme_options_reset'] = false; |
586 | - } |
|
587 | - else |
|
599 | + } else |
|
588 | 600 | { |
589 | 601 | $context['theme_options'] = array(); |
590 | 602 | $context['theme_options_reset'] = true; |
@@ -593,30 +605,32 @@ discard block |
||
593 | 605 | foreach ($context['options'] as $i => $setting) |
594 | 606 | { |
595 | 607 | // Just skip separators |
596 | - if (!is_array($setting)) |
|
597 | - continue; |
|
608 | + if (!is_array($setting)) { |
|
609 | + continue; |
|
610 | + } |
|
598 | 611 | |
599 | 612 | // Is this disabled? |
600 | 613 | if ($setting['id'] == 'calendar_start_day' && empty($modSettings['cal_enabled'])) |
601 | 614 | { |
602 | 615 | unset($context['options'][$i]); |
603 | 616 | continue; |
604 | - } |
|
605 | - elseif (($setting['id'] == 'topics_per_page' || $setting['id'] == 'messages_per_page') && !empty($modSettings['disableCustomPerPage'])) |
|
617 | + } elseif (($setting['id'] == 'topics_per_page' || $setting['id'] == 'messages_per_page') && !empty($modSettings['disableCustomPerPage'])) |
|
606 | 618 | { |
607 | 619 | unset($context['options'][$i]); |
608 | 620 | continue; |
609 | 621 | } |
610 | 622 | |
611 | - if (!isset($setting['type']) || $setting['type'] == 'bool') |
|
612 | - $context['options'][$i]['type'] = 'checkbox'; |
|
613 | - elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') |
|
614 | - $context['options'][$i]['type'] = 'number'; |
|
615 | - elseif ($setting['type'] == 'string') |
|
616 | - $context['options'][$i]['type'] = 'text'; |
|
623 | + if (!isset($setting['type']) || $setting['type'] == 'bool') { |
|
624 | + $context['options'][$i]['type'] = 'checkbox'; |
|
625 | + } elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') { |
|
626 | + $context['options'][$i]['type'] = 'number'; |
|
627 | + } elseif ($setting['type'] == 'string') { |
|
628 | + $context['options'][$i]['type'] = 'text'; |
|
629 | + } |
|
617 | 630 | |
618 | - if (isset($setting['options'])) |
|
619 | - $context['options'][$i]['type'] = 'list'; |
|
631 | + if (isset($setting['options'])) { |
|
632 | + $context['options'][$i]['type'] = 'list'; |
|
633 | + } |
|
620 | 634 | |
621 | 635 | $context['options'][$i]['value'] = !isset($context['theme_options'][$setting['id']]) ? '' : $context['theme_options'][$setting['id']]; |
622 | 636 | } |
@@ -641,8 +655,9 @@ discard block |
||
641 | 655 | { |
642 | 656 | global $txt, $context, $settings, $modSettings, $smcFunc; |
643 | 657 | |
644 | - if (empty($_GET['th']) && empty($_GET['id'])) |
|
645 | - return ThemeAdmin(); |
|
658 | + if (empty($_GET['th']) && empty($_GET['id'])) { |
|
659 | + return ThemeAdmin(); |
|
660 | + } |
|
646 | 661 | |
647 | 662 | $_GET['th'] = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id']; |
648 | 663 | |
@@ -653,8 +668,9 @@ discard block |
||
653 | 668 | isAllowedTo('admin_forum'); |
654 | 669 | |
655 | 670 | // Validate inputs/user. |
656 | - if (empty($_GET['th'])) |
|
657 | - fatal_lang_error('no_theme', false); |
|
671 | + if (empty($_GET['th'])) { |
|
672 | + fatal_lang_error('no_theme', false); |
|
673 | + } |
|
658 | 674 | |
659 | 675 | // Fetch the smiley sets... |
660 | 676 | $sets = explode(',', 'none,' . $modSettings['smiley_sets_known']); |
@@ -662,8 +678,9 @@ discard block |
||
662 | 678 | $context['smiley_sets'] = array( |
663 | 679 | '' => $txt['smileys_no_default'] |
664 | 680 | ); |
665 | - foreach ($sets as $i => $set) |
|
666 | - $context['smiley_sets'][$set] = $smcFunc['htmlspecialchars']($set_names[$i]); |
|
681 | + foreach ($sets as $i => $set) { |
|
682 | + $context['smiley_sets'][$set] = $smcFunc['htmlspecialchars']($set_names[$i]); |
|
683 | + } |
|
667 | 684 | |
668 | 685 | $old_id = $settings['theme_id']; |
669 | 686 | $old_settings = $settings; |
@@ -688,8 +705,9 @@ discard block |
||
688 | 705 | if (file_exists($settings['theme_dir'] . '/index.template.php')) |
689 | 706 | { |
690 | 707 | $file_contents = implode('', file($settings['theme_dir'] . '/index.template.php')); |
691 | - if (preg_match('~\$settings\[\'theme_variants\'\]\s*=(.+?);~', $file_contents, $matches)) |
|
692 | - eval('global $settings;' . $matches[0]); |
|
708 | + if (preg_match('~\$settings\[\'theme_variants\'\]\s*=(.+?);~', $file_contents, $matches)) { |
|
709 | + eval('global $settings;' . $matches[0]); |
|
710 | + } |
|
693 | 711 | } |
694 | 712 | |
695 | 713 | // Submitting! |
@@ -698,37 +716,45 @@ discard block |
||
698 | 716 | checkSession(); |
699 | 717 | validateToken('admin-sts'); |
700 | 718 | |
701 | - if (empty($_POST['options'])) |
|
702 | - $_POST['options'] = array(); |
|
703 | - if (empty($_POST['default_options'])) |
|
704 | - $_POST['default_options'] = array(); |
|
719 | + if (empty($_POST['options'])) { |
|
720 | + $_POST['options'] = array(); |
|
721 | + } |
|
722 | + if (empty($_POST['default_options'])) { |
|
723 | + $_POST['default_options'] = array(); |
|
724 | + } |
|
705 | 725 | |
706 | 726 | // Make sure items are cast correctly. |
707 | 727 | foreach ($context['theme_settings'] as $item) |
708 | 728 | { |
709 | 729 | // Disregard this item if this is just a separator. |
710 | - if (!is_array($item)) |
|
711 | - continue; |
|
730 | + if (!is_array($item)) { |
|
731 | + continue; |
|
732 | + } |
|
712 | 733 | |
713 | 734 | foreach (array('options', 'default_options') as $option) |
714 | 735 | { |
715 | - if (!isset($_POST[$option][$item['id']])) |
|
716 | - continue; |
|
736 | + if (!isset($_POST[$option][$item['id']])) { |
|
737 | + continue; |
|
738 | + } |
|
717 | 739 | // Checkbox. |
718 | - elseif (empty($item['type'])) |
|
719 | - $_POST[$option][$item['id']] = $_POST[$option][$item['id']] ? 1 : 0; |
|
740 | + elseif (empty($item['type'])) { |
|
741 | + $_POST[$option][$item['id']] = $_POST[$option][$item['id']] ? 1 : 0; |
|
742 | + } |
|
720 | 743 | // Number |
721 | - elseif ($item['type'] == 'number') |
|
722 | - $_POST[$option][$item['id']] = (int) $_POST[$option][$item['id']]; |
|
744 | + elseif ($item['type'] == 'number') { |
|
745 | + $_POST[$option][$item['id']] = (int) $_POST[$option][$item['id']]; |
|
746 | + } |
|
723 | 747 | } |
724 | 748 | } |
725 | 749 | |
726 | 750 | // Set up the sql query. |
727 | 751 | $inserts = array(); |
728 | - foreach ($_POST['options'] as $opt => $val) |
|
729 | - $inserts[] = array(0, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val); |
|
730 | - foreach ($_POST['default_options'] as $opt => $val) |
|
731 | - $inserts[] = array(0, 1, $opt, is_array($val) ? implode(',', $val) : $val); |
|
752 | + foreach ($_POST['options'] as $opt => $val) { |
|
753 | + $inserts[] = array(0, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val); |
|
754 | + } |
|
755 | + foreach ($_POST['default_options'] as $opt => $val) { |
|
756 | + $inserts[] = array(0, 1, $opt, is_array($val) ? implode(',', $val) : $val); |
|
757 | + } |
|
732 | 758 | // If we're actually inserting something.. |
733 | 759 | if (!empty($inserts)) |
734 | 760 | { |
@@ -754,8 +780,9 @@ discard block |
||
754 | 780 | |
755 | 781 | foreach ($settings as $setting => $dummy) |
756 | 782 | { |
757 | - if (!in_array($setting, array('theme_url', 'theme_dir', 'images_url', 'template_dirs'))) |
|
758 | - $settings[$setting] = htmlspecialchars__recursive($settings[$setting]); |
|
783 | + if (!in_array($setting, array('theme_url', 'theme_dir', 'images_url', 'template_dirs'))) { |
|
784 | + $settings[$setting] = htmlspecialchars__recursive($settings[$setting]); |
|
785 | + } |
|
759 | 786 | } |
760 | 787 | |
761 | 788 | $context['settings'] = $context['theme_settings']; |
@@ -764,18 +791,21 @@ discard block |
||
764 | 791 | foreach ($context['settings'] as $i => $setting) |
765 | 792 | { |
766 | 793 | // Separators are dummies, so leave them alone. |
767 | - if (!is_array($setting)) |
|
768 | - continue; |
|
794 | + if (!is_array($setting)) { |
|
795 | + continue; |
|
796 | + } |
|
769 | 797 | |
770 | - if (!isset($setting['type']) || $setting['type'] == 'bool') |
|
771 | - $context['settings'][$i]['type'] = 'checkbox'; |
|
772 | - elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') |
|
773 | - $context['settings'][$i]['type'] = 'number'; |
|
774 | - elseif ($setting['type'] == 'string') |
|
775 | - $context['settings'][$i]['type'] = 'text'; |
|
798 | + if (!isset($setting['type']) || $setting['type'] == 'bool') { |
|
799 | + $context['settings'][$i]['type'] = 'checkbox'; |
|
800 | + } elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') { |
|
801 | + $context['settings'][$i]['type'] = 'number'; |
|
802 | + } elseif ($setting['type'] == 'string') { |
|
803 | + $context['settings'][$i]['type'] = 'text'; |
|
804 | + } |
|
776 | 805 | |
777 | - if (isset($setting['options'])) |
|
778 | - $context['settings'][$i]['type'] = 'list'; |
|
806 | + if (isset($setting['options'])) { |
|
807 | + $context['settings'][$i]['type'] = 'list'; |
|
808 | + } |
|
779 | 809 | |
780 | 810 | $context['settings'][$i]['value'] = !isset($settings[$setting['id']]) ? '' : $settings[$setting['id']]; |
781 | 811 | } |
@@ -828,8 +858,9 @@ discard block |
||
828 | 858 | $themeID = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id']; |
829 | 859 | |
830 | 860 | // You can't delete the default theme! |
831 | - if ($themeID == 1) |
|
832 | - fatal_lang_error('no_access', false); |
|
861 | + if ($themeID == 1) { |
|
862 | + fatal_lang_error('no_access', false); |
|
863 | + } |
|
833 | 864 | |
834 | 865 | $theme_info = get_single_theme($themeID); |
835 | 866 | |
@@ -837,8 +868,9 @@ discard block |
||
837 | 868 | remove_theme($themeID); |
838 | 869 | |
839 | 870 | // And remove all its files and folders too. |
840 | - if (!empty($theme_info) && !empty($theme_info['theme_dir'])) |
|
841 | - remove_dir($theme_info['theme_dir']); |
|
871 | + if (!empty($theme_info) && !empty($theme_info['theme_dir'])) { |
|
872 | + remove_dir($theme_info['theme_dir']); |
|
873 | + } |
|
842 | 874 | |
843 | 875 | // Go back to the list page. |
844 | 876 | redirectexit('action=admin;area=theme;sa=list;' . $context['session_var'] . '=' . $context['session_id'] . ';done=removing'); |
@@ -863,12 +895,14 @@ discard block |
||
863 | 895 | $enableThemes = explode(',', $modSettings['enableThemes']); |
864 | 896 | |
865 | 897 | // Are we disabling it? |
866 | - if (isset($_GET['disabled'])) |
|
867 | - $enableThemes = array_diff($enableThemes, array($themeID)); |
|
898 | + if (isset($_GET['disabled'])) { |
|
899 | + $enableThemes = array_diff($enableThemes, array($themeID)); |
|
900 | + } |
|
868 | 901 | |
869 | 902 | // Nope? then enable it! |
870 | - else |
|
871 | - $enableThemes[] = (string) $themeID; |
|
903 | + else { |
|
904 | + $enableThemes[] = (string) $themeID; |
|
905 | + } |
|
872 | 906 | |
873 | 907 | // Update the setting. |
874 | 908 | $enableThemes = strtr(implode(',', $enableThemes), array(',,' => ',')); |
@@ -903,18 +937,21 @@ discard block |
||
903 | 937 | |
904 | 938 | $_SESSION['id_theme'] = 0; |
905 | 939 | |
906 | - if (isset($_GET['id'])) |
|
907 | - $_GET['th'] = $_GET['id']; |
|
940 | + if (isset($_GET['id'])) { |
|
941 | + $_GET['th'] = $_GET['id']; |
|
942 | + } |
|
908 | 943 | |
909 | 944 | // Saving a variant cause JS doesn't work - pretend it did ;) |
910 | 945 | if (isset($_POST['save'])) |
911 | 946 | { |
912 | 947 | // Which theme? |
913 | - foreach ($_POST['save'] as $k => $v) |
|
914 | - $_GET['th'] = (int) $k; |
|
948 | + foreach ($_POST['save'] as $k => $v) { |
|
949 | + $_GET['th'] = (int) $k; |
|
950 | + } |
|
915 | 951 | |
916 | - if (isset($_POST['vrt'][$k])) |
|
917 | - $_GET['vrt'] = $_POST['vrt'][$k]; |
|
952 | + if (isset($_POST['vrt'][$k])) { |
|
953 | + $_GET['vrt'] = $_POST['vrt'][$k]; |
|
954 | + } |
|
918 | 955 | } |
919 | 956 | |
920 | 957 | // Have we made a decision, or are we just browsing? |
@@ -992,8 +1029,9 @@ discard block |
||
992 | 1029 | else |
993 | 1030 | { |
994 | 1031 | // The forum's default theme is always 0 and we |
995 | - if (isset($_GET['th']) && $_GET['th'] == 0) |
|
996 | - $_GET['th'] = $modSettings['theme_guests']; |
|
1032 | + if (isset($_GET['th']) && $_GET['th'] == 0) { |
|
1033 | + $_GET['th'] = $modSettings['theme_guests']; |
|
1034 | + } |
|
997 | 1035 | |
998 | 1036 | updateMemberData((int) $_REQUEST['u'], array('id_theme' => (int) $_GET['th'])); |
999 | 1037 | |
@@ -1007,8 +1045,9 @@ discard block |
||
1007 | 1045 | ); |
1008 | 1046 | cache_put_data('theme_settings-' . $_GET['th'] . ':' . (int) $_REQUEST['u'], null, 90); |
1009 | 1047 | |
1010 | - if ($user_info['id'] == $_REQUEST['u']) |
|
1011 | - $_SESSION['id_variant'] = 0; |
|
1048 | + if ($user_info['id'] == $_REQUEST['u']) { |
|
1049 | + $_SESSION['id_variant'] = 0; |
|
1050 | + } |
|
1012 | 1051 | } |
1013 | 1052 | |
1014 | 1053 | redirectexit('action=profile;u=' . (int) $_REQUEST['u'] . ';area=theme'); |
@@ -1077,12 +1116,13 @@ discard block |
||
1077 | 1116 | ); |
1078 | 1117 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1079 | 1118 | { |
1080 | - if (!isset($context['available_themes'][$row['id_theme']])) |
|
1081 | - $context['available_themes'][$row['id_theme']] = array( |
|
1119 | + if (!isset($context['available_themes'][$row['id_theme']])) { |
|
1120 | + $context['available_themes'][$row['id_theme']] = array( |
|
1082 | 1121 | 'id' => $row['id_theme'], |
1083 | 1122 | 'selected' => $context['current_theme'] == $row['id_theme'], |
1084 | 1123 | 'num_users' => 0 |
1085 | 1124 | ); |
1125 | + } |
|
1086 | 1126 | $context['available_themes'][$row['id_theme']][$row['variable']] = $row['value']; |
1087 | 1127 | } |
1088 | 1128 | $smcFunc['db_free_result']($request); |
@@ -1095,9 +1135,9 @@ discard block |
||
1095 | 1135 | 'num_users' => 0 |
1096 | 1136 | ); |
1097 | 1137 | $guest_theme = 0; |
1138 | + } else { |
|
1139 | + $guest_theme = $modSettings['theme_guests']; |
|
1098 | 1140 | } |
1099 | - else |
|
1100 | - $guest_theme = $modSettings['theme_guests']; |
|
1101 | 1141 | |
1102 | 1142 | $request = $smcFunc['db_query']('', ' |
1103 | 1143 | SELECT id_theme, COUNT(*) AS the_count |
@@ -1110,15 +1150,17 @@ discard block |
||
1110 | 1150 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1111 | 1151 | { |
1112 | 1152 | // Figure out which theme it is they are REALLY using. |
1113 | - if (!empty($modSettings['knownThemes']) && !in_array($row['id_theme'], explode(',', $modSettings['knownThemes']))) |
|
1114 | - $row['id_theme'] = $guest_theme; |
|
1115 | - elseif (empty($modSettings['theme_allow'])) |
|
1116 | - $row['id_theme'] = $guest_theme; |
|
1153 | + if (!empty($modSettings['knownThemes']) && !in_array($row['id_theme'], explode(',', $modSettings['knownThemes']))) { |
|
1154 | + $row['id_theme'] = $guest_theme; |
|
1155 | + } elseif (empty($modSettings['theme_allow'])) { |
|
1156 | + $row['id_theme'] = $guest_theme; |
|
1157 | + } |
|
1117 | 1158 | |
1118 | - if (isset($context['available_themes'][$row['id_theme']])) |
|
1119 | - $context['available_themes'][$row['id_theme']]['num_users'] += $row['the_count']; |
|
1120 | - else |
|
1121 | - $context['available_themes'][$guest_theme]['num_users'] += $row['the_count']; |
|
1159 | + if (isset($context['available_themes'][$row['id_theme']])) { |
|
1160 | + $context['available_themes'][$row['id_theme']]['num_users'] += $row['the_count']; |
|
1161 | + } else { |
|
1162 | + $context['available_themes'][$guest_theme]['num_users'] += $row['the_count']; |
|
1163 | + } |
|
1122 | 1164 | } |
1123 | 1165 | $smcFunc['db_free_result']($request); |
1124 | 1166 | |
@@ -1137,8 +1179,9 @@ discard block |
||
1137 | 1179 | 'id_member' => isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? array(-1, $context['current_member']) : array(-1), |
1138 | 1180 | ) |
1139 | 1181 | ); |
1140 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1141 | - $variant_preferences[$row['id_theme']] = $row['value']; |
|
1182 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1183 | + $variant_preferences[$row['id_theme']] = $row['value']; |
|
1184 | + } |
|
1142 | 1185 | $smcFunc['db_free_result']($request); |
1143 | 1186 | } |
1144 | 1187 | |
@@ -1149,17 +1192,18 @@ discard block |
||
1149 | 1192 | foreach ($context['available_themes'] as $id_theme => $theme_data) |
1150 | 1193 | { |
1151 | 1194 | // Don't try to load the forum or board default theme's data... it doesn't have any! |
1152 | - if ($id_theme == 0) |
|
1153 | - continue; |
|
1195 | + if ($id_theme == 0) { |
|
1196 | + continue; |
|
1197 | + } |
|
1154 | 1198 | |
1155 | 1199 | // The thumbnail needs the correct path. |
1156 | 1200 | $settings['images_url'] = &$theme_data['images_url']; |
1157 | 1201 | |
1158 | - if (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php')) |
|
1159 | - include($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php'); |
|
1160 | - elseif (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php')) |
|
1161 | - include($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php'); |
|
1162 | - else |
|
1202 | + if (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php')) { |
|
1203 | + include($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php'); |
|
1204 | + } elseif (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php')) { |
|
1205 | + include($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php'); |
|
1206 | + } else |
|
1163 | 1207 | { |
1164 | 1208 | $txt['theme_thumbnail_href'] = $theme_data['images_url'] . '/thumbnail.png'; |
1165 | 1209 | $txt['theme_description'] = ''; |
@@ -1184,15 +1228,17 @@ discard block |
||
1184 | 1228 | loadLanguage('Settings'); |
1185 | 1229 | |
1186 | 1230 | $context['available_themes'][$id_theme]['variants'] = array(); |
1187 | - foreach ($settings['theme_variants'] as $variant) |
|
1188 | - $context['available_themes'][$id_theme]['variants'][$variant] = array( |
|
1231 | + foreach ($settings['theme_variants'] as $variant) { |
|
1232 | + $context['available_themes'][$id_theme]['variants'][$variant] = array( |
|
1189 | 1233 | 'label' => isset($txt['variant_' . $variant]) ? $txt['variant_' . $variant] : $variant, |
1190 | 1234 | 'thumbnail' => !file_exists($theme_data['theme_dir'] . '/images/thumbnail.png') || file_exists($theme_data['theme_dir'] . '/images/thumbnail_' . $variant . '.png') ? $theme_data['images_url'] . '/thumbnail_' . $variant . '.png' : ($theme_data['images_url'] . '/thumbnail.png'), |
1191 | 1235 | ); |
1236 | + } |
|
1192 | 1237 | |
1193 | 1238 | $context['available_themes'][$id_theme]['selected_variant'] = isset($_GET['vrt']) ? $_GET['vrt'] : (!empty($variant_preferences[$id_theme]) ? $variant_preferences[$id_theme] : (!empty($settings['default_variant']) ? $settings['default_variant'] : $settings['theme_variants'][0])); |
1194 | - if (!isset($context['available_themes'][$id_theme]['variants'][$context['available_themes'][$id_theme]['selected_variant']]['thumbnail'])) |
|
1195 | - $context['available_themes'][$id_theme]['selected_variant'] = $settings['theme_variants'][0]; |
|
1239 | + if (!isset($context['available_themes'][$id_theme]['variants'][$context['available_themes'][$id_theme]['selected_variant']]['thumbnail'])) { |
|
1240 | + $context['available_themes'][$id_theme]['selected_variant'] = $settings['theme_variants'][0]; |
|
1241 | + } |
|
1196 | 1242 | |
1197 | 1243 | $context['available_themes'][$id_theme]['thumbnail_href'] = $context['available_themes'][$id_theme]['variants'][$context['available_themes'][$id_theme]['selected_variant']]['thumbnail']; |
1198 | 1244 | // Allow themes to override the text. |
@@ -1208,8 +1254,9 @@ discard block |
||
1208 | 1254 | // As long as we're not doing the default theme... |
1209 | 1255 | if (!isset($_REQUEST['u']) || $_REQUEST['u'] >= 0) |
1210 | 1256 | { |
1211 | - if ($guest_theme != 0) |
|
1212 | - $context['available_themes'][0] = $context['available_themes'][$guest_theme]; |
|
1257 | + if ($guest_theme != 0) { |
|
1258 | + $context['available_themes'][0] = $context['available_themes'][$guest_theme]; |
|
1259 | + } |
|
1213 | 1260 | |
1214 | 1261 | $context['available_themes'][0]['id'] = 0; |
1215 | 1262 | $context['available_themes'][0]['name'] = $txt['theme_forum_default']; |
@@ -1258,14 +1305,16 @@ discard block |
||
1258 | 1305 | $action = $smcFunc['htmlspecialchars'](trim($_GET['do'])); |
1259 | 1306 | |
1260 | 1307 | // Got any info from the specific form? |
1261 | - if (!isset($_POST['save_' . $action])) |
|
1262 | - fatal_lang_error('theme_install_no_action', false); |
|
1308 | + if (!isset($_POST['save_' . $action])) { |
|
1309 | + fatal_lang_error('theme_install_no_action', false); |
|
1310 | + } |
|
1263 | 1311 | |
1264 | 1312 | validateToken('admin-t-' . $action); |
1265 | 1313 | |
1266 | 1314 | // Hopefully the themes directory is writable, or we might have a problem. |
1267 | - if (!is_writable($themedir)) |
|
1268 | - fatal_lang_error('theme_install_write_error', 'critical'); |
|
1315 | + if (!is_writable($themedir)) { |
|
1316 | + fatal_lang_error('theme_install_write_error', 'critical'); |
|
1317 | + } |
|
1269 | 1318 | |
1270 | 1319 | // Call the function and handle the result. |
1271 | 1320 | $result = $subActions[$action](); |
@@ -1280,9 +1329,10 @@ discard block |
||
1280 | 1329 | } |
1281 | 1330 | |
1282 | 1331 | // Nope, show a nice error. |
1283 | - else |
|
1284 | - fatal_lang_error('theme_install_no_action', false); |
|
1285 | -} |
|
1332 | + else { |
|
1333 | + fatal_lang_error('theme_install_no_action', false); |
|
1334 | + } |
|
1335 | + } |
|
1286 | 1336 | |
1287 | 1337 | /** |
1288 | 1338 | * Installs a theme from a theme package. |
@@ -1298,8 +1348,9 @@ discard block |
||
1298 | 1348 | $dirtemp = $themedir . '/temp'; |
1299 | 1349 | |
1300 | 1350 | // Make sure the temp dir doesn't already exist |
1301 | - if (file_exists($dirtemp)) |
|
1302 | - remove_dir($dirtemp); |
|
1351 | + if (file_exists($dirtemp)) { |
|
1352 | + remove_dir($dirtemp); |
|
1353 | + } |
|
1303 | 1354 | |
1304 | 1355 | // Create the temp dir. |
1305 | 1356 | mkdir($dirtemp, 0777); |
@@ -1311,17 +1362,20 @@ discard block |
||
1311 | 1362 | smf_chmod($dirtemp, '0755'); |
1312 | 1363 | |
1313 | 1364 | // How about now? |
1314 | - if (!is_writable($dirtemp)) |
|
1315 | - fatal_lang_error('theme_install_write_error', 'critical'); |
|
1365 | + if (!is_writable($dirtemp)) { |
|
1366 | + fatal_lang_error('theme_install_write_error', 'critical'); |
|
1367 | + } |
|
1316 | 1368 | } |
1317 | 1369 | |
1318 | 1370 | // This happens when the admin session is gone and the user has to login again. |
1319 | - if (!isset($_FILES) || !isset($_FILES['theme_gz']) || empty($_FILES['theme_gz'])) |
|
1320 | - redirectexit('action=admin;area=theme;sa=admin;' . $context['session_var'] . '=' . $context['session_id']); |
|
1371 | + if (!isset($_FILES) || !isset($_FILES['theme_gz']) || empty($_FILES['theme_gz'])) { |
|
1372 | + redirectexit('action=admin;area=theme;sa=admin;' . $context['session_var'] . '=' . $context['session_id']); |
|
1373 | + } |
|
1321 | 1374 | |
1322 | 1375 | // Another error check layer, something went wrong with the upload. |
1323 | - if (isset($_FILES['theme_gz']['error']) && $_FILES['theme_gz']['error'] != 0) |
|
1324 | - fatal_lang_error('theme_install_error_file_' . $_FILES['theme_gz']['error'], false); |
|
1376 | + if (isset($_FILES['theme_gz']['error']) && $_FILES['theme_gz']['error'] != 0) { |
|
1377 | + fatal_lang_error('theme_install_error_file_' . $_FILES['theme_gz']['error'], false); |
|
1378 | + } |
|
1325 | 1379 | |
1326 | 1380 | // Get the theme's name. |
1327 | 1381 | $name = pathinfo($_FILES['theme_gz']['name'], PATHINFO_FILENAME); |
@@ -1352,11 +1406,10 @@ discard block |
||
1352 | 1406 | |
1353 | 1407 | // return all the info. |
1354 | 1408 | return $context['to_install']; |
1409 | + } else { |
|
1410 | + fatal_lang_error('theme_install_error_title', false); |
|
1411 | + } |
|
1355 | 1412 | } |
1356 | - |
|
1357 | - else |
|
1358 | - fatal_lang_error('theme_install_error_title', false); |
|
1359 | -} |
|
1360 | 1413 | |
1361 | 1414 | /** |
1362 | 1415 | * Makes a copy from the default theme, assigns a name for it and installs it. |
@@ -1370,15 +1423,17 @@ discard block |
||
1370 | 1423 | global $forum_version; |
1371 | 1424 | |
1372 | 1425 | // There's gotta be something to work with. |
1373 | - if (!isset($_REQUEST['copy']) || empty($_REQUEST['copy'])) |
|
1374 | - fatal_lang_error('theme_install_error_title', false); |
|
1426 | + if (!isset($_REQUEST['copy']) || empty($_REQUEST['copy'])) { |
|
1427 | + fatal_lang_error('theme_install_error_title', false); |
|
1428 | + } |
|
1375 | 1429 | |
1376 | 1430 | // Get a cleaner version. |
1377 | 1431 | $name = preg_replace('~[^A-Za-z0-9_\- ]~', '', $_REQUEST['copy']); |
1378 | 1432 | |
1379 | 1433 | // Is there a theme already named like this? |
1380 | - if (file_exists($themedir . '/' . $name)) |
|
1381 | - fatal_lang_error('theme_install_already_dir', false); |
|
1434 | + if (file_exists($themedir . '/' . $name)) { |
|
1435 | + fatal_lang_error('theme_install_already_dir', false); |
|
1436 | + } |
|
1382 | 1437 | |
1383 | 1438 | // This is a brand new theme so set all possible values. |
1384 | 1439 | $context['to_install'] = array( |
@@ -1398,8 +1453,9 @@ discard block |
||
1398 | 1453 | |
1399 | 1454 | // Buy some time. |
1400 | 1455 | @set_time_limit(600); |
1401 | - if (function_exists('apache_reset_timeout')) |
|
1402 | - @apache_reset_timeout(); |
|
1456 | + if (function_exists('apache_reset_timeout')) { |
|
1457 | + @apache_reset_timeout(); |
|
1458 | + } |
|
1403 | 1459 | |
1404 | 1460 | // Create subdirectories for css and javascript files. |
1405 | 1461 | mkdir($context['to_install']['theme_dir'] . '/css', 0777); |
@@ -1435,12 +1491,13 @@ discard block |
||
1435 | 1491 | |
1436 | 1492 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1437 | 1493 | { |
1438 | - if ($row['variable'] == 'theme_templates') |
|
1439 | - $theme_templates = $row['value']; |
|
1440 | - elseif ($row['variable'] == 'theme_layers') |
|
1441 | - $theme_layers = $row['value']; |
|
1442 | - else |
|
1443 | - continue; |
|
1494 | + if ($row['variable'] == 'theme_templates') { |
|
1495 | + $theme_templates = $row['value']; |
|
1496 | + } elseif ($row['variable'] == 'theme_layers') { |
|
1497 | + $theme_layers = $row['value']; |
|
1498 | + } else { |
|
1499 | + continue; |
|
1500 | + } |
|
1444 | 1501 | } |
1445 | 1502 | |
1446 | 1503 | $smcFunc['db_free_result']($request); |
@@ -1499,12 +1556,14 @@ discard block |
||
1499 | 1556 | global $themedir, $themeurl, $context; |
1500 | 1557 | |
1501 | 1558 | // Cannot use the theme dir as a theme dir. |
1502 | - if (!isset($_REQUEST['theme_dir']) || empty($_REQUEST['theme_dir']) || rtrim(realpath($_REQUEST['theme_dir']), '/\\') == realpath($themedir)) |
|
1503 | - fatal_lang_error('theme_install_invalid_dir', false); |
|
1559 | + if (!isset($_REQUEST['theme_dir']) || empty($_REQUEST['theme_dir']) || rtrim(realpath($_REQUEST['theme_dir']), '/\\') == realpath($themedir)) { |
|
1560 | + fatal_lang_error('theme_install_invalid_dir', false); |
|
1561 | + } |
|
1504 | 1562 | |
1505 | 1563 | // Check is there is "something" on the dir. |
1506 | - elseif (!is_dir($_REQUEST['theme_dir']) || !file_exists($_REQUEST['theme_dir'] . '/theme_info.xml')) |
|
1507 | - fatal_lang_error('theme_install_error', false); |
|
1564 | + elseif (!is_dir($_REQUEST['theme_dir']) || !file_exists($_REQUEST['theme_dir'] . '/theme_info.xml')) { |
|
1565 | + fatal_lang_error('theme_install_error', false); |
|
1566 | + } |
|
1508 | 1567 | |
1509 | 1568 | $name = basename($_REQUEST['theme_dir']); |
1510 | 1569 | $name = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $name); |
@@ -1548,24 +1607,27 @@ discard block |
||
1548 | 1607 | } |
1549 | 1608 | |
1550 | 1609 | // Any special layers? |
1551 | - if (isset($settings['catch_action']['layers'])) |
|
1552 | - $context['template_layers'] = $settings['catch_action']['layers']; |
|
1610 | + if (isset($settings['catch_action']['layers'])) { |
|
1611 | + $context['template_layers'] = $settings['catch_action']['layers']; |
|
1612 | + } |
|
1553 | 1613 | |
1554 | 1614 | // Any function to call? |
1555 | 1615 | if (isset($settings['catch_action']['function'])) |
1556 | 1616 | { |
1557 | 1617 | $hook = $settings['catch_action']['function']; |
1558 | 1618 | |
1559 | - if (!isset($settings['catch_action']['filename'])) |
|
1560 | - $settings['catch_action']['filename'] = ''; |
|
1619 | + if (!isset($settings['catch_action']['filename'])) { |
|
1620 | + $settings['catch_action']['filename'] = ''; |
|
1621 | + } |
|
1561 | 1622 | |
1562 | 1623 | add_integration_function('integrate_wrap_action', $hook, false, $settings['catch_action']['filename'], false); |
1563 | 1624 | call_integration_hook('integrate_wrap_action'); |
1564 | 1625 | } |
1565 | 1626 | // And finally, the main sub template ;). |
1566 | - if (isset($settings['catch_action']['sub_template'])) |
|
1567 | - $context['sub_template'] = $settings['catch_action']['sub_template']; |
|
1568 | -} |
|
1627 | + if (isset($settings['catch_action']['sub_template'])) { |
|
1628 | + $context['sub_template'] = $settings['catch_action']['sub_template']; |
|
1629 | + } |
|
1630 | + } |
|
1569 | 1631 | |
1570 | 1632 | /** |
1571 | 1633 | * Set an option via javascript. |
@@ -1584,12 +1646,14 @@ discard block |
||
1584 | 1646 | checkSession('get'); |
1585 | 1647 | |
1586 | 1648 | // This good-for-nothing pixel is being used to keep the session alive. |
1587 | - if (empty($_GET['var']) || !isset($_GET['val'])) |
|
1588 | - redirectexit($settings['images_url'] . '/blank.png'); |
|
1649 | + if (empty($_GET['var']) || !isset($_GET['val'])) { |
|
1650 | + redirectexit($settings['images_url'] . '/blank.png'); |
|
1651 | + } |
|
1589 | 1652 | |
1590 | 1653 | // Sorry, guests can't go any further than this. |
1591 | - if ($user_info['is_guest'] || $user_info['id'] == 0) |
|
1592 | - obExit(false); |
|
1654 | + if ($user_info['is_guest'] || $user_info['id'] == 0) { |
|
1655 | + obExit(false); |
|
1656 | + } |
|
1593 | 1657 | |
1594 | 1658 | $reservedVars = array( |
1595 | 1659 | 'actual_theme_url', |
@@ -1612,8 +1676,9 @@ discard block |
||
1612 | 1676 | ); |
1613 | 1677 | |
1614 | 1678 | // Can't change reserved vars. |
1615 | - if (in_array(strtolower($_GET['var']), $reservedVars)) |
|
1616 | - redirectexit($settings['images_url'] . '/blank.png'); |
|
1679 | + if (in_array(strtolower($_GET['var']), $reservedVars)) { |
|
1680 | + redirectexit($settings['images_url'] . '/blank.png'); |
|
1681 | + } |
|
1617 | 1682 | |
1618 | 1683 | // Use a specific theme? |
1619 | 1684 | if (isset($_GET['th']) || isset($_GET['id'])) |
@@ -1629,8 +1694,9 @@ discard block |
||
1629 | 1694 | { |
1630 | 1695 | $options['admin_preferences'] = !empty($options['admin_preferences']) ? smf_json_decode($options['admin_preferences'], true) : array(); |
1631 | 1696 | // New thingy... |
1632 | - if (isset($_GET['admin_key']) && strlen($_GET['admin_key']) < 5) |
|
1633 | - $options['admin_preferences'][$_GET['admin_key']] = $_GET['val']; |
|
1697 | + if (isset($_GET['admin_key']) && strlen($_GET['admin_key']) < 5) { |
|
1698 | + $options['admin_preferences'][$_GET['admin_key']] = $_GET['val']; |
|
1699 | + } |
|
1634 | 1700 | |
1635 | 1701 | // Change the value to be something nice, |
1636 | 1702 | $_GET['val'] = json_encode($options['admin_preferences']); |
@@ -1660,8 +1726,9 @@ discard block |
||
1660 | 1726 | global $context, $scripturl, $boarddir, $smcFunc, $txt; |
1661 | 1727 | |
1662 | 1728 | // @todo Should this be removed? |
1663 | - if (isset($_REQUEST['preview'])) |
|
1664 | - die('die() with fire'); |
|
1729 | + if (isset($_REQUEST['preview'])) { |
|
1730 | + die('die() with fire'); |
|
1731 | + } |
|
1665 | 1732 | |
1666 | 1733 | isAllowedTo('admin_forum'); |
1667 | 1734 | loadTemplate('Themes'); |
@@ -1675,11 +1742,11 @@ discard block |
||
1675 | 1742 | foreach ($context['themes'] as $key => $theme) |
1676 | 1743 | { |
1677 | 1744 | // There has to be a Settings template! |
1678 | - if (!file_exists($theme['theme_dir'] . '/index.template.php') && !file_exists($theme['theme_dir'] . '/css/index.css')) |
|
1679 | - unset($context['themes'][$key]); |
|
1680 | - |
|
1681 | - else |
|
1682 | - $context['themes'][$key]['can_edit_style'] = file_exists($theme['theme_dir'] . '/css/index.css'); |
|
1745 | + if (!file_exists($theme['theme_dir'] . '/index.template.php') && !file_exists($theme['theme_dir'] . '/css/index.css')) { |
|
1746 | + unset($context['themes'][$key]); |
|
1747 | + } else { |
|
1748 | + $context['themes'][$key]['can_edit_style'] = file_exists($theme['theme_dir'] . '/css/index.css'); |
|
1749 | + } |
|
1683 | 1750 | } |
1684 | 1751 | |
1685 | 1752 | $context['sub_template'] = 'edit_list'; |
@@ -1694,22 +1761,24 @@ discard block |
||
1694 | 1761 | $context['theme_id'] = $currentTheme['id']; |
1695 | 1762 | $context['browse_title'] = sprintf($txt['themeadmin_browsing_theme'], $currentTheme['name']); |
1696 | 1763 | |
1697 | - if (!file_exists($currentTheme['theme_dir'] . '/index.template.php') && !file_exists($currentTheme['theme_dir'] . '/css/index.css')) |
|
1698 | - fatal_lang_error('theme_edit_missing', false); |
|
1764 | + if (!file_exists($currentTheme['theme_dir'] . '/index.template.php') && !file_exists($currentTheme['theme_dir'] . '/css/index.css')) { |
|
1765 | + fatal_lang_error('theme_edit_missing', false); |
|
1766 | + } |
|
1699 | 1767 | |
1700 | 1768 | if (!isset($_REQUEST['filename'])) |
1701 | 1769 | { |
1702 | 1770 | if (isset($_GET['directory'])) |
1703 | 1771 | { |
1704 | - if (substr($_GET['directory'], 0, 1) == '.') |
|
1705 | - $_GET['directory'] = ''; |
|
1706 | - else |
|
1772 | + if (substr($_GET['directory'], 0, 1) == '.') { |
|
1773 | + $_GET['directory'] = ''; |
|
1774 | + } else |
|
1707 | 1775 | { |
1708 | 1776 | $_GET['directory'] = preg_replace(array('~^[\./\\:\0\n\r]+~', '~[\\\\]~', '~/[\./]+~'), array('', '/', '/'), $_GET['directory']); |
1709 | 1777 | |
1710 | 1778 | $temp = realpath($currentTheme['theme_dir'] . '/' . $_GET['directory']); |
1711 | - if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) |
|
1712 | - $_GET['directory'] = ''; |
|
1779 | + if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) { |
|
1780 | + $_GET['directory'] = ''; |
|
1781 | + } |
|
1713 | 1782 | } |
1714 | 1783 | } |
1715 | 1784 | |
@@ -1728,37 +1797,39 @@ discard block |
||
1728 | 1797 | 'href' => $scripturl . '?action=admin;area=theme;th=' . $_GET['th'] . ';' . $context['session_var'] . '=' . $context['session_id'] . ';sa=edit;directory=' . $temp, |
1729 | 1798 | 'size' => '', |
1730 | 1799 | )); |
1800 | + } else { |
|
1801 | + $context['theme_files'] = get_file_listing($currentTheme['theme_dir'], ''); |
|
1731 | 1802 | } |
1732 | - else |
|
1733 | - $context['theme_files'] = get_file_listing($currentTheme['theme_dir'], ''); |
|
1734 | 1803 | |
1735 | 1804 | $context['sub_template'] = 'edit_browse'; |
1736 | 1805 | |
1737 | 1806 | return; |
1738 | - } |
|
1739 | - else |
|
1807 | + } else |
|
1740 | 1808 | { |
1741 | - if (substr($_REQUEST['filename'], 0, 1) == '.') |
|
1742 | - $_REQUEST['filename'] = ''; |
|
1743 | - else |
|
1809 | + if (substr($_REQUEST['filename'], 0, 1) == '.') { |
|
1810 | + $_REQUEST['filename'] = ''; |
|
1811 | + } else |
|
1744 | 1812 | { |
1745 | 1813 | $_REQUEST['filename'] = preg_replace(array('~^[\./\\:\0\n\r]+~', '~[\\\\]~', '~/[\./]+~'), array('', '/', '/'), $_REQUEST['filename']); |
1746 | 1814 | |
1747 | 1815 | $temp = realpath($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']); |
1748 | - if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) |
|
1749 | - $_REQUEST['filename'] = ''; |
|
1816 | + if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) { |
|
1817 | + $_REQUEST['filename'] = ''; |
|
1818 | + } |
|
1750 | 1819 | } |
1751 | 1820 | |
1752 | - if (empty($_REQUEST['filename'])) |
|
1753 | - fatal_lang_error('theme_edit_missing', false); |
|
1821 | + if (empty($_REQUEST['filename'])) { |
|
1822 | + fatal_lang_error('theme_edit_missing', false); |
|
1823 | + } |
|
1754 | 1824 | } |
1755 | 1825 | |
1756 | 1826 | if (isset($_POST['save'])) |
1757 | 1827 | { |
1758 | 1828 | if (checkSession('post', '', false) == '' && validateToken('admin-te-' . md5($_GET['th'] . '-' . $_REQUEST['filename']), 'post', false) == true) |
1759 | 1829 | { |
1760 | - if (is_array($_POST['entire_file'])) |
|
1761 | - $_POST['entire_file'] = implode("\n", $_POST['entire_file']); |
|
1830 | + if (is_array($_POST['entire_file'])) { |
|
1831 | + $_POST['entire_file'] = implode("\n", $_POST['entire_file']); |
|
1832 | + } |
|
1762 | 1833 | |
1763 | 1834 | $_POST['entire_file'] = rtrim(strtr($_POST['entire_file'], array("\r" => '', ' ' => "\t"))); |
1764 | 1835 | |
@@ -1770,10 +1841,11 @@ discard block |
||
1770 | 1841 | fclose($fp); |
1771 | 1842 | |
1772 | 1843 | $error = @file_get_contents($currentTheme['theme_url'] . '/tmp_' . session_id() . '.php'); |
1773 | - if (preg_match('~ <b>(\d+)</b><br( /)?' . '>$~i', $error) != 0) |
|
1774 | - $error_file = $currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php'; |
|
1775 | - else |
|
1776 | - unlink($currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php'); |
|
1844 | + if (preg_match('~ <b>(\d+)</b><br( /)?' . '>$~i', $error) != 0) { |
|
1845 | + $error_file = $currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php'; |
|
1846 | + } else { |
|
1847 | + unlink($currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php'); |
|
1848 | + } |
|
1777 | 1849 | } |
1778 | 1850 | |
1779 | 1851 | if (!isset($error_file)) |
@@ -1794,10 +1866,11 @@ discard block |
||
1794 | 1866 | $context['sub_template'] = 'edit_file'; |
1795 | 1867 | |
1796 | 1868 | // Recycle the submitted data. |
1797 | - if (is_array($_POST['entire_file'])) |
|
1798 | - $context['entire_file'] = $smcFunc['htmlspecialchars'](implode("\n", $_POST['entire_file'])); |
|
1799 | - else |
|
1800 | - $context['entire_file'] = $smcFunc['htmlspecialchars']($_POST['entire_file']); |
|
1869 | + if (is_array($_POST['entire_file'])) { |
|
1870 | + $context['entire_file'] = $smcFunc['htmlspecialchars'](implode("\n", $_POST['entire_file'])); |
|
1871 | + } else { |
|
1872 | + $context['entire_file'] = $smcFunc['htmlspecialchars']($_POST['entire_file']); |
|
1873 | + } |
|
1801 | 1874 | |
1802 | 1875 | $context['edit_filename'] = $smcFunc['htmlspecialchars']($_POST['filename']); |
1803 | 1876 | |
@@ -1820,17 +1893,17 @@ discard block |
||
1820 | 1893 | $context['sub_template'] = 'edit_style'; |
1821 | 1894 | |
1822 | 1895 | $context['entire_file'] = $smcFunc['htmlspecialchars'](strtr(file_get_contents($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']), array("\t" => ' '))); |
1823 | - } |
|
1824 | - elseif (substr($_REQUEST['filename'], -13) == '.template.php') |
|
1896 | + } elseif (substr($_REQUEST['filename'], -13) == '.template.php') |
|
1825 | 1897 | { |
1826 | 1898 | $context['sub_template'] = 'edit_template'; |
1827 | 1899 | |
1828 | - if (!isset($error_file)) |
|
1829 | - $file_data = file($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']); |
|
1830 | - else |
|
1900 | + if (!isset($error_file)) { |
|
1901 | + $file_data = file($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']); |
|
1902 | + } else |
|
1831 | 1903 | { |
1832 | - if (preg_match('~(<b>.+?</b>:.+?<b>).+?(</b>.+?<b>\d+</b>)<br( /)?' . '>$~i', $error, $match) != 0) |
|
1833 | - $context['parse_error'] = $match[1] . $_REQUEST['filename'] . $match[2]; |
|
1904 | + if (preg_match('~(<b>.+?</b>:.+?<b>).+?(</b>.+?<b>\d+</b>)<br( /)?' . '>$~i', $error, $match) != 0) { |
|
1905 | + $context['parse_error'] = $match[1] . $_REQUEST['filename'] . $match[2]; |
|
1906 | + } |
|
1834 | 1907 | $file_data = file($error_file); |
1835 | 1908 | unlink($error_file); |
1836 | 1909 | } |
@@ -1844,8 +1917,9 @@ discard block |
||
1844 | 1917 | // Try to format the functions a little nicer... |
1845 | 1918 | $context['file_parts'][$j]['data'] = trim($context['file_parts'][$j]['data']) . "\n"; |
1846 | 1919 | |
1847 | - if (empty($context['file_parts'][$j]['lines'])) |
|
1848 | - unset($context['file_parts'][$j]); |
|
1920 | + if (empty($context['file_parts'][$j]['lines'])) { |
|
1921 | + unset($context['file_parts'][$j]); |
|
1922 | + } |
|
1849 | 1923 | $context['file_parts'][++$j] = array('lines' => 0, 'line' => $i + 1, 'data' => ''); |
1850 | 1924 | } |
1851 | 1925 | |
@@ -1854,8 +1928,7 @@ discard block |
||
1854 | 1928 | } |
1855 | 1929 | |
1856 | 1930 | $context['entire_file'] = $smcFunc['htmlspecialchars'](strtr(implode('', $file_data), array("\t" => ' '))); |
1857 | - } |
|
1858 | - else |
|
1931 | + } else |
|
1859 | 1932 | { |
1860 | 1933 | $context['sub_template'] = 'edit_file'; |
1861 | 1934 | |
@@ -1881,8 +1954,9 @@ discard block |
||
1881 | 1954 | |
1882 | 1955 | $_GET['th'] = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id']; |
1883 | 1956 | |
1884 | - if (empty($_GET['th'])) |
|
1885 | - fatal_lang_error('theme_install_invalid_id'); |
|
1957 | + if (empty($_GET['th'])) { |
|
1958 | + fatal_lang_error('theme_install_invalid_id'); |
|
1959 | + } |
|
1886 | 1960 | |
1887 | 1961 | // Get the theme info. |
1888 | 1962 | $theme = get_single_theme($_GET['th']); |
@@ -1890,25 +1964,24 @@ discard block |
||
1890 | 1964 | |
1891 | 1965 | if (isset($_REQUEST['template']) && preg_match('~[\./\\\\:\0]~', $_REQUEST['template']) == 0) |
1892 | 1966 | { |
1893 | - if (file_exists($settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php')) |
|
1894 | - $filename = $settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php'; |
|
1895 | - |
|
1896 | - else |
|
1897 | - fatal_lang_error('no_access', false); |
|
1967 | + if (file_exists($settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php')) { |
|
1968 | + $filename = $settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php'; |
|
1969 | + } else { |
|
1970 | + fatal_lang_error('no_access', false); |
|
1971 | + } |
|
1898 | 1972 | |
1899 | 1973 | $fp = fopen($theme['theme_dir'] . '/' . $_REQUEST['template'] . '.template.php', 'w'); |
1900 | 1974 | fwrite($fp, file_get_contents($filename)); |
1901 | 1975 | fclose($fp); |
1902 | 1976 | |
1903 | 1977 | redirectexit('action=admin;area=theme;th=' . $context['theme_id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . ';sa=copy'); |
1904 | - } |
|
1905 | - elseif (isset($_REQUEST['lang_file']) && preg_match('~^[^\./\\\\:\0]\.[^\./\\\\:\0]$~', $_REQUEST['lang_file']) != 0) |
|
1978 | + } elseif (isset($_REQUEST['lang_file']) && preg_match('~^[^\./\\\\:\0]\.[^\./\\\\:\0]$~', $_REQUEST['lang_file']) != 0) |
|
1906 | 1979 | { |
1907 | - if (file_exists($settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php')) |
|
1908 | - $filename = $settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php'; |
|
1909 | - |
|
1910 | - else |
|
1911 | - fatal_lang_error('no_access', false); |
|
1980 | + if (file_exists($settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php')) { |
|
1981 | + $filename = $settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php'; |
|
1982 | + } else { |
|
1983 | + fatal_lang_error('no_access', false); |
|
1984 | + } |
|
1912 | 1985 | |
1913 | 1986 | $fp = fopen($theme['theme_dir'] . '/languages/' . $_REQUEST['lang_file'] . '.php', 'w'); |
1914 | 1987 | fwrite($fp, file_get_contents($filename)); |
@@ -1923,16 +1996,18 @@ discard block |
||
1923 | 1996 | $dir = dir($settings['default_theme_dir']); |
1924 | 1997 | while ($entry = $dir->read()) |
1925 | 1998 | { |
1926 | - if (substr($entry, -13) == '.template.php') |
|
1927 | - $templates[] = substr($entry, 0, -13); |
|
1999 | + if (substr($entry, -13) == '.template.php') { |
|
2000 | + $templates[] = substr($entry, 0, -13); |
|
2001 | + } |
|
1928 | 2002 | } |
1929 | 2003 | $dir->close(); |
1930 | 2004 | |
1931 | 2005 | $dir = dir($settings['default_theme_dir'] . '/languages'); |
1932 | 2006 | while ($entry = $dir->read()) |
1933 | 2007 | { |
1934 | - if (preg_match('~^([^\.]+\.[^\.]+)\.php$~', $entry, $matches)) |
|
1935 | - $lang_files[] = $matches[1]; |
|
2008 | + if (preg_match('~^([^\.]+\.[^\.]+)\.php$~', $entry, $matches)) { |
|
2009 | + $lang_files[] = $matches[1]; |
|
2010 | + } |
|
1936 | 2011 | } |
1937 | 2012 | $dir->close(); |
1938 | 2013 | |
@@ -1940,21 +2015,23 @@ discard block |
||
1940 | 2015 | natcasesort($lang_files); |
1941 | 2016 | |
1942 | 2017 | $context['available_templates'] = array(); |
1943 | - foreach ($templates as $template) |
|
1944 | - $context['available_templates'][$template] = array( |
|
2018 | + foreach ($templates as $template) { |
|
2019 | + $context['available_templates'][$template] = array( |
|
1945 | 2020 | 'filename' => $template . '.template.php', |
1946 | 2021 | 'value' => $template, |
1947 | 2022 | 'already_exists' => false, |
1948 | 2023 | 'can_copy' => is_writable($theme['theme_dir']), |
1949 | 2024 | ); |
2025 | + } |
|
1950 | 2026 | $context['available_language_files'] = array(); |
1951 | - foreach ($lang_files as $file) |
|
1952 | - $context['available_language_files'][$file] = array( |
|
2027 | + foreach ($lang_files as $file) { |
|
2028 | + $context['available_language_files'][$file] = array( |
|
1953 | 2029 | 'filename' => $file . '.php', |
1954 | 2030 | 'value' => $file, |
1955 | 2031 | 'already_exists' => false, |
1956 | 2032 | 'can_copy' => file_exists($theme['theme_dir'] . '/languages') ? is_writable($theme['theme_dir'] . '/languages') : is_writable($theme['theme_dir']), |
1957 | 2033 | ); |
2034 | + } |
|
1958 | 2035 | |
1959 | 2036 | $dir = dir($theme['theme_dir']); |
1960 | 2037 | while ($entry = $dir->read()) |
@@ -645,12 +645,12 @@ |
||
645 | 645 | </dd>'; |
646 | 646 | } |
647 | 647 | // A Textarea? |
648 | - elseif ($setting['type'] == 'textarea') |
|
648 | + elseif ($setting['type'] == 'textarea') |
|
649 | 649 | { |
650 | 650 | echo ' |
651 | 651 | <dd> |
652 | 652 | <textarea rows="4" style="width: 95%;" cols="40" name="', !empty($setting['default']) ? 'default_' : '', 'options[', $setting['id'], ']" id="', $setting['id'], '">', $setting['value'], '</textarea>'; |
653 | - echo ' |
|
653 | + echo ' |
|
654 | 654 | </dd>'; |
655 | 655 | } |
656 | 656 | // A regular input box, then? |
@@ -54,9 +54,10 @@ discard block |
||
54 | 54 | <dd> |
55 | 55 | <div id="known_themes_list">'; |
56 | 56 | |
57 | - foreach ($context['themes'] as $theme) |
|
58 | - echo ' |
|
57 | + foreach ($context['themes'] as $theme) { |
|
58 | + echo ' |
|
59 | 59 | <label for="options-known_themes_', $theme['id'], '"><input type="checkbox" name="options[known_themes][]" id="options-known_themes_', $theme['id'], '" value="', $theme['id'], '"', $theme['known'] ? ' checked' : '', ' class="input_check"> ', $theme['name'], '</label><br>'; |
60 | + } |
|
60 | 61 | |
61 | 62 | echo ' |
62 | 63 | </div> |
@@ -73,9 +74,10 @@ discard block |
||
73 | 74 | <select name="options[theme_guests]" id="theme_guests">'; |
74 | 75 | |
75 | 76 | // Put an option for each theme in the select box. |
76 | - foreach ($context['themes'] as $theme) |
|
77 | - echo ' |
|
77 | + foreach ($context['themes'] as $theme) { |
|
78 | + echo ' |
|
78 | 79 | <option value="', $theme['id'], '"', $modSettings['theme_guests'] == $theme['id'] ? ' selected' : '', '>', $theme['name'], '</option>'; |
80 | + } |
|
79 | 81 | |
80 | 82 | echo ' |
81 | 83 | </select> |
@@ -90,9 +92,10 @@ discard block |
||
90 | 92 | <option value="0">', $txt['theme_forum_default'], '</option>'; |
91 | 93 | |
92 | 94 | // Same thing, this time for changing the theme of everyone. |
93 | - foreach ($context['themes'] as $theme) |
|
94 | - echo ' |
|
95 | + foreach ($context['themes'] as $theme) { |
|
96 | + echo ' |
|
95 | 97 | <option value="', $theme['id'], '">', $theme['name'], '</option>'; |
98 | + } |
|
96 | 99 | |
97 | 100 | echo ' |
98 | 101 | </select> |
@@ -189,11 +192,12 @@ discard block |
||
189 | 192 | global $context, $scripturl, $txt; |
190 | 193 | |
191 | 194 | // Show a nice confirmation message. |
192 | - if (isset($_GET['done'])) |
|
193 | - echo ' |
|
195 | + if (isset($_GET['done'])) { |
|
196 | + echo ' |
|
194 | 197 | <div class="infobox"> |
195 | 198 | ', $txt['theme_confirmed_' . $_GET['done']], ' |
196 | 199 | </div>'; |
200 | + } |
|
197 | 201 | |
198 | 202 | echo ' |
199 | 203 | <div id="admincenter">'; |
@@ -356,11 +360,12 @@ discard block |
||
356 | 360 | if (empty($setting) || !is_array($setting)) |
357 | 361 | { |
358 | 362 | // Insert a separator (unless this is the first item in the list) |
359 | - if ($i !== $first_option_key) |
|
360 | - echo ' |
|
363 | + if ($i !== $first_option_key) { |
|
364 | + echo ' |
|
361 | 365 | </dl> |
362 | 366 | <hr> |
363 | 367 | <dl class="settings">'; |
368 | + } |
|
364 | 369 | |
365 | 370 | // Should we give a name to this section? |
366 | 371 | if (is_string($setting) && !empty($setting)) |
@@ -368,9 +373,9 @@ discard block |
||
368 | 373 | $titled_section = true; |
369 | 374 | echo ' |
370 | 375 | <dt><b>' . $setting . '</b></dt><dd></dd>'; |
376 | + } else { |
|
377 | + $titled_section = false; |
|
371 | 378 | } |
372 | - else |
|
373 | - $titled_section = false; |
|
374 | 379 | |
375 | 380 | continue; |
376 | 381 | } |
@@ -379,19 +384,21 @@ discard block |
||
379 | 384 | <dt ', $context['theme_options_reset'] ? 'style="width:50%"' : '', '>'; |
380 | 385 | |
381 | 386 | // Show the change option box ? |
382 | - if ($context['theme_options_reset']) |
|
383 | - echo ' |
|
387 | + if ($context['theme_options_reset']) { |
|
388 | + echo ' |
|
384 | 389 | <span class="floatleft"><select name="', !empty($setting['default']) ? 'default_' : '', 'options_master[', $setting['id'], ']" onchange="this.form.options_', $setting['id'], '.disabled = this.selectedIndex != 1;"> |
385 | 390 | <option value="0" selected>', $txt['themeadmin_reset_options_none'], '</option> |
386 | 391 | <option value="1">', $txt['themeadmin_reset_options_change'], '</option> |
387 | 392 | <option value="2">', $txt['themeadmin_reset_options_default'], '</option> |
388 | 393 | </select> </span>'; |
394 | + } |
|
389 | 395 | |
390 | 396 | echo ' |
391 | 397 | <label for="options_', $setting['id'], '">', !$titled_section ? '<b>' : '', $setting['label'], !$titled_section ? '</b>' : '', '</label>'; |
392 | - if (isset($setting['description'])) |
|
393 | - echo ' |
|
398 | + if (isset($setting['description'])) { |
|
399 | + echo ' |
|
394 | 400 | <br><span class="smalltext">', $setting['description'], '</span>'; |
401 | + } |
|
395 | 402 | echo ' |
396 | 403 | </dt>'; |
397 | 404 | |
@@ -433,13 +440,11 @@ discard block |
||
433 | 440 | |
434 | 441 | echo ' |
435 | 442 | <input type="number"', $min . $max . $step; |
436 | - } |
|
437 | - else if (isset($setting['type']) && $setting['type'] == 'url') |
|
443 | + } else if (isset($setting['type']) && $setting['type'] == 'url') |
|
438 | 444 | { |
439 | 445 | echo' |
440 | 446 | <input type="url"'; |
441 | - } |
|
442 | - else |
|
447 | + } else |
|
443 | 448 | { |
444 | 449 | echo ' |
445 | 450 | <input type="text"'; |
@@ -483,8 +488,8 @@ discard block |
||
483 | 488 | <br>'; |
484 | 489 | |
485 | 490 | // @todo Why can't I edit the default theme popup. |
486 | - if ($context['theme_settings']['theme_id'] != 1) |
|
487 | - echo ' |
|
491 | + if ($context['theme_settings']['theme_id'] != 1) { |
|
492 | + echo ' |
|
488 | 493 | <div class="cat_bar"> |
489 | 494 | <h3 class="catbg config_hd"> |
490 | 495 | ', $txt['theme_edit'], ' |
@@ -500,6 +505,7 @@ discard block |
||
500 | 505 | </li> |
501 | 506 | </ul> |
502 | 507 | </div>'; |
508 | + } |
|
503 | 509 | |
504 | 510 | echo ' |
505 | 511 | <div class="cat_bar"> |
@@ -553,9 +559,10 @@ discard block |
||
553 | 559 | <dd> |
554 | 560 | <select id="variant" name="options[default_variant]" onchange="changeVariant(this.value)">'; |
555 | 561 | |
556 | - foreach ($context['theme_variants'] as $key => $variant) |
|
557 | - echo ' |
|
562 | + foreach ($context['theme_variants'] as $key => $variant) { |
|
563 | + echo ' |
|
558 | 564 | <option value="', $key, '"', $context['default_variant'] == $key ? ' selected' : '', '>', $variant['label'], '</option>'; |
565 | + } |
|
559 | 566 | |
560 | 567 | echo ' |
561 | 568 | </select> |
@@ -590,11 +597,12 @@ discard block |
||
590 | 597 | if (empty($setting) || !is_array($setting)) |
591 | 598 | { |
592 | 599 | // We don't need a separator before the first list element |
593 | - if ($i !== $first_setting_key) |
|
594 | - echo ' |
|
600 | + if ($i !== $first_setting_key) { |
|
601 | + echo ' |
|
595 | 602 | </dl> |
596 | 603 | <hr> |
597 | 604 | <dl class="settings">'; |
605 | + } |
|
598 | 606 | |
599 | 607 | // Add a fake heading? |
600 | 608 | if (is_string($setting) && !empty($setting)) |
@@ -602,9 +610,9 @@ discard block |
||
602 | 610 | $titled_section = true; |
603 | 611 | echo ' |
604 | 612 | <dt><b>' . $setting . '</b></dt><dd></dd>'; |
613 | + } else { |
|
614 | + $titled_section = false; |
|
605 | 615 | } |
606 | - else |
|
607 | - $titled_section = false; |
|
608 | 616 | |
609 | 617 | continue; |
610 | 618 | } |
@@ -613,9 +621,10 @@ discard block |
||
613 | 621 | <dt> |
614 | 622 | <label for="', $setting['id'], '">', !$titled_section ? '<b>' : '', $setting['label'], !$titled_section ? '</b>' : '', '</label>:'; |
615 | 623 | |
616 | - if (isset($setting['description'])) |
|
617 | - echo '<br> |
|
624 | + if (isset($setting['description'])) { |
|
625 | + echo '<br> |
|
618 | 626 | <span class="smalltext">', $setting['description'], '</span>'; |
627 | + } |
|
619 | 628 | |
620 | 629 | echo ' |
621 | 630 | </dt>'; |
@@ -636,9 +645,10 @@ discard block |
||
636 | 645 | <dd> |
637 | 646 | <select name="', !empty($setting['default']) ? 'default_' : '', 'options[', $setting['id'], ']" id="', $setting['id'], '">'; |
638 | 647 | |
639 | - foreach ($setting['options'] as $value => $label) |
|
640 | - echo ' |
|
648 | + foreach ($setting['options'] as $value => $label) { |
|
649 | + echo ' |
|
641 | 650 | <option value="', $value, '"', $value == $setting['value'] ? ' selected' : '', '>', $label, '</option>'; |
651 | + } |
|
642 | 652 | |
643 | 653 | echo ' |
644 | 654 | </select> |
@@ -667,13 +677,11 @@ discard block |
||
667 | 677 | |
668 | 678 | echo ' |
669 | 679 | <input type="number"', $min . $max . $step; |
670 | - } |
|
671 | - else if (isset($setting['type']) && $setting['type'] == 'url') |
|
680 | + } else if (isset($setting['type']) && $setting['type'] == 'url') |
|
672 | 681 | { |
673 | 682 | echo' |
674 | 683 | <input type="url"'; |
675 | - } |
|
676 | - else |
|
684 | + } else |
|
677 | 685 | { |
678 | 686 | echo ' |
679 | 687 | <input type="text"'; |
@@ -826,21 +834,23 @@ discard block |
||
826 | 834 | <div class="windowbg">'; |
827 | 835 | |
828 | 836 | // Oops! there was an error :( |
829 | - if (!empty($context['error_message'])) |
|
830 | - echo ' |
|
837 | + if (!empty($context['error_message'])) { |
|
838 | + echo ' |
|
831 | 839 | <p> |
832 | 840 | ', $context['error_message'], ' |
833 | 841 | </p>'; |
842 | + } |
|
834 | 843 | |
835 | 844 | // Not much to show except a link back... |
836 | - else |
|
837 | - echo ' |
|
845 | + else { |
|
846 | + echo ' |
|
838 | 847 | <p> |
839 | 848 | <a href="', $scripturl, '?action=admin;area=theme;sa=list;th=', $context['installed_theme']['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $context['installed_theme']['name'], '</a> ', $txt['theme_' . (isset($context['installed_theme']['updated']) ? 'updated' : 'installed') . '_message'], ' |
840 | 849 | </p> |
841 | 850 | <p> |
842 | 851 | <a href="', $scripturl, '?action=admin;area=theme;sa=admin;', $context['session_var'], '=', $context['session_id'], '">', $txt['back'], '</a> |
843 | 852 | </p>'; |
853 | + } |
|
844 | 854 | |
845 | 855 | echo ' |
846 | 856 | </div> |
@@ -907,10 +917,11 @@ discard block |
||
907 | 917 | <span class="floatleft">', $template['filename'], $template['already_exists'] ? ' <span class="error">(' . $txt['themeadmin_edit_exists'] . ')</span>' : '', '</span> |
908 | 918 | <span class="floatright">'; |
909 | 919 | |
910 | - if ($template['can_copy']) |
|
911 | - echo '<a href="', $scripturl, '?action=admin;area=theme;th=', $context['theme_id'], ';', $context['session_var'], '=', $context['session_id'], ';sa=copy;template=', $template['value'], '" data-confirm="', $template['already_exists'] ? $txt['themeadmin_edit_overwrite_confirm'] : $txt['themeadmin_edit_copy_confirm'], '" class="you_sure">', $txt['themeadmin_edit_do_copy'], '</a>'; |
|
912 | - else |
|
913 | - echo $txt['themeadmin_edit_no_copy']; |
|
920 | + if ($template['can_copy']) { |
|
921 | + echo '<a href="', $scripturl, '?action=admin;area=theme;th=', $context['theme_id'], ';', $context['session_var'], '=', $context['session_id'], ';sa=copy;template=', $template['value'], '" data-confirm="', $template['already_exists'] ? $txt['themeadmin_edit_overwrite_confirm'] : $txt['themeadmin_edit_copy_confirm'], '" class="you_sure">', $txt['themeadmin_edit_do_copy'], '</a>'; |
|
922 | + } else { |
|
923 | + echo $txt['themeadmin_edit_no_copy']; |
|
924 | + } |
|
914 | 925 | |
915 | 926 | echo ' |
916 | 927 | </span> |
@@ -933,11 +944,12 @@ discard block |
||
933 | 944 | echo ' |
934 | 945 | <div id="admincenter">'; |
935 | 946 | |
936 | - if (!empty($context['browse_title'])) |
|
937 | - echo ' |
|
947 | + if (!empty($context['browse_title'])) { |
|
948 | + echo ' |
|
938 | 949 | <div class="cat_bar"> |
939 | 950 | <h3 class="catbg">', $context['browse_title'], '</h3> |
940 | 951 | </div>'; |
952 | + } |
|
941 | 953 | |
942 | 954 | echo ' |
943 | 955 | <table class="table_grid tborder"> |
@@ -957,14 +969,13 @@ discard block |
||
957 | 969 | <tr class="windowbg"> |
958 | 970 | <td>'; |
959 | 971 | |
960 | - if ($file['is_editable']) |
|
961 | - echo '<a href="', $file['href'], '"', $file['is_template'] ? ' style="font-weight: bold;"' : '', '>', $file['filename'], '</a>'; |
|
962 | - |
|
963 | - elseif ($file['is_directory']) |
|
964 | - echo '<a href="', $file['href'], '" class="is_directory"><span class="generic_icons folder"></span>', $file['filename'], '</a>'; |
|
965 | - |
|
966 | - else |
|
967 | - echo $file['filename']; |
|
972 | + if ($file['is_editable']) { |
|
973 | + echo '<a href="', $file['href'], '"', $file['is_template'] ? ' style="font-weight: bold;"' : '', '>', $file['filename'], '</a>'; |
|
974 | + } elseif ($file['is_directory']) { |
|
975 | + echo '<a href="', $file['href'], '" class="is_directory"><span class="generic_icons folder"></span>', $file['filename'], '</a>'; |
|
976 | + } else { |
|
977 | + echo $file['filename']; |
|
978 | + } |
|
968 | 979 | |
969 | 980 | echo ' |
970 | 981 | </td> |
@@ -986,11 +997,12 @@ discard block |
||
986 | 997 | { |
987 | 998 | global $context, $settings, $scripturl, $txt; |
988 | 999 | |
989 | - if ($context['session_error']) |
|
990 | - echo ' |
|
1000 | + if ($context['session_error']) { |
|
1001 | + echo ' |
|
991 | 1002 | <div class="errorbox"> |
992 | 1003 | ', $txt['error_session_timeout'], ' |
993 | 1004 | </div>'; |
1005 | + } |
|
994 | 1006 | |
995 | 1007 | // From now on no one can complain that editing css is difficult. If you disagree, go to www.w3schools.com. |
996 | 1008 | echo ' |
@@ -1053,17 +1065,18 @@ discard block |
||
1053 | 1065 | try |
1054 | 1066 | { |
1055 | 1067 | '; |
1056 | - if (isBrowser('is_ie')) |
|
1057 | - echo ' |
|
1068 | + if (isBrowser('is_ie')) { |
|
1069 | + echo ' |
|
1058 | 1070 | var sheets = frames["css_preview_box"].document.styleSheets; |
1059 | 1071 | for (var j = 0; j < sheets.length; j++) |
1060 | 1072 | { |
1061 | 1073 | if (sheets[j].id == "css_preview_box") |
1062 | 1074 | sheets[j].cssText = document.forms.stylesheetForm.entire_file.value; |
1063 | 1075 | }'; |
1064 | - else |
|
1065 | - echo ' |
|
1076 | + } else { |
|
1077 | + echo ' |
|
1066 | 1078 | setInnerHTML(frames["css_preview_box"].document.getElementById("css_preview_sheet"), document.forms.stylesheetForm.entire_file.value);'; |
1079 | + } |
|
1067 | 1080 | echo ' |
1068 | 1081 | } |
1069 | 1082 | catch (e) |
@@ -1115,9 +1128,10 @@ discard block |
||
1115 | 1128 | </div> |
1116 | 1129 | <div class="windowbg">'; |
1117 | 1130 | |
1118 | - if (!$context['allow_save']) |
|
1119 | - echo ' |
|
1131 | + if (!$context['allow_save']) { |
|
1132 | + echo ' |
|
1120 | 1133 | ', $txt['theme_edit_no_save'], ': ', $context['allow_save_filename'], '<br>'; |
1134 | + } |
|
1121 | 1135 | |
1122 | 1136 | echo ' |
1123 | 1137 | <textarea name="entire_file" cols="80" rows="20" style="width: 96%; font-family: monospace; margin-top: 1ex; white-space: pre;" onkeyup="setPreviewTimeout();" onchange="refreshPreview(true);">', $context['entire_file'], '</textarea><br> |
@@ -1130,9 +1144,10 @@ discard block |
||
1130 | 1144 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">'; |
1131 | 1145 | |
1132 | 1146 | // Hopefully it exists. |
1133 | - if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'])) |
|
1134 | - echo ' |
|
1147 | + if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'])) { |
|
1148 | + echo ' |
|
1135 | 1149 | <input type="hidden" name="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token_var'], '" value="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'], '">'; |
1150 | + } |
|
1136 | 1151 | |
1137 | 1152 | echo ' |
1138 | 1153 | </form> |
@@ -1146,18 +1161,20 @@ discard block |
||
1146 | 1161 | { |
1147 | 1162 | global $context, $scripturl, $txt; |
1148 | 1163 | |
1149 | - if ($context['session_error']) |
|
1150 | - echo ' |
|
1164 | + if ($context['session_error']) { |
|
1165 | + echo ' |
|
1151 | 1166 | <div class="errorbox"> |
1152 | 1167 | ', $txt['error_session_timeout'], ' |
1153 | 1168 | </div>'; |
1169 | + } |
|
1154 | 1170 | |
1155 | - if (isset($context['parse_error'])) |
|
1156 | - echo ' |
|
1171 | + if (isset($context['parse_error'])) { |
|
1172 | + echo ' |
|
1157 | 1173 | <div class="errorbox"> |
1158 | 1174 | ', $txt['themeadmin_edit_error'], ' |
1159 | 1175 | <div><pre>', $context['parse_error'], '</pre></div> |
1160 | 1176 | </div>'; |
1177 | + } |
|
1161 | 1178 | |
1162 | 1179 | // Just show a big box.... gray out the Save button if it's not saveable... (ie. not 777.) |
1163 | 1180 | echo ' |
@@ -1168,16 +1185,18 @@ discard block |
||
1168 | 1185 | </div> |
1169 | 1186 | <div class="windowbg">'; |
1170 | 1187 | |
1171 | - if (!$context['allow_save']) |
|
1172 | - echo ' |
|
1188 | + if (!$context['allow_save']) { |
|
1189 | + echo ' |
|
1173 | 1190 | ', $txt['theme_edit_no_save'], ': ', $context['allow_save_filename'], '<br>'; |
1191 | + } |
|
1174 | 1192 | |
1175 | - foreach ($context['file_parts'] as $part) |
|
1176 | - echo ' |
|
1193 | + foreach ($context['file_parts'] as $part) { |
|
1194 | + echo ' |
|
1177 | 1195 | <label for="on_line', $part['line'], '">', $txt['themeadmin_edit_on_line'], ' ', $part['line'], '</label>:<br> |
1178 | 1196 | <div class="centertext"> |
1179 | 1197 | <textarea id="on_line', $part['line'], '" name="entire_file[]" cols="80" rows="', $part['lines'] > 14 ? '14' : $part['lines'], '" class="edit_file">', $part['data'], '</textarea> |
1180 | 1198 | </div>'; |
1199 | + } |
|
1181 | 1200 | |
1182 | 1201 | echo ' |
1183 | 1202 | <div class="padding righttext"> |
@@ -1186,9 +1205,10 @@ discard block |
||
1186 | 1205 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">'; |
1187 | 1206 | |
1188 | 1207 | // Hopefully it exists. |
1189 | - if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'])) |
|
1190 | - echo ' |
|
1208 | + if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'])) { |
|
1209 | + echo ' |
|
1191 | 1210 | <input type="hidden" name="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token_var'], '" value="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'], '">'; |
1211 | + } |
|
1192 | 1212 | |
1193 | 1213 | echo ' |
1194 | 1214 | </div> |
@@ -1204,18 +1224,20 @@ discard block |
||
1204 | 1224 | { |
1205 | 1225 | global $context, $scripturl, $txt; |
1206 | 1226 | |
1207 | - if ($context['session_error']) |
|
1208 | - echo ' |
|
1227 | + if ($context['session_error']) { |
|
1228 | + echo ' |
|
1209 | 1229 | <div class="errorbox"> |
1210 | 1230 | ', $txt['error_session_timeout'], ' |
1211 | 1231 | </div>'; |
1232 | + } |
|
1212 | 1233 | |
1213 | 1234 | //Is this file writeable? |
1214 | - if (!$context['allow_save']) |
|
1215 | - echo ' |
|
1235 | + if (!$context['allow_save']) { |
|
1236 | + echo ' |
|
1216 | 1237 | <div class="errorbox"> |
1217 | 1238 | ', $txt['theme_edit_no_save'], ': ', $context['allow_save_filename'], ' |
1218 | 1239 | </div>'; |
1240 | + } |
|
1219 | 1241 | |
1220 | 1242 | // Just show a big box.... gray out the Save button if it's not saveable... (ie. not 777.) |
1221 | 1243 | echo ' |
@@ -1231,9 +1253,10 @@ discard block |
||
1231 | 1253 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">'; |
1232 | 1254 | |
1233 | 1255 | // Hopefully it exists. |
1234 | - if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'])) |
|
1235 | - echo ' |
|
1256 | + if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'])) { |
|
1257 | + echo ' |
|
1236 | 1258 | <input type="hidden" name="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token_var'], '" value="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'], '">'; |
1259 | + } |
|
1237 | 1260 | |
1238 | 1261 | echo ' |
1239 | 1262 | </div> |
@@ -64,9 +64,10 @@ discard block |
||
64 | 64 | <strong>', $txt['administrators'], ':</strong> |
65 | 65 | ', implode(', ', $context['administrators']); |
66 | 66 | // If we have lots of admins... don't show them all. |
67 | - if (!empty($context['more_admins_link'])) |
|
68 | - echo ' |
|
67 | + if (!empty($context['more_admins_link'])) { |
|
68 | + echo ' |
|
69 | 69 | (', $context['more_admins_link'], ')'; |
70 | + } |
|
70 | 71 | |
71 | 72 | echo ' |
72 | 73 | </div> |
@@ -83,16 +84,18 @@ discard block |
||
83 | 84 | foreach ($area['areas'] as $item_id => $item) |
84 | 85 | { |
85 | 86 | // No point showing the 'home' page here, we're already on it! |
86 | - if ($area_id == 'forum' && $item_id == 'index') |
|
87 | - continue; |
|
87 | + if ($area_id == 'forum' && $item_id == 'index') { |
|
88 | + continue; |
|
89 | + } |
|
88 | 90 | |
89 | 91 | $url = isset($item['url']) ? $item['url'] : $scripturl . '?action=admin;area=' . $item_id . (!empty($context[$context['admin_menu_name']]['extra_parameters']) ? $context[$context['admin_menu_name']]['extra_parameters'] : ''); |
90 | - if (!empty($item['icon_file'])) |
|
91 | - echo ' |
|
92 | + if (!empty($item['icon_file'])) { |
|
93 | + echo ' |
|
92 | 94 | <a href="', $url, '" class="admin_group', !empty($item['inactive']) ? ' inactive' : '', '"><img class="large_admin_menu_icon_file" src="', $item['icon_file'], '" alt="">', $item['label'], '</a>'; |
93 | - else |
|
94 | - echo ' |
|
95 | + } else { |
|
96 | + echo ' |
|
95 | 97 | <a href="', $url, '"><span class="large_', $item['icon_class'], !empty($item['inactive']) ? ' inactive' : '', '"></span>', $item['label'], '</a>'; |
98 | + } |
|
96 | 99 | } |
97 | 100 | |
98 | 101 | echo ' |
@@ -103,10 +106,11 @@ discard block |
||
103 | 106 | </div>'; |
104 | 107 | |
105 | 108 | // The below functions include all the scripts needed from the simplemachines.org site. The language and format are passed for internationalization. |
106 | - if (empty($modSettings['disable_smf_js'])) |
|
107 | - echo ' |
|
109 | + if (empty($modSettings['disable_smf_js'])) { |
|
110 | + echo ' |
|
108 | 111 | <script src="', $scripturl, '?action=viewsmfile;filename=current-version.js"></script> |
109 | 112 | <script src="', $scripturl, '?action=viewsmfile;filename=latest-news.js"></script>'; |
113 | + } |
|
110 | 114 | |
111 | 115 | // This sets the announcements and current versions themselves ;). |
112 | 116 | echo ' |
@@ -185,9 +189,10 @@ discard block |
||
185 | 189 | <em>', $version['version'], '</em>'; |
186 | 190 | |
187 | 191 | // more details for this item, show them a link |
188 | - if ($context['can_admin'] && isset($version['more'])) |
|
189 | - echo |
|
192 | + if ($context['can_admin'] && isset($version['more'])) { |
|
193 | + echo |
|
190 | 194 | ' <a href="', $scripturl, $version['more'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['version_check_more'], '</a>'; |
195 | + } |
|
191 | 196 | echo ' |
192 | 197 | <br>'; |
193 | 198 | } |
@@ -218,20 +223,22 @@ discard block |
||
218 | 223 | |
219 | 224 | foreach ($context['credits'] as $section) |
220 | 225 | { |
221 | - if (isset($section['pretext'])) |
|
222 | - echo ' |
|
226 | + if (isset($section['pretext'])) { |
|
227 | + echo ' |
|
223 | 228 | <p>', $section['pretext'], '</p><hr>'; |
229 | + } |
|
224 | 230 | |
225 | 231 | echo ' |
226 | 232 | <dl>'; |
227 | 233 | |
228 | 234 | foreach ($section['groups'] as $group) |
229 | 235 | { |
230 | - if (isset($group['title'])) |
|
231 | - echo ' |
|
236 | + if (isset($group['title'])) { |
|
237 | + echo ' |
|
232 | 238 | <dt> |
233 | 239 | <strong>', $group['title'], ':</strong> |
234 | 240 | </dt>'; |
241 | + } |
|
235 | 242 | |
236 | 243 | echo ' |
237 | 244 | <dd>', implode(', ', $group['members']), '</dd>'; |
@@ -240,10 +247,11 @@ discard block |
||
240 | 247 | echo ' |
241 | 248 | </dl>'; |
242 | 249 | |
243 | - if (isset($section['posttext'])) |
|
244 | - echo ' |
|
250 | + if (isset($section['posttext'])) { |
|
251 | + echo ' |
|
245 | 252 | <hr> |
246 | 253 | <p>', $section['posttext'], '</p>'; |
254 | + } |
|
247 | 255 | } |
248 | 256 | |
249 | 257 | echo ' |
@@ -259,9 +267,10 @@ discard block |
||
259 | 267 | smfSupportVersions.forum = "', $context['forum_version'], '";'; |
260 | 268 | |
261 | 269 | // Don't worry, none of this is logged, it's just used to give information that might be of use. |
262 | - foreach ($context['current_versions'] as $variable => $version) |
|
263 | - echo ' |
|
270 | + foreach ($context['current_versions'] as $variable => $version) { |
|
271 | + echo ' |
|
264 | 272 | smfSupportVersions.', $variable, ' = "', $version['version'], '";'; |
273 | + } |
|
265 | 274 | |
266 | 275 | // Now we just have to include the script and wait ;). |
267 | 276 | echo ' |
@@ -358,8 +367,8 @@ discard block |
||
358 | 367 | <tbody>'; |
359 | 368 | |
360 | 369 | // Loop through every source file displaying its version - using javascript. |
361 | - foreach ($context['file_versions'] as $filename => $version) |
|
362 | - echo ' |
|
370 | + foreach ($context['file_versions'] as $filename => $version) { |
|
371 | + echo ' |
|
363 | 372 | <tr class="windowbg"> |
364 | 373 | <td class="half_table"> |
365 | 374 | ', $filename, ' |
@@ -371,6 +380,7 @@ discard block |
||
371 | 380 | <em id="currentSources', $filename, '">??</em> |
372 | 381 | </td> |
373 | 382 | </tr>'; |
383 | + } |
|
374 | 384 | |
375 | 385 | // Default template files. |
376 | 386 | echo ' |
@@ -396,8 +406,8 @@ discard block |
||
396 | 406 | <table id="Default" class="table_grid"> |
397 | 407 | <tbody>'; |
398 | 408 | |
399 | - foreach ($context['default_template_versions'] as $filename => $version) |
|
400 | - echo ' |
|
409 | + foreach ($context['default_template_versions'] as $filename => $version) { |
|
410 | + echo ' |
|
401 | 411 | <tr class="windowbg"> |
402 | 412 | <td class="half_table"> |
403 | 413 | ', $filename, ' |
@@ -409,6 +419,7 @@ discard block |
||
409 | 419 | <em id="currentDefault', $filename, '">??</em> |
410 | 420 | </td> |
411 | 421 | </tr>'; |
422 | + } |
|
412 | 423 | |
413 | 424 | // Now the language files... |
414 | 425 | echo ' |
@@ -436,8 +447,8 @@ discard block |
||
436 | 447 | |
437 | 448 | foreach ($context['default_language_versions'] as $language => $files) |
438 | 449 | { |
439 | - foreach ($files as $filename => $version) |
|
440 | - echo ' |
|
450 | + foreach ($files as $filename => $version) { |
|
451 | + echo ' |
|
441 | 452 | <tr class="windowbg"> |
442 | 453 | <td class="half_table"> |
443 | 454 | ', $filename, '.<em>', $language, '</em>.php |
@@ -449,6 +460,7 @@ discard block |
||
449 | 460 | <em id="current', $filename, '.', $language, '">??</em> |
450 | 461 | </td> |
451 | 462 | </tr>'; |
463 | + } |
|
452 | 464 | } |
453 | 465 | |
454 | 466 | echo ' |
@@ -478,8 +490,8 @@ discard block |
||
478 | 490 | <table id="Templates" class="table_grid"> |
479 | 491 | <tbody>'; |
480 | 492 | |
481 | - foreach ($context['template_versions'] as $filename => $version) |
|
482 | - echo ' |
|
493 | + foreach ($context['template_versions'] as $filename => $version) { |
|
494 | + echo ' |
|
483 | 495 | <tr class="windowbg"> |
484 | 496 | <td class="half_table"> |
485 | 497 | ', $filename, ' |
@@ -491,6 +503,7 @@ discard block |
||
491 | 503 | <em id="currentTemplates', $filename, '">??</em> |
492 | 504 | </td> |
493 | 505 | </tr>'; |
506 | + } |
|
494 | 507 | |
495 | 508 | echo ' |
496 | 509 | </tbody> |
@@ -520,8 +533,8 @@ discard block |
||
520 | 533 | <table id="Tasks" class="table_grid"> |
521 | 534 | <tbody>'; |
522 | 535 | |
523 | - foreach ($context['tasks_versions'] as $filename => $version) |
|
524 | - echo ' |
|
536 | + foreach ($context['tasks_versions'] as $filename => $version) { |
|
537 | + echo ' |
|
525 | 538 | <tr class="windowbg"> |
526 | 539 | <td class="half_table"> |
527 | 540 | ', $filename, ' |
@@ -533,6 +546,7 @@ discard block |
||
533 | 546 | <em id="currentTasks', $filename, '">??</em> |
534 | 547 | </td> |
535 | 548 | </tr>'; |
549 | + } |
|
536 | 550 | |
537 | 551 | echo ' |
538 | 552 | </tbody> |
@@ -574,9 +588,10 @@ discard block |
||
574 | 588 | { |
575 | 589 | global $context, $scripturl, $txt, $modSettings; |
576 | 590 | |
577 | - if (!empty($context['saved_successful'])) |
|
578 | - echo ' |
|
591 | + if (!empty($context['saved_successful'])) { |
|
592 | + echo ' |
|
579 | 593 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
594 | + } |
|
580 | 595 | |
581 | 596 | // First section is for adding/removing words from the censored list. |
582 | 597 | echo ' |
@@ -591,11 +606,12 @@ discard block |
||
591 | 606 | <p>', $txt['admin_censored_where'], '</p>'; |
592 | 607 | |
593 | 608 | // Show text boxes for censoring [bad ] => [good ]. |
594 | - foreach ($context['censored_words'] as $vulgar => $proper) |
|
595 | - echo ' |
|
609 | + foreach ($context['censored_words'] as $vulgar => $proper) { |
|
610 | + echo ' |
|
596 | 611 | <div class="block"> |
597 | 612 | <input type="text" name="censor_vulgar[]" value="', $vulgar, '" size="30"> => <input type="text" name="censor_proper[]" value="', $proper, '" size="30"> |
598 | 613 | </div>'; |
614 | + } |
|
599 | 615 | |
600 | 616 | // Now provide a way to censor more words. |
601 | 617 | echo ' |
@@ -669,19 +685,21 @@ discard block |
||
669 | 685 | <div class="windowbg2 noup"> |
670 | 686 | ', $txt['not_done_reason']; |
671 | 687 | |
672 | - if (!empty($context['continue_percent'])) |
|
673 | - echo ' |
|
688 | + if (!empty($context['continue_percent'])) { |
|
689 | + echo ' |
|
674 | 690 | <div class="progress_bar"> |
675 | 691 | <div class="full_bar">', $context['continue_percent'], '%</div> |
676 | 692 | <div class="green_percent" style="width: ', $context['continue_percent'], '%;"> </div> |
677 | 693 | </div>'; |
694 | + } |
|
678 | 695 | |
679 | - if (!empty($context['substep_enabled'])) |
|
680 | - echo ' |
|
696 | + if (!empty($context['substep_enabled'])) { |
|
697 | + echo ' |
|
681 | 698 | <div class="progress_bar"> |
682 | 699 | <div class="full_bar">', $context['substep_title'], ' (', $context['substep_continue_percent'], '%)</div> |
683 | 700 | <div class="blue_percent" style="width: ', $context['substep_continue_percent'], '%;"> </div> |
684 | 701 | </div>'; |
702 | + } |
|
685 | 703 | |
686 | 704 | echo ' |
687 | 705 | <form action="', $scripturl, $context['continue_get_data'], '" method="post" accept-charset="', $context['character_set'], '" name="autoSubmit" id="autoSubmit"> |
@@ -716,35 +734,40 @@ discard block |
||
716 | 734 | { |
717 | 735 | global $context, $txt, $settings, $scripturl; |
718 | 736 | |
719 | - if (!empty($context['saved_successful'])) |
|
720 | - echo ' |
|
737 | + if (!empty($context['saved_successful'])) { |
|
738 | + echo ' |
|
721 | 739 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
722 | - elseif (!empty($context['saved_failed'])) |
|
723 | - echo ' |
|
740 | + } elseif (!empty($context['saved_failed'])) { |
|
741 | + echo ' |
|
724 | 742 | <div class="errorbox">', sprintf($txt['settings_not_saved'], $context['saved_failed']), '</div>'; |
743 | + } |
|
725 | 744 | |
726 | - if (!empty($context['settings_pre_javascript'])) |
|
727 | - echo ' |
|
745 | + if (!empty($context['settings_pre_javascript'])) { |
|
746 | + echo ' |
|
728 | 747 | <script>', $context['settings_pre_javascript'], '</script>'; |
748 | + } |
|
729 | 749 | |
730 | - if (!empty($context['settings_insert_above'])) |
|
731 | - echo $context['settings_insert_above']; |
|
750 | + if (!empty($context['settings_insert_above'])) { |
|
751 | + echo $context['settings_insert_above']; |
|
752 | + } |
|
732 | 753 | |
733 | 754 | echo ' |
734 | 755 | <div id="admincenter"> |
735 | 756 | <form id="admin_form_wrapper" action="', $context['post_url'], '" method="post" accept-charset="', $context['character_set'], '"', !empty($context['force_form_onsubmit']) ? ' onsubmit="' . $context['force_form_onsubmit'] . '"' : '', '>'; |
736 | 757 | |
737 | 758 | // Is there a custom title? |
738 | - if (isset($context['settings_title'])) |
|
739 | - echo ' |
|
759 | + if (isset($context['settings_title'])) { |
|
760 | + echo ' |
|
740 | 761 | <div class="cat_bar"> |
741 | 762 | <h3 class="catbg">', $context['settings_title'], '</h3> |
742 | 763 | </div>'; |
764 | + } |
|
743 | 765 | |
744 | 766 | // Have we got a message to display? |
745 | - if (!empty($context['settings_message'])) |
|
746 | - echo ' |
|
767 | + if (!empty($context['settings_message'])) { |
|
768 | + echo ' |
|
747 | 769 | <div class="information">', $context['settings_message'], '</div>'; |
770 | + } |
|
748 | 771 | |
749 | 772 | // Now actually loop through all the variables. |
750 | 773 | $is_open = false; |
@@ -797,8 +820,9 @@ discard block |
||
797 | 820 | // Hang about? Are you pulling my leg - a callback?! |
798 | 821 | if (is_array($config_var) && $config_var['type'] == 'callback') |
799 | 822 | { |
800 | - if (function_exists('template_callback_' . $config_var['name'])) |
|
801 | - call_user_func('template_callback_' . $config_var['name']); |
|
823 | + if (function_exists('template_callback_' . $config_var['name'])) { |
|
824 | + call_user_func('template_callback_' . $config_var['name']); |
|
825 | + } |
|
802 | 826 | |
803 | 827 | continue; |
804 | 828 | } |
@@ -828,9 +852,10 @@ discard block |
||
828 | 852 | $text_types = array('color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'time'); |
829 | 853 | |
830 | 854 | // Show the [?] button. |
831 | - if ($config_var['help']) |
|
832 | - echo ' |
|
855 | + if ($config_var['help']) { |
|
856 | + echo ' |
|
833 | 857 | <a id="setting_', $config_var['name'], '_help" href="', $scripturl, '?action=helpadmin;help=', $config_var['help'], '" onclick="return reqOverlayDiv(this.href);"><span class="generic_icons help" title="', $txt['help'], '"></span></a> '; |
858 | + } |
|
834 | 859 | |
835 | 860 | echo ' |
836 | 861 | <a id="setting_', $config_var['name'], '"></a> <span', ($config_var['disabled'] ? ' style="color: #777777;"' : ($config_var['invalid'] ? ' class="error"' : '')), '><label for="', $config_var['name'], '">', $config_var['label'], '</label>', $subtext, ($config_var['type'] == 'password' ? '<br><em>' . $txt['admin_confirm_password'] . '</em>' : ''), '</span> |
@@ -839,22 +864,25 @@ discard block |
||
839 | 864 | $config_var['preinput']; |
840 | 865 | |
841 | 866 | // Show a check box. |
842 | - if ($config_var['type'] == 'check') |
|
843 | - echo ' |
|
867 | + if ($config_var['type'] == 'check') { |
|
868 | + echo ' |
|
844 | 869 | <input type="checkbox"', $javascript, $disabled, ' name="', $config_var['name'], '" id="', $config_var['name'], '"', ($config_var['value'] ? ' checked' : ''), ' value="1" class="input_check">'; |
870 | + } |
|
845 | 871 | // Escape (via htmlspecialchars.) the text box. |
846 | - elseif ($config_var['type'] == 'password') |
|
847 | - echo ' |
|
872 | + elseif ($config_var['type'] == 'password') { |
|
873 | + echo ' |
|
848 | 874 | <input type="password"', $disabled, $javascript, ' name="', $config_var['name'], '[0]"', ($config_var['size'] ? ' size="' . $config_var['size'] . '"' : ''), ' value="*#fakepass#*" onfocus="this.value = \'\'; this.form.', $config_var['name'], '.disabled = false;" class="input_password"><br> |
849 | 875 | <input type="password" disabled id="', $config_var['name'], '" name="', $config_var['name'], '[1]"', ($config_var['size'] ? ' size="' . $config_var['size'] . '"' : ''), ' class="input_password">'; |
876 | + } |
|
850 | 877 | // Show a selection box. |
851 | 878 | elseif ($config_var['type'] == 'select') |
852 | 879 | { |
853 | 880 | echo ' |
854 | 881 | <select name="', $config_var['name'], '" id="', $config_var['name'], '" ', $javascript, $disabled, (!empty($config_var['multiple']) ? ' multiple="multiple"' : ''), (!empty($config_var['multiple']) && !empty($config_var['size']) ? ' size="' . $config_var['size'] . '"' : ''), '>'; |
855 | - foreach ($config_var['data'] as $option) |
|
856 | - echo ' |
|
882 | + foreach ($config_var['data'] as $option) { |
|
883 | + echo ' |
|
857 | 884 | <option value="', $option[0], '"', (!empty($config_var['value']) && ($option[0] == $config_var['value'] || (!empty($config_var['multiple']) && in_array($option[0], $config_var['value']))) ? ' selected' : ''), '>', $option[1], '</option>'; |
885 | + } |
|
858 | 886 | echo ' |
859 | 887 | </select>'; |
860 | 888 | } |
@@ -868,15 +896,17 @@ discard block |
||
868 | 896 | <legend class="board_selector"><a href="#">', $txt['select_boards_from_list'], '</a></legend>'; |
869 | 897 | foreach ($context['board_list'] as $id_cat => $cat) |
870 | 898 | { |
871 | - if (!$first) |
|
872 | - echo ' |
|
899 | + if (!$first) { |
|
900 | + echo ' |
|
873 | 901 | <hr>'; |
902 | + } |
|
874 | 903 | echo ' |
875 | 904 | <strong>', $cat['name'], '</strong> |
876 | 905 | <ul>'; |
877 | - foreach ($cat['boards'] as $id_board => $brd) |
|
878 | - echo ' |
|
906 | + foreach ($cat['boards'] as $id_board => $brd) { |
|
907 | + echo ' |
|
879 | 908 | <li><label><input type="checkbox" name="', $config_var['name'], '[', $brd['id'], ']" value="1" class="input_check"', in_array($brd['id'], $config_var['value']) ? ' checked' : '', '> ', $brd['child_level'] > 0 ? str_repeat(' ', $brd['child_level']) : '', $brd['name'], '</label></li>'; |
909 | + } |
|
880 | 910 | |
881 | 911 | echo ' |
882 | 912 | </ul>'; |
@@ -886,12 +916,14 @@ discard block |
||
886 | 916 | </fieldset>'; |
887 | 917 | } |
888 | 918 | // Text area? |
889 | - elseif ($config_var['type'] == 'large_text') |
|
890 | - echo ' |
|
919 | + elseif ($config_var['type'] == 'large_text') { |
|
920 | + echo ' |
|
891 | 921 | <textarea rows="', (!empty($config_var['size']) ? $config_var['size'] : (!empty($config_var['rows']) ? $config_var['rows'] : 4)), '" cols="', (!empty($config_var['cols']) ? $config_var['cols'] : 30), '" ', $javascript, $disabled, ' name="', $config_var['name'], '" id="', $config_var['name'], '">', $config_var['value'], '</textarea>'; |
922 | + } |
|
892 | 923 | // Permission group? |
893 | - elseif ($config_var['type'] == 'permissions') |
|
894 | - theme_inline_permissions($config_var['name']); |
|
924 | + elseif ($config_var['type'] == 'permissions') { |
|
925 | + theme_inline_permissions($config_var['name']); |
|
926 | + } |
|
895 | 927 | // BBC selection? |
896 | 928 | elseif ($config_var['type'] == 'bbc') |
897 | 929 | { |
@@ -902,20 +934,22 @@ discard block |
||
902 | 934 | |
903 | 935 | foreach ($context['bbc_columns'] as $bbcColumn) |
904 | 936 | { |
905 | - foreach ($bbcColumn as $bbcTag) |
|
906 | - echo ' |
|
937 | + foreach ($bbcColumn as $bbcTag) { |
|
938 | + echo ' |
|
907 | 939 | <li class="list_bbc floatleft"> |
908 | 940 | <input type="checkbox" name="', $config_var['name'], '_enabledTags[]" id="tag_', $config_var['name'], '_', $bbcTag['tag'], '" value="', $bbcTag['tag'], '"', !in_array($bbcTag['tag'], $context['bbc_sections'][$config_var['name']]['disabled']) ? ' checked' : '', ' class="input_check"> <label for="tag_', $config_var['name'], '_', $bbcTag['tag'], '">', $bbcTag['tag'], '</label>', $bbcTag['show_help'] ? ' (<a href="' . $scripturl . '?action=helpadmin;help=tag_' . $bbcTag['tag'] . '" onclick="return reqOverlayDiv(this.href);">?</a>)' : '', ' |
909 | 941 | </li>'; |
942 | + } |
|
910 | 943 | } |
911 | 944 | echo ' </ul> |
912 | 945 | <input type="checkbox" id="bbc_', $config_var['name'], '_select_all" onclick="invertAll(this, this.form, \'', $config_var['name'], '_enabledTags\');"', $context['bbc_sections'][$config_var['name']]['all_selected'] ? ' checked' : '', ' class="input_check"> <label for="bbc_', $config_var['name'], '_select_all"><em>', $txt['bbcTagsToUse_select_all'], '</em></label> |
913 | 946 | </fieldset>'; |
914 | 947 | } |
915 | 948 | // A simple message? |
916 | - elseif ($config_var['type'] == 'var_message') |
|
917 | - echo ' |
|
949 | + elseif ($config_var['type'] == 'var_message') { |
|
950 | + echo ' |
|
918 | 951 | <div', !empty($config_var['name']) ? ' id="' . $config_var['name'] . '"' : '', '>', $config_var['var_message'], '</div>'; |
952 | + } |
|
919 | 953 | // Assume it must be a text box |
920 | 954 | else |
921 | 955 | { |
@@ -940,63 +974,70 @@ discard block |
||
940 | 974 | ' . $config_var['postinput'] : '', |
941 | 975 | '</dd>'; |
942 | 976 | } |
943 | - } |
|
944 | - |
|
945 | - else |
|
977 | + } else |
|
946 | 978 | { |
947 | 979 | // Just show a separator. |
948 | - if ($config_var == '') |
|
949 | - echo ' |
|
980 | + if ($config_var == '') { |
|
981 | + echo ' |
|
950 | 982 | </dl> |
951 | 983 | <hr> |
952 | 984 | <dl class="settings">'; |
953 | - else |
|
954 | - echo ' |
|
985 | + } else { |
|
986 | + echo ' |
|
955 | 987 | <dd> |
956 | 988 | <strong>' . $config_var . '</strong> |
957 | 989 | </dd>'; |
990 | + } |
|
958 | 991 | } |
959 | 992 | } |
960 | 993 | |
961 | - if ($is_open) |
|
962 | - echo ' |
|
994 | + if ($is_open) { |
|
995 | + echo ' |
|
963 | 996 | </dl>'; |
997 | + } |
|
964 | 998 | |
965 | - if (empty($context['settings_save_dont_show'])) |
|
966 | - echo ' |
|
999 | + if (empty($context['settings_save_dont_show'])) { |
|
1000 | + echo ' |
|
967 | 1001 | <input type="submit" value="', $txt['save'], '"', (!empty($context['save_disabled']) ? ' disabled' : ''), (!empty($context['settings_save_onclick']) ? ' onclick="' . $context['settings_save_onclick'] . '"' : ''), ' class="button_submit">'; |
1002 | + } |
|
968 | 1003 | |
969 | - if ($is_open) |
|
970 | - echo ' |
|
1004 | + if ($is_open) { |
|
1005 | + echo ' |
|
971 | 1006 | </div>'; |
1007 | + } |
|
972 | 1008 | |
973 | 1009 | |
974 | 1010 | // At least one token has to be used! |
975 | - if (isset($context['admin-ssc_token'])) |
|
976 | - echo ' |
|
1011 | + if (isset($context['admin-ssc_token'])) { |
|
1012 | + echo ' |
|
977 | 1013 | <input type="hidden" name="', $context['admin-ssc_token_var'], '" value="', $context['admin-ssc_token'], '">'; |
1014 | + } |
|
978 | 1015 | |
979 | - if (isset($context['admin-dbsc_token'])) |
|
980 | - echo ' |
|
1016 | + if (isset($context['admin-dbsc_token'])) { |
|
1017 | + echo ' |
|
981 | 1018 | <input type="hidden" name="', $context['admin-dbsc_token_var'], '" value="', $context['admin-dbsc_token'], '">'; |
1019 | + } |
|
982 | 1020 | |
983 | - if (isset($context['admin-mp_token'])) |
|
984 | - echo ' |
|
1021 | + if (isset($context['admin-mp_token'])) { |
|
1022 | + echo ' |
|
985 | 1023 | <input type="hidden" name="', $context['admin-mp_token_var'], '" value="', $context['admin-mp_token'], '">'; |
1024 | + } |
|
986 | 1025 | |
987 | 1026 | echo ' |
988 | 1027 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
989 | 1028 | </form> |
990 | 1029 | </div>'; |
991 | 1030 | |
992 | - if (!empty($context['settings_post_javascript'])) |
|
993 | - echo ' |
|
1031 | + if (!empty($context['settings_post_javascript'])) { |
|
1032 | + echo ' |
|
994 | 1033 | <script> |
995 | 1034 | ', $context['settings_post_javascript'], ' |
996 | 1035 | </script>'; |
1036 | + } |
|
997 | 1037 | |
998 | - if (!empty($context['settings_insert_below'])) |
|
999 | - echo $context['settings_insert_below']; |
|
1038 | + if (!empty($context['settings_insert_below'])) { |
|
1039 | + echo $context['settings_insert_below']; |
|
1040 | + } |
|
1000 | 1041 | |
1001 | 1042 | // We may have added a board listing. If we did, we need to make it work. |
1002 | 1043 | addInlineJavascript(' |
@@ -1019,9 +1060,10 @@ discard block |
||
1019 | 1060 | { |
1020 | 1061 | global $context, $txt; |
1021 | 1062 | |
1022 | - if (!empty($context['saved_successful'])) |
|
1023 | - echo ' |
|
1063 | + if (!empty($context['saved_successful'])) { |
|
1064 | + echo ' |
|
1024 | 1065 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
1066 | + } |
|
1025 | 1067 | |
1026 | 1068 | // Standard fields. |
1027 | 1069 | template_show_list('standard_profile_fields'); |
@@ -1053,11 +1095,12 @@ discard block |
||
1053 | 1095 | if (isset($_GET['msg'])) |
1054 | 1096 | { |
1055 | 1097 | loadLanguage('Errors'); |
1056 | - if (isset($txt['custom_option_' . $_GET['msg']])) |
|
1057 | - echo ' |
|
1098 | + if (isset($txt['custom_option_' . $_GET['msg']])) { |
|
1099 | + echo ' |
|
1058 | 1100 | <div class="errorbox">', |
1059 | 1101 | $txt['custom_option_' . $_GET['msg']], ' |
1060 | 1102 | </div>'; |
1103 | + } |
|
1061 | 1104 | } |
1062 | 1105 | |
1063 | 1106 | echo ' |
@@ -1123,9 +1166,10 @@ discard block |
||
1123 | 1166 | <dd> |
1124 | 1167 | <select name="placement" id="placement">'; |
1125 | 1168 | |
1126 | - foreach ($context['cust_profile_fields_placement'] as $order => $name) |
|
1127 | - echo ' |
|
1169 | + foreach ($context['cust_profile_fields_placement'] as $order => $name) { |
|
1170 | + echo ' |
|
1128 | 1171 | <option value="', $order, '"', $context['field']['placement'] == $order ? ' selected' : '', '>', $txt['custom_profile_placement_' . $name], '</option>'; |
1172 | + } |
|
1129 | 1173 | |
1130 | 1174 | echo ' |
1131 | 1175 | </select> |
@@ -1148,9 +1192,10 @@ discard block |
||
1148 | 1192 | </dt> |
1149 | 1193 | <dd> |
1150 | 1194 | <select name="field_type" id="field_type" onchange="updateInputBoxes();">'; |
1151 | - foreach (array('text', 'textarea', 'select', 'radio', 'check') as $field_type) |
|
1152 | - echo ' |
|
1195 | + foreach (array('text', 'textarea', 'select', 'radio', 'check') as $field_type) { |
|
1196 | + echo ' |
|
1153 | 1197 | <option value="', $field_type, '"', $context['field']['type'] == $field_type ? ' selected' : '', '>', $txt['custom_profile_type_' . $field_type], '</option>'; |
1198 | + } |
|
1154 | 1199 | |
1155 | 1200 | echo ' |
1156 | 1201 | </select> |
@@ -1251,9 +1296,10 @@ discard block |
||
1251 | 1296 | </fieldset> |
1252 | 1297 | <input type="submit" name="save" value="', $txt['save'], '" class="button_submit">'; |
1253 | 1298 | |
1254 | - if ($context['fid']) |
|
1255 | - echo ' |
|
1299 | + if ($context['fid']) { |
|
1300 | + echo ' |
|
1256 | 1301 | <input type="submit" name="delete" value="', $txt['delete'], '" data-confirm="', $txt['custom_edit_delete_sure'], '" class="button_submit you_sure">'; |
1302 | + } |
|
1257 | 1303 | |
1258 | 1304 | echo ' |
1259 | 1305 | </div> |
@@ -1296,8 +1342,7 @@ discard block |
||
1296 | 1342 | { |
1297 | 1343 | echo ' |
1298 | 1344 | <p class="centertext"><strong>', $txt['admin_search_results_none'], '</strong></p>'; |
1299 | - } |
|
1300 | - else |
|
1345 | + } else |
|
1301 | 1346 | { |
1302 | 1347 | echo ' |
1303 | 1348 | <ol class="search_results">'; |
@@ -1323,9 +1368,10 @@ discard block |
||
1323 | 1368 | <li> |
1324 | 1369 | <a href="', $result['url'], '"><strong>', $result['name'], '</strong></a> [', isset($txt['admin_search_section_' . $result['type']]) ? $txt['admin_search_section_' . $result['type']] : $result['type'], ']'; |
1325 | 1370 | |
1326 | - if ($result['help']) |
|
1327 | - echo ' |
|
1371 | + if ($result['help']) { |
|
1372 | + echo ' |
|
1328 | 1373 | <p class="double_height">', $result['help'], '</p>'; |
1374 | + } |
|
1329 | 1375 | |
1330 | 1376 | echo ' |
1331 | 1377 | </li>'; |
@@ -1365,18 +1411,20 @@ discard block |
||
1365 | 1411 | <strong>', $txt['setup_verification_answer'], '</strong> |
1366 | 1412 | </dd>'; |
1367 | 1413 | |
1368 | - if (!empty($context['qa_by_lang'][$lang_id])) |
|
1369 | - foreach ($context['qa_by_lang'][$lang_id] as $q_id) |
|
1414 | + if (!empty($context['qa_by_lang'][$lang_id])) { |
|
1415 | + foreach ($context['qa_by_lang'][$lang_id] as $q_id) |
|
1370 | 1416 | { |
1371 | 1417 | $question = $context['question_answers'][$q_id]; |
1418 | + } |
|
1372 | 1419 | echo ' |
1373 | 1420 | <dt> |
1374 | 1421 | <input type="text" name="question[', $lang_id, '][', $q_id, ']" value="', $question['question'], '" size="50" class="input_text verification_question"> |
1375 | 1422 | </dt> |
1376 | 1423 | <dd>'; |
1377 | - foreach ($question['answers'] as $answer) |
|
1378 | - echo ' |
|
1424 | + foreach ($question['answers'] as $answer) { |
|
1425 | + echo ' |
|
1379 | 1426 | <input type="text" name="answer[', $lang_id, '][', $q_id, '][]" value="', $answer, '" size="50" class="input_text verification_answer">'; |
1427 | + } |
|
1380 | 1428 | |
1381 | 1429 | echo ' |
1382 | 1430 | <div class="qa_add_answer"><a href="javascript:void(0);" onclick="return addAnswer(this);">[ ', $txt['setup_verification_add_answer'], ' ]</a></div> |
@@ -1415,11 +1463,12 @@ discard block |
||
1415 | 1463 | ', $txt['errors_found'], ': |
1416 | 1464 | <ul>'; |
1417 | 1465 | |
1418 | - foreach ($context['repair_errors'] as $error) |
|
1419 | - echo ' |
|
1466 | + foreach ($context['repair_errors'] as $error) { |
|
1467 | + echo ' |
|
1420 | 1468 | <li> |
1421 | 1469 | ', $error, ' |
1422 | 1470 | </li>'; |
1471 | + } |
|
1423 | 1472 | |
1424 | 1473 | echo ' |
1425 | 1474 | </ul> |
@@ -1429,16 +1478,15 @@ discard block |
||
1429 | 1478 | <p class="padding"> |
1430 | 1479 | <strong><a href="', $scripturl, '?action=admin;area=repairboards;fixErrors;', $context['session_var'], '=', $context['session_id'], '">', $txt['yes'], '</a> - <a href="', $scripturl, '?action=admin;area=maintain">', $txt['no'], '</a></strong> |
1431 | 1480 | </p>'; |
1432 | - } |
|
1433 | - else |
|
1434 | - echo ' |
|
1481 | + } else { |
|
1482 | + echo ' |
|
1435 | 1483 | <p>', $txt['maintain_no_errors'], '</p> |
1436 | 1484 | <p class="padding"> |
1437 | 1485 | <a href="', $scripturl, '?action=admin;area=maintain;sa=routine">', $txt['maintain_return'], '</a> |
1438 | 1486 | </p>'; |
1487 | + } |
|
1439 | 1488 | |
1440 | - } |
|
1441 | - else |
|
1489 | + } else |
|
1442 | 1490 | { |
1443 | 1491 | if (!empty($context['redirect_to_recount'])) |
1444 | 1492 | { |
@@ -1450,8 +1498,7 @@ discard block |
||
1450 | 1498 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
1451 | 1499 | <input type="submit" name="recount" id="recount_now" value="', $txt['errors_recount_now'], '"> |
1452 | 1500 | </form>'; |
1453 | - } |
|
1454 | - else |
|
1501 | + } else |
|
1455 | 1502 | { |
1456 | 1503 | echo ' |
1457 | 1504 | <p>', $txt['errors_fixed'], '</p> |
@@ -1603,8 +1650,8 @@ discard block |
||
1603 | 1650 | function template_admin_quick_search() |
1604 | 1651 | { |
1605 | 1652 | global $context, $txt, $scripturl; |
1606 | - if ($context['user']['is_admin']) |
|
1607 | - echo ' |
|
1653 | + if ($context['user']['is_admin']) { |
|
1654 | + echo ' |
|
1608 | 1655 | <span class="floatright admin_search"> |
1609 | 1656 | <span class="generic_icons filter centericon"></span> |
1610 | 1657 | <input type="search" name="search_term" value="', $txt['admin_search'], '" onclick="if (this.value == \'', $txt['admin_search'], '\') this.value = \'\';" class="input_text"> |
@@ -1615,6 +1662,7 @@ discard block |
||
1615 | 1662 | </select> |
1616 | 1663 | <input type="submit" name="search_go" id="search_go" value="', $txt['admin_search_go'], '" class="button_submit"> |
1617 | 1664 | </span>'; |
1618 | -} |
|
1665 | + } |
|
1666 | + } |
|
1619 | 1667 | |
1620 | 1668 | ?> |
1621 | 1669 | \ No newline at end of file |