@@ -15,8 +15,9 @@ discard block |
||
15 | 15 | * @version 2.1 Beta 4 |
16 | 16 | */ |
17 | 17 | |
18 | -if (!defined('SMF')) |
|
18 | +if (!defined('SMF')) { |
|
19 | 19 | die('No direct access...'); |
20 | +} |
|
20 | 21 | |
21 | 22 | /** |
22 | 23 | * Takes a message and parses it, returning nothing. |
@@ -31,8 +32,9 @@ discard block |
||
31 | 32 | global $user_info, $modSettings, $context, $sourcedir; |
32 | 33 | |
33 | 34 | // This line makes all languages *theoretically* work even with the wrong charset ;). |
34 | - if (empty($context['utf8'])) |
|
35 | - $message = preg_replace('~&#(\d{4,5}|[2-9]\d{2,4}|1[2-9]\d);~', '&#$1;', $message); |
|
35 | + if (empty($context['utf8'])) { |
|
36 | + $message = preg_replace('~&#(\d{4,5}|[2-9]\d{2,4}|1[2-9]\d);~', '&#$1;', $message); |
|
37 | + } |
|
36 | 38 | |
37 | 39 | // Clean up after nobbc ;). |
38 | 40 | $message = preg_replace_callback('~\[nobbc\](.+?)\[/nobbc\]~is', function($a) |
@@ -47,17 +49,19 @@ discard block |
||
47 | 49 | $message = preg_replace('~\.{100,}~', '...', $message); |
48 | 50 | |
49 | 51 | // Trim off trailing quotes - these often happen by accident. |
50 | - while (substr($message, -7) == '[quote]') |
|
51 | - $message = substr($message, 0, -7); |
|
52 | - while (substr($message, 0, 8) == '[/quote]') |
|
53 | - $message = substr($message, 8); |
|
52 | + while (substr($message, -7) == '[quote]') { |
|
53 | + $message = substr($message, 0, -7); |
|
54 | + } |
|
55 | + while (substr($message, 0, 8) == '[/quote]') { |
|
56 | + $message = substr($message, 8); |
|
57 | + } |
|
54 | 58 | |
55 | 59 | // Find all code blocks, work out whether we'd be parsing them, then ensure they are all closed. |
56 | 60 | $in_tag = false; |
57 | 61 | $had_tag = false; |
58 | 62 | $codeopen = 0; |
59 | - if (preg_match_all('~(\[(/)*code(?:=[^\]]+)?\])~is', $message, $matches)) |
|
60 | - foreach ($matches[0] as $index => $dummy) |
|
63 | + if (preg_match_all('~(\[(/)*code(?:=[^\]]+)?\])~is', $message, $matches)) { |
|
64 | + foreach ($matches[0] as $index => $dummy) |
|
61 | 65 | { |
62 | 66 | // Closing? |
63 | 67 | if (!empty($matches[2][$index])) |
@@ -65,6 +69,7 @@ discard block |
||
65 | 69 | // If it's closing and we're not in a tag we need to open it... |
66 | 70 | if (!$in_tag) |
67 | 71 | $codeopen = true; |
72 | + } |
|
68 | 73 | // Either way we ain't in one any more. |
69 | 74 | $in_tag = false; |
70 | 75 | } |
@@ -73,17 +78,20 @@ discard block |
||
73 | 78 | { |
74 | 79 | $had_tag = true; |
75 | 80 | // If we're in a tag don't do nought! |
76 | - if (!$in_tag) |
|
77 | - $in_tag = true; |
|
81 | + if (!$in_tag) { |
|
82 | + $in_tag = true; |
|
83 | + } |
|
78 | 84 | } |
79 | 85 | } |
80 | 86 | |
81 | 87 | // If we have an open tag, close it. |
82 | - if ($in_tag) |
|
83 | - $message .= '[/code]'; |
|
88 | + if ($in_tag) { |
|
89 | + $message .= '[/code]'; |
|
90 | + } |
|
84 | 91 | // Open any ones that need to be open, only if we've never had a tag. |
85 | - if ($codeopen && !$had_tag) |
|
86 | - $message = '[code]' . $message; |
|
92 | + if ($codeopen && !$had_tag) { |
|
93 | + $message = '[code]' . $message; |
|
94 | + } |
|
87 | 95 | |
88 | 96 | // Replace code BBC with placeholders. We'll restore them at the end. |
89 | 97 | $parts = preg_split('~(\[/code\]|\[code(?:=[^\]]+)?\])~i', $message, -1, PREG_SPLIT_DELIM_CAPTURE); |
@@ -108,23 +116,26 @@ discard block |
||
108 | 116 | fixTags($message); |
109 | 117 | |
110 | 118 | // Replace /me.+?\n with [me=name]dsf[/me]\n. |
111 | - if (strpos($user_info['name'], '[') !== false || strpos($user_info['name'], ']') !== false || strpos($user_info['name'], '\'') !== false || strpos($user_info['name'], '"') !== false) |
|
112 | - $message = preg_replace('~(\A|\n)/me(?: | )([^\n]*)(?:\z)?~i', '$1[me="' . $user_info['name'] . '"]$2[/me]', $message); |
|
113 | - else |
|
114 | - $message = preg_replace('~(\A|\n)/me(?: | )([^\n]*)(?:\z)?~i', '$1[me=' . $user_info['name'] . ']$2[/me]', $message); |
|
119 | + if (strpos($user_info['name'], '[') !== false || strpos($user_info['name'], ']') !== false || strpos($user_info['name'], '\'') !== false || strpos($user_info['name'], '"') !== false) { |
|
120 | + $message = preg_replace('~(\A|\n)/me(?: | )([^\n]*)(?:\z)?~i', '$1[me="' . $user_info['name'] . '"]$2[/me]', $message); |
|
121 | + } else { |
|
122 | + $message = preg_replace('~(\A|\n)/me(?: | )([^\n]*)(?:\z)?~i', '$1[me=' . $user_info['name'] . ']$2[/me]', $message); |
|
123 | + } |
|
115 | 124 | |
116 | 125 | if (!$previewing && strpos($message, '[html]') !== false) |
117 | 126 | { |
118 | - if (allowedTo('admin_forum')) |
|
119 | - $message = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m) { |
|
127 | + if (allowedTo('admin_forum')) { |
|
128 | + $message = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m) { |
|
120 | 129 | return '[html]' . strtr(un_htmlspecialchars($m[1]), array("\n" => ' ', ' ' => '  ', '[' => '[', ']' => ']')) . '[/html]'; |
130 | + } |
|
121 | 131 | }, $message); |
122 | 132 | |
123 | 133 | // We should edit them out, or else if an admin edits the message they will get shown... |
124 | 134 | else |
125 | 135 | { |
126 | - while (strpos($message, '[html]') !== false) |
|
127 | - $message = preg_replace('~\[[/]?html\]~i', '', $message); |
|
136 | + while (strpos($message, '[html]') !== false) { |
|
137 | + $message = preg_replace('~\[[/]?html\]~i', '', $message); |
|
138 | + } |
|
128 | 139 | } |
129 | 140 | } |
130 | 141 | |
@@ -146,10 +157,12 @@ discard block |
||
146 | 157 | |
147 | 158 | $list_open = substr_count($message, '[list]') + substr_count($message, '[list '); |
148 | 159 | $list_close = substr_count($message, '[/list]'); |
149 | - if ($list_close - $list_open > 0) |
|
150 | - $message = str_repeat('[list]', $list_close - $list_open) . $message; |
|
151 | - if ($list_open - $list_close > 0) |
|
152 | - $message = $message . str_repeat('[/list]', $list_open - $list_close); |
|
160 | + if ($list_close - $list_open > 0) { |
|
161 | + $message = str_repeat('[list]', $list_close - $list_open) . $message; |
|
162 | + } |
|
163 | + if ($list_open - $list_close > 0) { |
|
164 | + $message = $message . str_repeat('[/list]', $list_open - $list_close); |
|
165 | + } |
|
153 | 166 | |
154 | 167 | $mistake_fixes = array( |
155 | 168 | // Find [table]s not followed by [tr]. |
@@ -198,8 +211,9 @@ discard block |
||
198 | 211 | ); |
199 | 212 | |
200 | 213 | // Fix up some use of tables without [tr]s, etc. (it has to be done more than once to catch it all.) |
201 | - for ($j = 0; $j < 3; $j++) |
|
202 | - $message = preg_replace(array_keys($mistake_fixes), $mistake_fixes, $message); |
|
214 | + for ($j = 0; $j < 3; $j++) { |
|
215 | + $message = preg_replace(array_keys($mistake_fixes), $mistake_fixes, $message); |
|
216 | + } |
|
203 | 217 | |
204 | 218 | // Remove empty bbc from the sections outside the code tags |
205 | 219 | $allowedEmpty = array( |
@@ -210,24 +224,28 @@ discard block |
||
210 | 224 | require_once($sourcedir . '/Subs.php'); |
211 | 225 | |
212 | 226 | $alltags = array(); |
213 | - foreach (($codes = parse_bbc(false)) as $code) |
|
214 | - if (!in_array($code['tag'], $allowedEmpty)) |
|
227 | + foreach (($codes = parse_bbc(false)) as $code) { |
|
228 | + if (!in_array($code['tag'], $allowedEmpty)) |
|
215 | 229 | $alltags[] = $code['tag']; |
230 | + } |
|
216 | 231 | |
217 | 232 | $alltags_regex = '\b' . implode("\b|\b", array_unique($alltags)) . '\b'; |
218 | 233 | |
219 | - while (preg_match('~\[(' . $alltags_regex . ')[^\]]*\]\s*\[/\1\]\s?~i', $message)) |
|
220 | - $message = preg_replace('~\[(' . $alltags_regex . ')[^\]]*\]\s*\[/\1\]\s?~i', '', $message); |
|
234 | + while (preg_match('~\[(' . $alltags_regex . ')[^\]]*\]\s*\[/\1\]\s?~i', $message)) { |
|
235 | + $message = preg_replace('~\[(' . $alltags_regex . ')[^\]]*\]\s*\[/\1\]\s?~i', '', $message); |
|
236 | + } |
|
221 | 237 | |
222 | 238 | // Restore code blocks |
223 | - if (!empty($code_tags)) |
|
224 | - $message = str_replace(array_keys($code_tags), array_values($code_tags), $message); |
|
239 | + if (!empty($code_tags)) { |
|
240 | + $message = str_replace(array_keys($code_tags), array_values($code_tags), $message); |
|
241 | + } |
|
225 | 242 | |
226 | 243 | // Restore white space entities |
227 | - if (!$previewing) |
|
228 | - $message = strtr($message, array(' ' => ' ', "\n" => '<br>', $context['utf8'] ? "\xC2\xA0" : "\xA0" => ' ')); |
|
229 | - else |
|
230 | - $message = strtr($message, array(' ' => ' ', $context['utf8'] ? "\xC2\xA0" : "\xA0" => ' ')); |
|
244 | + if (!$previewing) { |
|
245 | + $message = strtr($message, array(' ' => ' ', "\n" => '<br>', $context['utf8'] ? "\xC2\xA0" : "\xA0" => ' ')); |
|
246 | + } else { |
|
247 | + $message = strtr($message, array(' ' => ' ', $context['utf8'] ? "\xC2\xA0" : "\xA0" => ' ')); |
|
248 | + } |
|
231 | 249 | |
232 | 250 | // Now let's quickly clean up things that will slow our parser (which are common in posted code.) |
233 | 251 | $message = strtr($message, array('[]' => '[]', '['' => '['')); |
@@ -270,8 +288,9 @@ discard block |
||
270 | 288 | return "[time]" . timeformat("$m[1]", false) . "[/time]"; |
271 | 289 | }, $message); |
272 | 290 | |
273 | - if (!empty($code_tags)) |
|
274 | - $message = str_replace(array_keys($code_tags), array_values($code_tags), $message); |
|
291 | + if (!empty($code_tags)) { |
|
292 | + $message = str_replace(array_keys($code_tags), array_values($code_tags), $message); |
|
293 | + } |
|
275 | 294 | |
276 | 295 | // Change breaks back to \n's and &nsbp; back to spaces. |
277 | 296 | return preg_replace('~<br( /)?' . '>~', "\n", str_replace(' ', ' ', $message)); |
@@ -352,8 +371,9 @@ discard block |
||
352 | 371 | ); |
353 | 372 | |
354 | 373 | // Fix each type of tag. |
355 | - foreach ($fixArray as $param) |
|
356 | - fixTag($message, $param['tag'], $param['protocols'], $param['embeddedUrl'], $param['hasEqualSign'], !empty($param['hasExtra'])); |
|
374 | + foreach ($fixArray as $param) { |
|
375 | + fixTag($message, $param['tag'], $param['protocols'], $param['embeddedUrl'], $param['hasEqualSign'], !empty($param['hasExtra'])); |
|
376 | + } |
|
357 | 377 | |
358 | 378 | // Now fix possible security problems with images loading links automatically... |
359 | 379 | $message = preg_replace_callback('~(\[img.*?\])(.+?)\[/img\]~is', function($m) |
@@ -378,10 +398,11 @@ discard block |
||
378 | 398 | { |
379 | 399 | global $boardurl, $scripturl; |
380 | 400 | |
381 | - if (preg_match('~^([^:]+://[^/]+)~', $boardurl, $match) != 0) |
|
382 | - $domain_url = $match[1]; |
|
383 | - else |
|
384 | - $domain_url = $boardurl . '/'; |
|
401 | + if (preg_match('~^([^:]+://[^/]+)~', $boardurl, $match) != 0) { |
|
402 | + $domain_url = $match[1]; |
|
403 | + } else { |
|
404 | + $domain_url = $boardurl . '/'; |
|
405 | + } |
|
385 | 406 | |
386 | 407 | $replaces = array(); |
387 | 408 | |
@@ -389,11 +410,11 @@ discard block |
||
389 | 410 | { |
390 | 411 | $quoted = preg_match('~\[(' . $myTag . ')="~', $message); |
391 | 412 | preg_match_all('~\[(' . $myTag . ')=' . ($quoted ? '"(.*?)"' : '([^\]]*?)') . '\](?:(.+?)\[/(' . $myTag . ')\])?~is', $message, $matches); |
413 | + } elseif ($hasEqualSign) { |
|
414 | + preg_match_all('~\[(' . $myTag . ')=([^\]]*?)\](?:(.+?)\[/(' . $myTag . ')\])?~is', $message, $matches); |
|
415 | + } else { |
|
416 | + preg_match_all('~\[(' . $myTag . ($hasExtra ? '(?:[^\]]*?)' : '') . ')\](.+?)\[/(' . $myTag . ')\]~is', $message, $matches); |
|
392 | 417 | } |
393 | - elseif ($hasEqualSign) |
|
394 | - preg_match_all('~\[(' . $myTag . ')=([^\]]*?)\](?:(.+?)\[/(' . $myTag . ')\])?~is', $message, $matches); |
|
395 | - else |
|
396 | - preg_match_all('~\[(' . $myTag . ($hasExtra ? '(?:[^\]]*?)' : '') . ')\](.+?)\[/(' . $myTag . ')\]~is', $message, $matches); |
|
397 | 418 | |
398 | 419 | foreach ($matches[0] as $k => $dummy) |
399 | 420 | { |
@@ -406,49 +427,53 @@ discard block |
||
406 | 427 | foreach ($protocols as $protocol) |
407 | 428 | { |
408 | 429 | $found = strncasecmp($replace, $protocol . '://', strlen($protocol) + 3) === 0; |
409 | - if ($found) |
|
410 | - break; |
|
430 | + if ($found) { |
|
431 | + break; |
|
432 | + } |
|
411 | 433 | } |
412 | 434 | |
413 | 435 | if (!$found && $protocols[0] == 'http') |
414 | 436 | { |
415 | - if (substr($replace, 0, 1) == '/' && substr($replace, 0, 2) != '//') |
|
416 | - $replace = $domain_url . $replace; |
|
417 | - elseif (substr($replace, 0, 1) == '?') |
|
418 | - $replace = $scripturl . $replace; |
|
419 | - elseif (substr($replace, 0, 1) == '#' && $embeddedUrl) |
|
437 | + if (substr($replace, 0, 1) == '/' && substr($replace, 0, 2) != '//') { |
|
438 | + $replace = $domain_url . $replace; |
|
439 | + } elseif (substr($replace, 0, 1) == '?') { |
|
440 | + $replace = $scripturl . $replace; |
|
441 | + } elseif (substr($replace, 0, 1) == '#' && $embeddedUrl) |
|
420 | 442 | { |
421 | 443 | $replace = '#' . preg_replace('~[^A-Za-z0-9_\-#]~', '', substr($replace, 1)); |
422 | 444 | $this_tag = 'iurl'; |
423 | 445 | $this_close = 'iurl'; |
446 | + } elseif (substr($replace, 0, 2) != '//') { |
|
447 | + $replace = $protocols[0] . '://' . $replace; |
|
424 | 448 | } |
425 | - elseif (substr($replace, 0, 2) != '//') |
|
426 | - $replace = $protocols[0] . '://' . $replace; |
|
427 | - } |
|
428 | - elseif (!$found && $protocols[0] == 'ftp') |
|
429 | - $replace = $protocols[0] . '://' . preg_replace('~^(?!ftps?)[^:]+://~', '', $replace); |
|
430 | - elseif (!$found) |
|
431 | - $replace = $protocols[0] . '://' . $replace; |
|
432 | - |
|
433 | - if ($hasEqualSign && $embeddedUrl) |
|
434 | - $replaces[$matches[0][$k]] = '[' . $this_tag . '="' . $replace . '"]' . (empty($matches[4][$k]) ? '' : $matches[3][$k] . '[/' . $this_close . ']'); |
|
435 | - elseif ($hasEqualSign) |
|
436 | - $replaces['[' . $matches[1][$k] . '=' . $matches[2][$k] . ']'] = '[' . $this_tag . '=' . $replace . ']'; |
|
437 | - elseif ($embeddedUrl) |
|
438 | - $replaces['[' . $matches[1][$k] . ']' . $matches[2][$k] . '[/' . $matches[3][$k] . ']'] = '[' . $this_tag . '=' . $replace . ']' . $matches[2][$k] . '[/' . $this_close . ']'; |
|
439 | - else |
|
440 | - $replaces['[' . $matches[1][$k] . ']' . $matches[2][$k] . '[/' . $matches[3][$k] . ']'] = '[' . $this_tag . ']' . $replace . '[/' . $this_close . ']'; |
|
449 | + } elseif (!$found && $protocols[0] == 'ftp') { |
|
450 | + $replace = $protocols[0] . '://' . preg_replace('~^(?!ftps?)[^:]+://~', '', $replace); |
|
451 | + } elseif (!$found) { |
|
452 | + $replace = $protocols[0] . '://' . $replace; |
|
453 | + } |
|
454 | + |
|
455 | + if ($hasEqualSign && $embeddedUrl) { |
|
456 | + $replaces[$matches[0][$k]] = '[' . $this_tag . '="' . $replace . '"]' . (empty($matches[4][$k]) ? '' : $matches[3][$k] . '[/' . $this_close . ']'); |
|
457 | + } elseif ($hasEqualSign) { |
|
458 | + $replaces['[' . $matches[1][$k] . '=' . $matches[2][$k] . ']'] = '[' . $this_tag . '=' . $replace . ']'; |
|
459 | + } elseif ($embeddedUrl) { |
|
460 | + $replaces['[' . $matches[1][$k] . ']' . $matches[2][$k] . '[/' . $matches[3][$k] . ']'] = '[' . $this_tag . '=' . $replace . ']' . $matches[2][$k] . '[/' . $this_close . ']'; |
|
461 | + } else { |
|
462 | + $replaces['[' . $matches[1][$k] . ']' . $matches[2][$k] . '[/' . $matches[3][$k] . ']'] = '[' . $this_tag . ']' . $replace . '[/' . $this_close . ']'; |
|
463 | + } |
|
441 | 464 | } |
442 | 465 | |
443 | 466 | foreach ($replaces as $k => $v) |
444 | 467 | { |
445 | - if ($k == $v) |
|
446 | - unset($replaces[$k]); |
|
468 | + if ($k == $v) { |
|
469 | + unset($replaces[$k]); |
|
470 | + } |
|
447 | 471 | } |
448 | 472 | |
449 | - if (!empty($replaces)) |
|
450 | - $message = strtr($message, $replaces); |
|
451 | -} |
|
473 | + if (!empty($replaces)) { |
|
474 | + $message = strtr($message, $replaces); |
|
475 | + } |
|
476 | + } |
|
452 | 477 | |
453 | 478 | /** |
454 | 479 | * This function sends an email to the specified recipient(s). |
@@ -492,8 +517,9 @@ discard block |
||
492 | 517 | } |
493 | 518 | |
494 | 519 | // Nothing left? Nothing else to do |
495 | - if (empty($to_array)) |
|
496 | - return true; |
|
520 | + if (empty($to_array)) { |
|
521 | + return true; |
|
522 | + } |
|
497 | 523 | |
498 | 524 | // Once upon a time, Hotmail could not interpret non-ASCII mails. |
499 | 525 | // In honour of those days, it's still called the 'hotmail fix'. |
@@ -510,15 +536,17 @@ discard block |
||
510 | 536 | } |
511 | 537 | |
512 | 538 | // Call this function recursively for the hotmail addresses. |
513 | - if (!empty($hotmail_to)) |
|
514 | - $mail_result = sendmail($hotmail_to, $subject, $message, $from, $message_id, $send_html, $priority, true, $is_private); |
|
539 | + if (!empty($hotmail_to)) { |
|
540 | + $mail_result = sendmail($hotmail_to, $subject, $message, $from, $message_id, $send_html, $priority, true, $is_private); |
|
541 | + } |
|
515 | 542 | |
516 | 543 | // The remaining addresses no longer need the fix. |
517 | 544 | $hotmail_fix = false; |
518 | 545 | |
519 | 546 | // No other addresses left? Return instantly. |
520 | - if (empty($to_array)) |
|
521 | - return $mail_result; |
|
547 | + if (empty($to_array)) { |
|
548 | + return $mail_result; |
|
549 | + } |
|
522 | 550 | } |
523 | 551 | |
524 | 552 | // Get rid of entities. |
@@ -543,13 +571,15 @@ discard block |
||
543 | 571 | $headers .= 'Return-Path: ' . (empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from']) . $line_break; |
544 | 572 | $headers .= 'Date: ' . gmdate('D, d M Y H:i:s') . ' -0000' . $line_break; |
545 | 573 | |
546 | - if ($message_id !== null && empty($modSettings['mail_no_message_id'])) |
|
547 | - $headers .= 'Message-ID: <' . md5($scripturl . microtime()) . '-' . $message_id . strstr(empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from'], '@') . '>' . $line_break; |
|
574 | + if ($message_id !== null && empty($modSettings['mail_no_message_id'])) { |
|
575 | + $headers .= 'Message-ID: <' . md5($scripturl . microtime()) . '-' . $message_id . strstr(empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from'], '@') . '>' . $line_break; |
|
576 | + } |
|
548 | 577 | $headers .= 'X-Mailer: SMF' . $line_break; |
549 | 578 | |
550 | 579 | // Pass this to the integration before we start modifying the output -- it'll make it easier later. |
551 | - if (in_array(false, call_integration_hook('integrate_outgoing_email', array(&$subject, &$message, &$headers, &$to_array)), true)) |
|
552 | - return false; |
|
580 | + if (in_array(false, call_integration_hook('integrate_outgoing_email', array(&$subject, &$message, &$headers, &$to_array)), true)) { |
|
581 | + return false; |
|
582 | + } |
|
553 | 583 | |
554 | 584 | // Save the original message... |
555 | 585 | $orig_message = $message; |
@@ -598,17 +628,19 @@ discard block |
||
598 | 628 | } |
599 | 629 | |
600 | 630 | // Are we using the mail queue, if so this is where we butt in... |
601 | - if ($priority != 0) |
|
602 | - return AddMailQueue(false, $to_array, $subject, $message, $headers, $send_html, $priority, $is_private); |
|
631 | + if ($priority != 0) { |
|
632 | + return AddMailQueue(false, $to_array, $subject, $message, $headers, $send_html, $priority, $is_private); |
|
633 | + } |
|
603 | 634 | |
604 | 635 | // If it's a priority mail, send it now - note though that this should NOT be used for sending many at once. |
605 | 636 | elseif (!empty($modSettings['mail_limit'])) |
606 | 637 | { |
607 | 638 | list ($last_mail_time, $mails_this_minute) = @explode('|', $modSettings['mail_recent']); |
608 | - if (empty($mails_this_minute) || time() > $last_mail_time + 60) |
|
609 | - $new_queue_stat = time() . '|' . 1; |
|
610 | - else |
|
611 | - $new_queue_stat = $last_mail_time . '|' . ((int) $mails_this_minute + 1); |
|
639 | + if (empty($mails_this_minute) || time() > $last_mail_time + 60) { |
|
640 | + $new_queue_stat = time() . '|' . 1; |
|
641 | + } else { |
|
642 | + $new_queue_stat = $last_mail_time . '|' . ((int) $mails_this_minute + 1); |
|
643 | + } |
|
612 | 644 | |
613 | 645 | updateSettings(array('mail_recent' => $new_queue_stat)); |
614 | 646 | } |
@@ -642,8 +674,7 @@ discard block |
||
642 | 674 | log_error(sprintf($txt['mail_send_unable'], $to)); |
643 | 675 | $mail_result = false; |
644 | 676 | } |
645 | - } |
|
646 | - catch(ErrorException $e) |
|
677 | + } catch(ErrorException $e) |
|
647 | 678 | { |
648 | 679 | log_error($e->getMessage(), 'general', $e->getFile(), $e->getLine()); |
649 | 680 | log_error(sprintf($txt['mail_send_unable'], $to)); |
@@ -653,12 +684,13 @@ discard block |
||
653 | 684 | |
654 | 685 | // Wait, wait, I'm still sending here! |
655 | 686 | @set_time_limit(300); |
656 | - if (function_exists('apache_reset_timeout')) |
|
657 | - @apache_reset_timeout(); |
|
687 | + if (function_exists('apache_reset_timeout')) { |
|
688 | + @apache_reset_timeout(); |
|
689 | + } |
|
658 | 690 | } |
691 | + } else { |
|
692 | + $mail_result = $mail_result && smtp_mail($to_array, $subject, $message, $headers); |
|
659 | 693 | } |
660 | - else |
|
661 | - $mail_result = $mail_result && smtp_mail($to_array, $subject, $message, $headers); |
|
662 | 694 | |
663 | 695 | // Everything go smoothly? |
664 | 696 | return $mail_result; |
@@ -684,8 +716,9 @@ discard block |
||
684 | 716 | static $cur_insert = array(); |
685 | 717 | static $cur_insert_len = 0; |
686 | 718 | |
687 | - if ($cur_insert_len == 0) |
|
688 | - $cur_insert = array(); |
|
719 | + if ($cur_insert_len == 0) { |
|
720 | + $cur_insert = array(); |
|
721 | + } |
|
689 | 722 | |
690 | 723 | // If we're flushing, make the final inserts - also if we're near the MySQL length limit! |
691 | 724 | if (($flush || $cur_insert_len > 800000) && !empty($cur_insert)) |
@@ -760,8 +793,9 @@ discard block |
||
760 | 793 | } |
761 | 794 | |
762 | 795 | // If they are using SSI there is a good chance obExit will never be called. So lets be nice and flush it for them. |
763 | - if (SMF === 'SSI' || SMF === 'BACKGROUND') |
|
764 | - return AddMailQueue(true); |
|
796 | + if (SMF === 'SSI' || SMF === 'BACKGROUND') { |
|
797 | + return AddMailQueue(true); |
|
798 | + } |
|
765 | 799 | |
766 | 800 | return true; |
767 | 801 | } |
@@ -792,23 +826,26 @@ discard block |
||
792 | 826 | 'sent' => array() |
793 | 827 | ); |
794 | 828 | |
795 | - if ($from === null) |
|
796 | - $from = array( |
|
829 | + if ($from === null) { |
|
830 | + $from = array( |
|
797 | 831 | 'id' => $user_info['id'], |
798 | 832 | 'name' => $user_info['name'], |
799 | 833 | 'username' => $user_info['username'] |
800 | 834 | ); |
835 | + } |
|
801 | 836 | |
802 | 837 | // This is the one that will go in their inbox. |
803 | 838 | $htmlmessage = $smcFunc['htmlspecialchars']($message, ENT_QUOTES); |
804 | 839 | preparsecode($htmlmessage); |
805 | 840 | $htmlsubject = strtr($smcFunc['htmlspecialchars']($subject), array("\r" => '', "\n" => '', "\t" => '')); |
806 | - if ($smcFunc['strlen']($htmlsubject) > 100) |
|
807 | - $htmlsubject = $smcFunc['substr']($htmlsubject, 0, 100); |
|
841 | + if ($smcFunc['strlen']($htmlsubject) > 100) { |
|
842 | + $htmlsubject = $smcFunc['substr']($htmlsubject, 0, 100); |
|
843 | + } |
|
808 | 844 | |
809 | 845 | // Make sure is an array |
810 | - if (!is_array($recipients)) |
|
811 | - $recipients = array($recipients); |
|
846 | + if (!is_array($recipients)) { |
|
847 | + $recipients = array($recipients); |
|
848 | + } |
|
812 | 849 | |
813 | 850 | // Integrated PMs |
814 | 851 | call_integration_hook('integrate_personal_message', array(&$recipients, &$from, &$subject, &$message)); |
@@ -836,21 +873,23 @@ discard block |
||
836 | 873 | 'usernames' => array_keys($usernames), |
837 | 874 | ) |
838 | 875 | ); |
839 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
840 | - if (isset($usernames[$smcFunc['strtolower']($row['member_name'])])) |
|
876 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
877 | + if (isset($usernames[$smcFunc['strtolower']($row['member_name'])])) |
|
841 | 878 | $usernames[$smcFunc['strtolower']($row['member_name'])] = $row['id_member']; |
879 | + } |
|
842 | 880 | $smcFunc['db_free_result']($request); |
843 | 881 | |
844 | 882 | // Replace the usernames with IDs. Drop usernames that couldn't be found. |
845 | - foreach ($recipients as $rec_type => $rec) |
|
846 | - foreach ($rec as $id => $member) |
|
883 | + foreach ($recipients as $rec_type => $rec) { |
|
884 | + foreach ($rec as $id => $member) |
|
847 | 885 | { |
848 | 886 | if (is_numeric($recipients[$rec_type][$id])) |
849 | 887 | continue; |
888 | + } |
|
850 | 889 | |
851 | - if (!empty($usernames[$member])) |
|
852 | - $recipients[$rec_type][$id] = $usernames[$member]; |
|
853 | - else |
|
890 | + if (!empty($usernames[$member])) { |
|
891 | + $recipients[$rec_type][$id] = $usernames[$member]; |
|
892 | + } else |
|
854 | 893 | { |
855 | 894 | $log['failed'][$id] = sprintf($txt['pm_error_user_not_found'], $recipients[$rec_type][$id]); |
856 | 895 | unset($recipients[$rec_type][$id]); |
@@ -888,8 +927,9 @@ discard block |
||
888 | 927 | $delete = false; |
889 | 928 | foreach ($criteria as $criterium) |
890 | 929 | { |
891 | - if (($criterium['t'] == 'mid' && $criterium['v'] == $from['id']) || ($criterium['t'] == 'gid' && in_array($criterium['v'], $user_info['groups'])) || ($criterium['t'] == 'sub' && strpos($subject, $criterium['v']) !== false) || ($criterium['t'] == 'msg' && strpos($message, $criterium['v']) !== false)) |
|
892 | - $delete = true; |
|
930 | + if (($criterium['t'] == 'mid' && $criterium['v'] == $from['id']) || ($criterium['t'] == 'gid' && in_array($criterium['v'], $user_info['groups'])) || ($criterium['t'] == 'sub' && strpos($subject, $criterium['v']) !== false) || ($criterium['t'] == 'msg' && strpos($message, $criterium['v']) !== false)) { |
|
931 | + $delete = true; |
|
932 | + } |
|
893 | 933 | // If we're adding and one criteria don't match then we stop! |
894 | 934 | elseif (!$row['is_or']) |
895 | 935 | { |
@@ -897,8 +937,9 @@ discard block |
||
897 | 937 | break; |
898 | 938 | } |
899 | 939 | } |
900 | - if ($delete) |
|
901 | - $deletes[$row['id_member']] = 1; |
|
940 | + if ($delete) { |
|
941 | + $deletes[$row['id_member']] = 1; |
|
942 | + } |
|
902 | 943 | } |
903 | 944 | $smcFunc['db_free_result']($request); |
904 | 945 | |
@@ -913,8 +954,9 @@ discard block |
||
913 | 954 | array( |
914 | 955 | ) |
915 | 956 | ); |
916 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
917 | - $message_limit_cache[$row['id_group']] = $row['max_messages']; |
|
957 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
958 | + $message_limit_cache[$row['id_group']] = $row['max_messages']; |
|
959 | + } |
|
918 | 960 | $smcFunc['db_free_result']($request); |
919 | 961 | } |
920 | 962 | |
@@ -922,8 +964,9 @@ discard block |
||
922 | 964 | require_once($sourcedir . '/Subs-Members.php'); |
923 | 965 | $pmReadGroups = groupsAllowedTo('pm_read'); |
924 | 966 | |
925 | - if (empty($modSettings['permission_enable_deny'])) |
|
926 | - $pmReadGroups['denied'] = array(); |
|
967 | + if (empty($modSettings['permission_enable_deny'])) { |
|
968 | + $pmReadGroups['denied'] = array(); |
|
969 | + } |
|
927 | 970 | |
928 | 971 | // Load their alert preferences |
929 | 972 | require_once($sourcedir . '/Subs-Notify.php'); |
@@ -955,8 +998,9 @@ discard block |
||
955 | 998 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
956 | 999 | { |
957 | 1000 | // Don't do anything for members to be deleted! |
958 | - if (isset($deletes[$row['id_member']])) |
|
959 | - continue; |
|
1001 | + if (isset($deletes[$row['id_member']])) { |
|
1002 | + continue; |
|
1003 | + } |
|
960 | 1004 | |
961 | 1005 | // Load the preferences for this member (if any) |
962 | 1006 | $prefs = !empty($notifyPrefs[$row['id_member']]) ? $notifyPrefs[$row['id_member']] : array(); |
@@ -977,8 +1021,9 @@ discard block |
||
977 | 1021 | { |
978 | 1022 | foreach ($groups as $id) |
979 | 1023 | { |
980 | - if (isset($message_limit_cache[$id]) && $message_limit != 0 && $message_limit < $message_limit_cache[$id]) |
|
981 | - $message_limit = $message_limit_cache[$id]; |
|
1024 | + if (isset($message_limit_cache[$id]) && $message_limit != 0 && $message_limit < $message_limit_cache[$id]) { |
|
1025 | + $message_limit = $message_limit_cache[$id]; |
|
1026 | + } |
|
982 | 1027 | } |
983 | 1028 | |
984 | 1029 | if ($message_limit > 0 && $message_limit <= $row['instant_messages']) |
@@ -1026,8 +1071,9 @@ discard block |
||
1026 | 1071 | $smcFunc['db_free_result']($request); |
1027 | 1072 | |
1028 | 1073 | // Only 'send' the message if there are any recipients left. |
1029 | - if (empty($all_to)) |
|
1030 | - return $log; |
|
1074 | + if (empty($all_to)) { |
|
1075 | + return $log; |
|
1076 | + } |
|
1031 | 1077 | |
1032 | 1078 | // Insert the message itself and then grab the last insert id. |
1033 | 1079 | $id_pm = $smcFunc['db_insert']('', |
@@ -1048,8 +1094,8 @@ discard block |
||
1048 | 1094 | if (!empty($id_pm)) |
1049 | 1095 | { |
1050 | 1096 | // If this is new we need to set it part of it's own conversation. |
1051 | - if (empty($pm_head)) |
|
1052 | - $smcFunc['db_query']('', ' |
|
1097 | + if (empty($pm_head)) { |
|
1098 | + $smcFunc['db_query']('', ' |
|
1053 | 1099 | UPDATE {db_prefix}personal_messages |
1054 | 1100 | SET id_pm_head = {int:id_pm_head} |
1055 | 1101 | WHERE id_pm = {int:id_pm_head}', |
@@ -1057,6 +1103,7 @@ discard block |
||
1057 | 1103 | 'id_pm_head' => $id_pm, |
1058 | 1104 | ) |
1059 | 1105 | ); |
1106 | + } |
|
1060 | 1107 | |
1061 | 1108 | // Some people think manually deleting personal_messages is fun... it's not. We protect against it though :) |
1062 | 1109 | $smcFunc['db_query']('', ' |
@@ -1072,8 +1119,9 @@ discard block |
||
1072 | 1119 | foreach ($all_to as $to) |
1073 | 1120 | { |
1074 | 1121 | $insertRows[] = array($id_pm, $to, in_array($to, $recipients['bcc']) ? 1 : 0, isset($deletes[$to]) ? 1 : 0, 1); |
1075 | - if (!in_array($to, $recipients['bcc'])) |
|
1076 | - $to_list[] = $to; |
|
1122 | + if (!in_array($to, $recipients['bcc'])) { |
|
1123 | + $to_list[] = $to; |
|
1124 | + } |
|
1077 | 1125 | } |
1078 | 1126 | |
1079 | 1127 | $smcFunc['db_insert']('insert', |
@@ -1091,9 +1139,9 @@ discard block |
||
1091 | 1139 | { |
1092 | 1140 | censorText($message); |
1093 | 1141 | $message = trim(un_htmlspecialchars(strip_tags(strtr(parse_bbc($smcFunc['htmlspecialchars']($message), false), array('<br>' => "\n", '</div>' => "\n", '</li>' => "\n", '[' => '[', ']' => ']'))))); |
1142 | + } else { |
|
1143 | + $message = ''; |
|
1094 | 1144 | } |
1095 | - else |
|
1096 | - $message = ''; |
|
1097 | 1145 | |
1098 | 1146 | $to_names = array(); |
1099 | 1147 | if (count($to_list) > 1) |
@@ -1106,8 +1154,9 @@ discard block |
||
1106 | 1154 | 'to_members' => $to_list, |
1107 | 1155 | ) |
1108 | 1156 | ); |
1109 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1110 | - $to_names[] = un_htmlspecialchars($row['real_name']); |
|
1157 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1158 | + $to_names[] = un_htmlspecialchars($row['real_name']); |
|
1159 | + } |
|
1111 | 1160 | $smcFunc['db_free_result']($request); |
1112 | 1161 | } |
1113 | 1162 | $replacements = array( |
@@ -1135,11 +1184,13 @@ discard block |
||
1135 | 1184 | loadLanguage('index+PersonalMessage'); |
1136 | 1185 | |
1137 | 1186 | // Add one to their unread and read message counts. |
1138 | - foreach ($all_to as $k => $id) |
|
1139 | - if (isset($deletes[$id])) |
|
1187 | + foreach ($all_to as $k => $id) { |
|
1188 | + if (isset($deletes[$id])) |
|
1140 | 1189 | unset($all_to[$k]); |
1141 | - if (!empty($all_to)) |
|
1142 | - updateMemberData($all_to, array('instant_messages' => '+', 'unread_messages' => '+', 'new_pm' => 1)); |
|
1190 | + } |
|
1191 | + if (!empty($all_to)) { |
|
1192 | + updateMemberData($all_to, array('instant_messages' => '+', 'unread_messages' => '+', 'new_pm' => 1)); |
|
1193 | + } |
|
1143 | 1194 | |
1144 | 1195 | return $log; |
1145 | 1196 | } |
@@ -1169,15 +1220,17 @@ discard block |
||
1169 | 1220 | // Let's, for now, assume there are only 'ish characters. |
1170 | 1221 | $simple = true; |
1171 | 1222 | |
1172 | - foreach ($matches[1] as $entity) |
|
1173 | - if ($entity > 128) |
|
1223 | + foreach ($matches[1] as $entity) { |
|
1224 | + if ($entity > 128) |
|
1174 | 1225 | $simple = false; |
1226 | + } |
|
1175 | 1227 | unset($matches); |
1176 | 1228 | |
1177 | - if ($simple) |
|
1178 | - $string = preg_replace_callback('~&#(\d{3,8});~', function($m) |
|
1229 | + if ($simple) { |
|
1230 | + $string = preg_replace_callback('~&#(\d{3,8});~', function($m) |
|
1179 | 1231 | { |
1180 | 1232 | return chr("$m[1]"); |
1233 | + } |
|
1181 | 1234 | }, $string); |
1182 | 1235 | else |
1183 | 1236 | { |
@@ -1185,8 +1238,9 @@ discard block |
||
1185 | 1238 | if (!$context['utf8'] && function_exists('iconv')) |
1186 | 1239 | { |
1187 | 1240 | $newstring = @iconv($context['character_set'], 'UTF-8', $string); |
1188 | - if ($newstring) |
|
1189 | - $string = $newstring; |
|
1241 | + if ($newstring) { |
|
1242 | + $string = $newstring; |
|
1243 | + } |
|
1190 | 1244 | } |
1191 | 1245 | |
1192 | 1246 | $string = preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $string); |
@@ -1202,23 +1256,25 @@ discard block |
||
1202 | 1256 | if (!$context['utf8'] && function_exists('iconv')) |
1203 | 1257 | { |
1204 | 1258 | $newstring = @iconv($context['character_set'], 'UTF-8', $string); |
1205 | - if ($newstring) |
|
1206 | - $string = $newstring; |
|
1259 | + if ($newstring) { |
|
1260 | + $string = $newstring; |
|
1261 | + } |
|
1207 | 1262 | } |
1208 | 1263 | |
1209 | 1264 | $entityConvert = function($m) |
1210 | 1265 | { |
1211 | 1266 | $c = $m[1]; |
1212 | - if (strlen($c) === 1 && ord($c[0]) <= 0x7F) |
|
1213 | - return $c; |
|
1214 | - elseif (strlen($c) === 2 && ord($c[0]) >= 0xC0 && ord($c[0]) <= 0xDF) |
|
1215 | - return "&#" . (((ord($c[0]) ^ 0xC0) << 6) + (ord($c[1]) ^ 0x80)) . ";"; |
|
1216 | - elseif (strlen($c) === 3 && ord($c[0]) >= 0xE0 && ord($c[0]) <= 0xEF) |
|
1217 | - return "&#" . (((ord($c[0]) ^ 0xE0) << 12) + ((ord($c[1]) ^ 0x80) << 6) + (ord($c[2]) ^ 0x80)) . ";"; |
|
1218 | - elseif (strlen($c) === 4 && ord($c[0]) >= 0xF0 && ord($c[0]) <= 0xF7) |
|
1219 | - return "&#" . (((ord($c[0]) ^ 0xF0) << 18) + ((ord($c[1]) ^ 0x80) << 12) + ((ord($c[2]) ^ 0x80) << 6) + (ord($c[3]) ^ 0x80)) . ";"; |
|
1220 | - else |
|
1221 | - return ""; |
|
1267 | + if (strlen($c) === 1 && ord($c[0]) <= 0x7F) { |
|
1268 | + return $c; |
|
1269 | + } elseif (strlen($c) === 2 && ord($c[0]) >= 0xC0 && ord($c[0]) <= 0xDF) { |
|
1270 | + return "&#" . (((ord($c[0]) ^ 0xC0) << 6) + (ord($c[1]) ^ 0x80)) . ";"; |
|
1271 | + } elseif (strlen($c) === 3 && ord($c[0]) >= 0xE0 && ord($c[0]) <= 0xEF) { |
|
1272 | + return "&#" . (((ord($c[0]) ^ 0xE0) << 12) + ((ord($c[1]) ^ 0x80) << 6) + (ord($c[2]) ^ 0x80)) . ";"; |
|
1273 | + } elseif (strlen($c) === 4 && ord($c[0]) >= 0xF0 && ord($c[0]) <= 0xF7) { |
|
1274 | + return "&#" . (((ord($c[0]) ^ 0xF0) << 18) + ((ord($c[1]) ^ 0x80) << 12) + ((ord($c[2]) ^ 0x80) << 6) + (ord($c[3]) ^ 0x80)) . ";"; |
|
1275 | + } else { |
|
1276 | + return ""; |
|
1277 | + } |
|
1222 | 1278 | }; |
1223 | 1279 | |
1224 | 1280 | // Convert all 'special' characters to HTML entities. |
@@ -1232,19 +1288,20 @@ discard block |
||
1232 | 1288 | $string = base64_encode($string); |
1233 | 1289 | |
1234 | 1290 | // Show the characterset and the transfer-encoding for header strings. |
1235 | - if ($with_charset) |
|
1236 | - $string = '=?' . $charset . '?B?' . $string . '?='; |
|
1291 | + if ($with_charset) { |
|
1292 | + $string = '=?' . $charset . '?B?' . $string . '?='; |
|
1293 | + } |
|
1237 | 1294 | |
1238 | 1295 | // Break it up in lines (mail body). |
1239 | - else |
|
1240 | - $string = chunk_split($string, 76, $line_break); |
|
1296 | + else { |
|
1297 | + $string = chunk_split($string, 76, $line_break); |
|
1298 | + } |
|
1241 | 1299 | |
1242 | 1300 | return array($charset, $string, 'base64'); |
1301 | + } else { |
|
1302 | + return array($charset, $string, '7bit'); |
|
1303 | + } |
|
1243 | 1304 | } |
1244 | - |
|
1245 | - else |
|
1246 | - return array($charset, $string, '7bit'); |
|
1247 | -} |
|
1248 | 1305 | |
1249 | 1306 | /** |
1250 | 1307 | * Sends mail, like mail() but over SMTP. |
@@ -1270,8 +1327,9 @@ discard block |
||
1270 | 1327 | if ($modSettings['mail_type'] == 3 && $modSettings['smtp_username'] != '' && $modSettings['smtp_password'] != '') |
1271 | 1328 | { |
1272 | 1329 | $socket = fsockopen($modSettings['smtp_host'], 110, $errno, $errstr, 2); |
1273 | - if (!$socket && (substr($modSettings['smtp_host'], 0, 5) == 'smtp.' || substr($modSettings['smtp_host'], 0, 11) == 'ssl://smtp.')) |
|
1274 | - $socket = fsockopen(strtr($modSettings['smtp_host'], array('smtp.' => 'pop.')), 110, $errno, $errstr, 2); |
|
1330 | + if (!$socket && (substr($modSettings['smtp_host'], 0, 5) == 'smtp.' || substr($modSettings['smtp_host'], 0, 11) == 'ssl://smtp.')) { |
|
1331 | + $socket = fsockopen(strtr($modSettings['smtp_host'], array('smtp.' => 'pop.')), 110, $errno, $errstr, 2); |
|
1332 | + } |
|
1275 | 1333 | |
1276 | 1334 | if ($socket) |
1277 | 1335 | { |
@@ -1293,11 +1351,13 @@ discard block |
||
1293 | 1351 | if (substr($modSettings['smtp_host'], 0, 4) == 'ssl:' && (empty($modSettings['smtp_port']) || $modSettings['smtp_port'] == 25)) |
1294 | 1352 | { |
1295 | 1353 | // ssl:hostname can cause fsocketopen to fail with a lookup failure, ensure it exists for this test. |
1296 | - if (substr($modSettings['smtp_host'], 0, 6) != 'ssl://') |
|
1297 | - $modSettings['smtp_host'] = str_replace('ssl:', 'ss://', $modSettings['smtp_host']); |
|
1354 | + if (substr($modSettings['smtp_host'], 0, 6) != 'ssl://') { |
|
1355 | + $modSettings['smtp_host'] = str_replace('ssl:', 'ss://', $modSettings['smtp_host']); |
|
1356 | + } |
|
1298 | 1357 | |
1299 | - if ($socket = fsockopen($modSettings['smtp_host'], 465, $errno, $errstr, 3)) |
|
1300 | - log_error($txt['smtp_port_ssl']); |
|
1358 | + if ($socket = fsockopen($modSettings['smtp_host'], 465, $errno, $errstr, 3)) { |
|
1359 | + log_error($txt['smtp_port_ssl']); |
|
1360 | + } |
|
1301 | 1361 | } |
1302 | 1362 | |
1303 | 1363 | // Unable to connect! Don't show any error message, but just log one and try to continue anyway. |
@@ -1309,26 +1369,30 @@ discard block |
||
1309 | 1369 | } |
1310 | 1370 | |
1311 | 1371 | // Wait for a response of 220, without "-" continuer. |
1312 | - if (!server_parse(null, $socket, '220')) |
|
1313 | - return false; |
|
1372 | + if (!server_parse(null, $socket, '220')) { |
|
1373 | + return false; |
|
1374 | + } |
|
1314 | 1375 | |
1315 | 1376 | // Try to determine the server's fully qualified domain name |
1316 | 1377 | // Can't rely on $_SERVER['SERVER_NAME'] because it can be spoofed on Apache |
1317 | 1378 | if (empty($helo)) |
1318 | 1379 | { |
1319 | 1380 | // See if we can get the domain name from the host itself |
1320 | - if (function_exists('gethostname')) |
|
1321 | - $helo = gethostname(); |
|
1322 | - elseif (function_exists('php_uname')) |
|
1323 | - $helo = php_uname('n'); |
|
1381 | + if (function_exists('gethostname')) { |
|
1382 | + $helo = gethostname(); |
|
1383 | + } elseif (function_exists('php_uname')) { |
|
1384 | + $helo = php_uname('n'); |
|
1385 | + } |
|
1324 | 1386 | |
1325 | 1387 | // If the hostname isn't a fully qualified domain name, we can use the host name from $boardurl instead |
1326 | - if (empty($helo) || strpos($helo, '.') === false || substr_compare($helo, '.local', -6) === 0 || (!empty($modSettings['tld_regex']) && !preg_match('/\.' . $modSettings['tld_regex'] . '$/u', $helo))) |
|
1327 | - $helo = parse_url($boardurl, PHP_URL_HOST); |
|
1388 | + if (empty($helo) || strpos($helo, '.') === false || substr_compare($helo, '.local', -6) === 0 || (!empty($modSettings['tld_regex']) && !preg_match('/\.' . $modSettings['tld_regex'] . '$/u', $helo))) { |
|
1389 | + $helo = parse_url($boardurl, PHP_URL_HOST); |
|
1390 | + } |
|
1328 | 1391 | |
1329 | 1392 | // This is one of those situations where 'www.' is undesirable |
1330 | - if (strpos($helo, 'www.') === 0) |
|
1331 | - $helo = substr($helo, 4); |
|
1393 | + if (strpos($helo, 'www.') === 0) { |
|
1394 | + $helo = substr($helo, 4); |
|
1395 | + } |
|
1332 | 1396 | } |
1333 | 1397 | |
1334 | 1398 | // SMTP = 1, SMTP - STARTTLS = 2 |
@@ -1341,8 +1405,9 @@ discard block |
||
1341 | 1405 | if ($modSettings['mail_type'] == 2 && preg_match("~250( |-)STARTTLS~mi", $response)) |
1342 | 1406 | { |
1343 | 1407 | // Send STARTTLS to enable encryption |
1344 | - if (!server_parse('STARTTLS', $socket, '220')) |
|
1345 | - return false; |
|
1408 | + if (!server_parse('STARTTLS', $socket, '220')) { |
|
1409 | + return false; |
|
1410 | + } |
|
1346 | 1411 | // Enable the encryption |
1347 | 1412 | // php 5.6+ fix |
1348 | 1413 | $crypto_method = STREAM_CRYPTO_METHOD_TLS_CLIENT; |
@@ -1353,30 +1418,35 @@ discard block |
||
1353 | 1418 | $crypto_method |= STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT; |
1354 | 1419 | } |
1355 | 1420 | |
1356 | - if (!@stream_socket_enable_crypto($socket, true, $crypto_method)) |
|
1357 | - return false; |
|
1421 | + if (!@stream_socket_enable_crypto($socket, true, $crypto_method)) { |
|
1422 | + return false; |
|
1423 | + } |
|
1358 | 1424 | // Send the EHLO command again |
1359 | - if (!server_parse('EHLO ' . $helo, $socket, null) == '250') |
|
1360 | - return false; |
|
1425 | + if (!server_parse('EHLO ' . $helo, $socket, null) == '250') { |
|
1426 | + return false; |
|
1427 | + } |
|
1361 | 1428 | } |
1362 | 1429 | |
1363 | - if (!server_parse('AUTH LOGIN', $socket, '334')) |
|
1364 | - return false; |
|
1430 | + if (!server_parse('AUTH LOGIN', $socket, '334')) { |
|
1431 | + return false; |
|
1432 | + } |
|
1365 | 1433 | // Send the username and password, encoded. |
1366 | - if (!server_parse(base64_encode($modSettings['smtp_username']), $socket, '334')) |
|
1367 | - return false; |
|
1434 | + if (!server_parse(base64_encode($modSettings['smtp_username']), $socket, '334')) { |
|
1435 | + return false; |
|
1436 | + } |
|
1368 | 1437 | // The password is already encoded ;) |
1369 | - if (!server_parse($modSettings['smtp_password'], $socket, '235')) |
|
1370 | - return false; |
|
1438 | + if (!server_parse($modSettings['smtp_password'], $socket, '235')) { |
|
1439 | + return false; |
|
1440 | + } |
|
1441 | + } elseif (!server_parse('HELO ' . $helo, $socket, '250')) { |
|
1442 | + return false; |
|
1371 | 1443 | } |
1372 | - elseif (!server_parse('HELO ' . $helo, $socket, '250')) |
|
1373 | - return false; |
|
1374 | - } |
|
1375 | - else |
|
1444 | + } else |
|
1376 | 1445 | { |
1377 | 1446 | // Just say "helo". |
1378 | - if (!server_parse('HELO ' . $helo, $socket, '250')) |
|
1379 | - return false; |
|
1447 | + if (!server_parse('HELO ' . $helo, $socket, '250')) { |
|
1448 | + return false; |
|
1449 | + } |
|
1380 | 1450 | } |
1381 | 1451 | |
1382 | 1452 | // Fix the message for any lines beginning with a period! (the first is ignored, you see.) |
@@ -1389,31 +1459,38 @@ discard block |
||
1389 | 1459 | // Reset the connection to send another email. |
1390 | 1460 | if ($i != 0) |
1391 | 1461 | { |
1392 | - if (!server_parse('RSET', $socket, '250')) |
|
1393 | - return false; |
|
1462 | + if (!server_parse('RSET', $socket, '250')) { |
|
1463 | + return false; |
|
1464 | + } |
|
1394 | 1465 | } |
1395 | 1466 | |
1396 | 1467 | // From, to, and then start the data... |
1397 | - if (!server_parse('MAIL FROM: <' . (empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from']) . '>', $socket, '250')) |
|
1398 | - return false; |
|
1399 | - if (!server_parse('RCPT TO: <' . $mail_to . '>', $socket, '250')) |
|
1400 | - return false; |
|
1401 | - if (!server_parse('DATA', $socket, '354')) |
|
1402 | - return false; |
|
1468 | + if (!server_parse('MAIL FROM: <' . (empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from']) . '>', $socket, '250')) { |
|
1469 | + return false; |
|
1470 | + } |
|
1471 | + if (!server_parse('RCPT TO: <' . $mail_to . '>', $socket, '250')) { |
|
1472 | + return false; |
|
1473 | + } |
|
1474 | + if (!server_parse('DATA', $socket, '354')) { |
|
1475 | + return false; |
|
1476 | + } |
|
1403 | 1477 | fputs($socket, 'Subject: ' . $subject . "\r\n"); |
1404 | - if (strlen($mail_to) > 0) |
|
1405 | - fputs($socket, 'To: <' . $mail_to . '>' . "\r\n"); |
|
1478 | + if (strlen($mail_to) > 0) { |
|
1479 | + fputs($socket, 'To: <' . $mail_to . '>' . "\r\n"); |
|
1480 | + } |
|
1406 | 1481 | fputs($socket, $headers . "\r\n\r\n"); |
1407 | 1482 | fputs($socket, $message . "\r\n"); |
1408 | 1483 | |
1409 | 1484 | // Send a ., or in other words "end of data". |
1410 | - if (!server_parse('.', $socket, '250')) |
|
1411 | - return false; |
|
1485 | + if (!server_parse('.', $socket, '250')) { |
|
1486 | + return false; |
|
1487 | + } |
|
1412 | 1488 | |
1413 | 1489 | // Almost done, almost done... don't stop me just yet! |
1414 | 1490 | @set_time_limit(300); |
1415 | - if (function_exists('apache_reset_timeout')) |
|
1416 | - @apache_reset_timeout(); |
|
1491 | + if (function_exists('apache_reset_timeout')) { |
|
1492 | + @apache_reset_timeout(); |
|
1493 | + } |
|
1417 | 1494 | } |
1418 | 1495 | fputs($socket, 'QUIT' . "\r\n"); |
1419 | 1496 | fclose($socket); |
@@ -1437,8 +1514,9 @@ discard block |
||
1437 | 1514 | { |
1438 | 1515 | global $txt; |
1439 | 1516 | |
1440 | - if ($message !== null) |
|
1441 | - fputs($socket, $message . "\r\n"); |
|
1517 | + if ($message !== null) { |
|
1518 | + fputs($socket, $message . "\r\n"); |
|
1519 | + } |
|
1442 | 1520 | |
1443 | 1521 | // No response yet. |
1444 | 1522 | $server_response = ''; |
@@ -1454,8 +1532,9 @@ discard block |
||
1454 | 1532 | $response .= $server_response; |
1455 | 1533 | } |
1456 | 1534 | |
1457 | - if ($code === null) |
|
1458 | - return substr($server_response, 0, 3); |
|
1535 | + if ($code === null) { |
|
1536 | + return substr($server_response, 0, 3); |
|
1537 | + } |
|
1459 | 1538 | |
1460 | 1539 | if (substr($server_response, 0, 3) != $code) |
1461 | 1540 | { |
@@ -1485,8 +1564,9 @@ discard block |
||
1485 | 1564 | // Create a pspell or enchant dictionary resource |
1486 | 1565 | $dict = spell_init(); |
1487 | 1566 | |
1488 | - if (!isset($_POST['spellstring']) || !$dict) |
|
1489 | - die; |
|
1567 | + if (!isset($_POST['spellstring']) || !$dict) { |
|
1568 | + die; |
|
1569 | + } |
|
1490 | 1570 | |
1491 | 1571 | // Construct a bit of Javascript code. |
1492 | 1572 | $context['spell_js'] = ' |
@@ -1504,8 +1584,9 @@ discard block |
||
1504 | 1584 | $check_word = explode('|', $alphas[$i]); |
1505 | 1585 | |
1506 | 1586 | // If the word is a known word, or spelled right... |
1507 | - if (in_array($smcFunc['strtolower']($check_word[0]), $known_words) || spell_check($dict, $check_word[0]) || !isset($check_word[2])) |
|
1508 | - continue; |
|
1587 | + if (in_array($smcFunc['strtolower']($check_word[0]), $known_words) || spell_check($dict, $check_word[0]) || !isset($check_word[2])) { |
|
1588 | + continue; |
|
1589 | + } |
|
1509 | 1590 | |
1510 | 1591 | // Find the word, and move up the "last occurrence" to here. |
1511 | 1592 | $found_words = true; |
@@ -1519,20 +1600,23 @@ discard block |
||
1519 | 1600 | if (!empty($suggestions)) |
1520 | 1601 | { |
1521 | 1602 | // But first check they aren't going to be censored - no naughty words! |
1522 | - foreach ($suggestions as $k => $word) |
|
1523 | - if ($suggestions[$k] != censorText($word)) |
|
1603 | + foreach ($suggestions as $k => $word) { |
|
1604 | + if ($suggestions[$k] != censorText($word)) |
|
1524 | 1605 | unset($suggestions[$k]); |
1606 | + } |
|
1525 | 1607 | |
1526 | - if (!empty($suggestions)) |
|
1527 | - $context['spell_js'] .= '"' . implode('", "', $suggestions) . '"'; |
|
1608 | + if (!empty($suggestions)) { |
|
1609 | + $context['spell_js'] .= '"' . implode('", "', $suggestions) . '"'; |
|
1610 | + } |
|
1528 | 1611 | } |
1529 | 1612 | |
1530 | 1613 | $context['spell_js'] .= ']),'; |
1531 | 1614 | } |
1532 | 1615 | |
1533 | 1616 | // If words were found, take off the last comma. |
1534 | - if ($found_words) |
|
1535 | - $context['spell_js'] = substr($context['spell_js'], 0, -1); |
|
1617 | + if ($found_words) { |
|
1618 | + $context['spell_js'] = substr($context['spell_js'], 0, -1); |
|
1619 | + } |
|
1536 | 1620 | |
1537 | 1621 | $context['spell_js'] .= ' |
1538 | 1622 | );'; |
@@ -1567,11 +1651,13 @@ discard block |
||
1567 | 1651 | global $user_info, $smcFunc; |
1568 | 1652 | |
1569 | 1653 | // Can't do it if there's no topics. |
1570 | - if (empty($topics)) |
|
1571 | - return; |
|
1654 | + if (empty($topics)) { |
|
1655 | + return; |
|
1656 | + } |
|
1572 | 1657 | // It must be an array - it must! |
1573 | - if (!is_array($topics)) |
|
1574 | - $topics = array($topics); |
|
1658 | + if (!is_array($topics)) { |
|
1659 | + $topics = array($topics); |
|
1660 | + } |
|
1575 | 1661 | |
1576 | 1662 | // Get the subject and body... |
1577 | 1663 | $result = $smcFunc['db_query']('', ' |
@@ -1619,14 +1705,15 @@ discard block |
||
1619 | 1705 | } |
1620 | 1706 | $smcFunc['db_free_result']($result); |
1621 | 1707 | |
1622 | - if (!empty($task_rows)) |
|
1623 | - $smcFunc['db_insert']('', |
|
1708 | + if (!empty($task_rows)) { |
|
1709 | + $smcFunc['db_insert']('', |
|
1624 | 1710 | '{db_prefix}background_tasks', |
1625 | 1711 | array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'), |
1626 | 1712 | $task_rows, |
1627 | 1713 | array('id_task') |
1628 | 1714 | ); |
1629 | -} |
|
1715 | + } |
|
1716 | + } |
|
1630 | 1717 | |
1631 | 1718 | /** |
1632 | 1719 | * Create a post, either as new topic (id_topic = 0) or in an existing one. |
@@ -1664,9 +1751,9 @@ discard block |
||
1664 | 1751 | $msgOptions['send_notifications'] = isset($msgOptions['send_notifications']) ? (bool) $msgOptions['send_notifications'] : true; |
1665 | 1752 | |
1666 | 1753 | // We need to know if the topic is approved. If we're told that's great - if not find out. |
1667 | - if (!$modSettings['postmod_active']) |
|
1668 | - $topicOptions['is_approved'] = true; |
|
1669 | - elseif (!empty($topicOptions['id']) && !isset($topicOptions['is_approved'])) |
|
1754 | + if (!$modSettings['postmod_active']) { |
|
1755 | + $topicOptions['is_approved'] = true; |
|
1756 | + } elseif (!empty($topicOptions['id']) && !isset($topicOptions['is_approved'])) |
|
1670 | 1757 | { |
1671 | 1758 | $request = $smcFunc['db_query']('', ' |
1672 | 1759 | SELECT approved |
@@ -1689,8 +1776,7 @@ discard block |
||
1689 | 1776 | $posterOptions['id'] = 0; |
1690 | 1777 | $posterOptions['name'] = $txt['guest_title']; |
1691 | 1778 | $posterOptions['email'] = ''; |
1692 | - } |
|
1693 | - elseif ($posterOptions['id'] != $user_info['id']) |
|
1779 | + } elseif ($posterOptions['id'] != $user_info['id']) |
|
1694 | 1780 | { |
1695 | 1781 | $request = $smcFunc['db_query']('', ' |
1696 | 1782 | SELECT member_name, email_address |
@@ -1708,12 +1794,11 @@ discard block |
||
1708 | 1794 | $posterOptions['id'] = 0; |
1709 | 1795 | $posterOptions['name'] = $txt['guest_title']; |
1710 | 1796 | $posterOptions['email'] = ''; |
1797 | + } else { |
|
1798 | + list ($posterOptions['name'], $posterOptions['email']) = $smcFunc['db_fetch_row']($request); |
|
1711 | 1799 | } |
1712 | - else |
|
1713 | - list ($posterOptions['name'], $posterOptions['email']) = $smcFunc['db_fetch_row']($request); |
|
1714 | 1800 | $smcFunc['db_free_result']($request); |
1715 | - } |
|
1716 | - else |
|
1801 | + } else |
|
1717 | 1802 | { |
1718 | 1803 | $posterOptions['name'] = $user_info['name']; |
1719 | 1804 | $posterOptions['email'] = $user_info['email']; |
@@ -1723,8 +1808,9 @@ discard block |
||
1723 | 1808 | if (!empty($modSettings['enable_mentions'])) |
1724 | 1809 | { |
1725 | 1810 | $msgOptions['mentioned_members'] = Mentions::getMentionedMembers($msgOptions['body']); |
1726 | - if (!empty($msgOptions['mentioned_members'])) |
|
1727 | - $msgOptions['body'] = Mentions::getBody($msgOptions['body'], $msgOptions['mentioned_members']); |
|
1811 | + if (!empty($msgOptions['mentioned_members'])) { |
|
1812 | + $msgOptions['body'] = Mentions::getBody($msgOptions['body'], $msgOptions['mentioned_members']); |
|
1813 | + } |
|
1728 | 1814 | } |
1729 | 1815 | |
1730 | 1816 | // It's do or die time: forget any user aborts! |
@@ -1757,12 +1843,13 @@ discard block |
||
1757 | 1843 | ); |
1758 | 1844 | |
1759 | 1845 | // Something went wrong creating the message... |
1760 | - if (empty($msgOptions['id'])) |
|
1761 | - return false; |
|
1846 | + if (empty($msgOptions['id'])) { |
|
1847 | + return false; |
|
1848 | + } |
|
1762 | 1849 | |
1763 | 1850 | // Fix the attachments. |
1764 | - if (!empty($msgOptions['attachments'])) |
|
1765 | - $smcFunc['db_query']('', ' |
|
1851 | + if (!empty($msgOptions['attachments'])) { |
|
1852 | + $smcFunc['db_query']('', ' |
|
1766 | 1853 | UPDATE {db_prefix}attachments |
1767 | 1854 | SET id_msg = {int:id_msg} |
1768 | 1855 | WHERE id_attach IN ({array_int:attachment_list})', |
@@ -1771,6 +1858,7 @@ discard block |
||
1771 | 1858 | 'id_msg' => $msgOptions['id'], |
1772 | 1859 | ) |
1773 | 1860 | ); |
1861 | + } |
|
1774 | 1862 | |
1775 | 1863 | // What if we want to export new posts out to a CMS? |
1776 | 1864 | call_integration_hook('integrate_after_create_post', array($msgOptions, $topicOptions, $posterOptions, $message_columns, $message_parameters)); |
@@ -1847,20 +1935,23 @@ discard block |
||
1847 | 1935 | 'id_topic' => $topicOptions['id'], |
1848 | 1936 | 'counter_increment' => 1, |
1849 | 1937 | ); |
1850 | - if ($msgOptions['approved']) |
|
1851 | - $topics_columns = array( |
|
1938 | + if ($msgOptions['approved']) { |
|
1939 | + $topics_columns = array( |
|
1852 | 1940 | 'id_member_updated = {int:poster_id}', |
1853 | 1941 | 'id_last_msg = {int:id_msg}', |
1854 | 1942 | 'num_replies = num_replies + {int:counter_increment}', |
1855 | 1943 | ); |
1856 | - else |
|
1857 | - $topics_columns = array( |
|
1944 | + } else { |
|
1945 | + $topics_columns = array( |
|
1858 | 1946 | 'unapproved_posts = unapproved_posts + {int:counter_increment}', |
1859 | 1947 | ); |
1860 | - if ($topicOptions['lock_mode'] !== null) |
|
1861 | - $topics_columns[] = 'locked = {int:locked}'; |
|
1862 | - if ($topicOptions['sticky_mode'] !== null) |
|
1863 | - $topics_columns[] = 'is_sticky = {int:is_sticky}'; |
|
1948 | + } |
|
1949 | + if ($topicOptions['lock_mode'] !== null) { |
|
1950 | + $topics_columns[] = 'locked = {int:locked}'; |
|
1951 | + } |
|
1952 | + if ($topicOptions['sticky_mode'] !== null) { |
|
1953 | + $topics_columns[] = 'is_sticky = {int:is_sticky}'; |
|
1954 | + } |
|
1864 | 1955 | |
1865 | 1956 | call_integration_hook('integrate_modify_topic', array(&$topics_columns, &$update_parameters, &$msgOptions, &$topicOptions, &$posterOptions)); |
1866 | 1957 | |
@@ -1889,8 +1980,8 @@ discard block |
||
1889 | 1980 | ); |
1890 | 1981 | |
1891 | 1982 | // Increase the number of posts and topics on the board. |
1892 | - if ($msgOptions['approved']) |
|
1893 | - $smcFunc['db_query']('', ' |
|
1983 | + if ($msgOptions['approved']) { |
|
1984 | + $smcFunc['db_query']('', ' |
|
1894 | 1985 | UPDATE {db_prefix}boards |
1895 | 1986 | SET num_posts = num_posts + 1' . ($new_topic ? ', num_topics = num_topics + 1' : '') . ' |
1896 | 1987 | WHERE id_board = {int:id_board}', |
@@ -1898,7 +1989,7 @@ discard block |
||
1898 | 1989 | 'id_board' => $topicOptions['board'], |
1899 | 1990 | ) |
1900 | 1991 | ); |
1901 | - else |
|
1992 | + } else |
|
1902 | 1993 | { |
1903 | 1994 | $smcFunc['db_query']('', ' |
1904 | 1995 | UPDATE {db_prefix}boards |
@@ -1968,8 +2059,8 @@ discard block |
||
1968 | 2059 | } |
1969 | 2060 | } |
1970 | 2061 | |
1971 | - if ($msgOptions['approved'] && empty($topicOptions['is_approved'])) |
|
1972 | - $smcFunc['db_insert']('', |
|
2062 | + if ($msgOptions['approved'] && empty($topicOptions['is_approved'])) { |
|
2063 | + $smcFunc['db_insert']('', |
|
1973 | 2064 | '{db_prefix}background_tasks', |
1974 | 2065 | array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'), |
1975 | 2066 | array( |
@@ -1981,19 +2072,22 @@ discard block |
||
1981 | 2072 | ), |
1982 | 2073 | array('id_task') |
1983 | 2074 | ); |
2075 | + } |
|
1984 | 2076 | |
1985 | 2077 | // If there's a custom search index, it may need updating... |
1986 | 2078 | require_once($sourcedir . '/Search.php'); |
1987 | 2079 | $searchAPI = findSearchAPI(); |
1988 | - if (is_callable(array($searchAPI, 'postCreated'))) |
|
1989 | - $searchAPI->postCreated($msgOptions, $topicOptions, $posterOptions); |
|
2080 | + if (is_callable(array($searchAPI, 'postCreated'))) { |
|
2081 | + $searchAPI->postCreated($msgOptions, $topicOptions, $posterOptions); |
|
2082 | + } |
|
1990 | 2083 | |
1991 | 2084 | // Increase the post counter for the user that created the post. |
1992 | 2085 | if (!empty($posterOptions['update_post_count']) && !empty($posterOptions['id']) && $msgOptions['approved']) |
1993 | 2086 | { |
1994 | 2087 | // Are you the one that happened to create this post? |
1995 | - if ($user_info['id'] == $posterOptions['id']) |
|
1996 | - $user_info['posts']++; |
|
2088 | + if ($user_info['id'] == $posterOptions['id']) { |
|
2089 | + $user_info['posts']++; |
|
2090 | + } |
|
1997 | 2091 | updateMemberData($posterOptions['id'], array('posts' => '+')); |
1998 | 2092 | } |
1999 | 2093 | |
@@ -2001,19 +2095,21 @@ discard block |
||
2001 | 2095 | $_SESSION['last_read_topic'] = 0; |
2002 | 2096 | |
2003 | 2097 | // Better safe than sorry. |
2004 | - if (isset($_SESSION['topicseen_cache'][$topicOptions['board']])) |
|
2005 | - $_SESSION['topicseen_cache'][$topicOptions['board']]--; |
|
2098 | + if (isset($_SESSION['topicseen_cache'][$topicOptions['board']])) { |
|
2099 | + $_SESSION['topicseen_cache'][$topicOptions['board']]--; |
|
2100 | + } |
|
2006 | 2101 | |
2007 | 2102 | // Update all the stats so everyone knows about this new topic and message. |
2008 | 2103 | updateStats('message', true, $msgOptions['id']); |
2009 | 2104 | |
2010 | 2105 | // Update the last message on the board assuming it's approved AND the topic is. |
2011 | - if ($msgOptions['approved']) |
|
2012 | - updateLastMessages($topicOptions['board'], $new_topic || !empty($topicOptions['is_approved']) ? $msgOptions['id'] : 0); |
|
2106 | + if ($msgOptions['approved']) { |
|
2107 | + updateLastMessages($topicOptions['board'], $new_topic || !empty($topicOptions['is_approved']) ? $msgOptions['id'] : 0); |
|
2108 | + } |
|
2013 | 2109 | |
2014 | 2110 | // Queue createPost background notification |
2015 | - if ($msgOptions['send_notifications'] && $msgOptions['approved']) |
|
2016 | - $smcFunc['db_insert']('', |
|
2111 | + if ($msgOptions['send_notifications'] && $msgOptions['approved']) { |
|
2112 | + $smcFunc['db_insert']('', |
|
2017 | 2113 | '{db_prefix}background_tasks', |
2018 | 2114 | array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'), |
2019 | 2115 | array('$sourcedir/tasks/CreatePost-Notify.php', 'CreatePost_Notify_Background', $smcFunc['json_encode'](array( |
@@ -2024,6 +2120,7 @@ discard block |
||
2024 | 2120 | )), 0), |
2025 | 2121 | array('id_task') |
2026 | 2122 | ); |
2123 | + } |
|
2027 | 2124 | |
2028 | 2125 | // Alright, done now... we can abort now, I guess... at least this much is done. |
2029 | 2126 | ignore_user_abort($previous_ignore_user_abort); |
@@ -2050,14 +2147,18 @@ discard block |
||
2050 | 2147 | |
2051 | 2148 | // This is longer than it has to be, but makes it so we only set/change what we have to. |
2052 | 2149 | $messages_columns = array(); |
2053 | - if (isset($posterOptions['name'])) |
|
2054 | - $messages_columns['poster_name'] = $posterOptions['name']; |
|
2055 | - if (isset($posterOptions['email'])) |
|
2056 | - $messages_columns['poster_email'] = $posterOptions['email']; |
|
2057 | - if (isset($msgOptions['icon'])) |
|
2058 | - $messages_columns['icon'] = $msgOptions['icon']; |
|
2059 | - if (isset($msgOptions['subject'])) |
|
2060 | - $messages_columns['subject'] = $msgOptions['subject']; |
|
2150 | + if (isset($posterOptions['name'])) { |
|
2151 | + $messages_columns['poster_name'] = $posterOptions['name']; |
|
2152 | + } |
|
2153 | + if (isset($posterOptions['email'])) { |
|
2154 | + $messages_columns['poster_email'] = $posterOptions['email']; |
|
2155 | + } |
|
2156 | + if (isset($msgOptions['icon'])) { |
|
2157 | + $messages_columns['icon'] = $msgOptions['icon']; |
|
2158 | + } |
|
2159 | + if (isset($msgOptions['subject'])) { |
|
2160 | + $messages_columns['subject'] = $msgOptions['subject']; |
|
2161 | + } |
|
2061 | 2162 | if (isset($msgOptions['body'])) |
2062 | 2163 | { |
2063 | 2164 | $messages_columns['body'] = $msgOptions['body']; |
@@ -2084,8 +2185,9 @@ discard block |
||
2084 | 2185 | $messages_columns['modified_reason'] = $msgOptions['modify_reason']; |
2085 | 2186 | $messages_columns['id_msg_modified'] = $modSettings['maxMsgID']; |
2086 | 2187 | } |
2087 | - if (isset($msgOptions['smileys_enabled'])) |
|
2088 | - $messages_columns['smileys_enabled'] = empty($msgOptions['smileys_enabled']) ? 0 : 1; |
|
2188 | + if (isset($msgOptions['smileys_enabled'])) { |
|
2189 | + $messages_columns['smileys_enabled'] = empty($msgOptions['smileys_enabled']) ? 0 : 1; |
|
2190 | + } |
|
2089 | 2191 | |
2090 | 2192 | // Which columns need to be ints? |
2091 | 2193 | $messageInts = array('modified_time', 'id_msg_modified', 'smileys_enabled'); |
@@ -2096,8 +2198,9 @@ discard block |
||
2096 | 2198 | // Update search api |
2097 | 2199 | require_once($sourcedir . '/Search.php'); |
2098 | 2200 | $searchAPI = findSearchAPI(); |
2099 | - if ($searchAPI->supportsMethod('postRemoved')) |
|
2100 | - $searchAPI->postRemoved($msgOptions['id']); |
|
2201 | + if ($searchAPI->supportsMethod('postRemoved')) { |
|
2202 | + $searchAPI->postRemoved($msgOptions['id']); |
|
2203 | + } |
|
2101 | 2204 | |
2102 | 2205 | if (!empty($modSettings['enable_mentions']) && isset($msgOptions['body'])) |
2103 | 2206 | { |
@@ -2109,23 +2212,27 @@ discard block |
||
2109 | 2212 | { |
2110 | 2213 | preg_match_all('/\[member\=([0-9]+)\]([^\[]*)\[\/member\]/U', $msgOptions['old_body'], $match); |
2111 | 2214 | |
2112 | - if (isset($match[1]) && isset($match[2]) && is_array($match[1]) && is_array($match[2])) |
|
2113 | - foreach ($match[1] as $i => $oldID) |
|
2215 | + if (isset($match[1]) && isset($match[2]) && is_array($match[1]) && is_array($match[2])) { |
|
2216 | + foreach ($match[1] as $i => $oldID) |
|
2114 | 2217 | $oldmentions[$oldID] = array('id' => $oldID, 'real_name' => $match[2][$i]); |
2218 | + } |
|
2115 | 2219 | |
2116 | - if (empty($modSettings['search_custom_index_config'])) |
|
2117 | - unset($msgOptions['old_body']); |
|
2220 | + if (empty($modSettings['search_custom_index_config'])) { |
|
2221 | + unset($msgOptions['old_body']); |
|
2222 | + } |
|
2118 | 2223 | } |
2119 | 2224 | |
2120 | 2225 | $mentions = Mentions::getMentionedMembers($msgOptions['body']); |
2121 | 2226 | $messages_columns['body'] = $msgOptions['body'] = Mentions::getBody($msgOptions['body'], $mentions); |
2122 | 2227 | |
2123 | 2228 | // Remove the poster. |
2124 | - if (isset($mentions[$user_info['id']])) |
|
2125 | - unset($mentions[$user_info['id']]); |
|
2229 | + if (isset($mentions[$user_info['id']])) { |
|
2230 | + unset($mentions[$user_info['id']]); |
|
2231 | + } |
|
2126 | 2232 | |
2127 | - if (isset($oldmentions[$user_info['id']])) |
|
2128 | - unset($oldmentions[$user_info['id']]); |
|
2233 | + if (isset($oldmentions[$user_info['id']])) { |
|
2234 | + unset($oldmentions[$user_info['id']]); |
|
2235 | + } |
|
2129 | 2236 | |
2130 | 2237 | if (is_array($mentions) && is_array($oldmentions) && count(array_diff_key($mentions, $oldmentions)) > 0 && count($mentions) > count($oldmentions)) |
2131 | 2238 | { |
@@ -2155,8 +2262,9 @@ discard block |
||
2155 | 2262 | } |
2156 | 2263 | |
2157 | 2264 | // Nothing to do? |
2158 | - if (empty($messages_columns)) |
|
2159 | - return true; |
|
2265 | + if (empty($messages_columns)) { |
|
2266 | + return true; |
|
2267 | + } |
|
2160 | 2268 | |
2161 | 2269 | // Change the post. |
2162 | 2270 | $smcFunc['db_query']('', ' |
@@ -2217,8 +2325,9 @@ discard block |
||
2217 | 2325 | // If there's a custom search index, it needs to be modified... |
2218 | 2326 | require_once($sourcedir . '/Search.php'); |
2219 | 2327 | $searchAPI = findSearchAPI(); |
2220 | - if (is_callable(array($searchAPI, 'postModified'))) |
|
2221 | - $searchAPI->postModified($msgOptions, $topicOptions, $posterOptions); |
|
2328 | + if (is_callable(array($searchAPI, 'postModified'))) { |
|
2329 | + $searchAPI->postModified($msgOptions, $topicOptions, $posterOptions); |
|
2330 | + } |
|
2222 | 2331 | |
2223 | 2332 | if (isset($msgOptions['subject'])) |
2224 | 2333 | { |
@@ -2232,14 +2341,16 @@ discard block |
||
2232 | 2341 | 'id_first_msg' => $msgOptions['id'], |
2233 | 2342 | ) |
2234 | 2343 | ); |
2235 | - if ($smcFunc['db_num_rows']($request) == 1) |
|
2236 | - updateStats('subject', $topicOptions['id'], $msgOptions['subject']); |
|
2344 | + if ($smcFunc['db_num_rows']($request) == 1) { |
|
2345 | + updateStats('subject', $topicOptions['id'], $msgOptions['subject']); |
|
2346 | + } |
|
2237 | 2347 | $smcFunc['db_free_result']($request); |
2238 | 2348 | } |
2239 | 2349 | |
2240 | 2350 | // Finally, if we are setting the approved state we need to do much more work :( |
2241 | - if ($modSettings['postmod_active'] && isset($msgOptions['approved'])) |
|
2242 | - approvePosts($msgOptions['id'], $msgOptions['approved']); |
|
2351 | + if ($modSettings['postmod_active'] && isset($msgOptions['approved'])) { |
|
2352 | + approvePosts($msgOptions['id'], $msgOptions['approved']); |
|
2353 | + } |
|
2243 | 2354 | |
2244 | 2355 | return true; |
2245 | 2356 | } |
@@ -2256,11 +2367,13 @@ discard block |
||
2256 | 2367 | { |
2257 | 2368 | global $smcFunc; |
2258 | 2369 | |
2259 | - if (!is_array($msgs)) |
|
2260 | - $msgs = array($msgs); |
|
2370 | + if (!is_array($msgs)) { |
|
2371 | + $msgs = array($msgs); |
|
2372 | + } |
|
2261 | 2373 | |
2262 | - if (empty($msgs)) |
|
2263 | - return false; |
|
2374 | + if (empty($msgs)) { |
|
2375 | + return false; |
|
2376 | + } |
|
2264 | 2377 | |
2265 | 2378 | // May as well start at the beginning, working out *what* we need to change. |
2266 | 2379 | $request = $smcFunc['db_query']('', ' |
@@ -2292,20 +2405,22 @@ discard block |
||
2292 | 2405 | $topics[] = $row['id_topic']; |
2293 | 2406 | |
2294 | 2407 | // Ensure our change array exists already. |
2295 | - if (!isset($topic_changes[$row['id_topic']])) |
|
2296 | - $topic_changes[$row['id_topic']] = array( |
|
2408 | + if (!isset($topic_changes[$row['id_topic']])) { |
|
2409 | + $topic_changes[$row['id_topic']] = array( |
|
2297 | 2410 | 'id_last_msg' => $row['id_last_msg'], |
2298 | 2411 | 'approved' => $row['topic_approved'], |
2299 | 2412 | 'replies' => 0, |
2300 | 2413 | 'unapproved_posts' => 0, |
2301 | 2414 | ); |
2302 | - if (!isset($board_changes[$row['id_board']])) |
|
2303 | - $board_changes[$row['id_board']] = array( |
|
2415 | + } |
|
2416 | + if (!isset($board_changes[$row['id_board']])) { |
|
2417 | + $board_changes[$row['id_board']] = array( |
|
2304 | 2418 | 'posts' => 0, |
2305 | 2419 | 'topics' => 0, |
2306 | 2420 | 'unapproved_posts' => 0, |
2307 | 2421 | 'unapproved_topics' => 0, |
2308 | 2422 | ); |
2423 | + } |
|
2309 | 2424 | |
2310 | 2425 | // If it's the first message then the topic state changes! |
2311 | 2426 | if ($row['id_msg'] == $row['id_first_msg']) |
@@ -2326,14 +2441,13 @@ discard block |
||
2326 | 2441 | 'poster' => $row['id_member'], |
2327 | 2442 | 'new_topic' => true, |
2328 | 2443 | ); |
2329 | - } |
|
2330 | - else |
|
2444 | + } else |
|
2331 | 2445 | { |
2332 | 2446 | $topic_changes[$row['id_topic']]['replies'] += $approve ? 1 : -1; |
2333 | 2447 | |
2334 | 2448 | // This will be a post... but don't notify unless it's not followed by approved ones. |
2335 | - if ($row['id_msg'] > $row['id_last_msg']) |
|
2336 | - $notification_posts[$row['id_topic']] = array( |
|
2449 | + if ($row['id_msg'] > $row['id_last_msg']) { |
|
2450 | + $notification_posts[$row['id_topic']] = array( |
|
2337 | 2451 | 'id' => $row['id_msg'], |
2338 | 2452 | 'body' => $row['body'], |
2339 | 2453 | 'subject' => $row['subject'], |
@@ -2344,28 +2458,33 @@ discard block |
||
2344 | 2458 | 'new_topic' => false, |
2345 | 2459 | 'msg' => $row['id_msg'], |
2346 | 2460 | ); |
2461 | + } |
|
2347 | 2462 | } |
2348 | 2463 | |
2349 | 2464 | // If this is being approved and id_msg is higher than the current id_last_msg then it changes. |
2350 | - if ($approve && $row['id_msg'] > $topic_changes[$row['id_topic']]['id_last_msg']) |
|
2351 | - $topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_msg']; |
|
2465 | + if ($approve && $row['id_msg'] > $topic_changes[$row['id_topic']]['id_last_msg']) { |
|
2466 | + $topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_msg']; |
|
2467 | + } |
|
2352 | 2468 | // If this is being unapproved, and it's equal to the id_last_msg we need to find a new one! |
2353 | - elseif (!$approve) |
|
2354 | - // Default to the first message and then we'll override in a bit ;) |
|
2469 | + elseif (!$approve) { |
|
2470 | + // Default to the first message and then we'll override in a bit ;) |
|
2355 | 2471 | $topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_first_msg']; |
2472 | + } |
|
2356 | 2473 | |
2357 | 2474 | $topic_changes[$row['id_topic']]['unapproved_posts'] += $approve ? -1 : 1; |
2358 | 2475 | $board_changes[$row['id_board']]['unapproved_posts'] += $approve ? -1 : 1; |
2359 | 2476 | $board_changes[$row['id_board']]['posts'] += $approve ? 1 : -1; |
2360 | 2477 | |
2361 | 2478 | // Post count for the user? |
2362 | - if ($row['id_member'] && empty($row['count_posts'])) |
|
2363 | - $member_post_changes[$row['id_member']] = isset($member_post_changes[$row['id_member']]) ? $member_post_changes[$row['id_member']] + 1 : 1; |
|
2479 | + if ($row['id_member'] && empty($row['count_posts'])) { |
|
2480 | + $member_post_changes[$row['id_member']] = isset($member_post_changes[$row['id_member']]) ? $member_post_changes[$row['id_member']] + 1 : 1; |
|
2481 | + } |
|
2364 | 2482 | } |
2365 | 2483 | $smcFunc['db_free_result']($request); |
2366 | 2484 | |
2367 | - if (empty($msgs)) |
|
2368 | - return; |
|
2485 | + if (empty($msgs)) { |
|
2486 | + return; |
|
2487 | + } |
|
2369 | 2488 | |
2370 | 2489 | // Now we have the differences make the changes, first the easy one. |
2371 | 2490 | $smcFunc['db_query']('', ' |
@@ -2392,14 +2511,15 @@ discard block |
||
2392 | 2511 | 'approved' => 1, |
2393 | 2512 | ) |
2394 | 2513 | ); |
2395 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2396 | - $topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_last_msg']; |
|
2514 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2515 | + $topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_last_msg']; |
|
2516 | + } |
|
2397 | 2517 | $smcFunc['db_free_result']($request); |
2398 | 2518 | } |
2399 | 2519 | |
2400 | 2520 | // ... next the topics... |
2401 | - foreach ($topic_changes as $id => $changes) |
|
2402 | - $smcFunc['db_query']('', ' |
|
2521 | + foreach ($topic_changes as $id => $changes) { |
|
2522 | + $smcFunc['db_query']('', ' |
|
2403 | 2523 | UPDATE {db_prefix}topics |
2404 | 2524 | SET approved = {int:approved}, unapproved_posts = unapproved_posts + {int:unapproved_posts}, |
2405 | 2525 | num_replies = num_replies + {int:num_replies}, id_last_msg = {int:id_last_msg} |
@@ -2412,10 +2532,11 @@ discard block |
||
2412 | 2532 | 'id_topic' => $id, |
2413 | 2533 | ) |
2414 | 2534 | ); |
2535 | + } |
|
2415 | 2536 | |
2416 | 2537 | // ... finally the boards... |
2417 | - foreach ($board_changes as $id => $changes) |
|
2418 | - $smcFunc['db_query']('', ' |
|
2538 | + foreach ($board_changes as $id => $changes) { |
|
2539 | + $smcFunc['db_query']('', ' |
|
2419 | 2540 | UPDATE {db_prefix}boards |
2420 | 2541 | SET num_posts = num_posts + {int:num_posts}, unapproved_posts = unapproved_posts + {int:unapproved_posts}, |
2421 | 2542 | num_topics = num_topics + {int:num_topics}, unapproved_topics = unapproved_topics + {int:unapproved_topics} |
@@ -2428,13 +2549,14 @@ discard block |
||
2428 | 2549 | 'id_board' => $id, |
2429 | 2550 | ) |
2430 | 2551 | ); |
2552 | + } |
|
2431 | 2553 | |
2432 | 2554 | // Finally, least importantly, notifications! |
2433 | 2555 | if ($approve) |
2434 | 2556 | { |
2435 | 2557 | $task_rows = array(); |
2436 | - foreach (array_merge($notification_topics, $notification_posts) as $topic) |
|
2437 | - $task_rows[] = array( |
|
2558 | + foreach (array_merge($notification_topics, $notification_posts) as $topic) { |
|
2559 | + $task_rows[] = array( |
|
2438 | 2560 | '$sourcedir/tasks/CreatePost-Notify.php', 'CreatePost_Notify_Background', $smcFunc['json_encode'](array( |
2439 | 2561 | 'msgOptions' => array( |
2440 | 2562 | 'id' => $topic['msg'], |
@@ -2452,14 +2574,16 @@ discard block |
||
2452 | 2574 | 'type' => $topic['new_topic'] ? 'topic' : 'reply', |
2453 | 2575 | )), 0 |
2454 | 2576 | ); |
2577 | + } |
|
2455 | 2578 | |
2456 | - if ($notify) |
|
2457 | - $smcFunc['db_insert']('', |
|
2579 | + if ($notify) { |
|
2580 | + $smcFunc['db_insert']('', |
|
2458 | 2581 | '{db_prefix}background_tasks', |
2459 | 2582 | array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'), |
2460 | 2583 | $task_rows, |
2461 | 2584 | array('id_task') |
2462 | 2585 | ); |
2586 | + } |
|
2463 | 2587 | |
2464 | 2588 | $smcFunc['db_query']('', ' |
2465 | 2589 | DELETE FROM {db_prefix}approval_queue |
@@ -2475,8 +2599,9 @@ discard block |
||
2475 | 2599 | else |
2476 | 2600 | { |
2477 | 2601 | $msgInserts = array(); |
2478 | - foreach ($msgs as $msg) |
|
2479 | - $msgInserts[] = array($msg); |
|
2602 | + foreach ($msgs as $msg) { |
|
2603 | + $msgInserts[] = array($msg); |
|
2604 | + } |
|
2480 | 2605 | |
2481 | 2606 | $smcFunc['db_insert']('ignore', |
2482 | 2607 | '{db_prefix}approval_queue', |
@@ -2490,9 +2615,10 @@ discard block |
||
2490 | 2615 | updateLastMessages(array_keys($board_changes)); |
2491 | 2616 | |
2492 | 2617 | // Post count for the members? |
2493 | - if (!empty($member_post_changes)) |
|
2494 | - foreach ($member_post_changes as $id_member => $count_change) |
|
2618 | + if (!empty($member_post_changes)) { |
|
2619 | + foreach ($member_post_changes as $id_member => $count_change) |
|
2495 | 2620 | updateMemberData($id_member, array('posts' => 'posts ' . ($approve ? '+' : '-') . ' ' . $count_change)); |
2621 | + } |
|
2496 | 2622 | |
2497 | 2623 | return true; |
2498 | 2624 | } |
@@ -2509,11 +2635,13 @@ discard block |
||
2509 | 2635 | { |
2510 | 2636 | global $smcFunc; |
2511 | 2637 | |
2512 | - if (!is_array($topics)) |
|
2513 | - $topics = array($topics); |
|
2638 | + if (!is_array($topics)) { |
|
2639 | + $topics = array($topics); |
|
2640 | + } |
|
2514 | 2641 | |
2515 | - if (empty($topics)) |
|
2516 | - return false; |
|
2642 | + if (empty($topics)) { |
|
2643 | + return false; |
|
2644 | + } |
|
2517 | 2645 | |
2518 | 2646 | $approve_type = $approve ? 0 : 1; |
2519 | 2647 | |
@@ -2529,8 +2657,9 @@ discard block |
||
2529 | 2657 | ) |
2530 | 2658 | ); |
2531 | 2659 | $msgs = array(); |
2532 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2533 | - $msgs[] = $row['id_msg']; |
|
2660 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2661 | + $msgs[] = $row['id_msg']; |
|
2662 | + } |
|
2534 | 2663 | $smcFunc['db_free_result']($request); |
2535 | 2664 | |
2536 | 2665 | return approvePosts($msgs, $approve); |
@@ -2553,11 +2682,13 @@ discard block |
||
2553 | 2682 | global $board_info, $board, $smcFunc; |
2554 | 2683 | |
2555 | 2684 | // Please - let's be sane. |
2556 | - if (empty($setboards)) |
|
2557 | - return false; |
|
2685 | + if (empty($setboards)) { |
|
2686 | + return false; |
|
2687 | + } |
|
2558 | 2688 | |
2559 | - if (!is_array($setboards)) |
|
2560 | - $setboards = array($setboards); |
|
2689 | + if (!is_array($setboards)) { |
|
2690 | + $setboards = array($setboards); |
|
2691 | + } |
|
2561 | 2692 | |
2562 | 2693 | // If we don't know the id_msg we need to find it. |
2563 | 2694 | if (!$id_msg) |
@@ -2575,15 +2706,16 @@ discard block |
||
2575 | 2706 | ) |
2576 | 2707 | ); |
2577 | 2708 | $lastMsg = array(); |
2578 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2579 | - $lastMsg[$row['id_board']] = $row['id_msg']; |
|
2709 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2710 | + $lastMsg[$row['id_board']] = $row['id_msg']; |
|
2711 | + } |
|
2580 | 2712 | $smcFunc['db_free_result']($request); |
2581 | - } |
|
2582 | - else |
|
2713 | + } else |
|
2583 | 2714 | { |
2584 | 2715 | // Just to note - there should only be one board passed if we are doing this. |
2585 | - foreach ($setboards as $id_board) |
|
2586 | - $lastMsg[$id_board] = $id_msg; |
|
2716 | + foreach ($setboards as $id_board) { |
|
2717 | + $lastMsg[$id_board] = $id_msg; |
|
2718 | + } |
|
2587 | 2719 | } |
2588 | 2720 | |
2589 | 2721 | $parent_boards = array(); |
@@ -2598,10 +2730,11 @@ discard block |
||
2598 | 2730 | $lastModified[$id_board] = 0; |
2599 | 2731 | } |
2600 | 2732 | |
2601 | - if (!empty($board) && $id_board == $board) |
|
2602 | - $parents = $board_info['parent_boards']; |
|
2603 | - else |
|
2604 | - $parents = getBoardParents($id_board); |
|
2733 | + if (!empty($board) && $id_board == $board) { |
|
2734 | + $parents = $board_info['parent_boards']; |
|
2735 | + } else { |
|
2736 | + $parents = getBoardParents($id_board); |
|
2737 | + } |
|
2605 | 2738 | |
2606 | 2739 | // Ignore any parents on the top child level. |
2607 | 2740 | // @todo Why? |
@@ -2610,10 +2743,11 @@ discard block |
||
2610 | 2743 | if ($parent['level'] != 0) |
2611 | 2744 | { |
2612 | 2745 | // If we're already doing this one as a board, is this a higher last modified? |
2613 | - if (isset($lastModified[$id]) && $lastModified[$id_board] > $lastModified[$id]) |
|
2614 | - $lastModified[$id] = $lastModified[$id_board]; |
|
2615 | - elseif (!isset($lastModified[$id]) && (!isset($parent_boards[$id]) || $parent_boards[$id] < $lastModified[$id_board])) |
|
2616 | - $parent_boards[$id] = $lastModified[$id_board]; |
|
2746 | + if (isset($lastModified[$id]) && $lastModified[$id_board] > $lastModified[$id]) { |
|
2747 | + $lastModified[$id] = $lastModified[$id_board]; |
|
2748 | + } elseif (!isset($lastModified[$id]) && (!isset($parent_boards[$id]) || $parent_boards[$id] < $lastModified[$id_board])) { |
|
2749 | + $parent_boards[$id] = $lastModified[$id_board]; |
|
2750 | + } |
|
2617 | 2751 | } |
2618 | 2752 | } |
2619 | 2753 | } |
@@ -2626,23 +2760,24 @@ discard block |
||
2626 | 2760 | // Finally, to save on queries make the changes... |
2627 | 2761 | foreach ($parent_boards as $id => $msg) |
2628 | 2762 | { |
2629 | - if (!isset($parent_updates[$msg])) |
|
2630 | - $parent_updates[$msg] = array($id); |
|
2631 | - else |
|
2632 | - $parent_updates[$msg][] = $id; |
|
2763 | + if (!isset($parent_updates[$msg])) { |
|
2764 | + $parent_updates[$msg] = array($id); |
|
2765 | + } else { |
|
2766 | + $parent_updates[$msg][] = $id; |
|
2767 | + } |
|
2633 | 2768 | } |
2634 | 2769 | |
2635 | 2770 | foreach ($lastMsg as $id => $msg) |
2636 | 2771 | { |
2637 | - if (!isset($board_updates[$msg . '-' . $lastModified[$id]])) |
|
2638 | - $board_updates[$msg . '-' . $lastModified[$id]] = array( |
|
2772 | + if (!isset($board_updates[$msg . '-' . $lastModified[$id]])) { |
|
2773 | + $board_updates[$msg . '-' . $lastModified[$id]] = array( |
|
2639 | 2774 | 'id' => $msg, |
2640 | 2775 | 'updated' => $lastModified[$id], |
2641 | 2776 | 'boards' => array($id) |
2642 | 2777 | ); |
2643 | - |
|
2644 | - else |
|
2645 | - $board_updates[$msg . '-' . $lastModified[$id]]['boards'][] = $id; |
|
2778 | + } else { |
|
2779 | + $board_updates[$msg . '-' . $lastModified[$id]]['boards'][] = $id; |
|
2780 | + } |
|
2646 | 2781 | } |
2647 | 2782 | |
2648 | 2783 | // Now commit the changes! |
@@ -2734,11 +2869,13 @@ discard block |
||
2734 | 2869 | global $txt, $mbname, $scripturl, $settings; |
2735 | 2870 | |
2736 | 2871 | // First things first, load up the email templates language file, if we need to. |
2737 | - if ($loadLang) |
|
2738 | - loadLanguage('EmailTemplates', $lang); |
|
2872 | + if ($loadLang) { |
|
2873 | + loadLanguage('EmailTemplates', $lang); |
|
2874 | + } |
|
2739 | 2875 | |
2740 | - if (!isset($txt[$template . '_subject']) || !isset($txt[$template . '_body'])) |
|
2741 | - fatal_lang_error('email_no_template', 'template', array($template)); |
|
2876 | + if (!isset($txt[$template . '_subject']) || !isset($txt[$template . '_body'])) { |
|
2877 | + fatal_lang_error('email_no_template', 'template', array($template)); |
|
2878 | + } |
|
2742 | 2879 | |
2743 | 2880 | $ret = array( |
2744 | 2881 | 'subject' => $txt[$template . '_subject'], |
@@ -2788,17 +2925,18 @@ discard block |
||
2788 | 2925 | function user_info_callback($matches) |
2789 | 2926 | { |
2790 | 2927 | global $user_info; |
2791 | - if (empty($matches[1])) |
|
2792 | - return ''; |
|
2928 | + if (empty($matches[1])) { |
|
2929 | + return ''; |
|
2930 | + } |
|
2793 | 2931 | |
2794 | 2932 | $use_ref = true; |
2795 | 2933 | $ref = &$user_info; |
2796 | 2934 | |
2797 | 2935 | foreach (explode('.', $matches[1]) as $index) |
2798 | 2936 | { |
2799 | - if ($use_ref && isset($ref[$index])) |
|
2800 | - $ref = &$ref[$index]; |
|
2801 | - else |
|
2937 | + if ($use_ref && isset($ref[$index])) { |
|
2938 | + $ref = &$ref[$index]; |
|
2939 | + } else |
|
2802 | 2940 | { |
2803 | 2941 | $use_ref = false; |
2804 | 2942 | break; |
@@ -2835,8 +2973,7 @@ discard block |
||
2835 | 2973 | if (!empty($lang_locale) && enchant_broker_dict_exists($context['enchant_broker'], $lang_locale)) |
2836 | 2974 | { |
2837 | 2975 | $enchant_link = enchant_broker_request_dict($context['enchant_broker'], $lang_locale); |
2838 | - } |
|
2839 | - elseif (enchant_broker_dict_exists($context['enchant_broker'], $txt['lang_dictionary'])) |
|
2976 | + } elseif (enchant_broker_dict_exists($context['enchant_broker'], $txt['lang_dictionary'])) |
|
2840 | 2977 | { |
2841 | 2978 | $enchant_link = enchant_broker_request_dict($context['enchant_broker'], $txt['lang_dictionary']); |
2842 | 2979 | } |
@@ -2846,8 +2983,7 @@ discard block |
||
2846 | 2983 | { |
2847 | 2984 | $context['provider'] = 'enchant'; |
2848 | 2985 | return $enchant_link; |
2849 | - } |
|
2850 | - else |
|
2986 | + } else |
|
2851 | 2987 | { |
2852 | 2988 | // Free up any resources used... |
2853 | 2989 | @enchant_broker_free($context['enchant_broker']); |
@@ -2868,8 +3004,9 @@ discard block |
||
2868 | 3004 | $pspell_link = pspell_new($txt['lang_dictionary'], $txt['lang_spelling'], '', strtr($context['character_set'], array('iso-' => 'iso', 'ISO-' => 'iso')), PSPELL_FAST | PSPELL_RUN_TOGETHER); |
2869 | 3005 | |
2870 | 3006 | // Most people don't have anything but English installed... So we use English as a last resort. |
2871 | - if (!$pspell_link) |
|
2872 | - $pspell_link = pspell_new('en', '', '', '', PSPELL_FAST | PSPELL_RUN_TOGETHER); |
|
3007 | + if (!$pspell_link) { |
|
3008 | + $pspell_link = pspell_new('en', '', '', '', PSPELL_FAST | PSPELL_RUN_TOGETHER); |
|
3009 | + } |
|
2873 | 3010 | |
2874 | 3011 | error_reporting($old); |
2875 | 3012 | ob_end_clean(); |
@@ -2909,8 +3046,7 @@ discard block |
||
2909 | 3046 | $word = iconv($txt['lang_character_set'], 'UTF-8', $word); |
2910 | 3047 | } |
2911 | 3048 | return enchant_dict_check($dict, $word); |
2912 | - } |
|
2913 | - elseif ($context['provider'] == 'pspell') |
|
3049 | + } elseif ($context['provider'] == 'pspell') |
|
2914 | 3050 | { |
2915 | 3051 | return pspell_check($dict, $word); |
2916 | 3052 | } |
@@ -2946,13 +3082,11 @@ discard block |
||
2946 | 3082 | } |
2947 | 3083 | |
2948 | 3084 | return $suggestions; |
2949 | - } |
|
2950 | - else |
|
3085 | + } else |
|
2951 | 3086 | { |
2952 | 3087 | return enchant_dict_suggest($dict, $word); |
2953 | 3088 | } |
2954 | - } |
|
2955 | - elseif ($context['provider'] == 'pspell') |
|
3089 | + } elseif ($context['provider'] == 'pspell') |
|
2956 | 3090 | { |
2957 | 3091 | return pspell_suggest($dict, $word); |
2958 | 3092 | } |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Get the latest post made on the system |
@@ -44,8 +45,9 @@ discard block |
||
44 | 45 | 'is_approved' => 1, |
45 | 46 | ) |
46 | 47 | ); |
47 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
48 | - return array(); |
|
48 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
49 | + return array(); |
|
50 | + } |
|
49 | 51 | $row = $smcFunc['db_fetch_assoc']($request); |
50 | 52 | $smcFunc['db_free_result']($request); |
51 | 53 | |
@@ -54,8 +56,9 @@ discard block |
||
54 | 56 | censorText($row['body']); |
55 | 57 | |
56 | 58 | $row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled']), array('<br>' => ' '))); |
57 | - if ($smcFunc['strlen']($row['body']) > 128) |
|
58 | - $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; |
|
59 | + if ($smcFunc['strlen']($row['body']) > 128) { |
|
60 | + $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; |
|
61 | + } |
|
59 | 62 | |
60 | 63 | // Send the data. |
61 | 64 | return array( |
@@ -83,8 +86,9 @@ discard block |
||
83 | 86 | |
84 | 87 | $context['is_redirect'] = false; |
85 | 88 | |
86 | - if (isset($_REQUEST['start']) && $_REQUEST['start'] > 95) |
|
87 | - $_REQUEST['start'] = 95; |
|
89 | + if (isset($_REQUEST['start']) && $_REQUEST['start'] > 95) { |
|
90 | + $_REQUEST['start'] = 95; |
|
91 | + } |
|
88 | 92 | |
89 | 93 | $_REQUEST['start'] = (int) $_REQUEST['start']; |
90 | 94 | |
@@ -92,8 +96,9 @@ discard block |
||
92 | 96 | if (!empty($_REQUEST['c']) && empty($board)) |
93 | 97 | { |
94 | 98 | $_REQUEST['c'] = explode(',', $_REQUEST['c']); |
95 | - foreach ($_REQUEST['c'] as $i => $c) |
|
96 | - $_REQUEST['c'][$i] = (int) $c; |
|
99 | + foreach ($_REQUEST['c'] as $i => $c) { |
|
100 | + $_REQUEST['c'][$i] = (int) $c; |
|
101 | + } |
|
97 | 102 | |
98 | 103 | if (count($_REQUEST['c']) == 1) |
99 | 104 | { |
@@ -109,8 +114,9 @@ discard block |
||
109 | 114 | list ($name) = $smcFunc['db_fetch_row']($request); |
110 | 115 | $smcFunc['db_free_result']($request); |
111 | 116 | |
112 | - if (empty($name)) |
|
113 | - fatal_lang_error('no_access', false); |
|
117 | + if (empty($name)) { |
|
118 | + fatal_lang_error('no_access', false); |
|
119 | + } |
|
114 | 120 | |
115 | 121 | $context['linktree'][] = array( |
116 | 122 | 'url' => $scripturl . '#c' . (int) $_REQUEST['c'], |
@@ -142,8 +148,9 @@ discard block |
||
142 | 148 | } |
143 | 149 | $smcFunc['db_free_result']($request); |
144 | 150 | |
145 | - if (empty($boards)) |
|
146 | - fatal_lang_error('error_no_boards_selected'); |
|
151 | + if (empty($boards)) { |
|
152 | + fatal_lang_error('error_no_boards_selected'); |
|
153 | + } |
|
147 | 154 | |
148 | 155 | $query_this_board = 'b.id_board IN ({array_int:boards})'; |
149 | 156 | $query_parameters['boards'] = $boards; |
@@ -157,12 +164,12 @@ discard block |
||
157 | 164 | } |
158 | 165 | |
159 | 166 | $context['page_index'] = constructPageIndex($scripturl . '?action=recent;c=' . implode(',', $_REQUEST['c']), $_REQUEST['start'], min(100, $total_cat_posts), 10, false); |
160 | - } |
|
161 | - elseif (!empty($_REQUEST['boards'])) |
|
167 | + } elseif (!empty($_REQUEST['boards'])) |
|
162 | 168 | { |
163 | 169 | $_REQUEST['boards'] = explode(',', $_REQUEST['boards']); |
164 | - foreach ($_REQUEST['boards'] as $i => $b) |
|
165 | - $_REQUEST['boards'][$i] = (int) $b; |
|
170 | + foreach ($_REQUEST['boards'] as $i => $b) { |
|
171 | + $_REQUEST['boards'][$i] = (int) $b; |
|
172 | + } |
|
166 | 173 | |
167 | 174 | $request = $smcFunc['db_query']('', ' |
168 | 175 | SELECT b.id_board, b.num_posts |
@@ -186,8 +193,9 @@ discard block |
||
186 | 193 | } |
187 | 194 | $smcFunc['db_free_result']($request); |
188 | 195 | |
189 | - if (empty($boards)) |
|
190 | - fatal_lang_error('error_no_boards_selected'); |
|
196 | + if (empty($boards)) { |
|
197 | + fatal_lang_error('error_no_boards_selected'); |
|
198 | + } |
|
191 | 199 | |
192 | 200 | $query_this_board = 'b.id_board IN ({array_int:boards})'; |
193 | 201 | $query_parameters['boards'] = $boards; |
@@ -201,8 +209,7 @@ discard block |
||
201 | 209 | } |
202 | 210 | |
203 | 211 | $context['page_index'] = constructPageIndex($scripturl . '?action=recent;boards=' . implode(',', $_REQUEST['boards']), $_REQUEST['start'], min(100, $total_posts), 10, false); |
204 | - } |
|
205 | - elseif (!empty($board)) |
|
212 | + } elseif (!empty($board)) |
|
206 | 213 | { |
207 | 214 | $request = $smcFunc['db_query']('', ' |
208 | 215 | SELECT num_posts, redirect |
@@ -235,8 +242,7 @@ discard block |
||
235 | 242 | } |
236 | 243 | |
237 | 244 | $context['page_index'] = constructPageIndex($scripturl . '?action=recent;board=' . $board . '.%1$d', $_REQUEST['start'], min(100, $total_posts), 10, true); |
238 | - } |
|
239 | - else |
|
245 | + } else |
|
240 | 246 | { |
241 | 247 | $query_this_board = '{query_wanna_see_board}' . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? ' |
242 | 248 | AND b.id_board != {int:recycle_board}' : ''). ' |
@@ -271,8 +277,9 @@ discard block |
||
271 | 277 | ); |
272 | 278 | |
273 | 279 | // If you selected a redirection board, don't try getting posts for it... |
274 | - if ($context['is_redirect']) |
|
275 | - $messages = 0; |
|
280 | + if ($context['is_redirect']) { |
|
281 | + $messages = 0; |
|
282 | + } |
|
276 | 283 | |
277 | 284 | $key = 'recent-' . $user_info['id'] . '-' . md5($smcFunc['json_encode'](array_diff_key($query_parameters, array('max_id_msg' => 0)))) . '-' . (int) $_REQUEST['start']; |
278 | 285 | if (!$context['is_redirect'] && (empty($modSettings['cache_enable']) || ($messages = cache_get_data($key, 120)) == null)) |
@@ -303,16 +310,18 @@ discard block |
||
303 | 310 | $query_this_board = str_replace('AND m.id_msg >= {int:max_id_msg}', '', $query_this_board); |
304 | 311 | $cache_results = true; |
305 | 312 | unset($query_parameters['max_id_msg']); |
313 | + } else { |
|
314 | + $done = true; |
|
306 | 315 | } |
307 | - else |
|
308 | - $done = true; |
|
309 | 316 | } |
310 | 317 | $messages = array(); |
311 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
312 | - $messages[] = $row['id_msg']; |
|
318 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
319 | + $messages[] = $row['id_msg']; |
|
320 | + } |
|
313 | 321 | $smcFunc['db_free_result']($request); |
314 | - if (!empty($cache_results)) |
|
315 | - cache_put_data($key, $messages, 120); |
|
322 | + if (!empty($cache_results)) { |
|
323 | + cache_put_data($key, $messages, 120); |
|
324 | + } |
|
316 | 325 | } |
317 | 326 | |
318 | 327 | // Nothing here... Or at least, nothing you can see... |
@@ -399,8 +408,9 @@ discard block |
||
399 | 408 | 'css_class' => 'windowbg', |
400 | 409 | ); |
401 | 410 | |
402 | - if ($user_info['id'] == $row['id_first_member']) |
|
403 | - $board_ids['own'][$row['id_board']][] = $row['id_msg']; |
|
411 | + if ($user_info['id'] == $row['id_first_member']) { |
|
412 | + $board_ids['own'][$row['id_board']][] = $row['id_msg']; |
|
413 | + } |
|
404 | 414 | $board_ids['any'][$row['id_board']][] = $row['id_msg']; |
405 | 415 | } |
406 | 416 | $smcFunc['db_free_result']($request); |
@@ -426,20 +436,23 @@ discard block |
||
426 | 436 | $boards = boardsAllowedTo($permission); |
427 | 437 | |
428 | 438 | // If 0 is the only thing in the array, they can do it everywhere! |
429 | - if (!empty($boards) && $boards[0] == 0) |
|
430 | - $boards = array_keys($board_ids[$type]); |
|
439 | + if (!empty($boards) && $boards[0] == 0) { |
|
440 | + $boards = array_keys($board_ids[$type]); |
|
441 | + } |
|
431 | 442 | |
432 | 443 | // Go through the boards, and look for posts they can do this on. |
433 | 444 | foreach ($boards as $board_id) |
434 | 445 | { |
435 | 446 | // Hmm, they have permission, but there are no topics from that board on this page. |
436 | - if (!isset($board_ids[$type][$board_id])) |
|
437 | - continue; |
|
447 | + if (!isset($board_ids[$type][$board_id])) { |
|
448 | + continue; |
|
449 | + } |
|
438 | 450 | |
439 | 451 | // Okay, looks like they can do it for these posts. |
440 | - foreach ($board_ids[$type][$board_id] as $counter) |
|
441 | - if ($type == 'any' || $context['posts'][$counter]['poster']['id'] == $user_info['id']) |
|
452 | + foreach ($board_ids[$type][$board_id] as $counter) { |
|
453 | + if ($type == 'any' || $context['posts'][$counter]['poster']['id'] == $user_info['id']) |
|
442 | 454 | $context['posts'][$counter][$allowed] = true; |
455 | + } |
|
443 | 456 | } |
444 | 457 | } |
445 | 458 | } |
@@ -482,17 +495,19 @@ discard block |
||
482 | 495 | $context['showing_all_topics'] = isset($_GET['all']); |
483 | 496 | $context['start'] = (int) $_REQUEST['start']; |
484 | 497 | $context['topics_per_page'] = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) ? $options['topics_per_page'] : $modSettings['defaultMaxTopics']; |
485 | - if ($_REQUEST['action'] == 'unread') |
|
486 | - $context['page_title'] = $context['showing_all_topics'] ? $txt['unread_topics_all'] : $txt['unread_topics_visit']; |
|
487 | - else |
|
488 | - $context['page_title'] = $txt['unread_replies']; |
|
498 | + if ($_REQUEST['action'] == 'unread') { |
|
499 | + $context['page_title'] = $context['showing_all_topics'] ? $txt['unread_topics_all'] : $txt['unread_topics_visit']; |
|
500 | + } else { |
|
501 | + $context['page_title'] = $txt['unread_replies']; |
|
502 | + } |
|
489 | 503 | |
490 | - if ($context['showing_all_topics'] && !empty($context['load_average']) && !empty($modSettings['loadavg_allunread']) && $context['load_average'] >= $modSettings['loadavg_allunread']) |
|
491 | - fatal_lang_error('loadavg_allunread_disabled', false); |
|
492 | - elseif ($_REQUEST['action'] != 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unreadreplies']) && $context['load_average'] >= $modSettings['loadavg_unreadreplies']) |
|
493 | - fatal_lang_error('loadavg_unreadreplies_disabled', false); |
|
494 | - elseif (!$context['showing_all_topics'] && $_REQUEST['action'] == 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unread']) && $context['load_average'] >= $modSettings['loadavg_unread']) |
|
495 | - fatal_lang_error('loadavg_unread_disabled', false); |
|
504 | + if ($context['showing_all_topics'] && !empty($context['load_average']) && !empty($modSettings['loadavg_allunread']) && $context['load_average'] >= $modSettings['loadavg_allunread']) { |
|
505 | + fatal_lang_error('loadavg_allunread_disabled', false); |
|
506 | + } elseif ($_REQUEST['action'] != 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unreadreplies']) && $context['load_average'] >= $modSettings['loadavg_unreadreplies']) { |
|
507 | + fatal_lang_error('loadavg_unreadreplies_disabled', false); |
|
508 | + } elseif (!$context['showing_all_topics'] && $_REQUEST['action'] == 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unread']) && $context['load_average'] >= $modSettings['loadavg_unread']) { |
|
509 | + fatal_lang_error('loadavg_unread_disabled', false); |
|
510 | + } |
|
496 | 511 | |
497 | 512 | // Parameters for the main query. |
498 | 513 | $query_parameters = array(); |
@@ -505,12 +520,14 @@ discard block |
||
505 | 520 | if (!empty($_REQUEST['boards'])) |
506 | 521 | { |
507 | 522 | $_REQUEST['boards'] = explode(',', $_REQUEST['boards']); |
508 | - foreach ($_REQUEST['boards'] as $b) |
|
509 | - $boards[] = (int) $b; |
|
523 | + foreach ($_REQUEST['boards'] as $b) { |
|
524 | + $boards[] = (int) $b; |
|
525 | + } |
|
510 | 526 | } |
511 | 527 | |
512 | - if (!empty($board)) |
|
513 | - $boards[] = (int) $board; |
|
528 | + if (!empty($board)) { |
|
529 | + $boards[] = (int) $board; |
|
530 | + } |
|
514 | 531 | |
515 | 532 | // The easiest thing is to just get all the boards they can see, but since we've specified the top of tree we ignore some of them |
516 | 533 | $request = $smcFunc['db_query']('', ' |
@@ -527,30 +544,31 @@ discard block |
||
527 | 544 | ) |
528 | 545 | ); |
529 | 546 | |
530 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
531 | - if (in_array($row['id_parent'], $boards)) |
|
547 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
548 | + if (in_array($row['id_parent'], $boards)) |
|
532 | 549 | $boards[] = $row['id_board']; |
550 | + } |
|
533 | 551 | |
534 | 552 | $smcFunc['db_free_result']($request); |
535 | 553 | |
536 | - if (empty($boards)) |
|
537 | - fatal_lang_error('error_no_boards_selected'); |
|
554 | + if (empty($boards)) { |
|
555 | + fatal_lang_error('error_no_boards_selected'); |
|
556 | + } |
|
538 | 557 | |
539 | 558 | $query_this_board = 'id_board IN ({array_int:boards})'; |
540 | 559 | $query_parameters['boards'] = $boards; |
541 | 560 | $context['querystring_board_limits'] = ';boards=' . implode(',', $boards) . ';start=%d'; |
542 | - } |
|
543 | - elseif (!empty($board)) |
|
561 | + } elseif (!empty($board)) |
|
544 | 562 | { |
545 | 563 | $query_this_board = 'id_board = {int:board}'; |
546 | 564 | $query_parameters['board'] = $board; |
547 | 565 | $context['querystring_board_limits'] = ';board=' . $board . '.%1$d'; |
548 | - } |
|
549 | - elseif (!empty($_REQUEST['boards'])) |
|
566 | + } elseif (!empty($_REQUEST['boards'])) |
|
550 | 567 | { |
551 | 568 | $_REQUEST['boards'] = explode(',', $_REQUEST['boards']); |
552 | - foreach ($_REQUEST['boards'] as $i => $b) |
|
553 | - $_REQUEST['boards'][$i] = (int) $b; |
|
569 | + foreach ($_REQUEST['boards'] as $i => $b) { |
|
570 | + $_REQUEST['boards'][$i] = (int) $b; |
|
571 | + } |
|
554 | 572 | |
555 | 573 | $request = $smcFunc['db_query']('', ' |
556 | 574 | SELECT b.id_board |
@@ -562,22 +580,24 @@ discard block |
||
562 | 580 | ) |
563 | 581 | ); |
564 | 582 | $boards = array(); |
565 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
566 | - $boards[] = $row['id_board']; |
|
583 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
584 | + $boards[] = $row['id_board']; |
|
585 | + } |
|
567 | 586 | $smcFunc['db_free_result']($request); |
568 | 587 | |
569 | - if (empty($boards)) |
|
570 | - fatal_lang_error('error_no_boards_selected'); |
|
588 | + if (empty($boards)) { |
|
589 | + fatal_lang_error('error_no_boards_selected'); |
|
590 | + } |
|
571 | 591 | |
572 | 592 | $query_this_board = 'id_board IN ({array_int:boards})'; |
573 | 593 | $query_parameters['boards'] = $boards; |
574 | 594 | $context['querystring_board_limits'] = ';boards=' . implode(',', $boards) . ';start=%1$d'; |
575 | - } |
|
576 | - elseif (!empty($_REQUEST['c'])) |
|
595 | + } elseif (!empty($_REQUEST['c'])) |
|
577 | 596 | { |
578 | 597 | $_REQUEST['c'] = explode(',', $_REQUEST['c']); |
579 | - foreach ($_REQUEST['c'] as $i => $c) |
|
580 | - $_REQUEST['c'][$i] = (int) $c; |
|
598 | + foreach ($_REQUEST['c'] as $i => $c) { |
|
599 | + $_REQUEST['c'][$i] = (int) $c; |
|
600 | + } |
|
581 | 601 | |
582 | 602 | $see_board = isset($_REQUEST['action']) && $_REQUEST['action'] == 'unreadreplies' ? 'query_see_board' : 'query_wanna_see_board'; |
583 | 603 | $request = $smcFunc['db_query']('', ' |
@@ -590,18 +610,19 @@ discard block |
||
590 | 610 | ) |
591 | 611 | ); |
592 | 612 | $boards = array(); |
593 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
594 | - $boards[] = $row['id_board']; |
|
613 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
614 | + $boards[] = $row['id_board']; |
|
615 | + } |
|
595 | 616 | $smcFunc['db_free_result']($request); |
596 | 617 | |
597 | - if (empty($boards)) |
|
598 | - fatal_lang_error('error_no_boards_selected'); |
|
618 | + if (empty($boards)) { |
|
619 | + fatal_lang_error('error_no_boards_selected'); |
|
620 | + } |
|
599 | 621 | |
600 | 622 | $query_this_board = 'id_board IN ({array_int:boards})'; |
601 | 623 | $query_parameters['boards'] = $boards; |
602 | 624 | $context['querystring_board_limits'] = ';c=' . implode(',', $_REQUEST['c']) . ';start=%1$d'; |
603 | - } |
|
604 | - else |
|
625 | + } else |
|
605 | 626 | { |
606 | 627 | $see_board = isset($_REQUEST['action']) && $_REQUEST['action'] == 'unreadreplies' ? 'query_see_board' : 'query_wanna_see_board'; |
607 | 628 | // Don't bother to show deleted posts! |
@@ -615,12 +636,14 @@ discard block |
||
615 | 636 | ) |
616 | 637 | ); |
617 | 638 | $boards = array(); |
618 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
619 | - $boards[] = $row['id_board']; |
|
639 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
640 | + $boards[] = $row['id_board']; |
|
641 | + } |
|
620 | 642 | $smcFunc['db_free_result']($request); |
621 | 643 | |
622 | - if (empty($boards)) |
|
623 | - fatal_lang_error('error_no_boards_available', false); |
|
644 | + if (empty($boards)) { |
|
645 | + fatal_lang_error('error_no_boards_available', false); |
|
646 | + } |
|
624 | 647 | |
625 | 648 | $query_this_board = 'id_board IN ({array_int:boards})'; |
626 | 649 | $query_parameters['boards'] = $boards; |
@@ -682,13 +705,14 @@ discard block |
||
682 | 705 | 'name' => $_REQUEST['action'] == 'unread' ? $txt['unread_topics_visit'] : $txt['unread_replies'] |
683 | 706 | ); |
684 | 707 | |
685 | - if ($context['showing_all_topics']) |
|
686 | - $context['linktree'][] = array( |
|
708 | + if ($context['showing_all_topics']) { |
|
709 | + $context['linktree'][] = array( |
|
687 | 710 | 'url' => $scripturl . '?action=' . $_REQUEST['action'] . ';all' . sprintf($context['querystring_board_limits'], 0) . $context['querystring_sort_limits'], |
688 | 711 | 'name' => $txt['unread_topics_all'] |
689 | 712 | ); |
690 | - else |
|
691 | - $txt['unread_topics_visit_none'] = strtr($txt['unread_topics_visit_none'], array('?action=unread;all' => '?action=unread;all' . sprintf($context['querystring_board_limits'], 0) . $context['querystring_sort_limits'])); |
|
713 | + } else { |
|
714 | + $txt['unread_topics_visit_none'] = strtr($txt['unread_topics_visit_none'], array('?action=unread;all' => '?action=unread;all' . sprintf($context['querystring_board_limits'], 0) . $context['querystring_sort_limits'])); |
|
715 | + } |
|
692 | 716 | |
693 | 717 | loadTemplate('Recent'); |
694 | 718 | loadTemplate('MessageIndex'); |
@@ -696,8 +720,9 @@ discard block |
||
696 | 720 | |
697 | 721 | // Setup the default topic icons... for checking they exist and the like ;) |
698 | 722 | $context['icon_sources'] = array(); |
699 | - foreach ($context['stable_icons'] as $icon) |
|
700 | - $context['icon_sources'][$icon] = 'images_url'; |
|
723 | + foreach ($context['stable_icons'] as $icon) { |
|
724 | + $context['icon_sources'][$icon] = 'images_url'; |
|
725 | + } |
|
701 | 726 | |
702 | 727 | $is_topics = $_REQUEST['action'] == 'unread'; |
703 | 728 | |
@@ -727,8 +752,7 @@ discard block |
||
727 | 752 | ); |
728 | 753 | list ($earliest_msg) = $smcFunc['db_fetch_row']($request); |
729 | 754 | $smcFunc['db_free_result']($request); |
730 | - } |
|
731 | - else |
|
755 | + } else |
|
732 | 756 | { |
733 | 757 | $request = $smcFunc['db_query']('', ' |
734 | 758 | SELECT MIN(lmr.id_msg) |
@@ -744,14 +768,14 @@ discard block |
||
744 | 768 | } |
745 | 769 | |
746 | 770 | // This is needed in case of topics marked unread. |
747 | - if (empty($earliest_msg)) |
|
748 | - $earliest_msg = 0; |
|
749 | - else |
|
771 | + if (empty($earliest_msg)) { |
|
772 | + $earliest_msg = 0; |
|
773 | + } else |
|
750 | 774 | { |
751 | 775 | // Using caching, when possible, to ignore the below slow query. |
752 | - if (isset($_SESSION['cached_log_time']) && $_SESSION['cached_log_time'][0] + 45 > time()) |
|
753 | - $earliest_msg2 = $_SESSION['cached_log_time'][1]; |
|
754 | - else |
|
776 | + if (isset($_SESSION['cached_log_time']) && $_SESSION['cached_log_time'][0] + 45 > time()) { |
|
777 | + $earliest_msg2 = $_SESSION['cached_log_time'][1]; |
|
778 | + } else |
|
755 | 779 | { |
756 | 780 | // This query is pretty slow, but it's needed to ensure nothing crucial is ignored. |
757 | 781 | $request = $smcFunc['db_query']('', ' |
@@ -766,8 +790,9 @@ discard block |
||
766 | 790 | $smcFunc['db_free_result']($request); |
767 | 791 | |
768 | 792 | // In theory this could be zero, if the first ever post is unread, so fudge it ;) |
769 | - if ($earliest_msg2 == 0) |
|
770 | - $earliest_msg2 = -1; |
|
793 | + if ($earliest_msg2 == 0) { |
|
794 | + $earliest_msg2 = -1; |
|
795 | + } |
|
771 | 796 | |
772 | 797 | $_SESSION['cached_log_time'] = array(time(), $earliest_msg2); |
773 | 798 | } |
@@ -805,9 +830,9 @@ discard block |
||
805 | 830 | 'db_error_skip' => true, |
806 | 831 | )) |
807 | 832 | ) !== false; |
833 | + } else { |
|
834 | + $have_temp_table = false; |
|
808 | 835 | } |
809 | - else |
|
810 | - $have_temp_table = false; |
|
811 | 836 | |
812 | 837 | if ($context['showing_all_topics'] && $have_temp_table) |
813 | 838 | { |
@@ -853,14 +878,15 @@ discard block |
||
853 | 878 | |
854 | 879 | $context['topics'] = array(); |
855 | 880 | $context['no_topic_listing'] = true; |
856 | - if ($context['querystring_board_limits'] == ';start=%1$d') |
|
857 | - $context['querystring_board_limits'] = ''; |
|
858 | - else |
|
859 | - $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
881 | + if ($context['querystring_board_limits'] == ';start=%1$d') { |
|
882 | + $context['querystring_board_limits'] = ''; |
|
883 | + } else { |
|
884 | + $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
885 | + } |
|
860 | 886 | return; |
887 | + } else { |
|
888 | + $min_message = (int) $min_message; |
|
861 | 889 | } |
862 | - else |
|
863 | - $min_message = (int) $min_message; |
|
864 | 890 | |
865 | 891 | $request = $smcFunc['db_query']('substring', ' |
866 | 892 | SELECT ' . $select_clause . ' |
@@ -889,8 +915,7 @@ discard block |
||
889 | 915 | 'limit' => $context['topics_per_page'], |
890 | 916 | )) |
891 | 917 | ); |
892 | - } |
|
893 | - elseif ($is_topics) |
|
918 | + } elseif ($is_topics) |
|
894 | 919 | { |
895 | 920 | $request = $smcFunc['db_query']('', ' |
896 | 921 | SELECT COUNT(*), MIN(t.id_last_msg) |
@@ -941,14 +966,15 @@ discard block |
||
941 | 966 | |
942 | 967 | $context['topics'] = array(); |
943 | 968 | $context['no_topic_listing'] = true; |
944 | - if ($context['querystring_board_limits'] == ';start=%d') |
|
945 | - $context['querystring_board_limits'] = ''; |
|
946 | - else |
|
947 | - $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
969 | + if ($context['querystring_board_limits'] == ';start=%d') { |
|
970 | + $context['querystring_board_limits'] = ''; |
|
971 | + } else { |
|
972 | + $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
973 | + } |
|
948 | 974 | return; |
975 | + } else { |
|
976 | + $min_message = (int) $min_message; |
|
949 | 977 | } |
950 | - else |
|
951 | - $min_message = (int) $min_message; |
|
952 | 978 | |
953 | 979 | $request = $smcFunc['db_query']('substring', ' |
954 | 980 | SELECT ' . $select_clause . ' |
@@ -978,8 +1004,7 @@ discard block |
||
978 | 1004 | 'limit' => $context['topics_per_page'], |
979 | 1005 | )) |
980 | 1006 | ); |
981 | - } |
|
982 | - else |
|
1007 | + } else |
|
983 | 1008 | { |
984 | 1009 | if ($modSettings['totalMessages'] > 100000) |
985 | 1010 | { |
@@ -1031,8 +1056,8 @@ discard block |
||
1031 | 1056 | ) !== false; |
1032 | 1057 | |
1033 | 1058 | // If that worked, create a sample of the log_topics table too. |
1034 | - if ($have_temp_table) |
|
1035 | - $have_temp_table = $smcFunc['db_query']('', ' |
|
1059 | + if ($have_temp_table) { |
|
1060 | + $have_temp_table = $smcFunc['db_query']('', ' |
|
1036 | 1061 | CREATE TEMPORARY TABLE {db_prefix}log_topics_posted_in ( |
1037 | 1062 | PRIMARY KEY (id_topic) |
1038 | 1063 | ) |
@@ -1045,6 +1070,7 @@ discard block |
||
1045 | 1070 | 'db_error_skip' => true, |
1046 | 1071 | ) |
1047 | 1072 | ) !== false; |
1073 | + } |
|
1048 | 1074 | } |
1049 | 1075 | |
1050 | 1076 | if (!empty($have_temp_table)) |
@@ -1060,8 +1086,7 @@ discard block |
||
1060 | 1086 | ); |
1061 | 1087 | list ($num_topics) = $smcFunc['db_fetch_row']($request); |
1062 | 1088 | $smcFunc['db_free_result']($request); |
1063 | - } |
|
1064 | - else |
|
1089 | + } else |
|
1065 | 1090 | { |
1066 | 1091 | $request = $smcFunc['db_query']('unread_fetch_topic_count', ' |
1067 | 1092 | SELECT COUNT(DISTINCT t.id_topic), MIN(t.id_last_msg) |
@@ -1102,15 +1127,16 @@ discard block |
||
1102 | 1127 | { |
1103 | 1128 | $context['topics'] = array(); |
1104 | 1129 | $context['no_topic_listing'] = true; |
1105 | - if ($context['querystring_board_limits'] == ';start=%d') |
|
1106 | - $context['querystring_board_limits'] = ''; |
|
1107 | - else |
|
1108 | - $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
1130 | + if ($context['querystring_board_limits'] == ';start=%d') { |
|
1131 | + $context['querystring_board_limits'] = ''; |
|
1132 | + } else { |
|
1133 | + $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
1134 | + } |
|
1109 | 1135 | return; |
1110 | 1136 | } |
1111 | 1137 | |
1112 | - if (!empty($have_temp_table)) |
|
1113 | - $request = $smcFunc['db_query']('', ' |
|
1138 | + if (!empty($have_temp_table)) { |
|
1139 | + $request = $smcFunc['db_query']('', ' |
|
1114 | 1140 | SELECT t.id_topic |
1115 | 1141 | FROM {db_prefix}topics_posted_in AS t |
1116 | 1142 | LEFT JOIN {db_prefix}log_topics_posted_in AS lt ON (lt.id_topic = t.id_topic) |
@@ -1124,8 +1150,8 @@ discard block |
||
1124 | 1150 | 'limit' => $context['topics_per_page'], |
1125 | 1151 | )) |
1126 | 1152 | ); |
1127 | - else |
|
1128 | - $request = $smcFunc['db_query']('', ' |
|
1153 | + } else { |
|
1154 | + $request = $smcFunc['db_query']('', ' |
|
1129 | 1155 | SELECT DISTINCT t.id_topic,'.$_REQUEST['sort'].' |
1130 | 1156 | FROM {db_prefix}topics AS t |
1131 | 1157 | INNER JOIN {db_prefix}messages AS m ON (m.id_topic = t.id_topic AND m.id_member = {int:current_member})' . (strpos($_REQUEST['sort'], 'ms.') === false ? '' : ' |
@@ -1149,10 +1175,12 @@ discard block |
||
1149 | 1175 | 'sort' => $_REQUEST['sort'], |
1150 | 1176 | )) |
1151 | 1177 | ); |
1178 | + } |
|
1152 | 1179 | |
1153 | 1180 | $topics = array(); |
1154 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1155 | - $topics[] = $row['id_topic']; |
|
1181 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1182 | + $topics[] = $row['id_topic']; |
|
1183 | + } |
|
1156 | 1184 | $smcFunc['db_free_result']($request); |
1157 | 1185 | |
1158 | 1186 | // Sanity... where have you gone? |
@@ -1160,10 +1188,11 @@ discard block |
||
1160 | 1188 | { |
1161 | 1189 | $context['topics'] = array(); |
1162 | 1190 | $context['no_topic_listing'] = true; |
1163 | - if ($context['querystring_board_limits'] == ';start=%d') |
|
1164 | - $context['querystring_board_limits'] = ''; |
|
1165 | - else |
|
1166 | - $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
1191 | + if ($context['querystring_board_limits'] == ';start=%d') { |
|
1192 | + $context['querystring_board_limits'] = ''; |
|
1193 | + } else { |
|
1194 | + $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
1195 | + } |
|
1167 | 1196 | return; |
1168 | 1197 | } |
1169 | 1198 | |
@@ -1197,8 +1226,9 @@ discard block |
||
1197 | 1226 | |
1198 | 1227 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1199 | 1228 | { |
1200 | - if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') |
|
1201 | - continue; |
|
1229 | + if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') { |
|
1230 | + continue; |
|
1231 | + } |
|
1202 | 1232 | |
1203 | 1233 | $topic_ids[] = $row['id_topic']; |
1204 | 1234 | |
@@ -1206,11 +1236,13 @@ discard block |
||
1206 | 1236 | { |
1207 | 1237 | // Limit them to 128 characters - do this FIRST because it's a lot of wasted censoring otherwise. |
1208 | 1238 | $row['first_body'] = strip_tags(strtr(parse_bbc($row['first_body'], $row['first_smileys'], $row['id_first_msg']), array('<br>' => ' '))); |
1209 | - if ($smcFunc['strlen']($row['first_body']) > 128) |
|
1210 | - $row['first_body'] = $smcFunc['substr']($row['first_body'], 0, 128) . '...'; |
|
1239 | + if ($smcFunc['strlen']($row['first_body']) > 128) { |
|
1240 | + $row['first_body'] = $smcFunc['substr']($row['first_body'], 0, 128) . '...'; |
|
1241 | + } |
|
1211 | 1242 | $row['last_body'] = strip_tags(strtr(parse_bbc($row['last_body'], $row['last_smileys'], $row['id_last_msg']), array('<br>' => ' '))); |
1212 | - if ($smcFunc['strlen']($row['last_body']) > 128) |
|
1213 | - $row['last_body'] = $smcFunc['substr']($row['last_body'], 0, 128) . '...'; |
|
1243 | + if ($smcFunc['strlen']($row['last_body']) > 128) { |
|
1244 | + $row['last_body'] = $smcFunc['substr']($row['last_body'], 0, 128) . '...'; |
|
1245 | + } |
|
1214 | 1246 | |
1215 | 1247 | // Censor the subject and message preview. |
1216 | 1248 | censorText($row['first_subject']); |
@@ -1221,23 +1253,22 @@ discard block |
||
1221 | 1253 | { |
1222 | 1254 | $row['last_subject'] = $row['first_subject']; |
1223 | 1255 | $row['last_body'] = $row['first_body']; |
1224 | - } |
|
1225 | - else |
|
1256 | + } else |
|
1226 | 1257 | { |
1227 | 1258 | censorText($row['last_subject']); |
1228 | 1259 | censorText($row['last_body']); |
1229 | 1260 | } |
1230 | - } |
|
1231 | - else |
|
1261 | + } else |
|
1232 | 1262 | { |
1233 | 1263 | $row['first_body'] = ''; |
1234 | 1264 | $row['last_body'] = ''; |
1235 | 1265 | censorText($row['first_subject']); |
1236 | 1266 | |
1237 | - if ($row['id_first_msg'] == $row['id_last_msg']) |
|
1238 | - $row['last_subject'] = $row['first_subject']; |
|
1239 | - else |
|
1240 | - censorText($row['last_subject']); |
|
1267 | + if ($row['id_first_msg'] == $row['id_last_msg']) { |
|
1268 | + $row['last_subject'] = $row['first_subject']; |
|
1269 | + } else { |
|
1270 | + censorText($row['last_subject']); |
|
1271 | + } |
|
1241 | 1272 | } |
1242 | 1273 | |
1243 | 1274 | // Decide how many pages the topic should have. |
@@ -1249,29 +1280,32 @@ discard block |
||
1249 | 1280 | $pages = constructPageIndex($scripturl . '?topic=' . $row['id_topic'] . '.%1$d', $start, $topic_length, $messages_per_page, true, false); |
1250 | 1281 | |
1251 | 1282 | // If we can use all, show all. |
1252 | - if (!empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages']) |
|
1253 | - $pages .= ' <a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>'; |
|
1283 | + if (!empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages']) { |
|
1284 | + $pages .= ' <a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>'; |
|
1285 | + } |
|
1286 | + } else { |
|
1287 | + $pages = ''; |
|
1254 | 1288 | } |
1255 | 1289 | |
1256 | - else |
|
1257 | - $pages = ''; |
|
1258 | - |
|
1259 | 1290 | // We need to check the topic icons exist... you can never be too sure! |
1260 | 1291 | if (!empty($modSettings['messageIconChecks_enable'])) |
1261 | 1292 | { |
1262 | 1293 | // First icon first... as you'd expect. |
1263 | - if (!isset($context['icon_sources'][$row['first_icon']])) |
|
1264 | - $context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
1294 | + if (!isset($context['icon_sources'][$row['first_icon']])) { |
|
1295 | + $context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
1296 | + } |
|
1265 | 1297 | // Last icon... last... duh. |
1266 | - if (!isset($context['icon_sources'][$row['last_icon']])) |
|
1267 | - $context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
1268 | - } |
|
1269 | - else |
|
1298 | + if (!isset($context['icon_sources'][$row['last_icon']])) { |
|
1299 | + $context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
1300 | + } |
|
1301 | + } else |
|
1270 | 1302 | { |
1271 | - if (!isset($context['icon_sources'][$row['first_icon']])) |
|
1272 | - $context['icon_sources'][$row['first_icon']] = 'images_url'; |
|
1273 | - if (!isset($context['icon_sources'][$row['last_icon']])) |
|
1274 | - $context['icon_sources'][$row['last_icon']] = 'images_url'; |
|
1303 | + if (!isset($context['icon_sources'][$row['first_icon']])) { |
|
1304 | + $context['icon_sources'][$row['first_icon']] = 'images_url'; |
|
1305 | + } |
|
1306 | + if (!isset($context['icon_sources'][$row['last_icon']])) { |
|
1307 | + $context['icon_sources'][$row['last_icon']] = 'images_url'; |
|
1308 | + } |
|
1275 | 1309 | } |
1276 | 1310 | |
1277 | 1311 | // Force the recycling icon if appropriate |
@@ -1285,12 +1319,14 @@ discard block |
||
1285 | 1319 | $colorClass = 'windowbg'; |
1286 | 1320 | |
1287 | 1321 | // Sticky topics should get a different color, too. |
1288 | - if ($row['is_sticky']) |
|
1289 | - $colorClass .= ' sticky'; |
|
1322 | + if ($row['is_sticky']) { |
|
1323 | + $colorClass .= ' sticky'; |
|
1324 | + } |
|
1290 | 1325 | |
1291 | 1326 | // Locked topics get special treatment as well. |
1292 | - if ($row['locked']) |
|
1293 | - $colorClass .= ' locked'; |
|
1327 | + if ($row['locked']) { |
|
1328 | + $colorClass .= ' locked'; |
|
1329 | + } |
|
1294 | 1330 | |
1295 | 1331 | // And build the array. |
1296 | 1332 | $context['topics'][$row['id_topic']] = array( |
@@ -1387,8 +1423,9 @@ discard block |
||
1387 | 1423 | ); |
1388 | 1424 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
1389 | 1425 | { |
1390 | - if (empty($context['topics'][$row['id_topic']]['is_posted_in'])) |
|
1391 | - $context['topics'][$row['id_topic']]['is_posted_in'] = true; |
|
1426 | + if (empty($context['topics'][$row['id_topic']]['is_posted_in'])) { |
|
1427 | + $context['topics'][$row['id_topic']]['is_posted_in'] = true; |
|
1428 | + } |
|
1392 | 1429 | } |
1393 | 1430 | $smcFunc['db_free_result']($result); |
1394 | 1431 | } |
@@ -1403,28 +1440,30 @@ discard block |
||
1403 | 1440 | 'markread' => array('text' => !empty($context['no_board_limits']) ? 'mark_as_read' : 'mark_read_short', 'image' => 'markread.png', 'custom' => 'data-confirm="'. $txt['are_sure_mark_read'] .'"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=' . (!empty($context['no_board_limits']) ? 'all' : 'board' . $context['querystring_board_limits']) . ';' . $context['session_var'] . '=' . $context['session_id']), |
1404 | 1441 | ); |
1405 | 1442 | |
1406 | - if ($context['showCheckboxes']) |
|
1407 | - $context['recent_buttons']['markselectread'] = array( |
|
1443 | + if ($context['showCheckboxes']) { |
|
1444 | + $context['recent_buttons']['markselectread'] = array( |
|
1408 | 1445 | 'text' => 'quick_mod_markread', |
1409 | 1446 | 'image' => 'markselectedread.png', |
1410 | 1447 | 'url' => 'javascript:document.quickModForm.submit();', |
1411 | 1448 | ); |
1449 | + } |
|
1412 | 1450 | |
1413 | - if (!empty($context['topics']) && !$context['showing_all_topics']) |
|
1414 | - $context['recent_buttons']['readall'] = array('text' => 'unread_topics_all', 'image' => 'markreadall.png', 'url' => $scripturl . '?action=unread;all' . $context['querystring_board_limits'], 'active' => true); |
|
1415 | - } |
|
1416 | - elseif (!$is_topics && isset($context['topics_to_mark'])) |
|
1451 | + if (!empty($context['topics']) && !$context['showing_all_topics']) { |
|
1452 | + $context['recent_buttons']['readall'] = array('text' => 'unread_topics_all', 'image' => 'markreadall.png', 'url' => $scripturl . '?action=unread;all' . $context['querystring_board_limits'], 'active' => true); |
|
1453 | + } |
|
1454 | + } elseif (!$is_topics && isset($context['topics_to_mark'])) |
|
1417 | 1455 | { |
1418 | 1456 | $context['recent_buttons'] = array( |
1419 | 1457 | 'markread' => array('text' => 'mark_as_read', 'image' => 'markread.png', 'custom' => 'data-confirm="'. $txt['are_sure_mark_read'] .'"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=unreadreplies;topics=' . $context['topics_to_mark'] . ';' . $context['session_var'] . '=' . $context['session_id']), |
1420 | 1458 | ); |
1421 | 1459 | |
1422 | - if ($context['showCheckboxes']) |
|
1423 | - $context['recent_buttons']['markselectread'] = array( |
|
1460 | + if ($context['showCheckboxes']) { |
|
1461 | + $context['recent_buttons']['markselectread'] = array( |
|
1424 | 1462 | 'text' => 'quick_mod_markread', |
1425 | 1463 | 'image' => 'markselectedread.png', |
1426 | 1464 | 'url' => 'javascript:document.quickModForm.submit();', |
1427 | 1465 | ); |
1466 | + } |
|
1428 | 1467 | } |
1429 | 1468 | |
1430 | 1469 | // Allow mods to add additional buttons here |
@@ -12,8 +12,9 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Don't do anything if SMF is already loaded. |
15 | -if (defined('SMF')) |
|
15 | +if (defined('SMF')) { |
|
16 | 16 | return true; |
17 | +} |
|
17 | 18 | |
18 | 19 | define('SMF', 'SSI'); |
19 | 20 | |
@@ -28,16 +29,18 @@ discard block |
||
28 | 29 | $time_start = microtime(true); |
29 | 30 | |
30 | 31 | // Just being safe... |
31 | -foreach (array('db_character_set', 'cachedir') as $variable) |
|
32 | +foreach (array('db_character_set', 'cachedir') as $variable) { |
|
32 | 33 | if (isset($GLOBALS[$variable])) |
33 | 34 | unset($GLOBALS[$variable]); |
35 | +} |
|
34 | 36 | |
35 | 37 | // Get the forum's settings for database and file paths. |
36 | 38 | require_once(dirname(__FILE__) . '/Settings.php'); |
37 | 39 | |
38 | 40 | // Make absolutely sure the cache directory is defined. |
39 | -if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) |
|
41 | +if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) { |
|
40 | 42 | $cachedir = $boarddir . '/cache'; |
43 | +} |
|
41 | 44 | |
42 | 45 | $ssi_error_reporting = error_reporting(E_ALL); |
43 | 46 | /* Set this to one of three values depending on what you want to happen in the case of a fatal error. |
@@ -48,12 +51,14 @@ discard block |
||
48 | 51 | $ssi_on_error_method = false; |
49 | 52 | |
50 | 53 | // Don't do john didley if the forum's been shut down completely. |
51 | -if ($maintenance == 2 && (!isset($ssi_maintenance_off) || $ssi_maintenance_off !== true)) |
|
54 | +if ($maintenance == 2 && (!isset($ssi_maintenance_off) || $ssi_maintenance_off !== true)) { |
|
52 | 55 | die($mmessage); |
56 | +} |
|
53 | 57 | |
54 | 58 | // Fix for using the current directory as a path. |
55 | -if (substr($sourcedir, 0, 1) == '.' && substr($sourcedir, 1, 1) != '.') |
|
59 | +if (substr($sourcedir, 0, 1) == '.' && substr($sourcedir, 1, 1) != '.') { |
|
56 | 60 | $sourcedir = dirname(__FILE__) . substr($sourcedir, 1); |
61 | +} |
|
57 | 62 | |
58 | 63 | // Load the important includes. |
59 | 64 | require_once($sourcedir . '/QueryString.php'); |
@@ -78,26 +83,30 @@ discard block |
||
78 | 83 | cleanRequest(); |
79 | 84 | |
80 | 85 | // Seed the random generator? |
81 | -if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69) |
|
86 | +if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69) { |
|
82 | 87 | smf_seed_generator(); |
88 | +} |
|
83 | 89 | |
84 | 90 | // Check on any hacking attempts. |
85 | -if (isset($_REQUEST['GLOBALS']) || isset($_COOKIE['GLOBALS'])) |
|
91 | +if (isset($_REQUEST['GLOBALS']) || isset($_COOKIE['GLOBALS'])) { |
|
86 | 92 | die('No direct access...'); |
87 | -elseif (isset($_REQUEST['ssi_theme']) && (int) $_REQUEST['ssi_theme'] == (int) $ssi_theme) |
|
93 | +} elseif (isset($_REQUEST['ssi_theme']) && (int) $_REQUEST['ssi_theme'] == (int) $ssi_theme) { |
|
88 | 94 | die('No direct access...'); |
89 | -elseif (isset($_COOKIE['ssi_theme']) && (int) $_COOKIE['ssi_theme'] == (int) $ssi_theme) |
|
95 | +} elseif (isset($_COOKIE['ssi_theme']) && (int) $_COOKIE['ssi_theme'] == (int) $ssi_theme) { |
|
90 | 96 | die('No direct access...'); |
91 | -elseif (isset($_REQUEST['ssi_layers'], $ssi_layers) && (@get_magic_quotes_gpc() ? stripslashes($_REQUEST['ssi_layers']) : $_REQUEST['ssi_layers']) == $ssi_layers) |
|
97 | +} elseif (isset($_REQUEST['ssi_layers'], $ssi_layers) && (@get_magic_quotes_gpc() ? stripslashes($_REQUEST['ssi_layers']) : $_REQUEST['ssi_layers']) == $ssi_layers) { |
|
92 | 98 | die('No direct access...'); |
93 | -if (isset($_REQUEST['context'])) |
|
99 | +} |
|
100 | +if (isset($_REQUEST['context'])) { |
|
94 | 101 | die('No direct access...'); |
102 | +} |
|
95 | 103 | |
96 | 104 | // Gzip output? (because it must be boolean and true, this can't be hacked.) |
97 | -if (isset($ssi_gzip) && $ssi_gzip === true && ini_get('zlib.output_compression') != '1' && ini_get('output_handler') != 'ob_gzhandler' && version_compare(PHP_VERSION, '4.2.0', '>=')) |
|
105 | +if (isset($ssi_gzip) && $ssi_gzip === true && ini_get('zlib.output_compression') != '1' && ini_get('output_handler') != 'ob_gzhandler' && version_compare(PHP_VERSION, '4.2.0', '>=')) { |
|
98 | 106 | ob_start('ob_gzhandler'); |
99 | -else |
|
107 | +} else { |
|
100 | 108 | $modSettings['enableCompressedOutput'] = '0'; |
109 | +} |
|
101 | 110 | |
102 | 111 | /** |
103 | 112 | * An autoloader for certain classes. |
@@ -146,9 +155,9 @@ discard block |
||
146 | 155 | ob_start('ob_sessrewrite'); |
147 | 156 | |
148 | 157 | // Start the session... known to scramble SSI includes in cases... |
149 | -if (!headers_sent()) |
|
158 | +if (!headers_sent()) { |
|
150 | 159 | loadSession(); |
151 | -else |
|
160 | +} else |
|
152 | 161 | { |
153 | 162 | if (isset($_COOKIE[session_name()]) || isset($_REQUEST[session_name()])) |
154 | 163 | { |
@@ -182,12 +191,14 @@ discard block |
||
182 | 191 | loadTheme(isset($ssi_theme) ? (int) $ssi_theme : 0); |
183 | 192 | |
184 | 193 | // @todo: probably not the best place, but somewhere it should be set... |
185 | -if (!headers_sent()) |
|
194 | +if (!headers_sent()) { |
|
186 | 195 | header('content-type: text/html; charset=' . (empty($modSettings['global_character_set']) ? (empty($txt['lang_character_set']) ? 'ISO-8859-1' : $txt['lang_character_set']) : $modSettings['global_character_set'])); |
196 | +} |
|
187 | 197 | |
188 | 198 | // Take care of any banning that needs to be done. |
189 | -if (isset($_REQUEST['ssi_ban']) || (isset($ssi_ban) && $ssi_ban === true)) |
|
199 | +if (isset($_REQUEST['ssi_ban']) || (isset($ssi_ban) && $ssi_ban === true)) { |
|
190 | 200 | is_not_banned(); |
201 | +} |
|
191 | 202 | |
192 | 203 | // Do we allow guests in here? |
193 | 204 | if (empty($ssi_guest_access) && empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && basename($_SERVER['PHP_SELF']) != 'SSI.php') |
@@ -202,17 +213,19 @@ discard block |
||
202 | 213 | { |
203 | 214 | $context['template_layers'] = $ssi_layers; |
204 | 215 | template_header(); |
205 | -} |
|
206 | -else |
|
216 | +} else { |
|
207 | 217 | setupThemeContext(); |
218 | +} |
|
208 | 219 | |
209 | 220 | // Make sure they didn't muss around with the settings... but only if it's not cli. |
210 | -if (isset($_SERVER['REMOTE_ADDR']) && !isset($_SERVER['is_cli']) && session_id() == '') |
|
221 | +if (isset($_SERVER['REMOTE_ADDR']) && !isset($_SERVER['is_cli']) && session_id() == '') { |
|
211 | 222 | trigger_error($txt['ssi_session_broken'], E_USER_NOTICE); |
223 | +} |
|
212 | 224 | |
213 | 225 | // Without visiting the forum this session variable might not be set on submit. |
214 | -if (!isset($_SESSION['USER_AGENT']) && (!isset($_GET['ssi_function']) || $_GET['ssi_function'] !== 'pollVote')) |
|
226 | +if (!isset($_SESSION['USER_AGENT']) && (!isset($_GET['ssi_function']) || $_GET['ssi_function'] !== 'pollVote')) { |
|
215 | 227 | $_SESSION['USER_AGENT'] = $_SERVER['HTTP_USER_AGENT']; |
228 | +} |
|
216 | 229 | |
217 | 230 | // Have the ability to easily add functions to SSI. |
218 | 231 | call_integration_hook('integrate_SSI'); |
@@ -221,11 +234,13 @@ discard block |
||
221 | 234 | if (basename($_SERVER['PHP_SELF']) == 'SSI.php') |
222 | 235 | { |
223 | 236 | // You shouldn't just access SSI.php directly by URL!! |
224 | - if (!isset($_GET['ssi_function'])) |
|
225 | - die(sprintf($txt['ssi_not_direct'], $user_info['is_admin'] ? '\'' . addslashes(__FILE__) . '\'' : '\'SSI.php\'')); |
|
237 | + if (!isset($_GET['ssi_function'])) { |
|
238 | + die(sprintf($txt['ssi_not_direct'], $user_info['is_admin'] ? '\'' . addslashes(__FILE__) . '\'' : '\'SSI.php\'')); |
|
239 | + } |
|
226 | 240 | // Call a function passed by GET. |
227 | - if (function_exists('ssi_' . $_GET['ssi_function']) && (!empty($modSettings['allow_guestAccess']) || !$user_info['is_guest'])) |
|
228 | - call_user_func('ssi_' . $_GET['ssi_function']); |
|
241 | + if (function_exists('ssi_' . $_GET['ssi_function']) && (!empty($modSettings['allow_guestAccess']) || !$user_info['is_guest'])) { |
|
242 | + call_user_func('ssi_' . $_GET['ssi_function']); |
|
243 | + } |
|
229 | 244 | exit; |
230 | 245 | } |
231 | 246 | |
@@ -242,9 +257,10 @@ discard block |
||
242 | 257 | */ |
243 | 258 | function ssi_shutdown() |
244 | 259 | { |
245 | - if (!isset($_GET['ssi_function']) || $_GET['ssi_function'] != 'shutdown') |
|
246 | - template_footer(); |
|
247 | -} |
|
260 | + if (!isset($_GET['ssi_function']) || $_GET['ssi_function'] != 'shutdown') { |
|
261 | + template_footer(); |
|
262 | + } |
|
263 | + } |
|
248 | 264 | |
249 | 265 | /** |
250 | 266 | * Display a welcome message, like: Hey, User, you have 0 messages, 0 are new. |
@@ -257,15 +273,17 @@ discard block |
||
257 | 273 | |
258 | 274 | if ($output_method == 'echo') |
259 | 275 | { |
260 | - if ($context['user']['is_guest']) |
|
261 | - echo sprintf($txt[$context['can_register'] ? 'welcome_guest_register' : 'welcome_guest'], $txt['guest_title'], $context['forum_name_html_safe'], $scripturl . '?action=login', 'return reqOverlayDiv(this.href, ' . JavaScriptEscape($txt['login']) . ');', $scripturl . '?action=signup'); |
|
262 | - else |
|
263 | - echo $txt['hello_member'], ' <strong>', $context['user']['name'], '</strong>', allowedTo('pm_read') ? ', ' . (empty($context['user']['messages']) ? $txt['msg_alert_no_messages'] : (($context['user']['messages'] == 1 ? sprintf($txt['msg_alert_one_message'], $scripturl . '?action=pm') : sprintf($txt['msg_alert_many_message'], $scripturl . '?action=pm', $context['user']['messages'])) . ', ' . ($context['user']['unread_messages'] == 1 ? $txt['msg_alert_one_new'] : sprintf($txt['msg_alert_many_new'], $context['user']['unread_messages'])))) : ''; |
|
276 | + if ($context['user']['is_guest']) { |
|
277 | + echo sprintf($txt[$context['can_register'] ? 'welcome_guest_register' : 'welcome_guest'], $txt['guest_title'], $context['forum_name_html_safe'], $scripturl . '?action=login', 'return reqOverlayDiv(this.href, ' . JavaScriptEscape($txt['login']) . ');', $scripturl . '?action=signup'); |
|
278 | + } else { |
|
279 | + echo $txt['hello_member'], ' <strong>', $context['user']['name'], '</strong>', allowedTo('pm_read') ? ', ' . (empty($context['user']['messages']) ? $txt['msg_alert_no_messages'] : (($context['user']['messages'] == 1 ? sprintf($txt['msg_alert_one_message'], $scripturl . '?action=pm') : sprintf($txt['msg_alert_many_message'], $scripturl . '?action=pm', $context['user']['messages'])) . ', ' . ($context['user']['unread_messages'] == 1 ? $txt['msg_alert_one_new'] : sprintf($txt['msg_alert_many_new'], $context['user']['unread_messages'])))) : ''; |
|
280 | + } |
|
264 | 281 | } |
265 | 282 | // Don't echo... then do what?! |
266 | - else |
|
267 | - return $context['user']; |
|
268 | -} |
|
283 | + else { |
|
284 | + return $context['user']; |
|
285 | + } |
|
286 | + } |
|
269 | 287 | |
270 | 288 | /** |
271 | 289 | * Display a menu bar, like is displayed at the top of the forum. |
@@ -276,12 +294,14 @@ discard block |
||
276 | 294 | { |
277 | 295 | global $context; |
278 | 296 | |
279 | - if ($output_method == 'echo') |
|
280 | - template_menu(); |
|
297 | + if ($output_method == 'echo') { |
|
298 | + template_menu(); |
|
299 | + } |
|
281 | 300 | // What else could this do? |
282 | - else |
|
283 | - return $context['menu_buttons']; |
|
284 | -} |
|
301 | + else { |
|
302 | + return $context['menu_buttons']; |
|
303 | + } |
|
304 | + } |
|
285 | 305 | |
286 | 306 | /** |
287 | 307 | * Show a logout link. |
@@ -293,20 +313,23 @@ discard block |
||
293 | 313 | { |
294 | 314 | global $context, $txt, $scripturl; |
295 | 315 | |
296 | - if ($redirect_to != '') |
|
297 | - $_SESSION['logout_url'] = $redirect_to; |
|
316 | + if ($redirect_to != '') { |
|
317 | + $_SESSION['logout_url'] = $redirect_to; |
|
318 | + } |
|
298 | 319 | |
299 | 320 | // Guests can't log out. |
300 | - if ($context['user']['is_guest']) |
|
301 | - return false; |
|
321 | + if ($context['user']['is_guest']) { |
|
322 | + return false; |
|
323 | + } |
|
302 | 324 | |
303 | 325 | $link = '<a href="' . $scripturl . '?action=logout;' . $context['session_var'] . '=' . $context['session_id'] . '">' . $txt['logout'] . '</a>'; |
304 | 326 | |
305 | - if ($output_method == 'echo') |
|
306 | - echo $link; |
|
307 | - else |
|
308 | - return $link; |
|
309 | -} |
|
327 | + if ($output_method == 'echo') { |
|
328 | + echo $link; |
|
329 | + } else { |
|
330 | + return $link; |
|
331 | + } |
|
332 | + } |
|
310 | 333 | |
311 | 334 | /** |
312 | 335 | * Recent post list: [board] Subject by Poster Date |
@@ -322,17 +345,17 @@ discard block |
||
322 | 345 | global $modSettings, $context; |
323 | 346 | |
324 | 347 | // Excluding certain boards... |
325 | - if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) |
|
326 | - $exclude_boards = array($modSettings['recycle_board']); |
|
327 | - else |
|
328 | - $exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards)); |
|
348 | + if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) { |
|
349 | + $exclude_boards = array($modSettings['recycle_board']); |
|
350 | + } else { |
|
351 | + $exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards)); |
|
352 | + } |
|
329 | 353 | |
330 | 354 | // What about including certain boards - note we do some protection here as pre-2.0 didn't have this parameter. |
331 | 355 | if (is_array($include_boards) || (int) $include_boards === $include_boards) |
332 | 356 | { |
333 | 357 | $include_boards = is_array($include_boards) ? $include_boards : array($include_boards); |
334 | - } |
|
335 | - elseif ($include_boards != null) |
|
358 | + } elseif ($include_boards != null) |
|
336 | 359 | { |
337 | 360 | $include_boards = array(); |
338 | 361 | } |
@@ -369,8 +392,9 @@ discard block |
||
369 | 392 | { |
370 | 393 | global $modSettings; |
371 | 394 | |
372 | - if (empty($post_ids)) |
|
373 | - return; |
|
395 | + if (empty($post_ids)) { |
|
396 | + return; |
|
397 | + } |
|
374 | 398 | |
375 | 399 | // Allow the user to request more than one - why not? |
376 | 400 | $post_ids = is_array($post_ids) ? $post_ids : array($post_ids); |
@@ -405,8 +429,9 @@ discard block |
||
405 | 429 | global $scripturl, $txt, $user_info; |
406 | 430 | global $modSettings, $smcFunc, $context; |
407 | 431 | |
408 | - if (!empty($modSettings['enable_likes'])) |
|
409 | - $context['can_like'] = allowedTo('likes_like'); |
|
432 | + if (!empty($modSettings['enable_likes'])) { |
|
433 | + $context['can_like'] = allowedTo('likes_like'); |
|
434 | + } |
|
410 | 435 | |
411 | 436 | // Find all the posts. Newer ones will have higher IDs. |
412 | 437 | $request = $smcFunc['db_query']('substring', ' |
@@ -472,12 +497,13 @@ discard block |
||
472 | 497 | ); |
473 | 498 | |
474 | 499 | // Get the likes for each message. |
475 | - if (!empty($modSettings['enable_likes'])) |
|
476 | - $posts[$row['id_msg']]['likes'] = array( |
|
500 | + if (!empty($modSettings['enable_likes'])) { |
|
501 | + $posts[$row['id_msg']]['likes'] = array( |
|
477 | 502 | 'count' => $row['likes'], |
478 | 503 | 'you' => in_array($row['id_msg'], prepareLikesContext($row['id_topic'])), |
479 | 504 | 'can_like' => !$context['user']['is_guest'] && $row['id_member'] != $context['user']['id'] && !empty($context['can_like']), |
480 | 505 | ); |
506 | + } |
|
481 | 507 | } |
482 | 508 | $smcFunc['db_free_result']($request); |
483 | 509 | |
@@ -485,13 +511,14 @@ discard block |
||
485 | 511 | call_integration_hook('integrate_ssi_queryPosts', array(&$posts)); |
486 | 512 | |
487 | 513 | // Just return it. |
488 | - if ($output_method != 'echo' || empty($posts)) |
|
489 | - return $posts; |
|
514 | + if ($output_method != 'echo' || empty($posts)) { |
|
515 | + return $posts; |
|
516 | + } |
|
490 | 517 | |
491 | 518 | echo ' |
492 | 519 | <table style="border: none" class="ssi_table">'; |
493 | - foreach ($posts as $post) |
|
494 | - echo ' |
|
520 | + foreach ($posts as $post) { |
|
521 | + echo ' |
|
495 | 522 | <tr> |
496 | 523 | <td style="text-align: right; vertical-align: top; white-space: nowrap"> |
497 | 524 | [', $post['board']['link'], '] |
@@ -505,6 +532,7 @@ discard block |
||
505 | 532 | ', $post['time'], ' |
506 | 533 | </td> |
507 | 534 | </tr>'; |
535 | + } |
|
508 | 536 | echo ' |
509 | 537 | </table>'; |
510 | 538 | } |
@@ -522,25 +550,26 @@ discard block |
||
522 | 550 | global $settings, $scripturl, $txt, $user_info; |
523 | 551 | global $modSettings, $smcFunc, $context; |
524 | 552 | |
525 | - if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) |
|
526 | - $exclude_boards = array($modSettings['recycle_board']); |
|
527 | - else |
|
528 | - $exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards)); |
|
553 | + if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) { |
|
554 | + $exclude_boards = array($modSettings['recycle_board']); |
|
555 | + } else { |
|
556 | + $exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards)); |
|
557 | + } |
|
529 | 558 | |
530 | 559 | // Only some boards?. |
531 | 560 | if (is_array($include_boards) || (int) $include_boards === $include_boards) |
532 | 561 | { |
533 | 562 | $include_boards = is_array($include_boards) ? $include_boards : array($include_boards); |
534 | - } |
|
535 | - elseif ($include_boards != null) |
|
563 | + } elseif ($include_boards != null) |
|
536 | 564 | { |
537 | 565 | $output_method = $include_boards; |
538 | 566 | $include_boards = array(); |
539 | 567 | } |
540 | 568 | |
541 | 569 | $icon_sources = array(); |
542 | - foreach ($context['stable_icons'] as $icon) |
|
543 | - $icon_sources[$icon] = 'images_url'; |
|
570 | + foreach ($context['stable_icons'] as $icon) { |
|
571 | + $icon_sources[$icon] = 'images_url'; |
|
572 | + } |
|
544 | 573 | |
545 | 574 | // Find all the posts in distinct topics. Newer ones will have higher IDs. |
546 | 575 | $request = $smcFunc['db_query']('substring', ' |
@@ -565,13 +594,15 @@ discard block |
||
565 | 594 | ) |
566 | 595 | ); |
567 | 596 | $topics = array(); |
568 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
569 | - $topics[$row['id_topic']] = $row; |
|
597 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
598 | + $topics[$row['id_topic']] = $row; |
|
599 | + } |
|
570 | 600 | $smcFunc['db_free_result']($request); |
571 | 601 | |
572 | 602 | // Did we find anything? If not, bail. |
573 | - if (empty($topics)) |
|
574 | - return array(); |
|
603 | + if (empty($topics)) { |
|
604 | + return array(); |
|
605 | + } |
|
575 | 606 | |
576 | 607 | $recycle_board = !empty($modSettings['recycle_enable']) && !empty($modSettings['recycle_board']) ? (int) $modSettings['recycle_board'] : 0; |
577 | 608 | |
@@ -599,21 +630,24 @@ discard block |
||
599 | 630 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
600 | 631 | { |
601 | 632 | $row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']), array('<br>' => ' '))); |
602 | - if ($smcFunc['strlen']($row['body']) > 128) |
|
603 | - $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; |
|
633 | + if ($smcFunc['strlen']($row['body']) > 128) { |
|
634 | + $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; |
|
635 | + } |
|
604 | 636 | |
605 | 637 | // Censor the subject. |
606 | 638 | censorText($row['subject']); |
607 | 639 | censorText($row['body']); |
608 | 640 | |
609 | 641 | // Recycled icon |
610 | - if (!empty($recycle_board) && $topics[$row['id_topic']]['id_board']) |
|
611 | - $row['icon'] = 'recycled'; |
|
642 | + if (!empty($recycle_board) && $topics[$row['id_topic']]['id_board']) { |
|
643 | + $row['icon'] = 'recycled'; |
|
644 | + } |
|
612 | 645 | |
613 | - if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) |
|
614 | - $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
615 | - elseif (!isset($icon_sources[$row['icon']])) |
|
616 | - $icon_sources[$row['icon']] = 'images_url'; |
|
646 | + if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) { |
|
647 | + $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
648 | + } elseif (!isset($icon_sources[$row['icon']])) { |
|
649 | + $icon_sources[$row['icon']] = 'images_url'; |
|
650 | + } |
|
617 | 651 | |
618 | 652 | // Build the array. |
619 | 653 | $posts[] = array( |
@@ -652,13 +686,14 @@ discard block |
||
652 | 686 | call_integration_hook('integrate_ssi_recentTopics', array(&$posts)); |
653 | 687 | |
654 | 688 | // Just return it. |
655 | - if ($output_method != 'echo' || empty($posts)) |
|
656 | - return $posts; |
|
689 | + if ($output_method != 'echo' || empty($posts)) { |
|
690 | + return $posts; |
|
691 | + } |
|
657 | 692 | |
658 | 693 | echo ' |
659 | 694 | <table style="border: none" class="ssi_table">'; |
660 | - foreach ($posts as $post) |
|
661 | - echo ' |
|
695 | + foreach ($posts as $post) { |
|
696 | + echo ' |
|
662 | 697 | <tr> |
663 | 698 | <td style="text-align: right; vertical-align: top; white-space: nowrap"> |
664 | 699 | [', $post['board']['link'], '] |
@@ -672,6 +707,7 @@ discard block |
||
672 | 707 | ', $post['time'], ' |
673 | 708 | </td> |
674 | 709 | </tr>'; |
710 | + } |
|
675 | 711 | echo ' |
676 | 712 | </table>'; |
677 | 713 | } |
@@ -696,27 +732,30 @@ discard block |
||
696 | 732 | ) |
697 | 733 | ); |
698 | 734 | $return = array(); |
699 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
700 | - $return[] = array( |
|
735 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
736 | + $return[] = array( |
|
701 | 737 | 'id' => $row['id_member'], |
702 | 738 | 'name' => $row['real_name'], |
703 | 739 | 'href' => $scripturl . '?action=profile;u=' . $row['id_member'], |
704 | 740 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>', |
705 | 741 | 'posts' => $row['posts'] |
706 | 742 | ); |
743 | + } |
|
707 | 744 | $smcFunc['db_free_result']($request); |
708 | 745 | |
709 | 746 | // If mods want to do somthing with this list of members, let them do that now. |
710 | 747 | call_integration_hook('integrate_ssi_topPoster', array(&$return)); |
711 | 748 | |
712 | 749 | // Just return all the top posters. |
713 | - if ($output_method != 'echo') |
|
714 | - return $return; |
|
750 | + if ($output_method != 'echo') { |
|
751 | + return $return; |
|
752 | + } |
|
715 | 753 | |
716 | 754 | // Make a quick array to list the links in. |
717 | 755 | $temp_array = array(); |
718 | - foreach ($return as $member) |
|
719 | - $temp_array[] = $member['link']; |
|
756 | + foreach ($return as $member) { |
|
757 | + $temp_array[] = $member['link']; |
|
758 | + } |
|
720 | 759 | |
721 | 760 | echo implode(', ', $temp_array); |
722 | 761 | } |
@@ -748,8 +787,8 @@ discard block |
||
748 | 787 | ) |
749 | 788 | ); |
750 | 789 | $boards = array(); |
751 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
752 | - $boards[] = array( |
|
790 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
791 | + $boards[] = array( |
|
753 | 792 | 'id' => $row['id_board'], |
754 | 793 | 'num_posts' => $row['num_posts'], |
755 | 794 | 'num_topics' => $row['num_topics'], |
@@ -758,14 +797,16 @@ discard block |
||
758 | 797 | 'href' => $scripturl . '?board=' . $row['id_board'] . '.0', |
759 | 798 | 'link' => '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>' |
760 | 799 | ); |
800 | + } |
|
761 | 801 | $smcFunc['db_free_result']($request); |
762 | 802 | |
763 | 803 | // If mods want to do somthing with this list of boards, let them do that now. |
764 | 804 | call_integration_hook('integrate_ssi_topBoards', array(&$boards)); |
765 | 805 | |
766 | 806 | // If we shouldn't output or have nothing to output, just jump out. |
767 | - if ($output_method != 'echo' || empty($boards)) |
|
768 | - return $boards; |
|
807 | + if ($output_method != 'echo' || empty($boards)) { |
|
808 | + return $boards; |
|
809 | + } |
|
769 | 810 | |
770 | 811 | echo ' |
771 | 812 | <table class="ssi_table"> |
@@ -774,13 +815,14 @@ discard block |
||
774 | 815 | <th style="text-align: left">', $txt['board_topics'], '</th> |
775 | 816 | <th style="text-align: left">', $txt['posts'], '</th> |
776 | 817 | </tr>'; |
777 | - foreach ($boards as $sBoard) |
|
778 | - echo ' |
|
818 | + foreach ($boards as $sBoard) { |
|
819 | + echo ' |
|
779 | 820 | <tr> |
780 | 821 | <td>', $sBoard['link'], $sBoard['new'] ? ' <a href="' . $sBoard['href'] . '" class="new_posts">' . $txt['new'] . '</a>' : '', '</td> |
781 | 822 | <td style="text-align: right">', comma_format($sBoard['num_topics']), '</td> |
782 | 823 | <td style="text-align: right">', comma_format($sBoard['num_posts']), '</td> |
783 | 824 | </tr>'; |
825 | + } |
|
784 | 826 | echo ' |
785 | 827 | </table>'; |
786 | 828 | } |
@@ -813,12 +855,13 @@ discard block |
||
813 | 855 | ) |
814 | 856 | ); |
815 | 857 | $topic_ids = array(); |
816 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
817 | - $topic_ids[] = $row['id_topic']; |
|
858 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
859 | + $topic_ids[] = $row['id_topic']; |
|
860 | + } |
|
818 | 861 | $smcFunc['db_free_result']($request); |
862 | + } else { |
|
863 | + $topic_ids = array(); |
|
819 | 864 | } |
820 | - else |
|
821 | - $topic_ids = array(); |
|
822 | 865 | |
823 | 866 | $request = $smcFunc['db_query']('', ' |
824 | 867 | SELECT m.subject, m.id_topic, t.num_views, t.num_replies |
@@ -857,8 +900,9 @@ discard block |
||
857 | 900 | // If mods want to do somthing with this list of topics, let them do that now. |
858 | 901 | call_integration_hook('integrate_ssi_topTopics', array(&$topics, $type)); |
859 | 902 | |
860 | - if ($output_method != 'echo' || empty($topics)) |
|
861 | - return $topics; |
|
903 | + if ($output_method != 'echo' || empty($topics)) { |
|
904 | + return $topics; |
|
905 | + } |
|
862 | 906 | |
863 | 907 | echo ' |
864 | 908 | <table class="ssi_table"> |
@@ -867,8 +911,8 @@ discard block |
||
867 | 911 | <th style="text-align: left">', $txt['views'], '</th> |
868 | 912 | <th style="text-align: left">', $txt['replies'], '</th> |
869 | 913 | </tr>'; |
870 | - foreach ($topics as $sTopic) |
|
871 | - echo ' |
|
914 | + foreach ($topics as $sTopic) { |
|
915 | + echo ' |
|
872 | 916 | <tr> |
873 | 917 | <td style="text-align: left"> |
874 | 918 | ', $sTopic['link'], ' |
@@ -876,6 +920,7 @@ discard block |
||
876 | 920 | <td style="text-align: right">', comma_format($sTopic['num_views']), '</td> |
877 | 921 | <td style="text-align: right">', comma_format($sTopic['num_replies']), '</td> |
878 | 922 | </tr>'; |
923 | + } |
|
879 | 924 | echo ' |
880 | 925 | </table>'; |
881 | 926 | } |
@@ -911,12 +956,13 @@ discard block |
||
911 | 956 | { |
912 | 957 | global $txt, $context; |
913 | 958 | |
914 | - if ($output_method == 'echo') |
|
915 | - echo ' |
|
959 | + if ($output_method == 'echo') { |
|
960 | + echo ' |
|
916 | 961 | ', sprintf($txt['welcome_newest_member'], $context['common_stats']['latest_member']['link']), '<br>'; |
917 | - else |
|
918 | - return $context['common_stats']['latest_member']; |
|
919 | -} |
|
962 | + } else { |
|
963 | + return $context['common_stats']['latest_member']; |
|
964 | + } |
|
965 | + } |
|
920 | 966 | |
921 | 967 | /** |
922 | 968 | * Fetches a random member. |
@@ -965,8 +1011,9 @@ discard block |
||
965 | 1011 | } |
966 | 1012 | |
967 | 1013 | // Just to be sure put the random generator back to something... random. |
968 | - if ($random_type != '') |
|
969 | - mt_srand(time()); |
|
1014 | + if ($random_type != '') { |
|
1015 | + mt_srand(time()); |
|
1016 | + } |
|
970 | 1017 | |
971 | 1018 | return $result; |
972 | 1019 | } |
@@ -979,8 +1026,9 @@ discard block |
||
979 | 1026 | */ |
980 | 1027 | function ssi_fetchMember($member_ids = array(), $output_method = 'echo') |
981 | 1028 | { |
982 | - if (empty($member_ids)) |
|
983 | - return; |
|
1029 | + if (empty($member_ids)) { |
|
1030 | + return; |
|
1031 | + } |
|
984 | 1032 | |
985 | 1033 | // Can have more than one member if you really want... |
986 | 1034 | $member_ids = is_array($member_ids) ? $member_ids : array($member_ids); |
@@ -1005,8 +1053,9 @@ discard block |
||
1005 | 1053 | */ |
1006 | 1054 | function ssi_fetchGroupMembers($group_id = null, $output_method = 'echo') |
1007 | 1055 | { |
1008 | - if ($group_id === null) |
|
1009 | - return; |
|
1056 | + if ($group_id === null) { |
|
1057 | + return; |
|
1058 | + } |
|
1010 | 1059 | |
1011 | 1060 | $query_where = ' |
1012 | 1061 | id_group = {int:id_group} |
@@ -1033,8 +1082,9 @@ discard block |
||
1033 | 1082 | { |
1034 | 1083 | global $smcFunc, $memberContext; |
1035 | 1084 | |
1036 | - if ($query_where === null) |
|
1037 | - return; |
|
1085 | + if ($query_where === null) { |
|
1086 | + return; |
|
1087 | + } |
|
1038 | 1088 | |
1039 | 1089 | // Fetch the members in question. |
1040 | 1090 | $request = $smcFunc['db_query']('', ' |
@@ -1047,12 +1097,14 @@ discard block |
||
1047 | 1097 | )) |
1048 | 1098 | ); |
1049 | 1099 | $members = array(); |
1050 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1051 | - $members[] = $row['id_member']; |
|
1100 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1101 | + $members[] = $row['id_member']; |
|
1102 | + } |
|
1052 | 1103 | $smcFunc['db_free_result']($request); |
1053 | 1104 | |
1054 | - if (empty($members)) |
|
1055 | - return array(); |
|
1105 | + if (empty($members)) { |
|
1106 | + return array(); |
|
1107 | + } |
|
1056 | 1108 | |
1057 | 1109 | // If mods want to do somthing with this list of members, let them do that now. |
1058 | 1110 | call_integration_hook('integrate_ssi_queryMembers', array(&$members)); |
@@ -1061,23 +1113,25 @@ discard block |
||
1061 | 1113 | loadMemberData($members); |
1062 | 1114 | |
1063 | 1115 | // Draw the table! |
1064 | - if ($output_method == 'echo') |
|
1065 | - echo ' |
|
1116 | + if ($output_method == 'echo') { |
|
1117 | + echo ' |
|
1066 | 1118 | <table style="border: none" class="ssi_table">'; |
1119 | + } |
|
1067 | 1120 | |
1068 | 1121 | $query_members = array(); |
1069 | 1122 | foreach ($members as $member) |
1070 | 1123 | { |
1071 | 1124 | // Load their context data. |
1072 | - if (!loadMemberContext($member)) |
|
1073 | - continue; |
|
1125 | + if (!loadMemberContext($member)) { |
|
1126 | + continue; |
|
1127 | + } |
|
1074 | 1128 | |
1075 | 1129 | // Store this member's information. |
1076 | 1130 | $query_members[$member] = $memberContext[$member]; |
1077 | 1131 | |
1078 | 1132 | // Only do something if we're echo'ing. |
1079 | - if ($output_method == 'echo') |
|
1080 | - echo ' |
|
1133 | + if ($output_method == 'echo') { |
|
1134 | + echo ' |
|
1081 | 1135 | <tr> |
1082 | 1136 | <td style="text-align: right; vertical-align: top; white-space: nowrap"> |
1083 | 1137 | ', $query_members[$member]['link'], ' |
@@ -1085,12 +1139,14 @@ discard block |
||
1085 | 1139 | <br>', $query_members[$member]['avatar']['image'], ' |
1086 | 1140 | </td> |
1087 | 1141 | </tr>'; |
1142 | + } |
|
1088 | 1143 | } |
1089 | 1144 | |
1090 | 1145 | // End the table if appropriate. |
1091 | - if ($output_method == 'echo') |
|
1092 | - echo ' |
|
1146 | + if ($output_method == 'echo') { |
|
1147 | + echo ' |
|
1093 | 1148 | </table>'; |
1149 | + } |
|
1094 | 1150 | |
1095 | 1151 | // Send back the data. |
1096 | 1152 | return $query_members; |
@@ -1105,8 +1161,9 @@ discard block |
||
1105 | 1161 | { |
1106 | 1162 | global $txt, $scripturl, $modSettings, $smcFunc; |
1107 | 1163 | |
1108 | - if (!allowedTo('view_stats')) |
|
1109 | - return; |
|
1164 | + if (!allowedTo('view_stats')) { |
|
1165 | + return; |
|
1166 | + } |
|
1110 | 1167 | |
1111 | 1168 | $totals = array( |
1112 | 1169 | 'members' => $modSettings['totalMembers'], |
@@ -1135,8 +1192,9 @@ discard block |
||
1135 | 1192 | // If mods want to do somthing with the board stats, let them do that now. |
1136 | 1193 | call_integration_hook('integrate_ssi_boardStats', array(&$totals)); |
1137 | 1194 | |
1138 | - if ($output_method != 'echo') |
|
1139 | - return $totals; |
|
1195 | + if ($output_method != 'echo') { |
|
1196 | + return $totals; |
|
1197 | + } |
|
1140 | 1198 | |
1141 | 1199 | echo ' |
1142 | 1200 | ', $txt['total_members'], ': <a href="', $scripturl . '?action=mlist">', comma_format($totals['members']), '</a><br> |
@@ -1165,8 +1223,8 @@ discard block |
||
1165 | 1223 | call_integration_hook('integrate_ssi_whosOnline', array(&$return)); |
1166 | 1224 | |
1167 | 1225 | // Add some redundancy for backwards compatibility reasons. |
1168 | - if ($output_method != 'echo') |
|
1169 | - return $return + array( |
|
1226 | + if ($output_method != 'echo') { |
|
1227 | + return $return + array( |
|
1170 | 1228 | 'users' => $return['users_online'], |
1171 | 1229 | 'guests' => $return['num_guests'], |
1172 | 1230 | 'hidden' => $return['num_users_hidden'], |
@@ -1174,29 +1232,35 @@ discard block |
||
1174 | 1232 | 'num_users' => $return['num_users_online'], |
1175 | 1233 | 'total_users' => $return['num_users_online'] + $return['num_guests'], |
1176 | 1234 | ); |
1235 | + } |
|
1177 | 1236 | |
1178 | 1237 | echo ' |
1179 | 1238 | ', comma_format($return['num_guests']), ' ', $return['num_guests'] == 1 ? $txt['guest'] : $txt['guests'], ', ', comma_format($return['num_users_online']), ' ', $return['num_users_online'] == 1 ? $txt['user'] : $txt['users']; |
1180 | 1239 | |
1181 | 1240 | $bracketList = array(); |
1182 | - if (!empty($user_info['buddies'])) |
|
1183 | - $bracketList[] = comma_format($return['num_buddies']) . ' ' . ($return['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']); |
|
1184 | - if (!empty($return['num_spiders'])) |
|
1185 | - $bracketList[] = comma_format($return['num_spiders']) . ' ' . ($return['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']); |
|
1186 | - if (!empty($return['num_users_hidden'])) |
|
1187 | - $bracketList[] = comma_format($return['num_users_hidden']) . ' ' . $txt['hidden']; |
|
1241 | + if (!empty($user_info['buddies'])) { |
|
1242 | + $bracketList[] = comma_format($return['num_buddies']) . ' ' . ($return['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']); |
|
1243 | + } |
|
1244 | + if (!empty($return['num_spiders'])) { |
|
1245 | + $bracketList[] = comma_format($return['num_spiders']) . ' ' . ($return['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']); |
|
1246 | + } |
|
1247 | + if (!empty($return['num_users_hidden'])) { |
|
1248 | + $bracketList[] = comma_format($return['num_users_hidden']) . ' ' . $txt['hidden']; |
|
1249 | + } |
|
1188 | 1250 | |
1189 | - if (!empty($bracketList)) |
|
1190 | - echo ' (' . implode(', ', $bracketList) . ')'; |
|
1251 | + if (!empty($bracketList)) { |
|
1252 | + echo ' (' . implode(', ', $bracketList) . ')'; |
|
1253 | + } |
|
1191 | 1254 | |
1192 | 1255 | echo '<br> |
1193 | 1256 | ', implode(', ', $return['list_users_online']); |
1194 | 1257 | |
1195 | 1258 | // Showing membergroups? |
1196 | - if (!empty($settings['show_group_key']) && !empty($return['membergroups'])) |
|
1197 | - echo '<br> |
|
1259 | + if (!empty($settings['show_group_key']) && !empty($return['membergroups'])) { |
|
1260 | + echo '<br> |
|
1198 | 1261 | [' . implode('] [', $return['membergroups']) . ']'; |
1199 | -} |
|
1262 | + } |
|
1263 | + } |
|
1200 | 1264 | |
1201 | 1265 | /** |
1202 | 1266 | * Just like whosOnline except it also logs the online presence. |
@@ -1207,11 +1271,12 @@ discard block |
||
1207 | 1271 | { |
1208 | 1272 | writeLog(); |
1209 | 1273 | |
1210 | - if ($output_method != 'echo') |
|
1211 | - return ssi_whosOnline($output_method); |
|
1212 | - else |
|
1213 | - ssi_whosOnline($output_method); |
|
1214 | -} |
|
1274 | + if ($output_method != 'echo') { |
|
1275 | + return ssi_whosOnline($output_method); |
|
1276 | + } else { |
|
1277 | + ssi_whosOnline($output_method); |
|
1278 | + } |
|
1279 | + } |
|
1215 | 1280 | |
1216 | 1281 | // Shows a login box. |
1217 | 1282 | /** |
@@ -1224,11 +1289,13 @@ discard block |
||
1224 | 1289 | { |
1225 | 1290 | global $scripturl, $txt, $user_info, $context; |
1226 | 1291 | |
1227 | - if ($redirect_to != '') |
|
1228 | - $_SESSION['login_url'] = $redirect_to; |
|
1292 | + if ($redirect_to != '') { |
|
1293 | + $_SESSION['login_url'] = $redirect_to; |
|
1294 | + } |
|
1229 | 1295 | |
1230 | - if ($output_method != 'echo' || !$user_info['is_guest']) |
|
1231 | - return $user_info['is_guest']; |
|
1296 | + if ($output_method != 'echo' || !$user_info['is_guest']) { |
|
1297 | + return $user_info['is_guest']; |
|
1298 | + } |
|
1232 | 1299 | |
1233 | 1300 | // Create a login token |
1234 | 1301 | createToken('login'); |
@@ -1280,8 +1347,9 @@ discard block |
||
1280 | 1347 | |
1281 | 1348 | $boardsAllowed = array_intersect(boardsAllowedTo('poll_view'), boardsAllowedTo('poll_vote')); |
1282 | 1349 | |
1283 | - if (empty($boardsAllowed)) |
|
1284 | - return array(); |
|
1350 | + if (empty($boardsAllowed)) { |
|
1351 | + return array(); |
|
1352 | + } |
|
1285 | 1353 | |
1286 | 1354 | $request = $smcFunc['db_query']('', ' |
1287 | 1355 | SELECT p.id_poll, p.question, t.id_topic, p.max_votes, p.guest_vote, p.hide_results, p.expire_time |
@@ -1314,12 +1382,14 @@ discard block |
||
1314 | 1382 | $smcFunc['db_free_result']($request); |
1315 | 1383 | |
1316 | 1384 | // This user has voted on all the polls. |
1317 | - if (empty($row) || !is_array($row)) |
|
1318 | - return array(); |
|
1385 | + if (empty($row) || !is_array($row)) { |
|
1386 | + return array(); |
|
1387 | + } |
|
1319 | 1388 | |
1320 | 1389 | // If this is a guest who's voted we'll through ourselves to show poll to show the results. |
1321 | - if ($user_info['is_guest'] && (!$row['guest_vote'] || (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))))) |
|
1322 | - return ssi_showPoll($row['id_topic'], $output_method); |
|
1390 | + if ($user_info['is_guest'] && (!$row['guest_vote'] || (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))))) { |
|
1391 | + return ssi_showPoll($row['id_topic'], $output_method); |
|
1392 | + } |
|
1323 | 1393 | |
1324 | 1394 | $request = $smcFunc['db_query']('', ' |
1325 | 1395 | SELECT COUNT(DISTINCT id_member) |
@@ -1383,8 +1453,9 @@ discard block |
||
1383 | 1453 | // If mods want to do somthing with this list of polls, let them do that now. |
1384 | 1454 | call_integration_hook('integrate_ssi_recentPoll', array(&$return, $topPollInstead)); |
1385 | 1455 | |
1386 | - if ($output_method != 'echo') |
|
1387 | - return $return; |
|
1456 | + if ($output_method != 'echo') { |
|
1457 | + return $return; |
|
1458 | + } |
|
1388 | 1459 | |
1389 | 1460 | if ($allow_view_results) |
1390 | 1461 | { |
@@ -1393,19 +1464,20 @@ discard block |
||
1393 | 1464 | <strong>', $return['question'], '</strong><br> |
1394 | 1465 | ', !empty($return['allowed_warning']) ? $return['allowed_warning'] . '<br>' : ''; |
1395 | 1466 | |
1396 | - foreach ($return['options'] as $option) |
|
1397 | - echo ' |
|
1467 | + foreach ($return['options'] as $option) { |
|
1468 | + echo ' |
|
1398 | 1469 | <label for="', $option['id'], '">', $option['vote_button'], ' ', $option['option'], '</label><br>'; |
1470 | + } |
|
1399 | 1471 | |
1400 | 1472 | echo ' |
1401 | 1473 | <input type="submit" value="', $txt['poll_vote'], '" class="button"> |
1402 | 1474 | <input type="hidden" name="poll" value="', $return['id'], '"> |
1403 | 1475 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
1404 | 1476 | </form>'; |
1477 | + } else { |
|
1478 | + echo $txt['poll_cannot_see']; |
|
1479 | + } |
|
1405 | 1480 | } |
1406 | - else |
|
1407 | - echo $txt['poll_cannot_see']; |
|
1408 | -} |
|
1409 | 1481 | |
1410 | 1482 | /** |
1411 | 1483 | * Shows the poll from the specified topic |
@@ -1419,13 +1491,15 @@ discard block |
||
1419 | 1491 | |
1420 | 1492 | $boardsAllowed = boardsAllowedTo('poll_view'); |
1421 | 1493 | |
1422 | - if (empty($boardsAllowed)) |
|
1423 | - return array(); |
|
1494 | + if (empty($boardsAllowed)) { |
|
1495 | + return array(); |
|
1496 | + } |
|
1424 | 1497 | |
1425 | - if ($topic === null && isset($_REQUEST['ssi_topic'])) |
|
1426 | - $topic = (int) $_REQUEST['ssi_topic']; |
|
1427 | - else |
|
1428 | - $topic = (int) $topic; |
|
1498 | + if ($topic === null && isset($_REQUEST['ssi_topic'])) { |
|
1499 | + $topic = (int) $_REQUEST['ssi_topic']; |
|
1500 | + } else { |
|
1501 | + $topic = (int) $topic; |
|
1502 | + } |
|
1429 | 1503 | |
1430 | 1504 | $request = $smcFunc['db_query']('', ' |
1431 | 1505 | SELECT |
@@ -1446,17 +1520,18 @@ discard block |
||
1446 | 1520 | ); |
1447 | 1521 | |
1448 | 1522 | // Either this topic has no poll, or the user cannot view it. |
1449 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1450 | - return array(); |
|
1523 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1524 | + return array(); |
|
1525 | + } |
|
1451 | 1526 | |
1452 | 1527 | $row = $smcFunc['db_fetch_assoc']($request); |
1453 | 1528 | $smcFunc['db_free_result']($request); |
1454 | 1529 | |
1455 | 1530 | // Check if they can vote. |
1456 | 1531 | $already_voted = false; |
1457 | - if (!empty($row['expire_time']) && $row['expire_time'] < time()) |
|
1458 | - $allow_vote = false; |
|
1459 | - elseif ($user_info['is_guest']) |
|
1532 | + if (!empty($row['expire_time']) && $row['expire_time'] < time()) { |
|
1533 | + $allow_vote = false; |
|
1534 | + } elseif ($user_info['is_guest']) |
|
1460 | 1535 | { |
1461 | 1536 | // There's a difference between "allowed to vote" and "already voted"... |
1462 | 1537 | $allow_vote = $row['guest_vote']; |
@@ -1466,10 +1541,9 @@ discard block |
||
1466 | 1541 | { |
1467 | 1542 | $already_voted = true; |
1468 | 1543 | } |
1469 | - } |
|
1470 | - elseif (!empty($row['voting_locked']) || !allowedTo('poll_vote', $row['id_board'])) |
|
1471 | - $allow_vote = false; |
|
1472 | - else |
|
1544 | + } elseif (!empty($row['voting_locked']) || !allowedTo('poll_vote', $row['id_board'])) { |
|
1545 | + $allow_vote = false; |
|
1546 | + } else |
|
1473 | 1547 | { |
1474 | 1548 | $request = $smcFunc['db_query']('', ' |
1475 | 1549 | SELECT id_member |
@@ -1551,8 +1625,9 @@ discard block |
||
1551 | 1625 | // If mods want to do somthing with this poll, let them do that now. |
1552 | 1626 | call_integration_hook('integrate_ssi_showPoll', array(&$return)); |
1553 | 1627 | |
1554 | - if ($output_method != 'echo') |
|
1555 | - return $return; |
|
1628 | + if ($output_method != 'echo') { |
|
1629 | + return $return; |
|
1630 | + } |
|
1556 | 1631 | |
1557 | 1632 | if ($return['allow_vote']) |
1558 | 1633 | { |
@@ -1561,17 +1636,17 @@ discard block |
||
1561 | 1636 | <strong>', $return['question'], '</strong><br> |
1562 | 1637 | ', !empty($return['allowed_warning']) ? $return['allowed_warning'] . '<br>' : ''; |
1563 | 1638 | |
1564 | - foreach ($return['options'] as $option) |
|
1565 | - echo ' |
|
1639 | + foreach ($return['options'] as $option) { |
|
1640 | + echo ' |
|
1566 | 1641 | <label for="', $option['id'], '">', $option['vote_button'], ' ', $option['option'], '</label><br>'; |
1642 | + } |
|
1567 | 1643 | |
1568 | 1644 | echo ' |
1569 | 1645 | <input type="submit" value="', $txt['poll_vote'], '" class="button"> |
1570 | 1646 | <input type="hidden" name="poll" value="', $return['id'], '"> |
1571 | 1647 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
1572 | 1648 | </form>'; |
1573 | - } |
|
1574 | - else |
|
1649 | + } else |
|
1575 | 1650 | { |
1576 | 1651 | echo ' |
1577 | 1652 | <div class="ssi_poll"> |
@@ -1651,27 +1726,32 @@ discard block |
||
1651 | 1726 | 'is_approved' => 1, |
1652 | 1727 | ) |
1653 | 1728 | ); |
1654 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1655 | - die; |
|
1729 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1730 | + die; |
|
1731 | + } |
|
1656 | 1732 | $row = $smcFunc['db_fetch_assoc']($request); |
1657 | 1733 | $smcFunc['db_free_result']($request); |
1658 | 1734 | |
1659 | - if (!empty($row['voting_locked']) || ($row['selected'] != -1 && !$user_info['is_guest']) || (!empty($row['expire_time']) && time() > $row['expire_time'])) |
|
1660 | - redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
1735 | + if (!empty($row['voting_locked']) || ($row['selected'] != -1 && !$user_info['is_guest']) || (!empty($row['expire_time']) && time() > $row['expire_time'])) { |
|
1736 | + redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
1737 | + } |
|
1661 | 1738 | |
1662 | 1739 | // Too many options checked? |
1663 | - if (count($_REQUEST['options']) > $row['max_votes']) |
|
1664 | - redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
1740 | + if (count($_REQUEST['options']) > $row['max_votes']) { |
|
1741 | + redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
1742 | + } |
|
1665 | 1743 | |
1666 | 1744 | // It's a guest who has already voted? |
1667 | 1745 | if ($user_info['is_guest']) |
1668 | 1746 | { |
1669 | 1747 | // Guest voting disabled? |
1670 | - if (!$row['guest_vote']) |
|
1671 | - redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
1748 | + if (!$row['guest_vote']) { |
|
1749 | + redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
1750 | + } |
|
1672 | 1751 | // Already voted? |
1673 | - elseif (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))) |
|
1674 | - redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
1752 | + elseif (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))) { |
|
1753 | + redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
1754 | + } |
|
1675 | 1755 | } |
1676 | 1756 | |
1677 | 1757 | $sOptions = array(); |
@@ -1725,11 +1805,13 @@ discard block |
||
1725 | 1805 | { |
1726 | 1806 | global $scripturl, $txt, $context; |
1727 | 1807 | |
1728 | - if (!allowedTo('search_posts')) |
|
1729 | - return; |
|
1808 | + if (!allowedTo('search_posts')) { |
|
1809 | + return; |
|
1810 | + } |
|
1730 | 1811 | |
1731 | - if ($output_method != 'echo') |
|
1732 | - return $scripturl . '?action=search'; |
|
1812 | + if ($output_method != 'echo') { |
|
1813 | + return $scripturl . '?action=search'; |
|
1814 | + } |
|
1733 | 1815 | |
1734 | 1816 | echo ' |
1735 | 1817 | <form action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '"> |
@@ -1751,8 +1833,9 @@ discard block |
||
1751 | 1833 | // If mods want to do somthing with the news, let them do that now. Don't need to pass the news line itself, since it is already in $context. |
1752 | 1834 | call_integration_hook('integrate_ssi_news'); |
1753 | 1835 | |
1754 | - if ($output_method != 'echo') |
|
1755 | - return $context['random_news_line']; |
|
1836 | + if ($output_method != 'echo') { |
|
1837 | + return $context['random_news_line']; |
|
1838 | + } |
|
1756 | 1839 | |
1757 | 1840 | echo $context['random_news_line']; |
1758 | 1841 | } |
@@ -1766,8 +1849,9 @@ discard block |
||
1766 | 1849 | { |
1767 | 1850 | global $scripturl, $modSettings, $user_info; |
1768 | 1851 | |
1769 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view') || !allowedTo('profile_view')) |
|
1770 | - return; |
|
1852 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view') || !allowedTo('profile_view')) { |
|
1853 | + return; |
|
1854 | + } |
|
1771 | 1855 | |
1772 | 1856 | $eventOptions = array( |
1773 | 1857 | 'include_birthdays' => true, |
@@ -1778,13 +1862,15 @@ discard block |
||
1778 | 1862 | // The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary |
1779 | 1863 | call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions)); |
1780 | 1864 | |
1781 | - if ($output_method != 'echo') |
|
1782 | - return $return['calendar_birthdays']; |
|
1865 | + if ($output_method != 'echo') { |
|
1866 | + return $return['calendar_birthdays']; |
|
1867 | + } |
|
1783 | 1868 | |
1784 | - foreach ($return['calendar_birthdays'] as $member) |
|
1785 | - echo ' |
|
1869 | + foreach ($return['calendar_birthdays'] as $member) { |
|
1870 | + echo ' |
|
1786 | 1871 | <a href="', $scripturl, '?action=profile;u=', $member['id'], '"><span class="fix_rtl_names">' . $member['name'] . '</span>' . (isset($member['age']) ? ' (' . $member['age'] . ')' : '') . '</a>' . (!$member['is_last'] ? ', ' : ''); |
1787 | -} |
|
1872 | + } |
|
1873 | + } |
|
1788 | 1874 | |
1789 | 1875 | /** |
1790 | 1876 | * Shows today's holidays. |
@@ -1795,8 +1881,9 @@ discard block |
||
1795 | 1881 | { |
1796 | 1882 | global $modSettings, $user_info; |
1797 | 1883 | |
1798 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) |
|
1799 | - return; |
|
1884 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) { |
|
1885 | + return; |
|
1886 | + } |
|
1800 | 1887 | |
1801 | 1888 | $eventOptions = array( |
1802 | 1889 | 'include_holidays' => true, |
@@ -1807,8 +1894,9 @@ discard block |
||
1807 | 1894 | // The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary |
1808 | 1895 | call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions)); |
1809 | 1896 | |
1810 | - if ($output_method != 'echo') |
|
1811 | - return $return['calendar_holidays']; |
|
1897 | + if ($output_method != 'echo') { |
|
1898 | + return $return['calendar_holidays']; |
|
1899 | + } |
|
1812 | 1900 | |
1813 | 1901 | echo ' |
1814 | 1902 | ', implode(', ', $return['calendar_holidays']); |
@@ -1822,8 +1910,9 @@ discard block |
||
1822 | 1910 | { |
1823 | 1911 | global $modSettings, $user_info; |
1824 | 1912 | |
1825 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) |
|
1826 | - return; |
|
1913 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) { |
|
1914 | + return; |
|
1915 | + } |
|
1827 | 1916 | |
1828 | 1917 | $eventOptions = array( |
1829 | 1918 | 'include_events' => true, |
@@ -1834,14 +1923,16 @@ discard block |
||
1834 | 1923 | // The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary |
1835 | 1924 | call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions)); |
1836 | 1925 | |
1837 | - if ($output_method != 'echo') |
|
1838 | - return $return['calendar_events']; |
|
1926 | + if ($output_method != 'echo') { |
|
1927 | + return $return['calendar_events']; |
|
1928 | + } |
|
1839 | 1929 | |
1840 | 1930 | foreach ($return['calendar_events'] as $event) |
1841 | 1931 | { |
1842 | - if ($event['can_edit']) |
|
1843 | - echo ' |
|
1932 | + if ($event['can_edit']) { |
|
1933 | + echo ' |
|
1844 | 1934 | <a href="' . $event['modify_href'] . '" style="color: #ff0000;">*</a> '; |
1935 | + } |
|
1845 | 1936 | echo ' |
1846 | 1937 | ' . $event['link'] . (!$event['is_last'] ? ', ' : ''); |
1847 | 1938 | } |
@@ -1856,8 +1947,9 @@ discard block |
||
1856 | 1947 | { |
1857 | 1948 | global $modSettings, $txt, $scripturl, $user_info; |
1858 | 1949 | |
1859 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) |
|
1860 | - return; |
|
1950 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) { |
|
1951 | + return; |
|
1952 | + } |
|
1861 | 1953 | |
1862 | 1954 | $eventOptions = array( |
1863 | 1955 | 'include_birthdays' => allowedTo('profile_view'), |
@@ -1870,19 +1962,22 @@ discard block |
||
1870 | 1962 | // The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary |
1871 | 1963 | call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions)); |
1872 | 1964 | |
1873 | - if ($output_method != 'echo') |
|
1874 | - return $return; |
|
1965 | + if ($output_method != 'echo') { |
|
1966 | + return $return; |
|
1967 | + } |
|
1875 | 1968 | |
1876 | - if (!empty($return['calendar_holidays'])) |
|
1877 | - echo ' |
|
1969 | + if (!empty($return['calendar_holidays'])) { |
|
1970 | + echo ' |
|
1878 | 1971 | <span class="holiday">' . $txt['calendar_prompt'] . ' ' . implode(', ', $return['calendar_holidays']) . '<br></span>'; |
1972 | + } |
|
1879 | 1973 | if (!empty($return['calendar_birthdays'])) |
1880 | 1974 | { |
1881 | 1975 | echo ' |
1882 | 1976 | <span class="birthday">' . $txt['birthdays_upcoming'] . '</span> '; |
1883 | - foreach ($return['calendar_birthdays'] as $member) |
|
1884 | - echo ' |
|
1977 | + foreach ($return['calendar_birthdays'] as $member) { |
|
1978 | + echo ' |
|
1885 | 1979 | <a href="', $scripturl, '?action=profile;u=', $member['id'], '"><span class="fix_rtl_names">', $member['name'], '</span>', isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a>', !$member['is_last'] ? ', ' : ''; |
1980 | + } |
|
1886 | 1981 | echo ' |
1887 | 1982 | <br>'; |
1888 | 1983 | } |
@@ -1892,9 +1987,10 @@ discard block |
||
1892 | 1987 | <span class="event">' . $txt['events_upcoming'] . '</span> '; |
1893 | 1988 | foreach ($return['calendar_events'] as $event) |
1894 | 1989 | { |
1895 | - if ($event['can_edit']) |
|
1896 | - echo ' |
|
1990 | + if ($event['can_edit']) { |
|
1991 | + echo ' |
|
1897 | 1992 | <a href="' . $event['modify_href'] . '" style="color: #ff0000;">*</a> '; |
1993 | + } |
|
1898 | 1994 | echo ' |
1899 | 1995 | ' . $event['link'] . (!$event['is_last'] ? ', ' : ''); |
1900 | 1996 | } |
@@ -1918,25 +2014,29 @@ discard block |
||
1918 | 2014 | loadLanguage('Stats'); |
1919 | 2015 | |
1920 | 2016 | // Must be integers.... |
1921 | - if ($limit === null) |
|
1922 | - $limit = isset($_GET['limit']) ? (int) $_GET['limit'] : 5; |
|
1923 | - else |
|
1924 | - $limit = (int) $limit; |
|
1925 | - |
|
1926 | - if ($start === null) |
|
1927 | - $start = isset($_GET['start']) ? (int) $_GET['start'] : 0; |
|
1928 | - else |
|
1929 | - $start = (int) $start; |
|
1930 | - |
|
1931 | - if ($board !== null) |
|
1932 | - $board = (int) $board; |
|
1933 | - elseif (isset($_GET['board'])) |
|
1934 | - $board = (int) $_GET['board']; |
|
1935 | - |
|
1936 | - if ($length === null) |
|
1937 | - $length = isset($_GET['length']) ? (int) $_GET['length'] : 0; |
|
1938 | - else |
|
1939 | - $length = (int) $length; |
|
2017 | + if ($limit === null) { |
|
2018 | + $limit = isset($_GET['limit']) ? (int) $_GET['limit'] : 5; |
|
2019 | + } else { |
|
2020 | + $limit = (int) $limit; |
|
2021 | + } |
|
2022 | + |
|
2023 | + if ($start === null) { |
|
2024 | + $start = isset($_GET['start']) ? (int) $_GET['start'] : 0; |
|
2025 | + } else { |
|
2026 | + $start = (int) $start; |
|
2027 | + } |
|
2028 | + |
|
2029 | + if ($board !== null) { |
|
2030 | + $board = (int) $board; |
|
2031 | + } elseif (isset($_GET['board'])) { |
|
2032 | + $board = (int) $_GET['board']; |
|
2033 | + } |
|
2034 | + |
|
2035 | + if ($length === null) { |
|
2036 | + $length = isset($_GET['length']) ? (int) $_GET['length'] : 0; |
|
2037 | + } else { |
|
2038 | + $length = (int) $length; |
|
2039 | + } |
|
1940 | 2040 | |
1941 | 2041 | $limit = max(0, $limit); |
1942 | 2042 | $start = max(0, $start); |
@@ -1954,17 +2054,19 @@ discard block |
||
1954 | 2054 | ); |
1955 | 2055 | if ($smcFunc['db_num_rows']($request) == 0) |
1956 | 2056 | { |
1957 | - if ($output_method == 'echo') |
|
1958 | - die($txt['ssi_no_guests']); |
|
1959 | - else |
|
1960 | - return array(); |
|
2057 | + if ($output_method == 'echo') { |
|
2058 | + die($txt['ssi_no_guests']); |
|
2059 | + } else { |
|
2060 | + return array(); |
|
2061 | + } |
|
1961 | 2062 | } |
1962 | 2063 | list ($board) = $smcFunc['db_fetch_row']($request); |
1963 | 2064 | $smcFunc['db_free_result']($request); |
1964 | 2065 | |
1965 | 2066 | $icon_sources = array(); |
1966 | - foreach ($context['stable_icons'] as $icon) |
|
1967 | - $icon_sources[$icon] = 'images_url'; |
|
2067 | + foreach ($context['stable_icons'] as $icon) { |
|
2068 | + $icon_sources[$icon] = 'images_url'; |
|
2069 | + } |
|
1968 | 2070 | |
1969 | 2071 | if (!empty($modSettings['enable_likes'])) |
1970 | 2072 | { |
@@ -1987,12 +2089,14 @@ discard block |
||
1987 | 2089 | ) |
1988 | 2090 | ); |
1989 | 2091 | $posts = array(); |
1990 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1991 | - $posts[] = $row['id_first_msg']; |
|
2092 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2093 | + $posts[] = $row['id_first_msg']; |
|
2094 | + } |
|
1992 | 2095 | $smcFunc['db_free_result']($request); |
1993 | 2096 | |
1994 | - if (empty($posts)) |
|
1995 | - return array(); |
|
2097 | + if (empty($posts)) { |
|
2098 | + return array(); |
|
2099 | + } |
|
1996 | 2100 | |
1997 | 2101 | // Find the posts. |
1998 | 2102 | $request = $smcFunc['db_query']('', ' |
@@ -2022,26 +2126,30 @@ discard block |
||
2022 | 2126 | $last_space = strrpos($row['body'], ' '); |
2023 | 2127 | $last_open = strrpos($row['body'], '<'); |
2024 | 2128 | $last_close = strrpos($row['body'], '>'); |
2025 | - if (empty($last_space) || ($last_space == $last_open + 3 && (empty($last_close) || (!empty($last_close) && $last_close < $last_open))) || $last_space < $last_open || $last_open == $length - 6) |
|
2026 | - $cutoff = $last_open; |
|
2027 | - elseif (empty($last_close) || $last_close < $last_open) |
|
2028 | - $cutoff = $last_space; |
|
2129 | + if (empty($last_space) || ($last_space == $last_open + 3 && (empty($last_close) || (!empty($last_close) && $last_close < $last_open))) || $last_space < $last_open || $last_open == $length - 6) { |
|
2130 | + $cutoff = $last_open; |
|
2131 | + } elseif (empty($last_close) || $last_close < $last_open) { |
|
2132 | + $cutoff = $last_space; |
|
2133 | + } |
|
2029 | 2134 | |
2030 | - if ($cutoff !== false) |
|
2031 | - $row['body'] = $smcFunc['substr']($row['body'], 0, $cutoff); |
|
2135 | + if ($cutoff !== false) { |
|
2136 | + $row['body'] = $smcFunc['substr']($row['body'], 0, $cutoff); |
|
2137 | + } |
|
2032 | 2138 | $row['body'] .= '...'; |
2033 | 2139 | } |
2034 | 2140 | |
2035 | 2141 | $row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']); |
2036 | 2142 | |
2037 | - if (!empty($recycle_board) && $row['id_board'] == $recycle_board) |
|
2038 | - $row['icon'] = 'recycled'; |
|
2143 | + if (!empty($recycle_board) && $row['id_board'] == $recycle_board) { |
|
2144 | + $row['icon'] = 'recycled'; |
|
2145 | + } |
|
2039 | 2146 | |
2040 | 2147 | // Check that this message icon is there... |
2041 | - if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) |
|
2042 | - $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
2043 | - elseif (!isset($icon_sources[$row['icon']])) |
|
2044 | - $icon_sources[$row['icon']] = 'images_url'; |
|
2148 | + if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) { |
|
2149 | + $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
2150 | + } elseif (!isset($icon_sources[$row['icon']])) { |
|
2151 | + $icon_sources[$row['icon']] = 'images_url'; |
|
2152 | + } |
|
2045 | 2153 | |
2046 | 2154 | censorText($row['subject']); |
2047 | 2155 | censorText($row['body']); |
@@ -2078,16 +2186,18 @@ discard block |
||
2078 | 2186 | } |
2079 | 2187 | $smcFunc['db_free_result']($request); |
2080 | 2188 | |
2081 | - if (empty($return)) |
|
2082 | - return $return; |
|
2189 | + if (empty($return)) { |
|
2190 | + return $return; |
|
2191 | + } |
|
2083 | 2192 | |
2084 | 2193 | $return[count($return) - 1]['is_last'] = true; |
2085 | 2194 | |
2086 | 2195 | // If mods want to do somthing with this list of posts, let them do that now. |
2087 | 2196 | call_integration_hook('integrate_ssi_boardNews', array(&$return)); |
2088 | 2197 | |
2089 | - if ($output_method != 'echo') |
|
2090 | - return $return; |
|
2198 | + if ($output_method != 'echo') { |
|
2199 | + return $return; |
|
2200 | + } |
|
2091 | 2201 | |
2092 | 2202 | foreach ($return as $news) |
2093 | 2203 | { |
@@ -2139,9 +2249,10 @@ discard block |
||
2139 | 2249 | echo ' |
2140 | 2250 | </div>'; |
2141 | 2251 | |
2142 | - if (!$news['is_last']) |
|
2143 | - echo ' |
|
2252 | + if (!$news['is_last']) { |
|
2253 | + echo ' |
|
2144 | 2254 | <hr>'; |
2255 | + } |
|
2145 | 2256 | } |
2146 | 2257 | } |
2147 | 2258 | |
@@ -2155,8 +2266,9 @@ discard block |
||
2155 | 2266 | { |
2156 | 2267 | global $user_info, $scripturl, $modSettings, $txt, $context, $smcFunc; |
2157 | 2268 | |
2158 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) |
|
2159 | - return; |
|
2269 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) { |
|
2270 | + return; |
|
2271 | + } |
|
2160 | 2272 | |
2161 | 2273 | // Find all events which are happening in the near future that the member can see. |
2162 | 2274 | $request = $smcFunc['db_query']('', ' |
@@ -2182,20 +2294,23 @@ discard block |
||
2182 | 2294 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2183 | 2295 | { |
2184 | 2296 | // Check if we've already come by an event linked to this same topic with the same title... and don't display it if we have. |
2185 | - if (!empty($duplicates[$row['title'] . $row['id_topic']])) |
|
2186 | - continue; |
|
2297 | + if (!empty($duplicates[$row['title'] . $row['id_topic']])) { |
|
2298 | + continue; |
|
2299 | + } |
|
2187 | 2300 | |
2188 | 2301 | // Censor the title. |
2189 | 2302 | censorText($row['title']); |
2190 | 2303 | |
2191 | - if ($row['start_date'] < strftime('%Y-%m-%d', forum_time(false))) |
|
2192 | - $date = strftime('%Y-%m-%d', forum_time(false)); |
|
2193 | - else |
|
2194 | - $date = $row['start_date']; |
|
2304 | + if ($row['start_date'] < strftime('%Y-%m-%d', forum_time(false))) { |
|
2305 | + $date = strftime('%Y-%m-%d', forum_time(false)); |
|
2306 | + } else { |
|
2307 | + $date = $row['start_date']; |
|
2308 | + } |
|
2195 | 2309 | |
2196 | 2310 | // If the topic it is attached to is not approved then don't link it. |
2197 | - if (!empty($row['id_first_msg']) && !$row['approved']) |
|
2198 | - $row['id_board'] = $row['id_topic'] = $row['id_first_msg'] = 0; |
|
2311 | + if (!empty($row['id_first_msg']) && !$row['approved']) { |
|
2312 | + $row['id_board'] = $row['id_topic'] = $row['id_first_msg'] = 0; |
|
2313 | + } |
|
2199 | 2314 | |
2200 | 2315 | $allday = (empty($row['start_time']) || empty($row['end_time']) || empty($row['timezone']) || !in_array($row['timezone'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) ? true : false; |
2201 | 2316 | |
@@ -2221,24 +2336,27 @@ discard block |
||
2221 | 2336 | } |
2222 | 2337 | $smcFunc['db_free_result']($request); |
2223 | 2338 | |
2224 | - foreach ($return as $mday => $array) |
|
2225 | - $return[$mday][count($array) - 1]['is_last'] = true; |
|
2339 | + foreach ($return as $mday => $array) { |
|
2340 | + $return[$mday][count($array) - 1]['is_last'] = true; |
|
2341 | + } |
|
2226 | 2342 | |
2227 | 2343 | // If mods want to do somthing with this list of events, let them do that now. |
2228 | 2344 | call_integration_hook('integrate_ssi_recentEvents', array(&$return)); |
2229 | 2345 | |
2230 | - if ($output_method != 'echo' || empty($return)) |
|
2231 | - return $return; |
|
2346 | + if ($output_method != 'echo' || empty($return)) { |
|
2347 | + return $return; |
|
2348 | + } |
|
2232 | 2349 | |
2233 | 2350 | // Well the output method is echo. |
2234 | 2351 | echo ' |
2235 | 2352 | <span class="event">' . $txt['events'] . '</span> '; |
2236 | - foreach ($return as $mday => $array) |
|
2237 | - foreach ($array as $event) |
|
2353 | + foreach ($return as $mday => $array) { |
|
2354 | + foreach ($array as $event) |
|
2238 | 2355 | { |
2239 | 2356 | if ($event['can_edit']) |
2240 | 2357 | echo ' |
2241 | 2358 | <a href="' . $event['modify_href'] . '" style="color: #ff0000;">*</a> '; |
2359 | + } |
|
2242 | 2360 | |
2243 | 2361 | echo ' |
2244 | 2362 | ' . $event['link'] . (!$event['is_last'] ? ', ' : ''); |
@@ -2257,8 +2375,9 @@ discard block |
||
2257 | 2375 | global $smcFunc; |
2258 | 2376 | |
2259 | 2377 | // If $id is null, this was most likely called from a query string and should do nothing. |
2260 | - if ($id === null) |
|
2261 | - return; |
|
2378 | + if ($id === null) { |
|
2379 | + return; |
|
2380 | + } |
|
2262 | 2381 | |
2263 | 2382 | $request = $smcFunc['db_query']('', ' |
2264 | 2383 | SELECT passwd, member_name, is_activated |
@@ -2290,8 +2409,9 @@ discard block |
||
2290 | 2409 | $attachments_boards = boardsAllowedTo('view_attachments'); |
2291 | 2410 | |
2292 | 2411 | // No boards? Adios amigo. |
2293 | - if (empty($attachments_boards)) |
|
2294 | - return array(); |
|
2412 | + if (empty($attachments_boards)) { |
|
2413 | + return array(); |
|
2414 | + } |
|
2295 | 2415 | |
2296 | 2416 | // Is it an array? |
2297 | 2417 | $attachment_ext = (array) $attachment_ext; |
@@ -2375,8 +2495,9 @@ discard block |
||
2375 | 2495 | call_integration_hook('integrate_ssi_recentAttachments', array(&$attachments)); |
2376 | 2496 | |
2377 | 2497 | // So you just want an array? Here you can have it. |
2378 | - if ($output_method == 'array' || empty($attachments)) |
|
2379 | - return $attachments; |
|
2498 | + if ($output_method == 'array' || empty($attachments)) { |
|
2499 | + return $attachments; |
|
2500 | + } |
|
2380 | 2501 | |
2381 | 2502 | // Give them the default. |
2382 | 2503 | echo ' |
@@ -2387,14 +2508,15 @@ discard block |
||
2387 | 2508 | <th style="text-align: left; padding: 2">', $txt['downloads'], '</th> |
2388 | 2509 | <th style="text-align: left; padding: 2">', $txt['filesize'], '</th> |
2389 | 2510 | </tr>'; |
2390 | - foreach ($attachments as $attach) |
|
2391 | - echo ' |
|
2511 | + foreach ($attachments as $attach) { |
|
2512 | + echo ' |
|
2392 | 2513 | <tr> |
2393 | 2514 | <td>', $attach['file']['link'], '</td> |
2394 | 2515 | <td>', $attach['member']['link'], '</td> |
2395 | 2516 | <td style="text-align: center">', $attach['file']['downloads'], '</td> |
2396 | 2517 | <td>', $attach['file']['filesize'], '</td> |
2397 | 2518 | </tr>'; |
2519 | + } |
|
2398 | 2520 | echo ' |
2399 | 2521 | </table>'; |
2400 | 2522 | } |
@@ -18,23 +18,25 @@ discard block |
||
18 | 18 | global $context; |
19 | 19 | |
20 | 20 | // Prevent Chrome from auto completing fields when viewing/editing other members profiles |
21 | - if (isBrowser('is_chrome') && !$context['user']['is_owner']) |
|
22 | - echo ' |
|
21 | + if (isBrowser('is_chrome') && !$context['user']['is_owner']) { |
|
22 | + echo ' |
|
23 | 23 | <script> |
24 | 24 | disableAutoComplete(); |
25 | 25 | </script>'; |
26 | + } |
|
26 | 27 | |
27 | 28 | // If an error occurred while trying to save previously, give the user a clue! |
28 | 29 | echo ' |
29 | 30 | ', template_error_message(); |
30 | 31 | |
31 | 32 | // If the profile was update successfully, let the user know this. |
32 | - if (!empty($context['profile_updated'])) |
|
33 | - echo ' |
|
33 | + if (!empty($context['profile_updated'])) { |
|
34 | + echo ' |
|
34 | 35 | <div class="infobox"> |
35 | 36 | ', $context['profile_updated'], ' |
36 | 37 | </div>'; |
37 | -} |
|
38 | + } |
|
39 | + } |
|
38 | 40 | |
39 | 41 | /** |
40 | 42 | * Template for any HTML needed below the profile (closing off divs/tables, etc.) |
@@ -99,19 +101,19 @@ discard block |
||
99 | 101 | </div> |
100 | 102 | <div class="alerts_unread">'; |
101 | 103 | |
102 | - if (empty($context['unread_alerts'])) |
|
103 | - template_alerts_all_read(); |
|
104 | - |
|
105 | - else |
|
104 | + if (empty($context['unread_alerts'])) { |
|
105 | + template_alerts_all_read(); |
|
106 | + } else |
|
106 | 107 | { |
107 | - foreach ($context['unread_alerts'] as $id_alert => $details) |
|
108 | - echo ' |
|
108 | + foreach ($context['unread_alerts'] as $id_alert => $details) { |
|
109 | + echo ' |
|
109 | 110 | <div class="unread"> |
110 | 111 | ', !empty($details['sender']) ? $details['sender']['avatar']['image'] : '', ' |
111 | 112 | <div class="details"> |
112 | 113 | ', !empty($details['icon']) ? $details['icon'] : '', '<span>', $details['text'], '</span> - ', $details['time'], ' |
113 | 114 | </div> |
114 | 115 | </div>'; |
116 | + } |
|
115 | 117 | } |
116 | 118 | |
117 | 119 | echo ' |
@@ -158,37 +160,41 @@ discard block |
||
158 | 160 | if (!empty($context['print_custom_fields']['above_member'])) |
159 | 161 | { |
160 | 162 | $fields = ''; |
161 | - foreach ($context['print_custom_fields']['above_member'] as $field) |
|
162 | - if (!empty($field['output_html'])) |
|
163 | + foreach ($context['print_custom_fields']['above_member'] as $field) { |
|
164 | + if (!empty($field['output_html'])) |
|
163 | 165 | $fields .= ' |
164 | 166 | <li>' . $field['output_html'] . '</li>'; |
167 | + } |
|
165 | 168 | |
166 | - if (!empty($fields)) |
|
167 | - echo ' |
|
169 | + if (!empty($fields)) { |
|
170 | + echo ' |
|
168 | 171 | <div class="custom_fields_above_name"> |
169 | 172 | <ul>', $fields, ' |
170 | 173 | </ul> |
171 | 174 | </div>'; |
175 | + } |
|
172 | 176 | } |
173 | 177 | |
174 | 178 | echo ' |
175 | 179 | <div class="username clear"> |
176 | 180 | <h4>'; |
177 | 181 | |
178 | - if (!empty($context['print_custom_fields']['before_member'])) |
|
179 | - foreach ($context['print_custom_fields']['before_member'] as $field) |
|
182 | + if (!empty($context['print_custom_fields']['before_member'])) { |
|
183 | + foreach ($context['print_custom_fields']['before_member'] as $field) |
|
180 | 184 | if (!empty($field['output_html'])) |
181 | 185 | echo ' |
182 | 186 | <span>', $field['output_html'], '</span>'; |
187 | + } |
|
183 | 188 | |
184 | 189 | echo ' |
185 | 190 | ', $context['member']['name']; |
186 | 191 | |
187 | - if (!empty($context['print_custom_fields']['after_member'])) |
|
188 | - foreach ($context['print_custom_fields']['after_member'] as $field) |
|
192 | + if (!empty($context['print_custom_fields']['after_member'])) { |
|
193 | + foreach ($context['print_custom_fields']['after_member'] as $field) |
|
189 | 194 | if (!empty($field['output_html'])) |
190 | 195 | echo ' |
191 | 196 | <span>', $field['output_html'], '</span>'; |
197 | + } |
|
192 | 198 | |
193 | 199 | |
194 | 200 | echo ' |
@@ -201,39 +207,44 @@ discard block |
||
201 | 207 | if (!empty($context['print_custom_fields']['below_avatar'])) |
202 | 208 | { |
203 | 209 | $fields = ''; |
204 | - foreach ($context['print_custom_fields']['below_avatar'] as $field) |
|
205 | - if (!empty($field['output_html'])) |
|
210 | + foreach ($context['print_custom_fields']['below_avatar'] as $field) { |
|
211 | + if (!empty($field['output_html'])) |
|
206 | 212 | $fields .= ' |
207 | 213 | <li>' . $field['output_html'] . '</li>'; |
214 | + } |
|
208 | 215 | |
209 | - if (!empty($fields)) |
|
210 | - echo ' |
|
216 | + if (!empty($fields)) { |
|
217 | + echo ' |
|
211 | 218 | <div class="custom_fields_below_avatar"> |
212 | 219 | <ul>', $fields, ' |
213 | 220 | </ul> |
214 | 221 | </div>'; |
222 | + } |
|
215 | 223 | } |
216 | 224 | |
217 | 225 | echo ' |
218 | 226 | <ul class="icon_fields clear">'; |
219 | 227 | |
220 | 228 | // Email is only visible if it's your profile or you have the moderate_forum permission |
221 | - if ($context['member']['show_email']) |
|
222 | - echo ' |
|
229 | + if ($context['member']['show_email']) { |
|
230 | + echo ' |
|
223 | 231 | <li><a href="mailto:', $context['member']['email'], '" title="', $context['member']['email'], '" rel="nofollow"><span class="generic_icons mail" title="' . $txt['email'] . '"></span></a></li>'; |
232 | + } |
|
224 | 233 | |
225 | 234 | // Don't show an icon if they haven't specified a website. |
226 | - if ($context['member']['website']['url'] !== '' && !isset($context['disabled_fields']['website'])) |
|
227 | - echo ' |
|
235 | + if ($context['member']['website']['url'] !== '' && !isset($context['disabled_fields']['website'])) { |
|
236 | + echo ' |
|
228 | 237 | <li><a href="', $context['member']['website']['url'], '" title="' . $context['member']['website']['title'] . '" target="_blank" rel="noopener">', ($settings['use_image_buttons'] ? '<span class="generic_icons www" title="' . $context['member']['website']['title'] . '"></span>' : $txt['www']), '</a></li>'; |
238 | + } |
|
229 | 239 | |
230 | 240 | // Are there any custom profile fields as icons? |
231 | 241 | if (!empty($context['print_custom_fields']['icons'])) |
232 | 242 | { |
233 | - foreach ($context['print_custom_fields']['icons'] as $field) |
|
234 | - if (!empty($field['output_html'])) |
|
243 | + foreach ($context['print_custom_fields']['icons'] as $field) { |
|
244 | + if (!empty($field['output_html'])) |
|
235 | 245 | echo ' |
236 | 246 | <li class="custom_field">', $field['output_html'], '</li>'; |
247 | + } |
|
237 | 248 | } |
238 | 249 | |
239 | 250 | echo ' |
@@ -242,24 +253,27 @@ discard block |
||
242 | 253 | ', $context['can_send_pm'] ? '<a href="' . $context['member']['online']['href'] . '" title="' . $context['member']['online']['text'] . '" rel="nofollow">' : '', $settings['use_image_buttons'] ? '<span class="' . ($context['member']['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $context['member']['online']['text'] . '"></span>' : $context['member']['online']['label'], $context['can_send_pm'] ? '</a>' : '', $settings['use_image_buttons'] ? '<span class="smalltext"> ' . $context['member']['online']['label'] . '</span>' : ''; |
243 | 254 | |
244 | 255 | // Can they add this member as a buddy? |
245 | - if (!empty($context['can_have_buddy']) && !$context['user']['is_owner']) |
|
246 | - echo ' |
|
256 | + if (!empty($context['can_have_buddy']) && !$context['user']['is_owner']) { |
|
257 | + echo ' |
|
247 | 258 | <br> |
248 | 259 | <a href="', $scripturl, '?action=buddy;u=', $context['id_member'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['buddy_' . ($context['member']['is_buddy'] ? 'remove' : 'add')], '</a>'; |
260 | + } |
|
249 | 261 | |
250 | 262 | echo ' |
251 | 263 | </span>'; |
252 | 264 | |
253 | - if (!$context['user']['is_owner'] && $context['can_send_pm']) |
|
254 | - echo ' |
|
265 | + if (!$context['user']['is_owner'] && $context['can_send_pm']) { |
|
266 | + echo ' |
|
255 | 267 | <a href="', $scripturl, '?action=pm;sa=send;u=', $context['id_member'], '" class="infolinks">', $txt['profile_sendpm_short'], '</a>'; |
268 | + } |
|
256 | 269 | |
257 | 270 | echo ' |
258 | 271 | <a href="', $scripturl, '?action=profile;area=showposts;u=', $context['id_member'], '" class="infolinks">', $txt['showPosts'], '</a>'; |
259 | 272 | |
260 | - if ($context['user']['is_owner'] && !empty($modSettings['drafts_post_enabled'])) |
|
261 | - echo ' |
|
273 | + if ($context['user']['is_owner'] && !empty($modSettings['drafts_post_enabled'])) { |
|
274 | + echo ' |
|
262 | 275 | <a href="', $scripturl, '?action=profile;area=showdrafts;u=', $context['id_member'], '" class="infolinks">', $txt['drafts_show'], '</a>'; |
276 | + } |
|
263 | 277 | |
264 | 278 | echo ' |
265 | 279 | <a href="', $scripturl, '?action=profile;area=statistics;u=', $context['id_member'], '" class="infolinks">', $txt['statPanel'], '</a>'; |
@@ -268,17 +282,19 @@ discard block |
||
268 | 282 | if (!empty($context['print_custom_fields']['bottom_poster'])) |
269 | 283 | { |
270 | 284 | $fields = ''; |
271 | - foreach ($context['print_custom_fields']['bottom_poster'] as $field) |
|
272 | - if (!empty($field['output_html'])) |
|
285 | + foreach ($context['print_custom_fields']['bottom_poster'] as $field) { |
|
286 | + if (!empty($field['output_html'])) |
|
273 | 287 | $fields .= ' |
274 | 288 | <li>' . $field['output_html'] . '</li>'; |
289 | + } |
|
275 | 290 | |
276 | - if (!empty($fields)) |
|
277 | - echo ' |
|
291 | + if (!empty($fields)) { |
|
292 | + echo ' |
|
278 | 293 | <div class="custom_fields_bottom"> |
279 | 294 | <ul class="nolist">', $fields, ' |
280 | 295 | </ul> |
281 | 296 | </div>'; |
297 | + } |
|
282 | 298 | } |
283 | 299 | |
284 | 300 | echo ' |
@@ -287,30 +303,35 @@ discard block |
||
287 | 303 | <div id="detailedinfo"> |
288 | 304 | <dl class="settings">'; |
289 | 305 | |
290 | - if ($context['user']['is_owner'] || $context['user']['is_admin']) |
|
291 | - echo ' |
|
306 | + if ($context['user']['is_owner'] || $context['user']['is_admin']) { |
|
307 | + echo ' |
|
292 | 308 | <dt>', $txt['username'], ': </dt> |
293 | 309 | <dd>', $context['member']['username'], '</dd>'; |
310 | + } |
|
294 | 311 | |
295 | - if (!isset($context['disabled_fields']['posts'])) |
|
296 | - echo ' |
|
312 | + if (!isset($context['disabled_fields']['posts'])) { |
|
313 | + echo ' |
|
297 | 314 | <dt>', $txt['profile_posts'], ': </dt> |
298 | 315 | <dd>', $context['member']['posts'], ' (', $context['member']['posts_per_day'], ' ', $txt['posts_per_day'], ')</dd>'; |
316 | + } |
|
299 | 317 | |
300 | - if ($context['member']['show_email']) |
|
301 | - echo ' |
|
318 | + if ($context['member']['show_email']) { |
|
319 | + echo ' |
|
302 | 320 | <dt>', $txt['email'], ': </dt> |
303 | 321 | <dd><a href="mailto:', $context['member']['email'], '">', $context['member']['email'], '</a></dd>'; |
322 | + } |
|
304 | 323 | |
305 | - if (!empty($modSettings['titlesEnable']) && !empty($context['member']['title'])) |
|
306 | - echo ' |
|
324 | + if (!empty($modSettings['titlesEnable']) && !empty($context['member']['title'])) { |
|
325 | + echo ' |
|
307 | 326 | <dt>', $txt['custom_title'], ': </dt> |
308 | 327 | <dd>', $context['member']['title'], '</dd>'; |
328 | + } |
|
309 | 329 | |
310 | - if (!empty($context['member']['blurb'])) |
|
311 | - echo ' |
|
330 | + if (!empty($context['member']['blurb'])) { |
|
331 | + echo ' |
|
312 | 332 | <dt>', $txt['personal_text'], ': </dt> |
313 | 333 | <dd>', $context['member']['blurb'], '</dd>'; |
334 | + } |
|
314 | 335 | |
315 | 336 | echo ' |
316 | 337 | <dt>', $txt['age'], ':</dt> |
@@ -324,19 +345,21 @@ discard block |
||
324 | 345 | { |
325 | 346 | $fields = array(); |
326 | 347 | |
327 | - foreach ($context['print_custom_fields']['standard'] as $field) |
|
328 | - if (!empty($field['output_html'])) |
|
348 | + foreach ($context['print_custom_fields']['standard'] as $field) { |
|
349 | + if (!empty($field['output_html'])) |
|
329 | 350 | $fields[] = $field; |
351 | + } |
|
330 | 352 | |
331 | 353 | if (count($fields) > 0) |
332 | 354 | { |
333 | 355 | echo ' |
334 | 356 | <dl class="settings">'; |
335 | 357 | |
336 | - foreach ($fields as $field) |
|
337 | - echo ' |
|
358 | + foreach ($fields as $field) { |
|
359 | + echo ' |
|
338 | 360 | <dt>', $field['name'], ':</dt> |
339 | 361 | <dd>', $field['output_html'], '</dd>'; |
362 | + } |
|
340 | 363 | |
341 | 364 | echo ' |
342 | 365 | </dl>'; |
@@ -355,9 +378,10 @@ discard block |
||
355 | 378 | <a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=', ($context['can_issue_warning'] && !$context['user']['is_owner'] ? 'issuewarning' : 'viewwarning'), '">', $context['member']['warning'], '%</a>'; |
356 | 379 | |
357 | 380 | // Can we provide information on what this means? |
358 | - if (!empty($context['warning_status'])) |
|
359 | - echo ' |
|
381 | + if (!empty($context['warning_status'])) { |
|
382 | + echo ' |
|
360 | 383 | <span class="smalltext">(', $context['warning_status'], ')</span>'; |
384 | + } |
|
361 | 385 | |
362 | 386 | echo ' |
363 | 387 | </dd>'; |
@@ -367,11 +391,12 @@ discard block |
||
367 | 391 | if (!empty($context['activate_message']) || !empty($context['member']['bans'])) |
368 | 392 | { |
369 | 393 | // If the person looking at the summary has permission, and the account isn't activated, give the viewer the ability to do it themselves. |
370 | - if (!empty($context['activate_message'])) |
|
371 | - echo ' |
|
394 | + if (!empty($context['activate_message'])) { |
|
395 | + echo ' |
|
372 | 396 | <dt class="clear"> |
373 | 397 | <span class="alert">', $context['activate_message'], '</span> (<a href="', $context['activate_link'], '"', ($context['activate_type'] == 4 ? ' class="you_sure" data-confirm="' . $txt['profileConfirm'] . '"' : ''), '>', $context['activate_link_text'], '</a>) |
374 | 398 | </dt>'; |
399 | + } |
|
375 | 400 | |
376 | 401 | // If the current member is banned, show a message and possibly a link to the ban. |
377 | 402 | if (!empty($context['member']['bans'])) |
@@ -383,10 +408,11 @@ discard block |
||
383 | 408 | <dt class="clear hidden" id="ban_info"> |
384 | 409 | <strong>', $txt['user_banned_by_following'], ':</strong>'; |
385 | 410 | |
386 | - foreach ($context['member']['bans'] as $ban) |
|
387 | - echo ' |
|
411 | + foreach ($context['member']['bans'] as $ban) { |
|
412 | + echo ' |
|
388 | 413 | <br> |
389 | 414 | <span class="smalltext">', $ban['explanation'], '</span>'; |
415 | + } |
|
390 | 416 | |
391 | 417 | echo ' |
392 | 418 | </dt>'; |
@@ -400,30 +426,34 @@ discard block |
||
400 | 426 | // If the person looking is allowed, they can check the members IP address and hostname. |
401 | 427 | if ($context['can_see_ip']) |
402 | 428 | { |
403 | - if (!empty($context['member']['ip'])) |
|
404 | - echo ' |
|
429 | + if (!empty($context['member']['ip'])) { |
|
430 | + echo ' |
|
405 | 431 | <dt>', $txt['ip'], ': </dt> |
406 | 432 | <dd><a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['member']['ip'], ';u=', $context['member']['id'], '">', $context['member']['ip'], '</a></dd>'; |
433 | + } |
|
407 | 434 | |
408 | - if (empty($modSettings['disableHostnameLookup']) && !empty($context['member']['ip'])) |
|
409 | - echo ' |
|
435 | + if (empty($modSettings['disableHostnameLookup']) && !empty($context['member']['ip'])) { |
|
436 | + echo ' |
|
410 | 437 | <dt>', $txt['hostname'], ': </dt> |
411 | 438 | <dd>', $context['member']['hostname'], '</dd>'; |
439 | + } |
|
412 | 440 | } |
413 | 441 | |
414 | 442 | echo ' |
415 | 443 | <dt>', $txt['local_time'], ':</dt> |
416 | 444 | <dd>', $context['member']['local_time'], '</dd>'; |
417 | 445 | |
418 | - if (!empty($modSettings['userLanguage']) && !empty($context['member']['language'])) |
|
419 | - echo ' |
|
446 | + if (!empty($modSettings['userLanguage']) && !empty($context['member']['language'])) { |
|
447 | + echo ' |
|
420 | 448 | <dt>', $txt['language'], ':</dt> |
421 | 449 | <dd>', $context['member']['language'], '</dd>'; |
450 | + } |
|
422 | 451 | |
423 | - if ($context['member']['show_last_login']) |
|
424 | - echo ' |
|
452 | + if ($context['member']['show_last_login']) { |
|
453 | + echo ' |
|
425 | 454 | <dt>', $txt['lastLoggedIn'], ': </dt> |
426 | 455 | <dd>', $context['member']['last_login'], (!empty($context['member']['is_hidden']) ? ' (' . $txt['hidden'] . ')' : ''), '</dd>'; |
456 | + } |
|
427 | 457 | |
428 | 458 | echo ' |
429 | 459 | </dl>'; |
@@ -432,42 +462,47 @@ discard block |
||
432 | 462 | if (!empty($context['print_custom_fields']['above_signature'])) |
433 | 463 | { |
434 | 464 | $fields = ''; |
435 | - foreach ($context['print_custom_fields']['above_signature'] as $field) |
|
436 | - if (!empty($field['output_html'])) |
|
465 | + foreach ($context['print_custom_fields']['above_signature'] as $field) { |
|
466 | + if (!empty($field['output_html'])) |
|
437 | 467 | $fields .= ' |
438 | 468 | <li>' . $field['output_html'] . '</li>'; |
469 | + } |
|
439 | 470 | |
440 | - if (!empty($fields)) |
|
441 | - echo ' |
|
471 | + if (!empty($fields)) { |
|
472 | + echo ' |
|
442 | 473 | <div class="custom_fields_above_signature"> |
443 | 474 | <ul class="nolist">', $fields, ' |
444 | 475 | </ul> |
445 | 476 | </div>'; |
477 | + } |
|
446 | 478 | } |
447 | 479 | |
448 | 480 | // Show the users signature. |
449 | - if ($context['signature_enabled'] && !empty($context['member']['signature'])) |
|
450 | - echo ' |
|
481 | + if ($context['signature_enabled'] && !empty($context['member']['signature'])) { |
|
482 | + echo ' |
|
451 | 483 | <div class="signature"> |
452 | 484 | <h5>', $txt['signature'], ':</h5> |
453 | 485 | ', $context['member']['signature'], ' |
454 | 486 | </div>'; |
487 | + } |
|
455 | 488 | |
456 | 489 | // Are there any custom profile fields for below the signature? |
457 | 490 | if (!empty($context['print_custom_fields']['below_signature'])) |
458 | 491 | { |
459 | 492 | $fields = ''; |
460 | - foreach ($context['print_custom_fields']['below_signature'] as $field) |
|
461 | - if (!empty($field['output_html'])) |
|
493 | + foreach ($context['print_custom_fields']['below_signature'] as $field) { |
|
494 | + if (!empty($field['output_html'])) |
|
462 | 495 | $fields .= ' |
463 | 496 | <li>' . $field['output_html'] . '</li>'; |
497 | + } |
|
464 | 498 | |
465 | - if (!empty($fields)) |
|
466 | - echo ' |
|
499 | + if (!empty($fields)) { |
|
500 | + echo ' |
|
467 | 501 | <div class="custom_fields_below_signature"> |
468 | 502 | <ul class="nolist">', $fields, ' |
469 | 503 | </ul> |
470 | 504 | </div>'; |
505 | + } |
|
471 | 506 | } |
472 | 507 | |
473 | 508 | echo ' |
@@ -509,62 +544,70 @@ discard block |
||
509 | 544 | </div> |
510 | 545 | <div class="list_posts">'; |
511 | 546 | |
512 | - if (!$post['approved']) |
|
513 | - echo ' |
|
547 | + if (!$post['approved']) { |
|
548 | + echo ' |
|
514 | 549 | <div class="approve_post"> |
515 | 550 | <em>', $txt['post_awaiting_approval'], '</em> |
516 | 551 | </div>'; |
552 | + } |
|
517 | 553 | |
518 | 554 | echo ' |
519 | 555 | ', $post['body'], ' |
520 | 556 | </div>'; |
521 | 557 | |
522 | - if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) |
|
523 | - echo ' |
|
558 | + if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) { |
|
559 | + echo ' |
|
524 | 560 | <div class="floatright"> |
525 | 561 | <ul class="quickbuttons">'; |
562 | + } |
|
526 | 563 | |
527 | 564 | // If they *can* reply? |
528 | - if ($post['can_reply']) |
|
529 | - echo ' |
|
565 | + if ($post['can_reply']) { |
|
566 | + echo ' |
|
530 | 567 | <li><a href="', $scripturl, '?action=post;topic=', $post['topic'], '.', $post['start'], '"><span class="generic_icons reply_button"></span>', $txt['reply'], '</a></li>'; |
568 | + } |
|
531 | 569 | |
532 | 570 | // If they *can* quote? |
533 | - if ($post['can_quote']) |
|
534 | - echo ' |
|
571 | + if ($post['can_quote']) { |
|
572 | + echo ' |
|
535 | 573 | <li><a href="', $scripturl . '?action=post;topic=', $post['topic'], '.', $post['start'], ';quote=', $post['id'], '"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li>'; |
574 | + } |
|
536 | 575 | |
537 | 576 | // How about... even... remove it entirely?! |
538 | - if ($post['can_delete']) |
|
539 | - echo ' |
|
577 | + if ($post['can_delete']) { |
|
578 | + echo ' |
|
540 | 579 | <li><a href="', $scripturl, '?action=deletemsg;msg=', $post['id'], ';topic=', $post['topic'], ';profile;u=', $context['member']['id'], ';start=', $context['start'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['remove_message'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove'], '</a></li>'; |
580 | + } |
|
541 | 581 | |
542 | - if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) |
|
543 | - echo ' |
|
582 | + if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) { |
|
583 | + echo ' |
|
544 | 584 | </ul> |
545 | 585 | </div><!-- .floatright -->'; |
586 | + } |
|
546 | 587 | |
547 | 588 | echo ' |
548 | 589 | </div><!-- $post[css_class] -->'; |
549 | 590 | } |
591 | + } else { |
|
592 | + template_show_list('attachments'); |
|
550 | 593 | } |
551 | - else |
|
552 | - template_show_list('attachments'); |
|
553 | 594 | |
554 | 595 | // No posts? Just end with a informative message. |
555 | - if ((isset($context['attachments']) && empty($context['attachments'])) || (!isset($context['attachments']) && empty($context['posts']))) |
|
556 | - echo ' |
|
596 | + if ((isset($context['attachments']) && empty($context['attachments'])) || (!isset($context['attachments']) && empty($context['posts']))) { |
|
597 | + echo ' |
|
557 | 598 | <div class="windowbg"> |
558 | 599 | ', isset($context['attachments']) ? $txt['show_attachments_none'] : ($context['is_topics'] ? $txt['show_topics_none'] : $txt['show_posts_none']), ' |
559 | 600 | </div>'; |
601 | + } |
|
560 | 602 | |
561 | 603 | // Show more page numbers. |
562 | - if (!empty($context['page_index'])) |
|
563 | - echo ' |
|
604 | + if (!empty($context['page_index'])) { |
|
605 | + echo ' |
|
564 | 606 | <div class="pagesection"> |
565 | 607 | <div class="pagelinks">', $context['page_index'], '</div> |
566 | 608 | </div>'; |
567 | -} |
|
609 | + } |
|
610 | + } |
|
568 | 611 | |
569 | 612 | /** |
570 | 613 | * Template for showing alerts within the alerts popup |
@@ -574,11 +617,12 @@ discard block |
||
574 | 617 | global $context, $txt, $scripturl; |
575 | 618 | |
576 | 619 | // Do we have an update message? |
577 | - if (!empty($context['update_message'])) |
|
578 | - echo ' |
|
620 | + if (!empty($context['update_message'])) { |
|
621 | + echo ' |
|
579 | 622 | <div class="infobox"> |
580 | 623 | ', $context['update_message'], ' |
581 | 624 | </div>'; |
625 | + } |
|
582 | 626 | |
583 | 627 | echo ' |
584 | 628 | <div class="cat_bar"> |
@@ -587,18 +631,18 @@ discard block |
||
587 | 631 | </h3> |
588 | 632 | </div>'; |
589 | 633 | |
590 | - if (empty($context['alerts'])) |
|
591 | - echo ' |
|
634 | + if (empty($context['alerts'])) { |
|
635 | + echo ' |
|
592 | 636 | <div class="information"> |
593 | 637 | ', $txt['alerts_none'], ' |
594 | 638 | </div>'; |
595 | - |
|
596 | - else |
|
639 | + } else |
|
597 | 640 | { |
598 | 641 | // Start the form if checkboxes are in use |
599 | - if ($context['showCheckboxes']) |
|
600 | - echo ' |
|
642 | + if ($context['showCheckboxes']) { |
|
643 | + echo ' |
|
601 | 644 | <form action="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=showalerts;save" method="post" accept-charset="', $context['character_set'], '" id="mark_all">'; |
645 | + } |
|
602 | 646 | |
603 | 647 | echo ' |
604 | 648 | <table id="alerts" class="table_grid">'; |
@@ -617,9 +661,10 @@ discard block |
||
617 | 661 | <li><a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=showalerts;do=remove;aid=', $id, ';', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['delete'], '</a></li> |
618 | 662 | <li><a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=showalerts;do=', ($alert['is_read'] != 0 ? 'unread' : 'read'), ';aid=', $id, ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons ', $alert['is_read'] != 0 ? 'unread_button' : 'read_button', '"></span>', ($alert['is_read'] != 0 ? $txt['mark_unread'] : $txt['mark_read_short']), '</a></li>'; |
619 | 663 | |
620 | - if ($context['showCheckboxes']) |
|
621 | - echo ' |
|
664 | + if ($context['showCheckboxes']) { |
|
665 | + echo ' |
|
622 | 666 | <li><input type="checkbox" name="mark[', $id, ']" value="', $id, '"></li>'; |
667 | + } |
|
623 | 668 | |
624 | 669 | echo ' |
625 | 670 | </ul> |
@@ -634,8 +679,8 @@ discard block |
||
634 | 679 | ', $context['pagination'], ' |
635 | 680 | </div>'; |
636 | 681 | |
637 | - if ($context['showCheckboxes']) |
|
638 | - echo ' |
|
682 | + if ($context['showCheckboxes']) { |
|
683 | + echo ' |
|
639 | 684 | <div class="floatright"> |
640 | 685 | ', $txt['check_all'], ': <input type="checkbox" name="select_all" id="select_all"> |
641 | 686 | <select name="mark_as"> |
@@ -646,14 +691,16 @@ discard block |
||
646 | 691 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
647 | 692 | <input type="submit" name="req" value="', $txt['quick_mod_go'], '" class="button you_sure"> |
648 | 693 | </div>'; |
694 | + } |
|
649 | 695 | |
650 | 696 | echo ' |
651 | 697 | </div>'; |
652 | 698 | |
653 | - if ($context['showCheckboxes']) |
|
654 | - echo ' |
|
699 | + if ($context['showCheckboxes']) { |
|
700 | + echo ' |
|
655 | 701 | </form>'; |
656 | 702 | } |
703 | + } |
|
657 | 704 | } |
658 | 705 | |
659 | 706 | /** |
@@ -674,12 +721,12 @@ discard block |
||
674 | 721 | </div>' : ''; |
675 | 722 | |
676 | 723 | // No drafts? Just show an informative message. |
677 | - if (empty($context['drafts'])) |
|
678 | - echo ' |
|
724 | + if (empty($context['drafts'])) { |
|
725 | + echo ' |
|
679 | 726 | <div class="windowbg centertext"> |
680 | 727 | ', $txt['draft_none'], ' |
681 | 728 | </div>'; |
682 | - else |
|
729 | + } else |
|
683 | 730 | { |
684 | 731 | // For every draft to be displayed, give it its own div, and show the important details of the draft. |
685 | 732 | foreach ($context['drafts'] as $draft) |
@@ -691,13 +738,15 @@ discard block |
||
691 | 738 | <h5> |
692 | 739 | <strong><a href="', $scripturl, '?board=', $draft['board']['id'], '.0">', $draft['board']['name'], '</a> / ', $draft['topic']['link'], '</strong> '; |
693 | 740 | |
694 | - if (!empty($draft['sticky'])) |
|
695 | - echo ' |
|
741 | + if (!empty($draft['sticky'])) { |
|
742 | + echo ' |
|
696 | 743 | <span class="generic_icons sticky" title="', $txt['sticky_topic'], '"></span>'; |
744 | + } |
|
697 | 745 | |
698 | - if (!empty($draft['locked'])) |
|
699 | - echo ' |
|
746 | + if (!empty($draft['locked'])) { |
|
747 | + echo ' |
|
700 | 748 | <span class="generic_icons lock" title="', $txt['locked_topic'], '"></span>'; |
749 | + } |
|
701 | 750 | |
702 | 751 | echo ' |
703 | 752 | </h5> |
@@ -730,13 +779,13 @@ discard block |
||
730 | 779 | { |
731 | 780 | global $context, $scripturl, $txt; |
732 | 781 | |
733 | - if (!empty($context['saved_successful'])) |
|
734 | - echo ' |
|
782 | + if (!empty($context['saved_successful'])) { |
|
783 | + echo ' |
|
735 | 784 | <div class="infobox">', $context['user']['is_owner'] ? $txt['profile_updated_own'] : sprintf($txt['profile_updated_else'], $context['member']['name']), '</div>'; |
736 | - |
|
737 | - elseif (!empty($context['saved_failed'])) |
|
738 | - echo ' |
|
785 | + } elseif (!empty($context['saved_failed'])) { |
|
786 | + echo ' |
|
739 | 787 | <div class="errorbox">', $context['saved_failed'], '</div>'; |
788 | + } |
|
740 | 789 | |
741 | 790 | echo ' |
742 | 791 | <div id="edit_buddies"> |
@@ -751,14 +800,16 @@ discard block |
||
751 | 800 | <th scope="col" class="quarter_table buddy_link">', $txt['name'], '</th> |
752 | 801 | <th scope="col" class="buddy_status">', $txt['status'], '</th>'; |
753 | 802 | |
754 | - if ($context['can_moderate_forum']) |
|
755 | - echo ' |
|
803 | + if ($context['can_moderate_forum']) { |
|
804 | + echo ' |
|
756 | 805 | <th scope="col" class="buddy_email">', $txt['email'], '</th>'; |
806 | + } |
|
757 | 807 | |
758 | - if (!empty($context['custom_pf'])) |
|
759 | - foreach ($context['custom_pf'] as $column) |
|
808 | + if (!empty($context['custom_pf'])) { |
|
809 | + foreach ($context['custom_pf'] as $column) |
|
760 | 810 | echo ' |
761 | 811 | <th scope="col" class="buddy_custom_fields">', $column['label'], '</th>'; |
812 | + } |
|
762 | 813 | |
763 | 814 | echo ' |
764 | 815 | <th scope="col" class="buddy_remove">', $txt['remove'], '</th> |
@@ -767,13 +818,14 @@ discard block |
||
767 | 818 | <tbody>'; |
768 | 819 | |
769 | 820 | // If they don't have any buddies don't list them! |
770 | - if (empty($context['buddies'])) |
|
771 | - echo ' |
|
821 | + if (empty($context['buddies'])) { |
|
822 | + echo ' |
|
772 | 823 | <tr class="windowbg"> |
773 | 824 | <td colspan="', $context['can_moderate_forum'] ? '10' : '9', '"> |
774 | 825 | <strong>', $txt['no_buddies'], '</strong> |
775 | 826 | </td> |
776 | 827 | </tr>'; |
828 | + } |
|
777 | 829 | |
778 | 830 | // Now loop through each buddy showing info on each. |
779 | 831 | else |
@@ -787,17 +839,19 @@ discard block |
||
787 | 839 | <a href="', $buddy['online']['href'], '"><span class="' . ($buddy['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $buddy['online']['text'] . '"></span></a> |
788 | 840 | </td>'; |
789 | 841 | |
790 | - if ($buddy['show_email']) |
|
791 | - echo ' |
|
842 | + if ($buddy['show_email']) { |
|
843 | + echo ' |
|
792 | 844 | <td class="buddy_email centertext"> |
793 | 845 | <a href="mailto:' . $buddy['email'] . '" rel="nofollow"><span class="generic_icons mail icon" title="' . $txt['email'] . ' ' . $buddy['name'] . '"></span></a> |
794 | 846 | </td>'; |
847 | + } |
|
795 | 848 | |
796 | 849 | // Show the custom profile fields for this user. |
797 | - if (!empty($context['custom_pf'])) |
|
798 | - foreach ($context['custom_pf'] as $key => $column) |
|
850 | + if (!empty($context['custom_pf'])) { |
|
851 | + foreach ($context['custom_pf'] as $key => $column) |
|
799 | 852 | echo ' |
800 | 853 | <td class="lefttext buddy_custom_fields">', $buddy['options'][$key], '</td>'; |
854 | + } |
|
801 | 855 | |
802 | 856 | echo ' |
803 | 857 | <td class="centertext buddy_remove"> |
@@ -830,9 +884,10 @@ discard block |
||
830 | 884 | </dl> |
831 | 885 | </div>'; |
832 | 886 | |
833 | - if (!empty($context['token_check'])) |
|
834 | - echo ' |
|
887 | + if (!empty($context['token_check'])) { |
|
888 | + echo ' |
|
835 | 889 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
890 | + } |
|
836 | 891 | |
837 | 892 | echo ' |
838 | 893 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -858,13 +913,13 @@ discard block |
||
858 | 913 | { |
859 | 914 | global $context, $scripturl, $txt; |
860 | 915 | |
861 | - if (!empty($context['saved_successful'])) |
|
862 | - echo ' |
|
916 | + if (!empty($context['saved_successful'])) { |
|
917 | + echo ' |
|
863 | 918 | <div class="infobox">', $context['user']['is_owner'] ? $txt['profile_updated_own'] : sprintf($txt['profile_updated_else'], $context['member']['name']), '</div>'; |
864 | - |
|
865 | - elseif (!empty($context['saved_failed'])) |
|
866 | - echo ' |
|
919 | + } elseif (!empty($context['saved_failed'])) { |
|
920 | + echo ' |
|
867 | 921 | <div class="errorbox">', $context['saved_failed'], '</div>'; |
922 | + } |
|
868 | 923 | |
869 | 924 | echo ' |
870 | 925 | <div id="edit_buddies"> |
@@ -879,9 +934,10 @@ discard block |
||
879 | 934 | <th scope="col" class="quarter_table buddy_link">', $txt['name'], '</th> |
880 | 935 | <th scope="col" class="buddy_status">', $txt['status'], '</th>'; |
881 | 936 | |
882 | - if ($context['can_moderate_forum']) |
|
883 | - echo ' |
|
937 | + if ($context['can_moderate_forum']) { |
|
938 | + echo ' |
|
884 | 939 | <th scope="col" class="buddy_email">', $txt['email'], '</th>'; |
940 | + } |
|
885 | 941 | |
886 | 942 | echo ' |
887 | 943 | <th scope="col" class="buddy_remove">', $txt['ignore_remove'], '</th> |
@@ -890,13 +946,14 @@ discard block |
||
890 | 946 | <tbody>'; |
891 | 947 | |
892 | 948 | // If they don't have anyone on their ignore list, don't list it! |
893 | - if (empty($context['ignore_list'])) |
|
894 | - echo ' |
|
949 | + if (empty($context['ignore_list'])) { |
|
950 | + echo ' |
|
895 | 951 | <tr class="windowbg"> |
896 | 952 | <td colspan="', $context['can_moderate_forum'] ? '4' : '3', '"> |
897 | 953 | <strong>', $txt['no_ignore'], '</strong> |
898 | 954 | </td> |
899 | 955 | </tr>'; |
956 | + } |
|
900 | 957 | |
901 | 958 | // Now loop through each buddy showing info on each. |
902 | 959 | foreach ($context['ignore_list'] as $member) |
@@ -908,11 +965,12 @@ discard block |
||
908 | 965 | <a href="', $member['online']['href'], '"><span class="' . ($member['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $member['online']['text'] . '"></span></a> |
909 | 966 | </td>'; |
910 | 967 | |
911 | - if ($context['can_moderate_forum']) |
|
912 | - echo ' |
|
968 | + if ($context['can_moderate_forum']) { |
|
969 | + echo ' |
|
913 | 970 | <td class="centertext buddy_email"> |
914 | 971 | <a href="mailto:' . $member['email'] . '" rel="nofollow"><span class="generic_icons mail icon" title="' . $txt['email'] . ' ' . $member['name'] . '"></span></a> |
915 | 972 | </td>'; |
973 | + } |
|
916 | 974 | echo ' |
917 | 975 | <td class="centertext buddy_remove"> |
918 | 976 | <a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=lists;sa=ignore;remove=', $member['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons delete" title="', $txt['ignore_remove'], '"></span></a> |
@@ -943,9 +1001,10 @@ discard block |
||
943 | 1001 | </dl> |
944 | 1002 | </div>'; |
945 | 1003 | |
946 | - if (!empty($context['token_check'])) |
|
947 | - echo ' |
|
1004 | + if (!empty($context['token_check'])) { |
|
1005 | + echo ' |
|
948 | 1006 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
1007 | + } |
|
949 | 1008 | |
950 | 1009 | echo ' |
951 | 1010 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -990,9 +1049,10 @@ discard block |
||
990 | 1049 | <a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['last_ip'], ';u=', $context['member']['id'], '">', $context['last_ip'], '</a>'; |
991 | 1050 | |
992 | 1051 | // Second address detected? |
993 | - if (!empty($context['last_ip2'])) |
|
994 | - echo ' |
|
1052 | + if (!empty($context['last_ip2'])) { |
|
1053 | + echo ' |
|
995 | 1054 | , <a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['last_ip2'], ';u=', $context['member']['id'], '">', $context['last_ip2'], '</a>'; |
1055 | + } |
|
996 | 1056 | |
997 | 1057 | echo ' |
998 | 1058 | </dd>'; |
@@ -1058,9 +1118,10 @@ discard block |
||
1058 | 1118 | </div> |
1059 | 1119 | <div class="windowbg">'; |
1060 | 1120 | |
1061 | - foreach ($context['whois_servers'] as $server) |
|
1062 | - echo ' |
|
1121 | + foreach ($context['whois_servers'] as $server) { |
|
1122 | + echo ' |
|
1063 | 1123 | <a href="', $server['url'], '" target="_blank" rel="noopener"', '>', $server['name'], '</a><br>'; |
1124 | + } |
|
1064 | 1125 | echo ' |
1065 | 1126 | </div> |
1066 | 1127 | <br>'; |
@@ -1072,13 +1133,12 @@ discard block |
||
1072 | 1133 | <h3 class="catbg">', $txt['members_from_ip'], ' ', $context['ip'], '</h3> |
1073 | 1134 | </div>'; |
1074 | 1135 | |
1075 | - if (empty($context['ips'])) |
|
1076 | - echo ' |
|
1136 | + if (empty($context['ips'])) { |
|
1137 | + echo ' |
|
1077 | 1138 | <p class="windowbg description"> |
1078 | 1139 | <em>', $txt['no_members_from_ip'], '</em> |
1079 | 1140 | </p>'; |
1080 | - |
|
1081 | - else |
|
1141 | + } else |
|
1082 | 1142 | { |
1083 | 1143 | echo ' |
1084 | 1144 | <table class="table_grid"> |
@@ -1091,12 +1151,13 @@ discard block |
||
1091 | 1151 | <tbody>'; |
1092 | 1152 | |
1093 | 1153 | // Loop through each of the members and display them. |
1094 | - foreach ($context['ips'] as $ip => $memberlist) |
|
1095 | - echo ' |
|
1154 | + foreach ($context['ips'] as $ip => $memberlist) { |
|
1155 | + echo ' |
|
1096 | 1156 | <tr class="windowbg"> |
1097 | 1157 | <td><a href="', $context['base_url'], ';searchip=', $ip, '">', $ip, '</a></td> |
1098 | 1158 | <td>', implode(', ', $memberlist), '</td> |
1099 | 1159 | </tr>'; |
1160 | + } |
|
1100 | 1161 | |
1101 | 1162 | echo ' |
1102 | 1163 | </tbody> |
@@ -1138,11 +1199,10 @@ discard block |
||
1138 | 1199 | </h3> |
1139 | 1200 | </div>'; |
1140 | 1201 | |
1141 | - if ($context['member']['has_all_permissions']) |
|
1142 | - echo ' |
|
1202 | + if ($context['member']['has_all_permissions']) { |
|
1203 | + echo ' |
|
1143 | 1204 | <div class="information">', $txt['showPermissions_all'], '</div>'; |
1144 | - |
|
1145 | - else |
|
1205 | + } else |
|
1146 | 1206 | { |
1147 | 1207 | echo ' |
1148 | 1208 | <div class="information">',$txt['showPermissions_help'], '</div> |
@@ -1157,9 +1217,10 @@ discard block |
||
1157 | 1217 | <div class="windowbg smalltext"> |
1158 | 1218 | ', $txt['showPermissions_restricted_boards_desc'], ':<br>'; |
1159 | 1219 | |
1160 | - foreach ($context['no_access_boards'] as $no_access_board) |
|
1161 | - echo ' |
|
1220 | + foreach ($context['no_access_boards'] as $no_access_board) { |
|
1221 | + echo ' |
|
1162 | 1222 | <a href="', $scripturl, '?board=', $no_access_board['id'], '.0">', $no_access_board['name'], '</a>', $no_access_board['is_last'] ? '' : ', '; |
1223 | + } |
|
1163 | 1224 | echo ' |
1164 | 1225 | </div>'; |
1165 | 1226 | } |
@@ -1191,12 +1252,13 @@ discard block |
||
1191 | 1252 | </td> |
1192 | 1253 | <td class="smalltext">'; |
1193 | 1254 | |
1194 | - if ($permission['is_denied']) |
|
1195 | - echo ' |
|
1255 | + if ($permission['is_denied']) { |
|
1256 | + echo ' |
|
1196 | 1257 | <span class="alert">', $txt['showPermissions_denied'], ': ', implode(', ', $permission['groups']['denied']), '</span>'; |
1197 | - else |
|
1198 | - echo ' |
|
1258 | + } else { |
|
1259 | + echo ' |
|
1199 | 1260 | ', $txt['showPermissions_given'], ': ', implode(', ', $permission['groups']['allowed']); |
1261 | + } |
|
1200 | 1262 | |
1201 | 1263 | echo ' |
1202 | 1264 | </td> |
@@ -1207,10 +1269,10 @@ discard block |
||
1207 | 1269 | </table> |
1208 | 1270 | </div><!-- .tborder --> |
1209 | 1271 | <br>'; |
1210 | - } |
|
1211 | - else |
|
1212 | - echo ' |
|
1272 | + } else { |
|
1273 | + echo ' |
|
1213 | 1274 | <p class="windowbg">', $txt['showPermissions_none_general'], '</p>'; |
1275 | + } |
|
1214 | 1276 | |
1215 | 1277 | // Board permission section. |
1216 | 1278 | echo ' |
@@ -1221,14 +1283,16 @@ discard block |
||
1221 | 1283 | <select name="board" onchange="if (this.options[this.selectedIndex].value) this.form.submit();"> |
1222 | 1284 | <option value="0"', $context['board'] == 0 ? ' selected' : '', '>', $txt['showPermissions_global'], '</option>'; |
1223 | 1285 | |
1224 | - if (!empty($context['boards'])) |
|
1225 | - echo ' |
|
1286 | + if (!empty($context['boards'])) { |
|
1287 | + echo ' |
|
1226 | 1288 | <option value="" disabled>---------------------------</option>'; |
1289 | + } |
|
1227 | 1290 | |
1228 | 1291 | // Fill the box with any local permission boards. |
1229 | - foreach ($context['boards'] as $board) |
|
1230 | - echo ' |
|
1292 | + foreach ($context['boards'] as $board) { |
|
1293 | + echo ' |
|
1231 | 1294 | <option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['name'], ' (', $board['profile_name'], ')</option>'; |
1295 | + } |
|
1232 | 1296 | |
1233 | 1297 | echo ' |
1234 | 1298 | </select> |
@@ -1257,13 +1321,13 @@ discard block |
||
1257 | 1321 | </td> |
1258 | 1322 | <td class="smalltext">'; |
1259 | 1323 | |
1260 | - if ($permission['is_denied']) |
|
1261 | - echo ' |
|
1324 | + if ($permission['is_denied']) { |
|
1325 | + echo ' |
|
1262 | 1326 | <span class="alert">', $txt['showPermissions_denied'], ': ', implode(', ', $permission['groups']['denied']), '</span>'; |
1263 | - |
|
1264 | - else |
|
1265 | - echo ' |
|
1327 | + } else { |
|
1328 | + echo ' |
|
1266 | 1329 | ', $txt['showPermissions_given'], ': ', implode(', ', $permission['groups']['allowed']); |
1330 | + } |
|
1267 | 1331 | |
1268 | 1332 | echo ' |
1269 | 1333 | </td> |
@@ -1272,10 +1336,10 @@ discard block |
||
1272 | 1336 | echo ' |
1273 | 1337 | </tbody> |
1274 | 1338 | </table>'; |
1275 | - } |
|
1276 | - else |
|
1277 | - echo ' |
|
1339 | + } else { |
|
1340 | + echo ' |
|
1278 | 1341 | <p class="windowbg">', $txt['showPermissions_none_board'], '</p>'; |
1342 | + } |
|
1279 | 1343 | echo ' |
1280 | 1344 | </div><!-- #permissions -->'; |
1281 | 1345 | } |
@@ -1299,12 +1363,13 @@ discard block |
||
1299 | 1363 | echo ' |
1300 | 1364 | <dt>', $txt['statPanel_' . $key], '</dt>'; |
1301 | 1365 | |
1302 | - if (!empty($stat['url'])) |
|
1303 | - echo ' |
|
1366 | + if (!empty($stat['url'])) { |
|
1367 | + echo ' |
|
1304 | 1368 | <dd><a href="', $stat['url'], '">', $stat['text'], '</a></dd>'; |
1305 | - else |
|
1306 | - echo ' |
|
1369 | + } else { |
|
1370 | + echo ' |
|
1307 | 1371 | <dd>', $stat['text'], '</dd>'; |
1372 | + } |
|
1308 | 1373 | } |
1309 | 1374 | |
1310 | 1375 | echo ' |
@@ -1321,9 +1386,10 @@ discard block |
||
1321 | 1386 | </div>'; |
1322 | 1387 | |
1323 | 1388 | // If they haven't post at all, don't draw the graph. |
1324 | - if (empty($context['posts_by_time'])) |
|
1325 | - echo ' |
|
1389 | + if (empty($context['posts_by_time'])) { |
|
1390 | + echo ' |
|
1326 | 1391 | <p class="centertext padding">', $txt['statPanel_noPosts'], '</p>'; |
1392 | + } |
|
1327 | 1393 | |
1328 | 1394 | // Otherwise do! |
1329 | 1395 | else |
@@ -1332,8 +1398,8 @@ discard block |
||
1332 | 1398 | <ul class="activity_stats flow_hidden">'; |
1333 | 1399 | |
1334 | 1400 | // The labels. |
1335 | - foreach ($context['posts_by_time'] as $time_of_day) |
|
1336 | - echo ' |
|
1401 | + foreach ($context['posts_by_time'] as $time_of_day) { |
|
1402 | + echo ' |
|
1337 | 1403 | <li> |
1338 | 1404 | <div class="generic_bar vertical"> |
1339 | 1405 | <div class="bar" style="height: ', (int) $time_of_day['relative_percent'], '%;"> |
@@ -1342,6 +1408,7 @@ discard block |
||
1342 | 1408 | </div> |
1343 | 1409 | <span class="stats_hour">', $time_of_day['hour_format'], '</span> |
1344 | 1410 | </li>'; |
1411 | + } |
|
1345 | 1412 | |
1346 | 1413 | echo ' |
1347 | 1414 | </ul>'; |
@@ -1360,11 +1427,10 @@ discard block |
||
1360 | 1427 | </h3> |
1361 | 1428 | </div>'; |
1362 | 1429 | |
1363 | - if (empty($context['popular_boards'])) |
|
1364 | - echo ' |
|
1430 | + if (empty($context['popular_boards'])) { |
|
1431 | + echo ' |
|
1365 | 1432 | <p class="centertext padding">', $txt['statPanel_noPosts'], '</p>'; |
1366 | - |
|
1367 | - else |
|
1433 | + } else |
|
1368 | 1434 | { |
1369 | 1435 | echo ' |
1370 | 1436 | <dl class="stats">'; |
@@ -1394,10 +1460,10 @@ discard block |
||
1394 | 1460 | </h3> |
1395 | 1461 | </div>'; |
1396 | 1462 | |
1397 | - if (empty($context['board_activity'])) |
|
1398 | - echo ' |
|
1463 | + if (empty($context['board_activity'])) { |
|
1464 | + echo ' |
|
1399 | 1465 | <p class="centertext padding">', $txt['statPanel_noPosts'], '</p>'; |
1400 | - else |
|
1466 | + } else |
|
1401 | 1467 | { |
1402 | 1468 | echo ' |
1403 | 1469 | <dl class="stats">'; |
@@ -1448,90 +1514,97 @@ discard block |
||
1448 | 1514 | <h3 class="catbg profile_hd">'; |
1449 | 1515 | |
1450 | 1516 | // Don't say "Profile" if this isn't the profile... |
1451 | - if (!empty($context['profile_header_text'])) |
|
1452 | - echo ' |
|
1517 | + if (!empty($context['profile_header_text'])) { |
|
1518 | + echo ' |
|
1453 | 1519 | ', $context['profile_header_text']; |
1454 | - else |
|
1455 | - echo ' |
|
1520 | + } else { |
|
1521 | + echo ' |
|
1456 | 1522 | ', $txt['profile']; |
1523 | + } |
|
1457 | 1524 | |
1458 | 1525 | echo ' |
1459 | 1526 | </h3> |
1460 | 1527 | </div>'; |
1461 | 1528 | |
1462 | 1529 | // Have we some description? |
1463 | - if ($context['page_desc']) |
|
1464 | - echo ' |
|
1530 | + if ($context['page_desc']) { |
|
1531 | + echo ' |
|
1465 | 1532 | <p class="information">', $context['page_desc'], '</p>'; |
1533 | + } |
|
1466 | 1534 | |
1467 | 1535 | echo ' |
1468 | 1536 | <div class="roundframe">'; |
1469 | 1537 | |
1470 | 1538 | // Any bits at the start? |
1471 | - if (!empty($context['profile_prehtml'])) |
|
1472 | - echo ' |
|
1539 | + if (!empty($context['profile_prehtml'])) { |
|
1540 | + echo ' |
|
1473 | 1541 | <div>', $context['profile_prehtml'], '</div>'; |
1542 | + } |
|
1474 | 1543 | |
1475 | - if (!empty($context['profile_fields'])) |
|
1476 | - echo ' |
|
1544 | + if (!empty($context['profile_fields'])) { |
|
1545 | + echo ' |
|
1477 | 1546 | <dl class="settings">'; |
1547 | + } |
|
1478 | 1548 | |
1479 | 1549 | // Start the big old loop 'of love. |
1480 | 1550 | $lastItem = 'hr'; |
1481 | 1551 | foreach ($context['profile_fields'] as $key => $field) |
1482 | 1552 | { |
1483 | 1553 | // We add a little hack to be sure we never get more than one hr in a row! |
1484 | - if ($lastItem == 'hr' && $field['type'] == 'hr') |
|
1485 | - continue; |
|
1554 | + if ($lastItem == 'hr' && $field['type'] == 'hr') { |
|
1555 | + continue; |
|
1556 | + } |
|
1486 | 1557 | |
1487 | 1558 | $lastItem = $field['type']; |
1488 | - if ($field['type'] == 'hr') |
|
1489 | - echo ' |
|
1559 | + if ($field['type'] == 'hr') { |
|
1560 | + echo ' |
|
1490 | 1561 | </dl> |
1491 | 1562 | <hr> |
1492 | 1563 | <dl class="settings">'; |
1493 | - |
|
1494 | - elseif ($field['type'] == 'callback') |
|
1564 | + } elseif ($field['type'] == 'callback') |
|
1495 | 1565 | { |
1496 | 1566 | if (isset($field['callback_func']) && function_exists('template_profile_' . $field['callback_func'])) |
1497 | 1567 | { |
1498 | 1568 | $callback_func = 'template_profile_' . $field['callback_func']; |
1499 | 1569 | $callback_func(); |
1500 | 1570 | } |
1501 | - } |
|
1502 | - else |
|
1571 | + } else |
|
1503 | 1572 | { |
1504 | 1573 | echo ' |
1505 | 1574 | <dt> |
1506 | 1575 | <strong', !empty($field['is_error']) ? ' class="error"' : '', '>', $field['type'] !== 'label' ? '<label for="' . $key . '">' : '', $field['label'], $field['type'] !== 'label' ? '</label>' : '', '</strong>'; |
1507 | 1576 | |
1508 | 1577 | // Does it have any subtext to show? |
1509 | - if (!empty($field['subtext'])) |
|
1510 | - echo ' |
|
1578 | + if (!empty($field['subtext'])) { |
|
1579 | + echo ' |
|
1511 | 1580 | <br> |
1512 | 1581 | <span class="smalltext">', $field['subtext'], '</span>'; |
1582 | + } |
|
1513 | 1583 | |
1514 | 1584 | echo ' |
1515 | 1585 | </dt> |
1516 | 1586 | <dd>'; |
1517 | 1587 | |
1518 | 1588 | // Want to put something infront of the box? |
1519 | - if (!empty($field['preinput'])) |
|
1520 | - echo ' |
|
1589 | + if (!empty($field['preinput'])) { |
|
1590 | + echo ' |
|
1521 | 1591 | ', $field['preinput']; |
1592 | + } |
|
1522 | 1593 | |
1523 | 1594 | // What type of data are we showing? |
1524 | - if ($field['type'] == 'label') |
|
1525 | - echo ' |
|
1595 | + if ($field['type'] == 'label') { |
|
1596 | + echo ' |
|
1526 | 1597 | ', $field['value']; |
1598 | + } |
|
1527 | 1599 | |
1528 | 1600 | // Maybe it's a text box - very likely! |
1529 | 1601 | elseif (in_array($field['type'], array('int', 'float', 'text', 'password', 'color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'number', 'time', 'url'))) |
1530 | 1602 | { |
1531 | - if ($field['type'] == 'int' || $field['type'] == 'float') |
|
1532 | - $type = 'number'; |
|
1533 | - else |
|
1534 | - $type = $field['type']; |
|
1603 | + if ($field['type'] == 'int' || $field['type'] == 'float') { |
|
1604 | + $type = 'number'; |
|
1605 | + } else { |
|
1606 | + $type = $field['type']; |
|
1607 | + } |
|
1535 | 1608 | $step = $field['type'] == 'float' ? ' step="0.1"' : ''; |
1536 | 1609 | |
1537 | 1610 | |
@@ -1539,10 +1612,11 @@ discard block |
||
1539 | 1612 | <input type="', $type, '" name="', $key, '" id="', $key, '" size="', empty($field['size']) ? 30 : $field['size'], '" value="', $field['value'], '" ', $field['input_attr'], ' ', $step, '>'; |
1540 | 1613 | } |
1541 | 1614 | // You "checking" me out? ;) |
1542 | - elseif ($field['type'] == 'check') |
|
1543 | - echo ' |
|
1615 | + elseif ($field['type'] == 'check') { |
|
1616 | + echo ' |
|
1544 | 1617 | <input type="hidden" name="', $key, '" value="0"> |
1545 | 1618 | <input type="checkbox" name="', $key, '" id="', $key, '"', !empty($field['value']) ? ' checked' : '', ' value="1" ', $field['input_attr'], '>'; |
1619 | + } |
|
1546 | 1620 | |
1547 | 1621 | // Always fun - select boxes! |
1548 | 1622 | elseif ($field['type'] == 'select') |
@@ -1553,14 +1627,16 @@ discard block |
||
1553 | 1627 | if (isset($field['options'])) |
1554 | 1628 | { |
1555 | 1629 | // Is this some code to generate the options? |
1556 | - if (!is_array($field['options'])) |
|
1557 | - $field['options'] = $field['options'](); |
|
1630 | + if (!is_array($field['options'])) { |
|
1631 | + $field['options'] = $field['options'](); |
|
1632 | + } |
|
1558 | 1633 | |
1559 | 1634 | // Assuming we now have some! |
1560 | - if (is_array($field['options'])) |
|
1561 | - foreach ($field['options'] as $value => $name) |
|
1635 | + if (is_array($field['options'])) { |
|
1636 | + foreach ($field['options'] as $value => $name) |
|
1562 | 1637 | echo ' |
1563 | 1638 | <option', is_numeric($value) ? ' value="" disabled' : ' value="' . $value . '"', $value === $field['value'] ? ' selected' : '', '>', $name, '</option>'; |
1639 | + } |
|
1564 | 1640 | } |
1565 | 1641 | |
1566 | 1642 | echo ' |
@@ -1568,31 +1644,34 @@ discard block |
||
1568 | 1644 | } |
1569 | 1645 | |
1570 | 1646 | // Something to end with? |
1571 | - if (!empty($field['postinput'])) |
|
1572 | - echo ' |
|
1647 | + if (!empty($field['postinput'])) { |
|
1648 | + echo ' |
|
1573 | 1649 | ', $field['postinput']; |
1650 | + } |
|
1574 | 1651 | |
1575 | 1652 | echo ' |
1576 | 1653 | </dd>'; |
1577 | 1654 | } |
1578 | 1655 | } |
1579 | 1656 | |
1580 | - if (!empty($context['profile_fields'])) |
|
1581 | - echo ' |
|
1657 | + if (!empty($context['profile_fields'])) { |
|
1658 | + echo ' |
|
1582 | 1659 | </dl>'; |
1660 | + } |
|
1583 | 1661 | |
1584 | 1662 | // Are there any custom profile fields - if so print them! |
1585 | 1663 | if (!empty($context['custom_fields'])) |
1586 | 1664 | { |
1587 | - if ($lastItem != 'hr') |
|
1588 | - echo ' |
|
1665 | + if ($lastItem != 'hr') { |
|
1666 | + echo ' |
|
1589 | 1667 | <hr>'; |
1668 | + } |
|
1590 | 1669 | |
1591 | 1670 | echo ' |
1592 | 1671 | <dl class="settings">'; |
1593 | 1672 | |
1594 | - foreach ($context['custom_fields'] as $field) |
|
1595 | - echo ' |
|
1673 | + foreach ($context['custom_fields'] as $field) { |
|
1674 | + echo ' |
|
1596 | 1675 | <dt> |
1597 | 1676 | <strong>', $field['name'], ': </strong><br> |
1598 | 1677 | <span class="smalltext">', $field['desc'], '</span> |
@@ -1600,19 +1679,21 @@ discard block |
||
1600 | 1679 | <dd> |
1601 | 1680 | ', $field['input_html'], ' |
1602 | 1681 | </dd>'; |
1682 | + } |
|
1603 | 1683 | |
1604 | 1684 | echo ' |
1605 | 1685 | </dl>'; |
1606 | 1686 | } |
1607 | 1687 | |
1608 | 1688 | // Any closing HTML? |
1609 | - if (!empty($context['profile_posthtml'])) |
|
1610 | - echo ' |
|
1689 | + if (!empty($context['profile_posthtml'])) { |
|
1690 | + echo ' |
|
1611 | 1691 | <div>', $context['profile_posthtml'], '</div>'; |
1692 | + } |
|
1612 | 1693 | |
1613 | 1694 | // Only show the password box if it's actually needed. |
1614 | - if ($context['require_password']) |
|
1615 | - echo ' |
|
1695 | + if ($context['require_password']) { |
|
1696 | + echo ' |
|
1616 | 1697 | <dl class="settings"> |
1617 | 1698 | <dt> |
1618 | 1699 | <strong', isset($context['modify_error']['bad_password']) || isset($context['modify_error']['no_password']) ? ' class="error"' : '', '><label for="oldpasswrd">', $txt['current_password'], ': </label></strong><br> |
@@ -1622,18 +1703,21 @@ discard block |
||
1622 | 1703 | <input type="password" name="oldpasswrd" id="oldpasswrd" size="20"> |
1623 | 1704 | </dd> |
1624 | 1705 | </dl>'; |
1706 | + } |
|
1625 | 1707 | |
1626 | 1708 | // The button shouldn't say "Change profile" unless we're changing the profile... |
1627 | - if (!empty($context['submit_button_text'])) |
|
1628 | - echo ' |
|
1709 | + if (!empty($context['submit_button_text'])) { |
|
1710 | + echo ' |
|
1629 | 1711 | <input type="submit" name="save" value="', $context['submit_button_text'], '" class="button floatright">'; |
1630 | - else |
|
1631 | - echo ' |
|
1712 | + } else { |
|
1713 | + echo ' |
|
1632 | 1714 | <input type="submit" name="save" value="', $txt['change_profile'], '" class="button floatright">'; |
1715 | + } |
|
1633 | 1716 | |
1634 | - if (!empty($context['token_check'])) |
|
1635 | - echo ' |
|
1717 | + if (!empty($context['token_check'])) { |
|
1718 | + echo ' |
|
1636 | 1719 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
1720 | + } |
|
1637 | 1721 | |
1638 | 1722 | echo ' |
1639 | 1723 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -1643,10 +1727,11 @@ discard block |
||
1643 | 1727 | </form>'; |
1644 | 1728 | |
1645 | 1729 | // Any final spellchecking stuff? |
1646 | - if (!empty($context['show_spellchecking'])) |
|
1647 | - echo ' |
|
1730 | + if (!empty($context['show_spellchecking'])) { |
|
1731 | + echo ' |
|
1648 | 1732 | <form name="spell_form" id="spell_form" method="post" accept-charset="', $context['character_set'], '" target="spellWindow" action="', $scripturl, '?action=spellcheck"><input type="hidden" name="spellstring" value=""></form>'; |
1649 | -} |
|
1733 | + } |
|
1734 | + } |
|
1650 | 1735 | |
1651 | 1736 | /** |
1652 | 1737 | * Personal Message settings. |
@@ -1683,10 +1768,11 @@ discard block |
||
1683 | 1768 | <select name="pm_receive_from" id="pm_receive_from"> |
1684 | 1769 | <option value="0"', empty($context['receive_from']) || (empty($modSettings['enable_buddylist']) && $context['receive_from'] < 3) ? ' selected' : '', '>', $txt['pm_receive_from_everyone'], '</option>'; |
1685 | 1770 | |
1686 | - if (!empty($modSettings['enable_buddylist'])) |
|
1687 | - echo ' |
|
1771 | + if (!empty($modSettings['enable_buddylist'])) { |
|
1772 | + echo ' |
|
1688 | 1773 | <option value="1"', !empty($context['receive_from']) && $context['receive_from'] == 1 ? ' selected' : '', '>', $txt['pm_receive_from_ignore'], '</option> |
1689 | 1774 | <option value="2"', !empty($context['receive_from']) && $context['receive_from'] == 2 ? ' selected' : '', '>', $txt['pm_receive_from_buddies'], '</option>'; |
1775 | + } |
|
1690 | 1776 | |
1691 | 1777 | echo ' |
1692 | 1778 | <option value="3"', !empty($context['receive_from']) && $context['receive_from'] > 2 ? ' selected' : '', '>', $txt['pm_receive_from_admins'], '</option> |
@@ -1729,11 +1815,12 @@ discard block |
||
1729 | 1815 | if (empty($setting) || !is_array($setting)) |
1730 | 1816 | { |
1731 | 1817 | // Insert a separator (unless this is the first item in the list) |
1732 | - if ($i !== $first_option_key) |
|
1733 | - echo ' |
|
1818 | + if ($i !== $first_option_key) { |
|
1819 | + echo ' |
|
1734 | 1820 | </dl> |
1735 | 1821 | <hr> |
1736 | 1822 | <dl class="settings">'; |
1823 | + } |
|
1737 | 1824 | |
1738 | 1825 | // Should we give a name to this section? |
1739 | 1826 | if (is_string($setting) && !empty($setting)) |
@@ -1742,51 +1829,55 @@ discard block |
||
1742 | 1829 | echo ' |
1743 | 1830 | <dt><strong>' . $setting . '</strong></dt> |
1744 | 1831 | <dd></dd>'; |
1832 | + } else { |
|
1833 | + $titled_section = false; |
|
1745 | 1834 | } |
1746 | - else |
|
1747 | - $titled_section = false; |
|
1748 | 1835 | |
1749 | 1836 | continue; |
1750 | 1837 | } |
1751 | 1838 | |
1752 | 1839 | // Is this disabled? |
1753 | - if (isset($setting['enabled']) && $setting['enabled'] === false) |
|
1754 | - continue; |
|
1840 | + if (isset($setting['enabled']) && $setting['enabled'] === false) { |
|
1841 | + continue; |
|
1842 | + } |
|
1755 | 1843 | |
1756 | 1844 | // Some of these may not be set... Set to defaults here |
1757 | 1845 | $opts = array('calendar_start_day', 'topics_per_page', 'messages_per_page', 'display_quick_mod'); |
1758 | - if (in_array($setting['id'], $opts) && !isset($context['member']['options'][$setting['id']])) |
|
1759 | - $context['member']['options'][$setting['id']] = 0; |
|
1760 | - |
|
1761 | - if (!isset($setting['type']) || $setting['type'] == 'bool') |
|
1762 | - $setting['type'] = 'checkbox'; |
|
1763 | - |
|
1764 | - elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') |
|
1765 | - $setting['type'] = 'number'; |
|
1846 | + if (in_array($setting['id'], $opts) && !isset($context['member']['options'][$setting['id']])) { |
|
1847 | + $context['member']['options'][$setting['id']] = 0; |
|
1848 | + } |
|
1766 | 1849 | |
1767 | - elseif ($setting['type'] == 'string') |
|
1768 | - $setting['type'] = 'text'; |
|
1850 | + if (!isset($setting['type']) || $setting['type'] == 'bool') { |
|
1851 | + $setting['type'] = 'checkbox'; |
|
1852 | + } elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') { |
|
1853 | + $setting['type'] = 'number'; |
|
1854 | + } elseif ($setting['type'] == 'string') { |
|
1855 | + $setting['type'] = 'text'; |
|
1856 | + } |
|
1769 | 1857 | |
1770 | - if (isset($setting['options'])) |
|
1771 | - $setting['type'] = 'list'; |
|
1858 | + if (isset($setting['options'])) { |
|
1859 | + $setting['type'] = 'list'; |
|
1860 | + } |
|
1772 | 1861 | |
1773 | 1862 | echo ' |
1774 | 1863 | <dt> |
1775 | 1864 | <label for="', $setting['id'], '">', !$titled_section ? '<strong>' : '', $setting['label'], !$titled_section ? '</strong>' : '', '</label>'; |
1776 | 1865 | |
1777 | - if (isset($setting['description'])) |
|
1778 | - echo ' |
|
1866 | + if (isset($setting['description'])) { |
|
1867 | + echo ' |
|
1779 | 1868 | <br> |
1780 | 1869 | <span class="smalltext">', $setting['description'], '</span>'; |
1870 | + } |
|
1781 | 1871 | echo ' |
1782 | 1872 | </dt> |
1783 | 1873 | <dd>'; |
1784 | 1874 | |
1785 | 1875 | // Display checkbox options |
1786 | - if ($setting['type'] == 'checkbox') |
|
1787 | - echo ' |
|
1876 | + if ($setting['type'] == 'checkbox') { |
|
1877 | + echo ' |
|
1788 | 1878 | <input type="hidden" name="default_options[' . $setting['id'] . ']" value="0"> |
1789 | 1879 | <input type="checkbox" name="default_options[', $setting['id'], ']" id="', $setting['id'], '"', !empty($context['member']['options'][$setting['id']]) ? ' checked' : '', ' value="1">'; |
1880 | + } |
|
1790 | 1881 | |
1791 | 1882 | // How about selection lists, we all love them |
1792 | 1883 | elseif ($setting['type'] == 'list') |
@@ -1794,9 +1885,10 @@ discard block |
||
1794 | 1885 | echo ' |
1795 | 1886 | <select name="default_options[', $setting['id'], ']" id="', $setting['id'], '"', '>'; |
1796 | 1887 | |
1797 | - foreach ($setting['options'] as $value => $label) |
|
1798 | - echo ' |
|
1888 | + foreach ($setting['options'] as $value => $label) { |
|
1889 | + echo ' |
|
1799 | 1890 | <option value="', $value, '"', $value == $context['member']['options'][$setting['id']] ? ' selected' : '', '>', $label, '</option>'; |
1891 | + } |
|
1800 | 1892 | |
1801 | 1893 | echo ' |
1802 | 1894 | </select>'; |
@@ -1812,14 +1904,13 @@ discard block |
||
1812 | 1904 | |
1813 | 1905 | echo ' |
1814 | 1906 | <input type="number"', $min . $max . $step; |
1815 | - } |
|
1816 | - elseif (isset($setting['type']) && $setting['type'] == 'url') |
|
1817 | - echo' |
|
1907 | + } elseif (isset($setting['type']) && $setting['type'] == 'url') { |
|
1908 | + echo' |
|
1818 | 1909 | <input type="url"'; |
1819 | - |
|
1820 | - else |
|
1821 | - echo ' |
|
1910 | + } else { |
|
1911 | + echo ' |
|
1822 | 1912 | <input type="text"'; |
1913 | + } |
|
1823 | 1914 | |
1824 | 1915 | echo ' name="default_options[', $setting['id'], ']" id="', $setting['id'], '" value="', isset($context['member']['options'][$setting['id']]) ? $context['member']['options'][$setting['id']] : $setting['value'], '"', $setting['type'] == 'number' ? ' size="5"' : '', '>'; |
1825 | 1916 | } |
@@ -1856,8 +1947,8 @@ discard block |
||
1856 | 1947 | <dl class="settings">'; |
1857 | 1948 | |
1858 | 1949 | // Allow notification on announcements to be disabled? |
1859 | - if (!empty($modSettings['allow_disableAnnounce'])) |
|
1860 | - echo ' |
|
1950 | + if (!empty($modSettings['allow_disableAnnounce'])) { |
|
1951 | + echo ' |
|
1861 | 1952 | <dt> |
1862 | 1953 | <label for="notify_announcements">', $txt['notify_important_email'], '</label> |
1863 | 1954 | </dt> |
@@ -1865,15 +1956,17 @@ discard block |
||
1865 | 1956 | <input type="hidden" name="notify_announcements" value="0"> |
1866 | 1957 | <input type="checkbox" id="notify_announcements" name="notify_announcements" value="1"', !empty($context['member']['notify_announcements']) ? ' checked' : '', '> |
1867 | 1958 | </dd>'; |
1959 | + } |
|
1868 | 1960 | |
1869 | - if (!empty($modSettings['enable_ajax_alerts'])) |
|
1870 | - echo ' |
|
1961 | + if (!empty($modSettings['enable_ajax_alerts'])) { |
|
1962 | + echo ' |
|
1871 | 1963 | <dt> |
1872 | 1964 | <label for="notify_send_body">', $txt['notify_alert_timeout'], '</label> |
1873 | 1965 | </dt> |
1874 | 1966 | <dd> |
1875 | 1967 | <input type="number" size="4" id="notify_alert_timeout" name="opt_alert_timeout" min="0" value="', $context['member']['alert_timeout'], '"> |
1876 | 1968 | </dd>'; |
1969 | + } |
|
1877 | 1970 | |
1878 | 1971 | echo ' |
1879 | 1972 | </dl> |
@@ -1905,9 +1998,10 @@ discard block |
||
1905 | 1998 | |
1906 | 1999 | $label = $txt['alert_opt_' . $opts[1]]; |
1907 | 2000 | $label_pos = isset($opts['label']) ? $opts['label'] : ''; |
1908 | - if ($label_pos == 'before') |
|
1909 | - echo ' |
|
2001 | + if ($label_pos == 'before') { |
|
2002 | + echo ' |
|
1910 | 2003 | <label for="opt_', $opts[1], '">', $label, '</label>'; |
2004 | + } |
|
1911 | 2005 | |
1912 | 2006 | $this_value = isset($context['alert_prefs'][$opts[1]]) ? $context['alert_prefs'][$opts[1]] : 0; |
1913 | 2007 | switch ($opts[0]) |
@@ -1921,17 +2015,19 @@ discard block |
||
1921 | 2015 | echo ' |
1922 | 2016 | <select name="opt_', $opts[1], '" id="opt_', $opts[1], '">'; |
1923 | 2017 | |
1924 | - foreach ($opts['opts'] as $k => $v) |
|
1925 | - echo ' |
|
2018 | + foreach ($opts['opts'] as $k => $v) { |
|
2019 | + echo ' |
|
1926 | 2020 | <option value="', $k, '"', $this_value == $k ? ' selected' : '', '>', $v, '</option>'; |
2021 | + } |
|
1927 | 2022 | echo ' |
1928 | 2023 | </select>'; |
1929 | 2024 | break; |
1930 | 2025 | } |
1931 | 2026 | |
1932 | - if ($label_pos == 'after') |
|
1933 | - echo ' |
|
2027 | + if ($label_pos == 'after') { |
|
2028 | + echo ' |
|
1934 | 2029 | <label for="opt_', $opts[1], '">', $label, '</label>'; |
2030 | + } |
|
1935 | 2031 | |
1936 | 2032 | echo ' |
1937 | 2033 | </td> |
@@ -2048,11 +2144,12 @@ discard block |
||
2048 | 2144 | <p class="information">', $txt['groupMembership_info'], '</p>'; |
2049 | 2145 | |
2050 | 2146 | // Do we have an update message? |
2051 | - if (!empty($context['update_message'])) |
|
2052 | - echo ' |
|
2147 | + if (!empty($context['update_message'])) { |
|
2148 | + echo ' |
|
2053 | 2149 | <div class="infobox"> |
2054 | 2150 | ', $context['update_message'], '. |
2055 | 2151 | </div>'; |
2152 | + } |
|
2056 | 2153 | |
2057 | 2154 | echo ' |
2058 | 2155 | <div id="groups">'; |
@@ -2074,8 +2171,7 @@ discard block |
||
2074 | 2171 | </div> |
2075 | 2172 | </div> |
2076 | 2173 | </div><!-- .groupmembership -->'; |
2077 | - } |
|
2078 | - else |
|
2174 | + } else |
|
2079 | 2175 | { |
2080 | 2176 | echo ' |
2081 | 2177 | <div class="title_bar"> |
@@ -2087,27 +2183,30 @@ discard block |
||
2087 | 2183 | echo ' |
2088 | 2184 | <div class="windowbg" id="primdiv_', $group['id'], '">'; |
2089 | 2185 | |
2090 | - if ($context['can_edit_primary']) |
|
2091 | - echo ' |
|
2186 | + if ($context['can_edit_primary']) { |
|
2187 | + echo ' |
|
2092 | 2188 | <input type="radio" name="primary" id="primary_', $group['id'], '" value="', $group['id'], '"', $group['is_primary'] ? ' checked' : '', ' onclick="highlightSelected(\'primdiv_' . $group['id'] . '\');"', $group['can_be_primary'] ? '' : ' disabled', '>'; |
2189 | + } |
|
2093 | 2190 | |
2094 | 2191 | echo ' |
2095 | 2192 | <label for="primary_', $group['id'], '"><strong>', (empty($group['color']) ? $group['name'] : '<span style="color: ' . $group['color'] . '">' . $group['name'] . '</span>'), '</strong>', (!empty($group['desc']) ? '<br><span class="smalltext">' . $group['desc'] . '</span>' : ''), '</label>'; |
2096 | 2193 | |
2097 | 2194 | // Can they leave their group? |
2098 | - if ($group['can_leave']) |
|
2099 | - echo ' |
|
2195 | + if ($group['can_leave']) { |
|
2196 | + echo ' |
|
2100 | 2197 | <a href="' . $scripturl . '?action=profile;save;u=' . $context['id_member'] . ';area=groupmembership;' . $context['session_var'] . '=' . $context['session_id'] . ';gid=' . $group['id'] . ';', $context[$context['token_check'] . '_token_var'], '=', $context[$context['token_check'] . '_token'], '">' . $txt['leave_group'] . '</a>'; |
2198 | + } |
|
2101 | 2199 | |
2102 | 2200 | echo ' |
2103 | 2201 | </div><!-- .windowbg -->'; |
2104 | 2202 | } |
2105 | 2203 | |
2106 | - if ($context['can_edit_primary']) |
|
2107 | - echo ' |
|
2204 | + if ($context['can_edit_primary']) { |
|
2205 | + echo ' |
|
2108 | 2206 | <div class="padding righttext"> |
2109 | 2207 | <input type="submit" value="', $txt['make_primary'], '" class="button"> |
2110 | 2208 | </div>'; |
2209 | + } |
|
2111 | 2210 | |
2112 | 2211 | // Any groups they can join? |
2113 | 2212 | if (!empty($context['groups']['available'])) |
@@ -2123,17 +2222,16 @@ discard block |
||
2123 | 2222 | <div class="windowbg"> |
2124 | 2223 | <strong>', (empty($group['color']) ? $group['name'] : '<span style="color: ' . $group['color'] . '">' . $group['name'] . '</span>'), '</strong>', (!empty($group['desc']) ? '<br><span class="smalltext">' . $group['desc'] . '</span>' : ''), ''; |
2125 | 2224 | |
2126 | - if ($group['type'] == 3) |
|
2127 | - echo ' |
|
2225 | + if ($group['type'] == 3) { |
|
2226 | + echo ' |
|
2128 | 2227 | <a href="', $scripturl, '?action=profile;save;u=', $context['id_member'], ';area=groupmembership;', $context['session_var'], '=', $context['session_id'], ';gid=', $group['id'], ';', $context[$context['token_check'] . '_token_var'], '=', $context[$context['token_check'] . '_token'], '" class="button floatright">', $txt['join_group'], '</a>'; |
2129 | - |
|
2130 | - elseif ($group['type'] == 2 && $group['pending']) |
|
2131 | - echo ' |
|
2228 | + } elseif ($group['type'] == 2 && $group['pending']) { |
|
2229 | + echo ' |
|
2132 | 2230 | <span class="floatright">', $txt['approval_pending'], '</span>'; |
2133 | - |
|
2134 | - elseif ($group['type'] == 2) |
|
2135 | - echo ' |
|
2231 | + } elseif ($group['type'] == 2) { |
|
2232 | + echo ' |
|
2136 | 2233 | <a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=groupmembership;request=', $group['id'], '" class="button floatright">', $txt['request_group'], '</a>'; |
2234 | + } |
|
2137 | 2235 | |
2138 | 2236 | echo ' |
2139 | 2237 | </div><!-- .windowbg -->'; |
@@ -2156,9 +2254,10 @@ discard block |
||
2156 | 2254 | |
2157 | 2255 | prevDiv.className = "windowbg"; |
2158 | 2256 | }'; |
2159 | - if (isset($context['groups']['member'][$context['primary_group']])) |
|
2160 | - echo ' |
|
2257 | + if (isset($context['groups']['member'][$context['primary_group']])) { |
|
2258 | + echo ' |
|
2161 | 2259 | highlightSelected("primdiv_' . $context['primary_group'] . '");'; |
2260 | + } |
|
2162 | 2261 | |
2163 | 2262 | echo ' |
2164 | 2263 | </script>'; |
@@ -2167,9 +2266,10 @@ discard block |
||
2167 | 2266 | echo ' |
2168 | 2267 | </div><!-- #groups -->'; |
2169 | 2268 | |
2170 | - if (!empty($context['token_check'])) |
|
2171 | - echo ' |
|
2269 | + if (!empty($context['token_check'])) { |
|
2270 | + echo ' |
|
2172 | 2271 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
2272 | + } |
|
2173 | 2273 | |
2174 | 2274 | echo ' |
2175 | 2275 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -2247,10 +2347,11 @@ discard block |
||
2247 | 2347 | |
2248 | 2348 | // Work out the starting warning. |
2249 | 2349 | $context['current_warning_mode'] = $context['warning_mode'][0]; |
2250 | - foreach ($context['warning_mode'] as $limit => $warning) |
|
2251 | - if ($context['member']['warning'] >= $limit) |
|
2350 | + foreach ($context['warning_mode'] as $limit => $warning) { |
|
2351 | + if ($context['member']['warning'] >= $limit) |
|
2252 | 2352 | $context['current_warning_mode'] = $warning; |
2253 | -} |
|
2353 | + } |
|
2354 | + } |
|
2254 | 2355 | |
2255 | 2356 | // Show all warnings of a user? |
2256 | 2357 | function template_viewWarning() |
@@ -2285,14 +2386,15 @@ discard block |
||
2285 | 2386 | </dd>'; |
2286 | 2387 | |
2287 | 2388 | // There's some impact of this? |
2288 | - if (!empty($context['level_effects'][$context['current_level']])) |
|
2289 | - echo ' |
|
2389 | + if (!empty($context['level_effects'][$context['current_level']])) { |
|
2390 | + echo ' |
|
2290 | 2391 | <dt> |
2291 | 2392 | <strong>', $txt['profile_viewwarning_impact'], ':</strong> |
2292 | 2393 | </dt> |
2293 | 2394 | <dd> |
2294 | 2395 | ', $context['level_effects'][$context['current_level']], ' |
2295 | 2396 | </dd>'; |
2397 | + } |
|
2296 | 2398 | |
2297 | 2399 | echo ' |
2298 | 2400 | </dl> |
@@ -2330,10 +2432,11 @@ discard block |
||
2330 | 2432 | |
2331 | 2433 | // Otherwise see what we can do...'; |
2332 | 2434 | |
2333 | - foreach ($context['notification_templates'] as $k => $type) |
|
2334 | - echo ' |
|
2435 | + foreach ($context['notification_templates'] as $k => $type) { |
|
2436 | + echo ' |
|
2335 | 2437 | if (index == ', $k, ') |
2336 | 2438 | document.getElementById(\'warn_body\').value = "', strtr($type['body'], array('"' => "'", "\n" => '\\n', "\r" => '')), '";'; |
2439 | + } |
|
2337 | 2440 | |
2338 | 2441 | echo ' |
2339 | 2442 | } |
@@ -2343,10 +2446,11 @@ discard block |
||
2343 | 2446 | // Also set the right effect. |
2344 | 2447 | effectText = "";'; |
2345 | 2448 | |
2346 | - foreach ($context['level_effects'] as $limit => $text) |
|
2347 | - echo ' |
|
2449 | + foreach ($context['level_effects'] as $limit => $text) { |
|
2450 | + echo ' |
|
2348 | 2451 | if (slideAmount >= ', $limit, ') |
2349 | 2452 | effectText = "', $text, '";'; |
2453 | + } |
|
2350 | 2454 | |
2351 | 2455 | echo ' |
2352 | 2456 | setInnerHTML(document.getElementById(\'cur_level_div\'), slideAmount + \'% (\' + effectText + \')\'); |
@@ -2361,32 +2465,35 @@ discard block |
||
2361 | 2465 | </h3> |
2362 | 2466 | </div>'; |
2363 | 2467 | |
2364 | - if (!$context['user']['is_owner']) |
|
2365 | - echo ' |
|
2468 | + if (!$context['user']['is_owner']) { |
|
2469 | + echo ' |
|
2366 | 2470 | <p class="information">', $txt['profile_warning_desc'], '</p>'; |
2471 | + } |
|
2367 | 2472 | |
2368 | 2473 | echo ' |
2369 | 2474 | <div class="windowbg"> |
2370 | 2475 | <dl class="settings">'; |
2371 | 2476 | |
2372 | - if (!$context['user']['is_owner']) |
|
2373 | - echo ' |
|
2477 | + if (!$context['user']['is_owner']) { |
|
2478 | + echo ' |
|
2374 | 2479 | <dt> |
2375 | 2480 | <strong>', $txt['profile_warning_name'], ':</strong> |
2376 | 2481 | </dt> |
2377 | 2482 | <dd> |
2378 | 2483 | <strong>', $context['member']['name'], '</strong> |
2379 | 2484 | </dd>'; |
2485 | + } |
|
2380 | 2486 | |
2381 | 2487 | echo ' |
2382 | 2488 | <dt> |
2383 | 2489 | <strong>', $txt['profile_warning_level'], ':</strong>'; |
2384 | 2490 | |
2385 | 2491 | // Is there only so much they can apply? |
2386 | - if ($context['warning_limit']) |
|
2387 | - echo ' |
|
2492 | + if ($context['warning_limit']) { |
|
2493 | + echo ' |
|
2388 | 2494 | <br> |
2389 | 2495 | <span class="smalltext">', sprintf($txt['profile_warning_limit_attribute'], $context['warning_limit']), '</span>'; |
2496 | + } |
|
2390 | 2497 | |
2391 | 2498 | echo ' |
2392 | 2499 | </dt> |
@@ -2441,9 +2548,10 @@ discard block |
||
2441 | 2548 | <option value="-1">', $txt['profile_warning_notify_template'], '</option> |
2442 | 2549 | <option value="-1" disabled>------------------------------</option>'; |
2443 | 2550 | |
2444 | - foreach ($context['notification_templates'] as $id_template => $template) |
|
2445 | - echo ' |
|
2551 | + foreach ($context['notification_templates'] as $id_template => $template) { |
|
2552 | + echo ' |
|
2446 | 2553 | <option value="', $id_template, '">', $template['title'], '</option>'; |
2554 | + } |
|
2447 | 2555 | |
2448 | 2556 | echo ' |
2449 | 2557 | </select> |
@@ -2456,9 +2564,10 @@ discard block |
||
2456 | 2564 | </dl> |
2457 | 2565 | <div class="righttext">'; |
2458 | 2566 | |
2459 | - if (!empty($context['token_check'])) |
|
2460 | - echo ' |
|
2567 | + if (!empty($context['token_check'])) { |
|
2568 | + echo ' |
|
2461 | 2569 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
2570 | + } |
|
2462 | 2571 | |
2463 | 2572 | echo ' |
2464 | 2573 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -2474,8 +2583,8 @@ discard block |
||
2474 | 2583 | echo ' |
2475 | 2584 | <script>'; |
2476 | 2585 | |
2477 | - if (!$context['user']['is_owner']) |
|
2478 | - echo ' |
|
2586 | + if (!$context['user']['is_owner']) { |
|
2587 | + echo ' |
|
2479 | 2588 | modifyWarnNotify(); |
2480 | 2589 | $(document).ready(function() { |
2481 | 2590 | $("#preview_button").click(function() { |
@@ -2514,6 +2623,7 @@ discard block |
||
2514 | 2623 | }); |
2515 | 2624 | return false; |
2516 | 2625 | }'; |
2626 | + } |
|
2517 | 2627 | |
2518 | 2628 | echo ' |
2519 | 2629 | </script>'; |
@@ -2536,17 +2646,19 @@ discard block |
||
2536 | 2646 | </div>'; |
2537 | 2647 | |
2538 | 2648 | // If deleting another account give them a lovely info box. |
2539 | - if (!$context['user']['is_owner']) |
|
2540 | - echo ' |
|
2649 | + if (!$context['user']['is_owner']) { |
|
2650 | + echo ' |
|
2541 | 2651 | <p class="information">', $txt['deleteAccount_desc'], '</p>'; |
2652 | + } |
|
2542 | 2653 | |
2543 | 2654 | echo ' |
2544 | 2655 | <div class="windowbg">'; |
2545 | 2656 | |
2546 | 2657 | // If they are deleting their account AND the admin needs to approve it - give them another piece of info ;) |
2547 | - if ($context['needs_approval']) |
|
2548 | - echo ' |
|
2658 | + if ($context['needs_approval']) { |
|
2659 | + echo ' |
|
2549 | 2660 | <div class="errorbox">', $txt['deleteAccount_approval'], '</div>'; |
2661 | + } |
|
2550 | 2662 | |
2551 | 2663 | // If the user is deleting their own account warn them first - and require a password! |
2552 | 2664 | if ($context['user']['is_owner']) |
@@ -2558,9 +2670,10 @@ discard block |
||
2558 | 2670 | <input type="password" name="oldpasswrd" size="20"> |
2559 | 2671 | <input type="submit" value="', $txt['yes'], '" class="button">'; |
2560 | 2672 | |
2561 | - if (!empty($context['token_check'])) |
|
2562 | - echo ' |
|
2673 | + if (!empty($context['token_check'])) { |
|
2674 | + echo ' |
|
2563 | 2675 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
2676 | + } |
|
2564 | 2677 | |
2565 | 2678 | echo ' |
2566 | 2679 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -2590,10 +2703,11 @@ discard block |
||
2590 | 2703 | <option value="topics">', $txt['deleteAccount_topics'], '</option> |
2591 | 2704 | </select>'; |
2592 | 2705 | |
2593 | - if ($context['show_perma_delete']) |
|
2594 | - echo ' |
|
2706 | + if ($context['show_perma_delete']) { |
|
2707 | + echo ' |
|
2595 | 2708 | <br> |
2596 | 2709 | <label for="perma_delete"><input type="checkbox" name="perma_delete" id="perma_delete" value="1">', $txt['deleteAccount_permanent'], ':</label>'; |
2710 | + } |
|
2597 | 2711 | |
2598 | 2712 | echo ' |
2599 | 2713 | </div>'; |
@@ -2606,9 +2720,10 @@ discard block |
||
2606 | 2720 | <div> |
2607 | 2721 | <input type="submit" value="', $txt['delete'], '" class="button">'; |
2608 | 2722 | |
2609 | - if (!empty($context['token_check'])) |
|
2610 | - echo ' |
|
2723 | + if (!empty($context['token_check'])) { |
|
2724 | + echo ' |
|
2611 | 2725 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
2726 | + } |
|
2612 | 2727 | |
2613 | 2728 | echo ' |
2614 | 2729 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -2634,8 +2749,8 @@ discard block |
||
2634 | 2749 | <hr>'; |
2635 | 2750 | |
2636 | 2751 | // Only show the password box if it's actually needed. |
2637 | - if ($context['require_password']) |
|
2638 | - echo ' |
|
2752 | + if ($context['require_password']) { |
|
2753 | + echo ' |
|
2639 | 2754 | <dl class="settings"> |
2640 | 2755 | <dt> |
2641 | 2756 | <strong', isset($context['modify_error']['bad_password']) || isset($context['modify_error']['no_password']) ? ' class="error"' : '', '>', $txt['current_password'], ': </strong><br> |
@@ -2645,13 +2760,15 @@ discard block |
||
2645 | 2760 | <input type="password" name="oldpasswrd" size="20"> |
2646 | 2761 | </dd> |
2647 | 2762 | </dl>'; |
2763 | + } |
|
2648 | 2764 | |
2649 | 2765 | echo ' |
2650 | 2766 | <div class="righttext">'; |
2651 | 2767 | |
2652 | - if (!empty($context['token_check'])) |
|
2653 | - echo ' |
|
2768 | + if (!empty($context['token_check'])) { |
|
2769 | + echo ' |
|
2654 | 2770 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
2771 | + } |
|
2655 | 2772 | |
2656 | 2773 | echo ' |
2657 | 2774 | <input type="submit" value="', $txt['change_profile'], '" class="button"> |
@@ -2678,9 +2795,10 @@ discard block |
||
2678 | 2795 | <ul id="list_errors">'; |
2679 | 2796 | |
2680 | 2797 | // Cycle through each error and display an error message. |
2681 | - foreach ($context['post_errors'] as $error) |
|
2682 | - echo ' |
|
2798 | + foreach ($context['post_errors'] as $error) { |
|
2799 | + echo ' |
|
2683 | 2800 | <li>', isset($txt['profile_error_' . $error]) ? $txt['profile_error_' . $error] : $error, '</li>'; |
2801 | + } |
|
2684 | 2802 | |
2685 | 2803 | echo ' |
2686 | 2804 | </ul>'; |
@@ -2706,12 +2824,13 @@ discard block |
||
2706 | 2824 | <select name="id_group" ', ($context['user']['is_owner'] && $context['member']['group_id'] == 1 ? 'onchange="if (this.value != 1 && !confirm(\'' . $txt['deadmin_confirm'] . '\')) this.value = 1;"' : ''), '>'; |
2707 | 2825 | |
2708 | 2826 | // Fill the select box with all primary member groups that can be assigned to a member. |
2709 | - foreach ($context['member_groups'] as $member_group) |
|
2710 | - if (!empty($member_group['can_be_primary'])) |
|
2827 | + foreach ($context['member_groups'] as $member_group) { |
|
2828 | + if (!empty($member_group['can_be_primary'])) |
|
2711 | 2829 | echo ' |
2712 | 2830 | <option value="', $member_group['id'], '"', $member_group['is_primary'] ? ' selected' : '', '> |
2713 | 2831 | ', $member_group['name'], ' |
2714 | 2832 | </option>'; |
2833 | + } |
|
2715 | 2834 | |
2716 | 2835 | echo ' |
2717 | 2836 | </select> |
@@ -2724,10 +2843,11 @@ discard block |
||
2724 | 2843 | <input type="hidden" name="additional_groups[]" value="0">'; |
2725 | 2844 | |
2726 | 2845 | // For each membergroup show a checkbox so members can be assigned to more than one group. |
2727 | - foreach ($context['member_groups'] as $member_group) |
|
2728 | - if ($member_group['can_be_additional']) |
|
2846 | + foreach ($context['member_groups'] as $member_group) { |
|
2847 | + if ($member_group['can_be_additional']) |
|
2729 | 2848 | echo ' |
2730 | 2849 | <label for="additional_groups-', $member_group['id'], '"><input type="checkbox" name="additional_groups[]" value="', $member_group['id'], '" id="additional_groups-', $member_group['id'], '"', $member_group['is_additional'] ? ' checked' : '', '> ', $member_group['name'], '</label><br>'; |
2850 | + } |
|
2731 | 2851 | |
2732 | 2852 | echo ' |
2733 | 2853 | </span> |
@@ -2787,9 +2907,10 @@ discard block |
||
2787 | 2907 | <span class="smalltext">', $txt['sig_info'], '</span><br> |
2788 | 2908 | <br>'; |
2789 | 2909 | |
2790 | - if ($context['show_spellchecking']) |
|
2791 | - echo ' |
|
2910 | + if ($context['show_spellchecking']) { |
|
2911 | + echo ' |
|
2792 | 2912 | <input type="button" value="', $txt['spell_check'], '" onclick="spellCheck(\'creator\', \'signature\');" class="button">'; |
2913 | + } |
|
2793 | 2914 | |
2794 | 2915 | echo ' |
2795 | 2916 | </dt> |
@@ -2797,17 +2918,20 @@ discard block |
||
2797 | 2918 | <textarea class="editor" onkeyup="calcCharLeft();" id="signature" name="signature" rows="5" cols="50">', $context['member']['signature'], '</textarea><br>'; |
2798 | 2919 | |
2799 | 2920 | // If there is a limit at all! |
2800 | - if (!empty($context['signature_limits']['max_length'])) |
|
2801 | - echo ' |
|
2921 | + if (!empty($context['signature_limits']['max_length'])) { |
|
2922 | + echo ' |
|
2802 | 2923 | <span class="smalltext">', sprintf($txt['max_sig_characters'], $context['signature_limits']['max_length']), ' <span id="signatureLeft">', $context['signature_limits']['max_length'], '</span></span><br>'; |
2924 | + } |
|
2803 | 2925 | |
2804 | - if (!empty($context['show_preview_button'])) |
|
2805 | - echo ' |
|
2926 | + if (!empty($context['show_preview_button'])) { |
|
2927 | + echo ' |
|
2806 | 2928 | <input type="button" name="preview_signature" id="preview_button" value="', $txt['preview_signature'], '" class="button floatright">'; |
2929 | + } |
|
2807 | 2930 | |
2808 | - if ($context['signature_warning']) |
|
2809 | - echo ' |
|
2931 | + if ($context['signature_warning']) { |
|
2932 | + echo ' |
|
2810 | 2933 | <span class="smalltext">', $context['signature_warning'], '</span>'; |
2934 | + } |
|
2811 | 2935 | |
2812 | 2936 | // Some javascript used to count how many characters have been used so far in the signature. |
2813 | 2937 | echo ' |
@@ -2838,38 +2962,43 @@ discard block |
||
2838 | 2962 | <label for="avatar_upload_box">', $txt['personal_picture'], '</label> |
2839 | 2963 | </strong>'; |
2840 | 2964 | |
2841 | - if (empty($modSettings['gravatarOverride'])) |
|
2842 | - echo ' |
|
2965 | + if (empty($modSettings['gravatarOverride'])) { |
|
2966 | + echo ' |
|
2843 | 2967 | <input type="radio" onclick="swap_avatar(this); return true;" name="avatar_choice" id="avatar_choice_none" value="none"' . ($context['member']['avatar']['choice'] == 'none' ? ' checked="checked"' : '') . '> |
2844 | 2968 | <label for="avatar_choice_none"' . (isset($context['modify_error']['bad_avatar']) ? ' class="error"' : '') . '> |
2845 | 2969 | ' . $txt['no_avatar'] . ' |
2846 | 2970 | </label><br>'; |
2971 | + } |
|
2847 | 2972 | |
2848 | - if (!empty($context['member']['avatar']['allow_server_stored'])) |
|
2849 | - echo ' |
|
2973 | + if (!empty($context['member']['avatar']['allow_server_stored'])) { |
|
2974 | + echo ' |
|
2850 | 2975 | <input type="radio" onclick="swap_avatar(this); return true;" name="avatar_choice" id="avatar_choice_server_stored" value="server_stored"' . ($context['member']['avatar']['choice'] == 'server_stored' ? ' checked="checked"' : '') . '> |
2851 | 2976 | <label for="avatar_choice_server_stored"' . (isset($context['modify_error']['bad_avatar']) ? ' class="error"' : '') . '> |
2852 | 2977 | ', $txt['choose_avatar_gallery'], ' |
2853 | 2978 | </label><br>'; |
2979 | + } |
|
2854 | 2980 | |
2855 | - if (!empty($context['member']['avatar']['allow_external'])) |
|
2856 | - echo ' |
|
2981 | + if (!empty($context['member']['avatar']['allow_external'])) { |
|
2982 | + echo ' |
|
2857 | 2983 | <input type="radio" onclick="swap_avatar(this); return true;" name="avatar_choice" id="avatar_choice_external" value="external"' . ($context['member']['avatar']['choice'] == 'external' ? ' checked="checked"' : '') . '> |
2858 | 2984 | <label for="avatar_choice_external"' . (isset($context['modify_error']['bad_avatar']) ? ' class="error"' : '') . '> |
2859 | 2985 | ', $txt['my_own_pic'], ' |
2860 | 2986 | </label><br>'; |
2987 | + } |
|
2861 | 2988 | |
2862 | - if (!empty($context['member']['avatar']['allow_upload'])) |
|
2863 | - echo ' |
|
2989 | + if (!empty($context['member']['avatar']['allow_upload'])) { |
|
2990 | + echo ' |
|
2864 | 2991 | <input type="radio" onclick="swap_avatar(this); return true;" name="avatar_choice" id="avatar_choice_upload" value="upload"' . ($context['member']['avatar']['choice'] == 'upload' ? ' checked="checked"' : '') . '> |
2865 | 2992 | <label for="avatar_choice_upload"' . (isset($context['modify_error']['bad_avatar']) ? ' class="error"' : '') . '> |
2866 | 2993 | ', $txt['avatar_will_upload'], ' |
2867 | 2994 | </label><br>'; |
2995 | + } |
|
2868 | 2996 | |
2869 | - if (!empty($context['member']['avatar']['allow_gravatar'])) |
|
2870 | - echo ' |
|
2997 | + if (!empty($context['member']['avatar']['allow_gravatar'])) { |
|
2998 | + echo ' |
|
2871 | 2999 | <input type="radio" onclick="swap_avatar(this); return true;" name="avatar_choice" id="avatar_choice_gravatar" value="gravatar"' . ($context['member']['avatar']['choice'] == 'gravatar' ? ' checked="checked"' : '') . '> |
2872 | 3000 | <label for="avatar_choice_gravatar"' . (isset($context['modify_error']['bad_avatar']) ? ' class="error"' : '') . '>' . $txt['use_gravatar'] . '</label>'; |
3001 | + } |
|
2873 | 3002 | |
2874 | 3003 | echo ' |
2875 | 3004 | </dt> |
@@ -2884,9 +3013,10 @@ discard block |
||
2884 | 3013 | <select name="cat" id="cat" size="10" onchange="changeSel(\'\');" onfocus="selectRadioByName(document.forms.creator.avatar_choice, \'server_stored\');">'; |
2885 | 3014 | |
2886 | 3015 | // This lists all the file categories. |
2887 | - foreach ($context['avatars'] as $avatar) |
|
2888 | - echo ' |
|
3016 | + foreach ($context['avatars'] as $avatar) { |
|
3017 | + echo ' |
|
2889 | 3018 | <option value="', $avatar['filename'] . ($avatar['is_dir'] ? '/' : ''), '"', ($avatar['checked'] ? ' selected' : ''), '>', $avatar['name'], '</option>'; |
3019 | + } |
|
2890 | 3020 | |
2891 | 3021 | echo ' |
2892 | 3022 | </select> |
@@ -2918,20 +3048,22 @@ discard block |
||
2918 | 3048 | } |
2919 | 3049 | |
2920 | 3050 | // If the user can link to an off server avatar, show them a box to input the address. |
2921 | - if (!empty($context['member']['avatar']['allow_external'])) |
|
2922 | - echo ' |
|
3051 | + if (!empty($context['member']['avatar']['allow_external'])) { |
|
3052 | + echo ' |
|
2923 | 3053 | <div id="avatar_external"> |
2924 | 3054 | <div class="smalltext">', $txt['avatar_by_url'], '</div>', !empty($modSettings['avatar_action_too_large']) && $modSettings['avatar_action_too_large'] == 'option_download_and_resize' ? template_max_size('external') : '', ' |
2925 | 3055 | <input type="text" name="userpicpersonal" size="45" value="', ((stristr($context['member']['avatar']['external'], 'http://') || stristr($context['member']['avatar']['external'], 'https://')) ? $context['member']['avatar']['external'] : 'http://'), '" onfocus="selectRadioByName(document.forms.creator.avatar_choice, \'external\');" onchange="if (typeof(previewExternalAvatar) != \'undefined\') previewExternalAvatar(this.value);"> |
2926 | 3056 | </div>'; |
3057 | + } |
|
2927 | 3058 | |
2928 | 3059 | // If the user is able to upload avatars to the server show them an upload box. |
2929 | - if (!empty($context['member']['avatar']['allow_upload'])) |
|
2930 | - echo ' |
|
3060 | + if (!empty($context['member']['avatar']['allow_upload'])) { |
|
3061 | + echo ' |
|
2931 | 3062 | <div id="avatar_upload"> |
2932 | 3063 | <input type="file" size="44" name="attachment" id="avatar_upload_box" value="" onchange="readfromUpload(this)" onfocus="selectRadioByName(document.forms.creator.avatar_choice, \'upload\');" accept="image/gif, image/jpeg, image/jpg, image/png">', template_max_size('upload'), ' |
2933 | 3064 | ', (!empty($context['member']['avatar']['id_attach']) ? '<br><img src="' . $context['member']['avatar']['href'] . (strpos($context['member']['avatar']['href'], '?') === false ? '?' : '&') . 'time=' . time() . '" alt="" id="attached_image"><input type="hidden" name="id_attach" value="' . $context['member']['avatar']['id_attach'] . '">' : ''), ' |
2934 | 3065 | </div>'; |
3066 | + } |
|
2935 | 3067 | |
2936 | 3068 | // if the user is able to use Gravatar avatars show then the image preview |
2937 | 3069 | if (!empty($context['member']['avatar']['allow_gravatar'])) |
@@ -2940,16 +3072,17 @@ discard block |
||
2940 | 3072 | <div id="avatar_gravatar"> |
2941 | 3073 | <img src="' . $context['member']['avatar']['href'] . '" alt="">'; |
2942 | 3074 | |
2943 | - if (empty($modSettings['gravatarAllowExtraEmail'])) |
|
2944 | - echo ' |
|
3075 | + if (empty($modSettings['gravatarAllowExtraEmail'])) { |
|
3076 | + echo ' |
|
2945 | 3077 | <div class="smalltext">', $txt['gravatar_noAlternateEmail'], '</div>'; |
2946 | - else |
|
3078 | + } else |
|
2947 | 3079 | { |
2948 | 3080 | // Depending on other stuff, the stored value here might have some odd things in it from other areas. |
2949 | - if ($context['member']['avatar']['external'] == $context['member']['email']) |
|
2950 | - $textbox_value = ''; |
|
2951 | - else |
|
2952 | - $textbox_value = $context['member']['avatar']['external']; |
|
3081 | + if ($context['member']['avatar']['external'] == $context['member']['email']) { |
|
3082 | + $textbox_value = ''; |
|
3083 | + } else { |
|
3084 | + $textbox_value = $context['member']['avatar']['external']; |
|
3085 | + } |
|
2953 | 3086 | |
2954 | 3087 | echo ' |
2955 | 3088 | <div class="smalltext">', $txt['gravatar_alternateEmail'], '</div> |
@@ -3021,8 +3154,9 @@ discard block |
||
3021 | 3154 | $h = !empty($modSettings['avatar_max_height_' . $type]) ? comma_format($modSettings['avatar_max_height_' . $type]) : 0; |
3022 | 3155 | |
3023 | 3156 | $suffix = (!empty($w) ? 'w' : '') . (!empty($h) ? 'h' : ''); |
3024 | - if (empty($suffix)) |
|
3025 | - return; |
|
3157 | + if (empty($suffix)) { |
|
3158 | + return; |
|
3159 | + } |
|
3026 | 3160 | |
3027 | 3161 | echo ' |
3028 | 3162 | <div class="smalltext">', sprintf($txt['avatar_max_size_' . $suffix], $w, $h), '</div>'; |
@@ -3047,9 +3181,10 @@ discard block |
||
3047 | 3181 | <select name="easyformat" id="easyformat" onchange="document.forms.creator.time_format.value = this.options[this.selectedIndex].value;">'; |
3048 | 3182 | |
3049 | 3183 | // Help the user by showing a list of common time formats. |
3050 | - foreach ($context['easy_timeformats'] as $time_format) |
|
3051 | - echo ' |
|
3184 | + foreach ($context['easy_timeformats'] as $time_format) { |
|
3185 | + echo ' |
|
3052 | 3186 | <option value="', $time_format['format'], '"', $time_format['format'] == $context['member']['time_format'] ? ' selected' : '', '>', $time_format['title'], '</option>'; |
3187 | + } |
|
3053 | 3188 | |
3054 | 3189 | echo ' |
3055 | 3190 | </select> |
@@ -3087,9 +3222,10 @@ discard block |
||
3087 | 3222 | <dd> |
3088 | 3223 | <select name="smiley_set" id="smiley_set">'; |
3089 | 3224 | |
3090 | - foreach ($context['smiley_sets'] as $set) |
|
3091 | - echo ' |
|
3225 | + foreach ($context['smiley_sets'] as $set) { |
|
3226 | + echo ' |
|
3092 | 3227 | <option value="', $set['id'], '"', $set['selected'] ? ' selected' : '', '>', $set['name'], '</option>'; |
3228 | + } |
|
3093 | 3229 | |
3094 | 3230 | echo ' |
3095 | 3231 | </select> |
@@ -3111,17 +3247,17 @@ discard block |
||
3111 | 3247 | <div class="roundframe"> |
3112 | 3248 | <div>'; |
3113 | 3249 | |
3114 | - if (!empty($context['tfa_backup'])) |
|
3115 | - echo ' |
|
3250 | + if (!empty($context['tfa_backup'])) { |
|
3251 | + echo ' |
|
3116 | 3252 | <div class="smalltext error"> |
3117 | 3253 | ', $txt['tfa_backup_used_desc'], ' |
3118 | 3254 | </div>'; |
3119 | - |
|
3120 | - elseif ($modSettings['tfa_mode'] == 2) |
|
3121 | - echo ' |
|
3255 | + } elseif ($modSettings['tfa_mode'] == 2) { |
|
3256 | + echo ' |
|
3122 | 3257 | <div class="smalltext"> |
3123 | 3258 | <strong>', $txt['tfa_forced_desc'], '</strong> |
3124 | 3259 | </div>'; |
3260 | + } |
|
3125 | 3261 | |
3126 | 3262 | echo ' |
3127 | 3263 | <div class="smalltext"> |
@@ -3132,11 +3268,12 @@ discard block |
||
3132 | 3268 | <div class="block"> |
3133 | 3269 | <strong>', $txt['tfa_step1'], '</strong><br>'; |
3134 | 3270 | |
3135 | - if (!empty($context['tfa_pass_error'])) |
|
3136 | - echo ' |
|
3271 | + if (!empty($context['tfa_pass_error'])) { |
|
3272 | + echo ' |
|
3137 | 3273 | <div class="error smalltext"> |
3138 | 3274 | ', $txt['tfa_pass_invalid'], ' |
3139 | 3275 | </div>'; |
3276 | + } |
|
3140 | 3277 | |
3141 | 3278 | echo ' |
3142 | 3279 | <input type="password" name="passwd" size="25"', !empty($context['tfa_pass_error']) ? ' class="error"' : '', !empty($context['tfa_pass_value']) ? ' value="' . $context['tfa_pass_value'] . '"' : '', '> |
@@ -3149,11 +3286,12 @@ discard block |
||
3149 | 3286 | <div class="block"> |
3150 | 3287 | <strong>', $txt['tfa_step3'], '</strong><br>'; |
3151 | 3288 | |
3152 | - if (!empty($context['tfa_error'])) |
|
3153 | - echo ' |
|
3289 | + if (!empty($context['tfa_error'])) { |
|
3290 | + echo ' |
|
3154 | 3291 | <div class="error smalltext"> |
3155 | 3292 | ', $txt['tfa_code_invalid'], ' |
3156 | 3293 | </div>'; |
3294 | + } |
|
3157 | 3295 | |
3158 | 3296 | echo ' |
3159 | 3297 | <input type="text" name="tfa_code" size="25"', !empty($context['tfa_error']) ? ' class="error"' : '', !empty($context['tfa_value']) ? ' value="' . $context['tfa_value'] . '"' : '', '> |
@@ -3167,10 +3305,11 @@ discard block |
||
3167 | 3305 | <img src="', $context['tfa_qr_url'], '" alt=""> |
3168 | 3306 | </div>'; |
3169 | 3307 | |
3170 | - if (!empty($context['from_ajax'])) |
|
3171 | - echo ' |
|
3308 | + if (!empty($context['from_ajax'])) { |
|
3309 | + echo ' |
|
3172 | 3310 | <br> |
3173 | 3311 | <a href="javascript:self.close();"></a>'; |
3312 | + } |
|
3174 | 3313 | |
3175 | 3314 | echo ' |
3176 | 3315 | </div> |
@@ -3210,17 +3349,16 @@ discard block |
||
3210 | 3349 | </dt> |
3211 | 3350 | <dd>'; |
3212 | 3351 | |
3213 | - if (!$context['tfa_enabled'] && $context['user']['is_owner']) |
|
3214 | - echo ' |
|
3352 | + if (!$context['tfa_enabled'] && $context['user']['is_owner']) { |
|
3353 | + echo ' |
|
3215 | 3354 | <a href="', !empty($modSettings['force_ssl']) ? strtr($scripturl, array('http://' => 'https://')) : $scripturl, '?action=profile;area=tfasetup" id="enable_tfa">', $txt['tfa_profile_enable'], '</a>'; |
3216 | - |
|
3217 | - elseif (!$context['tfa_enabled']) |
|
3218 | - echo ' |
|
3355 | + } elseif (!$context['tfa_enabled']) { |
|
3356 | + echo ' |
|
3219 | 3357 | ', $txt['tfa_profile_disabled']; |
3220 | - |
|
3221 | - else |
|
3222 | - echo ' |
|
3358 | + } else { |
|
3359 | + echo ' |
|
3223 | 3360 | ', sprintf($txt['tfa_profile_enabled'], $scripturl . '?action=profile;u=' . $context['id_member'] . ';area=tfasetup;disable'); |
3361 | + } |
|
3224 | 3362 | |
3225 | 3363 | echo ' |
3226 | 3364 | </dd>'; |
@@ -62,16 +62,17 @@ |
||
62 | 62 | <div id="error_box" class="errorbox"> |
63 | 63 | <ul id="error_list">'; |
64 | 64 | |
65 | - foreach ($context['post_errors'] as $key => $error) |
|
66 | - echo ' |
|
65 | + foreach ($context['post_errors'] as $key => $error) { |
|
66 | + echo ' |
|
67 | 67 | <li id="error_', $key, '" class="error">', $error, '</li>'; |
68 | + } |
|
68 | 69 | |
69 | 70 | echo ' |
70 | 71 | </ul>'; |
71 | - } |
|
72 | - else |
|
73 | - echo ' |
|
72 | + } else { |
|
73 | + echo ' |
|
74 | 74 | <div id="error_box" class="errorbox hidden">'; |
75 | + } |
|
75 | 76 | |
76 | 77 | echo ' |
77 | 78 | </div>'; |
@@ -30,25 +30,27 @@ discard block |
||
30 | 30 | </div> |
31 | 31 | <div class="information">'; |
32 | 32 | |
33 | - if ($context['is_installed']) |
|
34 | - echo ' |
|
33 | + if ($context['is_installed']) { |
|
34 | + echo ' |
|
35 | 35 | <strong>', $txt['package_installed_warning1'], '</strong><br> |
36 | 36 | <br> |
37 | 37 | ', $txt['package_installed_warning2'], '<br> |
38 | 38 | <br>'; |
39 | + } |
|
39 | 40 | |
40 | 41 | echo $txt['package_installed_warning3'], ' |
41 | 42 | </div> |
42 | 43 | <br>'; |
43 | 44 | |
44 | 45 | // Do errors exist in the install? If so light them up like a christmas tree. |
45 | - if ($context['has_failure']) |
|
46 | - echo ' |
|
46 | + if ($context['has_failure']) { |
|
47 | + echo ' |
|
47 | 48 | <div class="errorbox"> |
48 | 49 | ', sprintf($txt['package_will_fail_title'], $txt['package_' . ($context['uninstalling'] ? 'uninstall' : 'install')]), '<br> |
49 | 50 | ', sprintf($txt['package_will_fail_warning'], $txt['package_' . ($context['uninstalling'] ? 'uninstall' : 'install')]), |
50 | 51 | !empty($context['failure_details']) ? '<br><br><strong>' . $context['failure_details'] . '</strong>' : '', ' |
51 | 52 | </div>'; |
53 | + } |
|
52 | 54 | |
53 | 55 | // Display the package readme if one exists |
54 | 56 | if (isset($context['package_readme'])) |
@@ -62,9 +64,10 @@ discard block |
||
62 | 64 | <span class="floatright">', $txt['package_available_readme_language'], ' |
63 | 65 | <select name="readme_language" id="readme_language" onchange="if (this.options[this.selectedIndex].value) window.location.href = smf_prepareScriptUrl(smf_scripturl + \'', '?action=admin;area=packages;sa=', $context['uninstalling'] ? 'uninstall' : 'install', ';package=', $context['filename'], ';readme=\' + this.options[this.selectedIndex].value + \';license=\' + get_selected(\'license_language\'));">'; |
64 | 66 | |
65 | - foreach ($context['readmes'] as $a => $b) |
|
66 | - echo ' |
|
67 | + foreach ($context['readmes'] as $a => $b) { |
|
68 | + echo ' |
|
67 | 69 | <option value="', $b, '"', $a === 'selected' ? ' selected' : '', '>', $b == 'default' ? $txt['package_readme_default'] : ucfirst($b), '</option>'; |
70 | + } |
|
68 | 71 | |
69 | 72 | echo ' |
70 | 73 | </select> |
@@ -85,9 +88,10 @@ discard block |
||
85 | 88 | <span class="floatright">', $txt['package_available_license_language'], ' |
86 | 89 | <select name="license_language" id="license_language" onchange="if (this.options[this.selectedIndex].value) window.location.href = smf_prepareScriptUrl(smf_scripturl + \'', '?action=admin;area=packages;sa=install', ';package=', $context['filename'], ';license=\' + this.options[this.selectedIndex].value + \';readme=\' + get_selected(\'readme_language\'));">'; |
87 | 90 | |
88 | - foreach ($context['licenses'] as $a => $b) |
|
89 | - echo ' |
|
91 | + foreach ($context['licenses'] as $a => $b) { |
|
92 | + echo ' |
|
90 | 93 | <option value="', $b, '"', $a === 'selected' ? ' selected' : '', '>', $b == 'default' ? $txt['package_license_default'] : ucfirst($b), '</option>'; |
94 | + } |
|
91 | 95 | echo ' |
92 | 96 | </select> |
93 | 97 | </span> |
@@ -114,9 +118,10 @@ discard block |
||
114 | 118 | ', $txt['package_db_uninstall_actions'], ': |
115 | 119 | <ul>'; |
116 | 120 | |
117 | - foreach ($context['database_changes'] as $change) |
|
118 | - echo ' |
|
121 | + foreach ($context['database_changes'] as $change) { |
|
122 | + echo ' |
|
119 | 123 | <li>', $change, '</li>'; |
124 | + } |
|
120 | 125 | |
121 | 126 | echo ' |
122 | 127 | </ul> |
@@ -127,14 +132,14 @@ discard block |
||
127 | 132 | echo ' |
128 | 133 | <div class="information">'; |
129 | 134 | |
130 | - if (empty($context['actions']) && empty($context['database_changes'])) |
|
131 | - echo ' |
|
135 | + if (empty($context['actions']) && empty($context['database_changes'])) { |
|
136 | + echo ' |
|
132 | 137 | <br> |
133 | 138 | <div class="errorbox"> |
134 | 139 | ', $txt['corrupt_compatible'], ' |
135 | 140 | </div> |
136 | 141 | </div><!-- .information -->'; |
137 | - else |
|
142 | + } else |
|
138 | 143 | { |
139 | 144 | echo ' |
140 | 145 | ', $txt['perform_actions'], ' |
@@ -238,9 +243,10 @@ discard block |
||
238 | 243 | <td></td> |
239 | 244 | <td>'; |
240 | 245 | |
241 | - if (!empty($context['themes_locked'])) |
|
242 | - echo ' |
|
246 | + if (!empty($context['themes_locked'])) { |
|
247 | + echo ' |
|
243 | 248 | <input type="hidden" name="custom_theme[]" value="', $id, '">'; |
249 | + } |
|
244 | 250 | echo ' |
245 | 251 | <input type="checkbox" name="custom_theme[]" id="custom_theme_', $id, '" value="', $id, '" onclick="', (!empty($theme['has_failure']) ? 'if (this.form.custom_theme_' . $id . '.checked && !confirm(\'' . $txt['package_theme_failure_warning'] . '\')) return false;' : ''), 'invertAll(this, this.form, \'dummy_theme_', $id, '\', true);"', !empty($context['themes_locked']) ? ' disabled checked' : '', '> |
246 | 252 | </td> |
@@ -306,21 +312,23 @@ discard block |
||
306 | 312 | } |
307 | 313 | |
308 | 314 | // Are we effectively ready to install? |
309 | - if (!$context['ftp_needed'] && (!empty($context['actions']) || !empty($context['database_changes']))) |
|
310 | - echo ' |
|
315 | + if (!$context['ftp_needed'] && (!empty($context['actions']) || !empty($context['database_changes']))) { |
|
316 | + echo ' |
|
311 | 317 | <div class="righttext padding"> |
312 | 318 | <input type="submit" value="', $context['uninstalling'] ? $txt['package_uninstall_now'] : $txt['package_install_now'], '" onclick="return ', !empty($context['has_failure']) ? '(submitThisOnce(this) && confirm(\'' . ($context['uninstalling'] ? $txt['package_will_fail_popup_uninstall'] : $txt['package_will_fail_popup']) . '\'))' : 'submitThisOnce(this)', ';" class="button"> |
313 | 319 | </div>'; |
320 | + } |
|
314 | 321 | |
315 | 322 | // If we need ftp information then demand it! |
316 | - elseif ($context['ftp_needed']) |
|
317 | - echo ' |
|
323 | + elseif ($context['ftp_needed']) { |
|
324 | + echo ' |
|
318 | 325 | <div class="cat_bar"> |
319 | 326 | <h3 class="catbg">', $txt['package_ftp_necessary'], '</h3> |
320 | 327 | </div> |
321 | 328 | <div> |
322 | 329 | ', template_control_chmod(), ' |
323 | 330 | </div>'; |
331 | + } |
|
324 | 332 | |
325 | 333 | echo ' |
326 | 334 | |
@@ -336,8 +344,8 @@ discard block |
||
336 | 344 | // Operations. |
337 | 345 | if (!empty($js_operations)) |
338 | 346 | { |
339 | - foreach ($js_operations as $key => $operation) |
|
340 | - echo ' |
|
347 | + foreach ($js_operations as $key => $operation) { |
|
348 | + echo ' |
|
341 | 349 | aOperationElements[', $key, '] = new smc_Toggle({ |
342 | 350 | bToggleEnabled: true, |
343 | 351 | bNoAnimate: true, |
@@ -355,6 +363,7 @@ discard block |
||
355 | 363 | } |
356 | 364 | ] |
357 | 365 | });'; |
366 | + } |
|
358 | 367 | } |
359 | 368 | |
360 | 369 | echo ' |
@@ -376,14 +385,15 @@ discard block |
||
376 | 385 | </script>'; |
377 | 386 | |
378 | 387 | // And a bit more for database changes. |
379 | - if (!empty($context['database_changes'])) |
|
380 | - echo ' |
|
388 | + if (!empty($context['database_changes'])) { |
|
389 | + echo ' |
|
381 | 390 | <script> |
382 | 391 | var database_changes_area = document.getElementById(\'db_changes_div\'); |
383 | 392 | var db_vis = false; |
384 | 393 | database_changes_area.classList.add(\'hidden\'); |
385 | 394 | </script>'; |
386 | -} |
|
395 | + } |
|
396 | + } |
|
387 | 397 | |
388 | 398 | /** |
389 | 399 | * Extract package contents |
@@ -392,8 +402,8 @@ discard block |
||
392 | 402 | { |
393 | 403 | global $context, $txt, $scripturl; |
394 | 404 | |
395 | - if (!empty($context['redirect_url'])) |
|
396 | - echo ' |
|
405 | + if (!empty($context['redirect_url'])) { |
|
406 | + echo ' |
|
397 | 407 | <script> |
398 | 408 | setTimeout("doRedirect();", ', empty($context['redirect_timeout']) ? '5000' : $context['redirect_timeout'], '); |
399 | 409 | |
@@ -402,49 +412,48 @@ discard block |
||
402 | 412 | window.location = "', $context['redirect_url'], '"; |
403 | 413 | } |
404 | 414 | </script>'; |
415 | + } |
|
405 | 416 | |
406 | - if (empty($context['redirect_url'])) |
|
407 | - echo ' |
|
417 | + if (empty($context['redirect_url'])) { |
|
418 | + echo ' |
|
408 | 419 | <div class="cat_bar"> |
409 | 420 | <h3 class="catbg">', $context['uninstalling'] ? $txt['uninstall'] : $txt['extracting'], '</h3> |
410 | 421 | </div> |
411 | 422 | <div class="information">', $txt['package_installed_extract'], '</div>'; |
412 | - else |
|
413 | - echo ' |
|
423 | + } else { |
|
424 | + echo ' |
|
414 | 425 | <div class="cat_bar"> |
415 | 426 | <h3 class="catbg">', $txt['package_installed_redirecting'], '</h3> |
416 | 427 | </div>'; |
428 | + } |
|
417 | 429 | |
418 | 430 | echo ' |
419 | 431 | <div class="windowbg">'; |
420 | 432 | |
421 | 433 | // If we are going to redirect we have a slightly different agenda. |
422 | - if (!empty($context['redirect_url'])) |
|
423 | - echo ' |
|
434 | + if (!empty($context['redirect_url'])) { |
|
435 | + echo ' |
|
424 | 436 | ', $context['redirect_text'], '<br><br> |
425 | 437 | <a href="', $context['redirect_url'], '">', $txt['package_installed_redirect_go_now'], '</a> | <a href="', $scripturl, '?action=admin;area=packages;sa=browse">', $txt['package_installed_redirect_cancel'], '</a>'; |
426 | - |
|
427 | - elseif ($context['uninstalling']) |
|
428 | - echo ' |
|
438 | + } elseif ($context['uninstalling']) { |
|
439 | + echo ' |
|
429 | 440 | ', $txt['package_uninstall_done']; |
430 | - |
|
431 | - elseif ($context['install_finished']) |
|
441 | + } elseif ($context['install_finished']) |
|
432 | 442 | { |
433 | - if ($context['extract_type'] == 'avatar') |
|
434 | - echo ' |
|
443 | + if ($context['extract_type'] == 'avatar') { |
|
444 | + echo ' |
|
435 | 445 | ', $txt['avatars_extracted']; |
436 | - |
|
437 | - elseif ($context['extract_type'] == 'language') |
|
438 | - echo ' |
|
446 | + } elseif ($context['extract_type'] == 'language') { |
|
447 | + echo ' |
|
439 | 448 | ', $txt['language_extracted']; |
440 | - |
|
441 | - else |
|
442 | - echo ' |
|
449 | + } else { |
|
450 | + echo ' |
|
443 | 451 | ', $txt['package_installed_done']; |
444 | - } |
|
445 | - else |
|
446 | - echo ' |
|
452 | + } |
|
453 | + } else { |
|
454 | + echo ' |
|
447 | 455 | ', $txt['corrupt_compatible']; |
456 | + } |
|
448 | 457 | |
449 | 458 | echo ' |
450 | 459 | </div><!-- .windowbg -->'; |
@@ -474,9 +483,10 @@ discard block |
||
474 | 483 | <div class="windowbg"> |
475 | 484 | <ol>'; |
476 | 485 | |
477 | - foreach ($context['files'] as $fileinfo) |
|
478 | - echo ' |
|
486 | + foreach ($context['files'] as $fileinfo) { |
|
487 | + echo ' |
|
479 | 488 | <li><a href="', $scripturl, '?action=admin;area=packages;sa=examine;package=', $context['filename'], ';file=', $fileinfo['filename'], '" title="', $txt['view'], '">', $fileinfo['filename'], '</a> (', $fileinfo['size'], ' ', $txt['package_bytes'], ')</li>'; |
489 | + } |
|
480 | 490 | |
481 | 491 | echo ' |
482 | 492 | </ol> |
@@ -536,9 +546,10 @@ discard block |
||
536 | 546 | </script> |
537 | 547 | <div id="yourVersion" style="display:none">', $context['forum_version'], '</div>'; |
538 | 548 | |
539 | - if (empty($modSettings['disable_smf_js'])) |
|
540 | - echo ' |
|
549 | + if (empty($modSettings['disable_smf_js'])) { |
|
550 | + echo ' |
|
541 | 551 | <script src="', $scripturl, '?action=viewsmfile;filename=latest-news.js"></script>'; |
552 | + } |
|
542 | 553 | |
543 | 554 | // This sets the announcements and current versions themselves ;). |
544 | 555 | echo ' |
@@ -576,12 +587,13 @@ discard block |
||
576 | 587 | } |
577 | 588 | } |
578 | 589 | |
579 | - if (!$mods_available) |
|
580 | - echo ' |
|
590 | + if (!$mods_available) { |
|
591 | + echo ' |
|
581 | 592 | <div class="noticebox">', $txt['no_packages'], '</div>'; |
582 | - else |
|
583 | - echo ' |
|
593 | + } else { |
|
594 | + echo ' |
|
584 | 595 | <br>'; |
596 | + } |
|
585 | 597 | |
586 | 598 | // The advanced (emulation) box, collapsed by default |
587 | 599 | echo ' |
@@ -608,9 +620,10 @@ discard block |
||
608 | 620 | <a id="revert" name="revert"></a> |
609 | 621 | <select name="version_emulate" id="ve">'; |
610 | 622 | |
611 | - foreach ($context['emulation_versions'] as $version) |
|
612 | - echo ' |
|
623 | + foreach ($context['emulation_versions'] as $version) { |
|
624 | + echo ' |
|
613 | 625 | <option value="', $version, '"', ($version == $context['selected_version'] ? ' selected="selected"' : ''), '>', $version, '</option>'; |
626 | + } |
|
614 | 627 | |
615 | 628 | echo ' |
616 | 629 | </select> |
@@ -665,11 +678,12 @@ discard block |
||
665 | 678 | { |
666 | 679 | global $context, $txt, $scripturl; |
667 | 680 | |
668 | - if (!empty($context['package_ftp']['error'])) |
|
669 | - echo ' |
|
681 | + if (!empty($context['package_ftp']['error'])) { |
|
682 | + echo ' |
|
670 | 683 | <div class="errorbox"> |
671 | 684 | <pre>', $context['package_ftp']['error'], '</pre> |
672 | 685 | </div>'; |
686 | + } |
|
673 | 687 | |
674 | 688 | echo ' |
675 | 689 | <div id="admin_form_wrapper"> |
@@ -752,13 +766,14 @@ discard block |
||
752 | 766 | <legend>' . $txt['package_servers'] . '</legend> |
753 | 767 | <ul class="package_servers">'; |
754 | 768 | |
755 | - foreach ($context['servers'] as $server) |
|
756 | - echo ' |
|
769 | + foreach ($context['servers'] as $server) { |
|
770 | + echo ' |
|
757 | 771 | <li class="flow_auto"> |
758 | 772 | <span class="floatleft">' . $server['name'] . '</span> |
759 | 773 | <span class="package_server floatright"><a href="' . $scripturl . '?action=admin;area=packages;get;sa=remove;server=' . $server['id'] . ';', $context['session_var'], '=', $context['session_id'], '">[ ' . $txt['delete'] . ' ]</a></span> |
760 | 774 | <span class="package_server floatright"><a href="' . $scripturl . '?action=admin;area=packages;get;sa=browse;server=' . $server['id'] . '">[ ' . $txt['package_browse'] . ' ]</a></span> |
761 | 775 | </li>'; |
776 | + } |
|
762 | 777 | echo ' |
763 | 778 | </ul> |
764 | 779 | </fieldset> |
@@ -842,11 +857,12 @@ discard block |
||
842 | 857 | <div class="windowbg">'; |
843 | 858 | |
844 | 859 | // No packages, as yet. |
845 | - if (empty($context['package_list'])) |
|
846 | - echo ' |
|
860 | + if (empty($context['package_list'])) { |
|
861 | + echo ' |
|
847 | 862 | <ul> |
848 | 863 | <li>', $txt['no_packages'], '</li> |
849 | 864 | </ul>'; |
865 | + } |
|
850 | 866 | |
851 | 867 | // List out the packages... |
852 | 868 | else |
@@ -860,11 +876,12 @@ discard block |
||
860 | 876 | <li> |
861 | 877 | <strong><span id="ps_img_', $i, '" class="toggle_up" alt="*" style="display: none;"></span> ', $packageSection['title'], '</strong>'; |
862 | 878 | |
863 | - if (!empty($packageSection['text'])) |
|
864 | - echo ' |
|
879 | + if (!empty($packageSection['text'])) { |
|
880 | + echo ' |
|
865 | 881 | <div class="sub_bar"> |
866 | 882 | <h3 class="subbg">', $packageSection['text'], '</h3> |
867 | 883 | </div>'; |
884 | + } |
|
868 | 885 | |
869 | 886 | echo ' |
870 | 887 | <', $context['list_type'], ' id="package_section_', $i, '" class="packages">'; |
@@ -875,24 +892,28 @@ discard block |
||
875 | 892 | <li>'; |
876 | 893 | |
877 | 894 | // Textual message. Could be empty just for a blank line... |
878 | - if ($package['is_text']) |
|
879 | - echo ' |
|
895 | + if ($package['is_text']) { |
|
896 | + echo ' |
|
880 | 897 | ', empty($package['name']) ? ' ' : $package['name']; |
898 | + } |
|
881 | 899 | |
882 | 900 | // This is supposed to be a rule.. |
883 | - elseif ($package['is_line']) |
|
884 | - echo ' |
|
901 | + elseif ($package['is_line']) { |
|
902 | + echo ' |
|
885 | 903 | <hr>'; |
904 | + } |
|
886 | 905 | |
887 | 906 | // A remote link. |
888 | - elseif ($package['is_remote']) |
|
889 | - echo ' |
|
907 | + elseif ($package['is_remote']) { |
|
908 | + echo ' |
|
890 | 909 | <strong>', $package['link'], '</strong>'; |
910 | + } |
|
891 | 911 | |
892 | 912 | // A title? |
893 | - elseif ($package['is_heading'] || $package['is_title']) |
|
894 | - echo ' |
|
913 | + elseif ($package['is_heading'] || $package['is_title']) { |
|
914 | + echo ' |
|
895 | 915 | <strong>', $package['name'], '</strong>'; |
916 | + } |
|
896 | 917 | |
897 | 918 | // Otherwise, it's a package. |
898 | 919 | else |
@@ -903,32 +924,36 @@ discard block |
||
903 | 924 | <ul id="package_section_', $i, '_pkg_', $id, '" class="package_section">'; |
904 | 925 | |
905 | 926 | // Show the mod type? |
906 | - if ($package['type'] != '') |
|
907 | - echo ' |
|
927 | + if ($package['type'] != '') { |
|
928 | + echo ' |
|
908 | 929 | <li class="package_section"> |
909 | 930 | ', $txt['package_type'], ': ', $smcFunc['ucwords']($smcFunc['strtolower']($package['type'])), ' |
910 | 931 | </li>'; |
932 | + } |
|
911 | 933 | |
912 | 934 | // Show the version number? |
913 | - if ($package['version'] != '') |
|
914 | - echo ' |
|
935 | + if ($package['version'] != '') { |
|
936 | + echo ' |
|
915 | 937 | <li class="package_section"> |
916 | 938 | ', $txt['mod_version'], ': ', $package['version'], ' |
917 | 939 | </li>'; |
940 | + } |
|
918 | 941 | |
919 | 942 | // How 'bout the author? |
920 | - if (!empty($package['author']) && $package['author']['name'] != '' && isset($package['author']['link'])) |
|
921 | - echo ' |
|
943 | + if (!empty($package['author']) && $package['author']['name'] != '' && isset($package['author']['link'])) { |
|
944 | + echo ' |
|
922 | 945 | <li class="package_section"> |
923 | 946 | ', $txt['mod_author'], ': ', $package['author']['link'], ' |
924 | 947 | </li>'; |
948 | + } |
|
925 | 949 | |
926 | 950 | // The homepage... |
927 | - if ($package['author']['website']['link'] != '') |
|
928 | - echo ' |
|
951 | + if ($package['author']['website']['link'] != '') { |
|
952 | + echo ' |
|
929 | 953 | <li class="package_section"> |
930 | 954 | ', $txt['author_website'], ': ', $package['author']['website']['link'], ' |
931 | 955 | </li>'; |
956 | + } |
|
932 | 957 | |
933 | 958 | // Description: bleh bleh! |
934 | 959 | // Location of file: http://someplace/. |
@@ -986,8 +1011,8 @@ discard block |
||
986 | 1011 | |
987 | 1012 | foreach ($ps['items'] as $id => $package) |
988 | 1013 | { |
989 | - if (!$package['is_text'] && !$package['is_line'] && !$package['is_remote']) |
|
990 | - echo ' |
|
1014 | + if (!$package['is_text'] && !$package['is_line'] && !$package['is_remote']) { |
|
1015 | + echo ' |
|
991 | 1016 | var oPackageToggle_', $section, '_pkg_', $id, ' = new smc_Toggle({ |
992 | 1017 | bToggleEnabled: true, |
993 | 1018 | bCurrentlyCollapsed: true, |
@@ -1002,6 +1027,7 @@ discard block |
||
1002 | 1027 | } |
1003 | 1028 | ] |
1004 | 1029 | });'; |
1030 | + } |
|
1005 | 1031 | } |
1006 | 1032 | } |
1007 | 1033 | |
@@ -1044,9 +1070,10 @@ discard block |
||
1044 | 1070 | { |
1045 | 1071 | global $context, $txt, $scripturl; |
1046 | 1072 | |
1047 | - if (!empty($context['saved_successful'])) |
|
1048 | - echo ' |
|
1073 | + if (!empty($context['saved_successful'])) { |
|
1074 | + echo ' |
|
1049 | 1075 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
1076 | + } |
|
1050 | 1077 | |
1051 | 1078 | echo ' |
1052 | 1079 | <div class="cat_bar"> |
@@ -1106,8 +1133,9 @@ discard block |
||
1106 | 1133 | global $context, $txt; |
1107 | 1134 | |
1108 | 1135 | // Nothing to do? Brilliant! |
1109 | - if (empty($context['package_ftp'])) |
|
1110 | - return false; |
|
1136 | + if (empty($context['package_ftp'])) { |
|
1137 | + return false; |
|
1138 | + } |
|
1111 | 1139 | |
1112 | 1140 | if (empty($context['package_ftp']['form_elements_only'])) |
1113 | 1141 | { |
@@ -1117,19 +1145,21 @@ discard block |
||
1117 | 1145 | ', $txt['package_ftp_why_file_list'], ' |
1118 | 1146 | <ul style="display: inline;">'; |
1119 | 1147 | |
1120 | - if (!empty($context['notwritable_files'])) |
|
1121 | - foreach ($context['notwritable_files'] as $file) |
|
1148 | + if (!empty($context['notwritable_files'])) { |
|
1149 | + foreach ($context['notwritable_files'] as $file) |
|
1122 | 1150 | echo ' |
1123 | 1151 | <li>', $file, '</li>'; |
1152 | + } |
|
1124 | 1153 | |
1125 | 1154 | echo ' |
1126 | 1155 | </ul>'; |
1127 | 1156 | |
1128 | - if (!$context['server']['is_windows']) |
|
1129 | - echo ' |
|
1157 | + if (!$context['server']['is_windows']) { |
|
1158 | + echo ' |
|
1130 | 1159 | <hr> |
1131 | 1160 | ', $txt['package_chmod_linux'], '<br> |
1132 | 1161 | <samp># chmod a+w ', implode(' ', $context['notwritable_files']), '</samp>'; |
1162 | + } |
|
1133 | 1163 | |
1134 | 1164 | echo ' |
1135 | 1165 | </div><!-- #need_writable_list -->'; |
@@ -1142,9 +1172,10 @@ discard block |
||
1142 | 1172 | </div> |
1143 | 1173 | </div>'; |
1144 | 1174 | |
1145 | - if (!empty($context['package_ftp']['destination'])) |
|
1146 | - echo ' |
|
1175 | + if (!empty($context['package_ftp']['destination'])) { |
|
1176 | + echo ' |
|
1147 | 1177 | <form action="', $context['package_ftp']['destination'], '" method="post" accept-charset="', $context['character_set'], '">'; |
1178 | + } |
|
1148 | 1179 | |
1149 | 1180 | echo ' |
1150 | 1181 | <fieldset> |
@@ -1178,24 +1209,27 @@ discard block |
||
1178 | 1209 | </dl> |
1179 | 1210 | </fieldset>'; |
1180 | 1211 | |
1181 | - if (empty($context['package_ftp']['form_elements_only'])) |
|
1182 | - echo ' |
|
1212 | + if (empty($context['package_ftp']['form_elements_only'])) { |
|
1213 | + echo ' |
|
1183 | 1214 | <div class="righttext" style="margin: 1ex;"> |
1184 | 1215 | <span id="test_ftp_placeholder_full"></span> |
1185 | 1216 | <input type="submit" value="', $txt['package_proceed'], '" class="button"> |
1186 | 1217 | </div>'; |
1218 | + } |
|
1187 | 1219 | |
1188 | - if (!empty($context['package_ftp']['destination'])) |
|
1189 | - echo ' |
|
1220 | + if (!empty($context['package_ftp']['destination'])) { |
|
1221 | + echo ' |
|
1190 | 1222 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
1191 | 1223 | </form>'; |
1224 | + } |
|
1192 | 1225 | |
1193 | 1226 | // Hide the details of the list. |
1194 | - if (empty($context['package_ftp']['form_elements_only'])) |
|
1195 | - echo ' |
|
1227 | + if (empty($context['package_ftp']['form_elements_only'])) { |
|
1228 | + echo ' |
|
1196 | 1229 | <script> |
1197 | 1230 | document.getElementById(\'need_writable_list\').style.display = \'none\'; |
1198 | 1231 | </script>'; |
1232 | + } |
|
1199 | 1233 | |
1200 | 1234 | // Quick generate the test button. |
1201 | 1235 | echo ' |
@@ -1552,9 +1586,10 @@ discard block |
||
1552 | 1586 | <td width="30%"> |
1553 | 1587 | <strong>'; |
1554 | 1588 | |
1555 | - if (!empty($dir['type']) && ($dir['type'] == 'dir' || $dir['type'] == 'dir_recursive')) |
|
1556 | - echo ' |
|
1589 | + if (!empty($dir['type']) && ($dir['type'] == 'dir' || $dir['type'] == 'dir_recursive')) { |
|
1590 | + echo ' |
|
1557 | 1591 | <span class="generic_icons folder"></span>'; |
1592 | + } |
|
1558 | 1593 | |
1559 | 1594 | echo ' |
1560 | 1595 | ', $name, ' |
@@ -1581,8 +1616,9 @@ discard block |
||
1581 | 1616 | </td> |
1582 | 1617 | </tr>'; |
1583 | 1618 | |
1584 | - if (!empty($dir['contents'])) |
|
1585 | - template_permission_show_contents($name, $dir['contents'], 1); |
|
1619 | + if (!empty($dir['contents'])) { |
|
1620 | + template_permission_show_contents($name, $dir['contents'], 1); |
|
1621 | + } |
|
1586 | 1622 | } |
1587 | 1623 | |
1588 | 1624 | echo ' |
@@ -1618,13 +1654,14 @@ discard block |
||
1618 | 1654 | </fieldset>'; |
1619 | 1655 | |
1620 | 1656 | // Likely to need FTP? |
1621 | - if (empty($context['ftp_connected'])) |
|
1622 | - echo ' |
|
1657 | + if (empty($context['ftp_connected'])) { |
|
1658 | + echo ' |
|
1623 | 1659 | <p> |
1624 | 1660 | ', $txt['package_file_perms_ftp_details'], ': |
1625 | 1661 | </p> |
1626 | 1662 | ', template_control_chmod(), ' |
1627 | 1663 | <div class="noticebox">', $txt['package_file_perms_ftp_retain'], '</div>'; |
1664 | + } |
|
1628 | 1665 | |
1629 | 1666 | echo ' |
1630 | 1667 | <span id="test_ftp_placeholder_full"></span> |
@@ -1633,9 +1670,10 @@ discard block |
||
1633 | 1670 | </div><!-- .windowbg -->'; |
1634 | 1671 | |
1635 | 1672 | // Any looks fors we've already done? |
1636 | - foreach ($context['look_for'] as $path) |
|
1637 | - echo ' |
|
1673 | + foreach ($context['look_for'] as $path) { |
|
1674 | + echo ' |
|
1638 | 1675 | <input type="hidden" name="back_look[]" value="', $path, '">'; |
1676 | + } |
|
1639 | 1677 | |
1640 | 1678 | echo ' |
1641 | 1679 | </form> |
@@ -1677,9 +1715,10 @@ discard block |
||
1677 | 1715 | <td class="smalltext" width="30%">' . str_repeat(' ', $level * 5), ' |
1678 | 1716 | ', (!empty($dir['type']) && $dir['type'] == 'dir_recursive') || !empty($dir['list_contents']) ? '<a id="link_' . $cur_ident . '" href="' . $scripturl . '?action=admin;area=packages;sa=perms;find=' . base64_encode($ident . '/' . $name) . ';back_look=' . $context['back_look_data'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '#fol_' . $cur_ident . '" onclick="return expandFolder(\'' . $cur_ident . '\', \'' . addcslashes($ident . '/' . $name, "'\\") . '\');">' : ''; |
1679 | 1717 | |
1680 | - if (!empty($dir['type']) && ($dir['type'] == 'dir' || $dir['type'] == 'dir_recursive')) |
|
1681 | - echo ' |
|
1718 | + if (!empty($dir['type']) && ($dir['type'] == 'dir' || $dir['type'] == 'dir_recursive')) { |
|
1719 | + echo ' |
|
1682 | 1720 | <span class="generic_icons folder"></span>'; |
1721 | + } |
|
1683 | 1722 | |
1684 | 1723 | echo ' |
1685 | 1724 | ', $name, ' |
@@ -1697,34 +1736,38 @@ discard block |
||
1697 | 1736 | </tr> |
1698 | 1737 | <tr id="insert_div_loc_' . $cur_ident . '" style="display: none;"><td></td></tr>'; |
1699 | 1738 | |
1700 | - if (!empty($dir['contents'])) |
|
1701 | - template_permission_show_contents($ident . '/' . $name, $dir['contents'], $level + 1, !empty($dir['more_files'])); |
|
1739 | + if (!empty($dir['contents'])) { |
|
1740 | + template_permission_show_contents($ident . '/' . $name, $dir['contents'], $level + 1, !empty($dir['more_files'])); |
|
1741 | + } |
|
1702 | 1742 | } |
1703 | 1743 | } |
1704 | 1744 | |
1705 | 1745 | // We have more files to show? |
1706 | - if ($has_more) |
|
1707 | - echo ' |
|
1746 | + if ($has_more) { |
|
1747 | + echo ' |
|
1708 | 1748 | <tr class="windowbg" id="content_', $js_ident, '_more"> |
1709 | 1749 | <td class="smalltext" width="40%">' . str_repeat(' ', $level * 5), ' |
1710 | 1750 | « <a href="' . $scripturl . '?action=admin;area=packages;sa=perms;find=' . base64_encode($ident) . ';fileoffset=', ($context['file_offset'] + $context['file_limit']), ';' . $context['session_var'] . '=' . $context['session_id'] . '#fol_' . preg_replace('~[^A-Za-z0-9_\-=:]~', ':-:', $ident) . '">', $txt['package_file_perms_more_files'], '</a> » |
1711 | 1751 | </td> |
1712 | 1752 | <td colspan="6"></td> |
1713 | 1753 | </tr>'; |
1754 | + } |
|
1714 | 1755 | |
1715 | 1756 | if ($drawn_div) |
1716 | 1757 | { |
1717 | 1758 | // Hide anything too far down the tree. |
1718 | 1759 | $isFound = false; |
1719 | - foreach ($context['look_for'] as $tree) |
|
1720 | - if (substr($tree, 0, strlen($ident)) == $ident) |
|
1760 | + foreach ($context['look_for'] as $tree) { |
|
1761 | + if (substr($tree, 0, strlen($ident)) == $ident) |
|
1721 | 1762 | $isFound = true; |
1763 | + } |
|
1722 | 1764 | |
1723 | - if ($level > 1 && !$isFound) |
|
1724 | - echo ' |
|
1765 | + if ($level > 1 && !$isFound) { |
|
1766 | + echo ' |
|
1725 | 1767 | <script> |
1726 | 1768 | expandFolder(\'', $js_ident, '\', \'\'); |
1727 | 1769 | </script>'; |
1770 | + } |
|
1728 | 1771 | } |
1729 | 1772 | } |
1730 | 1773 | |
@@ -1743,11 +1786,12 @@ discard block |
||
1743 | 1786 | <h3 class="catbg">', $txt['package_file_perms_applying'], '</h3> |
1744 | 1787 | </div>'; |
1745 | 1788 | |
1746 | - if (!empty($context['skip_ftp'])) |
|
1747 | - echo ' |
|
1789 | + if (!empty($context['skip_ftp'])) { |
|
1790 | + echo ' |
|
1748 | 1791 | <div class="errorbox"> |
1749 | 1792 | ', $txt['package_file_perms_skipping_ftp'], ' |
1750 | 1793 | </div>'; |
1794 | + } |
|
1751 | 1795 | |
1752 | 1796 | // How many have we done? |
1753 | 1797 | $remaining_items = count($context['method'] == 'individual' ? $context['to_process'] : $context['directory_list']); |
@@ -1785,28 +1829,31 @@ discard block |
||
1785 | 1829 | <br>'; |
1786 | 1830 | |
1787 | 1831 | // Put out the right hidden data. |
1788 | - if ($context['method'] == 'individual') |
|
1789 | - echo ' |
|
1832 | + if ($context['method'] == 'individual') { |
|
1833 | + echo ' |
|
1790 | 1834 | <input type="hidden" name="custom_value" value="', $context['custom_value'], '"> |
1791 | 1835 | <input type="hidden" name="totalItems" value="', $context['total_items'], '"> |
1792 | 1836 | <input type="hidden" name="toProcess" value="', $context['to_process_encode'], '">'; |
1793 | - else |
|
1794 | - echo ' |
|
1837 | + } else { |
|
1838 | + echo ' |
|
1795 | 1839 | <input type="hidden" name="predefined" value="', $context['predefined_type'], '"> |
1796 | 1840 | <input type="hidden" name="fileOffset" value="', $context['file_offset'], '"> |
1797 | 1841 | <input type="hidden" name="totalItems" value="', $context['total_items'], '"> |
1798 | 1842 | <input type="hidden" name="dirList" value="', $context['directory_list_encode'], '"> |
1799 | 1843 | <input type="hidden" name="specialFiles" value="', $context['special_files_encode'], '">'; |
1844 | + } |
|
1800 | 1845 | |
1801 | 1846 | // Are we not using FTP for whatever reason. |
1802 | - if (!empty($context['skip_ftp'])) |
|
1803 | - echo ' |
|
1847 | + if (!empty($context['skip_ftp'])) { |
|
1848 | + echo ' |
|
1804 | 1849 | <input type="hidden" name="skip_ftp" value="1">'; |
1850 | + } |
|
1805 | 1851 | |
1806 | 1852 | // Retain state. |
1807 | - foreach ($context['back_look_data'] as $path) |
|
1808 | - echo ' |
|
1853 | + foreach ($context['back_look_data'] as $path) { |
|
1854 | + echo ' |
|
1809 | 1855 | <input type="hidden" name="back_look[]" value="', $path, '">'; |
1856 | + } |
|
1810 | 1857 | |
1811 | 1858 | echo ' |
1812 | 1859 | <input type="hidden" name="method" value="', $context['method'], '"> |
@@ -54,9 +54,10 @@ discard block |
||
54 | 54 | <legend>', $txt['membergroups_edit_select_group_type'], '</legend> |
55 | 55 | <label for="group_type_private"><input type="radio" name="group_type" id="group_type_private" value="0" checked onclick="swapPostGroup(0);">', $txt['membergroups_group_type_private'], '</label><br>'; |
56 | 56 | |
57 | - if ($context['allow_protected']) |
|
58 | - echo ' |
|
57 | + if ($context['allow_protected']) { |
|
58 | + echo ' |
|
59 | 59 | <label for="group_type_protected"><input type="radio" name="group_type" id="group_type_protected" value="1" onclick="swapPostGroup(0);">', $txt['membergroups_group_type_protected'], '</label><br>'; |
60 | + } |
|
60 | 61 | |
61 | 62 | echo ' |
62 | 63 | <label for="group_type_request"><input type="radio" name="group_type" id="group_type_request" value="2" onclick="swapPostGroup(0);">', $txt['membergroups_group_type_request'], '</label><br> |
@@ -66,14 +67,15 @@ discard block |
||
66 | 67 | </dd>'; |
67 | 68 | } |
68 | 69 | |
69 | - if ($context['post_group'] || $context['undefined_group']) |
|
70 | - echo ' |
|
70 | + if ($context['post_group'] || $context['undefined_group']) { |
|
71 | + echo ' |
|
71 | 72 | <dt id="min_posts_text"> |
72 | 73 | <strong>', $txt['membergroups_min_posts'], ':</strong> |
73 | 74 | </dt> |
74 | 75 | <dd> |
75 | 76 | <input type="number" name="min_posts" id="min_posts_input" size="5"> |
76 | 77 | </dd>'; |
78 | + } |
|
77 | 79 | |
78 | 80 | if (!$context['post_group'] || !empty($modSettings['permission_enable_postgroups'])) |
79 | 81 | { |
@@ -91,9 +93,10 @@ discard block |
||
91 | 93 | <option value="-1">', $txt['membergroups_guests'], '</option> |
92 | 94 | <option value="0" selected>', $txt['membergroups_members'], '</option>'; |
93 | 95 | |
94 | - foreach ($context['groups'] as $group) |
|
95 | - echo ' |
|
96 | + foreach ($context['groups'] as $group) { |
|
97 | + echo ' |
|
96 | 98 | <option value="', $group['id'], '">', $group['name'], '</option>'; |
99 | + } |
|
97 | 100 | |
98 | 101 | echo ' |
99 | 102 | </select> |
@@ -104,9 +107,10 @@ discard block |
||
104 | 107 | <option value="-1">', $txt['membergroups_guests'], '</option> |
105 | 108 | <option value="0" selected>', $txt['membergroups_members'], '</option>'; |
106 | 109 | |
107 | - foreach ($context['groups'] as $group) |
|
108 | - echo ' |
|
110 | + foreach ($context['groups'] as $group) { |
|
111 | + echo ' |
|
109 | 112 | <option value="', $group['id'], '">', $group['name'], '</option>'; |
113 | + } |
|
110 | 114 | |
111 | 115 | echo ' |
112 | 116 | </select> |
@@ -138,8 +142,8 @@ discard block |
||
138 | 142 | <input type="submit" value="', $txt['membergroups_add_group'], '" class="button"> |
139 | 143 | </div><!-- .windowbg -->'; |
140 | 144 | |
141 | - if ($context['undefined_group']) |
|
142 | - echo ' |
|
145 | + if ($context['undefined_group']) { |
|
146 | + echo ' |
|
143 | 147 | <script> |
144 | 148 | function swapPostGroup(isChecked) |
145 | 149 | { |
@@ -149,6 +153,7 @@ discard block |
||
149 | 153 | } |
150 | 154 | swapPostGroup(', $context['post_group'] ? 'true' : 'false', '); |
151 | 155 | </script>'; |
156 | + } |
|
152 | 157 | |
153 | 158 | echo ' |
154 | 159 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -178,14 +183,15 @@ discard block |
||
178 | 183 | <input type="text" name="group_name" id="group_name_input" value="', $context['group']['editable_name'], '" size="30"> |
179 | 184 | </dd>'; |
180 | 185 | |
181 | - if ($context['group']['id'] != 3 && $context['group']['id'] != 4) |
|
182 | - echo ' |
|
186 | + if ($context['group']['id'] != 3 && $context['group']['id'] != 4) { |
|
187 | + echo ' |
|
183 | 188 | <dt id="group_desc_text"> |
184 | 189 | <label for="group_desc_input"><strong>', $txt['membergroups_edit_desc'], ':</strong></label> |
185 | 190 | </dt> |
186 | 191 | <dd> |
187 | 192 | <textarea name="group_desc" id="group_desc_input" rows="4" cols="40">', $context['group']['description'], '</textarea> |
188 | 193 | </dd>'; |
194 | + } |
|
189 | 195 | |
190 | 196 | // Group type... |
191 | 197 | if ($context['group']['allow_post_group']) |
@@ -199,9 +205,10 @@ discard block |
||
199 | 205 | <legend>', $txt['membergroups_edit_select_group_type'], '</legend> |
200 | 206 | <label for="group_type_private"><input type="radio" name="group_type" id="group_type_private" value="0"', !$context['group']['is_post_group'] && $context['group']['type'] == 0 ? ' checked' : '', ' onclick="swapPostGroup(0);">', $txt['membergroups_group_type_private'], '</label><br>'; |
201 | 207 | |
202 | - if ($context['group']['allow_protected']) |
|
203 | - echo ' |
|
208 | + if ($context['group']['allow_protected']) { |
|
209 | + echo ' |
|
204 | 210 | <label for="group_type_protected"><input type="radio" name="group_type" id="group_type_protected" value="1"', $context['group']['type'] == 1 ? ' checked' : '', ' onclick="swapPostGroup(0);">', $txt['membergroups_group_type_protected'], '</label><br>'; |
211 | + } |
|
205 | 212 | |
206 | 213 | echo ' |
207 | 214 | <label for="group_type_request"><input type="radio" name="group_type" id="group_type_request" value="2"', $context['group']['type'] == 2 ? ' checked' : '', ' onclick="swapPostGroup(0);">', $txt['membergroups_group_type_request'], '</label><br> |
@@ -211,8 +218,8 @@ discard block |
||
211 | 218 | </dd>'; |
212 | 219 | } |
213 | 220 | |
214 | - if ($context['group']['id'] != 3 && $context['group']['id'] != 4) |
|
215 | - echo ' |
|
221 | + if ($context['group']['id'] != 3 && $context['group']['id'] != 4) { |
|
222 | + echo ' |
|
216 | 223 | <dt id="group_moderators_text"> |
217 | 224 | <label for="group_moderators"><strong>', $txt['moderators'], ':</strong></label> |
218 | 225 | </dt> |
@@ -230,6 +237,7 @@ discard block |
||
230 | 237 | <option value="2"', $context['group']['hidden'] == 2 ? ' selected' : '', '>', $txt['membergroups_edit_hidden_all'], '</option> |
231 | 238 | </select> |
232 | 239 | </dd>'; |
240 | + } |
|
233 | 241 | |
234 | 242 | // Can they inherit permissions? |
235 | 243 | if ($context['group']['id'] > 1 && $context['group']['id'] != 3) |
@@ -246,9 +254,10 @@ discard block |
||
246 | 254 | <option value="0"', $context['group']['inherited_from'] == 0 ? ' selected' : '', '>', $txt['membergroups_edit_inherit_permissions_from'], ': ', $txt['membergroups_members'], '</option>'; |
247 | 255 | |
248 | 256 | // For all the inheritable groups show an option. |
249 | - foreach ($context['inheritable_groups'] as $id => $group) |
|
250 | - echo ' |
|
257 | + foreach ($context['inheritable_groups'] as $id => $group) { |
|
258 | + echo ' |
|
251 | 259 | <option value="', $id, '"', $context['group']['inherited_from'] == $id ? ' selected' : '', '>', $txt['membergroups_edit_inherit_permissions_from'], ': ', $group, '</option>'; |
260 | + } |
|
252 | 261 | |
253 | 262 | echo ' |
254 | 263 | </select> |
@@ -256,8 +265,8 @@ discard block |
||
256 | 265 | </dd>'; |
257 | 266 | } |
258 | 267 | |
259 | - if ($context['group']['allow_post_group']) |
|
260 | - echo ' |
|
268 | + if ($context['group']['allow_post_group']) { |
|
269 | + echo ' |
|
261 | 270 | |
262 | 271 | <dt id="min_posts_text"> |
263 | 272 | <label for="min_posts_input"><strong>', $txt['membergroups_min_posts'], ':</strong></label> |
@@ -265,6 +274,7 @@ discard block |
||
265 | 274 | <dd> |
266 | 275 | <input type="number" name="min_posts" id="min_posts_input"', $context['group']['is_post_group'] ? ' value="' . $context['group']['min_posts'] . '"' : '', ' size="6"> |
267 | 276 | </dd>'; |
277 | + } |
|
268 | 278 | |
269 | 279 | echo ' |
270 | 280 | <dt> |
@@ -294,9 +304,10 @@ discard block |
||
294 | 304 | <select name="icon_image" id="icon_image_input">'; |
295 | 305 | |
296 | 306 | // For every possible icon, create an option. |
297 | - foreach ($context['possible_icons'] as $icon) |
|
298 | - echo ' |
|
307 | + foreach ($context['possible_icons'] as $icon) { |
|
308 | + echo ' |
|
299 | 309 | <option value="', $icon, '"', $context['group']['icon_image'] == $icon ? ' selected' : '', '>', $icon, '</option>'; |
310 | + } |
|
300 | 311 | |
301 | 312 | echo ' |
302 | 313 | </select> |
@@ -305,9 +316,10 @@ discard block |
||
305 | 316 | } |
306 | 317 | |
307 | 318 | // No? Hide the entire control. |
308 | - else |
|
309 | - echo ' |
|
319 | + else { |
|
320 | + echo ' |
|
310 | 321 | <input type="hidden" name="icon_image" value="">'; |
322 | + } |
|
311 | 323 | |
312 | 324 | echo ' |
313 | 325 | <dt> |
@@ -319,8 +331,8 @@ discard block |
||
319 | 331 | </dd>'; |
320 | 332 | |
321 | 333 | // Force 2FA for this membergroup? |
322 | - if (!empty($modSettings['tfa_mode']) && $modSettings['tfa_mode'] == 2) |
|
323 | - echo ' |
|
334 | + if (!empty($modSettings['tfa_mode']) && $modSettings['tfa_mode'] == 2) { |
|
335 | + echo ' |
|
324 | 336 | <dt> |
325 | 337 | <label for="group_tfa_force_input"><strong>', $txt['membergroups_tfa_force'], ':</strong></label><br> |
326 | 338 | <span class="smalltext">', $txt['membergroups_tfa_force_note'], '</span> |
@@ -328,6 +340,7 @@ discard block |
||
328 | 340 | <dd> |
329 | 341 | <input type="checkbox" name="group_tfa_force"', $context['group']['tfa_required'] ? ' checked' : '', '> |
330 | 342 | </dd>'; |
343 | + } |
|
331 | 344 | |
332 | 345 | if (!empty($context['categories'])) |
333 | 346 | { |
@@ -338,11 +351,11 @@ discard block |
||
338 | 351 | </dt> |
339 | 352 | <dd>'; |
340 | 353 | |
341 | - if (!empty($context['can_manage_boards'])) |
|
342 | - echo $txt['membergroups_can_manage_access']; |
|
343 | - |
|
344 | - else |
|
345 | - template_add_edit_group_boards_list(); |
|
354 | + if (!empty($context['can_manage_boards'])) { |
|
355 | + echo $txt['membergroups_can_manage_access']; |
|
356 | + } else { |
|
357 | + template_add_edit_group_boards_list(); |
|
358 | + } |
|
346 | 359 | |
347 | 360 | echo ' |
348 | 361 | </dd>'; |
@@ -371,20 +384,21 @@ discard block |
||
371 | 384 | sItemListContainerId: \'moderator_container\', |
372 | 385 | aListItems: ['; |
373 | 386 | |
374 | - foreach ($context['group']['moderators'] as $id_member => $member_name) |
|
375 | - echo ' |
|
387 | + foreach ($context['group']['moderators'] as $id_member => $member_name) { |
|
388 | + echo ' |
|
376 | 389 | { |
377 | 390 | sItemId: ', JavaScriptEscape($id_member), ', |
378 | 391 | sItemName: ', JavaScriptEscape($member_name), ' |
379 | 392 | }', $id_member == $context['group']['last_moderator_id'] ? '' : ','; |
393 | + } |
|
380 | 394 | |
381 | 395 | echo ' |
382 | 396 | ] |
383 | 397 | }); |
384 | 398 | </script>'; |
385 | 399 | |
386 | - if ($context['group']['allow_post_group']) |
|
387 | - echo ' |
|
400 | + if ($context['group']['allow_post_group']) { |
|
401 | + echo ' |
|
388 | 402 | <script> |
389 | 403 | function swapPostGroup(isChecked) |
390 | 404 | { |
@@ -432,7 +446,8 @@ discard block |
||
432 | 446 | |
433 | 447 | swapPostGroup(', $context['group']['is_post_group'] ? 'true' : 'false', '); |
434 | 448 | </script>'; |
435 | -} |
|
449 | + } |
|
450 | + } |
|
436 | 451 | |
437 | 452 | /** |
438 | 453 | * The template for determining which boards a group has access to. |
@@ -450,13 +465,13 @@ discard block |
||
450 | 465 | |
451 | 466 | foreach ($context['categories'] as $category) |
452 | 467 | { |
453 | - if (empty($modSettings['deny_boards_access'])) |
|
454 | - echo ' |
|
468 | + if (empty($modSettings['deny_boards_access'])) { |
|
469 | + echo ' |
|
455 | 470 | <li class="category"> |
456 | 471 | <a href="javascript:void(0);" onclick="selectBoards([', implode(', ', $category['child_ids']), '], \'new_group\'); return false;"><strong>', $category['name'], '</strong></a> |
457 | 472 | <ul>'; |
458 | - else |
|
459 | - echo ' |
|
473 | + } else { |
|
474 | + echo ' |
|
460 | 475 | <li class="category"> |
461 | 476 | <strong>', $category['name'], '</strong> |
462 | 477 | <span class="select_all_box"> |
@@ -469,16 +484,17 @@ discard block |
||
469 | 484 | </select> |
470 | 485 | </span> |
471 | 486 | <ul id="boards_list_', $category['id'], '">'; |
487 | + } |
|
472 | 488 | |
473 | 489 | foreach ($category['boards'] as $board) |
474 | 490 | { |
475 | - if (empty($modSettings['deny_boards_access'])) |
|
476 | - echo ' |
|
491 | + if (empty($modSettings['deny_boards_access'])) { |
|
492 | + echo ' |
|
477 | 493 | <li class="board" style="margin-', $context['right_to_left'] ? 'right' : 'left', ': ', $board['child_level'], 'em;"> |
478 | 494 | <input type="checkbox" name="boardaccess[', $board['id'], ']" id="brd', $board['id'], '" value="allow"', $board['allow'] ? ' checked' : '', '> <label for="brd', $board['id'], '">', $board['name'], '</label> |
479 | 495 | </li>'; |
480 | - else |
|
481 | - echo ' |
|
496 | + } else { |
|
497 | + echo ' |
|
482 | 498 | <li class="board" style="width:100%"> |
483 | 499 | <span style="margin-', $context['right_to_left'] ? 'right' : 'left', ': ', $board['child_level'], 'em;">', $board['name'], ': </span> |
484 | 500 | <span style="width:50%;float:right"> |
@@ -487,6 +503,7 @@ discard block |
||
487 | 503 | <input type="radio" name="boardaccess[', $board['id'], ']" id="deny_brd', $board['id'], '" value="deny"', $board['deny'] ? ' checked' : '', '> <label for="deny_brd', $board['id'], '">', $txt['permissions_option_deny'], '</label> |
488 | 504 | </span> |
489 | 505 | </li>'; |
506 | + } |
|
490 | 507 | } |
491 | 508 | |
492 | 509 | echo ' |
@@ -497,14 +514,14 @@ discard block |
||
497 | 514 | echo ' |
498 | 515 | </ul>'; |
499 | 516 | |
500 | - if (empty($modSettings['deny_boards_access'])) |
|
501 | - echo ' |
|
517 | + if (empty($modSettings['deny_boards_access'])) { |
|
518 | + echo ' |
|
502 | 519 | <br class="clear"><br> |
503 | 520 | <input type="checkbox" id="checkall_check" onclick="invertAll(this, this.form, \'boardaccess\');"> |
504 | 521 | <label for="checkall_check"><em>', $txt['check_all'], '</em></label> |
505 | 522 | </fieldset>'; |
506 | - else |
|
507 | - echo ' |
|
523 | + } else { |
|
524 | + echo ' |
|
508 | 525 | <br class="clear"> |
509 | 526 | <span class="select_all_box"> |
510 | 527 | <em>', $txt['all'], ': </em> |
@@ -520,15 +537,17 @@ discard block |
||
520 | 537 | }); |
521 | 538 | }); |
522 | 539 | </script>'; |
540 | + } |
|
523 | 541 | |
524 | - if ($collapse) |
|
525 | - echo ' |
|
542 | + if ($collapse) { |
|
543 | + echo ' |
|
526 | 544 | <a href="javascript:void(0);" onclick="document.getElementById(\'visible_boards\').classList.remove(\'hidden\'); document.getElementById(\'visible_boards_link\').classList.add(\'hidden\'); return false;" id="visible_boards_link" class="hidden">[ ', $txt['membergroups_select_visible_boards'], ' ]</a> |
527 | 545 | <script> |
528 | 546 | document.getElementById("visible_boards_link").classList.remove(\'hidden\'); |
529 | 547 | document.getElementById("visible_boards").classList.add(\'hidden\'); |
530 | 548 | </script>'; |
531 | -} |
|
549 | + } |
|
550 | + } |
|
532 | 551 | |
533 | 552 | /** |
534 | 553 | * Templatine for viewing the members of a group. |
@@ -552,14 +571,15 @@ discard block |
||
552 | 571 | </dd>'; |
553 | 572 | |
554 | 573 | // Any description to show? |
555 | - if (!empty($context['group']['description'])) |
|
556 | - echo ' |
|
574 | + if (!empty($context['group']['description'])) { |
|
575 | + echo ' |
|
557 | 576 | <dt> |
558 | 577 | <strong>' . $txt['membergroups_members_description'] . ':</strong> |
559 | 578 | </dt> |
560 | 579 | <dd> |
561 | 580 | ', $context['group']['description'], ' |
562 | 581 | </dd>'; |
582 | + } |
|
563 | 583 | |
564 | 584 | echo ' |
565 | 585 | <dt> |
@@ -573,8 +593,9 @@ discard block |
||
573 | 593 | if (!empty($context['group']['moderators'])) |
574 | 594 | { |
575 | 595 | $moderators = array(); |
576 | - foreach ($context['group']['moderators'] as $moderator) |
|
577 | - $moderators[] = '<a href="' . $scripturl . '?action=profile;u=' . $moderator['id'] . '">' . $moderator['name'] . '</a>'; |
|
596 | + foreach ($context['group']['moderators'] as $moderator) { |
|
597 | + $moderators[] = '<a href="' . $scripturl . '?action=profile;u=' . $moderator['id'] . '">' . $moderator['name'] . '</a>'; |
|
598 | + } |
|
578 | 599 | |
579 | 600 | echo ' |
580 | 601 | <dt> |
@@ -599,9 +620,10 @@ discard block |
||
599 | 620 | <tr class="title_bar"> |
600 | 621 | <th><a href="', $scripturl, '?action=', $context['current_action'], (isset($context['admin_area']) ? ';area=' . $context['admin_area'] : ''), ';sa=members;start=', $context['start'], ';sort=name', $context['sort_by'] == 'name' && $context['sort_direction'] == 'up' ? ';desc' : '', ';group=', $context['group']['id'], '">', $txt['name'], $context['sort_by'] == 'name' ? ' <span class="generic_icons sort_' . $context['sort_direction'] . '"></span>' : '', '</a></th>'; |
601 | 622 | |
602 | - if ($context['can_send_email']) |
|
603 | - echo ' |
|
623 | + if ($context['can_send_email']) { |
|
624 | + echo ' |
|
604 | 625 | <th><a href="', $scripturl, '?action=', $context['current_action'], (isset($context['admin_area']) ? ';area=' . $context['admin_area'] : ''), ';sa=members;start=', $context['start'], ';sort=email', $context['sort_by'] == 'email' && $context['sort_direction'] == 'up' ? ';desc' : '', ';group=', $context['group']['id'], '">', $txt['email'], $context['sort_by'] == 'email' ? ' <span class="generic_icons sort_' . $context['sort_direction'] . '"></span>' : '', '</a></th>'; |
626 | + } |
|
605 | 627 | |
606 | 628 | echo ' |
607 | 629 | <th><a href="', $scripturl, '?action=', $context['current_action'], (isset($context['admin_area']) ? ';area=' . $context['admin_area'] : ''), ';sa=members;start=', $context['start'], ';sort=active', $context['sort_by'] == 'active' && $context['sort_direction'] == 'up' ? ';desc' : '', ';group=', $context['group']['id'], '">', $txt['membergroups_members_last_active'], $context['sort_by'] == 'active' ? '<span class="generic_icons sort_' . $context['sort_direction'] . '"></span>' : '', '</a></th> |
@@ -610,20 +632,22 @@ discard block |
||
610 | 632 | <a href="', $scripturl, '?action=', $context['current_action'], (isset($context['admin_area']) ? ';area=' . $context['admin_area'] : ''), ';sa=members;start=', $context['start'], ';sort=posts', $context['sort_by'] == 'posts' && $context['sort_direction'] == 'up' ? ';desc' : '', ';group=', $context['group']['id'], '">', $txt['posts'], $context['sort_by'] == 'posts' ? ' <span class="generic_icons sort_' . $context['sort_direction'] . '"></span>' : '', '</a> |
611 | 633 | </th>'; |
612 | 634 | |
613 | - if (!empty($context['group']['assignable'])) |
|
614 | - echo ' |
|
635 | + if (!empty($context['group']['assignable'])) { |
|
636 | + echo ' |
|
615 | 637 | <th style="width: 4%"><input type="checkbox" onclick="invertAll(this, this.form);"></th>'; |
638 | + } |
|
616 | 639 | |
617 | 640 | echo ' |
618 | 641 | </tr> |
619 | 642 | </thead> |
620 | 643 | <tbody>'; |
621 | 644 | |
622 | - if (empty($context['members'])) |
|
623 | - echo ' |
|
645 | + if (empty($context['members'])) { |
|
646 | + echo ' |
|
624 | 647 | <tr class="windowbg"> |
625 | 648 | <td colspan="6">', $txt['membergroups_members_no_members'], '</td> |
626 | 649 | </tr>'; |
650 | + } |
|
627 | 651 | |
628 | 652 | foreach ($context['members'] as $member) |
629 | 653 | { |
@@ -631,20 +655,22 @@ discard block |
||
631 | 655 | <tr class="windowbg"> |
632 | 656 | <td>', $member['name'], '</td>'; |
633 | 657 | |
634 | - if ($context['can_send_email']) |
|
635 | - echo ' |
|
658 | + if ($context['can_send_email']) { |
|
659 | + echo ' |
|
636 | 660 | <td> |
637 | 661 | <a href="mailto:', $member['email'], '">', $member['email'], '</a> |
638 | 662 | </td>'; |
663 | + } |
|
639 | 664 | |
640 | 665 | echo ' |
641 | 666 | <td>', $member['last_online'], '</td> |
642 | 667 | <td>', $member['registered'], '</td> |
643 | 668 | <td', empty($context['group']['assignable']) ? ' colspan="2"' : '', '>', $member['posts'], '</td>'; |
644 | 669 | |
645 | - if (!empty($context['group']['assignable'])) |
|
646 | - echo ' |
|
670 | + if (!empty($context['group']['assignable'])) { |
|
671 | + echo ' |
|
647 | 672 | <td style="width: 4%"><input type="checkbox" name="rem[]" value="', $member['id'], '" ', ($context['user']['id'] == $member['id'] && $context['group']['id'] == 1 ? 'onclick="if (this.checked) return confirm(\'' . $txt['membergroups_members_deadmin_confirm'] . '\')" ' : ''), '/></td>'; |
673 | + } |
|
648 | 674 | |
649 | 675 | echo ' |
650 | 676 | </tr>'; |
@@ -654,11 +680,12 @@ discard block |
||
654 | 680 | </tbody> |
655 | 681 | </table>'; |
656 | 682 | |
657 | - if (!empty($context['group']['assignable'])) |
|
658 | - echo ' |
|
683 | + if (!empty($context['group']['assignable'])) { |
|
684 | + echo ' |
|
659 | 685 | <div class="floatright"> |
660 | 686 | <input type="submit" name="remove" value="', $txt['membergroups_members_remove'], '" class="button "> |
661 | 687 | </div>'; |
688 | + } |
|
662 | 689 | |
663 | 690 | echo ' |
664 | 691 | <div class="pagesection flow_hidden"> |
@@ -666,8 +693,8 @@ discard block |
||
666 | 693 | </div> |
667 | 694 | <br>'; |
668 | 695 | |
669 | - if (!empty($context['group']['assignable'])) |
|
670 | - echo ' |
|
696 | + if (!empty($context['group']['assignable'])) { |
|
697 | + echo ' |
|
671 | 698 | <div class="cat_bar"> |
672 | 699 | <h3 class="catbg">', $txt['membergroups_members_add_title'], '</h3> |
673 | 700 | </div> |
@@ -683,14 +710,15 @@ discard block |
||
683 | 710 | </dl> |
684 | 711 | <input type="submit" name="add" value="', $txt['membergroups_members_add'], '" class="button"> |
685 | 712 | </div>'; |
713 | + } |
|
686 | 714 | |
687 | 715 | echo ' |
688 | 716 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
689 | 717 | <input type="hidden" name="', $context['mod-mgm_token_var'], '" value="', $context['mod-mgm_token'], '"> |
690 | 718 | </form>'; |
691 | 719 | |
692 | - if (!empty($context['group']['assignable'])) |
|
693 | - echo ' |
|
720 | + if (!empty($context['group']['assignable'])) { |
|
721 | + echo ' |
|
694 | 722 | <script> |
695 | 723 | var oAddMemberSuggest = new smc_AutoSuggest({ |
696 | 724 | sSelf: \'oAddMemberSuggest\', |
@@ -706,7 +734,8 @@ discard block |
||
706 | 734 | sItemListContainerId: \'toAddItemContainer\' |
707 | 735 | }); |
708 | 736 | </script>'; |
709 | -} |
|
737 | + } |
|
738 | + } |
|
710 | 739 | |
711 | 740 | /** |
712 | 741 | * Allow the moderator to enter a reason to each user being rejected. |
@@ -726,8 +755,8 @@ discard block |
||
726 | 755 | <dl class="settings">'; |
727 | 756 | |
728 | 757 | // Loop through and print out a reason box for each... |
729 | - foreach ($context['group_requests'] as $request) |
|
730 | - echo ' |
|
758 | + foreach ($context['group_requests'] as $request) { |
|
759 | + echo ' |
|
731 | 760 | <dt> |
732 | 761 | <strong>', sprintf($txt['mc_groupr_reason_desc'], $request['member_link'], $request['group_link']), ':</strong> |
733 | 762 | </dt> |
@@ -735,6 +764,7 @@ discard block |
||
735 | 764 | <input type="hidden" name="groupr[]" value="', $request['id'], '"> |
736 | 765 | <textarea name="groupreason[', $request['id'], ']" rows="3" cols="40"></textarea> |
737 | 766 | </dd>'; |
767 | + } |
|
738 | 768 | |
739 | 769 | echo ' |
740 | 770 | </dl> |
@@ -22,30 +22,32 @@ discard block |
||
22 | 22 | <div id="calendar">'; |
23 | 23 | |
24 | 24 | // Show the mini-blocks if they're enabled. |
25 | - if (empty($context['blocks_disabled'])) |
|
26 | - echo ' |
|
25 | + if (empty($context['blocks_disabled'])) { |
|
26 | + echo ' |
|
27 | 27 | <div id="month_grid"> |
28 | 28 | ', template_show_month_grid('prev', true), ' |
29 | 29 | ', template_show_month_grid('current', true), ' |
30 | 30 | ', template_show_month_grid('next', true), ' |
31 | 31 | </div>'; |
32 | + } |
|
32 | 33 | |
33 | 34 | // What view are we showing? |
34 | - if ($context['calendar_view'] == 'viewlist') |
|
35 | - echo ' |
|
35 | + if ($context['calendar_view'] == 'viewlist') { |
|
36 | + echo ' |
|
36 | 37 | <div id="main_grid"> |
37 | 38 | ', template_show_upcoming_list('main'), ' |
38 | 39 | </div>'; |
39 | - elseif ($context['calendar_view'] == 'viewweek') |
|
40 | - echo ' |
|
40 | + } elseif ($context['calendar_view'] == 'viewweek') { |
|
41 | + echo ' |
|
41 | 42 | <div id="main_grid"> |
42 | 43 | ', template_show_week_grid('main'), ' |
43 | 44 | </div>'; |
44 | - else |
|
45 | - echo ' |
|
45 | + } else { |
|
46 | + echo ' |
|
46 | 47 | <div id="main_grid"> |
47 | 48 | ', template_show_month_grid('main'), ' |
48 | 49 | </div>'; |
50 | + } |
|
49 | 51 | |
50 | 52 | // Close our wrapper. |
51 | 53 | echo ' |
@@ -64,20 +66,22 @@ discard block |
||
64 | 66 | global $context, $scripturl, $txt; |
65 | 67 | |
66 | 68 | // Bail out if we have nothing to work with |
67 | - if (!isset($context['calendar_grid_' . $grid_name])) |
|
68 | - return false; |
|
69 | + if (!isset($context['calendar_grid_' . $grid_name])) { |
|
70 | + return false; |
|
71 | + } |
|
69 | 72 | |
70 | 73 | // Protect programmer sanity |
71 | 74 | $calendar_data = &$context['calendar_grid_' . $grid_name]; |
72 | 75 | |
73 | 76 | // Do we want a title? |
74 | - if (empty($calendar_data['disable_title'])) |
|
75 | - echo ' |
|
77 | + if (empty($calendar_data['disable_title'])) { |
|
78 | + echo ' |
|
76 | 79 | <div class="cat_bar"> |
77 | 80 | <h3 class="catbg centertext largetext"> |
78 | 81 | <a href="', $scripturl, '?action=calendar;viewlist;year=', $calendar_data['start_year'], ';month=', $calendar_data['start_month'], ';day=', $calendar_data['start_day'], '">', $txt['calendar_upcoming'], '</a> |
79 | 82 | </h3> |
80 | 83 | </div>'; |
84 | + } |
|
81 | 85 | |
82 | 86 | // Give the user some controls to work with |
83 | 87 | template_calendar_top($calendar_data); |
@@ -100,11 +104,13 @@ discard block |
||
100 | 104 | <li class="windowbg"> |
101 | 105 | <strong class="event_title">', $event['link'], '</strong>'; |
102 | 106 | |
103 | - if ($event['can_edit']) |
|
104 | - echo ' <a href="' . $event['modify_href'] . '"><span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span></a>'; |
|
107 | + if ($event['can_edit']) { |
|
108 | + echo ' <a href="' . $event['modify_href'] . '"><span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span></a>'; |
|
109 | + } |
|
105 | 110 | |
106 | - if ($event['can_export']) |
|
107 | - echo ' <a href="' . $event['export_href'] . '"><span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span></a>'; |
|
111 | + if ($event['can_export']) { |
|
112 | + echo ' <a href="' . $event['export_href'] . '"><span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span></a>'; |
|
113 | + } |
|
108 | 114 | |
109 | 115 | echo ' |
110 | 116 | <br>'; |
@@ -112,14 +118,14 @@ discard block |
||
112 | 118 | if (!empty($event['allday'])) |
113 | 119 | { |
114 | 120 | echo '<time datetime="' . $event['start_iso_gmdate'] . '">', trim($event['start_date_local']), '</time>', ($event['start_date'] != $event['end_date']) ? ' – <time datetime="' . $event['end_iso_gmdate'] . '">' . trim($event['end_date_local']) . '</time>' : ''; |
115 | - } |
|
116 | - else |
|
121 | + } else |
|
117 | 122 | { |
118 | 123 | // Display event info relative to user's local timezone |
119 | 124 | echo '<time datetime="' . $event['start_iso_gmdate'] . '">', trim($event['start_date_local']), ', ', trim($event['start_time_local']), '</time> – <time datetime="' . $event['end_iso_gmdate'] . '">'; |
120 | 125 | |
121 | - if ($event['start_date_local'] != $event['end_date_local']) |
|
122 | - echo trim($event['end_date_local']) . ', '; |
|
126 | + if ($event['start_date_local'] != $event['end_date_local']) { |
|
127 | + echo trim($event['end_date_local']) . ', '; |
|
128 | + } |
|
123 | 129 | |
124 | 130 | echo trim($event['end_time_local']); |
125 | 131 | |
@@ -128,23 +134,27 @@ discard block |
||
128 | 134 | { |
129 | 135 | echo '</time> (<time datetime="' . $event['start_iso_gmdate'] . '">'; |
130 | 136 | |
131 | - if ($event['start_date_orig'] != $event['start_date_local'] || $event['end_date_orig'] != $event['end_date_local'] || $event['start_date_orig'] != $event['end_date_orig']) |
|
132 | - echo trim($event['start_date_orig']), ', '; |
|
137 | + if ($event['start_date_orig'] != $event['start_date_local'] || $event['end_date_orig'] != $event['end_date_local'] || $event['start_date_orig'] != $event['end_date_orig']) { |
|
138 | + echo trim($event['start_date_orig']), ', '; |
|
139 | + } |
|
133 | 140 | |
134 | 141 | echo trim($event['start_time_orig']), '</time> – <time datetime="' . $event['end_iso_gmdate'] . '">'; |
135 | 142 | |
136 | - if ($event['start_date_orig'] != $event['end_date_orig']) |
|
137 | - echo trim($event['end_date_orig']) . ', '; |
|
143 | + if ($event['start_date_orig'] != $event['end_date_orig']) { |
|
144 | + echo trim($event['end_date_orig']) . ', '; |
|
145 | + } |
|
138 | 146 | |
139 | 147 | echo trim($event['end_time_orig']), ' ', $event['tz_abbrev'], '</time>)'; |
140 | 148 | } |
141 | 149 | // Event is scheduled in the user's own timezone? Let 'em know, just to avoid confusion |
142 | - else |
|
143 | - echo ' ', $event['tz_abbrev'], '</time>'; |
|
150 | + else { |
|
151 | + echo ' ', $event['tz_abbrev'], '</time>'; |
|
152 | + } |
|
144 | 153 | } |
145 | 154 | |
146 | - if (!empty($event['location'])) |
|
147 | - echo '<br>', $event['location']; |
|
155 | + if (!empty($event['location'])) { |
|
156 | + echo '<br>', $event['location']; |
|
157 | + } |
|
148 | 158 | |
149 | 159 | echo ' |
150 | 160 | </li>'; |
@@ -176,8 +186,9 @@ discard block |
||
176 | 186 | |
177 | 187 | $birthdays = array(); |
178 | 188 | |
179 | - foreach ($date as $member) |
|
180 | - $birthdays[] = '<a href="' . $scripturl . '?action=profile;u=' . $member['id'] . '">' . $member['name'] . (isset($member['age']) ? ' (' . $member['age'] . ')' : '') . '</a>'; |
|
189 | + foreach ($date as $member) { |
|
190 | + $birthdays[] = '<a href="' . $scripturl . '?action=profile;u=' . $member['id'] . '">' . $member['name'] . (isset($member['age']) ? ' (' . $member['age'] . ')' : '') . '</a>'; |
|
191 | + } |
|
181 | 192 | |
182 | 193 | echo implode(', ', $birthdays); |
183 | 194 | |
@@ -208,8 +219,9 @@ discard block |
||
208 | 219 | $date_local = $date['date_local']; |
209 | 220 | unset($date['date_local']); |
210 | 221 | |
211 | - foreach ($date as $holiday) |
|
212 | - $holidays[] = $holiday . ' (' . $date_local . ')'; |
|
222 | + foreach ($date as $holiday) { |
|
223 | + $holidays[] = $holiday . ' (' . $date_local . ')'; |
|
224 | + } |
|
213 | 225 | } |
214 | 226 | |
215 | 227 | echo implode(', ', $holidays); |
@@ -233,17 +245,19 @@ discard block |
||
233 | 245 | global $context, $txt, $scripturl, $modSettings; |
234 | 246 | |
235 | 247 | // If the grid doesn't exist, no point in proceeding. |
236 | - if (!isset($context['calendar_grid_' . $grid_name])) |
|
237 | - return false; |
|
248 | + if (!isset($context['calendar_grid_' . $grid_name])) { |
|
249 | + return false; |
|
250 | + } |
|
238 | 251 | |
239 | 252 | // A handy little pointer variable. |
240 | 253 | $calendar_data = &$context['calendar_grid_' . $grid_name]; |
241 | 254 | |
242 | 255 | // Some conditions for whether or not we should show the week links *here*. |
243 | - if (isset($calendar_data['show_week_links']) && ($calendar_data['show_week_links'] == 3 || (($calendar_data['show_week_links'] == 1 && $is_mini === true) || $calendar_data['show_week_links'] == 2 && $is_mini === false))) |
|
244 | - $show_week_links = true; |
|
245 | - else |
|
246 | - $show_week_links = false; |
|
256 | + if (isset($calendar_data['show_week_links']) && ($calendar_data['show_week_links'] == 3 || (($calendar_data['show_week_links'] == 1 && $is_mini === true) || $calendar_data['show_week_links'] == 2 && $is_mini === false))) { |
|
257 | + $show_week_links = true; |
|
258 | + } else { |
|
259 | + $show_week_links = false; |
|
260 | + } |
|
247 | 261 | |
248 | 262 | // Assuming that we've not disabled it, show the title block! |
249 | 263 | if (empty($calendar_data['disable_title'])) |
@@ -253,18 +267,20 @@ discard block |
||
253 | 267 | <h3 class="catbg centertext largetext">'; |
254 | 268 | |
255 | 269 | // Previous Link: If we're showing prev / next and it's not a mini-calendar. |
256 | - if (empty($calendar_data['previous_calendar']['disabled']) && $calendar_data['show_next_prev'] && $is_mini === false) |
|
257 | - echo ' |
|
270 | + if (empty($calendar_data['previous_calendar']['disabled']) && $calendar_data['show_next_prev'] && $is_mini === false) { |
|
271 | + echo ' |
|
258 | 272 | <span class="floatleft"> |
259 | 273 | <a href="', $calendar_data['previous_calendar']['href'], '">«</a> |
260 | 274 | </span>'; |
275 | + } |
|
261 | 276 | |
262 | 277 | // Next Link: if we're showing prev / next and it's not a mini-calendar. |
263 | - if (empty($calendar_data['next_calendar']['disabled']) && $calendar_data['show_next_prev'] && $is_mini === false) |
|
264 | - echo ' |
|
278 | + if (empty($calendar_data['next_calendar']['disabled']) && $calendar_data['show_next_prev'] && $is_mini === false) { |
|
279 | + echo ' |
|
265 | 280 | <span class="floatright"> |
266 | 281 | <a href="', $calendar_data['next_calendar']['href'], '">»</a> |
267 | 282 | </span>'; |
283 | + } |
|
268 | 284 | |
269 | 285 | // Arguably the most exciting part, the title! |
270 | 286 | echo ' |
@@ -274,8 +290,9 @@ discard block |
||
274 | 290 | } |
275 | 291 | |
276 | 292 | // Show the controls on main grids |
277 | - if ($is_mini === false) |
|
278 | - template_calendar_top($calendar_data); |
|
293 | + if ($is_mini === false) { |
|
294 | + template_calendar_top($calendar_data); |
|
295 | + } |
|
279 | 296 | |
280 | 297 | // Finally, the main calendar table. |
281 | 298 | echo ' |
@@ -288,14 +305,16 @@ discard block |
||
288 | 305 | <tr>'; |
289 | 306 | |
290 | 307 | // If we're showing week links, there's an extra column ahead of the week links, so let's think ahead and be prepared! |
291 | - if ($show_week_links === true) |
|
292 | - echo ' |
|
308 | + if ($show_week_links === true) { |
|
309 | + echo ' |
|
293 | 310 | <th></th>'; |
311 | + } |
|
294 | 312 | |
295 | 313 | // Now, loop through each actual day of the week. |
296 | - foreach ($calendar_data['week_days'] as $day) |
|
297 | - echo ' |
|
314 | + foreach ($calendar_data['week_days'] as $day) { |
|
315 | + echo ' |
|
298 | 316 | <th class="days" scope="col">', !empty($calendar_data['short_day_titles']) || $is_mini === true ? $txt['days_short'][$day] : $txt['days'][$day], '</th>'; |
317 | + } |
|
299 | 318 | |
300 | 319 | echo ' |
301 | 320 | </tr>'; |
@@ -313,11 +332,12 @@ discard block |
||
313 | 332 | <tr class="days_wrapper">'; |
314 | 333 | |
315 | 334 | // This is where we add the actual week link, if enabled on this location. |
316 | - if ($show_week_links === true) |
|
317 | - echo ' |
|
335 | + if ($show_week_links === true) { |
|
336 | + echo ' |
|
318 | 337 | <td class="windowbg weeks"> |
319 | 338 | <a href="', $scripturl, '?action=calendar;viewweek;year=', $calendar_data['current_year'], ';month=', $calendar_data['current_month'], ';day=', $week['days'][0]['day'], '" title="', $txt['calendar_view_week'], '">»</a> |
320 | 339 | </td>'; |
340 | + } |
|
321 | 341 | |
322 | 342 | // Now loop through each day in the week we're on. |
323 | 343 | foreach ($week['days'] as $day) |
@@ -333,27 +353,29 @@ discard block |
||
333 | 353 | // Additional classes are given for events, holidays, and birthdays. |
334 | 354 | if (!empty($day['events']) && !empty($calendar_data['highlight']['events'])) |
335 | 355 | { |
336 | - if ($is_mini === true && in_array($calendar_data['highlight']['events'], array(1, 3))) |
|
337 | - $classes[] = 'events'; |
|
338 | - elseif ($is_mini === false && in_array($calendar_data['highlight']['events'], array(2, 3))) |
|
339 | - $classes[] = 'events'; |
|
356 | + if ($is_mini === true && in_array($calendar_data['highlight']['events'], array(1, 3))) { |
|
357 | + $classes[] = 'events'; |
|
358 | + } elseif ($is_mini === false && in_array($calendar_data['highlight']['events'], array(2, 3))) { |
|
359 | + $classes[] = 'events'; |
|
360 | + } |
|
340 | 361 | } |
341 | 362 | if (!empty($day['holidays']) && !empty($calendar_data['highlight']['holidays'])) |
342 | 363 | { |
343 | - if ($is_mini === true && in_array($calendar_data['highlight']['holidays'], array(1, 3))) |
|
344 | - $classes[] = 'holidays'; |
|
345 | - elseif ($is_mini === false && in_array($calendar_data['highlight']['holidays'], array(2, 3))) |
|
346 | - $classes[] = 'holidays'; |
|
364 | + if ($is_mini === true && in_array($calendar_data['highlight']['holidays'], array(1, 3))) { |
|
365 | + $classes[] = 'holidays'; |
|
366 | + } elseif ($is_mini === false && in_array($calendar_data['highlight']['holidays'], array(2, 3))) { |
|
367 | + $classes[] = 'holidays'; |
|
368 | + } |
|
347 | 369 | } |
348 | 370 | if (!empty($day['birthdays']) && !empty($calendar_data['highlight']['birthdays'])) |
349 | 371 | { |
350 | - if ($is_mini === true && in_array($calendar_data['highlight']['birthdays'], array(1, 3))) |
|
351 | - $classes[] = 'birthdays'; |
|
352 | - elseif ($is_mini === false && in_array($calendar_data['highlight']['birthdays'], array(2, 3))) |
|
353 | - $classes[] = 'birthdays'; |
|
372 | + if ($is_mini === true && in_array($calendar_data['highlight']['birthdays'], array(1, 3))) { |
|
373 | + $classes[] = 'birthdays'; |
|
374 | + } elseif ($is_mini === false && in_array($calendar_data['highlight']['birthdays'], array(2, 3))) { |
|
375 | + $classes[] = 'birthdays'; |
|
376 | + } |
|
354 | 377 | } |
355 | - } |
|
356 | - else |
|
378 | + } else |
|
357 | 379 | { |
358 | 380 | // Default Classes (either compact or comfortable and disabled). |
359 | 381 | $classes[] = !empty($calendar_data['size']) && $calendar_data['size'] == 'small' ? 'compact' : 'comfortable'; |
@@ -371,25 +393,27 @@ discard block |
||
371 | 393 | $title_prefix = !empty($day['is_first_of_month']) && $context['current_month'] == $calendar_data['current_month'] && $is_mini === false ? (!empty($calendar_data['short_month_titles']) ? $txt['months_short'][$calendar_data['current_month']] . ' ' : $txt['months_titles'][$calendar_data['current_month']] . ' ') : ''; |
372 | 394 | |
373 | 395 | // The actual day number - be it a link, or just plain old text! |
374 | - if (!empty($modSettings['cal_daysaslink']) && $context['can_post']) |
|
375 | - echo ' |
|
396 | + if (!empty($modSettings['cal_daysaslink']) && $context['can_post']) { |
|
397 | + echo ' |
|
376 | 398 | <a href="', $scripturl, '?action=calendar;sa=post;year=', $calendar_data['current_year'], ';month=', $calendar_data['current_month'], ';day=', $day['day'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="day_text">', $title_prefix, $day['day'], '</span></a>'; |
377 | - elseif ($is_mini) |
|
378 | - echo ' |
|
399 | + } elseif ($is_mini) { |
|
400 | + echo ' |
|
379 | 401 | <a href="', $scripturl, '?action=calendar;', $context['calendar_view'], ';year=', $calendar_data['current_year'], ';month=', $calendar_data['current_month'], ';day=', $day['day'], '"><span class="day_text">', $title_prefix, $day['day'], '</span></a>'; |
380 | - else |
|
381 | - echo ' |
|
402 | + } else { |
|
403 | + echo ' |
|
382 | 404 | <span class="day_text">', $title_prefix, $day['day'], '</span>'; |
405 | + } |
|
383 | 406 | |
384 | 407 | // A lot of stuff, we're not showing on mini-calendars to conserve space. |
385 | 408 | if ($is_mini === false) |
386 | 409 | { |
387 | 410 | // Holidays are always fun, let's show them! |
388 | - if (!empty($day['holidays'])) |
|
389 | - echo ' |
|
411 | + if (!empty($day['holidays'])) { |
|
412 | + echo ' |
|
390 | 413 | <div class="smalltext holiday"> |
391 | 414 | <span>', $txt['calendar_prompt'], '</span> ', implode(', ', $day['holidays']), ' |
392 | 415 | </div>'; |
416 | + } |
|
393 | 417 | |
394 | 418 | // Happy Birthday Dear Member! |
395 | 419 | if (!empty($day['birthdays'])) |
@@ -407,15 +431,17 @@ discard block |
||
407 | 431 | echo '<a href="', $scripturl, '?action=profile;u=', $member['id'], '"><span class="fix_rtl_names">', $member['name'], '</span>', isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a>', $member['is_last'] || ($count == 10 && $use_js_hide) ? '' : ', '; |
408 | 432 | |
409 | 433 | // 9...10! Let's stop there. |
410 | - if ($birthday_count == 10 && $use_js_hide) |
|
411 | - // !!TODO - Inline CSS and JavaScript should be moved. |
|
434 | + if ($birthday_count == 10 && $use_js_hide) { |
|
435 | + // !!TODO - Inline CSS and JavaScript should be moved. |
|
412 | 436 | echo '<span class="hidelink" id="bdhidelink_', $day['day'], '">...<br><a href="', $scripturl, '?action=calendar;month=', $calendar_data['current_month'], ';year=', $calendar_data['current_year'], ';showbd" onclick="document.getElementById(\'bdhide_', $day['day'], '\').classList.remove(\'hidden\'); document.getElementById(\'bdhidelink_', $day['day'], '\').classList.add(\'hidden\'); return false;">(', sprintf($txt['calendar_click_all'], count($day['birthdays'])), ')</a></span><span id="bdhide_', $day['day'], '" class="hidden">, '; |
437 | + } |
|
413 | 438 | |
414 | 439 | ++$birthday_count; |
415 | 440 | } |
416 | - if ($use_js_hide) |
|
417 | - echo ' |
|
441 | + if ($use_js_hide) { |
|
442 | + echo ' |
|
418 | 443 | </span>'; |
444 | + } |
|
419 | 445 | |
420 | 446 | echo ' |
421 | 447 | </div><!-- .smalltext -->'; |
@@ -426,8 +452,9 @@ discard block |
||
426 | 452 | { |
427 | 453 | // Sort events by start time (all day events will be listed first) |
428 | 454 | uasort($day['events'], function($a, $b) { |
429 | - if ($a['start_timestamp'] == $b['start_timestamp']) |
|
430 | - return 0; |
|
455 | + if ($a['start_timestamp'] == $b['start_timestamp']) { |
|
456 | + return 0; |
|
457 | + } |
|
431 | 458 | |
432 | 459 | return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1; |
433 | 460 | }); |
@@ -447,20 +474,22 @@ discard block |
||
447 | 474 | ', $event['link'], '<br> |
448 | 475 | <span class="event_time', empty($event_icons_needed) ? ' floatright' : '', '">'; |
449 | 476 | |
450 | - if (!empty($event['start_time_local']) && $event['starts_today'] == true) |
|
451 | - echo trim(str_replace(':00 ', ' ', $event['start_time_local'])); |
|
452 | - elseif (!empty($event['end_time_local']) && $event['ends_today'] == true) |
|
453 | - echo strtolower($txt['ends']), ' ', trim(str_replace(':00 ', ' ', $event['end_time_local'])); |
|
454 | - elseif (!empty($event['allday'])) |
|
455 | - echo $txt['calendar_allday']; |
|
477 | + if (!empty($event['start_time_local']) && $event['starts_today'] == true) { |
|
478 | + echo trim(str_replace(':00 ', ' ', $event['start_time_local'])); |
|
479 | + } elseif (!empty($event['end_time_local']) && $event['ends_today'] == true) { |
|
480 | + echo strtolower($txt['ends']), ' ', trim(str_replace(':00 ', ' ', $event['end_time_local'])); |
|
481 | + } elseif (!empty($event['allday'])) { |
|
482 | + echo $txt['calendar_allday']; |
|
483 | + } |
|
456 | 484 | |
457 | 485 | echo ' |
458 | 486 | </span>'; |
459 | 487 | |
460 | - if (!empty($event['location'])) |
|
461 | - echo ' |
|
488 | + if (!empty($event['location'])) { |
|
489 | + echo ' |
|
462 | 490 | <br> |
463 | 491 | <span class="event_location', empty($event_icons_needed) ? ' floatright' : '', '">' . $event['location'] . '</span>'; |
492 | + } |
|
464 | 493 | |
465 | 494 | if ($event['can_edit'] || $event['can_export']) |
466 | 495 | { |
@@ -468,18 +497,20 @@ discard block |
||
468 | 497 | <span class="modify_event_links">'; |
469 | 498 | |
470 | 499 | // If they can edit the event, show an icon they can click on.... |
471 | - if ($event['can_edit']) |
|
472 | - echo ' |
|
500 | + if ($event['can_edit']) { |
|
501 | + echo ' |
|
473 | 502 | <a class="modify_event" href="', $event['modify_href'], '"> |
474 | 503 | <span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span> |
475 | 504 | </a>'; |
505 | + } |
|
476 | 506 | |
477 | 507 | // Exporting! |
478 | - if ($event['can_export']) |
|
479 | - echo ' |
|
508 | + if ($event['can_export']) { |
|
509 | + echo ' |
|
480 | 510 | <a class="modify_event" href="', $event['export_href'], '"> |
481 | 511 | <span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span> |
482 | 512 | </a>'; |
513 | + } |
|
483 | 514 | |
484 | 515 | echo ' |
485 | 516 | </span><br class="clear">'; |
@@ -498,10 +529,11 @@ discard block |
||
498 | 529 | // Otherwise, assuming it's not a mini-calendar, we can show previous / next month days! |
499 | 530 | elseif ($is_mini === false) |
500 | 531 | { |
501 | - if (empty($current_month_started) && !empty($context['calendar_grid_prev'])) |
|
502 | - echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_prev']['current_year'], ';month=', $context['calendar_grid_prev']['current_month'], '">', $context['calendar_grid_prev']['last_of_month'] - $calendar_data['shift']-- +1, '</a>'; |
|
503 | - elseif (!empty($current_month_started) && !empty($context['calendar_grid_next'])) |
|
504 | - echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_next']['current_year'], ';month=', $context['calendar_grid_next']['current_month'], '">', $current_month_started + 1 == $count ? (!empty($calendar_data['short_month_titles']) ? $txt['months_short'][$context['calendar_grid_next']['current_month']] . ' ' : $txt['months_titles'][$context['calendar_grid_next']['current_month']] . ' ') : '', $final_count++, '</a>'; |
|
532 | + if (empty($current_month_started) && !empty($context['calendar_grid_prev'])) { |
|
533 | + echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_prev']['current_year'], ';month=', $context['calendar_grid_prev']['current_month'], '">', $context['calendar_grid_prev']['last_of_month'] - $calendar_data['shift']-- +1, '</a>'; |
|
534 | + } elseif (!empty($current_month_started) && !empty($context['calendar_grid_next'])) { |
|
535 | + echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_next']['current_year'], ';month=', $context['calendar_grid_next']['current_month'], '">', $current_month_started + 1 == $count ? (!empty($calendar_data['short_month_titles']) ? $txt['months_short'][$context['calendar_grid_next']['current_month']] . ' ' : $txt['months_titles'][$context['calendar_grid_next']['current_month']] . ' ') : '', $final_count++, '</a>'; |
|
536 | + } |
|
505 | 537 | } |
506 | 538 | |
507 | 539 | // Close this day and increase var count. |
@@ -531,8 +563,9 @@ discard block |
||
531 | 563 | global $context, $txt, $scripturl, $modSettings; |
532 | 564 | |
533 | 565 | // We might have no reason to proceed, if the variable isn't there. |
534 | - if (!isset($context['calendar_grid_' . $grid_name])) |
|
535 | - return false; |
|
566 | + if (!isset($context['calendar_grid_' . $grid_name])) { |
|
567 | + return false; |
|
568 | + } |
|
536 | 569 | |
537 | 570 | // Handy pointer. |
538 | 571 | $calendar_data = &$context['calendar_grid_' . $grid_name]; |
@@ -549,22 +582,25 @@ discard block |
||
549 | 582 | <h3 class="catbg centertext largetext">'; |
550 | 583 | |
551 | 584 | // Previous Week Link... |
552 | - if (empty($calendar_data['previous_calendar']['disabled']) && !empty($calendar_data['show_next_prev'])) |
|
553 | - echo ' |
|
585 | + if (empty($calendar_data['previous_calendar']['disabled']) && !empty($calendar_data['show_next_prev'])) { |
|
586 | + echo ' |
|
554 | 587 | <span class="floatleft"> |
555 | 588 | <a href="', $calendar_data['previous_week']['href'], '">«</a> |
556 | 589 | </span>'; |
590 | + } |
|
557 | 591 | |
558 | 592 | // Next Week Link... |
559 | - if (empty($calendar_data['next_calendar']['disabled']) && !empty($calendar_data['show_next_prev'])) |
|
560 | - echo ' |
|
593 | + if (empty($calendar_data['next_calendar']['disabled']) && !empty($calendar_data['show_next_prev'])) { |
|
594 | + echo ' |
|
561 | 595 | <span class="floatright"> |
562 | 596 | <a href="', $calendar_data['next_week']['href'], '">»</a> |
563 | 597 | </span>'; |
598 | + } |
|
564 | 599 | |
565 | 600 | // The Month Title + Week Number... |
566 | - if (!empty($calendar_data['week_title'])) |
|
567 | - echo $calendar_data['week_title']; |
|
601 | + if (!empty($calendar_data['week_title'])) { |
|
602 | + echo $calendar_data['week_title']; |
|
603 | + } |
|
568 | 604 | |
569 | 605 | echo ' |
570 | 606 | </h3> |
@@ -605,11 +641,12 @@ discard block |
||
605 | 641 | <td class="', implode(' ', $classes), ' act_day">'; |
606 | 642 | |
607 | 643 | // Should the day number be a link? |
608 | - if (!empty($modSettings['cal_daysaslink']) && $context['can_post']) |
|
609 | - echo ' |
|
644 | + if (!empty($modSettings['cal_daysaslink']) && $context['can_post']) { |
|
645 | + echo ' |
|
610 | 646 | <a href="', $scripturl, '?action=calendar;sa=post;month=', $month_data['current_month'], ';year=', $month_data['current_year'], ';day=', $day['day'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['days'][$day['day_of_week']], ' - ', $day['day'], '</a>'; |
611 | - else |
|
612 | - echo $txt['days'][$day['day_of_week']], ' - ', $day['day']; |
|
647 | + } else { |
|
648 | + echo $txt['days'][$day['day_of_week']], ' - ', $day['day']; |
|
649 | + } |
|
613 | 650 | |
614 | 651 | echo ' |
615 | 652 | </td> |
@@ -620,8 +657,9 @@ discard block |
||
620 | 657 | { |
621 | 658 | // Sort events by start time (all day events will be listed first) |
622 | 659 | uasort($day['events'], function($a, $b) { |
623 | - if ($a['start_timestamp'] == $b['start_timestamp']) |
|
624 | - return 0; |
|
660 | + if ($a['start_timestamp'] == $b['start_timestamp']) { |
|
661 | + return 0; |
|
662 | + } |
|
625 | 663 | return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1; |
626 | 664 | }); |
627 | 665 | |
@@ -635,35 +673,39 @@ discard block |
||
635 | 673 | echo $event['link'], '<br> |
636 | 674 | <span class="event_time', empty($event_icons_needed) ? ' floatright' : '', '">'; |
637 | 675 | |
638 | - if (!empty($event['start_time_local'])) |
|
639 | - echo trim($event['start_time_local']), !empty($event['end_time_local']) ? ' – ' . trim($event['end_time_local']) : ''; |
|
640 | - else |
|
641 | - echo $txt['calendar_allday']; |
|
676 | + if (!empty($event['start_time_local'])) { |
|
677 | + echo trim($event['start_time_local']), !empty($event['end_time_local']) ? ' – ' . trim($event['end_time_local']) : ''; |
|
678 | + } else { |
|
679 | + echo $txt['calendar_allday']; |
|
680 | + } |
|
642 | 681 | |
643 | 682 | echo ' |
644 | 683 | </span>'; |
645 | 684 | |
646 | - if (!empty($event['location'])) |
|
647 | - echo '<br> |
|
685 | + if (!empty($event['location'])) { |
|
686 | + echo '<br> |
|
648 | 687 | <span class="event_location', empty($event_icons_needed) ? ' floatright' : '', '">' . $event['location'] . '</span>'; |
688 | + } |
|
649 | 689 | |
650 | 690 | if (!empty($event_icons_needed)) |
651 | 691 | { |
652 | 692 | echo ' <span class="modify_event_links">'; |
653 | 693 | |
654 | 694 | // If they can edit the event, show a star they can click on.... |
655 | - if (!empty($event['can_edit'])) |
|
656 | - echo ' |
|
695 | + if (!empty($event['can_edit'])) { |
|
696 | + echo ' |
|
657 | 697 | <a class="modify_event" href="', $event['modify_href'], '"> |
658 | 698 | <span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span> |
659 | 699 | </a>'; |
700 | + } |
|
660 | 701 | |
661 | 702 | // Can we export? Sweet. |
662 | - if (!empty($event['can_export'])) |
|
663 | - echo ' |
|
703 | + if (!empty($event['can_export'])) { |
|
704 | + echo ' |
|
664 | 705 | <a class="modify_event" href="', $event['export_href'], '"> |
665 | 706 | <span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span> |
666 | 707 | </a>'; |
708 | + } |
|
667 | 709 | |
668 | 710 | echo ' |
669 | 711 | </span><br class="clear">'; |
@@ -681,22 +723,23 @@ discard block |
||
681 | 723 | </div> |
682 | 724 | <br class="clear">'; |
683 | 725 | } |
684 | - } |
|
685 | - else |
|
726 | + } else |
|
686 | 727 | { |
687 | - if (!empty($context['can_post'])) |
|
688 | - echo ' |
|
728 | + if (!empty($context['can_post'])) { |
|
729 | + echo ' |
|
689 | 730 | <div class="week_add_event"> |
690 | 731 | <a href="', $scripturl, '?action=calendar;sa=post;month=', $month_data['current_month'], ';year=', $month_data['current_year'], ';day=', $day['day'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['calendar_post_event'], '</a> |
691 | 732 | </div>'; |
733 | + } |
|
692 | 734 | } |
693 | 735 | echo ' |
694 | 736 | </td> |
695 | 737 | <td class="', implode(' ', $classes), !empty($day['holidays']) ? ' holidays' : ' disabled', ' holiday_col" data-css-prefix="' . $txt['calendar_prompt'] . ' ">'; |
696 | 738 | |
697 | 739 | // Show any holidays! |
698 | - if (!empty($day['holidays'])) |
|
699 | - echo implode('<br>', $day['holidays']); |
|
740 | + if (!empty($day['holidays'])) { |
|
741 | + echo implode('<br>', $day['holidays']); |
|
742 | + } |
|
700 | 743 | |
701 | 744 | echo ' |
702 | 745 | </td> |
@@ -705,11 +748,12 @@ discard block |
||
705 | 748 | // Show any birthdays... |
706 | 749 | if (!empty($day['birthdays'])) |
707 | 750 | { |
708 | - foreach ($day['birthdays'] as $member) |
|
709 | - echo ' |
|
751 | + foreach ($day['birthdays'] as $member) { |
|
752 | + echo ' |
|
710 | 753 | <a href="', $scripturl, '?action=profile;u=', $member['id'], '">', $member['name'], '</a> |
711 | 754 | ', isset($member['age']) ? ' (' . $member['age'] . ')' : '', ' |
712 | 755 | ', $member['is_last'] ? '' : '<br>'; |
756 | + } |
|
713 | 757 | } |
714 | 758 | echo ' |
715 | 759 | </td> |
@@ -755,26 +799,27 @@ discard block |
||
755 | 799 | <input type="text" name="end_date" id="end_date" maxlength="10" value="', $calendar_data['end_date'], '" tabindex="', $context['tabindex']++, '" class="date_input end" data-type="date"> |
756 | 800 | <input type="submit" class="button" style="float:none" id="view_button" value="', $txt['view'], '"> |
757 | 801 | </form>'; |
758 | - } |
|
759 | - else |
|
802 | + } else |
|
760 | 803 | { |
761 | 804 | echo' |
762 | 805 | <form action="', $scripturl, '?action=calendar" id="calendar_navigation" method="post" accept-charset="', $context['character_set'], '"> |
763 | 806 | <select name="month" id="input_month">'; |
764 | 807 | |
765 | 808 | // Show a select box with all the months. |
766 | - foreach ($txt['months_short'] as $number => $month) |
|
767 | - echo ' |
|
809 | + foreach ($txt['months_short'] as $number => $month) { |
|
810 | + echo ' |
|
768 | 811 | <option value="', $number, '"', $number == $context['current_month'] ? ' selected' : '', '>', $month, '</option>'; |
812 | + } |
|
769 | 813 | |
770 | 814 | echo ' |
771 | 815 | </select> |
772 | 816 | <select name="year">'; |
773 | 817 | |
774 | 818 | // Show a link for every year... |
775 | - for ($year = $context['calendar_resources']['min_year']; $year <= $context['calendar_resources']['max_year']; $year++) |
|
776 | - echo ' |
|
819 | + for ($year = $context['calendar_resources']['min_year']; $year <= $context['calendar_resources']['max_year']; $year++) { |
|
820 | + echo ' |
|
777 | 821 | <option value="', $year, '"', $year == $context['current_year'] ? ' selected' : '', '>', $year, '</option>'; |
822 | + } |
|
778 | 823 | |
779 | 824 | echo ' |
780 | 825 | </select> |
@@ -796,9 +841,10 @@ discard block |
||
796 | 841 | echo ' |
797 | 842 | <form action="', $scripturl, '?action=calendar;sa=post" method="post" name="postevent" accept-charset="', $context['character_set'], '" onsubmit="submitonce(this);">'; |
798 | 843 | |
799 | - if (!empty($context['event']['new'])) |
|
800 | - echo ' |
|
844 | + if (!empty($context['event']['new'])) { |
|
845 | + echo ' |
|
801 | 846 | <input type="hidden" name="eventid" value="', $context['event']['eventid'], '">'; |
847 | + } |
|
802 | 848 | |
803 | 849 | // Start the main table. |
804 | 850 | echo ' |
@@ -809,8 +855,8 @@ discard block |
||
809 | 855 | </h3> |
810 | 856 | </div>'; |
811 | 857 | |
812 | - if (!empty($context['post_error']['messages'])) |
|
813 | - echo ' |
|
858 | + if (!empty($context['post_error']['messages'])) { |
|
859 | + echo ' |
|
814 | 860 | <div class="errorbox"> |
815 | 861 | <dl class="event_error"> |
816 | 862 | <dt> |
@@ -821,6 +867,7 @@ discard block |
||
821 | 867 | </dt> |
822 | 868 | </dl> |
823 | 869 | </div>'; |
870 | + } |
|
824 | 871 | |
825 | 872 | echo ' |
826 | 873 | <div class="roundframe noup"> |
@@ -848,9 +895,10 @@ discard block |
||
848 | 895 | echo ' |
849 | 896 | <optgroup label="', $category['name'], '">'; |
850 | 897 | |
851 | - foreach ($category['boards'] as $board) |
|
852 | - echo ' |
|
898 | + foreach ($category['boards'] as $board) { |
|
899 | + echo ' |
|
853 | 900 | <option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level'] - 1) . '=>' : '', ' ', $board['name'], '</option>'; |
901 | + } |
|
854 | 902 | echo ' |
855 | 903 | </optgroup>'; |
856 | 904 | } |
@@ -886,9 +934,10 @@ discard block |
||
886 | 934 | <span class="label">', $txt['calendar_timezone'], '</span> |
887 | 935 | <select name="tz" id="tz"', !empty($context['event']['allday']) ? ' disabled' : '', '>'; |
888 | 936 | |
889 | - foreach ($context['all_timezones'] as $tz => $tzname) |
|
890 | - echo ' |
|
937 | + foreach ($context['all_timezones'] as $tz => $tzname) { |
|
938 | + echo ' |
|
891 | 939 | <option', is_numeric($tz) ? ' value="" disabled' : ' value="' . $tz . '"', $tz === $context['event']['tz'] ? ' selected' : '', '>', $tzname, '</option>'; |
940 | + } |
|
892 | 941 | |
893 | 942 | echo ' |
894 | 943 | </select> |
@@ -904,9 +953,10 @@ discard block |
||
904 | 953 | <input type="submit" value="', empty($context['event']['new']) ? $txt['save'] : $txt['post'], '" class="button">'; |
905 | 954 | |
906 | 955 | // Delete button? |
907 | - if (empty($context['event']['new'])) |
|
908 | - echo ' |
|
956 | + if (empty($context['event']['new'])) { |
|
957 | + echo ' |
|
909 | 958 | <input type="submit" name="deleteevent" value="', $txt['event_delete'], '" data-confirm="', $txt['calendar_confirm_delete'], '" class="button you_sure">'; |
959 | + } |
|
910 | 960 | |
911 | 961 | echo ' |
912 | 962 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -934,9 +984,10 @@ discard block |
||
934 | 984 | echo ' |
935 | 985 | <td style="padding-', $alt ? 'right' : 'left', ': 1.5em;">'; |
936 | 986 | |
937 | - foreach ($v as $i) |
|
938 | - echo ' |
|
987 | + foreach ($v as $i) { |
|
988 | + echo ' |
|
939 | 989 | <img src="', $context['offimg'], '" alt="" id="', $t, '_', $i, '"><br>'; |
990 | + } |
|
940 | 991 | |
941 | 992 | echo ' |
942 | 993 | </td>'; |
@@ -957,9 +1008,10 @@ discard block |
||
957 | 1008 | |
958 | 1009 | foreach ($context['clockicons'] as $t => $v) |
959 | 1010 | { |
960 | - foreach ($v as $i) |
|
961 | - echo ' |
|
1011 | + foreach ($v as $i) { |
|
1012 | + echo ' |
|
962 | 1013 | icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');'; |
1014 | + } |
|
963 | 1015 | } |
964 | 1016 | |
965 | 1017 | echo ' |
@@ -984,13 +1036,14 @@ discard block |
||
984 | 1036 | |
985 | 1037 | foreach ($context['clockicons'] as $t => $v) |
986 | 1038 | { |
987 | - foreach ($v as $i) |
|
988 | - echo ' |
|
1039 | + foreach ($v as $i) { |
|
1040 | + echo ' |
|
989 | 1041 | if (', $t, ' >= ', $i, ') |
990 | 1042 | { |
991 | 1043 | turnon.push("', $t, '_', $i, '"); |
992 | 1044 | ', $t, ' -= ', $i, '; |
993 | 1045 | }'; |
1046 | + } |
|
994 | 1047 | } |
995 | 1048 | |
996 | 1049 | echo ' |
@@ -1034,9 +1087,10 @@ discard block |
||
1034 | 1087 | <tr class="windowbg"> |
1035 | 1088 | <td>'; |
1036 | 1089 | |
1037 | - foreach ($v as $i) |
|
1038 | - echo ' |
|
1090 | + foreach ($v as $i) { |
|
1091 | + echo ' |
|
1039 | 1092 | <img src="', $context['offimg'], '" alt="" id="', $t, '_', $i, '" style="padding: 2px;">'; |
1093 | + } |
|
1040 | 1094 | |
1041 | 1095 | echo ' |
1042 | 1096 | </td> |
@@ -1058,9 +1112,10 @@ discard block |
||
1058 | 1112 | |
1059 | 1113 | foreach ($context['clockicons'] as $t => $v) |
1060 | 1114 | { |
1061 | - foreach ($v as $i) |
|
1062 | - echo ' |
|
1115 | + foreach ($v as $i) { |
|
1116 | + echo ' |
|
1063 | 1117 | icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');'; |
1118 | + } |
|
1064 | 1119 | } |
1065 | 1120 | |
1066 | 1121 | echo ' |
@@ -1077,13 +1132,14 @@ discard block |
||
1077 | 1132 | |
1078 | 1133 | foreach ($context['clockicons'] as $t => $v) |
1079 | 1134 | { |
1080 | - foreach ($v as $i) |
|
1081 | - echo ' |
|
1135 | + foreach ($v as $i) { |
|
1136 | + echo ' |
|
1082 | 1137 | if (', $t, ' >= ', $i, ') |
1083 | 1138 | { |
1084 | 1139 | turnon.push("', $t, '_', $i, '"); |
1085 | 1140 | ', $t, ' -= ', $i, '; |
1086 | 1141 | }'; |
1142 | + } |
|
1087 | 1143 | } |
1088 | 1144 | |
1089 | 1145 | echo ' |
@@ -1127,9 +1183,10 @@ discard block |
||
1127 | 1183 | <tr class="windowbg"> |
1128 | 1184 | <td>'; |
1129 | 1185 | |
1130 | - foreach ($v as $i) |
|
1131 | - echo ' |
|
1186 | + foreach ($v as $i) { |
|
1187 | + echo ' |
|
1132 | 1188 | <img src="', $context['offimg'], '" alt="" id="', $t, '_', $i, '" style="padding: 2px;">'; |
1189 | + } |
|
1133 | 1190 | |
1134 | 1191 | echo ' |
1135 | 1192 | </td> |
@@ -1145,9 +1202,10 @@ discard block |
||
1145 | 1202 | |
1146 | 1203 | foreach ($context['clockicons'] as $t => $v) |
1147 | 1204 | { |
1148 | - foreach ($v as $i) |
|
1149 | - echo ' |
|
1205 | + foreach ($v as $i) { |
|
1206 | + echo ' |
|
1150 | 1207 | icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');'; |
1208 | + } |
|
1151 | 1209 | } |
1152 | 1210 | |
1153 | 1211 | echo ' |
@@ -1168,13 +1226,14 @@ discard block |
||
1168 | 1226 | |
1169 | 1227 | foreach ($context['clockicons'] as $t => $v) |
1170 | 1228 | { |
1171 | - foreach ($v as $i) |
|
1172 | - echo ' |
|
1229 | + foreach ($v as $i) { |
|
1230 | + echo ' |
|
1173 | 1231 | if (', $t, ' >= ', $i, ') |
1174 | 1232 | { |
1175 | 1233 | turnon.push("', $t, '_', $i, '"); |
1176 | 1234 | ', $t, ' -= ', $i, '; |
1177 | 1235 | }'; |
1236 | + } |
|
1178 | 1237 | } |
1179 | 1238 | |
1180 | 1239 | echo ' |
@@ -1218,9 +1277,10 @@ discard block |
||
1218 | 1277 | <tr class="windowbg"> |
1219 | 1278 | <td>'; |
1220 | 1279 | |
1221 | - foreach ($v as $i) |
|
1222 | - echo ' |
|
1280 | + foreach ($v as $i) { |
|
1281 | + echo ' |
|
1223 | 1282 | <img src="', $i ? $context['onimg'] : $context['offimg'], '" alt="" style="padding: 2px;">'; |
1283 | + } |
|
1224 | 1284 | |
1225 | 1285 | echo ' |
1226 | 1286 | </td> |
@@ -25,18 +25,20 @@ discard block |
||
25 | 25 | </div> |
26 | 26 | <div class="windowbg">'; |
27 | 27 | |
28 | - if (!empty($context['move_board'])) |
|
29 | - echo ' |
|
28 | + if (!empty($context['move_board'])) { |
|
29 | + echo ' |
|
30 | 30 | <div class="noticebox"> |
31 | 31 | ', $context['move_title'], ' [<a href="', $scripturl, '?action=admin;area=manageboards">', $txt['mboards_cancel_moving'], '</a>]', ' |
32 | 32 | </div>'; |
33 | + } |
|
33 | 34 | |
34 | 35 | // No categories so show a label. |
35 | - if (empty($context['categories'])) |
|
36 | - echo ' |
|
36 | + if (empty($context['categories'])) { |
|
37 | + echo ' |
|
37 | 38 | <div class="windowbg centertext"> |
38 | 39 | ', $txt['mboards_no_cats'], ' |
39 | 40 | </div>'; |
41 | + } |
|
40 | 42 | |
41 | 43 | // Loop through every category, listing the boards in each as we go. |
42 | 44 | foreach ($context['categories'] as $category) |
@@ -54,9 +56,10 @@ discard block |
||
54 | 56 | <form action="', $scripturl, '?action=admin;area=manageboards;sa=newboard;cat=', $category['id'], '" method="post" accept-charset="', $context['character_set'], '"> |
55 | 57 | <ul id="category_', $category['id'], '" class="nolist">'; |
56 | 58 | |
57 | - if (!empty($category['move_link'])) |
|
58 | - echo ' |
|
59 | + if (!empty($category['move_link'])) { |
|
60 | + echo ' |
|
59 | 61 | <li><a href="', $category['move_link']['href'], '" title="', $category['move_link']['label'], '"><span class="generic_icons select_above"></span></a></li>'; |
62 | + } |
|
60 | 63 | |
61 | 64 | $recycle_board = '<a href="' . $scripturl . '?action=admin;area=manageboards;sa=settings"> <img src="' . $settings['images_url'] . '/post/recycled.png" alt="' . $txt['recycle_board'] . '" title="' . $txt['recycle_board'] . '"></a>'; |
62 | 65 | $redirect_board = '<img src="' . $settings['images_url'] . '/new_redirect.png" alt="' . $txt['redirect_board_desc'] . '" title="' . $txt['redirect_board_desc'] . '">'; |
@@ -79,9 +82,10 @@ discard block |
||
79 | 82 | echo ' |
80 | 83 | <li class="windowbg" style="padding-', $context['right_to_left'] ? 'right' : 'left', ': ', 5 + 30 * $board['move_links'][0]['child_level'], 'px;">'; |
81 | 84 | |
82 | - foreach ($board['move_links'] as $link) |
|
83 | - echo ' |
|
85 | + foreach ($board['move_links'] as $link) { |
|
86 | + echo ' |
|
84 | 87 | <a href="', $link['href'], '" class="move_links" title="', $link['label'], '"><span class="generic_icons select_', $link['class'], '" title="', $link['label'], '"></span></a>'; |
88 | + } |
|
85 | 89 | |
86 | 90 | echo ' |
87 | 91 | </li>'; |
@@ -130,9 +134,10 @@ discard block |
||
130 | 134 | <select name="cat_order">'; |
131 | 135 | |
132 | 136 | // Print every existing category into a select box. |
133 | - foreach ($context['category_order'] as $order) |
|
134 | - echo ' |
|
137 | + foreach ($context['category_order'] as $order) { |
|
138 | + echo ' |
|
135 | 139 | <option', $order['selected'] ? ' selected' : '', ' value="', $order['id'], '">', $order['name'], '</option>'; |
140 | + } |
|
136 | 141 | echo ' |
137 | 142 | </select> |
138 | 143 | </dd>'; |
@@ -167,14 +172,15 @@ discard block |
||
167 | 172 | { |
168 | 173 | foreach ($context['custom_category_settings'] as $catset_id => $catset) |
169 | 174 | { |
170 | - if (!empty($catset['dt']) && !empty($catset['dd'])) |
|
171 | - echo ' |
|
175 | + if (!empty($catset['dt']) && !empty($catset['dd'])) { |
|
176 | + echo ' |
|
172 | 177 | <dt class="clear', !is_numeric($catset_id) ? ' catset_' . $catset_id : '', '"> |
173 | 178 | ', $catset['dt'], ' |
174 | 179 | </dt> |
175 | 180 | <dd', !is_numeric($catset_id) ? ' class="catset_' . $catset_id . '"' : '', '> |
176 | 181 | ', $catset['dd'], ' |
177 | 182 | </dd>'; |
183 | + } |
|
178 | 184 | } |
179 | 185 | } |
180 | 186 | |
@@ -182,21 +188,23 @@ discard block |
||
182 | 188 | echo ' |
183 | 189 | </dl>'; |
184 | 190 | |
185 | - if (isset($context['category']['is_new'])) |
|
186 | - echo ' |
|
191 | + if (isset($context['category']['is_new'])) { |
|
192 | + echo ' |
|
187 | 193 | <input type="submit" name="add" value="', $txt['mboards_add_cat_button'], '" onclick="return !isEmptyText(this.form.cat_name);" tabindex="', $context['tabindex']++, '" class="button">'; |
188 | - else |
|
189 | - echo ' |
|
194 | + } else { |
|
195 | + echo ' |
|
190 | 196 | <input type="submit" name="edit" value="', $txt['modify'], '" onclick="return !isEmptyText(this.form.cat_name);" tabindex="', $context['tabindex']++, '" class="button"> |
191 | 197 | <input type="submit" name="delete" value="', $txt['mboards_delete_cat'], '" data-confirm="', $txt['catConfirm'], '" class="button you_sure">'; |
198 | + } |
|
192 | 199 | echo ' |
193 | 200 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
194 | 201 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
195 | 202 | |
196 | 203 | // If this category is empty we don't bother with the next confirmation screen. |
197 | - if ($context['category']['is_empty']) |
|
198 | - echo ' |
|
204 | + if ($context['category']['is_empty']) { |
|
205 | + echo ' |
|
199 | 206 | <input type="hidden" name="empty" value="1">'; |
207 | + } |
|
200 | 208 | |
201 | 209 | echo ' |
202 | 210 | </div><!-- .windowbg --> |
@@ -223,9 +231,10 @@ discard block |
||
223 | 231 | <p>', $txt['mboards_delete_cat_contains'], ':</p> |
224 | 232 | <ul>'; |
225 | 233 | |
226 | - foreach ($context['category']['children'] as $child) |
|
227 | - echo ' |
|
234 | + foreach ($context['category']['children'] as $child) { |
|
235 | + echo ' |
|
228 | 236 | <li>', $child, '</li>'; |
237 | + } |
|
229 | 238 | |
230 | 239 | echo ' |
231 | 240 | </ul> |
@@ -239,10 +248,11 @@ discard block |
||
239 | 248 | <label for="delete_action1"><input type="radio" id="delete_action1" name="delete_action" value="1"', count($context['category_order']) == 1 ? ' disabled' : '', '>', $txt['mboards_delete_option2'], '</label>: |
240 | 249 | <select name="cat_to"', count($context['category_order']) == 1 ? ' disabled' : '', '>'; |
241 | 250 | |
242 | - foreach ($context['category_order'] as $cat) |
|
243 | - if ($cat['id'] != 0) |
|
251 | + foreach ($context['category_order'] as $cat) { |
|
252 | + if ($cat['id'] != 0) |
|
244 | 253 | echo ' |
245 | 254 | <option value="', $cat['id'], '">', $cat['true_name'], '</option>'; |
255 | + } |
|
246 | 256 | |
247 | 257 | echo ' |
248 | 258 | </select> |
@@ -285,9 +295,10 @@ discard block |
||
285 | 295 | <dd> |
286 | 296 | <select name="new_cat" onchange="if (this.form.order) {this.form.order.disabled = this.options[this.selectedIndex].value != 0; this.form.board_order.disabled = this.options[this.selectedIndex].value != 0 || this.form.order.options[this.form.order.selectedIndex].value == \'\';}">'; |
287 | 297 | |
288 | - foreach ($context['categories'] as $category) |
|
289 | - echo ' |
|
298 | + foreach ($context['categories'] as $category) { |
|
299 | + echo ' |
|
290 | 300 | <option', $category['selected'] ? ' selected' : '', ' value="', $category['id'], '">', $category['name'], '</option>'; |
301 | + } |
|
291 | 302 | echo ' |
292 | 303 | </select> |
293 | 304 | </dd>'; |
@@ -315,9 +326,10 @@ discard block |
||
315 | 326 | <select id="board_order" name="board_order"', !isset($context['board']['is_new']) ? ' disabled' : '', '> |
316 | 327 | ', !isset($context['board']['is_new']) ? '<option value="">(' . $txt['mboards_unchanged'] . ')</option>' : ''; |
317 | 328 | |
318 | - foreach ($context['board_order'] as $order) |
|
319 | - echo ' |
|
329 | + foreach ($context['board_order'] as $order) { |
|
330 | + echo ' |
|
320 | 331 | <option', $order['selected'] ? ' selected' : '', ' value="', $order['id'], '">', $order['name'], '</option>'; |
332 | + } |
|
321 | 333 | echo ' |
322 | 334 | </select> |
323 | 335 | </dd>'; |
@@ -346,13 +358,15 @@ discard block |
||
346 | 358 | <dd> |
347 | 359 | <select name="profile">'; |
348 | 360 | |
349 | - if (isset($context['board']['is_new'])) |
|
350 | - echo ' |
|
361 | + if (isset($context['board']['is_new'])) { |
|
362 | + echo ' |
|
351 | 363 | <option value="-1">[', $txt['permission_profile_inherit'], ']</option>'; |
364 | + } |
|
352 | 365 | |
353 | - foreach ($context['profiles'] as $id => $profile) |
|
354 | - echo ' |
|
366 | + foreach ($context['profiles'] as $id => $profile) { |
|
367 | + echo ' |
|
355 | 368 | <option value="', $id, '"', $id == $context['board']['profile'] ? ' selected' : '', '>', $profile['name'], '</option>'; |
369 | + } |
|
356 | 370 | |
357 | 371 | echo ' |
358 | 372 | </select> |
@@ -365,8 +379,8 @@ discard block |
||
365 | 379 | </dt> |
366 | 380 | <dd>'; |
367 | 381 | |
368 | - if (!empty($modSettings['deny_boards_access'])) |
|
369 | - echo ' |
|
382 | + if (!empty($modSettings['deny_boards_access'])) { |
|
383 | + echo ' |
|
370 | 384 | <table> |
371 | 385 | <tr> |
372 | 386 | <td></td> |
@@ -374,10 +388,11 @@ discard block |
||
374 | 388 | <th>', $txt['permissions_option_off'], '</th> |
375 | 389 | <th>', $txt['permissions_option_deny'], '</th> |
376 | 390 | </tr>'; |
391 | + } |
|
377 | 392 | |
378 | 393 | // List all the membergroups so the user can choose who may access this board. |
379 | - foreach ($context['groups'] as $group) |
|
380 | - if (empty($modSettings['deny_boards_access'])) |
|
394 | + foreach ($context['groups'] as $group) { |
|
395 | + if (empty($modSettings['deny_boards_access'])) |
|
381 | 396 | echo ' |
382 | 397 | <label for="groups_', $group['id'], '"> |
383 | 398 | <input type="checkbox" name="groups[', $group['id'], ']" value="allow" id="groups_', $group['id'], '"', in_array($group['id'], $context['board_managers']) ? ' checked disabled' : ($group['allow'] ? ' checked' : ''), '> |
@@ -385,8 +400,9 @@ discard block |
||
385 | 400 | ', $group['name'], ' |
386 | 401 | </span> |
387 | 402 | </label><br>'; |
388 | - else |
|
389 | - echo ' |
|
403 | + } |
|
404 | + else { |
|
405 | + echo ' |
|
390 | 406 | <tr> |
391 | 407 | <td> |
392 | 408 | <label for="groups_', $group['id'], '_a"> |
@@ -406,16 +422,17 @@ discard block |
||
406 | 422 | </td> |
407 | 423 | <td></td> |
408 | 424 | </tr>'; |
425 | + } |
|
409 | 426 | |
410 | - if (empty($modSettings['deny_boards_access'])) |
|
411 | - echo ' |
|
427 | + if (empty($modSettings['deny_boards_access'])) { |
|
428 | + echo ' |
|
412 | 429 | <span class="select_all_box"> |
413 | 430 | <em>', $txt['check_all'], '</em> <input type="checkbox" onclick="invertAll(this, this.form, \'groups[\');"> |
414 | 431 | </span> |
415 | 432 | <br><br> |
416 | 433 | </dd>'; |
417 | - else |
|
418 | - echo ' |
|
434 | + } else { |
|
435 | + echo ' |
|
419 | 436 | <tr class="select_all_box"> |
420 | 437 | <td> |
421 | 438 | </td> |
@@ -434,6 +451,7 @@ discard block |
||
434 | 451 | </tr> |
435 | 452 | </table> |
436 | 453 | </dd>'; |
454 | + } |
|
437 | 455 | |
438 | 456 | // Options to choose moderators, specify as announcement board and choose whether to count posts here. |
439 | 457 | echo ' |
@@ -488,8 +506,8 @@ discard block |
||
488 | 506 | </dl> |
489 | 507 | </div>'; |
490 | 508 | |
491 | - if ($context['board']['redirect']) |
|
492 | - echo ' |
|
509 | + if ($context['board']['redirect']) { |
|
510 | + echo ' |
|
493 | 511 | <div id="reset_redirect_div"> |
494 | 512 | <dl class="settings"> |
495 | 513 | <dt> |
@@ -502,6 +520,7 @@ discard block |
||
502 | 520 | </dd> |
503 | 521 | </dl> |
504 | 522 | </div>'; |
523 | + } |
|
505 | 524 | } |
506 | 525 | |
507 | 526 | echo ' |
@@ -529,9 +548,10 @@ discard block |
||
529 | 548 | <select name="boardtheme" id="boardtheme" onchange="refreshOptions();"> |
530 | 549 | <option value="0"', $context['board']['theme'] == 0 ? ' selected' : '', '>', $txt['mboards_theme_default'], '</option>'; |
531 | 550 | |
532 | - foreach ($context['themes'] as $theme) |
|
533 | - echo ' |
|
551 | + foreach ($context['themes'] as $theme) { |
|
552 | + echo ' |
|
534 | 553 | <option value="', $theme['id'], '"', $context['board']['theme'] == $theme['id'] ? ' selected' : '', '>', $theme['name'], '</option>'; |
554 | + } |
|
535 | 555 | |
536 | 556 | echo ' |
537 | 557 | </select> |
@@ -560,14 +580,15 @@ discard block |
||
560 | 580 | |
561 | 581 | foreach ($context['custom_board_settings'] as $cbs_id => $cbs) |
562 | 582 | { |
563 | - if (!empty($cbs['dt']) && !empty($cbs['dd'])) |
|
564 | - echo ' |
|
583 | + if (!empty($cbs['dt']) && !empty($cbs['dd'])) { |
|
584 | + echo ' |
|
565 | 585 | <dt class="clear', !is_numeric($cbs_id) ? ' cbs_' . $cbs_id : '', '"> |
566 | 586 | ', $cbs['dt'], ' |
567 | 587 | </dt> |
568 | 588 | <dd', !is_numeric($cbs_id) ? ' class="cbs_' . $cbs_id . '"' : '', '> |
569 | 589 | ', $cbs['dd'], ' |
570 | 590 | </dd>'; |
591 | + } |
|
571 | 592 | } |
572 | 593 | |
573 | 594 | echo ' |
@@ -575,9 +596,10 @@ discard block |
||
575 | 596 | </div>'; |
576 | 597 | } |
577 | 598 | |
578 | - if (!empty($context['board']['is_recycle'])) |
|
579 | - echo ' |
|
599 | + if (!empty($context['board']['is_recycle'])) { |
|
600 | + echo ' |
|
580 | 601 | <div class="noticebox">', $txt['mboards_recycle_disabled_delete'], '</div>'; |
602 | + } |
|
581 | 603 | |
582 | 604 | echo ' |
583 | 605 | <input type="hidden" name="rid" value="', $context['redirect_location'], '"> |
@@ -585,21 +607,24 @@ discard block |
||
585 | 607 | <input type="hidden" name="', $context['admin-be-' . $context['board']['id'] . '_token_var'], '" value="', $context['admin-be-' . $context['board']['id'] . '_token'], '">'; |
586 | 608 | |
587 | 609 | // If this board has no children don't bother with the next confirmation screen. |
588 | - if ($context['board']['no_children']) |
|
589 | - echo ' |
|
610 | + if ($context['board']['no_children']) { |
|
611 | + echo ' |
|
590 | 612 | <input type="hidden" name="no_children" value="1">'; |
613 | + } |
|
591 | 614 | |
592 | - if (isset($context['board']['is_new'])) |
|
593 | - echo ' |
|
615 | + if (isset($context['board']['is_new'])) { |
|
616 | + echo ' |
|
594 | 617 | <input type="hidden" name="cur_cat" value="', $context['board']['category'], '"> |
595 | 618 | <input type="submit" name="add" value="', $txt['mboards_new_board'], '" onclick="return !isEmptyText(this.form.board_name);" class="button">'; |
596 | - else |
|
597 | - echo ' |
|
619 | + } else { |
|
620 | + echo ' |
|
598 | 621 | <input type="submit" name="edit" value="', $txt['modify'], '" onclick="return !isEmptyText(this.form.board_name);" class="button">'; |
622 | + } |
|
599 | 623 | |
600 | - if (!isset($context['board']['is_new']) && empty($context['board']['is_recycle'])) |
|
601 | - echo ' |
|
624 | + if (!isset($context['board']['is_new']) && empty($context['board']['is_recycle'])) { |
|
625 | + echo ' |
|
602 | 626 | <input type="submit" name="delete" value="', $txt['mboards_delete_board'], '" data-confirm="', $txt['boardConfirm'], '" class="button you_sure">'; |
627 | + } |
|
603 | 628 | echo ' |
604 | 629 | </div><!-- .windowbg --> |
605 | 630 | </form> |
@@ -620,12 +645,13 @@ discard block |
||
620 | 645 | sItemListContainerId: \'moderator_container\', |
621 | 646 | aListItems: ['; |
622 | 647 | |
623 | - foreach ($context['board']['moderators'] as $id_member => $member_name) |
|
624 | - echo ' |
|
648 | + foreach ($context['board']['moderators'] as $id_member => $member_name) { |
|
649 | + echo ' |
|
625 | 650 | { |
626 | 651 | sItemId: ', JavaScriptEscape($id_member), ', |
627 | 652 | sItemName: ', JavaScriptEscape($member_name), ' |
628 | 653 | }', $id_member == $context['board']['last_moderator_id'] ? '' : ','; |
654 | + } |
|
629 | 655 | |
630 | 656 | echo ' |
631 | 657 | ] |
@@ -645,12 +671,13 @@ discard block |
||
645 | 671 | sItemListContainerId: \'moderator_group_container\', |
646 | 672 | aListItems: ['; |
647 | 673 | |
648 | - foreach ($context['board']['moderator_groups'] as $id_group => $group_name) |
|
649 | - echo ' |
|
674 | + foreach ($context['board']['moderator_groups'] as $id_group => $group_name) { |
|
675 | + echo ' |
|
650 | 676 | { |
651 | 677 | sItemId: ', JavaScriptEscape($id_group), ', |
652 | 678 | sItemName: ', JavaScriptEscape($group_name), ' |
653 | 679 | }', $id_group == $context['board']['last_moderator_group_id'] ? '' : ','; |
680 | + } |
|
654 | 681 | |
655 | 682 | echo ' |
656 | 683 | ] |
@@ -689,20 +716,22 @@ discard block |
||
689 | 716 | else |
690 | 717 | document.getElementById("redirect_address_div").classList.add(\'hidden\');'; |
691 | 718 | |
692 | - if ($context['board']['redirect']) |
|
693 | - echo ' |
|
719 | + if ($context['board']['redirect']) { |
|
720 | + echo ' |
|
694 | 721 | if(redirectEnabled) |
695 | 722 | document.getElementById("reset_redirect_div").classList.remove(\'hidden\'); |
696 | 723 | else |
697 | 724 | document.getElementById("reset_redirect_div").classList.add(\'hidden\');'; |
725 | + } |
|
698 | 726 | } |
699 | 727 | |
700 | 728 | // Include any JavaScript added by mods using the 'integrate_edit_board' hook. |
701 | 729 | if (!empty($context['custom_refreshOptions']) && is_array($context['custom_refreshOptions'])) |
702 | 730 | { |
703 | - foreach ($context['custom_refreshOptions'] as $refreshOption) |
|
704 | - echo ' |
|
731 | + foreach ($context['custom_refreshOptions'] as $refreshOption) { |
|
732 | + echo ' |
|
705 | 733 | ', $refreshOption; |
734 | + } |
|
706 | 735 | } |
707 | 736 | |
708 | 737 | echo ' |
@@ -731,9 +760,10 @@ discard block |
||
731 | 760 | <p>', $txt['mboards_delete_board_contains'], '</p> |
732 | 761 | <ul>'; |
733 | 762 | |
734 | - foreach ($context['children'] as $child) |
|
735 | - echo ' |
|
763 | + foreach ($context['children'] as $child) { |
|
764 | + echo ' |
|
736 | 765 | <li>', $child['node']['name'], '</li>'; |
766 | + } |
|
737 | 767 | |
738 | 768 | echo ' |
739 | 769 | </ul> |
@@ -747,10 +777,11 @@ discard block |
||
747 | 777 | <label for="delete_action1"><input type="radio" id="delete_action1" name="delete_action" value="1"', empty($context['can_move_children']) ? ' disabled' : '', '>', $txt['mboards_delete_board_option2'], '</label>: |
748 | 778 | <select name="board_to"', empty($context['can_move_children']) ? ' disabled' : '', '>'; |
749 | 779 | |
750 | - foreach ($context['board_order'] as $board) |
|
751 | - if ($board['id'] != $context['board']['id'] && empty($board['is_child'])) |
|
780 | + foreach ($context['board_order'] as $board) { |
|
781 | + if ($board['id'] != $context['board']['id'] && empty($board['is_child'])) |
|
752 | 782 | echo ' |
753 | 783 | <option value="', $board['id'], '">', $board['name'], '</option>'; |
784 | + } |
|
754 | 785 | |
755 | 786 | echo ' |
756 | 787 | </select> |