@@ -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 | * Load the $modSettings array. |
@@ -25,13 +26,14 @@ discard block |
||
25 | 26 | global $cache_enable, $sourcedir, $context; |
26 | 27 | |
27 | 28 | // Most database systems have not set UTF-8 as their default input charset. |
28 | - if (!empty($db_character_set)) |
|
29 | - $smcFunc['db_query']('', ' |
|
29 | + if (!empty($db_character_set)) { |
|
30 | + $smcFunc['db_query']('', ' |
|
30 | 31 | SET NAMES {string:db_character_set}', |
31 | 32 | array( |
32 | 33 | 'db_character_set' => $db_character_set, |
33 | 34 | ) |
34 | 35 | ); |
36 | + } |
|
35 | 37 | |
36 | 38 | // We need some caching support, maybe. |
37 | 39 | loadCacheAccelerator(); |
@@ -46,28 +48,36 @@ discard block |
||
46 | 48 | ) |
47 | 49 | ); |
48 | 50 | $modSettings = array(); |
49 | - if (!$request) |
|
50 | - display_db_error(); |
|
51 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
52 | - $modSettings[$row[0]] = $row[1]; |
|
51 | + if (!$request) { |
|
52 | + display_db_error(); |
|
53 | + } |
|
54 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
55 | + $modSettings[$row[0]] = $row[1]; |
|
56 | + } |
|
53 | 57 | $smcFunc['db_free_result']($request); |
54 | 58 | |
55 | 59 | // Do a few things to protect against missing settings or settings with invalid values... |
56 | - if (empty($modSettings['defaultMaxTopics']) || $modSettings['defaultMaxTopics'] <= 0 || $modSettings['defaultMaxTopics'] > 999) |
|
57 | - $modSettings['defaultMaxTopics'] = 20; |
|
58 | - if (empty($modSettings['defaultMaxMessages']) || $modSettings['defaultMaxMessages'] <= 0 || $modSettings['defaultMaxMessages'] > 999) |
|
59 | - $modSettings['defaultMaxMessages'] = 15; |
|
60 | - if (empty($modSettings['defaultMaxMembers']) || $modSettings['defaultMaxMembers'] <= 0 || $modSettings['defaultMaxMembers'] > 999) |
|
61 | - $modSettings['defaultMaxMembers'] = 30; |
|
62 | - if (empty($modSettings['defaultMaxListItems']) || $modSettings['defaultMaxListItems'] <= 0 || $modSettings['defaultMaxListItems'] > 999) |
|
63 | - $modSettings['defaultMaxListItems'] = 15; |
|
60 | + if (empty($modSettings['defaultMaxTopics']) || $modSettings['defaultMaxTopics'] <= 0 || $modSettings['defaultMaxTopics'] > 999) { |
|
61 | + $modSettings['defaultMaxTopics'] = 20; |
|
62 | + } |
|
63 | + if (empty($modSettings['defaultMaxMessages']) || $modSettings['defaultMaxMessages'] <= 0 || $modSettings['defaultMaxMessages'] > 999) { |
|
64 | + $modSettings['defaultMaxMessages'] = 15; |
|
65 | + } |
|
66 | + if (empty($modSettings['defaultMaxMembers']) || $modSettings['defaultMaxMembers'] <= 0 || $modSettings['defaultMaxMembers'] > 999) { |
|
67 | + $modSettings['defaultMaxMembers'] = 30; |
|
68 | + } |
|
69 | + if (empty($modSettings['defaultMaxListItems']) || $modSettings['defaultMaxListItems'] <= 0 || $modSettings['defaultMaxListItems'] > 999) { |
|
70 | + $modSettings['defaultMaxListItems'] = 15; |
|
71 | + } |
|
64 | 72 | |
65 | 73 | // We excpiclity do not use $smcFunc['json_decode'] here yet, as $smcFunc is not fully loaded. |
66 | - if (!is_array($modSettings['attachmentUploadDir'])) |
|
67 | - $modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
|
74 | + if (!is_array($modSettings['attachmentUploadDir'])) { |
|
75 | + $modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
|
76 | + } |
|
68 | 77 | |
69 | - if (!empty($cache_enable)) |
|
70 | - cache_put_data('modSettings', $modSettings, 90); |
|
78 | + if (!empty($cache_enable)) { |
|
79 | + cache_put_data('modSettings', $modSettings, 90); |
|
80 | + } |
|
71 | 81 | } |
72 | 82 | |
73 | 83 | $modSettings['cache_enable'] = $cache_enable; |
@@ -87,8 +97,9 @@ discard block |
||
87 | 97 | }; |
88 | 98 | $fix_utf8mb4 = function($string) use ($utf8, $smcFunc) |
89 | 99 | { |
90 | - if (!$utf8 || $smcFunc['db_mb4']) |
|
91 | - return $string; |
|
100 | + if (!$utf8 || $smcFunc['db_mb4']) { |
|
101 | + return $string; |
|
102 | + } |
|
92 | 103 | |
93 | 104 | $i = 0; |
94 | 105 | $len = strlen($string); |
@@ -100,18 +111,15 @@ discard block |
||
100 | 111 | { |
101 | 112 | $new_string .= $string[$i]; |
102 | 113 | $i++; |
103 | - } |
|
104 | - elseif ($ord < 224) |
|
114 | + } elseif ($ord < 224) |
|
105 | 115 | { |
106 | 116 | $new_string .= $string[$i] . $string[$i + 1]; |
107 | 117 | $i += 2; |
108 | - } |
|
109 | - elseif ($ord < 240) |
|
118 | + } elseif ($ord < 240) |
|
110 | 119 | { |
111 | 120 | $new_string .= $string[$i] . $string[$i + 1] . $string[$i + 2]; |
112 | 121 | $i += 3; |
113 | - } |
|
114 | - elseif ($ord < 248) |
|
122 | + } elseif ($ord < 248) |
|
115 | 123 | { |
116 | 124 | // Magic happens. |
117 | 125 | $val = (ord($string[$i]) & 0x07) << 18; |
@@ -155,8 +163,7 @@ discard block |
||
155 | 163 | { |
156 | 164 | $result = array_search($needle, array_slice($haystack_arr, $offset)); |
157 | 165 | return is_int($result) ? $result + $offset : false; |
158 | - } |
|
159 | - else |
|
166 | + } else |
|
160 | 167 | { |
161 | 168 | $needle_arr = preg_split('~(&#' . (empty($modSettings['disableEntityCheck']) ? '\d{1,7}' : '021') . ';|"|&|<|>| |.)~' . ($utf8 ? 'u' : '') . '', $ent_check($needle), -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); |
162 | 169 | $needle_size = count($needle_arr); |
@@ -165,8 +172,9 @@ discard block |
||
165 | 172 | while ((int) $result === $result) |
166 | 173 | { |
167 | 174 | $offset += $result; |
168 | - if (array_slice($haystack_arr, $offset, $needle_size) === $needle_arr) |
|
169 | - return $offset; |
|
175 | + if (array_slice($haystack_arr, $offset, $needle_size) === $needle_arr) { |
|
176 | + return $offset; |
|
177 | + } |
|
170 | 178 | $result = array_search($needle_arr[0], array_slice($haystack_arr, ++$offset)); |
171 | 179 | } |
172 | 180 | return false; |
@@ -204,8 +212,9 @@ discard block |
||
204 | 212 | $string = $ent_check($string); |
205 | 213 | preg_match('~^(' . $ent_list . '|.){' . $smcFunc['strlen'](substr($string, 0, $length)) . '}~' . ($utf8 ? 'u' : ''), $string, $matches); |
206 | 214 | $string = $matches[0]; |
207 | - while (strlen($string) > $length) |
|
208 | - $string = preg_replace('~(?:' . $ent_list . '|.)$~' . ($utf8 ? 'u' : ''), '', $string); |
|
215 | + while (strlen($string) > $length) { |
|
216 | + $string = preg_replace('~(?:' . $ent_list . '|.)$~' . ($utf8 ? 'u' : ''), '', $string); |
|
217 | + } |
|
209 | 218 | return $string; |
210 | 219 | }, |
211 | 220 | 'ucfirst' => $utf8 ? function($string) use (&$smcFunc) |
@@ -215,8 +224,9 @@ discard block |
||
215 | 224 | 'ucwords' => $utf8 ? function($string) use (&$smcFunc) |
216 | 225 | { |
217 | 226 | $words = preg_split('~([\s\r\n\t]+)~', $string, -1, PREG_SPLIT_DELIM_CAPTURE); |
218 | - for ($i = 0, $n = count($words); $i < $n; $i += 2) |
|
219 | - $words[$i] = $smcFunc['ucfirst']($words[$i]); |
|
227 | + for ($i = 0, $n = count($words); $i < $n; $i += 2) { |
|
228 | + $words[$i] = $smcFunc['ucfirst']($words[$i]); |
|
229 | + } |
|
220 | 230 | return implode('', $words); |
221 | 231 | } : 'ucwords', |
222 | 232 | 'json_decode' => 'smf_json_decode', |
@@ -224,16 +234,17 @@ discard block |
||
224 | 234 | ); |
225 | 235 | |
226 | 236 | // Setting the timezone is a requirement for some functions. |
227 | - if (isset($modSettings['default_timezone']) && in_array($modSettings['default_timezone'], timezone_identifiers_list())) |
|
228 | - date_default_timezone_set($modSettings['default_timezone']); |
|
229 | - else |
|
237 | + if (isset($modSettings['default_timezone']) && in_array($modSettings['default_timezone'], timezone_identifiers_list())) { |
|
238 | + date_default_timezone_set($modSettings['default_timezone']); |
|
239 | + } else |
|
230 | 240 | { |
231 | 241 | // Get PHP's default timezone, if set |
232 | 242 | $ini_tz = ini_get('date.timezone'); |
233 | - if (!empty($ini_tz)) |
|
234 | - $modSettings['default_timezone'] = $ini_tz; |
|
235 | - else |
|
236 | - $modSettings['default_timezone'] = ''; |
|
243 | + if (!empty($ini_tz)) { |
|
244 | + $modSettings['default_timezone'] = $ini_tz; |
|
245 | + } else { |
|
246 | + $modSettings['default_timezone'] = ''; |
|
247 | + } |
|
237 | 248 | |
238 | 249 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
239 | 250 | if (!in_array($modSettings['default_timezone'], timezone_identifiers_list())) |
@@ -251,22 +262,26 @@ discard block |
||
251 | 262 | if (($modSettings['load_average'] = cache_get_data('loadavg', 90)) == null) |
252 | 263 | { |
253 | 264 | $modSettings['load_average'] = @file_get_contents('/proc/loadavg'); |
254 | - if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) != 0) |
|
255 | - $modSettings['load_average'] = (float) $matches[1]; |
|
256 | - elseif (($modSettings['load_average'] = @`uptime`) != null && preg_match('~load average[s]?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) != 0) |
|
257 | - $modSettings['load_average'] = (float) $matches[1]; |
|
258 | - else |
|
259 | - unset($modSettings['load_average']); |
|
265 | + if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) != 0) { |
|
266 | + $modSettings['load_average'] = (float) $matches[1]; |
|
267 | + } elseif (($modSettings['load_average'] = @`uptime`) != null && preg_match('~load average[s]?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) != 0) { |
|
268 | + $modSettings['load_average'] = (float) $matches[1]; |
|
269 | + } else { |
|
270 | + unset($modSettings['load_average']); |
|
271 | + } |
|
260 | 272 | |
261 | - if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) |
|
262 | - cache_put_data('loadavg', $modSettings['load_average'], 90); |
|
273 | + if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) { |
|
274 | + cache_put_data('loadavg', $modSettings['load_average'], 90); |
|
275 | + } |
|
263 | 276 | } |
264 | 277 | |
265 | - if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) |
|
266 | - call_integration_hook('integrate_load_average', array($modSettings['load_average'])); |
|
278 | + if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) { |
|
279 | + call_integration_hook('integrate_load_average', array($modSettings['load_average'])); |
|
280 | + } |
|
267 | 281 | |
268 | - if (!empty($modSettings['loadavg_forum']) && !empty($modSettings['load_average']) && $modSettings['load_average'] >= $modSettings['loadavg_forum']) |
|
269 | - display_loadavg_error(); |
|
282 | + if (!empty($modSettings['loadavg_forum']) && !empty($modSettings['load_average']) && $modSettings['load_average'] >= $modSettings['loadavg_forum']) { |
|
283 | + display_loadavg_error(); |
|
284 | + } |
|
270 | 285 | } |
271 | 286 | |
272 | 287 | // Is post moderation alive and well? Everywhere else assumes this has been defined, so let's make sure it is. |
@@ -287,8 +302,9 @@ discard block |
||
287 | 302 | if (defined('SMF_INTEGRATION_SETTINGS')) |
288 | 303 | { |
289 | 304 | $integration_settings = $smcFUnc['json_decode'](SMF_INTEGRATION_SETTINGS, true); |
290 | - foreach ($integration_settings as $hook => $function) |
|
291 | - add_integration_function($hook, $function, '', false); |
|
305 | + foreach ($integration_settings as $hook => $function) { |
|
306 | + add_integration_function($hook, $function, '', false); |
|
307 | + } |
|
292 | 308 | } |
293 | 309 | |
294 | 310 | // Any files to pre include? |
@@ -298,8 +314,9 @@ discard block |
||
298 | 314 | foreach ($pre_includes as $include) |
299 | 315 | { |
300 | 316 | $include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
301 | - if (file_exists($include)) |
|
302 | - require_once($include); |
|
317 | + if (file_exists($include)) { |
|
318 | + require_once($include); |
|
319 | + } |
|
303 | 320 | } |
304 | 321 | } |
305 | 322 | |
@@ -403,27 +420,28 @@ discard block |
||
403 | 420 | break; |
404 | 421 | } |
405 | 422 | } |
423 | + } else { |
|
424 | + $id_member = 0; |
|
406 | 425 | } |
407 | - else |
|
408 | - $id_member = 0; |
|
409 | 426 | |
410 | 427 | if (empty($id_member) && isset($_COOKIE[$cookiename])) |
411 | 428 | { |
412 | 429 | $cookie_data = $smcFunc['json_decode']($_COOKIE[$cookiename], true, false); |
413 | 430 | |
414 | - if (empty($cookie_data)) |
|
415 | - $cookie_data = safe_unserialize($_COOKIE[$cookiename]); |
|
431 | + if (empty($cookie_data)) { |
|
432 | + $cookie_data = safe_unserialize($_COOKIE[$cookiename]); |
|
433 | + } |
|
416 | 434 | |
417 | 435 | list ($id_member, $password) = $cookie_data; |
418 | 436 | $id_member = !empty($id_member) && strlen($password) > 0 ? (int) $id_member : 0; |
419 | - } |
|
420 | - elseif (empty($id_member) && isset($_SESSION['login_' . $cookiename]) && ($_SESSION['USER_AGENT'] == $_SERVER['HTTP_USER_AGENT'] || !empty($modSettings['disableCheckUA']))) |
|
437 | + } elseif (empty($id_member) && isset($_SESSION['login_' . $cookiename]) && ($_SESSION['USER_AGENT'] == $_SERVER['HTTP_USER_AGENT'] || !empty($modSettings['disableCheckUA']))) |
|
421 | 438 | { |
422 | 439 | // @todo Perhaps we can do some more checking on this, such as on the first octet of the IP? |
423 | 440 | $cookie_data = $smcFunc['json_decode']($_SESSION['login_' . $cookiename]); |
424 | 441 | |
425 | - if (empty($cookie_data)) |
|
426 | - $cookie_data = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
442 | + if (empty($cookie_data)) { |
|
443 | + $cookie_data = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
444 | + } |
|
427 | 445 | |
428 | 446 | list ($id_member, $password, $login_span) = $cookie_data; |
429 | 447 | $id_member = !empty($id_member) && strlen($password) == 128 && $login_span > time() ? (int) $id_member : 0; |
@@ -448,30 +466,34 @@ discard block |
||
448 | 466 | $user_settings = $smcFunc['db_fetch_assoc']($request); |
449 | 467 | $smcFunc['db_free_result']($request); |
450 | 468 | |
451 | - if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($user_settings['avatar'], 'http://') !== false) |
|
452 | - $user_settings['avatar'] = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($user_settings['avatar']) . '&hash=' . md5($user_settings['avatar'] . $image_proxy_secret); |
|
469 | + if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($user_settings['avatar'], 'http://') !== false) { |
|
470 | + $user_settings['avatar'] = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($user_settings['avatar']) . '&hash=' . md5($user_settings['avatar'] . $image_proxy_secret); |
|
471 | + } |
|
453 | 472 | |
454 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
455 | - cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
473 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
474 | + cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
475 | + } |
|
456 | 476 | } |
457 | 477 | |
458 | 478 | // Did we find 'im? If not, junk it. |
459 | 479 | if (!empty($user_settings)) |
460 | 480 | { |
461 | 481 | // As much as the password should be right, we can assume the integration set things up. |
462 | - if (!empty($already_verified) && $already_verified === true) |
|
463 | - $check = true; |
|
482 | + if (!empty($already_verified) && $already_verified === true) { |
|
483 | + $check = true; |
|
484 | + } |
|
464 | 485 | // SHA-512 hash should be 128 characters long. |
465 | - elseif (strlen($password) == 128) |
|
466 | - $check = hash_salt($user_settings['passwd'], $user_settings['password_salt']) == $password; |
|
467 | - else |
|
468 | - $check = false; |
|
486 | + elseif (strlen($password) == 128) { |
|
487 | + $check = hash_salt($user_settings['passwd'], $user_settings['password_salt']) == $password; |
|
488 | + } else { |
|
489 | + $check = false; |
|
490 | + } |
|
469 | 491 | |
470 | 492 | // Wrong password or not activated - either way, you're going nowhere. |
471 | 493 | $id_member = $check && ($user_settings['is_activated'] == 1 || $user_settings['is_activated'] == 11) ? (int) $user_settings['id_member'] : 0; |
494 | + } else { |
|
495 | + $id_member = 0; |
|
472 | 496 | } |
473 | - else |
|
474 | - $id_member = 0; |
|
475 | 497 | |
476 | 498 | // If we no longer have the member maybe they're being all hackey, stop brute force! |
477 | 499 | if (!$id_member) |
@@ -495,8 +517,9 @@ discard block |
||
495 | 517 | |
496 | 518 | list ($tfamember, $tfasecret) = $tfa_data; |
497 | 519 | |
498 | - if (!isset($tfamember, $tfasecret) || (int) $tfamember != $id_member) |
|
499 | - $tfasecret = null; |
|
520 | + if (!isset($tfamember, $tfasecret) || (int) $tfamember != $id_member) { |
|
521 | + $tfasecret = null; |
|
522 | + } |
|
500 | 523 | } |
501 | 524 | |
502 | 525 | if (empty($tfasecret) || hash_salt($user_settings['tfa_backup'], $user_settings['password_salt']) != $tfasecret) |
@@ -516,10 +539,12 @@ discard block |
||
516 | 539 | // Are we forcing 2FA? Need to check if the user groups actually require 2FA |
517 | 540 | elseif (!empty($modSettings['tfa_mode']) && $modSettings['tfa_mode'] >= 2 && $id_member && empty($user_settings['tfa_secret'])) |
518 | 541 | { |
519 | - if ($modSettings['tfa_mode'] == 2) //only do this if we are just forcing SOME membergroups |
|
542 | + if ($modSettings['tfa_mode'] == 2) { |
|
543 | + //only do this if we are just forcing SOME membergroups |
|
520 | 544 | { |
521 | 545 | //Build an array of ALL user membergroups. |
522 | 546 | $full_groups = array($user_settings['id_group']); |
547 | + } |
|
523 | 548 | if (!empty($user_settings['additional_groups'])) |
524 | 549 | { |
525 | 550 | $full_groups = array_merge($full_groups, explode(',', $user_settings['additional_groups'])); |
@@ -539,15 +564,17 @@ discard block |
||
539 | 564 | ); |
540 | 565 | $row = $smcFunc['db_fetch_assoc']($request); |
541 | 566 | $smcFunc['db_free_result']($request); |
567 | + } else { |
|
568 | + $row['total'] = 1; |
|
542 | 569 | } |
543 | - else |
|
544 | - $row['total'] = 1; //simplifies logics in the next "if" |
|
570 | + //simplifies logics in the next "if" |
|
545 | 571 | |
546 | 572 | $area = !empty($_REQUEST['area']) ? $_REQUEST['area'] : ''; |
547 | 573 | $action = !empty($_REQUEST['action']) ? $_REQUEST['action'] : ''; |
548 | 574 | |
549 | - if ($row['total'] > 0 && !in_array($action, array('profile', 'logout')) || ($action == 'profile' && $area != 'tfasetup')) |
|
550 | - redirectexit('action=profile;area=tfasetup;forced'); |
|
575 | + if ($row['total'] > 0 && !in_array($action, array('profile', 'logout')) || ($action == 'profile' && $area != 'tfasetup')) { |
|
576 | + redirectexit('action=profile;area=tfasetup;forced'); |
|
577 | + } |
|
551 | 578 | } |
552 | 579 | } |
553 | 580 | |
@@ -584,33 +611,37 @@ discard block |
||
584 | 611 | updateMemberData($id_member, array('id_msg_last_visit' => (int) $modSettings['maxMsgID'], 'last_login' => time(), 'member_ip' => $_SERVER['REMOTE_ADDR'], 'member_ip2' => $_SERVER['BAN_CHECK_IP'])); |
585 | 612 | $user_settings['last_login'] = time(); |
586 | 613 | |
587 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
588 | - cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
614 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
615 | + cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
616 | + } |
|
589 | 617 | |
590 | - if (!empty($modSettings['cache_enable'])) |
|
591 | - cache_put_data('user_last_visit-' . $id_member, $_SESSION['id_msg_last_visit'], 5 * 3600); |
|
618 | + if (!empty($modSettings['cache_enable'])) { |
|
619 | + cache_put_data('user_last_visit-' . $id_member, $_SESSION['id_msg_last_visit'], 5 * 3600); |
|
620 | + } |
|
592 | 621 | } |
622 | + } elseif (empty($_SESSION['id_msg_last_visit'])) { |
|
623 | + $_SESSION['id_msg_last_visit'] = $user_settings['id_msg_last_visit']; |
|
593 | 624 | } |
594 | - elseif (empty($_SESSION['id_msg_last_visit'])) |
|
595 | - $_SESSION['id_msg_last_visit'] = $user_settings['id_msg_last_visit']; |
|
596 | 625 | |
597 | 626 | $username = $user_settings['member_name']; |
598 | 627 | |
599 | - if (empty($user_settings['additional_groups'])) |
|
600 | - $user_info = array( |
|
628 | + if (empty($user_settings['additional_groups'])) { |
|
629 | + $user_info = array( |
|
601 | 630 | 'groups' => array($user_settings['id_group'], $user_settings['id_post_group']) |
602 | 631 | ); |
603 | - else |
|
604 | - $user_info = array( |
|
632 | + } else { |
|
633 | + $user_info = array( |
|
605 | 634 | 'groups' => array_merge( |
606 | 635 | array($user_settings['id_group'], $user_settings['id_post_group']), |
607 | 636 | explode(',', $user_settings['additional_groups']) |
608 | 637 | ) |
609 | 638 | ); |
639 | + } |
|
610 | 640 | |
611 | 641 | // Because history has proven that it is possible for groups to go bad - clean up in case. |
612 | - foreach ($user_info['groups'] as $k => $v) |
|
613 | - $user_info['groups'][$k] = (int) $v; |
|
642 | + foreach ($user_info['groups'] as $k => $v) { |
|
643 | + $user_info['groups'][$k] = (int) $v; |
|
644 | + } |
|
614 | 645 | |
615 | 646 | // This is a logged in user, so definitely not a spider. |
616 | 647 | $user_info['possibly_robot'] = false; |
@@ -624,8 +655,7 @@ discard block |
||
624 | 655 | $time_system = new DateTime('now', $tz_system); |
625 | 656 | $time_user = new DateTime('now', $tz_user); |
626 | 657 | $user_info['time_offset'] = ($tz_user->getOffset($time_user) - $tz_system->getOffset($time_system)) / 3600; |
627 | - } |
|
628 | - else |
|
658 | + } else |
|
629 | 659 | { |
630 | 660 | // !!! Compatibility. |
631 | 661 | $user_info['time_offset'] = empty($user_settings['time_offset']) ? 0 : $user_settings['time_offset']; |
@@ -639,8 +669,9 @@ discard block |
||
639 | 669 | $user_info = array('groups' => array(-1)); |
640 | 670 | $user_settings = array(); |
641 | 671 | |
642 | - if (isset($_COOKIE[$cookiename]) && empty($context['tfa_member'])) |
|
643 | - $_COOKIE[$cookiename] = ''; |
|
672 | + if (isset($_COOKIE[$cookiename]) && empty($context['tfa_member'])) { |
|
673 | + $_COOKIE[$cookiename] = ''; |
|
674 | + } |
|
644 | 675 | |
645 | 676 | // Expire the 2FA cookie |
646 | 677 | if (isset($_COOKIE[$cookiename . '_tfa']) && empty($context['tfa_member'])) |
@@ -657,19 +688,20 @@ discard block |
||
657 | 688 | } |
658 | 689 | |
659 | 690 | // Create a login token if it doesn't exist yet. |
660 | - if (!isset($_SESSION['token']['post-login'])) |
|
661 | - createToken('login'); |
|
662 | - else |
|
663 | - list ($context['login_token_var'],,, $context['login_token']) = $_SESSION['token']['post-login']; |
|
691 | + if (!isset($_SESSION['token']['post-login'])) { |
|
692 | + createToken('login'); |
|
693 | + } else { |
|
694 | + list ($context['login_token_var'],,, $context['login_token']) = $_SESSION['token']['post-login']; |
|
695 | + } |
|
664 | 696 | |
665 | 697 | // Do we perhaps think this is a search robot? Check every five minutes just in case... |
666 | 698 | if ((!empty($modSettings['spider_mode']) || !empty($modSettings['spider_group'])) && (!isset($_SESSION['robot_check']) || $_SESSION['robot_check'] < time() - 300)) |
667 | 699 | { |
668 | 700 | require_once($sourcedir . '/ManageSearchEngines.php'); |
669 | 701 | $user_info['possibly_robot'] = SpiderCheck(); |
702 | + } elseif (!empty($modSettings['spider_mode'])) { |
|
703 | + $user_info['possibly_robot'] = isset($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0; |
|
670 | 704 | } |
671 | - elseif (!empty($modSettings['spider_mode'])) |
|
672 | - $user_info['possibly_robot'] = isset($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0; |
|
673 | 705 | // If we haven't turned on proper spider hunts then have a guess! |
674 | 706 | else |
675 | 707 | { |
@@ -717,8 +749,9 @@ discard block |
||
717 | 749 | $user_info['groups'] = array_unique($user_info['groups']); |
718 | 750 | |
719 | 751 | // Make sure that the last item in the ignore boards array is valid. If the list was too long it could have an ending comma that could cause problems. |
720 | - if (!empty($user_info['ignoreboards']) && empty($user_info['ignoreboards'][$tmp = count($user_info['ignoreboards']) - 1])) |
|
721 | - unset($user_info['ignoreboards'][$tmp]); |
|
752 | + if (!empty($user_info['ignoreboards']) && empty($user_info['ignoreboards'][$tmp = count($user_info['ignoreboards']) - 1])) { |
|
753 | + unset($user_info['ignoreboards'][$tmp]); |
|
754 | + } |
|
722 | 755 | |
723 | 756 | // Allow the user to change their language. |
724 | 757 | if (!empty($modSettings['userLanguage'])) |
@@ -731,31 +764,36 @@ discard block |
||
731 | 764 | $user_info['language'] = strtr($_GET['language'], './\\:', '____'); |
732 | 765 | |
733 | 766 | // Make it permanent for members. |
734 | - if (!empty($user_info['id'])) |
|
735 | - updateMemberData($user_info['id'], array('lngfile' => $user_info['language'])); |
|
736 | - else |
|
737 | - $_SESSION['language'] = $user_info['language']; |
|
767 | + if (!empty($user_info['id'])) { |
|
768 | + updateMemberData($user_info['id'], array('lngfile' => $user_info['language'])); |
|
769 | + } else { |
|
770 | + $_SESSION['language'] = $user_info['language']; |
|
771 | + } |
|
772 | + } elseif (!empty($_SESSION['language']) && isset($languages[strtr($_SESSION['language'], './\\:', '____')])) { |
|
773 | + $user_info['language'] = strtr($_SESSION['language'], './\\:', '____'); |
|
738 | 774 | } |
739 | - elseif (!empty($_SESSION['language']) && isset($languages[strtr($_SESSION['language'], './\\:', '____')])) |
|
740 | - $user_info['language'] = strtr($_SESSION['language'], './\\:', '____'); |
|
741 | 775 | } |
742 | 776 | |
743 | 777 | // Just build this here, it makes it easier to change/use - administrators can see all boards. |
744 | - if ($user_info['is_admin']) |
|
745 | - $user_info['query_see_board'] = '1=1'; |
|
778 | + if ($user_info['is_admin']) { |
|
779 | + $user_info['query_see_board'] = '1=1'; |
|
780 | + } |
|
746 | 781 | // Otherwise just the groups in $user_info['groups']. |
747 | - else |
|
748 | - $user_info['query_see_board'] = '((FIND_IN_SET(' . implode(', b.member_groups) != 0 OR FIND_IN_SET(', $user_info['groups']) . ', b.member_groups) != 0)' . (!empty($modSettings['deny_boards_access']) ? ' AND (FIND_IN_SET(' . implode(', b.deny_member_groups) = 0 AND FIND_IN_SET(', $user_info['groups']) . ', b.deny_member_groups) = 0)' : '') . (isset($user_info['mod_cache']) ? ' OR ' . $user_info['mod_cache']['mq'] : '') . ')'; |
|
782 | + else { |
|
783 | + $user_info['query_see_board'] = '((FIND_IN_SET(' . implode(', b.member_groups) != 0 OR FIND_IN_SET(', $user_info['groups']) . ', b.member_groups) != 0)' . (!empty($modSettings['deny_boards_access']) ? ' AND (FIND_IN_SET(' . implode(', b.deny_member_groups) = 0 AND FIND_IN_SET(', $user_info['groups']) . ', b.deny_member_groups) = 0)' : '') . (isset($user_info['mod_cache']) ? ' OR ' . $user_info['mod_cache']['mq'] : '') . ')'; |
|
784 | + } |
|
749 | 785 | |
750 | 786 | // Build the list of boards they WANT to see. |
751 | 787 | // This will take the place of query_see_boards in certain spots, so it better include the boards they can see also |
752 | 788 | |
753 | 789 | // If they aren't ignoring any boards then they want to see all the boards they can see |
754 | - if (empty($user_info['ignoreboards'])) |
|
755 | - $user_info['query_wanna_see_board'] = $user_info['query_see_board']; |
|
790 | + if (empty($user_info['ignoreboards'])) { |
|
791 | + $user_info['query_wanna_see_board'] = $user_info['query_see_board']; |
|
792 | + } |
|
756 | 793 | // Ok I guess they don't want to see all the boards |
757 | - else |
|
758 | - $user_info['query_wanna_see_board'] = '(' . $user_info['query_see_board'] . ' AND b.id_board NOT IN (' . implode(',', $user_info['ignoreboards']) . '))'; |
|
794 | + else { |
|
795 | + $user_info['query_wanna_see_board'] = '(' . $user_info['query_see_board'] . ' AND b.id_board NOT IN (' . implode(',', $user_info['ignoreboards']) . '))'; |
|
796 | + } |
|
759 | 797 | |
760 | 798 | call_integration_hook('integrate_user_info'); |
761 | 799 | } |
@@ -813,9 +851,9 @@ discard block |
||
813 | 851 | } |
814 | 852 | |
815 | 853 | // Remember redirection is the key to avoiding fallout from your bosses. |
816 | - if (!empty($topic)) |
|
817 | - redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg']); |
|
818 | - else |
|
854 | + if (!empty($topic)) { |
|
855 | + redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg']); |
|
856 | + } else |
|
819 | 857 | { |
820 | 858 | loadPermissions(); |
821 | 859 | loadTheme(); |
@@ -833,10 +871,11 @@ discard block |
||
833 | 871 | if (!empty($modSettings['cache_enable']) && (empty($topic) || $modSettings['cache_enable'] >= 3)) |
834 | 872 | { |
835 | 873 | // @todo SLOW? |
836 | - if (!empty($topic)) |
|
837 | - $temp = cache_get_data('topic_board-' . $topic, 120); |
|
838 | - else |
|
839 | - $temp = cache_get_data('board-' . $board, 120); |
|
874 | + if (!empty($topic)) { |
|
875 | + $temp = cache_get_data('topic_board-' . $topic, 120); |
|
876 | + } else { |
|
877 | + $temp = cache_get_data('board-' . $board, 120); |
|
878 | + } |
|
840 | 879 | |
841 | 880 | if (!empty($temp)) |
842 | 881 | { |
@@ -874,8 +913,9 @@ discard block |
||
874 | 913 | $row = $smcFunc['db_fetch_assoc']($request); |
875 | 914 | |
876 | 915 | // Set the current board. |
877 | - if (!empty($row['id_board'])) |
|
878 | - $board = $row['id_board']; |
|
916 | + if (!empty($row['id_board'])) { |
|
917 | + $board = $row['id_board']; |
|
918 | + } |
|
879 | 919 | |
880 | 920 | // Basic operating information. (globals... :/) |
881 | 921 | $board_info = array( |
@@ -911,21 +951,23 @@ discard block |
||
911 | 951 | |
912 | 952 | do |
913 | 953 | { |
914 | - if (!empty($row['id_moderator'])) |
|
915 | - $board_info['moderators'][$row['id_moderator']] = array( |
|
954 | + if (!empty($row['id_moderator'])) { |
|
955 | + $board_info['moderators'][$row['id_moderator']] = array( |
|
916 | 956 | 'id' => $row['id_moderator'], |
917 | 957 | 'name' => $row['real_name'], |
918 | 958 | 'href' => $scripturl . '?action=profile;u=' . $row['id_moderator'], |
919 | 959 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_moderator'] . '">' . $row['real_name'] . '</a>' |
920 | 960 | ); |
961 | + } |
|
921 | 962 | |
922 | - if (!empty($row['id_moderator_group'])) |
|
923 | - $board_info['moderator_groups'][$row['id_moderator_group']] = array( |
|
963 | + if (!empty($row['id_moderator_group'])) { |
|
964 | + $board_info['moderator_groups'][$row['id_moderator_group']] = array( |
|
924 | 965 | 'id' => $row['id_moderator_group'], |
925 | 966 | 'name' => $row['group_name'], |
926 | 967 | 'href' => $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'], |
927 | 968 | 'link' => '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'] . '">' . $row['group_name'] . '</a>' |
928 | 969 | ); |
970 | + } |
|
929 | 971 | } |
930 | 972 | while ($row = $smcFunc['db_fetch_assoc']($request)); |
931 | 973 | |
@@ -957,12 +999,12 @@ discard block |
||
957 | 999 | if (!empty($modSettings['cache_enable']) && (empty($topic) || $modSettings['cache_enable'] >= 3)) |
958 | 1000 | { |
959 | 1001 | // @todo SLOW? |
960 | - if (!empty($topic)) |
|
961 | - cache_put_data('topic_board-' . $topic, $board_info, 120); |
|
1002 | + if (!empty($topic)) { |
|
1003 | + cache_put_data('topic_board-' . $topic, $board_info, 120); |
|
1004 | + } |
|
962 | 1005 | cache_put_data('board-' . $board, $board_info, 120); |
963 | 1006 | } |
964 | - } |
|
965 | - else |
|
1007 | + } else |
|
966 | 1008 | { |
967 | 1009 | // Otherwise the topic is invalid, there are no moderators, etc. |
968 | 1010 | $board_info = array( |
@@ -976,8 +1018,9 @@ discard block |
||
976 | 1018 | $smcFunc['db_free_result']($request); |
977 | 1019 | } |
978 | 1020 | |
979 | - if (!empty($topic)) |
|
980 | - $_GET['board'] = (int) $board; |
|
1021 | + if (!empty($topic)) { |
|
1022 | + $_GET['board'] = (int) $board; |
|
1023 | + } |
|
981 | 1024 | |
982 | 1025 | if (!empty($board)) |
983 | 1026 | { |
@@ -987,10 +1030,12 @@ discard block |
||
987 | 1030 | // Now check if the user is a moderator. |
988 | 1031 | $user_info['is_mod'] = isset($board_info['moderators'][$user_info['id']]) || count(array_intersect($user_info['groups'], $moderator_groups)) != 0; |
989 | 1032 | |
990 | - if (count(array_intersect($user_info['groups'], $board_info['groups'])) == 0 && !$user_info['is_admin']) |
|
991 | - $board_info['error'] = 'access'; |
|
992 | - if (!empty($modSettings['deny_boards_access']) && count(array_intersect($user_info['groups'], $board_info['deny_groups'])) != 0 && !$user_info['is_admin']) |
|
993 | - $board_info['error'] = 'access'; |
|
1033 | + if (count(array_intersect($user_info['groups'], $board_info['groups'])) == 0 && !$user_info['is_admin']) { |
|
1034 | + $board_info['error'] = 'access'; |
|
1035 | + } |
|
1036 | + if (!empty($modSettings['deny_boards_access']) && count(array_intersect($user_info['groups'], $board_info['deny_groups'])) != 0 && !$user_info['is_admin']) { |
|
1037 | + $board_info['error'] = 'access'; |
|
1038 | + } |
|
994 | 1039 | |
995 | 1040 | // Build up the linktree. |
996 | 1041 | $context['linktree'] = array_merge( |
@@ -1013,8 +1058,9 @@ discard block |
||
1013 | 1058 | $context['current_board'] = $board; |
1014 | 1059 | |
1015 | 1060 | // No posting in redirection boards! |
1016 | - if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'post' && !empty($board_info['redirect'])) |
|
1017 | - $board_info['error'] == 'post_in_redirect'; |
|
1061 | + if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'post' && !empty($board_info['redirect'])) { |
|
1062 | + $board_info['error'] == 'post_in_redirect'; |
|
1063 | + } |
|
1018 | 1064 | |
1019 | 1065 | // Hacker... you can't see this topic, I'll tell you that. (but moderators can!) |
1020 | 1066 | if (!empty($board_info['error']) && (!empty($modSettings['deny_boards_access']) || $board_info['error'] != 'access' || !$user_info['is_mod'])) |
@@ -1040,24 +1086,23 @@ discard block |
||
1040 | 1086 | ob_end_clean(); |
1041 | 1087 | header('HTTP/1.1 403 Forbidden'); |
1042 | 1088 | die; |
1043 | - } |
|
1044 | - elseif ($board_info['error'] == 'post_in_redirect') |
|
1089 | + } elseif ($board_info['error'] == 'post_in_redirect') |
|
1045 | 1090 | { |
1046 | 1091 | // Slightly different error message here... |
1047 | 1092 | fatal_lang_error('cannot_post_redirect', false); |
1048 | - } |
|
1049 | - elseif ($user_info['is_guest']) |
|
1093 | + } elseif ($user_info['is_guest']) |
|
1050 | 1094 | { |
1051 | 1095 | loadLanguage('Errors'); |
1052 | 1096 | is_not_guest($txt['topic_gone']); |
1097 | + } else { |
|
1098 | + fatal_lang_error('topic_gone', false); |
|
1053 | 1099 | } |
1054 | - else |
|
1055 | - fatal_lang_error('topic_gone', false); |
|
1056 | 1100 | } |
1057 | 1101 | |
1058 | - if ($user_info['is_mod']) |
|
1059 | - $user_info['groups'][] = 3; |
|
1060 | -} |
|
1102 | + if ($user_info['is_mod']) { |
|
1103 | + $user_info['groups'][] = 3; |
|
1104 | + } |
|
1105 | + } |
|
1061 | 1106 | |
1062 | 1107 | /** |
1063 | 1108 | * Load this user's permissions. |
@@ -1078,8 +1123,9 @@ discard block |
||
1078 | 1123 | asort($cache_groups); |
1079 | 1124 | $cache_groups = implode(',', $cache_groups); |
1080 | 1125 | // If it's a spider then cache it different. |
1081 | - if ($user_info['possibly_robot']) |
|
1082 | - $cache_groups .= '-spider'; |
|
1126 | + if ($user_info['possibly_robot']) { |
|
1127 | + $cache_groups .= '-spider'; |
|
1128 | + } |
|
1083 | 1129 | |
1084 | 1130 | if ($modSettings['cache_enable'] >= 2 && !empty($board) && ($temp = cache_get_data('permissions:' . $cache_groups . ':' . $board, 240)) != null && time() - 240 > $modSettings['settings_updated']) |
1085 | 1131 | { |
@@ -1087,9 +1133,9 @@ discard block |
||
1087 | 1133 | banPermissions(); |
1088 | 1134 | |
1089 | 1135 | return; |
1136 | + } elseif (($temp = cache_get_data('permissions:' . $cache_groups, 240)) != null && time() - 240 > $modSettings['settings_updated']) { |
|
1137 | + list ($user_info['permissions'], $removals) = $temp; |
|
1090 | 1138 | } |
1091 | - elseif (($temp = cache_get_data('permissions:' . $cache_groups, 240)) != null && time() - 240 > $modSettings['settings_updated']) |
|
1092 | - list ($user_info['permissions'], $removals) = $temp; |
|
1093 | 1139 | } |
1094 | 1140 | |
1095 | 1141 | // If it is detected as a robot, and we are restricting permissions as a special group - then implement this. |
@@ -1111,23 +1157,26 @@ discard block |
||
1111 | 1157 | $removals = array(); |
1112 | 1158 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1113 | 1159 | { |
1114 | - if (empty($row['add_deny'])) |
|
1115 | - $removals[] = $row['permission']; |
|
1116 | - else |
|
1117 | - $user_info['permissions'][] = $row['permission']; |
|
1160 | + if (empty($row['add_deny'])) { |
|
1161 | + $removals[] = $row['permission']; |
|
1162 | + } else { |
|
1163 | + $user_info['permissions'][] = $row['permission']; |
|
1164 | + } |
|
1118 | 1165 | } |
1119 | 1166 | $smcFunc['db_free_result']($request); |
1120 | 1167 | |
1121 | - if (isset($cache_groups)) |
|
1122 | - cache_put_data('permissions:' . $cache_groups, array($user_info['permissions'], $removals), 240); |
|
1168 | + if (isset($cache_groups)) { |
|
1169 | + cache_put_data('permissions:' . $cache_groups, array($user_info['permissions'], $removals), 240); |
|
1170 | + } |
|
1123 | 1171 | } |
1124 | 1172 | |
1125 | 1173 | // Get the board permissions. |
1126 | 1174 | if (!empty($board)) |
1127 | 1175 | { |
1128 | 1176 | // Make sure the board (if any) has been loaded by loadBoard(). |
1129 | - if (!isset($board_info['profile'])) |
|
1130 | - fatal_lang_error('no_board'); |
|
1177 | + if (!isset($board_info['profile'])) { |
|
1178 | + fatal_lang_error('no_board'); |
|
1179 | + } |
|
1131 | 1180 | |
1132 | 1181 | $request = $smcFunc['db_query']('', ' |
1133 | 1182 | SELECT permission, add_deny |
@@ -1143,20 +1192,23 @@ discard block |
||
1143 | 1192 | ); |
1144 | 1193 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1145 | 1194 | { |
1146 | - if (empty($row['add_deny'])) |
|
1147 | - $removals[] = $row['permission']; |
|
1148 | - else |
|
1149 | - $user_info['permissions'][] = $row['permission']; |
|
1195 | + if (empty($row['add_deny'])) { |
|
1196 | + $removals[] = $row['permission']; |
|
1197 | + } else { |
|
1198 | + $user_info['permissions'][] = $row['permission']; |
|
1199 | + } |
|
1150 | 1200 | } |
1151 | 1201 | $smcFunc['db_free_result']($request); |
1152 | 1202 | } |
1153 | 1203 | |
1154 | 1204 | // Remove all the permissions they shouldn't have ;). |
1155 | - if (!empty($modSettings['permission_enable_deny'])) |
|
1156 | - $user_info['permissions'] = array_diff($user_info['permissions'], $removals); |
|
1205 | + if (!empty($modSettings['permission_enable_deny'])) { |
|
1206 | + $user_info['permissions'] = array_diff($user_info['permissions'], $removals); |
|
1207 | + } |
|
1157 | 1208 | |
1158 | - if (isset($cache_groups) && !empty($board) && $modSettings['cache_enable'] >= 2) |
|
1159 | - cache_put_data('permissions:' . $cache_groups . ':' . $board, array($user_info['permissions'], null), 240); |
|
1209 | + if (isset($cache_groups) && !empty($board) && $modSettings['cache_enable'] >= 2) { |
|
1210 | + cache_put_data('permissions:' . $cache_groups . ':' . $board, array($user_info['permissions'], null), 240); |
|
1211 | + } |
|
1160 | 1212 | |
1161 | 1213 | // Banned? Watch, don't touch.. |
1162 | 1214 | banPermissions(); |
@@ -1168,17 +1220,18 @@ discard block |
||
1168 | 1220 | { |
1169 | 1221 | require_once($sourcedir . '/Subs-Auth.php'); |
1170 | 1222 | rebuildModCache(); |
1223 | + } else { |
|
1224 | + $user_info['mod_cache'] = $_SESSION['mc']; |
|
1171 | 1225 | } |
1172 | - else |
|
1173 | - $user_info['mod_cache'] = $_SESSION['mc']; |
|
1174 | 1226 | |
1175 | 1227 | // This is a useful phantom permission added to the current user, and only the current user while they are logged in. |
1176 | 1228 | // For example this drastically simplifies certain changes to the profile area. |
1177 | 1229 | $user_info['permissions'][] = 'is_not_guest'; |
1178 | 1230 | // And now some backwards compatibility stuff for mods and whatnot that aren't expecting the new permissions. |
1179 | 1231 | $user_info['permissions'][] = 'profile_view_own'; |
1180 | - if (in_array('profile_view', $user_info['permissions'])) |
|
1181 | - $user_info['permissions'][] = 'profile_view_any'; |
|
1232 | + if (in_array('profile_view', $user_info['permissions'])) { |
|
1233 | + $user_info['permissions'][] = 'profile_view_any'; |
|
1234 | + } |
|
1182 | 1235 | } |
1183 | 1236 | } |
1184 | 1237 | |
@@ -1196,8 +1249,9 @@ discard block |
||
1196 | 1249 | global $image_proxy_enabled, $image_proxy_secret, $boardurl; |
1197 | 1250 | |
1198 | 1251 | // Can't just look for no users :P. |
1199 | - if (empty($users)) |
|
1200 | - return array(); |
|
1252 | + if (empty($users)) { |
|
1253 | + return array(); |
|
1254 | + } |
|
1201 | 1255 | |
1202 | 1256 | // Pass the set value |
1203 | 1257 | $context['loadMemberContext_set'] = $set; |
@@ -1212,8 +1266,9 @@ discard block |
||
1212 | 1266 | for ($i = 0, $n = count($users); $i < $n; $i++) |
1213 | 1267 | { |
1214 | 1268 | $data = cache_get_data('member_data-' . $set . '-' . $users[$i], 240); |
1215 | - if ($data == null) |
|
1216 | - continue; |
|
1269 | + if ($data == null) { |
|
1270 | + continue; |
|
1271 | + } |
|
1217 | 1272 | |
1218 | 1273 | $loaded_ids[] = $data['id_member']; |
1219 | 1274 | $user_profile[$data['id_member']] = $data; |
@@ -1280,13 +1335,16 @@ discard block |
||
1280 | 1335 | $row['avatar_original'] = !empty($row['avatar']) ? $row['avatar'] : ''; |
1281 | 1336 | |
1282 | 1337 | // Take care of proxying avatar if required, do this here for maximum reach |
1283 | - if ($image_proxy_enabled && !empty($row['avatar']) && stripos($row['avatar'], 'http://') !== false) |
|
1284 | - $row['avatar'] = $boardurl . '/proxy.php?request=' . urlencode($row['avatar']) . '&hash=' . md5($row['avatar'] . $image_proxy_secret); |
|
1338 | + if ($image_proxy_enabled && !empty($row['avatar']) && stripos($row['avatar'], 'http://') !== false) { |
|
1339 | + $row['avatar'] = $boardurl . '/proxy.php?request=' . urlencode($row['avatar']) . '&hash=' . md5($row['avatar'] . $image_proxy_secret); |
|
1340 | + } |
|
1285 | 1341 | |
1286 | - if (isset($row['member_ip'])) |
|
1287 | - $row['member_ip'] = inet_dtop($row['member_ip']); |
|
1288 | - if (isset($row['member_ip2'])) |
|
1289 | - $row['member_ip2'] = inet_dtop($row['member_ip2']); |
|
1342 | + if (isset($row['member_ip'])) { |
|
1343 | + $row['member_ip'] = inet_dtop($row['member_ip']); |
|
1344 | + } |
|
1345 | + if (isset($row['member_ip2'])) { |
|
1346 | + $row['member_ip2'] = inet_dtop($row['member_ip2']); |
|
1347 | + } |
|
1290 | 1348 | $new_loaded_ids[] = $row['id_member']; |
1291 | 1349 | $loaded_ids[] = $row['id_member']; |
1292 | 1350 | $row['options'] = array(); |
@@ -1305,8 +1363,9 @@ discard block |
||
1305 | 1363 | 'loaded_ids' => $new_loaded_ids, |
1306 | 1364 | ) |
1307 | 1365 | ); |
1308 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1309 | - $user_profile[$row['id_member']]['options'][$row['variable']] = $row['value']; |
|
1366 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1367 | + $user_profile[$row['id_member']]['options'][$row['variable']] = $row['value']; |
|
1368 | + } |
|
1310 | 1369 | $smcFunc['db_free_result']($request); |
1311 | 1370 | } |
1312 | 1371 | |
@@ -1317,10 +1376,11 @@ discard block |
||
1317 | 1376 | { |
1318 | 1377 | foreach ($loaded_ids as $a_member) |
1319 | 1378 | { |
1320 | - if (!empty($user_profile[$a_member]['additional_groups'])) |
|
1321 | - $groups = array_merge(array($user_profile[$a_member]['id_group']), explode(',', $user_profile[$a_member]['additional_groups'])); |
|
1322 | - else |
|
1323 | - $groups = array($user_profile[$a_member]['id_group']); |
|
1379 | + if (!empty($user_profile[$a_member]['additional_groups'])) { |
|
1380 | + $groups = array_merge(array($user_profile[$a_member]['id_group']), explode(',', $user_profile[$a_member]['additional_groups'])); |
|
1381 | + } else { |
|
1382 | + $groups = array($user_profile[$a_member]['id_group']); |
|
1383 | + } |
|
1324 | 1384 | |
1325 | 1385 | $temp = array_intersect($groups, array_keys($board_info['moderator_groups'])); |
1326 | 1386 | |
@@ -1333,8 +1393,9 @@ discard block |
||
1333 | 1393 | |
1334 | 1394 | if (!empty($new_loaded_ids) && !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 3) |
1335 | 1395 | { |
1336 | - for ($i = 0, $n = count($new_loaded_ids); $i < $n; $i++) |
|
1337 | - cache_put_data('member_data-' . $set . '-' . $new_loaded_ids[$i], $user_profile[$new_loaded_ids[$i]], 240); |
|
1396 | + for ($i = 0, $n = count($new_loaded_ids); $i < $n; $i++) { |
|
1397 | + cache_put_data('member_data-' . $set . '-' . $new_loaded_ids[$i], $user_profile[$new_loaded_ids[$i]], 240); |
|
1398 | + } |
|
1338 | 1399 | } |
1339 | 1400 | |
1340 | 1401 | // Are we loading any moderators? If so, fix their group data... |
@@ -1360,14 +1421,17 @@ discard block |
||
1360 | 1421 | foreach ($temp_mods as $id) |
1361 | 1422 | { |
1362 | 1423 | // By popular demand, don't show admins or global moderators as moderators. |
1363 | - if ($user_profile[$id]['id_group'] != 1 && $user_profile[$id]['id_group'] != 2) |
|
1364 | - $user_profile[$id]['member_group'] = $row['member_group']; |
|
1424 | + if ($user_profile[$id]['id_group'] != 1 && $user_profile[$id]['id_group'] != 2) { |
|
1425 | + $user_profile[$id]['member_group'] = $row['member_group']; |
|
1426 | + } |
|
1365 | 1427 | |
1366 | 1428 | // If the Moderator group has no color or icons, but their group does... don't overwrite. |
1367 | - if (!empty($row['icons'])) |
|
1368 | - $user_profile[$id]['icons'] = $row['icons']; |
|
1369 | - if (!empty($row['member_group_color'])) |
|
1370 | - $user_profile[$id]['member_group_color'] = $row['member_group_color']; |
|
1429 | + if (!empty($row['icons'])) { |
|
1430 | + $user_profile[$id]['icons'] = $row['icons']; |
|
1431 | + } |
|
1432 | + if (!empty($row['member_group_color'])) { |
|
1433 | + $user_profile[$id]['member_group_color'] = $row['member_group_color']; |
|
1434 | + } |
|
1371 | 1435 | } |
1372 | 1436 | } |
1373 | 1437 | |
@@ -1389,12 +1453,14 @@ discard block |
||
1389 | 1453 | static $loadedLanguages = array(); |
1390 | 1454 | |
1391 | 1455 | // If this person's data is already loaded, skip it. |
1392 | - if (isset($dataLoaded[$user])) |
|
1393 | - return true; |
|
1456 | + if (isset($dataLoaded[$user])) { |
|
1457 | + return true; |
|
1458 | + } |
|
1394 | 1459 | |
1395 | 1460 | // We can't load guests or members not loaded by loadMemberData()! |
1396 | - if ($user == 0) |
|
1397 | - return false; |
|
1461 | + if ($user == 0) { |
|
1462 | + return false; |
|
1463 | + } |
|
1398 | 1464 | if (!isset($user_profile[$user])) |
1399 | 1465 | { |
1400 | 1466 | trigger_error('loadMemberContext(): member id ' . $user . ' not previously loaded by loadMemberData()', E_USER_WARNING); |
@@ -1420,12 +1486,16 @@ discard block |
||
1420 | 1486 | $buddy_list = !empty($profile['buddy_list']) ? explode(',', $profile['buddy_list']) : array(); |
1421 | 1487 | |
1422 | 1488 | //We need a little fallback for the membergroup icons. If it doesn't exist in the current theme, fallback to default theme |
1423 | - if (isset($profile['icons'][1]) && file_exists($settings['actual_theme_dir'] . '/images/membericons/' . $profile['icons'][1])) //icon is set and exists |
|
1489 | + if (isset($profile['icons'][1]) && file_exists($settings['actual_theme_dir'] . '/images/membericons/' . $profile['icons'][1])) { |
|
1490 | + //icon is set and exists |
|
1424 | 1491 | $group_icon_url = $settings['images_url'] . '/membericons/' . $profile['icons'][1]; |
1425 | - elseif (isset($profile['icons'][1])) //icon is set and doesn't exist, fallback to default |
|
1492 | + } elseif (isset($profile['icons'][1])) { |
|
1493 | + //icon is set and doesn't exist, fallback to default |
|
1426 | 1494 | $group_icon_url = $settings['default_images_url'] . '/membericons/' . $profile['icons'][1]; |
1427 | - else //not set, bye bye |
|
1495 | + } else { |
|
1496 | + //not set, bye bye |
|
1428 | 1497 | $group_icon_url = ''; |
1498 | + } |
|
1429 | 1499 | |
1430 | 1500 | // These minimal values are always loaded |
1431 | 1501 | $memberContext[$user] = array( |
@@ -1444,8 +1514,9 @@ discard block |
||
1444 | 1514 | if ($context['loadMemberContext_set'] != 'minimal') |
1445 | 1515 | { |
1446 | 1516 | // Go the extra mile and load the user's native language name. |
1447 | - if (empty($loadedLanguages)) |
|
1448 | - $loadedLanguages = getLanguages(); |
|
1517 | + if (empty($loadedLanguages)) { |
|
1518 | + $loadedLanguages = getLanguages(); |
|
1519 | + } |
|
1449 | 1520 | |
1450 | 1521 | $memberContext[$user] += array( |
1451 | 1522 | 'username_color' => '<span ' . (!empty($profile['member_group_color']) ? 'style="color:' . $profile['member_group_color'] . ';"' : '') . '>' . $profile['member_name'] . '</span>', |
@@ -1499,31 +1570,33 @@ discard block |
||
1499 | 1570 | { |
1500 | 1571 | if (!empty($modSettings['gravatarOverride']) || (!empty($modSettings['gravatarEnabled']) && stristr($profile['avatar'], 'gravatar://'))) |
1501 | 1572 | { |
1502 | - if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($profile['avatar'], 'gravatar://') && strlen($profile['avatar']) > 11) |
|
1503 | - $image = get_gravatar_url($smcFunc['substr']($profile['avatar'], 11)); |
|
1504 | - else |
|
1505 | - $image = get_gravatar_url($profile['email_address']); |
|
1506 | - } |
|
1507 | - else |
|
1573 | + if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($profile['avatar'], 'gravatar://') && strlen($profile['avatar']) > 11) { |
|
1574 | + $image = get_gravatar_url($smcFunc['substr']($profile['avatar'], 11)); |
|
1575 | + } else { |
|
1576 | + $image = get_gravatar_url($profile['email_address']); |
|
1577 | + } |
|
1578 | + } else |
|
1508 | 1579 | { |
1509 | 1580 | // So it's stored in the member table? |
1510 | 1581 | if (!empty($profile['avatar'])) |
1511 | 1582 | { |
1512 | 1583 | $image = (stristr($profile['avatar'], 'http://') || stristr($profile['avatar'], 'https://')) ? $profile['avatar'] : $modSettings['avatar_url'] . '/' . $profile['avatar']; |
1584 | + } elseif (!empty($profile['filename'])) { |
|
1585 | + $image = $modSettings['custom_avatar_url'] . '/' . $profile['filename']; |
|
1513 | 1586 | } |
1514 | - elseif (!empty($profile['filename'])) |
|
1515 | - $image = $modSettings['custom_avatar_url'] . '/' . $profile['filename']; |
|
1516 | 1587 | // Right... no avatar...use the default one |
1517 | - else |
|
1518 | - $image = $modSettings['avatar_url'] . '/default.png'; |
|
1588 | + else { |
|
1589 | + $image = $modSettings['avatar_url'] . '/default.png'; |
|
1590 | + } |
|
1519 | 1591 | } |
1520 | - if (!empty($image)) |
|
1521 | - $memberContext[$user]['avatar'] = array( |
|
1592 | + if (!empty($image)) { |
|
1593 | + $memberContext[$user]['avatar'] = array( |
|
1522 | 1594 | 'name' => $profile['avatar'], |
1523 | 1595 | 'image' => '<img class="avatar" src="' . $image . '" alt="avatar_' . $profile['member_name'] . '">', |
1524 | 1596 | 'href' => $image, |
1525 | 1597 | 'url' => $image, |
1526 | 1598 | ); |
1599 | + } |
|
1527 | 1600 | } |
1528 | 1601 | |
1529 | 1602 | // Are we also loading the members custom fields into context? |
@@ -1531,35 +1604,41 @@ discard block |
||
1531 | 1604 | { |
1532 | 1605 | $memberContext[$user]['custom_fields'] = array(); |
1533 | 1606 | |
1534 | - if (!isset($context['display_fields'])) |
|
1535 | - $context['display_fields'] = $smcFunc['json_decode']($modSettings['displayFields'], true); |
|
1607 | + if (!isset($context['display_fields'])) { |
|
1608 | + $context['display_fields'] = $smcFunc['json_decode']($modSettings['displayFields'], true); |
|
1609 | + } |
|
1536 | 1610 | |
1537 | 1611 | foreach ($context['display_fields'] as $custom) |
1538 | 1612 | { |
1539 | - if (!isset($custom['col_name']) || trim($custom['col_name']) == '' || empty($profile['options'][$custom['col_name']])) |
|
1540 | - continue; |
|
1613 | + if (!isset($custom['col_name']) || trim($custom['col_name']) == '' || empty($profile['options'][$custom['col_name']])) { |
|
1614 | + continue; |
|
1615 | + } |
|
1541 | 1616 | |
1542 | 1617 | $value = $profile['options'][$custom['col_name']]; |
1543 | 1618 | |
1544 | 1619 | // Don't show the "disabled" option for the "gender" field. |
1545 | - if ($custom['col_name'] == 'cust_gender' && $value == 'Disabled') |
|
1546 | - continue; |
|
1620 | + if ($custom['col_name'] == 'cust_gender' && $value == 'Disabled') { |
|
1621 | + continue; |
|
1622 | + } |
|
1547 | 1623 | |
1548 | 1624 | // BBC? |
1549 | - if ($custom['bbc']) |
|
1550 | - $value = parse_bbc($value); |
|
1625 | + if ($custom['bbc']) { |
|
1626 | + $value = parse_bbc($value); |
|
1627 | + } |
|
1551 | 1628 | // ... or checkbox? |
1552 | - elseif (isset($custom['type']) && $custom['type'] == 'check') |
|
1553 | - $value = $value ? $txt['yes'] : $txt['no']; |
|
1629 | + elseif (isset($custom['type']) && $custom['type'] == 'check') { |
|
1630 | + $value = $value ? $txt['yes'] : $txt['no']; |
|
1631 | + } |
|
1554 | 1632 | |
1555 | 1633 | // Enclosing the user input within some other text? |
1556 | - if (!empty($custom['enclose'])) |
|
1557 | - $value = strtr($custom['enclose'], array( |
|
1634 | + if (!empty($custom['enclose'])) { |
|
1635 | + $value = strtr($custom['enclose'], array( |
|
1558 | 1636 | '{SCRIPTURL}' => $scripturl, |
1559 | 1637 | '{IMAGES_URL}' => $settings['images_url'], |
1560 | 1638 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
1561 | 1639 | '{INPUT}' => $value, |
1562 | 1640 | )); |
1641 | + } |
|
1563 | 1642 | |
1564 | 1643 | $memberContext[$user]['custom_fields'][] = array( |
1565 | 1644 | 'title' => !empty($custom['title']) ? $custom['title'] : $custom['col_name'], |
@@ -1586,8 +1665,9 @@ discard block |
||
1586 | 1665 | global $smcFunc, $txt, $scripturl, $settings; |
1587 | 1666 | |
1588 | 1667 | // Do not waste my time... |
1589 | - if (empty($users) || empty($params)) |
|
1590 | - return false; |
|
1668 | + if (empty($users) || empty($params)) { |
|
1669 | + return false; |
|
1670 | + } |
|
1591 | 1671 | |
1592 | 1672 | // Make sure it's an array. |
1593 | 1673 | $users = !is_array($users) ? array($users) : array_unique($users); |
@@ -1611,31 +1691,36 @@ discard block |
||
1611 | 1691 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1612 | 1692 | { |
1613 | 1693 | // BBC? |
1614 | - if (!empty($row['bbc'])) |
|
1615 | - $row['value'] = parse_bbc($row['value']); |
|
1694 | + if (!empty($row['bbc'])) { |
|
1695 | + $row['value'] = parse_bbc($row['value']); |
|
1696 | + } |
|
1616 | 1697 | |
1617 | 1698 | // ... or checkbox? |
1618 | - elseif (isset($row['type']) && $row['type'] == 'check') |
|
1619 | - $row['value'] = !empty($row['value']) ? $txt['yes'] : $txt['no']; |
|
1699 | + elseif (isset($row['type']) && $row['type'] == 'check') { |
|
1700 | + $row['value'] = !empty($row['value']) ? $txt['yes'] : $txt['no']; |
|
1701 | + } |
|
1620 | 1702 | |
1621 | 1703 | // Enclosing the user input within some other text? |
1622 | - if (!empty($row['enclose'])) |
|
1623 | - $row['value'] = strtr($row['enclose'], array( |
|
1704 | + if (!empty($row['enclose'])) { |
|
1705 | + $row['value'] = strtr($row['enclose'], array( |
|
1624 | 1706 | '{SCRIPTURL}' => $scripturl, |
1625 | 1707 | '{IMAGES_URL}' => $settings['images_url'], |
1626 | 1708 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
1627 | 1709 | '{INPUT}' => un_htmlspecialchars($row['value']), |
1628 | 1710 | )); |
1711 | + } |
|
1629 | 1712 | |
1630 | 1713 | // Send a simple array if there is just 1 param |
1631 | - if (count($params) == 1) |
|
1632 | - $return[$row['id_member']] = $row; |
|
1714 | + if (count($params) == 1) { |
|
1715 | + $return[$row['id_member']] = $row; |
|
1716 | + } |
|
1633 | 1717 | |
1634 | 1718 | // More than 1? knock yourself out... |
1635 | 1719 | else |
1636 | 1720 | { |
1637 | - if (!isset($return[$row['id_member']])) |
|
1638 | - $return[$row['id_member']] = array(); |
|
1721 | + if (!isset($return[$row['id_member']])) { |
|
1722 | + $return[$row['id_member']] = array(); |
|
1723 | + } |
|
1639 | 1724 | |
1640 | 1725 | $return[$row['id_member']][$row['variable']] = $row; |
1641 | 1726 | } |
@@ -1669,8 +1754,9 @@ discard block |
||
1669 | 1754 | global $context; |
1670 | 1755 | |
1671 | 1756 | // Don't know any browser! |
1672 | - if (empty($context['browser'])) |
|
1673 | - detectBrowser(); |
|
1757 | + if (empty($context['browser'])) { |
|
1758 | + detectBrowser(); |
|
1759 | + } |
|
1674 | 1760 | |
1675 | 1761 | return !empty($context['browser'][$browser]) || !empty($context['browser']['is_' . $browser]) ? true : false; |
1676 | 1762 | } |
@@ -1688,8 +1774,9 @@ discard block |
||
1688 | 1774 | global $context, $settings, $options, $sourcedir, $ssi_theme, $smcFunc, $language, $board, $image_proxy_enabled; |
1689 | 1775 | |
1690 | 1776 | // The theme was specified by parameter. |
1691 | - if (!empty($id_theme)) |
|
1692 | - $id_theme = (int) $id_theme; |
|
1777 | + if (!empty($id_theme)) { |
|
1778 | + $id_theme = (int) $id_theme; |
|
1779 | + } |
|
1693 | 1780 | // The theme was specified by REQUEST. |
1694 | 1781 | elseif (!empty($_REQUEST['theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) |
1695 | 1782 | { |
@@ -1697,51 +1784,58 @@ discard block |
||
1697 | 1784 | $_SESSION['id_theme'] = $id_theme; |
1698 | 1785 | } |
1699 | 1786 | // The theme was specified by REQUEST... previously. |
1700 | - elseif (!empty($_SESSION['id_theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) |
|
1701 | - $id_theme = (int) $_SESSION['id_theme']; |
|
1787 | + elseif (!empty($_SESSION['id_theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) { |
|
1788 | + $id_theme = (int) $_SESSION['id_theme']; |
|
1789 | + } |
|
1702 | 1790 | // The theme is just the user's choice. (might use ?board=1;theme=0 to force board theme.) |
1703 | - elseif (!empty($user_info['theme']) && !isset($_REQUEST['theme'])) |
|
1704 | - $id_theme = $user_info['theme']; |
|
1791 | + elseif (!empty($user_info['theme']) && !isset($_REQUEST['theme'])) { |
|
1792 | + $id_theme = $user_info['theme']; |
|
1793 | + } |
|
1705 | 1794 | // The theme was specified by the board. |
1706 | - elseif (!empty($board_info['theme'])) |
|
1707 | - $id_theme = $board_info['theme']; |
|
1795 | + elseif (!empty($board_info['theme'])) { |
|
1796 | + $id_theme = $board_info['theme']; |
|
1797 | + } |
|
1708 | 1798 | // The theme is the forum's default. |
1709 | - else |
|
1710 | - $id_theme = $modSettings['theme_guests']; |
|
1799 | + else { |
|
1800 | + $id_theme = $modSettings['theme_guests']; |
|
1801 | + } |
|
1711 | 1802 | |
1712 | 1803 | // Verify the id_theme... no foul play. |
1713 | 1804 | // Always allow the board specific theme, if they are overriding. |
1714 | - if (!empty($board_info['theme']) && $board_info['override_theme']) |
|
1715 | - $id_theme = $board_info['theme']; |
|
1805 | + if (!empty($board_info['theme']) && $board_info['override_theme']) { |
|
1806 | + $id_theme = $board_info['theme']; |
|
1807 | + } |
|
1716 | 1808 | // If they have specified a particular theme to use with SSI allow it to be used. |
1717 | - elseif (!empty($ssi_theme) && $id_theme == $ssi_theme) |
|
1718 | - $id_theme = (int) $id_theme; |
|
1719 | - elseif (!empty($modSettings['enableThemes']) && !allowedTo('admin_forum')) |
|
1809 | + elseif (!empty($ssi_theme) && $id_theme == $ssi_theme) { |
|
1810 | + $id_theme = (int) $id_theme; |
|
1811 | + } elseif (!empty($modSettings['enableThemes']) && !allowedTo('admin_forum')) |
|
1720 | 1812 | { |
1721 | 1813 | $themes = explode(',', $modSettings['enableThemes']); |
1722 | - if (!in_array($id_theme, $themes)) |
|
1723 | - $id_theme = $modSettings['theme_guests']; |
|
1724 | - else |
|
1814 | + if (!in_array($id_theme, $themes)) { |
|
1815 | + $id_theme = $modSettings['theme_guests']; |
|
1816 | + } else { |
|
1817 | + $id_theme = (int) $id_theme; |
|
1818 | + } |
|
1819 | + } else { |
|
1725 | 1820 | $id_theme = (int) $id_theme; |
1726 | 1821 | } |
1727 | - else |
|
1728 | - $id_theme = (int) $id_theme; |
|
1729 | 1822 | |
1730 | 1823 | $member = empty($user_info['id']) ? -1 : $user_info['id']; |
1731 | 1824 | |
1732 | 1825 | // Disable image proxy if we don't have SSL enabled |
1733 | - if (empty($modSettings['force_ssl']) || $modSettings['force_ssl'] < 2) |
|
1734 | - $image_proxy_enabled = false; |
|
1826 | + if (empty($modSettings['force_ssl']) || $modSettings['force_ssl'] < 2) { |
|
1827 | + $image_proxy_enabled = false; |
|
1828 | + } |
|
1735 | 1829 | |
1736 | 1830 | if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2 && ($temp = cache_get_data('theme_settings-' . $id_theme . ':' . $member, 60)) != null && time() - 60 > $modSettings['settings_updated']) |
1737 | 1831 | { |
1738 | 1832 | $themeData = $temp; |
1739 | 1833 | $flag = true; |
1834 | + } elseif (($temp = cache_get_data('theme_settings-' . $id_theme, 90)) != null && time() - 60 > $modSettings['settings_updated']) { |
|
1835 | + $themeData = $temp + array($member => array()); |
|
1836 | + } else { |
|
1837 | + $themeData = array(-1 => array(), 0 => array(), $member => array()); |
|
1740 | 1838 | } |
1741 | - elseif (($temp = cache_get_data('theme_settings-' . $id_theme, 90)) != null && time() - 60 > $modSettings['settings_updated']) |
|
1742 | - $themeData = $temp + array($member => array()); |
|
1743 | - else |
|
1744 | - $themeData = array(-1 => array(), 0 => array(), $member => array()); |
|
1745 | 1839 | |
1746 | 1840 | if (empty($flag)) |
1747 | 1841 | { |
@@ -1760,31 +1854,37 @@ discard block |
||
1760 | 1854 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
1761 | 1855 | { |
1762 | 1856 | // There are just things we shouldn't be able to change as members. |
1763 | - if ($row['id_member'] != 0 && in_array($row['variable'], array('actual_theme_url', 'actual_images_url', 'base_theme_dir', 'base_theme_url', 'default_images_url', 'default_theme_dir', 'default_theme_url', 'default_template', 'images_url', 'number_recent_posts', 'smiley_sets_default', 'theme_dir', 'theme_id', 'theme_layers', 'theme_templates', 'theme_url'))) |
|
1764 | - continue; |
|
1857 | + if ($row['id_member'] != 0 && in_array($row['variable'], array('actual_theme_url', 'actual_images_url', 'base_theme_dir', 'base_theme_url', 'default_images_url', 'default_theme_dir', 'default_theme_url', 'default_template', 'images_url', 'number_recent_posts', 'smiley_sets_default', 'theme_dir', 'theme_id', 'theme_layers', 'theme_templates', 'theme_url'))) { |
|
1858 | + continue; |
|
1859 | + } |
|
1765 | 1860 | |
1766 | 1861 | // If this is the theme_dir of the default theme, store it. |
1767 | - if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1' && empty($row['id_member'])) |
|
1768 | - $themeData[0]['default_' . $row['variable']] = $row['value']; |
|
1862 | + if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1' && empty($row['id_member'])) { |
|
1863 | + $themeData[0]['default_' . $row['variable']] = $row['value']; |
|
1864 | + } |
|
1769 | 1865 | |
1770 | 1866 | // If this isn't set yet, is a theme option, or is not the default theme.. |
1771 | - if (!isset($themeData[$row['id_member']][$row['variable']]) || $row['id_theme'] != '1') |
|
1772 | - $themeData[$row['id_member']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value']; |
|
1867 | + if (!isset($themeData[$row['id_member']][$row['variable']]) || $row['id_theme'] != '1') { |
|
1868 | + $themeData[$row['id_member']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value']; |
|
1869 | + } |
|
1773 | 1870 | } |
1774 | 1871 | $smcFunc['db_free_result']($result); |
1775 | 1872 | |
1776 | - if (!empty($themeData[-1])) |
|
1777 | - foreach ($themeData[-1] as $k => $v) |
|
1873 | + if (!empty($themeData[-1])) { |
|
1874 | + foreach ($themeData[-1] as $k => $v) |
|
1778 | 1875 | { |
1779 | 1876 | if (!isset($themeData[$member][$k])) |
1780 | 1877 | $themeData[$member][$k] = $v; |
1878 | + } |
|
1781 | 1879 | } |
1782 | 1880 | |
1783 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
1784 | - cache_put_data('theme_settings-' . $id_theme . ':' . $member, $themeData, 60); |
|
1881 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
1882 | + cache_put_data('theme_settings-' . $id_theme . ':' . $member, $themeData, 60); |
|
1883 | + } |
|
1785 | 1884 | // Only if we didn't already load that part of the cache... |
1786 | - elseif (!isset($temp)) |
|
1787 | - cache_put_data('theme_settings-' . $id_theme, array(-1 => $themeData[-1], 0 => $themeData[0]), 90); |
|
1885 | + elseif (!isset($temp)) { |
|
1886 | + cache_put_data('theme_settings-' . $id_theme, array(-1 => $themeData[-1], 0 => $themeData[0]), 90); |
|
1887 | + } |
|
1788 | 1888 | } |
1789 | 1889 | |
1790 | 1890 | $settings = $themeData[0]; |
@@ -1801,20 +1901,24 @@ discard block |
||
1801 | 1901 | $settings['template_dirs'][] = $settings['theme_dir']; |
1802 | 1902 | |
1803 | 1903 | // Based on theme (if there is one). |
1804 | - if (!empty($settings['base_theme_dir'])) |
|
1805 | - $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
1904 | + if (!empty($settings['base_theme_dir'])) { |
|
1905 | + $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
1906 | + } |
|
1806 | 1907 | |
1807 | 1908 | // Lastly the default theme. |
1808 | - if ($settings['theme_dir'] != $settings['default_theme_dir']) |
|
1809 | - $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
1909 | + if ($settings['theme_dir'] != $settings['default_theme_dir']) { |
|
1910 | + $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
1911 | + } |
|
1810 | 1912 | |
1811 | - if (!$initialize) |
|
1812 | - return; |
|
1913 | + if (!$initialize) { |
|
1914 | + return; |
|
1915 | + } |
|
1813 | 1916 | |
1814 | 1917 | // Check to see if we're forcing SSL |
1815 | 1918 | if (!empty($modSettings['force_ssl']) && $modSettings['force_ssl'] == 2 && empty($maintenance) && |
1816 | - (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'off') && SMF != 'SSI') |
|
1817 | - redirectexit(strtr($_SERVER['REQUEST_URL'], array('http://' => 'https://'))); |
|
1919 | + (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'off') && SMF != 'SSI') { |
|
1920 | + redirectexit(strtr($_SERVER['REQUEST_URL'], array('http://' => 'https://'))); |
|
1921 | + } |
|
1818 | 1922 | |
1819 | 1923 | // Check to see if they're accessing it from the wrong place. |
1820 | 1924 | if (isset($_SERVER['HTTP_HOST']) || isset($_SERVER['SERVER_NAME'])) |
@@ -1822,8 +1926,9 @@ discard block |
||
1822 | 1926 | $detected_url = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ? 'https://' : 'http://'; |
1823 | 1927 | $detected_url .= empty($_SERVER['HTTP_HOST']) ? $_SERVER['SERVER_NAME'] . (empty($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT'] == '80' ? '' : ':' . $_SERVER['SERVER_PORT']) : $_SERVER['HTTP_HOST']; |
1824 | 1928 | $temp = preg_replace('~/' . basename($scripturl) . '(/.+)?$~', '', strtr(dirname($_SERVER['PHP_SELF']), '\\', '/')); |
1825 | - if ($temp != '/') |
|
1826 | - $detected_url .= $temp; |
|
1929 | + if ($temp != '/') { |
|
1930 | + $detected_url .= $temp; |
|
1931 | + } |
|
1827 | 1932 | } |
1828 | 1933 | if (isset($detected_url) && $detected_url != $boardurl) |
1829 | 1934 | { |
@@ -1835,8 +1940,9 @@ discard block |
||
1835 | 1940 | foreach ($aliases as $alias) |
1836 | 1941 | { |
1837 | 1942 | // Rip off all the boring parts, spaces, etc. |
1838 | - if ($detected_url == trim($alias) || strtr($detected_url, array('http://' => '', 'https://' => '')) == trim($alias)) |
|
1839 | - $do_fix = true; |
|
1943 | + if ($detected_url == trim($alias) || strtr($detected_url, array('http://' => '', 'https://' => '')) == trim($alias)) { |
|
1944 | + $do_fix = true; |
|
1945 | + } |
|
1840 | 1946 | } |
1841 | 1947 | } |
1842 | 1948 | |
@@ -1844,20 +1950,22 @@ discard block |
||
1844 | 1950 | if (empty($do_fix) && strtr($detected_url, array('://' => '://www.')) == $boardurl && (empty($_GET) || count($_GET) == 1) && SMF != 'SSI') |
1845 | 1951 | { |
1846 | 1952 | // Okay, this seems weird, but we don't want an endless loop - this will make $_GET not empty ;). |
1847 | - if (empty($_GET)) |
|
1848 | - redirectexit('wwwRedirect'); |
|
1849 | - else |
|
1953 | + if (empty($_GET)) { |
|
1954 | + redirectexit('wwwRedirect'); |
|
1955 | + } else |
|
1850 | 1956 | { |
1851 | 1957 | list ($k, $v) = each($_GET); |
1852 | 1958 | |
1853 | - if ($k != 'wwwRedirect') |
|
1854 | - redirectexit('wwwRedirect;' . $k . '=' . $v); |
|
1959 | + if ($k != 'wwwRedirect') { |
|
1960 | + redirectexit('wwwRedirect;' . $k . '=' . $v); |
|
1961 | + } |
|
1855 | 1962 | } |
1856 | 1963 | } |
1857 | 1964 | |
1858 | 1965 | // #3 is just a check for SSL... |
1859 | - if (strtr($detected_url, array('https://' => 'http://')) == $boardurl) |
|
1860 | - $do_fix = true; |
|
1966 | + if (strtr($detected_url, array('https://' => 'http://')) == $boardurl) { |
|
1967 | + $do_fix = true; |
|
1968 | + } |
|
1861 | 1969 | |
1862 | 1970 | // Okay, #4 - perhaps it's an IP address? We're gonna want to use that one, then. (assuming it's the IP or something...) |
1863 | 1971 | if (!empty($do_fix) || preg_match('~^http[s]?://(?:[\d\.:]+|\[[\d:]+\](?::\d+)?)(?:$|/)~', $detected_url) == 1) |
@@ -1891,8 +1999,9 @@ discard block |
||
1891 | 1999 | $board_info['moderators'][$k]['link'] = strtr($dummy['link'], array('"' . $oldurl => '"' . $boardurl)); |
1892 | 2000 | } |
1893 | 2001 | } |
1894 | - foreach ($context['linktree'] as $k => $dummy) |
|
1895 | - $context['linktree'][$k]['url'] = strtr($dummy['url'], array($oldurl => $boardurl)); |
|
2002 | + foreach ($context['linktree'] as $k => $dummy) { |
|
2003 | + $context['linktree'][$k]['url'] = strtr($dummy['url'], array($oldurl => $boardurl)); |
|
2004 | + } |
|
1896 | 2005 | } |
1897 | 2006 | } |
1898 | 2007 | // Set up the contextual user array. |
@@ -1911,16 +2020,16 @@ discard block |
||
1911 | 2020 | 'email' => $user_info['email'], |
1912 | 2021 | 'ignoreusers' => $user_info['ignoreusers'], |
1913 | 2022 | ); |
1914 | - if (!$context['user']['is_guest']) |
|
1915 | - $context['user']['name'] = $user_info['name']; |
|
1916 | - elseif ($context['user']['is_guest'] && !empty($txt['guest_title'])) |
|
1917 | - $context['user']['name'] = $txt['guest_title']; |
|
2023 | + if (!$context['user']['is_guest']) { |
|
2024 | + $context['user']['name'] = $user_info['name']; |
|
2025 | + } elseif ($context['user']['is_guest'] && !empty($txt['guest_title'])) { |
|
2026 | + $context['user']['name'] = $txt['guest_title']; |
|
2027 | + } |
|
1918 | 2028 | |
1919 | 2029 | // Determine the current smiley set. |
1920 | 2030 | $user_info['smiley_set'] = (!in_array($user_info['smiley_set'], explode(',', $modSettings['smiley_sets_known'])) && $user_info['smiley_set'] != 'none') || empty($modSettings['smiley_sets_enable']) ? (!empty($settings['smiley_sets_default']) ? $settings['smiley_sets_default'] : $modSettings['smiley_sets_default']) : $user_info['smiley_set']; |
1921 | 2031 | $context['user']['smiley_set'] = $user_info['smiley_set']; |
1922 | - } |
|
1923 | - else |
|
2032 | + } else |
|
1924 | 2033 | { |
1925 | 2034 | $context['user'] = array( |
1926 | 2035 | 'id' => -1, |
@@ -1936,18 +2045,24 @@ discard block |
||
1936 | 2045 | } |
1937 | 2046 | |
1938 | 2047 | // Some basic information... |
1939 | - if (!isset($context['html_headers'])) |
|
1940 | - $context['html_headers'] = ''; |
|
1941 | - if (!isset($context['javascript_files'])) |
|
1942 | - $context['javascript_files'] = array(); |
|
1943 | - if (!isset($context['css_files'])) |
|
1944 | - $context['css_files'] = array(); |
|
1945 | - if (!isset($context['css_header'])) |
|
1946 | - $context['css_header'] = array(); |
|
1947 | - if (!isset($context['javascript_inline'])) |
|
1948 | - $context['javascript_inline'] = array('standard' => array(), 'defer' => array()); |
|
1949 | - if (!isset($context['javascript_vars'])) |
|
1950 | - $context['javascript_vars'] = array(); |
|
2048 | + if (!isset($context['html_headers'])) { |
|
2049 | + $context['html_headers'] = ''; |
|
2050 | + } |
|
2051 | + if (!isset($context['javascript_files'])) { |
|
2052 | + $context['javascript_files'] = array(); |
|
2053 | + } |
|
2054 | + if (!isset($context['css_files'])) { |
|
2055 | + $context['css_files'] = array(); |
|
2056 | + } |
|
2057 | + if (!isset($context['css_header'])) { |
|
2058 | + $context['css_header'] = array(); |
|
2059 | + } |
|
2060 | + if (!isset($context['javascript_inline'])) { |
|
2061 | + $context['javascript_inline'] = array('standard' => array(), 'defer' => array()); |
|
2062 | + } |
|
2063 | + if (!isset($context['javascript_vars'])) { |
|
2064 | + $context['javascript_vars'] = array(); |
|
2065 | + } |
|
1951 | 2066 | |
1952 | 2067 | $context['login_url'] = (!empty($modSettings['force_ssl']) && $modSettings['force_ssl'] < 2 ? strtr($scripturl, array('http://' => 'https://')) : $scripturl) . '?action=login2'; |
1953 | 2068 | $context['menu_separator'] = !empty($settings['use_image_buttons']) ? ' ' : ' | '; |
@@ -1959,8 +2074,9 @@ discard block |
||
1959 | 2074 | $context['current_action'] = isset($_REQUEST['action']) ? $smcFunc['htmlspecialchars']($_REQUEST['action']) : null; |
1960 | 2075 | $context['current_subaction'] = isset($_REQUEST['sa']) ? $_REQUEST['sa'] : null; |
1961 | 2076 | $context['can_register'] = empty($modSettings['registration_method']) || $modSettings['registration_method'] != 3; |
1962 | - if (isset($modSettings['load_average'])) |
|
1963 | - $context['load_average'] = $modSettings['load_average']; |
|
2077 | + if (isset($modSettings['load_average'])) { |
|
2078 | + $context['load_average'] = $modSettings['load_average']; |
|
2079 | + } |
|
1964 | 2080 | |
1965 | 2081 | // Detect the browser. This is separated out because it's also used in attachment downloads |
1966 | 2082 | detectBrowser(); |
@@ -1974,8 +2090,9 @@ discard block |
||
1974 | 2090 | // This allows sticking some HTML on the page output - useful for controls. |
1975 | 2091 | $context['insert_after_template'] = ''; |
1976 | 2092 | |
1977 | - if (!isset($txt)) |
|
1978 | - $txt = array(); |
|
2093 | + if (!isset($txt)) { |
|
2094 | + $txt = array(); |
|
2095 | + } |
|
1979 | 2096 | |
1980 | 2097 | $simpleActions = array( |
1981 | 2098 | 'findmember', |
@@ -2021,9 +2138,10 @@ discard block |
||
2021 | 2138 | |
2022 | 2139 | // See if theres any extra param to check. |
2023 | 2140 | $requiresXML = false; |
2024 | - foreach ($extraParams as $key => $extra) |
|
2025 | - if (isset($_REQUEST[$extra])) |
|
2141 | + foreach ($extraParams as $key => $extra) { |
|
2142 | + if (isset($_REQUEST[$extra])) |
|
2026 | 2143 | $requiresXML = true; |
2144 | + } |
|
2027 | 2145 | |
2028 | 2146 | // Output is fully XML, so no need for the index template. |
2029 | 2147 | if (isset($_REQUEST['xml']) && (in_array($context['current_action'], $xmlActions) || $requiresXML)) |
@@ -2038,37 +2156,39 @@ discard block |
||
2038 | 2156 | { |
2039 | 2157 | loadLanguage('index+Modifications'); |
2040 | 2158 | $context['template_layers'] = array(); |
2041 | - } |
|
2042 | - |
|
2043 | - else |
|
2159 | + } else |
|
2044 | 2160 | { |
2045 | 2161 | // Custom templates to load, or just default? |
2046 | - if (isset($settings['theme_templates'])) |
|
2047 | - $templates = explode(',', $settings['theme_templates']); |
|
2048 | - else |
|
2049 | - $templates = array('index'); |
|
2162 | + if (isset($settings['theme_templates'])) { |
|
2163 | + $templates = explode(',', $settings['theme_templates']); |
|
2164 | + } else { |
|
2165 | + $templates = array('index'); |
|
2166 | + } |
|
2050 | 2167 | |
2051 | 2168 | // Load each template... |
2052 | - foreach ($templates as $template) |
|
2053 | - loadTemplate($template); |
|
2169 | + foreach ($templates as $template) { |
|
2170 | + loadTemplate($template); |
|
2171 | + } |
|
2054 | 2172 | |
2055 | 2173 | // ...and attempt to load their associated language files. |
2056 | 2174 | $required_files = implode('+', array_merge($templates, array('Modifications'))); |
2057 | 2175 | loadLanguage($required_files, '', false); |
2058 | 2176 | |
2059 | 2177 | // Custom template layers? |
2060 | - if (isset($settings['theme_layers'])) |
|
2061 | - $context['template_layers'] = explode(',', $settings['theme_layers']); |
|
2062 | - else |
|
2063 | - $context['template_layers'] = array('html', 'body'); |
|
2178 | + if (isset($settings['theme_layers'])) { |
|
2179 | + $context['template_layers'] = explode(',', $settings['theme_layers']); |
|
2180 | + } else { |
|
2181 | + $context['template_layers'] = array('html', 'body'); |
|
2182 | + } |
|
2064 | 2183 | } |
2065 | 2184 | |
2066 | 2185 | // Initialize the theme. |
2067 | 2186 | loadSubTemplate('init', 'ignore'); |
2068 | 2187 | |
2069 | 2188 | // Allow overriding the board wide time/number formats. |
2070 | - if (empty($user_settings['time_format']) && !empty($txt['time_format'])) |
|
2071 | - $user_info['time_format'] = $txt['time_format']; |
|
2189 | + if (empty($user_settings['time_format']) && !empty($txt['time_format'])) { |
|
2190 | + $user_info['time_format'] = $txt['time_format']; |
|
2191 | + } |
|
2072 | 2192 | |
2073 | 2193 | // Set the character set from the template. |
2074 | 2194 | $context['character_set'] = empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']; |
@@ -2076,12 +2196,14 @@ discard block |
||
2076 | 2196 | $context['right_to_left'] = !empty($txt['lang_rtl']); |
2077 | 2197 | |
2078 | 2198 | // Guests may still need a name. |
2079 | - if ($context['user']['is_guest'] && empty($context['user']['name'])) |
|
2080 | - $context['user']['name'] = $txt['guest_title']; |
|
2199 | + if ($context['user']['is_guest'] && empty($context['user']['name'])) { |
|
2200 | + $context['user']['name'] = $txt['guest_title']; |
|
2201 | + } |
|
2081 | 2202 | |
2082 | 2203 | // Any theme-related strings that need to be loaded? |
2083 | - if (!empty($settings['require_theme_strings'])) |
|
2084 | - loadLanguage('ThemeStrings', '', false); |
|
2204 | + if (!empty($settings['require_theme_strings'])) { |
|
2205 | + loadLanguage('ThemeStrings', '', false); |
|
2206 | + } |
|
2085 | 2207 | |
2086 | 2208 | // Make a special URL for the language. |
2087 | 2209 | $settings['lang_images_url'] = $settings['images_url'] . '/' . (!empty($txt['image_lang']) ? $txt['image_lang'] : $user_info['language']); |
@@ -2092,8 +2214,9 @@ discard block |
||
2092 | 2214 | // Here is my luvly Responsive CSS |
2093 | 2215 | loadCSSFile('responsive.css', array('force_current' => false, 'validate' => true, 'minimize' => true), 'smf_responsive'); |
2094 | 2216 | |
2095 | - if ($context['right_to_left']) |
|
2096 | - loadCSSFile('rtl.css', array(), 'smf_rtl'); |
|
2217 | + if ($context['right_to_left']) { |
|
2218 | + loadCSSFile('rtl.css', array(), 'smf_rtl'); |
|
2219 | + } |
|
2097 | 2220 | |
2098 | 2221 | // We allow theme variants, because we're cool. |
2099 | 2222 | $context['theme_variant'] = ''; |
@@ -2101,14 +2224,17 @@ discard block |
||
2101 | 2224 | if (!empty($settings['theme_variants'])) |
2102 | 2225 | { |
2103 | 2226 | // Overriding - for previews and that ilk. |
2104 | - if (!empty($_REQUEST['variant'])) |
|
2105 | - $_SESSION['id_variant'] = $_REQUEST['variant']; |
|
2227 | + if (!empty($_REQUEST['variant'])) { |
|
2228 | + $_SESSION['id_variant'] = $_REQUEST['variant']; |
|
2229 | + } |
|
2106 | 2230 | // User selection? |
2107 | - if (empty($settings['disable_user_variant']) || allowedTo('admin_forum')) |
|
2108 | - $context['theme_variant'] = !empty($_SESSION['id_variant']) ? $_SESSION['id_variant'] : (!empty($options['theme_variant']) ? $options['theme_variant'] : ''); |
|
2231 | + if (empty($settings['disable_user_variant']) || allowedTo('admin_forum')) { |
|
2232 | + $context['theme_variant'] = !empty($_SESSION['id_variant']) ? $_SESSION['id_variant'] : (!empty($options['theme_variant']) ? $options['theme_variant'] : ''); |
|
2233 | + } |
|
2109 | 2234 | // If not a user variant, select the default. |
2110 | - if ($context['theme_variant'] == '' || !in_array($context['theme_variant'], $settings['theme_variants'])) |
|
2111 | - $context['theme_variant'] = !empty($settings['default_variant']) && in_array($settings['default_variant'], $settings['theme_variants']) ? $settings['default_variant'] : $settings['theme_variants'][0]; |
|
2235 | + if ($context['theme_variant'] == '' || !in_array($context['theme_variant'], $settings['theme_variants'])) { |
|
2236 | + $context['theme_variant'] = !empty($settings['default_variant']) && in_array($settings['default_variant'], $settings['theme_variants']) ? $settings['default_variant'] : $settings['theme_variants'][0]; |
|
2237 | + } |
|
2112 | 2238 | |
2113 | 2239 | // Do this to keep things easier in the templates. |
2114 | 2240 | $context['theme_variant'] = '_' . $context['theme_variant']; |
@@ -2117,20 +2243,23 @@ discard block |
||
2117 | 2243 | if (!empty($context['theme_variant'])) |
2118 | 2244 | { |
2119 | 2245 | loadCSSFile('index' . $context['theme_variant'] . '.css', array(), 'smf_index' . $context['theme_variant']); |
2120 | - if ($context['right_to_left']) |
|
2121 | - loadCSSFile('rtl' . $context['theme_variant'] . '.css', array(), 'smf_rtl' . $context['theme_variant']); |
|
2246 | + if ($context['right_to_left']) { |
|
2247 | + loadCSSFile('rtl' . $context['theme_variant'] . '.css', array(), 'smf_rtl' . $context['theme_variant']); |
|
2248 | + } |
|
2122 | 2249 | } |
2123 | 2250 | } |
2124 | 2251 | |
2125 | 2252 | // Let's be compatible with old themes! |
2126 | - if (!function_exists('template_html_above') && in_array('html', $context['template_layers'])) |
|
2127 | - $context['template_layers'] = array('main'); |
|
2253 | + if (!function_exists('template_html_above') && in_array('html', $context['template_layers'])) { |
|
2254 | + $context['template_layers'] = array('main'); |
|
2255 | + } |
|
2128 | 2256 | |
2129 | 2257 | $context['tabindex'] = 1; |
2130 | 2258 | |
2131 | 2259 | // Compatibility. |
2132 | - if (!isset($settings['theme_version'])) |
|
2133 | - $modSettings['memberCount'] = $modSettings['totalMembers']; |
|
2260 | + if (!isset($settings['theme_version'])) { |
|
2261 | + $modSettings['memberCount'] = $modSettings['totalMembers']; |
|
2262 | + } |
|
2134 | 2263 | |
2135 | 2264 | // Default JS variables for use in every theme |
2136 | 2265 | $context['javascript_vars'] = array( |
@@ -2149,18 +2278,18 @@ discard block |
||
2149 | 2278 | ); |
2150 | 2279 | |
2151 | 2280 | // Add the JQuery library to the list of files to load. |
2152 | - if (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'cdn') |
|
2153 | - loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
2154 | - |
|
2155 | - elseif (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'local') |
|
2156 | - loadJavaScriptFile('jquery-3.1.1.min.js', array('seed' => false), 'smf_jquery'); |
|
2157 | - |
|
2158 | - elseif (isset($modSettings['jquery_source'], $modSettings['jquery_custom']) && $modSettings['jquery_source'] == 'custom') |
|
2159 | - loadJavaScriptFile($modSettings['jquery_custom'], array('external' => true), 'smf_jquery'); |
|
2281 | + if (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'cdn') { |
|
2282 | + loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
2283 | + } elseif (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'local') { |
|
2284 | + loadJavaScriptFile('jquery-3.1.1.min.js', array('seed' => false), 'smf_jquery'); |
|
2285 | + } elseif (isset($modSettings['jquery_source'], $modSettings['jquery_custom']) && $modSettings['jquery_source'] == 'custom') { |
|
2286 | + loadJavaScriptFile($modSettings['jquery_custom'], array('external' => true), 'smf_jquery'); |
|
2287 | + } |
|
2160 | 2288 | |
2161 | 2289 | // Auto loading? template_javascript() will take care of the local half of this. |
2162 | - else |
|
2163 | - loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
2290 | + else { |
|
2291 | + loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
2292 | + } |
|
2164 | 2293 | |
2165 | 2294 | // Queue our JQuery plugins! |
2166 | 2295 | loadJavaScriptFile('smf_jquery_plugins.js', array('minimize' => true), 'smf_jquery_plugins'); |
@@ -2183,12 +2312,12 @@ discard block |
||
2183 | 2312 | require_once($sourcedir . '/ScheduledTasks.php'); |
2184 | 2313 | |
2185 | 2314 | // What to do, what to do?! |
2186 | - if (empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time()) |
|
2187 | - AutoTask(); |
|
2188 | - else |
|
2189 | - ReduceMailQueue(); |
|
2190 | - } |
|
2191 | - else |
|
2315 | + if (empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time()) { |
|
2316 | + AutoTask(); |
|
2317 | + } else { |
|
2318 | + ReduceMailQueue(); |
|
2319 | + } |
|
2320 | + } else |
|
2192 | 2321 | { |
2193 | 2322 | $type = empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time() ? 'task' : 'mailq'; |
2194 | 2323 | $ts = $type == 'mailq' ? $modSettings['mail_next_send'] : $modSettings['next_task_time']; |
@@ -2239,8 +2368,9 @@ discard block |
||
2239 | 2368 | foreach ($theme_includes as $include) |
2240 | 2369 | { |
2241 | 2370 | $include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
2242 | - if (file_exists($include)) |
|
2243 | - require_once($include); |
|
2371 | + if (file_exists($include)) { |
|
2372 | + require_once($include); |
|
2373 | + } |
|
2244 | 2374 | } |
2245 | 2375 | } |
2246 | 2376 | |
@@ -2270,16 +2400,19 @@ discard block |
||
2270 | 2400 | // Do any style sheets first, cause we're easy with those. |
2271 | 2401 | if (!empty($style_sheets)) |
2272 | 2402 | { |
2273 | - if (!is_array($style_sheets)) |
|
2274 | - $style_sheets = array($style_sheets); |
|
2403 | + if (!is_array($style_sheets)) { |
|
2404 | + $style_sheets = array($style_sheets); |
|
2405 | + } |
|
2275 | 2406 | |
2276 | - foreach ($style_sheets as $sheet) |
|
2277 | - loadCSSFile($sheet . '.css', array(), $sheet); |
|
2407 | + foreach ($style_sheets as $sheet) { |
|
2408 | + loadCSSFile($sheet . '.css', array(), $sheet); |
|
2409 | + } |
|
2278 | 2410 | } |
2279 | 2411 | |
2280 | 2412 | // No template to load? |
2281 | - if ($template_name === false) |
|
2282 | - return true; |
|
2413 | + if ($template_name === false) { |
|
2414 | + return true; |
|
2415 | + } |
|
2283 | 2416 | |
2284 | 2417 | $loaded = false; |
2285 | 2418 | foreach ($settings['template_dirs'] as $template_dir) |
@@ -2294,12 +2427,14 @@ discard block |
||
2294 | 2427 | |
2295 | 2428 | if ($loaded) |
2296 | 2429 | { |
2297 | - if ($db_show_debug === true) |
|
2298 | - $context['debug']['templates'][] = $template_name . ' (' . basename($template_dir) . ')'; |
|
2430 | + if ($db_show_debug === true) { |
|
2431 | + $context['debug']['templates'][] = $template_name . ' (' . basename($template_dir) . ')'; |
|
2432 | + } |
|
2299 | 2433 | |
2300 | 2434 | // If they have specified an initialization function for this template, go ahead and call it now. |
2301 | - if (function_exists('template_' . $template_name . '_init')) |
|
2302 | - call_user_func('template_' . $template_name . '_init'); |
|
2435 | + if (function_exists('template_' . $template_name . '_init')) { |
|
2436 | + call_user_func('template_' . $template_name . '_init'); |
|
2437 | + } |
|
2303 | 2438 | } |
2304 | 2439 | // Hmmm... doesn't exist?! I don't suppose the directory is wrong, is it? |
2305 | 2440 | elseif (!file_exists($settings['default_theme_dir']) && file_exists($boarddir . '/Themes/default')) |
@@ -2319,13 +2454,14 @@ discard block |
||
2319 | 2454 | loadTemplate($template_name); |
2320 | 2455 | } |
2321 | 2456 | // Cause an error otherwise. |
2322 | - elseif ($template_name != 'Errors' && $template_name != 'index' && $fatal) |
|
2323 | - fatal_lang_error('theme_template_error', 'template', array((string) $template_name)); |
|
2324 | - elseif ($fatal) |
|
2325 | - die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load Themes/default/%s.template.php!', (string) $template_name), 'template')); |
|
2326 | - else |
|
2327 | - return false; |
|
2328 | -} |
|
2457 | + elseif ($template_name != 'Errors' && $template_name != 'index' && $fatal) { |
|
2458 | + fatal_lang_error('theme_template_error', 'template', array((string) $template_name)); |
|
2459 | + } elseif ($fatal) { |
|
2460 | + die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load Themes/default/%s.template.php!', (string) $template_name), 'template')); |
|
2461 | + } else { |
|
2462 | + return false; |
|
2463 | + } |
|
2464 | + } |
|
2329 | 2465 | |
2330 | 2466 | /** |
2331 | 2467 | * Load a sub-template. |
@@ -2343,17 +2479,19 @@ discard block |
||
2343 | 2479 | { |
2344 | 2480 | global $context, $txt, $db_show_debug; |
2345 | 2481 | |
2346 | - if ($db_show_debug === true) |
|
2347 | - $context['debug']['sub_templates'][] = $sub_template_name; |
|
2482 | + if ($db_show_debug === true) { |
|
2483 | + $context['debug']['sub_templates'][] = $sub_template_name; |
|
2484 | + } |
|
2348 | 2485 | |
2349 | 2486 | // Figure out what the template function is named. |
2350 | 2487 | $theme_function = 'template_' . $sub_template_name; |
2351 | - if (function_exists($theme_function)) |
|
2352 | - $theme_function(); |
|
2353 | - elseif ($fatal === false) |
|
2354 | - fatal_lang_error('theme_template_error', 'template', array((string) $sub_template_name)); |
|
2355 | - elseif ($fatal !== 'ignore') |
|
2356 | - die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load the %s sub template!', (string) $sub_template_name), 'template')); |
|
2488 | + if (function_exists($theme_function)) { |
|
2489 | + $theme_function(); |
|
2490 | + } elseif ($fatal === false) { |
|
2491 | + fatal_lang_error('theme_template_error', 'template', array((string) $sub_template_name)); |
|
2492 | + } elseif ($fatal !== 'ignore') { |
|
2493 | + die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load the %s sub template!', (string) $sub_template_name), 'template')); |
|
2494 | + } |
|
2357 | 2495 | |
2358 | 2496 | // Are we showing debugging for templates? Just make sure not to do it before the doctype... |
2359 | 2497 | if (allowedTo('admin_forum') && isset($_REQUEST['debug']) && !in_array($sub_template_name, array('init', 'main_below')) && ob_get_length() > 0 && !isset($_REQUEST['xml'])) |
@@ -2390,8 +2528,9 @@ discard block |
||
2390 | 2528 | $params['validate'] = isset($params['validate']) ? $params['validate'] : true; |
2391 | 2529 | |
2392 | 2530 | // If this is an external file, automatically set this to false. |
2393 | - if (!empty($params['external'])) |
|
2394 | - $params['minimize'] = false; |
|
2531 | + if (!empty($params['external'])) { |
|
2532 | + $params['minimize'] = false; |
|
2533 | + } |
|
2395 | 2534 | |
2396 | 2535 | // Account for shorthand like admin.css?alp21 filenames |
2397 | 2536 | $has_seed = strpos($fileName, '.css?'); |
@@ -2408,13 +2547,10 @@ discard block |
||
2408 | 2547 | { |
2409 | 2548 | $fileUrl = $settings['default_theme_url'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
2410 | 2549 | $filePath = $settings['default_theme_dir'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
2550 | + } else { |
|
2551 | + $fileUrl = false; |
|
2411 | 2552 | } |
2412 | - |
|
2413 | - else |
|
2414 | - $fileUrl = false; |
|
2415 | - } |
|
2416 | - |
|
2417 | - else |
|
2553 | + } else |
|
2418 | 2554 | { |
2419 | 2555 | $fileUrl = $settings[$themeRef . '_url'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
2420 | 2556 | $filePath = $settings[$themeRef . '_dir'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
@@ -2429,12 +2565,14 @@ discard block |
||
2429 | 2565 | } |
2430 | 2566 | |
2431 | 2567 | // Add it to the array for use in the template |
2432 | - if (!empty($fileName)) |
|
2433 | - $context['css_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
2568 | + if (!empty($fileName)) { |
|
2569 | + $context['css_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
2570 | + } |
|
2434 | 2571 | |
2435 | - if (!empty($context['right_to_left']) && !empty($params['rtl'])) |
|
2436 | - loadCSSFile($params['rtl'], array_diff_key($params, array('rtl' => 0))); |
|
2437 | -} |
|
2572 | + if (!empty($context['right_to_left']) && !empty($params['rtl'])) { |
|
2573 | + loadCSSFile($params['rtl'], array_diff_key($params, array('rtl' => 0))); |
|
2574 | + } |
|
2575 | + } |
|
2438 | 2576 | |
2439 | 2577 | /** |
2440 | 2578 | * Add a block of inline css code to be executed later |
@@ -2451,8 +2589,9 @@ discard block |
||
2451 | 2589 | global $context; |
2452 | 2590 | |
2453 | 2591 | // Gotta add something... |
2454 | - if (empty($css)) |
|
2455 | - return false; |
|
2592 | + if (empty($css)) { |
|
2593 | + return false; |
|
2594 | + } |
|
2456 | 2595 | |
2457 | 2596 | $context['css_header'][] = $css; |
2458 | 2597 | } |
@@ -2487,8 +2626,9 @@ discard block |
||
2487 | 2626 | $params['validate'] = isset($params['validate']) ? $params['validate'] : true; |
2488 | 2627 | |
2489 | 2628 | // If this is an external file, automatically set this to false. |
2490 | - if (!empty($params['external'])) |
|
2491 | - $params['minimize'] = false; |
|
2629 | + if (!empty($params['external'])) { |
|
2630 | + $params['minimize'] = false; |
|
2631 | + } |
|
2492 | 2632 | |
2493 | 2633 | // Account for shorthand like admin.js?alp21 filenames |
2494 | 2634 | $has_seed = strpos($fileName, '.js?'); |
@@ -2505,16 +2645,12 @@ discard block |
||
2505 | 2645 | { |
2506 | 2646 | $fileUrl = $settings['default_theme_url'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
2507 | 2647 | $filePath = $settings['default_theme_dir'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
2508 | - } |
|
2509 | - |
|
2510 | - else |
|
2648 | + } else |
|
2511 | 2649 | { |
2512 | 2650 | $fileUrl = false; |
2513 | 2651 | $filePath = false; |
2514 | 2652 | } |
2515 | - } |
|
2516 | - |
|
2517 | - else |
|
2653 | + } else |
|
2518 | 2654 | { |
2519 | 2655 | $fileUrl = $settings[$themeRef . '_url'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
2520 | 2656 | $filePath = $settings[$themeRef . '_dir'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
@@ -2529,9 +2665,10 @@ discard block |
||
2529 | 2665 | } |
2530 | 2666 | |
2531 | 2667 | // Add it to the array for use in the template |
2532 | - if (!empty($fileName)) |
|
2533 | - $context['javascript_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
2534 | -} |
|
2668 | + if (!empty($fileName)) { |
|
2669 | + $context['javascript_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
2670 | + } |
|
2671 | + } |
|
2535 | 2672 | |
2536 | 2673 | /** |
2537 | 2674 | * Add a Javascript variable for output later (for feeding text strings and similar to JS) |
@@ -2545,9 +2682,10 @@ discard block |
||
2545 | 2682 | { |
2546 | 2683 | global $context; |
2547 | 2684 | |
2548 | - if (!empty($key) && (!empty($value) || $value === '0')) |
|
2549 | - $context['javascript_vars'][$key] = !empty($escape) ? JavaScriptEscape($value) : $value; |
|
2550 | -} |
|
2685 | + if (!empty($key) && (!empty($value) || $value === '0')) { |
|
2686 | + $context['javascript_vars'][$key] = !empty($escape) ? JavaScriptEscape($value) : $value; |
|
2687 | + } |
|
2688 | + } |
|
2551 | 2689 | |
2552 | 2690 | /** |
2553 | 2691 | * Add a block of inline Javascript code to be executed later |
@@ -2564,8 +2702,9 @@ discard block |
||
2564 | 2702 | { |
2565 | 2703 | global $context; |
2566 | 2704 | |
2567 | - if (empty($javascript)) |
|
2568 | - return false; |
|
2705 | + if (empty($javascript)) { |
|
2706 | + return false; |
|
2707 | + } |
|
2569 | 2708 | |
2570 | 2709 | $context['javascript_inline'][($defer === true ? 'defer' : 'standard')][] = $javascript; |
2571 | 2710 | } |
@@ -2586,15 +2725,18 @@ discard block |
||
2586 | 2725 | static $already_loaded = array(); |
2587 | 2726 | |
2588 | 2727 | // Default to the user's language. |
2589 | - if ($lang == '') |
|
2590 | - $lang = isset($user_info['language']) ? $user_info['language'] : $language; |
|
2728 | + if ($lang == '') { |
|
2729 | + $lang = isset($user_info['language']) ? $user_info['language'] : $language; |
|
2730 | + } |
|
2591 | 2731 | |
2592 | 2732 | // Do we want the English version of language file as fallback? |
2593 | - if (empty($modSettings['disable_language_fallback']) && $lang != 'english') |
|
2594 | - loadLanguage($template_name, 'english', false); |
|
2733 | + if (empty($modSettings['disable_language_fallback']) && $lang != 'english') { |
|
2734 | + loadLanguage($template_name, 'english', false); |
|
2735 | + } |
|
2595 | 2736 | |
2596 | - if (!$force_reload && isset($already_loaded[$template_name]) && $already_loaded[$template_name] == $lang) |
|
2597 | - return $lang; |
|
2737 | + if (!$force_reload && isset($already_loaded[$template_name]) && $already_loaded[$template_name] == $lang) { |
|
2738 | + return $lang; |
|
2739 | + } |
|
2598 | 2740 | |
2599 | 2741 | // Make sure we have $settings - if not we're in trouble and need to find it! |
2600 | 2742 | if (empty($settings['default_theme_dir'])) |
@@ -2605,8 +2747,9 @@ discard block |
||
2605 | 2747 | |
2606 | 2748 | // What theme are we in? |
2607 | 2749 | $theme_name = basename($settings['theme_url']); |
2608 | - if (empty($theme_name)) |
|
2609 | - $theme_name = 'unknown'; |
|
2750 | + if (empty($theme_name)) { |
|
2751 | + $theme_name = 'unknown'; |
|
2752 | + } |
|
2610 | 2753 | |
2611 | 2754 | // For each file open it up and write it out! |
2612 | 2755 | foreach (explode('+', $template_name) as $template) |
@@ -2648,8 +2791,9 @@ discard block |
||
2648 | 2791 | $found = true; |
2649 | 2792 | |
2650 | 2793 | // setlocale is required for basename() & pathinfo() to work properly on the selected language |
2651 | - if (!empty($txt['lang_locale']) && !empty($modSettings['global_character_set'])) |
|
2652 | - setlocale(LC_CTYPE, $txt['lang_locale'] . '.' . $modSettings['global_character_set']); |
|
2794 | + if (!empty($txt['lang_locale']) && !empty($modSettings['global_character_set'])) { |
|
2795 | + setlocale(LC_CTYPE, $txt['lang_locale'] . '.' . $modSettings['global_character_set']); |
|
2796 | + } |
|
2653 | 2797 | |
2654 | 2798 | break; |
2655 | 2799 | } |
@@ -2689,8 +2833,9 @@ discard block |
||
2689 | 2833 | } |
2690 | 2834 | |
2691 | 2835 | // Keep track of what we're up to soldier. |
2692 | - if ($db_show_debug === true) |
|
2693 | - $context['debug']['language_files'][] = $template_name . '.' . $lang . ' (' . $theme_name . ')'; |
|
2836 | + if ($db_show_debug === true) { |
|
2837 | + $context['debug']['language_files'][] = $template_name . '.' . $lang . ' (' . $theme_name . ')'; |
|
2838 | + } |
|
2694 | 2839 | |
2695 | 2840 | // Remember what we have loaded, and in which language. |
2696 | 2841 | $already_loaded[$template_name] = $lang; |
@@ -2736,8 +2881,9 @@ discard block |
||
2736 | 2881 | ) |
2737 | 2882 | ); |
2738 | 2883 | // In the EXTREMELY unlikely event this happens, give an error message. |
2739 | - if ($smcFunc['db_num_rows']($result) == 0) |
|
2740 | - fatal_lang_error('parent_not_found', 'critical'); |
|
2884 | + if ($smcFunc['db_num_rows']($result) == 0) { |
|
2885 | + fatal_lang_error('parent_not_found', 'critical'); |
|
2886 | + } |
|
2741 | 2887 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
2742 | 2888 | { |
2743 | 2889 | if (!isset($boards[$row['id_board']])) |
@@ -2754,8 +2900,8 @@ discard block |
||
2754 | 2900 | ); |
2755 | 2901 | } |
2756 | 2902 | // If a moderator exists for this board, add that moderator for all children too. |
2757 | - if (!empty($row['id_moderator'])) |
|
2758 | - foreach ($boards as $id => $dummy) |
|
2903 | + if (!empty($row['id_moderator'])) { |
|
2904 | + foreach ($boards as $id => $dummy) |
|
2759 | 2905 | { |
2760 | 2906 | $boards[$id]['moderators'][$row['id_moderator']] = array( |
2761 | 2907 | 'id' => $row['id_moderator'], |
@@ -2763,11 +2909,12 @@ discard block |
||
2763 | 2909 | 'href' => $scripturl . '?action=profile;u=' . $row['id_moderator'], |
2764 | 2910 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_moderator'] . '">' . $row['real_name'] . '</a>' |
2765 | 2911 | ); |
2912 | + } |
|
2766 | 2913 | } |
2767 | 2914 | |
2768 | 2915 | // If a moderator group exists for this board, add that moderator group for all children too |
2769 | - if (!empty($row['id_moderator_group'])) |
|
2770 | - foreach ($boards as $id => $dummy) |
|
2916 | + if (!empty($row['id_moderator_group'])) { |
|
2917 | + foreach ($boards as $id => $dummy) |
|
2771 | 2918 | { |
2772 | 2919 | $boards[$id]['moderator_groups'][$row['id_moderator_group']] = array( |
2773 | 2920 | 'id' => $row['id_moderator_group'], |
@@ -2775,6 +2922,7 @@ discard block |
||
2775 | 2922 | 'href' => $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'], |
2776 | 2923 | 'link' => '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'] . '">' . $row['group_name'] . '</a>' |
2777 | 2924 | ); |
2925 | + } |
|
2778 | 2926 | } |
2779 | 2927 | } |
2780 | 2928 | $smcFunc['db_free_result']($result); |
@@ -2801,23 +2949,27 @@ discard block |
||
2801 | 2949 | if (!$use_cache || ($context['languages'] = cache_get_data('known_languages', !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600)) == null) |
2802 | 2950 | { |
2803 | 2951 | // If we don't have our ucwords function defined yet, let's load the settings data. |
2804 | - if (empty($smcFunc['ucwords'])) |
|
2805 | - reloadSettings(); |
|
2952 | + if (empty($smcFunc['ucwords'])) { |
|
2953 | + reloadSettings(); |
|
2954 | + } |
|
2806 | 2955 | |
2807 | 2956 | // If we don't have our theme information yet, let's get it. |
2808 | - if (empty($settings['default_theme_dir'])) |
|
2809 | - loadTheme(0, false); |
|
2957 | + if (empty($settings['default_theme_dir'])) { |
|
2958 | + loadTheme(0, false); |
|
2959 | + } |
|
2810 | 2960 | |
2811 | 2961 | // Default language directories to try. |
2812 | 2962 | $language_directories = array( |
2813 | 2963 | $settings['default_theme_dir'] . '/languages', |
2814 | 2964 | ); |
2815 | - if (!empty($settings['actual_theme_dir']) && $settings['actual_theme_dir'] != $settings['default_theme_dir']) |
|
2816 | - $language_directories[] = $settings['actual_theme_dir'] . '/languages'; |
|
2965 | + if (!empty($settings['actual_theme_dir']) && $settings['actual_theme_dir'] != $settings['default_theme_dir']) { |
|
2966 | + $language_directories[] = $settings['actual_theme_dir'] . '/languages'; |
|
2967 | + } |
|
2817 | 2968 | |
2818 | 2969 | // We possibly have a base theme directory. |
2819 | - if (!empty($settings['base_theme_dir'])) |
|
2820 | - $language_directories[] = $settings['base_theme_dir'] . '/languages'; |
|
2970 | + if (!empty($settings['base_theme_dir'])) { |
|
2971 | + $language_directories[] = $settings['base_theme_dir'] . '/languages'; |
|
2972 | + } |
|
2821 | 2973 | |
2822 | 2974 | // Remove any duplicates. |
2823 | 2975 | $language_directories = array_unique($language_directories); |
@@ -2831,20 +2983,21 @@ discard block |
||
2831 | 2983 | foreach ($language_directories as $language_dir) |
2832 | 2984 | { |
2833 | 2985 | // Can't look in here... doesn't exist! |
2834 | - if (!file_exists($language_dir)) |
|
2835 | - continue; |
|
2986 | + if (!file_exists($language_dir)) { |
|
2987 | + continue; |
|
2988 | + } |
|
2836 | 2989 | |
2837 | 2990 | $dir = dir($language_dir); |
2838 | 2991 | while ($entry = $dir->read()) |
2839 | 2992 | { |
2840 | 2993 | // Look for the index language file... For good measure skip any "index.language-utf8.php" files |
2841 | - if (!preg_match('~^index\.(.+[^-utf8])\.php$~', $entry, $matches)) |
|
2842 | - continue; |
|
2843 | - |
|
2844 | - if (!empty($langList) && !empty($langList[$matches[1]])) |
|
2845 | - $langName = $langList[$matches[1]]; |
|
2994 | + if (!preg_match('~^index\.(.+[^-utf8])\.php$~', $entry, $matches)) { |
|
2995 | + continue; |
|
2996 | + } |
|
2846 | 2997 | |
2847 | - else |
|
2998 | + if (!empty($langList) && !empty($langList[$matches[1]])) { |
|
2999 | + $langName = $langList[$matches[1]]; |
|
3000 | + } else |
|
2848 | 3001 | { |
2849 | 3002 | $langName = $smcFunc['ucwords'](strtr($matches[1], array('_' => ' '))); |
2850 | 3003 | |
@@ -2885,12 +3038,14 @@ discard block |
||
2885 | 3038 | } |
2886 | 3039 | |
2887 | 3040 | // Do we need to store the lang list? |
2888 | - if (empty($langList)) |
|
2889 | - updateSettings(array('langList' => $smcFunc['json_encode']($catchLang))); |
|
3041 | + if (empty($langList)) { |
|
3042 | + updateSettings(array('langList' => $smcFunc['json_encode']($catchLang))); |
|
3043 | + } |
|
2890 | 3044 | |
2891 | 3045 | // Let's cash in on this deal. |
2892 | - if (!empty($modSettings['cache_enable'])) |
|
2893 | - cache_put_data('known_languages', $context['languages'], !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600); |
|
3046 | + if (!empty($modSettings['cache_enable'])) { |
|
3047 | + cache_put_data('known_languages', $context['languages'], !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600); |
|
3048 | + } |
|
2894 | 3049 | } |
2895 | 3050 | |
2896 | 3051 | return $context['languages']; |
@@ -2913,8 +3068,9 @@ discard block |
||
2913 | 3068 | global $modSettings, $options, $txt; |
2914 | 3069 | static $censor_vulgar = null, $censor_proper; |
2915 | 3070 | |
2916 | - if ((!empty($options['show_no_censored']) && !empty($modSettings['allow_no_censored']) && !$force) || empty($modSettings['censor_vulgar']) || trim($text) === '') |
|
2917 | - return $text; |
|
3071 | + if ((!empty($options['show_no_censored']) && !empty($modSettings['allow_no_censored']) && !$force) || empty($modSettings['censor_vulgar']) || trim($text) === '') { |
|
3072 | + return $text; |
|
3073 | + } |
|
2918 | 3074 | |
2919 | 3075 | // If they haven't yet been loaded, load them. |
2920 | 3076 | if ($censor_vulgar == null) |
@@ -2942,9 +3098,9 @@ discard block |
||
2942 | 3098 | { |
2943 | 3099 | $func = !empty($modSettings['censorIgnoreCase']) ? 'str_ireplace' : 'str_replace'; |
2944 | 3100 | $text = $func($censor_vulgar, $censor_proper, $text); |
3101 | + } else { |
|
3102 | + $text = preg_replace($censor_vulgar, $censor_proper, $text); |
|
2945 | 3103 | } |
2946 | - else |
|
2947 | - $text = preg_replace($censor_vulgar, $censor_proper, $text); |
|
2948 | 3104 | |
2949 | 3105 | return $text; |
2950 | 3106 | } |
@@ -2970,38 +3126,42 @@ discard block |
||
2970 | 3126 | @ini_set('track_errors', '1'); |
2971 | 3127 | |
2972 | 3128 | // Don't include the file more than once, if $once is true. |
2973 | - if ($once && in_array($filename, $templates)) |
|
2974 | - return; |
|
3129 | + if ($once && in_array($filename, $templates)) { |
|
3130 | + return; |
|
3131 | + } |
|
2975 | 3132 | // Add this file to the include list, whether $once is true or not. |
2976 | - else |
|
2977 | - $templates[] = $filename; |
|
3133 | + else { |
|
3134 | + $templates[] = $filename; |
|
3135 | + } |
|
2978 | 3136 | |
2979 | 3137 | // Are we going to use eval? |
2980 | 3138 | if (empty($modSettings['disableTemplateEval'])) |
2981 | 3139 | { |
2982 | 3140 | $file_found = file_exists($filename) && eval('?' . '>' . rtrim(file_get_contents($filename))) !== false; |
2983 | 3141 | $settings['current_include_filename'] = $filename; |
2984 | - } |
|
2985 | - else |
|
3142 | + } else |
|
2986 | 3143 | { |
2987 | 3144 | $file_found = file_exists($filename); |
2988 | 3145 | |
2989 | - if ($once && $file_found) |
|
2990 | - require_once($filename); |
|
2991 | - elseif ($file_found) |
|
2992 | - require($filename); |
|
3146 | + if ($once && $file_found) { |
|
3147 | + require_once($filename); |
|
3148 | + } elseif ($file_found) { |
|
3149 | + require($filename); |
|
3150 | + } |
|
2993 | 3151 | } |
2994 | 3152 | |
2995 | 3153 | if ($file_found !== true) |
2996 | 3154 | { |
2997 | 3155 | ob_end_clean(); |
2998 | - if (!empty($modSettings['enableCompressedOutput'])) |
|
2999 | - @ob_start('ob_gzhandler'); |
|
3000 | - else |
|
3001 | - ob_start(); |
|
3156 | + if (!empty($modSettings['enableCompressedOutput'])) { |
|
3157 | + @ob_start('ob_gzhandler'); |
|
3158 | + } else { |
|
3159 | + ob_start(); |
|
3160 | + } |
|
3002 | 3161 | |
3003 | - if (isset($_GET['debug'])) |
|
3004 | - header('Content-Type: application/xhtml+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
3162 | + if (isset($_GET['debug'])) { |
|
3163 | + header('Content-Type: application/xhtml+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
3164 | + } |
|
3005 | 3165 | |
3006 | 3166 | // Don't cache error pages!! |
3007 | 3167 | header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
@@ -3020,12 +3180,13 @@ discard block |
||
3020 | 3180 | echo '<!DOCTYPE html> |
3021 | 3181 | <html', !empty($context['right_to_left']) ? ' dir="rtl"' : '', '> |
3022 | 3182 | <head>'; |
3023 | - if (isset($context['character_set'])) |
|
3024 | - echo ' |
|
3183 | + if (isset($context['character_set'])) { |
|
3184 | + echo ' |
|
3025 | 3185 | <meta charset="', $context['character_set'], '">'; |
3186 | + } |
|
3026 | 3187 | |
3027 | - if (!empty($maintenance) && !allowedTo('admin_forum')) |
|
3028 | - echo ' |
|
3188 | + if (!empty($maintenance) && !allowedTo('admin_forum')) { |
|
3189 | + echo ' |
|
3029 | 3190 | <title>', $mtitle, '</title> |
3030 | 3191 | </head> |
3031 | 3192 | <body> |
@@ -3033,8 +3194,8 @@ discard block |
||
3033 | 3194 | ', $mmessage, ' |
3034 | 3195 | </body> |
3035 | 3196 | </html>'; |
3036 | - elseif (!allowedTo('admin_forum')) |
|
3037 | - echo ' |
|
3197 | + } elseif (!allowedTo('admin_forum')) { |
|
3198 | + echo ' |
|
3038 | 3199 | <title>', $txt['template_parse_error'], '</title> |
3039 | 3200 | </head> |
3040 | 3201 | <body> |
@@ -3042,16 +3203,18 @@ discard block |
||
3042 | 3203 | ', $txt['template_parse_error_message'], ' |
3043 | 3204 | </body> |
3044 | 3205 | </html>'; |
3045 | - else |
|
3206 | + } else |
|
3046 | 3207 | { |
3047 | 3208 | require_once($sourcedir . '/Subs-Package.php'); |
3048 | 3209 | |
3049 | 3210 | $error = fetch_web_data($boardurl . strtr($filename, array($boarddir => '', strtr($boarddir, '\\', '/') => ''))); |
3050 | 3211 | $error_array = error_get_last(); |
3051 | - if (empty($error) && ini_get('track_errors') && !empty($error_array)) |
|
3052 | - $error = $error_array['message']; |
|
3053 | - if (empty($error)) |
|
3054 | - $error = $txt['template_parse_errmsg']; |
|
3212 | + if (empty($error) && ini_get('track_errors') && !empty($error_array)) { |
|
3213 | + $error = $error_array['message']; |
|
3214 | + } |
|
3215 | + if (empty($error)) { |
|
3216 | + $error = $txt['template_parse_errmsg']; |
|
3217 | + } |
|
3055 | 3218 | |
3056 | 3219 | $error = strtr($error, array('<b>' => '<strong>', '</b>' => '</strong>')); |
3057 | 3220 | |
@@ -3062,11 +3225,12 @@ discard block |
||
3062 | 3225 | <h3>', $txt['template_parse_error'], '</h3> |
3063 | 3226 | ', sprintf($txt['template_parse_error_details'], strtr($filename, array($boarddir => '', strtr($boarddir, '\\', '/') => ''))); |
3064 | 3227 | |
3065 | - if (!empty($error)) |
|
3066 | - echo ' |
|
3228 | + if (!empty($error)) { |
|
3229 | + echo ' |
|
3067 | 3230 | <hr> |
3068 | 3231 | |
3069 | 3232 | <div style="margin: 0 20px;"><pre>', strtr(strtr($error, array('<strong>' . $boarddir => '<strong>...', '<strong>' . strtr($boarddir, '\\', '/') => '<strong>...')), '\\', '/'), '</pre></div>'; |
3233 | + } |
|
3070 | 3234 | |
3071 | 3235 | // I know, I know... this is VERY COMPLICATED. Still, it's good. |
3072 | 3236 | if (preg_match('~ <strong>(\d+)</strong><br( /)?' . '>$~i', $error, $match) != 0) |
@@ -3076,10 +3240,11 @@ discard block |
||
3076 | 3240 | $data2 = preg_split('~\<br( /)?\>~', $data2); |
3077 | 3241 | |
3078 | 3242 | // Fix the PHP code stuff... |
3079 | - if (!isBrowser('gecko')) |
|
3080 | - $data2 = str_replace("\t", '<span style="white-space: pre;">' . "\t" . '</span>', $data2); |
|
3081 | - else |
|
3082 | - $data2 = str_replace('<pre style="display: inline;">' . "\t" . '</pre>', "\t", $data2); |
|
3243 | + if (!isBrowser('gecko')) { |
|
3244 | + $data2 = str_replace("\t", '<span style="white-space: pre;">' . "\t" . '</span>', $data2); |
|
3245 | + } else { |
|
3246 | + $data2 = str_replace('<pre style="display: inline;">' . "\t" . '</pre>', "\t", $data2); |
|
3247 | + } |
|
3083 | 3248 | |
3084 | 3249 | // Now we get to work around a bug in PHP where it doesn't escape <br>s! |
3085 | 3250 | $j = -1; |
@@ -3087,8 +3252,9 @@ discard block |
||
3087 | 3252 | { |
3088 | 3253 | $j++; |
3089 | 3254 | |
3090 | - if (substr_count($line, '<br>') == 0) |
|
3091 | - continue; |
|
3255 | + if (substr_count($line, '<br>') == 0) { |
|
3256 | + continue; |
|
3257 | + } |
|
3092 | 3258 | |
3093 | 3259 | $n = substr_count($line, '<br>'); |
3094 | 3260 | for ($i = 0; $i < $n; $i++) |
@@ -3107,38 +3273,42 @@ discard block |
||
3107 | 3273 | // Figure out what the color coding was before... |
3108 | 3274 | $line = max($match[1] - 9, 1); |
3109 | 3275 | $last_line = ''; |
3110 | - for ($line2 = $line - 1; $line2 > 1; $line2--) |
|
3111 | - if (strpos($data2[$line2], '<') !== false) |
|
3276 | + for ($line2 = $line - 1; $line2 > 1; $line2--) { |
|
3277 | + if (strpos($data2[$line2], '<') !== false) |
|
3112 | 3278 | { |
3113 | 3279 | if (preg_match('~(<[^/>]+>)[^<]*$~', $data2[$line2], $color_match) != 0) |
3114 | 3280 | $last_line = $color_match[1]; |
3281 | + } |
|
3115 | 3282 | break; |
3116 | 3283 | } |
3117 | 3284 | |
3118 | 3285 | // Show the relevant lines... |
3119 | 3286 | for ($n = min($match[1] + 4, count($data2) + 1); $line <= $n; $line++) |
3120 | 3287 | { |
3121 | - if ($line == $match[1]) |
|
3122 | - echo '</pre><div style="background-color: #ffb0b5;"><pre style="margin: 0;">'; |
|
3288 | + if ($line == $match[1]) { |
|
3289 | + echo '</pre><div style="background-color: #ffb0b5;"><pre style="margin: 0;">'; |
|
3290 | + } |
|
3123 | 3291 | |
3124 | 3292 | echo '<span style="color: black;">', sprintf('%' . strlen($n) . 's', $line), ':</span> '; |
3125 | - if (isset($data2[$line]) && $data2[$line] != '') |
|
3126 | - echo substr($data2[$line], 0, 2) == '</' ? preg_replace('~^</[^>]+>~', '', $data2[$line]) : $last_line . $data2[$line]; |
|
3293 | + if (isset($data2[$line]) && $data2[$line] != '') { |
|
3294 | + echo substr($data2[$line], 0, 2) == '</' ? preg_replace('~^</[^>]+>~', '', $data2[$line]) : $last_line . $data2[$line]; |
|
3295 | + } |
|
3127 | 3296 | |
3128 | 3297 | if (isset($data2[$line]) && preg_match('~(<[^/>]+>)[^<]*$~', $data2[$line], $color_match) != 0) |
3129 | 3298 | { |
3130 | 3299 | $last_line = $color_match[1]; |
3131 | 3300 | echo '</', substr($last_line, 1, 4), '>'; |
3301 | + } elseif ($last_line != '' && strpos($data2[$line], '<') !== false) { |
|
3302 | + $last_line = ''; |
|
3303 | + } elseif ($last_line != '' && $data2[$line] != '') { |
|
3304 | + echo '</', substr($last_line, 1, 4), '>'; |
|
3132 | 3305 | } |
3133 | - elseif ($last_line != '' && strpos($data2[$line], '<') !== false) |
|
3134 | - $last_line = ''; |
|
3135 | - elseif ($last_line != '' && $data2[$line] != '') |
|
3136 | - echo '</', substr($last_line, 1, 4), '>'; |
|
3137 | 3306 | |
3138 | - if ($line == $match[1]) |
|
3139 | - echo '</pre></div><pre style="margin: 0;">'; |
|
3140 | - else |
|
3141 | - echo "\n"; |
|
3307 | + if ($line == $match[1]) { |
|
3308 | + echo '</pre></div><pre style="margin: 0;">'; |
|
3309 | + } else { |
|
3310 | + echo "\n"; |
|
3311 | + } |
|
3142 | 3312 | } |
3143 | 3313 | |
3144 | 3314 | echo '</pre></div>'; |
@@ -3162,8 +3332,9 @@ discard block |
||
3162 | 3332 | global $db_type, $db_name, $ssi_db_user, $ssi_db_passwd, $sourcedir, $db_prefix, $db_port; |
3163 | 3333 | |
3164 | 3334 | // Figure out what type of database we are using. |
3165 | - if (empty($db_type) || !file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) |
|
3166 | - $db_type = 'mysql'; |
|
3335 | + if (empty($db_type) || !file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) { |
|
3336 | + $db_type = 'mysql'; |
|
3337 | + } |
|
3167 | 3338 | |
3168 | 3339 | // Load the file for the database. |
3169 | 3340 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
@@ -3171,8 +3342,9 @@ discard block |
||
3171 | 3342 | $db_options = array(); |
3172 | 3343 | |
3173 | 3344 | // Add in the port if needed |
3174 | - if (!empty($db_port)) |
|
3175 | - $db_options['port'] = $db_port; |
|
3345 | + if (!empty($db_port)) { |
|
3346 | + $db_options['port'] = $db_port; |
|
3347 | + } |
|
3176 | 3348 | |
3177 | 3349 | // If we are in SSI try them first, but don't worry if it doesn't work, we have the normal username and password we can use. |
3178 | 3350 | if (SMF == 'SSI' && !empty($ssi_db_user) && !empty($ssi_db_passwd)) |
@@ -3191,13 +3363,15 @@ discard block |
||
3191 | 3363 | } |
3192 | 3364 | |
3193 | 3365 | // Safe guard here, if there isn't a valid connection lets put a stop to it. |
3194 | - if (!$db_connection) |
|
3195 | - display_db_error(); |
|
3366 | + if (!$db_connection) { |
|
3367 | + display_db_error(); |
|
3368 | + } |
|
3196 | 3369 | |
3197 | 3370 | // If in SSI mode fix up the prefix. |
3198 | - if (SMF == 'SSI') |
|
3199 | - db_fix_prefix($db_prefix, $db_name); |
|
3200 | -} |
|
3371 | + if (SMF == 'SSI') { |
|
3372 | + db_fix_prefix($db_prefix, $db_name); |
|
3373 | + } |
|
3374 | + } |
|
3201 | 3375 | |
3202 | 3376 | /** |
3203 | 3377 | * Try to load up a supported caching method. This is saved in $cacheAPI if we are not overriding it. |
@@ -3211,10 +3385,11 @@ discard block |
||
3211 | 3385 | global $sourcedir, $cacheAPI, $cache_accelerator; |
3212 | 3386 | |
3213 | 3387 | // Not overriding this and we have a cacheAPI, send it back. |
3214 | - if (empty($overrideCache) && is_object($cacheAPI)) |
|
3215 | - return $cacheAPI; |
|
3216 | - elseif (is_null($cacheAPI)) |
|
3217 | - $cacheAPI = false; |
|
3388 | + if (empty($overrideCache) && is_object($cacheAPI)) { |
|
3389 | + return $cacheAPI; |
|
3390 | + } elseif (is_null($cacheAPI)) { |
|
3391 | + $cacheAPI = false; |
|
3392 | + } |
|
3218 | 3393 | |
3219 | 3394 | // Make sure our class is in session. |
3220 | 3395 | require_once($sourcedir . '/Class-CacheAPI.php'); |
@@ -3235,8 +3410,9 @@ discard block |
||
3235 | 3410 | if (!$testAPI->isSupported()) |
3236 | 3411 | { |
3237 | 3412 | // Can we save ourselves? |
3238 | - if (!empty($fallbackSMF) && is_null($overrideCache) && $tryAccelerator != 'smf') |
|
3239 | - return loadCacheAccelerator(null, false); |
|
3413 | + if (!empty($fallbackSMF) && is_null($overrideCache) && $tryAccelerator != 'smf') { |
|
3414 | + return loadCacheAccelerator(null, false); |
|
3415 | + } |
|
3240 | 3416 | return false; |
3241 | 3417 | } |
3242 | 3418 | |
@@ -3248,9 +3424,9 @@ discard block |
||
3248 | 3424 | { |
3249 | 3425 | $cacheAPI = $testAPI; |
3250 | 3426 | return $cacheAPI; |
3427 | + } else { |
|
3428 | + return $testAPI; |
|
3251 | 3429 | } |
3252 | - else |
|
3253 | - return $testAPI; |
|
3254 | 3430 | } |
3255 | 3431 | } |
3256 | 3432 | |
@@ -3270,8 +3446,9 @@ discard block |
||
3270 | 3446 | |
3271 | 3447 | // @todo Why are we doing this if caching is disabled? |
3272 | 3448 | |
3273 | - if (function_exists('call_integration_hook')) |
|
3274 | - call_integration_hook('pre_cache_quick_get', array(&$key, &$file, &$function, &$params, &$level)); |
|
3449 | + if (function_exists('call_integration_hook')) { |
|
3450 | + call_integration_hook('pre_cache_quick_get', array(&$key, &$file, &$function, &$params, &$level)); |
|
3451 | + } |
|
3275 | 3452 | |
3276 | 3453 | /* Refresh the cache if either: |
3277 | 3454 | 1. Caching is disabled. |
@@ -3285,16 +3462,19 @@ discard block |
||
3285 | 3462 | require_once($sourcedir . '/' . $file); |
3286 | 3463 | $cache_block = call_user_func_array($function, $params); |
3287 | 3464 | |
3288 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= $level) |
|
3289 | - cache_put_data($key, $cache_block, $cache_block['expires'] - time()); |
|
3465 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= $level) { |
|
3466 | + cache_put_data($key, $cache_block, $cache_block['expires'] - time()); |
|
3467 | + } |
|
3290 | 3468 | } |
3291 | 3469 | |
3292 | 3470 | // Some cached data may need a freshening up after retrieval. |
3293 | - if (!empty($cache_block['post_retri_eval'])) |
|
3294 | - eval($cache_block['post_retri_eval']); |
|
3471 | + if (!empty($cache_block['post_retri_eval'])) { |
|
3472 | + eval($cache_block['post_retri_eval']); |
|
3473 | + } |
|
3295 | 3474 | |
3296 | - if (function_exists('call_integration_hook')) |
|
3297 | - call_integration_hook('post_cache_quick_get', array(&$cache_block)); |
|
3475 | + if (function_exists('call_integration_hook')) { |
|
3476 | + call_integration_hook('post_cache_quick_get', array(&$cache_block)); |
|
3477 | + } |
|
3298 | 3478 | |
3299 | 3479 | return $cache_block['data']; |
3300 | 3480 | } |
@@ -3321,8 +3501,9 @@ discard block |
||
3321 | 3501 | global $smcFunc, $cache_enable, $cacheAPI; |
3322 | 3502 | global $cache_hits, $cache_count, $db_show_debug; |
3323 | 3503 | |
3324 | - if (empty($cache_enable) || empty($cacheAPI)) |
|
3325 | - return; |
|
3504 | + if (empty($cache_enable) || empty($cacheAPI)) { |
|
3505 | + return; |
|
3506 | + } |
|
3326 | 3507 | |
3327 | 3508 | $cache_count = isset($cache_count) ? $cache_count + 1 : 1; |
3328 | 3509 | if (isset($db_show_debug) && $db_show_debug === true) |
@@ -3335,12 +3516,14 @@ discard block |
||
3335 | 3516 | $value = $value === null ? null : (isset($smcFunc['json_encode']) ? $smcFunc['json_encode']($value) : json_encode($value)); |
3336 | 3517 | $cacheAPI->putData($key, $value, $ttl); |
3337 | 3518 | |
3338 | - if (function_exists('call_integration_hook')) |
|
3339 | - call_integration_hook('cache_put_data', array(&$key, &$value, &$ttl)); |
|
3519 | + if (function_exists('call_integration_hook')) { |
|
3520 | + call_integration_hook('cache_put_data', array(&$key, &$value, &$ttl)); |
|
3521 | + } |
|
3340 | 3522 | |
3341 | - if (isset($db_show_debug) && $db_show_debug === true) |
|
3342 | - $cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
3343 | -} |
|
3523 | + if (isset($db_show_debug) && $db_show_debug === true) { |
|
3524 | + $cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
3525 | + } |
|
3526 | + } |
|
3344 | 3527 | |
3345 | 3528 | /** |
3346 | 3529 | * Gets the value from the cache specified by key, so long as it is not older than ttl seconds. |
@@ -3356,8 +3539,9 @@ discard block |
||
3356 | 3539 | global $smcFunc, $cache_enable, $cacheAPI; |
3357 | 3540 | global $cache_hits, $cache_count, $cache_misses, $cache_count_misses, $db_show_debug; |
3358 | 3541 | |
3359 | - if (empty($cache_enable) || empty($cacheAPI)) |
|
3360 | - return; |
|
3542 | + if (empty($cache_enable) || empty($cacheAPI)) { |
|
3543 | + return; |
|
3544 | + } |
|
3361 | 3545 | |
3362 | 3546 | $cache_count = isset($cache_count) ? $cache_count + 1 : 1; |
3363 | 3547 | if (isset($db_show_debug) && $db_show_debug === true) |
@@ -3377,16 +3561,18 @@ discard block |
||
3377 | 3561 | |
3378 | 3562 | if (empty($value)) |
3379 | 3563 | { |
3380 | - if (!is_array($cache_misses)) |
|
3381 | - $cache_misses = array(); |
|
3564 | + if (!is_array($cache_misses)) { |
|
3565 | + $cache_misses = array(); |
|
3566 | + } |
|
3382 | 3567 | |
3383 | 3568 | $cache_count_misses = isset($cache_count_misses) ? $cache_count_misses + 1 : 1; |
3384 | 3569 | $cache_misses[$cache_count_misses] = array('k' => $original_key, 'd' => 'get'); |
3385 | 3570 | } |
3386 | 3571 | } |
3387 | 3572 | |
3388 | - if (function_exists('call_integration_hook') && isset($value)) |
|
3389 | - call_integration_hook('cache_get_data', array(&$key, &$ttl, &$value)); |
|
3573 | + if (function_exists('call_integration_hook') && isset($value)) { |
|
3574 | + call_integration_hook('cache_get_data', array(&$key, &$ttl, &$value)); |
|
3575 | + } |
|
3390 | 3576 | |
3391 | 3577 | return empty($value) ? null : (isset($smcFunc['json_encode']) ? $smcFunc['json_decode']($value, true) : smf_json_decode($value, true)); |
3392 | 3578 | } |
@@ -3408,8 +3594,9 @@ discard block |
||
3408 | 3594 | global $cacheAPI; |
3409 | 3595 | |
3410 | 3596 | // If we can't get to the API, can't do this. |
3411 | - if (empty($cacheAPI)) |
|
3412 | - return; |
|
3597 | + if (empty($cacheAPI)) { |
|
3598 | + return; |
|
3599 | + } |
|
3413 | 3600 | |
3414 | 3601 | // Ask the API to do the heavy lifting. cleanCache also calls invalidateCache to be sure. |
3415 | 3602 | $cacheAPI->cleanCache($type); |
@@ -3434,8 +3621,9 @@ discard block |
||
3434 | 3621 | global $modSettings, $boardurl, $smcFunc, $image_proxy_enabled, $image_proxy_secret; |
3435 | 3622 | |
3436 | 3623 | // Come on! |
3437 | - if (empty($data)) |
|
3438 | - return array(); |
|
3624 | + if (empty($data)) { |
|
3625 | + return array(); |
|
3626 | + } |
|
3439 | 3627 | |
3440 | 3628 | // Set a nice default var. |
3441 | 3629 | $image = ''; |
@@ -3443,11 +3631,11 @@ discard block |
||
3443 | 3631 | // Gravatar has been set as mandatory! |
3444 | 3632 | if (!empty($modSettings['gravatarOverride'])) |
3445 | 3633 | { |
3446 | - if (!empty($modSettings['gravatarAllowExtraEmail']) && !empty($data['avatar']) && stristr($data['avatar'], 'gravatar://')) |
|
3447 | - $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
3448 | - |
|
3449 | - else if (!empty($data['email'])) |
|
3450 | - $image = get_gravatar_url($data['email']); |
|
3634 | + if (!empty($modSettings['gravatarAllowExtraEmail']) && !empty($data['avatar']) && stristr($data['avatar'], 'gravatar://')) { |
|
3635 | + $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
3636 | + } else if (!empty($data['email'])) { |
|
3637 | + $image = get_gravatar_url($data['email']); |
|
3638 | + } |
|
3451 | 3639 | } |
3452 | 3640 | |
3453 | 3641 | // Look if the user has a gravatar field or has set an external url as avatar. |
@@ -3459,54 +3647,60 @@ discard block |
||
3459 | 3647 | // Gravatar. |
3460 | 3648 | if (stristr($data['avatar'], 'gravatar://')) |
3461 | 3649 | { |
3462 | - if ($data['avatar'] == 'gravatar://') |
|
3463 | - $image = get_gravatar_url($data['email']); |
|
3464 | - |
|
3465 | - elseif (!empty($modSettings['gravatarAllowExtraEmail'])) |
|
3466 | - $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
3650 | + if ($data['avatar'] == 'gravatar://') { |
|
3651 | + $image = get_gravatar_url($data['email']); |
|
3652 | + } elseif (!empty($modSettings['gravatarAllowExtraEmail'])) { |
|
3653 | + $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
3654 | + } |
|
3467 | 3655 | } |
3468 | 3656 | |
3469 | 3657 | // External url. |
3470 | 3658 | else |
3471 | 3659 | { |
3472 | 3660 | // Using ssl? |
3473 | - if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($data['avatar'], 'http://') !== false) |
|
3474 | - $image = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($data['avatar']) . '&hash=' . md5($data['avatar'] . $image_proxy_secret); |
|
3661 | + if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($data['avatar'], 'http://') !== false) { |
|
3662 | + $image = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($data['avatar']) . '&hash=' . md5($data['avatar'] . $image_proxy_secret); |
|
3663 | + } |
|
3475 | 3664 | |
3476 | 3665 | // Just a plain external url. |
3477 | - else |
|
3478 | - $image = (stristr($data['avatar'], 'http://') || stristr($data['avatar'], 'https://')) ? $data['avatar'] : $modSettings['avatar_url'] . '/' . $data['avatar']; |
|
3666 | + else { |
|
3667 | + $image = (stristr($data['avatar'], 'http://') || stristr($data['avatar'], 'https://')) ? $data['avatar'] : $modSettings['avatar_url'] . '/' . $data['avatar']; |
|
3668 | + } |
|
3479 | 3669 | } |
3480 | 3670 | } |
3481 | 3671 | |
3482 | 3672 | // Perhaps this user has an attachment as avatar... |
3483 | - else if (!empty($data['filename'])) |
|
3484 | - $image = $modSettings['custom_avatar_url'] . '/' . $data['filename']; |
|
3673 | + else if (!empty($data['filename'])) { |
|
3674 | + $image = $modSettings['custom_avatar_url'] . '/' . $data['filename']; |
|
3675 | + } |
|
3485 | 3676 | |
3486 | 3677 | // Right... no avatar... use our default image. |
3487 | - else |
|
3488 | - $image = $modSettings['avatar_url'] . '/default.png'; |
|
3678 | + else { |
|
3679 | + $image = $modSettings['avatar_url'] . '/default.png'; |
|
3680 | + } |
|
3489 | 3681 | } |
3490 | 3682 | |
3491 | 3683 | call_integration_hook('integrate_set_avatar_data', array(&$image, &$data)); |
3492 | 3684 | |
3493 | 3685 | // At this point in time $image has to be filled unless you chose to force gravatar and the user doesn't have the needed data to retrieve it... thus a check for !empty() is still needed. |
3494 | - if (!empty($image)) |
|
3495 | - return array( |
|
3686 | + if (!empty($image)) { |
|
3687 | + return array( |
|
3496 | 3688 | 'name' => !empty($data['avatar']) ? $data['avatar'] : '', |
3497 | 3689 | 'image' => '<img class="avatar" src="' . $image . '" />', |
3498 | 3690 | 'href' => $image, |
3499 | 3691 | 'url' => $image, |
3500 | 3692 | ); |
3693 | + } |
|
3501 | 3694 | |
3502 | 3695 | // Fallback to make life easier for everyone... |
3503 | - else |
|
3504 | - return array( |
|
3696 | + else { |
|
3697 | + return array( |
|
3505 | 3698 | 'name' => '', |
3506 | 3699 | 'image' => '', |
3507 | 3700 | 'href' => '', |
3508 | 3701 | 'url' => '', |
3509 | 3702 | ); |
3510 | -} |
|
3703 | + } |
|
3704 | + } |
|
3511 | 3705 | |
3512 | 3706 | ?> |
3513 | 3707 | \ No newline at end of file |
@@ -2259,9 +2259,9 @@ discard block |
||
2259 | 2259 | * |
2260 | 2260 | * @uses the template_include() function to include the file. |
2261 | 2261 | * @param string $template_name The name of the template to load |
2262 | - * @param array|string $style_sheets The name of a single stylesheet or an array of names of stylesheets to load |
|
2262 | + * @param string $style_sheets The name of a single stylesheet or an array of names of stylesheets to load |
|
2263 | 2263 | * @param bool $fatal If true, dies with an error message if the template cannot be found |
2264 | - * @return boolean Whether or not the template was loaded |
|
2264 | + * @return boolean|null Whether or not the template was loaded |
|
2265 | 2265 | */ |
2266 | 2266 | function loadTemplate($template_name, $style_sheets = array(), $fatal = true) |
2267 | 2267 | { |
@@ -2444,7 +2444,7 @@ discard block |
||
2444 | 2444 | * - all code added with this function is added to the same <style> tag so do make sure your css is valid! |
2445 | 2445 | * |
2446 | 2446 | * @param string $css Some css code |
2447 | - * @return void|bool Adds the CSS to the $context['css_header'] array or returns if no CSS is specified |
|
2447 | + * @return false|null Adds the CSS to the $context['css_header'] array or returns if no CSS is specified |
|
2448 | 2448 | */ |
2449 | 2449 | function addInlineCss($css) |
2450 | 2450 | { |
@@ -2558,7 +2558,7 @@ discard block |
||
2558 | 2558 | * |
2559 | 2559 | * @param string $javascript Some JS code |
2560 | 2560 | * @param bool $defer Whether the script should load in <head> or before the closing <html> tag |
2561 | - * @return void|bool Adds the code to one of the $context['javascript_inline'] arrays or returns if no JS was specified |
|
2561 | + * @return false|null Adds the code to one of the $context['javascript_inline'] arrays or returns if no JS was specified |
|
2562 | 2562 | */ |
2563 | 2563 | function addInlineJavaScript($javascript, $defer = false) |
2564 | 2564 | { |
@@ -2791,7 +2791,7 @@ discard block |
||
2791 | 2791 | * It will try to choose only utf8 or non-utf8 languages. |
2792 | 2792 | * |
2793 | 2793 | * @param bool $use_cache Whether or not to use the cache |
2794 | - * @return array An array of information about available languages |
|
2794 | + * @return string An array of information about available languages |
|
2795 | 2795 | */ |
2796 | 2796 | function getLanguages($use_cache = true) |
2797 | 2797 | { |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * The main dispatcher; doesn't do anything, just delegates. |
@@ -92,18 +93,19 @@ discard block |
||
92 | 93 | checkSession('get'); |
93 | 94 | validateToken('admin-bm-' . (int) $_REQUEST['src_board'], 'request'); |
94 | 95 | |
95 | - if ($_REQUEST['move_to'] === 'top') |
|
96 | - $boardOptions = array( |
|
96 | + if ($_REQUEST['move_to'] === 'top') { |
|
97 | + $boardOptions = array( |
|
97 | 98 | 'move_to' => $_REQUEST['move_to'], |
98 | 99 | 'target_category' => (int) $_REQUEST['target_cat'], |
99 | 100 | 'move_first_child' => true, |
100 | 101 | ); |
101 | - else |
|
102 | - $boardOptions = array( |
|
102 | + } else { |
|
103 | + $boardOptions = array( |
|
103 | 104 | 'move_to' => $_REQUEST['move_to'], |
104 | 105 | 'target_board' => (int) $_REQUEST['target_board'], |
105 | 106 | 'move_first_child' => true, |
106 | 107 | ); |
108 | + } |
|
107 | 109 | modifyBoard((int) $_REQUEST['src_board'], $boardOptions); |
108 | 110 | } |
109 | 111 | |
@@ -148,15 +150,16 @@ discard block |
||
148 | 150 | $security = $context['session_var'] . '=' . $context['session_id'] . ';' . $context['admin-bm-' . $context['move_board'] . '_token_var'] . '=' . $context['admin-bm-' . $context['move_board'] . '_token']; |
149 | 151 | foreach ($boardList[$catid] as $boardid) |
150 | 152 | { |
151 | - if (!isset($context['categories'][$catid]['move_link'])) |
|
152 | - $context['categories'][$catid]['move_link'] = array( |
|
153 | + if (!isset($context['categories'][$catid]['move_link'])) { |
|
154 | + $context['categories'][$catid]['move_link'] = array( |
|
153 | 155 | 'child_level' => 0, |
154 | 156 | 'label' => $txt['mboards_order_before'] . ' \'' . $smcFunc['htmlspecialchars']($boards[$boardid]['name']) . '\'', |
155 | 157 | 'href' => $scripturl . '?action=admin;area=manageboards;sa=move;src_board=' . $context['move_board'] . ';target_board=' . $boardid . ';move_to=before;' . $security, |
156 | 158 | ); |
159 | + } |
|
157 | 160 | |
158 | - if (!$context['categories'][$catid]['boards'][$boardid]['move']) |
|
159 | - $context['categories'][$catid]['boards'][$boardid]['move_links'] = array( |
|
161 | + if (!$context['categories'][$catid]['boards'][$boardid]['move']) { |
|
162 | + $context['categories'][$catid]['boards'][$boardid]['move_links'] = array( |
|
160 | 163 | array( |
161 | 164 | 'child_level' => $boards[$boardid]['level'], |
162 | 165 | 'label' => $txt['mboards_order_after'] . '\'' . $smcFunc['htmlspecialchars']($boards[$boardid]['name']) . '\'', |
@@ -170,34 +173,39 @@ discard block |
||
170 | 173 | 'class' => 'here', |
171 | 174 | ), |
172 | 175 | ); |
176 | + } |
|
173 | 177 | |
174 | 178 | $difference = $boards[$boardid]['level'] - $prev_child_level; |
175 | - if ($difference == 1) |
|
176 | - array_push($stack, !empty($context['categories'][$catid]['boards'][$prev_board]['move_links']) ? array_shift($context['categories'][$catid]['boards'][$prev_board]['move_links']) : null); |
|
177 | - elseif ($difference < 0) |
|
179 | + if ($difference == 1) { |
|
180 | + array_push($stack, !empty($context['categories'][$catid]['boards'][$prev_board]['move_links']) ? array_shift($context['categories'][$catid]['boards'][$prev_board]['move_links']) : null); |
|
181 | + } elseif ($difference < 0) |
|
178 | 182 | { |
179 | - if (empty($context['categories'][$catid]['boards'][$prev_board]['move_links'])) |
|
180 | - $context['categories'][$catid]['boards'][$prev_board]['move_links'] = array(); |
|
181 | - for ($i = 0; $i < -$difference; $i++) |
|
182 | - if (($temp = array_pop($stack)) != null) |
|
183 | + if (empty($context['categories'][$catid]['boards'][$prev_board]['move_links'])) { |
|
184 | + $context['categories'][$catid]['boards'][$prev_board]['move_links'] = array(); |
|
185 | + } |
|
186 | + for ($i = 0; $i < -$difference; $i++) { |
|
187 | + if (($temp = array_pop($stack)) != null) |
|
183 | 188 | array_unshift($context['categories'][$catid]['boards'][$prev_board]['move_links'], $temp); |
189 | + } |
|
184 | 190 | } |
185 | 191 | |
186 | 192 | $prev_board = $boardid; |
187 | 193 | $prev_child_level = $boards[$boardid]['level']; |
188 | 194 | |
189 | 195 | } |
190 | - if (!empty($stack) && !empty($context['categories'][$catid]['boards'][$prev_board]['move_links'])) |
|
191 | - $context['categories'][$catid]['boards'][$prev_board]['move_links'] = array_merge($stack, $context['categories'][$catid]['boards'][$prev_board]['move_links']); |
|
192 | - elseif (!empty($stack)) |
|
193 | - $context['categories'][$catid]['boards'][$prev_board]['move_links'] = $stack; |
|
196 | + if (!empty($stack) && !empty($context['categories'][$catid]['boards'][$prev_board]['move_links'])) { |
|
197 | + $context['categories'][$catid]['boards'][$prev_board]['move_links'] = array_merge($stack, $context['categories'][$catid]['boards'][$prev_board]['move_links']); |
|
198 | + } elseif (!empty($stack)) { |
|
199 | + $context['categories'][$catid]['boards'][$prev_board]['move_links'] = $stack; |
|
200 | + } |
|
194 | 201 | |
195 | - if (empty($boardList[$catid])) |
|
196 | - $context['categories'][$catid]['move_link'] = array( |
|
202 | + if (empty($boardList[$catid])) { |
|
203 | + $context['categories'][$catid]['move_link'] = array( |
|
197 | 204 | 'child_level' => 0, |
198 | 205 | 'label' => $txt['mboards_order_before'] . ' \'' . $smcFunc['htmlspecialchars']($tree['node']['name']) . '\'', |
199 | 206 | 'href' => $scripturl . '?action=admin;area=manageboards;sa=move;src_board=' . $context['move_board'] . ';target_cat=' . $catid . ';move_to=top;' . $security, |
200 | 207 | ); |
208 | + } |
|
201 | 209 | } |
202 | 210 | } |
203 | 211 | |
@@ -253,9 +261,9 @@ discard block |
||
253 | 261 | ); |
254 | 262 | } |
255 | 263 | // Category doesn't exist, man... sorry. |
256 | - elseif (!isset($cat_tree[$_REQUEST['cat']])) |
|
257 | - redirectexit('action=admin;area=manageboards'); |
|
258 | - else |
|
264 | + elseif (!isset($cat_tree[$_REQUEST['cat']])) { |
|
265 | + redirectexit('action=admin;area=manageboards'); |
|
266 | + } else |
|
259 | 267 | { |
260 | 268 | $context['category'] = array( |
261 | 269 | 'id' => $_REQUEST['cat'], |
@@ -267,30 +275,31 @@ discard block |
||
267 | 275 | 'is_empty' => empty($cat_tree[$_REQUEST['cat']]['children']) |
268 | 276 | ); |
269 | 277 | |
270 | - foreach ($boardList[$_REQUEST['cat']] as $child_board) |
|
271 | - $context['category']['children'][] = str_repeat('-', $boards[$child_board]['level']) . ' ' . $boards[$child_board]['name']; |
|
278 | + foreach ($boardList[$_REQUEST['cat']] as $child_board) { |
|
279 | + $context['category']['children'][] = str_repeat('-', $boards[$child_board]['level']) . ' ' . $boards[$child_board]['name']; |
|
280 | + } |
|
272 | 281 | } |
273 | 282 | |
274 | 283 | $prevCat = 0; |
275 | 284 | foreach ($cat_tree as $catid => $tree) |
276 | 285 | { |
277 | - if ($catid == $_REQUEST['cat'] && $prevCat > 0) |
|
278 | - $context['category_order'][$prevCat]['selected'] = true; |
|
279 | - elseif ($catid != $_REQUEST['cat']) |
|
280 | - $context['category_order'][$catid] = array( |
|
286 | + if ($catid == $_REQUEST['cat'] && $prevCat > 0) { |
|
287 | + $context['category_order'][$prevCat]['selected'] = true; |
|
288 | + } elseif ($catid != $_REQUEST['cat']) { |
|
289 | + $context['category_order'][$catid] = array( |
|
281 | 290 | 'id' => $catid, |
282 | 291 | 'name' => $txt['mboards_order_after'] . $tree['node']['name'], |
283 | 292 | 'selected' => false, |
284 | 293 | 'true_name' => $tree['node']['name'] |
285 | 294 | ); |
295 | + } |
|
286 | 296 | $prevCat = $catid; |
287 | 297 | } |
288 | 298 | if (!isset($_REQUEST['delete'])) |
289 | 299 | { |
290 | 300 | $context['sub_template'] = 'modify_category'; |
291 | 301 | $context['page_title'] = $_REQUEST['sa'] == 'newcat' ? $txt['mboards_new_cat_name'] : $txt['catEdit']; |
292 | - } |
|
293 | - else |
|
302 | + } else |
|
294 | 303 | { |
295 | 304 | $context['sub_template'] = 'confirm_category_delete'; |
296 | 305 | $context['page_title'] = $txt['mboards_delete_cat']; |
@@ -327,8 +336,9 @@ discard block |
||
327 | 336 | { |
328 | 337 | $catOptions = array(); |
329 | 338 | |
330 | - if (isset($_POST['cat_order'])) |
|
331 | - $catOptions['move_after'] = (int) $_POST['cat_order']; |
|
339 | + if (isset($_POST['cat_order'])) { |
|
340 | + $catOptions['move_after'] = (int) $_POST['cat_order']; |
|
341 | + } |
|
332 | 342 | |
333 | 343 | // Change "This & That" to "This & That" but don't change "¢" to "&cent;"... |
334 | 344 | $catOptions['cat_name'] = parse_bbc($smcFunc['htmlspecialchars']($_POST['cat_name']), false, '', $context['description_allowed_tags']); |
@@ -336,10 +346,11 @@ discard block |
||
336 | 346 | |
337 | 347 | $catOptions['is_collapsible'] = isset($_POST['collapse']); |
338 | 348 | |
339 | - if (isset($_POST['add'])) |
|
340 | - createCategory($catOptions); |
|
341 | - else |
|
342 | - modifyCategory($_POST['cat'], $catOptions); |
|
349 | + if (isset($_POST['add'])) { |
|
350 | + createCategory($catOptions); |
|
351 | + } else { |
|
352 | + modifyCategory($_POST['cat'], $catOptions); |
|
353 | + } |
|
343 | 354 | } |
344 | 355 | // If they want to delete - first give them confirmation. |
345 | 356 | elseif (isset($_POST['delete']) && !isset($_POST['confirmation']) && !isset($_POST['empty'])) |
@@ -353,13 +364,14 @@ discard block |
||
353 | 364 | // First off - check if we are moving all the current boards first - before we start deleting! |
354 | 365 | if (isset($_POST['delete_action']) && $_POST['delete_action'] == 1) |
355 | 366 | { |
356 | - if (empty($_POST['cat_to'])) |
|
357 | - fatal_lang_error('mboards_delete_error'); |
|
367 | + if (empty($_POST['cat_to'])) { |
|
368 | + fatal_lang_error('mboards_delete_error'); |
|
369 | + } |
|
358 | 370 | |
359 | 371 | deleteCategories(array($_POST['cat']), (int) $_POST['cat_to']); |
372 | + } else { |
|
373 | + deleteCategories(array($_POST['cat'])); |
|
360 | 374 | } |
361 | - else |
|
362 | - deleteCategories(array($_POST['cat'])); |
|
363 | 375 | } |
364 | 376 | |
365 | 377 | redirectexit('action=admin;area=manageboards'); |
@@ -404,8 +416,9 @@ discard block |
||
404 | 416 | if ($_REQUEST['sa'] == 'newboard') |
405 | 417 | { |
406 | 418 | // Category doesn't exist, man... sorry. |
407 | - if (empty($_REQUEST['cat'])) |
|
408 | - redirectexit('action=admin;area=manageboards'); |
|
419 | + if (empty($_REQUEST['cat'])) { |
|
420 | + redirectexit('action=admin;area=manageboards'); |
|
421 | + } |
|
409 | 422 | |
410 | 423 | // Some things that need to be setup for a new board. |
411 | 424 | $curBoard = array( |
@@ -429,8 +442,7 @@ discard block |
||
429 | 442 | 'category' => (int) $_REQUEST['cat'], |
430 | 443 | 'no_children' => true, |
431 | 444 | ); |
432 | - } |
|
433 | - else |
|
445 | + } else |
|
434 | 446 | { |
435 | 447 | // Just some easy shortcuts. |
436 | 448 | $curBoard = &$boards[$_REQUEST['boardid']]; |
@@ -478,8 +490,9 @@ discard block |
||
478 | 490 | ); |
479 | 491 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
480 | 492 | { |
481 | - if ($_REQUEST['sa'] == 'newboard' && $row['min_posts'] == -1) |
|
482 | - $curBoard['member_groups'][] = $row['id_group']; |
|
493 | + if ($_REQUEST['sa'] == 'newboard' && $row['min_posts'] == -1) { |
|
494 | + $curBoard['member_groups'][] = $row['id_group']; |
|
495 | + } |
|
483 | 496 | |
484 | 497 | $context['groups'][(int) $row['id_group']] = array( |
485 | 498 | 'id' => $row['id_group'], |
@@ -492,8 +505,9 @@ discard block |
||
492 | 505 | $smcFunc['db_free_result']($request); |
493 | 506 | |
494 | 507 | // Category doesn't exist, man... sorry. |
495 | - if (!isset($boardList[$curBoard['category']])) |
|
496 | - redirectexit('action=admin;area=manageboards'); |
|
508 | + if (!isset($boardList[$curBoard['category']])) { |
|
509 | + redirectexit('action=admin;area=manageboards'); |
|
510 | + } |
|
497 | 511 | |
498 | 512 | foreach ($boardList[$curBoard['category']] as $boardid) |
499 | 513 | { |
@@ -507,8 +521,7 @@ discard block |
||
507 | 521 | 'is_child' => false, |
508 | 522 | 'selected' => true |
509 | 523 | ); |
510 | - } |
|
511 | - else |
|
524 | + } else |
|
512 | 525 | { |
513 | 526 | $context['board_order'][] = array( |
514 | 527 | 'id' => $boardid, |
@@ -525,19 +538,21 @@ discard block |
||
525 | 538 | $context['can_move_children'] = false; |
526 | 539 | $context['children'] = $boards[$_REQUEST['boardid']]['tree']['children']; |
527 | 540 | |
528 | - foreach ($context['board_order'] as $lBoard) |
|
529 | - if ($lBoard['is_child'] == false && $lBoard['selected'] == false) |
|
541 | + foreach ($context['board_order'] as $lBoard) { |
|
542 | + if ($lBoard['is_child'] == false && $lBoard['selected'] == false) |
|
530 | 543 | $context['can_move_children'] = true; |
544 | + } |
|
531 | 545 | } |
532 | 546 | |
533 | 547 | // Get other available categories. |
534 | 548 | $context['categories'] = array(); |
535 | - foreach ($cat_tree as $catID => $tree) |
|
536 | - $context['categories'][] = array( |
|
549 | + foreach ($cat_tree as $catID => $tree) { |
|
550 | + $context['categories'][] = array( |
|
537 | 551 | 'id' => $catID == $curBoard['category'] ? 0 : $catID, |
538 | 552 | 'name' => $tree['node']['name'], |
539 | 553 | 'selected' => $catID == $curBoard['category'] |
540 | 554 | ); |
555 | + } |
|
541 | 556 | |
542 | 557 | $request = $smcFunc['db_query']('', ' |
543 | 558 | SELECT mem.id_member, mem.real_name |
@@ -549,14 +564,16 @@ discard block |
||
549 | 564 | ) |
550 | 565 | ); |
551 | 566 | $context['board']['moderators'] = array(); |
552 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
553 | - $context['board']['moderators'][$row['id_member']] = $row['real_name']; |
|
567 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
568 | + $context['board']['moderators'][$row['id_member']] = $row['real_name']; |
|
569 | + } |
|
554 | 570 | $smcFunc['db_free_result']($request); |
555 | 571 | |
556 | 572 | $context['board']['moderator_list'] = empty($context['board']['moderators']) ? '' : '"' . implode('", "', $context['board']['moderators']) . '"'; |
557 | 573 | |
558 | - if (!empty($context['board']['moderators'])) |
|
559 | - list ($context['board']['last_moderator_id']) = array_slice(array_keys($context['board']['moderators']), -1); |
|
574 | + if (!empty($context['board']['moderators'])) { |
|
575 | + list ($context['board']['last_moderator_id']) = array_slice(array_keys($context['board']['moderators']), -1); |
|
576 | + } |
|
560 | 577 | |
561 | 578 | // Get all the groups assigned as moderators |
562 | 579 | $request = $smcFunc['db_query']('', ' |
@@ -568,14 +585,16 @@ discard block |
||
568 | 585 | ) |
569 | 586 | ); |
570 | 587 | $context['board']['moderator_groups'] = array(); |
571 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
572 | - $context['board']['moderator_groups'][$row['id_group']] = $context['groups'][$row['id_group']]['name']; |
|
588 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
589 | + $context['board']['moderator_groups'][$row['id_group']] = $context['groups'][$row['id_group']]['name']; |
|
590 | + } |
|
573 | 591 | $smcFunc['db_free_result']($request); |
574 | 592 | |
575 | 593 | $context['board']['moderator_groups_list'] = empty($context['board']['moderator_groups']) ? '' : '"' . implode('", &qout;', $context['board']['moderator_groups']) . '"'; |
576 | 594 | |
577 | - if (!empty($context['board']['moderator_groups'])) |
|
578 | - list ($context['board']['last_moderator_group_id']) = array_slice(array_keys($context['board']['moderator_groups']), -1); |
|
595 | + if (!empty($context['board']['moderator_groups'])) { |
|
596 | + list ($context['board']['last_moderator_group_id']) = array_slice(array_keys($context['board']['moderator_groups']), -1); |
|
597 | + } |
|
579 | 598 | |
580 | 599 | // Get all the themes... |
581 | 600 | $request = $smcFunc['db_query']('', ' |
@@ -587,8 +606,9 @@ discard block |
||
587 | 606 | ) |
588 | 607 | ); |
589 | 608 | $context['themes'] = array(); |
590 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
591 | - $context['themes'][] = $row; |
|
609 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
610 | + $context['themes'][] = $row; |
|
611 | + } |
|
592 | 612 | $smcFunc['db_free_result']($request); |
593 | 613 | |
594 | 614 | if (!isset($_REQUEST['delete'])) |
@@ -596,8 +616,7 @@ discard block |
||
596 | 616 | $context['sub_template'] = 'modify_board'; |
597 | 617 | $context['page_title'] = $txt['boardsEdit']; |
598 | 618 | loadJavaScriptFile('suggest.js', array('defer' => false), 'smf_suggest'); |
599 | - } |
|
600 | - else |
|
619 | + } else |
|
601 | 620 | { |
602 | 621 | $context['sub_template'] = 'confirm_board_delete'; |
603 | 622 | $context['page_title'] = $txt['mboards_delete_board']; |
@@ -641,8 +660,9 @@ discard block |
||
641 | 660 | // Change the boardorder of this board? |
642 | 661 | elseif (!empty($_POST['placement']) && !empty($_POST['board_order'])) |
643 | 662 | { |
644 | - if (!in_array($_POST['placement'], array('before', 'after', 'child'))) |
|
645 | - fatal_lang_error('mangled_post', false); |
|
663 | + if (!in_array($_POST['placement'], array('before', 'after', 'child'))) { |
|
664 | + fatal_lang_error('mangled_post', false); |
|
665 | + } |
|
646 | 666 | |
647 | 667 | $boardOptions['move_to'] = $_POST['placement']; |
648 | 668 | $boardOptions['target_board'] = (int) $_POST['board_order']; |
@@ -655,13 +675,14 @@ discard block |
||
655 | 675 | $boardOptions['access_groups'] = array(); |
656 | 676 | $boardOptions['deny_groups'] = array(); |
657 | 677 | |
658 | - if (!empty($_POST['groups'])) |
|
659 | - foreach ($_POST['groups'] as $group => $action) |
|
678 | + if (!empty($_POST['groups'])) { |
|
679 | + foreach ($_POST['groups'] as $group => $action) |
|
660 | 680 | { |
661 | 681 | if ($action == 'allow') |
662 | 682 | $boardOptions['access_groups'][] = (int) $group; |
663 | - elseif ($action == 'deny') |
|
664 | - $boardOptions['deny_groups'][] = (int) $group; |
|
683 | + } elseif ($action == 'deny') { |
|
684 | + $boardOptions['deny_groups'][] = (int) $group; |
|
685 | + } |
|
665 | 686 | } |
666 | 687 | |
667 | 688 | // People with manage-boards are special. |
@@ -673,8 +694,9 @@ discard block |
||
673 | 694 | // Secondly, make sure those with super cow powers (like apt-get, or in this case manage boards) are upgraded. |
674 | 695 | $boardOptions['access_groups'] = array_unique(array_merge($boardOptions['access_groups'], $board_managers)); |
675 | 696 | |
676 | - if (strlen(implode(',', $boardOptions['access_groups'])) > 255 || strlen(implode(',', $boardOptions['deny_groups'])) > 255) |
|
677 | - fatal_lang_error('too_many_groups', false); |
|
697 | + if (strlen(implode(',', $boardOptions['access_groups'])) > 255 || strlen(implode(',', $boardOptions['deny_groups'])) > 255) { |
|
698 | + fatal_lang_error('too_many_groups', false); |
|
699 | + } |
|
678 | 700 | |
679 | 701 | // Do not allow HTML tags. Parse the string. |
680 | 702 | $boardOptions['board_name'] = parse_bbc($smcFunc['htmlspecialchars']($_POST['board_name']), false, '', $context['description_allowed_tags']); |
@@ -685,8 +707,9 @@ discard block |
||
685 | 707 | if (isset($_POST['moderator_list']) && is_array($_POST['moderator_list'])) |
686 | 708 | { |
687 | 709 | $moderators = array(); |
688 | - foreach ($_POST['moderator_list'] as $moderator) |
|
689 | - $moderators[(int) $moderator] = (int) $moderator; |
|
710 | + foreach ($_POST['moderator_list'] as $moderator) { |
|
711 | + $moderators[(int) $moderator] = (int) $moderator; |
|
712 | + } |
|
690 | 713 | $boardOptions['moderators'] = $moderators; |
691 | 714 | } |
692 | 715 | |
@@ -695,8 +718,9 @@ discard block |
||
695 | 718 | if (isset($_POST['moderator_group_list']) && is_array($_POST['moderator_group_list'])) |
696 | 719 | { |
697 | 720 | $moderator_groups = array(); |
698 | - foreach ($_POST['moderator_group_list'] as $moderator_group) |
|
699 | - $moderator_groups[(int) $moderator_group] = (int) $moderator_group; |
|
721 | + foreach ($_POST['moderator_group_list'] as $moderator_group) { |
|
722 | + $moderator_groups[(int) $moderator_group] = (int) $moderator_group; |
|
723 | + } |
|
700 | 724 | $boardOptions['moderator_groups'] = $moderator_groups; |
701 | 725 | } |
702 | 726 | |
@@ -722,56 +746,62 @@ discard block |
||
722 | 746 | $smcFunc['db_free_result']($request); |
723 | 747 | |
724 | 748 | // If we're turning redirection on check the board doesn't have posts in it - if it does don't make it a redirection board. |
725 | - if ($boardOptions['redirect'] && empty($oldRedirect) && $numPosts) |
|
726 | - unset($boardOptions['redirect']); |
|
749 | + if ($boardOptions['redirect'] && empty($oldRedirect) && $numPosts) { |
|
750 | + unset($boardOptions['redirect']); |
|
751 | + } |
|
727 | 752 | // Reset the redirection count when switching on/off. |
728 | - elseif (empty($boardOptions['redirect']) != empty($oldRedirect)) |
|
729 | - $boardOptions['num_posts'] = 0; |
|
753 | + elseif (empty($boardOptions['redirect']) != empty($oldRedirect)) { |
|
754 | + $boardOptions['num_posts'] = 0; |
|
755 | + } |
|
730 | 756 | // Resetting the count? |
731 | - elseif ($boardOptions['redirect'] && !empty($_POST['reset_redirect'])) |
|
732 | - $boardOptions['num_posts'] = 0; |
|
757 | + elseif ($boardOptions['redirect'] && !empty($_POST['reset_redirect'])) { |
|
758 | + $boardOptions['num_posts'] = 0; |
|
759 | + } |
|
733 | 760 | } |
734 | 761 | |
735 | 762 | // Create a new board... |
736 | 763 | if (isset($_POST['add'])) |
737 | 764 | { |
738 | 765 | // New boards by default go to the bottom of the category. |
739 | - if (empty($_POST['new_cat'])) |
|
740 | - $boardOptions['target_category'] = (int) $_POST['cur_cat']; |
|
741 | - if (!isset($boardOptions['move_to'])) |
|
742 | - $boardOptions['move_to'] = 'bottom'; |
|
766 | + if (empty($_POST['new_cat'])) { |
|
767 | + $boardOptions['target_category'] = (int) $_POST['cur_cat']; |
|
768 | + } |
|
769 | + if (!isset($boardOptions['move_to'])) { |
|
770 | + $boardOptions['move_to'] = 'bottom'; |
|
771 | + } |
|
743 | 772 | |
744 | 773 | createBoard($boardOptions); |
745 | 774 | } |
746 | 775 | |
747 | 776 | // ...or update an existing board. |
748 | - else |
|
749 | - modifyBoard($_POST['boardid'], $boardOptions); |
|
750 | - } |
|
751 | - elseif (isset($_POST['delete']) && !isset($_POST['confirmation']) && !isset($_POST['no_children'])) |
|
777 | + else { |
|
778 | + modifyBoard($_POST['boardid'], $boardOptions); |
|
779 | + } |
|
780 | + } elseif (isset($_POST['delete']) && !isset($_POST['confirmation']) && !isset($_POST['no_children'])) |
|
752 | 781 | { |
753 | 782 | EditBoard(); |
754 | 783 | return; |
755 | - } |
|
756 | - elseif (isset($_POST['delete'])) |
|
784 | + } elseif (isset($_POST['delete'])) |
|
757 | 785 | { |
758 | 786 | // First off - check if we are moving all the current child boards first - before we start deleting! |
759 | 787 | if (isset($_POST['delete_action']) && $_POST['delete_action'] == 1) |
760 | 788 | { |
761 | - if (empty($_POST['board_to'])) |
|
762 | - fatal_lang_error('mboards_delete_board_error'); |
|
789 | + if (empty($_POST['board_to'])) { |
|
790 | + fatal_lang_error('mboards_delete_board_error'); |
|
791 | + } |
|
763 | 792 | |
764 | 793 | deleteBoards(array($_POST['boardid']), (int) $_POST['board_to']); |
794 | + } else { |
|
795 | + deleteBoards(array($_POST['boardid']), 0); |
|
765 | 796 | } |
766 | - else |
|
767 | - deleteBoards(array($_POST['boardid']), 0); |
|
768 | 797 | } |
769 | 798 | |
770 | - if (isset($_REQUEST['rid']) && $_REQUEST['rid'] == 'permissions') |
|
771 | - redirectexit('action=admin;area=permissions;sa=board;' . $context['session_var'] . '=' . $context['session_id']); |
|
772 | - else |
|
773 | - redirectexit('action=admin;area=manageboards'); |
|
774 | -} |
|
799 | + if (isset($_REQUEST['rid']) && $_REQUEST['rid'] == 'permissions') { |
|
800 | + redirectexit('action=admin;area=permissions;sa=board;' . $context['session_var'] . '=' . $context['session_id']); |
|
801 | + } else { |
|
802 | + redirectexit('action=admin;area=manageboards'); |
|
803 | + } |
|
804 | + } |
|
775 | 805 | |
776 | 806 | /** |
777 | 807 | * Used to retrieve data for modifying a board category |
@@ -808,8 +838,9 @@ discard block |
||
808 | 838 | $smcFunc['db_free_result']($request); |
809 | 839 | |
810 | 840 | // This would probably never happen, but just to be sure. |
811 | - if ($cat .= $allowed_sa[1]) |
|
812 | - die(str_replace(',', ' to', $cat)); |
|
841 | + if ($cat .= $allowed_sa[1]) { |
|
842 | + die(str_replace(',', ' to', $cat)); |
|
843 | + } |
|
813 | 844 | |
814 | 845 | redirectexit(); |
815 | 846 | } |
@@ -835,8 +866,9 @@ discard block |
||
835 | 866 | 'empty_string' => '', |
836 | 867 | ) |
837 | 868 | ); |
838 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
839 | - $recycle_boards[$row['id_board']] = $row['cat_name'] . ' - ' . $row['board_name']; |
|
869 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
870 | + $recycle_boards[$row['id_board']] = $row['cat_name'] . ' - ' . $row['board_name']; |
|
871 | + } |
|
840 | 872 | $smcFunc['db_free_result']($request); |
841 | 873 | |
842 | 874 | if (!empty($recycle_boards)) |
@@ -844,9 +876,9 @@ discard block |
||
844 | 876 | require_once($sourcedir . '/Subs-Boards.php'); |
845 | 877 | sortBoards($recycle_boards); |
846 | 878 | $recycle_boards = array('') + $recycle_boards; |
879 | + } else { |
|
880 | + $recycle_boards = array(''); |
|
847 | 881 | } |
848 | - else |
|
849 | - $recycle_boards = array(''); |
|
850 | 882 | |
851 | 883 | // Here and the board settings... |
852 | 884 | $config_vars = array( |
@@ -864,8 +896,9 @@ discard block |
||
864 | 896 | |
865 | 897 | call_integration_hook('integrate_modify_board_settings', array(&$config_vars)); |
866 | 898 | |
867 | - if ($return_config) |
|
868 | - return $config_vars; |
|
899 | + if ($return_config) { |
|
900 | + return $config_vars; |
|
901 | + } |
|
869 | 902 | |
870 | 903 | // Needed for the settings template. |
871 | 904 | require_once($sourcedir . '/ManageServer.php'); |
@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | * @version 2.1 Beta 4 |
12 | 12 | */ |
13 | 13 | |
14 | -if (!defined('SMF')) |
|
14 | +if (!defined('SMF')) { |
|
15 | 15 | die('Hacking attempt...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * PostgreSQL Cache API class |
@@ -51,8 +52,9 @@ discard block |
||
51 | 52 | |
52 | 53 | $result = pg_execute($db_connection, '', array('public', $db_prefix . 'cache')); |
53 | 54 | |
54 | - if (pg_affected_rows($result) === 0) |
|
55 | - pg_query($db_connection, 'CREATE UNLOGGED TABLE {db_prefix}cache (key text, value text, ttl bigint, PRIMARY KEY (key))'); |
|
55 | + if (pg_affected_rows($result) === 0) { |
|
56 | + pg_query($db_connection, 'CREATE UNLOGGED TABLE {db_prefix}cache (key text, value text, ttl bigint, PRIMARY KEY (key))'); |
|
57 | + } |
|
56 | 58 | } |
57 | 59 | |
58 | 60 | /** |
@@ -63,14 +65,16 @@ discard block |
||
63 | 65 | global $smcFunc, $db_connection; |
64 | 66 | |
65 | 67 | |
66 | - if ($smcFunc['db_title'] !== 'PostgreSQL') |
|
67 | - return false; |
|
68 | + if ($smcFunc['db_title'] !== 'PostgreSQL') { |
|
69 | + return false; |
|
70 | + } |
|
68 | 71 | |
69 | 72 | $result = pg_query($db_connection, 'SHOW server_version_num'); |
70 | 73 | $res = pg_fetch_assoc($result); |
71 | 74 | |
72 | - if ($res['server_version_num'] < 90500) |
|
73 | - return false; |
|
75 | + if ($res['server_version_num'] < 90500) { |
|
76 | + return false; |
|
77 | + } |
|
74 | 78 | |
75 | 79 | return $test ? true : parent::isSupported(); |
76 | 80 | } |
@@ -84,13 +88,15 @@ discard block |
||
84 | 88 | |
85 | 89 | $ttl = time() - $ttl; |
86 | 90 | |
87 | - if (empty($this->pg_get_data_prep)) |
|
88 | - $this->pg_get_data_prep = pg_prepare($db_connection, 'smf_cache_get_data', 'SELECT value FROM ' . $db_prefix . 'cache WHERE key = $1 AND ttl >= $2 LIMIT 1'); |
|
91 | + if (empty($this->pg_get_data_prep)) { |
|
92 | + $this->pg_get_data_prep = pg_prepare($db_connection, 'smf_cache_get_data', 'SELECT value FROM ' . $db_prefix . 'cache WHERE key = $1 AND ttl >= $2 LIMIT 1'); |
|
93 | + } |
|
89 | 94 | |
90 | 95 | $result = pg_execute($db_connection, 'smf_cache_get_data', array($key, $ttl)); |
91 | 96 | |
92 | - if (pg_affected_rows($result) === 0) |
|
93 | - return null; |
|
97 | + if (pg_affected_rows($result) === 0) { |
|
98 | + return null; |
|
99 | + } |
|
94 | 100 | |
95 | 101 | $res = pg_fetch_assoc($result); |
96 | 102 | |
@@ -104,23 +110,26 @@ discard block |
||
104 | 110 | { |
105 | 111 | global $db_prefix, $db_connection; |
106 | 112 | |
107 | - if (!isset($value)) |
|
108 | - $value = ''; |
|
113 | + if (!isset($value)) { |
|
114 | + $value = ''; |
|
115 | + } |
|
109 | 116 | |
110 | 117 | $ttl = time() + $ttl; |
111 | 118 | |
112 | - if (empty($this->pg_put_data_prep)) |
|
113 | - $this->pg_put_data_prep = pg_prepare($db_connection, 'smf_cache_put_data', |
|
119 | + if (empty($this->pg_put_data_prep)) { |
|
120 | + $this->pg_put_data_prep = pg_prepare($db_connection, 'smf_cache_put_data', |
|
114 | 121 | 'INSERT INTO ' . $db_prefix . 'cache(key,value,ttl) VALUES($1,$2,$3) |
115 | 122 | ON CONFLICT(key) DO UPDATE SET value = excluded.value, ttl = excluded.ttl' |
116 | 123 | ); |
124 | + } |
|
117 | 125 | |
118 | 126 | $result = pg_execute($db_connection, 'smf_cache_put_data', array($key, $value, $ttl)); |
119 | 127 | |
120 | - if (pg_affected_rows($result) > 0) |
|
121 | - return true; |
|
122 | - else |
|
123 | - return false; |
|
128 | + if (pg_affected_rows($result) > 0) { |
|
129 | + return true; |
|
130 | + } else { |
|
131 | + return false; |
|
132 | + } |
|
124 | 133 | } |
125 | 134 | |
126 | 135 | /** |
@@ -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 all birthdays within the given time range. |
@@ -60,8 +61,7 @@ discard block |
||
60 | 61 | 'max_year' => $year_high, |
61 | 62 | ) |
62 | 63 | ); |
63 | - } |
|
64 | - else |
|
64 | + } else |
|
65 | 65 | { |
66 | 66 | $result = $smcFunc['db_query']('birthday_array', ' |
67 | 67 | SELECT id_member, real_name, YEAR(birthdate) AS birth_year, birthdate |
@@ -91,10 +91,11 @@ discard block |
||
91 | 91 | $bday = array(); |
92 | 92 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
93 | 93 | { |
94 | - if ($year_low != $year_high) |
|
95 | - $age_year = substr($row['birthdate'], 5) < substr($high_date, 5) ? $year_high : $year_low; |
|
96 | - else |
|
97 | - $age_year = $year_low; |
|
94 | + if ($year_low != $year_high) { |
|
95 | + $age_year = substr($row['birthdate'], 5) < substr($high_date, 5) ? $year_high : $year_low; |
|
96 | + } else { |
|
97 | + $age_year = $year_low; |
|
98 | + } |
|
98 | 99 | |
99 | 100 | $bday[$age_year . substr($row['birthdate'], 4)][] = array( |
100 | 101 | 'id' => $row['id_member'], |
@@ -108,8 +109,9 @@ discard block |
||
108 | 109 | ksort($bday); |
109 | 110 | |
110 | 111 | // Set is_last, so the themes know when to stop placing separators. |
111 | - foreach ($bday as $mday => $array) |
|
112 | - $bday[$mday][count($array) - 1]['is_last'] = true; |
|
112 | + foreach ($bday as $mday => $array) { |
|
113 | + $bday[$mday][count($array) - 1]['is_last'] = true; |
|
114 | + } |
|
113 | 115 | |
114 | 116 | return $bday; |
115 | 117 | } |
@@ -133,8 +135,9 @@ discard block |
||
133 | 135 | static $timezone_array = array(); |
134 | 136 | require_once($sourcedir . '/Subs.php'); |
135 | 137 | |
136 | - if (empty($timezone_array['default'])) |
|
137 | - $timezone_array['default'] = timezone_open(date_default_timezone_get()); |
|
138 | + if (empty($timezone_array['default'])) { |
|
139 | + $timezone_array['default'] = timezone_open(date_default_timezone_get()); |
|
140 | + } |
|
138 | 141 | |
139 | 142 | $low_object = date_create($low_date); |
140 | 143 | $high_object = date_create($high_date); |
@@ -161,8 +164,9 @@ discard block |
||
161 | 164 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
162 | 165 | { |
163 | 166 | // If the attached topic is not approved then for the moment pretend it doesn't exist |
164 | - if (!empty($row['id_first_msg']) && $modSettings['postmod_active'] && !$row['approved']) |
|
165 | - continue; |
|
167 | + if (!empty($row['id_first_msg']) && $modSettings['postmod_active'] && !$row['approved']) { |
|
168 | + continue; |
|
169 | + } |
|
166 | 170 | |
167 | 171 | // Force a censor of the title - as often these are used by others. |
168 | 172 | censorText($row['title'], $use_permissions ? false : true); |
@@ -170,12 +174,14 @@ discard block |
||
170 | 174 | // Get the various time and date properties for this event |
171 | 175 | list($start, $end, $allday, $span, $tz, $tz_abbrev) = buildEventDatetimes($row); |
172 | 176 | |
173 | - if (empty($timezone_array[$tz])) |
|
174 | - $timezone_array[$tz] = timezone_open($tz); |
|
177 | + if (empty($timezone_array[$tz])) { |
|
178 | + $timezone_array[$tz] = timezone_open($tz); |
|
179 | + } |
|
175 | 180 | |
176 | 181 | // Sanity check |
177 | - if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) |
|
178 | - continue; |
|
182 | + if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) { |
|
183 | + continue; |
|
184 | + } |
|
179 | 185 | |
180 | 186 | // Get set up for the loop |
181 | 187 | $start_object = date_create($row['start_date'] . (!$allday ? ' ' . $row['start_time'] : ''), $timezone_array[$tz]); |
@@ -239,8 +245,8 @@ discard block |
||
239 | 245 | ); |
240 | 246 | |
241 | 247 | // If we're using permissions (calendar pages?) then just ouput normal contextual style information. |
242 | - if ($use_permissions) |
|
243 | - $events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array( |
|
248 | + if ($use_permissions) { |
|
249 | + $events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array( |
|
244 | 250 | 'href' => $row['id_board'] == 0 ? '' : $scripturl . '?topic=' . $row['id_topic'] . '.0', |
245 | 251 | 'link' => $row['id_board'] == 0 ? $row['title'] : '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['title'] . '</a>', |
246 | 252 | 'can_edit' => allowedTo('calendar_edit_any') || ($row['id_member'] == $user_info['id'] && allowedTo('calendar_edit_own')), |
@@ -248,9 +254,10 @@ discard block |
||
248 | 254 | 'can_export' => !empty($modSettings['cal_export']) ? true : false, |
249 | 255 | 'export_href' => $scripturl . '?action=calendar;sa=ical;eventid=' . $row['id_event'] . ';' . $context['session_var'] . '=' . $context['session_id'], |
250 | 256 | )); |
257 | + } |
|
251 | 258 | // Otherwise, this is going to be cached and the VIEWER'S permissions should apply... just put together some info. |
252 | - else |
|
253 | - $events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array( |
|
259 | + else { |
|
260 | + $events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array( |
|
254 | 261 | 'href' => $row['id_topic'] == 0 ? '' : $scripturl . '?topic=' . $row['id_topic'] . '.0', |
255 | 262 | 'link' => $row['id_topic'] == 0 ? $row['title'] : '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['title'] . '</a>', |
256 | 263 | 'can_edit' => false, |
@@ -260,6 +267,7 @@ discard block |
||
260 | 267 | 'poster' => $row['id_member'], |
261 | 268 | 'allowed_groups' => explode(',', $row['member_groups']), |
262 | 269 | )); |
270 | + } |
|
263 | 271 | |
264 | 272 | date_add($cal_date, date_interval_create_from_date_string('1 day')); |
265 | 273 | } |
@@ -269,8 +277,9 @@ discard block |
||
269 | 277 | // If we're doing normal contextual data, go through and make things clear to the templates ;). |
270 | 278 | if ($use_permissions) |
271 | 279 | { |
272 | - foreach ($events as $mday => $array) |
|
273 | - $events[$mday][count($array) - 1]['is_last'] = true; |
|
280 | + foreach ($events as $mday => $array) { |
|
281 | + $events[$mday][count($array) - 1]['is_last'] = true; |
|
282 | + } |
|
274 | 283 | } |
275 | 284 | |
276 | 285 | ksort($events); |
@@ -290,11 +299,12 @@ discard block |
||
290 | 299 | global $smcFunc; |
291 | 300 | |
292 | 301 | // Get the lowest and highest dates for "all years". |
293 | - if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) |
|
294 | - $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_dec} |
|
302 | + if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) { |
|
303 | + $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_dec} |
|
295 | 304 | OR event_date BETWEEN {date:all_year_jan} AND {date:all_year_high}'; |
296 | - else |
|
297 | - $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_high}'; |
|
305 | + } else { |
|
306 | + $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_high}'; |
|
307 | + } |
|
298 | 308 | |
299 | 309 | // Find some holidays... ;). |
300 | 310 | $result = $smcFunc['db_query']('', ' |
@@ -314,10 +324,11 @@ discard block |
||
314 | 324 | $holidays = array(); |
315 | 325 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
316 | 326 | { |
317 | - if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) |
|
318 | - $event_year = substr($row['event_date'], 5) < substr($high_date, 5) ? substr($high_date, 0, 4) : substr($low_date, 0, 4); |
|
319 | - else |
|
320 | - $event_year = substr($low_date, 0, 4); |
|
327 | + if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) { |
|
328 | + $event_year = substr($row['event_date'], 5) < substr($high_date, 5) ? substr($high_date, 0, 4) : substr($low_date, 0, 4); |
|
329 | + } else { |
|
330 | + $event_year = substr($low_date, 0, 4); |
|
331 | + } |
|
321 | 332 | |
322 | 333 | $holidays[$event_year . substr($row['event_date'], 4)][] = $row['title']; |
323 | 334 | } |
@@ -343,10 +354,12 @@ discard block |
||
343 | 354 | isAllowedTo('calendar_post'); |
344 | 355 | |
345 | 356 | // No board? No topic?!? |
346 | - if (empty($board)) |
|
347 | - fatal_lang_error('missing_board_id', false); |
|
348 | - if (empty($topic)) |
|
349 | - fatal_lang_error('missing_topic_id', false); |
|
357 | + if (empty($board)) { |
|
358 | + fatal_lang_error('missing_board_id', false); |
|
359 | + } |
|
360 | + if (empty($topic)) { |
|
361 | + fatal_lang_error('missing_topic_id', false); |
|
362 | + } |
|
350 | 363 | |
351 | 364 | // Administrator, Moderator, or owner. Period. |
352 | 365 | if (!allowedTo('admin_forum') && !allowedTo('moderate_board')) |
@@ -364,12 +377,14 @@ discard block |
||
364 | 377 | if ($row = $smcFunc['db_fetch_assoc']($result)) |
365 | 378 | { |
366 | 379 | // Not the owner of the topic. |
367 | - if ($row['id_member_started'] != $user_info['id']) |
|
368 | - fatal_lang_error('not_your_topic', 'user'); |
|
380 | + if ($row['id_member_started'] != $user_info['id']) { |
|
381 | + fatal_lang_error('not_your_topic', 'user'); |
|
382 | + } |
|
369 | 383 | } |
370 | 384 | // Topic/Board doesn't exist..... |
371 | - else |
|
372 | - fatal_lang_error('calendar_no_topic', 'general'); |
|
385 | + else { |
|
386 | + fatal_lang_error('calendar_no_topic', 'general'); |
|
387 | + } |
|
373 | 388 | $smcFunc['db_free_result']($result); |
374 | 389 | } |
375 | 390 | } |
@@ -457,14 +472,16 @@ discard block |
||
457 | 472 | if (!empty($calendarOptions['start_day'])) |
458 | 473 | { |
459 | 474 | $nShift -= $calendarOptions['start_day']; |
460 | - if ($nShift < 0) |
|
461 | - $nShift = 7 + $nShift; |
|
475 | + if ($nShift < 0) { |
|
476 | + $nShift = 7 + $nShift; |
|
477 | + } |
|
462 | 478 | } |
463 | 479 | |
464 | 480 | // Number of rows required to fit the month. |
465 | 481 | $nRows = floor(($month_info['last_day']['day_of_month'] + $nShift) / 7); |
466 | - if (($month_info['last_day']['day_of_month'] + $nShift) % 7) |
|
467 | - $nRows++; |
|
482 | + if (($month_info['last_day']['day_of_month'] + $nShift) % 7) { |
|
483 | + $nRows++; |
|
484 | + } |
|
468 | 485 | |
469 | 486 | // Fetch the arrays for birthdays, posted events, and holidays. |
470 | 487 | $bday = $calendarOptions['show_birthdays'] ? getBirthdayRange($month_info['first_day']['date'], $month_info['last_day']['date']) : array(); |
@@ -477,8 +494,9 @@ discard block |
||
477 | 494 | { |
478 | 495 | $calendarGrid['week_days'][] = $count; |
479 | 496 | $count++; |
480 | - if ($count == 7) |
|
481 | - $count = 0; |
|
497 | + if ($count == 7) { |
|
498 | + $count = 0; |
|
499 | + } |
|
482 | 500 | } |
483 | 501 | |
484 | 502 | // Iterate through each week. |
@@ -495,8 +513,9 @@ discard block |
||
495 | 513 | { |
496 | 514 | $nDay = ($nRow * 7) + $nCol - $nShift + 1; |
497 | 515 | |
498 | - if ($nDay < 1 || $nDay > $month_info['last_day']['day_of_month']) |
|
499 | - $nDay = 0; |
|
516 | + if ($nDay < 1 || $nDay > $month_info['last_day']['day_of_month']) { |
|
517 | + $nDay = 0; |
|
518 | + } |
|
500 | 519 | |
501 | 520 | $date = sprintf('%04d-%02d-%02d', $year, $month, $nDay); |
502 | 521 | |
@@ -514,8 +533,9 @@ discard block |
||
514 | 533 | } |
515 | 534 | |
516 | 535 | // What is the last day of the month? |
517 | - if ($is_previous === true) |
|
518 | - $calendarGrid['last_of_month'] = $month_info['last_day']['day_of_month']; |
|
536 | + if ($is_previous === true) { |
|
537 | + $calendarGrid['last_of_month'] = $month_info['last_day']['day_of_month']; |
|
538 | + } |
|
519 | 539 | |
520 | 540 | // We'll use the shift in the template. |
521 | 541 | $calendarGrid['shift'] = $nShift; |
@@ -549,8 +569,9 @@ discard block |
||
549 | 569 | { |
550 | 570 | // Here we offset accordingly to get things to the real start of a week. |
551 | 571 | $date_diff = $day_of_week - $calendarOptions['start_day']; |
552 | - if ($date_diff < 0) |
|
553 | - $date_diff += 7; |
|
572 | + if ($date_diff < 0) { |
|
573 | + $date_diff += 7; |
|
574 | + } |
|
554 | 575 | $new_timestamp = mktime(0, 0, 0, $month, $day, $year) - $date_diff * 86400; |
555 | 576 | $day = (int) strftime('%d', $new_timestamp); |
556 | 577 | $month = (int) strftime('%m', $new_timestamp); |
@@ -680,18 +701,20 @@ discard block |
||
680 | 701 | { |
681 | 702 | foreach ($date_events as $event_key => $event_val) |
682 | 703 | { |
683 | - if (in_array($event_val['id'], $temp)) |
|
684 | - unset($calendarGrid['events'][$date][$event_key]); |
|
685 | - else |
|
686 | - $temp[] = $event_val['id']; |
|
704 | + if (in_array($event_val['id'], $temp)) { |
|
705 | + unset($calendarGrid['events'][$date][$event_key]); |
|
706 | + } else { |
|
707 | + $temp[] = $event_val['id']; |
|
708 | + } |
|
687 | 709 | } |
688 | 710 | } |
689 | 711 | |
690 | 712 | // Give birthdays and holidays a friendly format, without the year |
691 | - if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
692 | - $date_format = '%b %d'; |
|
693 | - else |
|
694 | - $date_format = str_replace(array('%Y', '%y', '%G', '%g', '%C', '%c', '%D'), array('', '', '', '', '', '%b %d', '%m/%d'), $matches[0]); |
|
713 | + if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
714 | + $date_format = '%b %d'; |
|
715 | + } else { |
|
716 | + $date_format = str_replace(array('%Y', '%y', '%G', '%g', '%C', '%c', '%D'), array('', '', '', '', '', '%b %d', '%m/%d'), $matches[0]); |
|
717 | + } |
|
695 | 718 | |
696 | 719 | foreach (array('birthdays', 'holidays') as $type) |
697 | 720 | { |
@@ -786,8 +809,9 @@ discard block |
||
786 | 809 | // Holidays between now and now + days. |
787 | 810 | for ($i = $now; $i < $now + $days_for_index; $i += 86400) |
788 | 811 | { |
789 | - if (isset($cached_data['holidays'][strftime('%Y-%m-%d', $i)])) |
|
790 | - $return_data['calendar_holidays'] = array_merge($return_data['calendar_holidays'], $cached_data['holidays'][strftime('%Y-%m-%d', $i)]); |
|
812 | + if (isset($cached_data['holidays'][strftime('%Y-%m-%d', $i)])) { |
|
813 | + $return_data['calendar_holidays'] = array_merge($return_data['calendar_holidays'], $cached_data['holidays'][strftime('%Y-%m-%d', $i)]); |
|
814 | + } |
|
791 | 815 | } |
792 | 816 | |
793 | 817 | // Happy Birthday, guys and gals! |
@@ -796,8 +820,9 @@ discard block |
||
796 | 820 | $loop_date = strftime('%Y-%m-%d', $i); |
797 | 821 | if (isset($cached_data['birthdays'][$loop_date])) |
798 | 822 | { |
799 | - foreach ($cached_data['birthdays'][$loop_date] as $index => $dummy) |
|
800 | - $cached_data['birthdays'][strftime('%Y-%m-%d', $i)][$index]['is_today'] = $loop_date === $today['date']; |
|
823 | + foreach ($cached_data['birthdays'][$loop_date] as $index => $dummy) { |
|
824 | + $cached_data['birthdays'][strftime('%Y-%m-%d', $i)][$index]['is_today'] = $loop_date === $today['date']; |
|
825 | + } |
|
801 | 826 | $return_data['calendar_birthdays'] = array_merge($return_data['calendar_birthdays'], $cached_data['birthdays'][$loop_date]); |
802 | 827 | } |
803 | 828 | } |
@@ -809,8 +834,9 @@ discard block |
||
809 | 834 | $loop_date = strftime('%Y-%m-%d', $i); |
810 | 835 | |
811 | 836 | // No events today? Check the next day. |
812 | - if (empty($cached_data['events'][$loop_date])) |
|
813 | - continue; |
|
837 | + if (empty($cached_data['events'][$loop_date])) { |
|
838 | + continue; |
|
839 | + } |
|
814 | 840 | |
815 | 841 | // Loop through all events to add a few last-minute values. |
816 | 842 | foreach ($cached_data['events'][$loop_date] as $ev => $event) |
@@ -823,9 +849,9 @@ discard block |
||
823 | 849 | { |
824 | 850 | unset($cached_data['events'][$loop_date][$ev]); |
825 | 851 | continue; |
852 | + } else { |
|
853 | + $duplicates[$this_event['topic'] . $this_event['title']] = true; |
|
826 | 854 | } |
827 | - else |
|
828 | - $duplicates[$this_event['topic'] . $this_event['title']] = true; |
|
829 | 855 | |
830 | 856 | // Might be set to true afterwards, depending on the permissions. |
831 | 857 | $this_event['can_edit'] = false; |
@@ -833,15 +859,18 @@ discard block |
||
833 | 859 | $this_event['date'] = $loop_date; |
834 | 860 | } |
835 | 861 | |
836 | - if (!empty($cached_data['events'][$loop_date])) |
|
837 | - $return_data['calendar_events'] = array_merge($return_data['calendar_events'], $cached_data['events'][$loop_date]); |
|
862 | + if (!empty($cached_data['events'][$loop_date])) { |
|
863 | + $return_data['calendar_events'] = array_merge($return_data['calendar_events'], $cached_data['events'][$loop_date]); |
|
864 | + } |
|
838 | 865 | } |
839 | 866 | |
840 | 867 | // Mark the last item so that a list separator can be used in the template. |
841 | - for ($i = 0, $n = count($return_data['calendar_birthdays']); $i < $n; $i++) |
|
842 | - $return_data['calendar_birthdays'][$i]['is_last'] = !isset($return_data['calendar_birthdays'][$i + 1]); |
|
843 | - for ($i = 0, $n = count($return_data['calendar_events']); $i < $n; $i++) |
|
844 | - $return_data['calendar_events'][$i]['is_last'] = !isset($return_data['calendar_events'][$i + 1]); |
|
868 | + for ($i = 0, $n = count($return_data['calendar_birthdays']); $i < $n; $i++) { |
|
869 | + $return_data['calendar_birthdays'][$i]['is_last'] = !isset($return_data['calendar_birthdays'][$i + 1]); |
|
870 | + } |
|
871 | + for ($i = 0, $n = count($return_data['calendar_events']); $i < $n; $i++) { |
|
872 | + $return_data['calendar_events'][$i]['is_last'] = !isset($return_data['calendar_events'][$i + 1]); |
|
873 | + } |
|
845 | 874 | |
846 | 875 | return array( |
847 | 876 | 'data' => $return_data, |
@@ -889,37 +918,46 @@ discard block |
||
889 | 918 | if (isset($_POST['start_date'])) |
890 | 919 | { |
891 | 920 | $d = date_parse($_POST['start_date']); |
892 | - if (!empty($d['error_count']) || !empty($d['warning_count'])) |
|
893 | - fatal_lang_error('invalid_date', false); |
|
894 | - if (empty($d['year'])) |
|
895 | - fatal_lang_error('event_year_missing', false); |
|
896 | - if (empty($d['month'])) |
|
897 | - fatal_lang_error('event_month_missing', false); |
|
898 | - } |
|
899 | - elseif (isset($_POST['start_datetime'])) |
|
921 | + if (!empty($d['error_count']) || !empty($d['warning_count'])) { |
|
922 | + fatal_lang_error('invalid_date', false); |
|
923 | + } |
|
924 | + if (empty($d['year'])) { |
|
925 | + fatal_lang_error('event_year_missing', false); |
|
926 | + } |
|
927 | + if (empty($d['month'])) { |
|
928 | + fatal_lang_error('event_month_missing', false); |
|
929 | + } |
|
930 | + } elseif (isset($_POST['start_datetime'])) |
|
900 | 931 | { |
901 | 932 | $d = date_parse($_POST['start_datetime']); |
902 | - if (!empty($d['error_count']) || !empty($d['warning_count'])) |
|
903 | - fatal_lang_error('invalid_date', false); |
|
904 | - if (empty($d['year'])) |
|
905 | - fatal_lang_error('event_year_missing', false); |
|
906 | - if (empty($d['month'])) |
|
907 | - fatal_lang_error('event_month_missing', false); |
|
933 | + if (!empty($d['error_count']) || !empty($d['warning_count'])) { |
|
934 | + fatal_lang_error('invalid_date', false); |
|
935 | + } |
|
936 | + if (empty($d['year'])) { |
|
937 | + fatal_lang_error('event_year_missing', false); |
|
938 | + } |
|
939 | + if (empty($d['month'])) { |
|
940 | + fatal_lang_error('event_month_missing', false); |
|
941 | + } |
|
908 | 942 | } |
909 | 943 | // The 2.0 way |
910 | 944 | else |
911 | 945 | { |
912 | 946 | // No month? No year? |
913 | - if (!isset($_POST['month'])) |
|
914 | - fatal_lang_error('event_month_missing', false); |
|
915 | - if (!isset($_POST['year'])) |
|
916 | - fatal_lang_error('event_year_missing', false); |
|
947 | + if (!isset($_POST['month'])) { |
|
948 | + fatal_lang_error('event_month_missing', false); |
|
949 | + } |
|
950 | + if (!isset($_POST['year'])) { |
|
951 | + fatal_lang_error('event_year_missing', false); |
|
952 | + } |
|
917 | 953 | |
918 | 954 | // Check the month and year... |
919 | - if ($_POST['month'] < 1 || $_POST['month'] > 12) |
|
920 | - fatal_lang_error('invalid_month', false); |
|
921 | - if ($_POST['year'] < $modSettings['cal_minyear'] || $_POST['year'] > $modSettings['cal_maxyear']) |
|
922 | - fatal_lang_error('invalid_year', false); |
|
955 | + if ($_POST['month'] < 1 || $_POST['month'] > 12) { |
|
956 | + fatal_lang_error('invalid_month', false); |
|
957 | + } |
|
958 | + if ($_POST['year'] < $modSettings['cal_minyear'] || $_POST['year'] > $modSettings['cal_maxyear']) { |
|
959 | + fatal_lang_error('invalid_year', false); |
|
960 | + } |
|
923 | 961 | } |
924 | 962 | } |
925 | 963 | |
@@ -929,8 +967,9 @@ discard block |
||
929 | 967 | // If they want to us to calculate an end date, make sure it will fit in an acceptable range. |
930 | 968 | if (isset($_POST['span'])) |
931 | 969 | { |
932 | - if (($_POST['span'] < 1) || (!empty($modSettings['cal_maxspan']) && $_POST['span'] > $modSettings['cal_maxspan'])) |
|
933 | - fatal_lang_error('invalid_days_numb', false); |
|
970 | + if (($_POST['span'] < 1) || (!empty($modSettings['cal_maxspan']) && $_POST['span'] > $modSettings['cal_maxspan'])) { |
|
971 | + fatal_lang_error('invalid_days_numb', false); |
|
972 | + } |
|
934 | 973 | } |
935 | 974 | |
936 | 975 | // There is no need to validate the following values if we are just deleting the event. |
@@ -940,24 +979,29 @@ discard block |
||
940 | 979 | if (empty($_POST['start_date']) && empty($_POST['start_datetime'])) |
941 | 980 | { |
942 | 981 | // No day? |
943 | - if (!isset($_POST['day'])) |
|
944 | - fatal_lang_error('event_day_missing', false); |
|
982 | + if (!isset($_POST['day'])) { |
|
983 | + fatal_lang_error('event_day_missing', false); |
|
984 | + } |
|
945 | 985 | |
946 | 986 | // Bad day? |
947 | - if (!checkdate($_POST['month'], $_POST['day'], $_POST['year'])) |
|
948 | - fatal_lang_error('invalid_date', false); |
|
987 | + if (!checkdate($_POST['month'], $_POST['day'], $_POST['year'])) { |
|
988 | + fatal_lang_error('invalid_date', false); |
|
989 | + } |
|
949 | 990 | } |
950 | 991 | |
951 | - if (!isset($_POST['evtitle']) && !isset($_POST['subject'])) |
|
952 | - fatal_lang_error('event_title_missing', false); |
|
953 | - elseif (!isset($_POST['evtitle'])) |
|
954 | - $_POST['evtitle'] = $_POST['subject']; |
|
992 | + if (!isset($_POST['evtitle']) && !isset($_POST['subject'])) { |
|
993 | + fatal_lang_error('event_title_missing', false); |
|
994 | + } elseif (!isset($_POST['evtitle'])) { |
|
995 | + $_POST['evtitle'] = $_POST['subject']; |
|
996 | + } |
|
955 | 997 | |
956 | 998 | // No title? |
957 | - if ($smcFunc['htmltrim']($_POST['evtitle']) === '') |
|
958 | - fatal_lang_error('no_event_title', false); |
|
959 | - if ($smcFunc['strlen']($_POST['evtitle']) > 100) |
|
960 | - $_POST['evtitle'] = $smcFunc['substr']($_POST['evtitle'], 0, 100); |
|
999 | + if ($smcFunc['htmltrim']($_POST['evtitle']) === '') { |
|
1000 | + fatal_lang_error('no_event_title', false); |
|
1001 | + } |
|
1002 | + if ($smcFunc['strlen']($_POST['evtitle']) > 100) { |
|
1003 | + $_POST['evtitle'] = $smcFunc['substr']($_POST['evtitle'], 0, 100); |
|
1004 | + } |
|
961 | 1005 | $_POST['evtitle'] = str_replace(';', '', $_POST['evtitle']); |
962 | 1006 | } |
963 | 1007 | } |
@@ -984,8 +1028,9 @@ discard block |
||
984 | 1028 | ); |
985 | 1029 | |
986 | 1030 | // No results, return false. |
987 | - if ($smcFunc['db_num_rows'] === 0) |
|
988 | - return false; |
|
1031 | + if ($smcFunc['db_num_rows'] === 0) { |
|
1032 | + return false; |
|
1033 | + } |
|
989 | 1034 | |
990 | 1035 | // Grab the results and return. |
991 | 1036 | list ($poster) = $smcFunc['db_fetch_row']($request); |
@@ -1119,8 +1164,9 @@ discard block |
||
1119 | 1164 | call_integration_hook('integrate_modify_event', array($event_id, &$eventOptions, &$event_columns, &$event_parameters)); |
1120 | 1165 | |
1121 | 1166 | $column_clauses = array(); |
1122 | - foreach ($event_columns as $col => $crit) |
|
1123 | - $column_clauses[] = $col . ' = ' . $crit; |
|
1167 | + foreach ($event_columns as $col => $crit) { |
|
1168 | + $column_clauses[] = $col . ' = ' . $crit; |
|
1169 | + } |
|
1124 | 1170 | |
1125 | 1171 | $smcFunc['db_query']('', ' |
1126 | 1172 | UPDATE {db_prefix}calendar |
@@ -1205,8 +1251,9 @@ discard block |
||
1205 | 1251 | ); |
1206 | 1252 | |
1207 | 1253 | // If nothing returned, we are in poo, poo. |
1208 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
1209 | - return false; |
|
1254 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
1255 | + return false; |
|
1256 | + } |
|
1210 | 1257 | |
1211 | 1258 | $row = $smcFunc['db_fetch_assoc']($request); |
1212 | 1259 | $smcFunc['db_free_result']($request); |
@@ -1214,8 +1261,9 @@ discard block |
||
1214 | 1261 | list($start, $end, $allday, $span, $tz, $tz_abbrev) = buildEventDatetimes($row); |
1215 | 1262 | |
1216 | 1263 | // Sanity check |
1217 | - if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) |
|
1218 | - return false; |
|
1264 | + if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) { |
|
1265 | + return false; |
|
1266 | + } |
|
1219 | 1267 | |
1220 | 1268 | $return_value = array( |
1221 | 1269 | 'boards' => array(), |
@@ -1352,24 +1400,27 @@ discard block |
||
1352 | 1400 | |
1353 | 1401 | // Set $span, in case we need it |
1354 | 1402 | $span = isset($eventOptions['span']) ? $eventOptions['span'] : (isset($_POST['span']) ? $_POST['span'] : 0); |
1355 | - if ($span > 0) |
|
1356 | - $span = !empty($modSettings['cal_maxspan']) ? min($modSettings['cal_maxspan'], $span - 1) : $span - 1; |
|
1403 | + if ($span > 0) { |
|
1404 | + $span = !empty($modSettings['cal_maxspan']) ? min($modSettings['cal_maxspan'], $span - 1) : $span - 1; |
|
1405 | + } |
|
1357 | 1406 | |
1358 | 1407 | // Define the timezone for this event, falling back to the default if not provided |
1359 | - if (!empty($eventOptions['tz']) && in_array($eventOptions['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) |
|
1360 | - $tz = $eventOptions['tz']; |
|
1361 | - elseif (!empty($_POST['tz']) && in_array($_POST['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) |
|
1362 | - $tz = $_POST['tz']; |
|
1363 | - else |
|
1364 | - $tz = getUserTimezone(); |
|
1408 | + if (!empty($eventOptions['tz']) && in_array($eventOptions['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) { |
|
1409 | + $tz = $eventOptions['tz']; |
|
1410 | + } elseif (!empty($_POST['tz']) && in_array($_POST['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) { |
|
1411 | + $tz = $_POST['tz']; |
|
1412 | + } else { |
|
1413 | + $tz = getUserTimezone(); |
|
1414 | + } |
|
1365 | 1415 | |
1366 | 1416 | // Is this supposed to be an all day event, or should it have specific start and end times? |
1367 | - if (isset($eventOptions['allday'])) |
|
1368 | - $allday = $eventOptions['allday']; |
|
1369 | - elseif (empty($_POST['allday'])) |
|
1370 | - $allday = false; |
|
1371 | - else |
|
1372 | - $allday = true; |
|
1417 | + if (isset($eventOptions['allday'])) { |
|
1418 | + $allday = $eventOptions['allday']; |
|
1419 | + } elseif (empty($_POST['allday'])) { |
|
1420 | + $allday = false; |
|
1421 | + } else { |
|
1422 | + $allday = true; |
|
1423 | + } |
|
1373 | 1424 | |
1374 | 1425 | // Input might come as individual parameters... |
1375 | 1426 | $start_year = isset($eventOptions['year']) ? $eventOptions['year'] : (isset($_POST['year']) ? $_POST['year'] : null); |
@@ -1396,10 +1447,12 @@ discard block |
||
1396 | 1447 | $end_time_string = isset($eventOptions['end_time']) ? $eventOptions['end_time'] : (isset($_POST['end_time']) ? $_POST['end_time'] : null); |
1397 | 1448 | |
1398 | 1449 | // If the date and time were given in separate strings, combine them |
1399 | - if (empty($start_string) && isset($start_date_string)) |
|
1400 | - $start_string = $start_date_string . (isset($start_time_string) ? ' ' . $start_time_string : ''); |
|
1401 | - if (empty($end_string) && isset($end_date_string)) |
|
1402 | - $end_string = $end_date_string . (isset($end_time_string) ? ' ' . $end_time_string : ''); |
|
1450 | + if (empty($start_string) && isset($start_date_string)) { |
|
1451 | + $start_string = $start_date_string . (isset($start_time_string) ? ' ' . $start_time_string : ''); |
|
1452 | + } |
|
1453 | + if (empty($end_string) && isset($end_date_string)) { |
|
1454 | + $end_string = $end_date_string . (isset($end_time_string) ? ' ' . $end_time_string : ''); |
|
1455 | + } |
|
1403 | 1456 | |
1404 | 1457 | // If some form of string input was given, override individually defined options with it |
1405 | 1458 | if (isset($start_string)) |
@@ -1490,10 +1543,11 @@ discard block |
||
1490 | 1543 | if ($start_object >= $end_object) |
1491 | 1544 | { |
1492 | 1545 | $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, $start_hour, $start_minute, $start_second) . ' ' . $tz); |
1493 | - if ($span > 0) |
|
1494 | - date_add($end_object, date_interval_create_from_date_string($span . ' days')); |
|
1495 | - else |
|
1496 | - date_add($end_object, date_interval_create_from_date_string('1 hour')); |
|
1546 | + if ($span > 0) { |
|
1547 | + date_add($end_object, date_interval_create_from_date_string($span . ' days')); |
|
1548 | + } else { |
|
1549 | + date_add($end_object, date_interval_create_from_date_string('1 hour')); |
|
1550 | + } |
|
1497 | 1551 | } |
1498 | 1552 | |
1499 | 1553 | // Is $end_object too late? |
@@ -1506,9 +1560,9 @@ discard block |
||
1506 | 1560 | { |
1507 | 1561 | $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, $start_hour, $start_minute, $start_second) . ' ' . $tz); |
1508 | 1562 | date_add($end_object, date_interval_create_from_date_string($modSettings['cal_maxspan'] . ' days')); |
1563 | + } else { |
|
1564 | + $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, '11', '59', '59') . ' ' . $tz); |
|
1509 | 1565 | } |
1510 | - else |
|
1511 | - $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, '11', '59', '59') . ' ' . $tz); |
|
1512 | 1566 | } |
1513 | 1567 | } |
1514 | 1568 | |
@@ -1521,8 +1575,7 @@ discard block |
||
1521 | 1575 | $start_time = null; |
1522 | 1576 | $end_time = null; |
1523 | 1577 | $tz = null; |
1524 | - } |
|
1525 | - else |
|
1578 | + } else |
|
1526 | 1579 | { |
1527 | 1580 | $start_time = date_format($start_object, 'H:i:s'); |
1528 | 1581 | $end_time = date_format($end_object, 'H:i:s'); |
@@ -1548,19 +1601,21 @@ discard block |
||
1548 | 1601 | // First, try to create a better date format, ignoring the "time" elements. |
1549 | 1602 | if (empty($date_format)) |
1550 | 1603 | { |
1551 | - if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
1552 | - $date_format = '%F'; |
|
1553 | - else |
|
1554 | - $date_format = $matches[0]; |
|
1604 | + if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
1605 | + $date_format = '%F'; |
|
1606 | + } else { |
|
1607 | + $date_format = $matches[0]; |
|
1608 | + } |
|
1555 | 1609 | } |
1556 | 1610 | |
1557 | 1611 | // We want a fairly compact version of the time, but as close as possible to the user's settings. |
1558 | 1612 | if (empty($time_format)) |
1559 | 1613 | { |
1560 | - if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
1561 | - $time_format = '%k:%M'; |
|
1562 | - else |
|
1563 | - $time_format = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
1614 | + if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
1615 | + $time_format = '%k:%M'; |
|
1616 | + } else { |
|
1617 | + $time_format = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
1618 | + } |
|
1564 | 1619 | } |
1565 | 1620 | |
1566 | 1621 | // Should this be an all day event? |
@@ -1570,11 +1625,13 @@ discard block |
||
1570 | 1625 | $span = 1 + date_interval_format(date_diff(date_create($row['start_date']), date_create($row['end_date'])), '%d'); |
1571 | 1626 | |
1572 | 1627 | // We need to have a defined timezone in the steps below |
1573 | - if (empty($row['timezone'])) |
|
1574 | - $row['timezone'] = getUserTimezone(); |
|
1628 | + if (empty($row['timezone'])) { |
|
1629 | + $row['timezone'] = getUserTimezone(); |
|
1630 | + } |
|
1575 | 1631 | |
1576 | - if (empty($timezone_array[$row['timezone']])) |
|
1577 | - $timezone_array[$row['timezone']] = timezone_open($row['timezone']); |
|
1632 | + if (empty($timezone_array[$row['timezone']])) { |
|
1633 | + $timezone_array[$row['timezone']] = timezone_open($row['timezone']); |
|
1634 | + } |
|
1578 | 1635 | |
1579 | 1636 | // Get most of the standard date information for the start and end datetimes |
1580 | 1637 | $start = date_parse($row['start_date'] . (!$allday ? ' ' . $row['start_time'] : '')); |
@@ -1622,8 +1679,9 @@ discard block |
||
1622 | 1679 | global $smcFunc, $context, $user_info, $modSettings, $user_settings; |
1623 | 1680 | static $member_cache = array(); |
1624 | 1681 | |
1625 | - if (is_null($id_member) && $user_info['is_guest'] == false) |
|
1626 | - $id_member = $context['user']['id']; |
|
1682 | + if (is_null($id_member) && $user_info['is_guest'] == false) { |
|
1683 | + $id_member = $context['user']['id']; |
|
1684 | + } |
|
1627 | 1685 | |
1628 | 1686 | //check if the cache got the data |
1629 | 1687 | if (isset($id_member) && isset($member_cache[$id_member])) |
@@ -1652,11 +1710,13 @@ discard block |
||
1652 | 1710 | $smcFunc['db_free_result']($request); |
1653 | 1711 | } |
1654 | 1712 | |
1655 | - if (empty($timezone) || !in_array($timezone, timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) |
|
1656 | - $timezone = isset($modSettings['default_timezone']) ? $modSettings['default_timezone'] : date_default_timezone_get(); |
|
1713 | + if (empty($timezone) || !in_array($timezone, timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) { |
|
1714 | + $timezone = isset($modSettings['default_timezone']) ? $modSettings['default_timezone'] : date_default_timezone_get(); |
|
1715 | + } |
|
1657 | 1716 | |
1658 | - if (isset($id_member)) |
|
1659 | - $member_cache[$id_member] = $timezone; |
|
1717 | + if (isset($id_member)) { |
|
1718 | + $member_cache[$id_member] = $timezone; |
|
1719 | + } |
|
1660 | 1720 | |
1661 | 1721 | return $timezone; |
1662 | 1722 | } |
@@ -1685,8 +1745,9 @@ discard block |
||
1685 | 1745 | ) |
1686 | 1746 | ); |
1687 | 1747 | $holidays = array(); |
1688 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1689 | - $holidays[] = $row; |
|
1748 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1749 | + $holidays[] = $row; |
|
1750 | + } |
|
1690 | 1751 | $smcFunc['db_free_result']($request); |
1691 | 1752 | |
1692 | 1753 | return $holidays; |
@@ -1334,7 +1334,7 @@ discard block |
||
1334 | 1334 | 'class' => 'centercol', |
1335 | 1335 | ), |
1336 | 1336 | 'data' => array( |
1337 | - 'function' => function ($rowData) |
|
1337 | + 'function' => function($rowData) |
|
1338 | 1338 | { |
1339 | 1339 | $isChecked = $rowData['disabled'] ? '' : ' checked'; |
1340 | 1340 | $onClickHandler = $rowData['can_show_register'] ? sprintf(' onclick="document.getElementById(\'reg_%1$s\').disabled = !this.checked;"', $rowData['id']) : ''; |
@@ -1350,7 +1350,7 @@ discard block |
||
1350 | 1350 | 'class' => 'centercol', |
1351 | 1351 | ), |
1352 | 1352 | 'data' => array( |
1353 | - 'function' => function ($rowData) |
|
1353 | + 'function' => function($rowData) |
|
1354 | 1354 | { |
1355 | 1355 | $isChecked = $rowData['on_register'] && !$rowData['disabled'] ? ' checked' : ''; |
1356 | 1356 | $isDisabled = $rowData['can_show_register'] ? '' : ' disabled'; |
@@ -1397,15 +1397,15 @@ discard block |
||
1397 | 1397 | 'value' => $txt['custom_profile_fieldorder'], |
1398 | 1398 | ), |
1399 | 1399 | 'data' => array( |
1400 | - 'function' => function ($rowData) use ($context, $txt, $scripturl) |
|
1400 | + 'function' => function($rowData) use ($context, $txt, $scripturl) |
|
1401 | 1401 | { |
1402 | - $return = '<p class="centertext bold_text">'. $rowData['field_order'] .'<br>'; |
|
1402 | + $return = '<p class="centertext bold_text">' . $rowData['field_order'] . '<br>'; |
|
1403 | 1403 | |
1404 | 1404 | if ($rowData['field_order'] > 1) |
1405 | - $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_up'] .'"></span></a>'; |
|
1405 | + $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="' . $txt['custom_edit_order_move'] . ' ' . $txt['custom_edit_order_up'] . '"></span></a>'; |
|
1406 | 1406 | |
1407 | 1407 | if ($rowData['field_order'] < $context['custFieldsMaxOrder']) |
1408 | - $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_down'] .'"></span></a>'; |
|
1408 | + $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="' . $txt['custom_edit_order_move'] . ' ' . $txt['custom_edit_order_down'] . '"></span></a>'; |
|
1409 | 1409 | |
1410 | 1410 | $return .= '</p>'; |
1411 | 1411 | |
@@ -1423,7 +1423,7 @@ discard block |
||
1423 | 1423 | 'value' => $txt['custom_profile_fieldname'], |
1424 | 1424 | ), |
1425 | 1425 | 'data' => array( |
1426 | - 'function' => function ($rowData) use ($scripturl) |
|
1426 | + 'function' => function($rowData) use ($scripturl) |
|
1427 | 1427 | { |
1428 | 1428 | return sprintf('<a href="%1$s?action=admin;area=featuresettings;sa=profileedit;fid=%2$d">%3$s</a><div class="smalltext">%4$s</div>', $scripturl, $rowData['id_field'], $rowData['field_name'], $rowData['field_desc']); |
1429 | 1429 | }, |
@@ -1439,7 +1439,7 @@ discard block |
||
1439 | 1439 | 'value' => $txt['custom_profile_fieldtype'], |
1440 | 1440 | ), |
1441 | 1441 | 'data' => array( |
1442 | - 'function' => function ($rowData) use ($txt) |
|
1442 | + 'function' => function($rowData) use ($txt) |
|
1443 | 1443 | { |
1444 | 1444 | $textKey = sprintf('custom_profile_type_%1$s', $rowData['field_type']); |
1445 | 1445 | return isset($txt[$textKey]) ? $txt[$textKey] : $textKey; |
@@ -1457,7 +1457,7 @@ discard block |
||
1457 | 1457 | 'value' => $txt['custom_profile_active'], |
1458 | 1458 | ), |
1459 | 1459 | 'data' => array( |
1460 | - 'function' => function ($rowData) use ($txt) |
|
1460 | + 'function' => function($rowData) use ($txt) |
|
1461 | 1461 | { |
1462 | 1462 | return $rowData['active'] ? $txt['yes'] : $txt['no']; |
1463 | 1463 | }, |
@@ -1474,7 +1474,7 @@ discard block |
||
1474 | 1474 | 'value' => $txt['custom_profile_placement'], |
1475 | 1475 | ), |
1476 | 1476 | 'data' => array( |
1477 | - 'function' => function ($rowData) |
|
1477 | + 'function' => function($rowData) |
|
1478 | 1478 | { |
1479 | 1479 | global $txt, $context; |
1480 | 1480 | |
@@ -1709,7 +1709,7 @@ discard block |
||
1709 | 1709 | redirectexit('action=admin;area=featuresettings;sa=profile'); // @todo implement an error handler |
1710 | 1710 | |
1711 | 1711 | // All good, proceed. |
1712 | - $smcFunc['db_query']('',' |
|
1712 | + $smcFunc['db_query']('', ' |
|
1713 | 1713 | UPDATE {db_prefix}custom_fields |
1714 | 1714 | SET field_order = {int:old_order} |
1715 | 1715 | WHERE field_order = {int:new_order}', |
@@ -1718,7 +1718,7 @@ discard block |
||
1718 | 1718 | 'old_order' => $context['field']['order'], |
1719 | 1719 | ) |
1720 | 1720 | ); |
1721 | - $smcFunc['db_query']('',' |
|
1721 | + $smcFunc['db_query']('', ' |
|
1722 | 1722 | UPDATE {db_prefix}custom_fields |
1723 | 1723 | SET field_order = {int:new_order} |
1724 | 1724 | WHERE id_field = {int:id_field}', |
@@ -1820,7 +1820,7 @@ discard block |
||
1820 | 1820 | $smcFunc['db_free_result']($request); |
1821 | 1821 | |
1822 | 1822 | $unique = false; |
1823 | - for ($i = 0; !$unique && $i < 9; $i ++) |
|
1823 | + for ($i = 0; !$unique && $i < 9; $i++) |
|
1824 | 1824 | { |
1825 | 1825 | if (!in_array($col_name, $current_fields)) |
1826 | 1826 | $unique = true; |
@@ -1993,7 +1993,7 @@ discard block |
||
1993 | 1993 | ); |
1994 | 1994 | |
1995 | 1995 | // Re-arrange the order. |
1996 | - $smcFunc['db_query']('',' |
|
1996 | + $smcFunc['db_query']('', ' |
|
1997 | 1997 | UPDATE {db_prefix}custom_fields |
1998 | 1998 | SET field_order = field_order - 1 |
1999 | 1999 | WHERE field_order > {int:current_order}', |
@@ -2257,7 +2257,7 @@ discard block |
||
2257 | 2257 | $context['token_check'] = 'noti-admin'; |
2258 | 2258 | |
2259 | 2259 | // Specify our action since we'll want to post back here instead of the profile |
2260 | - $context['action'] = 'action=admin;area=featuresettings;sa=alerts;'. $context['session_var'] .'='. $context['session_id']; |
|
2260 | + $context['action'] = 'action=admin;area=featuresettings;sa=alerts;' . $context['session_var'] . '=' . $context['session_id']; |
|
2261 | 2261 | |
2262 | 2262 | loadTemplate('Profile'); |
2263 | 2263 | loadLanguage('Profile'); |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 4 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * This function makes sure the requested subaction does exists, if it doesn't, it sets a default action or. |
@@ -206,16 +207,18 @@ discard block |
||
206 | 207 | { |
207 | 208 | $all_zones = timezone_identifiers_list(); |
208 | 209 | // Make sure we set the value to the same as the printed value. |
209 | - foreach ($all_zones as $zone) |
|
210 | - $config_vars['default_timezone'][2][$zone] = $zone; |
|
210 | + foreach ($all_zones as $zone) { |
|
211 | + $config_vars['default_timezone'][2][$zone] = $zone; |
|
212 | + } |
|
213 | + } else { |
|
214 | + unset($config_vars['default_timezone']); |
|
211 | 215 | } |
212 | - else |
|
213 | - unset($config_vars['default_timezone']); |
|
214 | 216 | |
215 | 217 | call_integration_hook('integrate_modify_basic_settings', array(&$config_vars)); |
216 | 218 | |
217 | - if ($return_config) |
|
218 | - return $config_vars; |
|
219 | + if ($return_config) { |
|
220 | + return $config_vars; |
|
221 | + } |
|
219 | 222 | |
220 | 223 | // Saving? |
221 | 224 | if (isset($_GET['save'])) |
@@ -223,8 +226,9 @@ discard block |
||
223 | 226 | checkSession(); |
224 | 227 | |
225 | 228 | // Prevent absurd boundaries here - make it a day tops. |
226 | - if (isset($_POST['lastActive'])) |
|
227 | - $_POST['lastActive'] = min((int) $_POST['lastActive'], 1440); |
|
229 | + if (isset($_POST['lastActive'])) { |
|
230 | + $_POST['lastActive'] = min((int) $_POST['lastActive'], 1440); |
|
231 | + } |
|
228 | 232 | |
229 | 233 | call_integration_hook('integrate_save_basic_settings'); |
230 | 234 | |
@@ -269,8 +273,9 @@ discard block |
||
269 | 273 | |
270 | 274 | call_integration_hook('integrate_modify_bbc_settings', array(&$config_vars)); |
271 | 275 | |
272 | - if ($return_config) |
|
273 | - return $config_vars; |
|
276 | + if ($return_config) { |
|
277 | + return $config_vars; |
|
278 | + } |
|
274 | 279 | |
275 | 280 | // Setup the template. |
276 | 281 | require_once($sourcedir . '/ManageServer.php'); |
@@ -287,13 +292,15 @@ discard block |
||
287 | 292 | |
288 | 293 | // Clean up the tags. |
289 | 294 | $bbcTags = array(); |
290 | - foreach (parse_bbc(false) as $tag) |
|
291 | - $bbcTags[] = $tag['tag']; |
|
295 | + foreach (parse_bbc(false) as $tag) { |
|
296 | + $bbcTags[] = $tag['tag']; |
|
297 | + } |
|
292 | 298 | |
293 | - if (!isset($_POST['disabledBBC_enabledTags'])) |
|
294 | - $_POST['disabledBBC_enabledTags'] = array(); |
|
295 | - elseif (!is_array($_POST['disabledBBC_enabledTags'])) |
|
296 | - $_POST['disabledBBC_enabledTags'] = array($_POST['disabledBBC_enabledTags']); |
|
299 | + if (!isset($_POST['disabledBBC_enabledTags'])) { |
|
300 | + $_POST['disabledBBC_enabledTags'] = array(); |
|
301 | + } elseif (!is_array($_POST['disabledBBC_enabledTags'])) { |
|
302 | + $_POST['disabledBBC_enabledTags'] = array($_POST['disabledBBC_enabledTags']); |
|
303 | + } |
|
297 | 304 | // Work out what is actually disabled! |
298 | 305 | $_POST['disabledBBC'] = implode(',', array_diff($bbcTags, $_POST['disabledBBC_enabledTags'])); |
299 | 306 | |
@@ -337,8 +344,9 @@ discard block |
||
337 | 344 | |
338 | 345 | call_integration_hook('integrate_layout_settings', array(&$config_vars)); |
339 | 346 | |
340 | - if ($return_config) |
|
341 | - return $config_vars; |
|
347 | + if ($return_config) { |
|
348 | + return $config_vars; |
|
349 | + } |
|
342 | 350 | |
343 | 351 | // Saving? |
344 | 352 | if (isset($_GET['save'])) |
@@ -379,8 +387,9 @@ discard block |
||
379 | 387 | |
380 | 388 | call_integration_hook('integrate_likes_settings', array(&$config_vars)); |
381 | 389 | |
382 | - if ($return_config) |
|
383 | - return $config_vars; |
|
390 | + if ($return_config) { |
|
391 | + return $config_vars; |
|
392 | + } |
|
384 | 393 | |
385 | 394 | // Saving? |
386 | 395 | if (isset($_GET['save'])) |
@@ -418,8 +427,9 @@ discard block |
||
418 | 427 | |
419 | 428 | call_integration_hook('integrate_mentions_settings', array(&$config_vars)); |
420 | 429 | |
421 | - if ($return_config) |
|
422 | - return $config_vars; |
|
430 | + if ($return_config) { |
|
431 | + return $config_vars; |
|
432 | + } |
|
423 | 433 | |
424 | 434 | // Saving? |
425 | 435 | if (isset($_GET['save'])) |
@@ -463,8 +473,8 @@ discard block |
||
463 | 473 | 'enable' => array('check', 'warning_enable'), |
464 | 474 | ); |
465 | 475 | |
466 | - if (!empty($modSettings['warning_settings']) && $currently_enabled) |
|
467 | - $config_vars += array( |
|
476 | + if (!empty($modSettings['warning_settings']) && $currently_enabled) { |
|
477 | + $config_vars += array( |
|
468 | 478 | '', |
469 | 479 | array('int', 'warning_watch', 'subtext' => $txt['setting_warning_watch_note'] . ' ' . $txt['zero_to_disable']), |
470 | 480 | 'moderate' => array('int', 'warning_moderate', 'subtext' => $txt['setting_warning_moderate_note'] . ' ' . $txt['zero_to_disable']), |
@@ -473,15 +483,18 @@ discard block |
||
473 | 483 | 'rem2' => array('int', 'warning_decrement', 'subtext' => $txt['setting_warning_decrement_note'] . ' ' . $txt['zero_to_disable']), |
474 | 484 | array('permissions', 'view_warning'), |
475 | 485 | ); |
486 | + } |
|
476 | 487 | |
477 | 488 | call_integration_hook('integrate_warning_settings', array(&$config_vars)); |
478 | 489 | |
479 | - if ($return_config) |
|
480 | - return $config_vars; |
|
490 | + if ($return_config) { |
|
491 | + return $config_vars; |
|
492 | + } |
|
481 | 493 | |
482 | 494 | // Cannot use moderation if post moderation is not enabled. |
483 | - if (!$modSettings['postmod_active']) |
|
484 | - unset($config_vars['moderate']); |
|
495 | + if (!$modSettings['postmod_active']) { |
|
496 | + unset($config_vars['moderate']); |
|
497 | + } |
|
485 | 498 | |
486 | 499 | // Will need the utility functions from here. |
487 | 500 | require_once($sourcedir . '/ManageServer.php'); |
@@ -506,16 +519,16 @@ discard block |
||
506 | 519 | 'warning_watch' => 10, |
507 | 520 | 'warning_mute' => 60, |
508 | 521 | ); |
509 | - if ($modSettings['postmod_active']) |
|
510 | - $vars['warning_moderate'] = 35; |
|
522 | + if ($modSettings['postmod_active']) { |
|
523 | + $vars['warning_moderate'] = 35; |
|
524 | + } |
|
511 | 525 | |
512 | 526 | foreach ($vars as $var => $value) |
513 | 527 | { |
514 | 528 | $config_vars[] = array('int', $var); |
515 | 529 | $_POST[$var] = $value; |
516 | 530 | } |
517 | - } |
|
518 | - else |
|
531 | + } else |
|
519 | 532 | { |
520 | 533 | $_POST['warning_watch'] = min($_POST['warning_watch'], 100); |
521 | 534 | $_POST['warning_moderate'] = $modSettings['postmod_active'] ? min($_POST['warning_moderate'], 100) : 0; |
@@ -603,8 +616,9 @@ discard block |
||
603 | 616 | |
604 | 617 | call_integration_hook('integrate_spam_settings', array(&$config_vars)); |
605 | 618 | |
606 | - if ($return_config) |
|
607 | - return $config_vars; |
|
619 | + if ($return_config) { |
|
620 | + return $config_vars; |
|
621 | + } |
|
608 | 622 | |
609 | 623 | // You need to be an admin to edit settings! |
610 | 624 | isAllowedTo('admin_forum'); |
@@ -638,8 +652,9 @@ discard block |
||
638 | 652 | |
639 | 653 | if (empty($context['qa_by_lang'][strtr($language, array('-utf8' => ''))]) && !empty($context['question_answers'])) |
640 | 654 | { |
641 | - if (empty($context['settings_insert_above'])) |
|
642 | - $context['settings_insert_above'] = ''; |
|
655 | + if (empty($context['settings_insert_above'])) { |
|
656 | + $context['settings_insert_above'] = ''; |
|
657 | + } |
|
643 | 658 | |
644 | 659 | $context['settings_insert_above'] .= '<div class="noticebox">' . sprintf($txt['question_not_defined'], $context['languages'][$language]['name']) . '</div>'; |
645 | 660 | } |
@@ -682,8 +697,9 @@ discard block |
||
682 | 697 | $_POST['pm_spam_settings'] = (int) $_POST['max_pm_recipients'] . ',' . (int) $_POST['pm_posts_verification'] . ',' . (int) $_POST['pm_posts_per_hour']; |
683 | 698 | |
684 | 699 | // Hack in guest requiring verification! |
685 | - if (empty($_POST['posts_require_captcha']) && !empty($_POST['guests_require_captcha'])) |
|
686 | - $_POST['posts_require_captcha'] = -1; |
|
700 | + if (empty($_POST['posts_require_captcha']) && !empty($_POST['guests_require_captcha'])) { |
|
701 | + $_POST['posts_require_captcha'] = -1; |
|
702 | + } |
|
687 | 703 | |
688 | 704 | $save_vars = $config_vars; |
689 | 705 | unset($save_vars['pm1'], $save_vars['pm2'], $save_vars['pm3'], $save_vars['guest_verify']); |
@@ -700,14 +716,16 @@ discard block |
||
700 | 716 | foreach ($context['qa_languages'] as $lang_id => $dummy) |
701 | 717 | { |
702 | 718 | // If we had some questions for this language before, but don't now, delete everything from that language. |
703 | - if ((!isset($_POST['question'][$lang_id]) || !is_array($_POST['question'][$lang_id])) && !empty($context['qa_by_lang'][$lang_id])) |
|
704 | - $changes['delete'] = array_merge($questions['delete'], $context['qa_by_lang'][$lang_id]); |
|
719 | + if ((!isset($_POST['question'][$lang_id]) || !is_array($_POST['question'][$lang_id])) && !empty($context['qa_by_lang'][$lang_id])) { |
|
720 | + $changes['delete'] = array_merge($questions['delete'], $context['qa_by_lang'][$lang_id]); |
|
721 | + } |
|
705 | 722 | |
706 | 723 | // Now step through and see if any existing questions no longer exist. |
707 | - if (!empty($context['qa_by_lang'][$lang_id])) |
|
708 | - foreach ($context['qa_by_lang'][$lang_id] as $q_id) |
|
724 | + if (!empty($context['qa_by_lang'][$lang_id])) { |
|
725 | + foreach ($context['qa_by_lang'][$lang_id] as $q_id) |
|
709 | 726 | if (empty($_POST['question'][$lang_id][$q_id])) |
710 | 727 | $changes['delete'][] = $q_id; |
728 | + } |
|
711 | 729 | |
712 | 730 | // Now let's see if there are new questions or ones that need updating. |
713 | 731 | if (isset($_POST['question'][$lang_id])) |
@@ -716,14 +734,16 @@ discard block |
||
716 | 734 | { |
717 | 735 | // Ignore junky ids. |
718 | 736 | $q_id = (int) $q_id; |
719 | - if ($q_id <= 0) |
|
720 | - continue; |
|
737 | + if ($q_id <= 0) { |
|
738 | + continue; |
|
739 | + } |
|
721 | 740 | |
722 | 741 | // Check the question isn't empty (because they want to delete it?) |
723 | 742 | if (empty($question) || trim($question) == '') |
724 | 743 | { |
725 | - if (isset($context['question_answers'][$q_id])) |
|
726 | - $changes['delete'][] = $q_id; |
|
744 | + if (isset($context['question_answers'][$q_id])) { |
|
745 | + $changes['delete'][] = $q_id; |
|
746 | + } |
|
727 | 747 | continue; |
728 | 748 | } |
729 | 749 | $question = $smcFunc['htmlspecialchars'](trim($question)); |
@@ -731,19 +751,22 @@ discard block |
||
731 | 751 | // Get the answers. Firstly check there actually might be some. |
732 | 752 | if (!isset($_POST['answer'][$lang_id][$q_id]) || !is_array($_POST['answer'][$lang_id][$q_id])) |
733 | 753 | { |
734 | - if (isset($context['question_answers'][$q_id])) |
|
735 | - $changes['delete'][] = $q_id; |
|
754 | + if (isset($context['question_answers'][$q_id])) { |
|
755 | + $changes['delete'][] = $q_id; |
|
756 | + } |
|
736 | 757 | continue; |
737 | 758 | } |
738 | 759 | // Now get them and check that they might be viable. |
739 | 760 | $answers = array(); |
740 | - foreach ($_POST['answer'][$lang_id][$q_id] as $answer) |
|
741 | - if (!empty($answer) && trim($answer) !== '') |
|
761 | + foreach ($_POST['answer'][$lang_id][$q_id] as $answer) { |
|
762 | + if (!empty($answer) && trim($answer) !== '') |
|
742 | 763 | $answers[] = $smcFunc['htmlspecialchars'](trim($answer)); |
764 | + } |
|
743 | 765 | if (empty($answers)) |
744 | 766 | { |
745 | - if (isset($context['question_answers'][$q_id])) |
|
746 | - $changes['delete'][] = $q_id; |
|
767 | + if (isset($context['question_answers'][$q_id])) { |
|
768 | + $changes['delete'][] = $q_id; |
|
769 | + } |
|
747 | 770 | continue; |
748 | 771 | } |
749 | 772 | $answers = $smcFunc['json_encode']($answers); |
@@ -753,16 +776,17 @@ discard block |
||
753 | 776 | { |
754 | 777 | // New question. Now, we don't want to randomly consume ids, so we'll set those, rather than trusting the browser's supplied ids. |
755 | 778 | $changes['insert'][] = array($lang_id, $question, $answers); |
756 | - } |
|
757 | - else |
|
779 | + } else |
|
758 | 780 | { |
759 | 781 | // It's an existing question. Let's see what's changed, if anything. |
760 | - if ($lang_id != $context['question_answers'][$q_id]['lngfile'] || $question != $context['question_answers'][$q_id]['question'] || $answers != $context['question_answers'][$q_id]['answers']) |
|
761 | - $changes['replace'][$q_id] = array('lngfile' => $lang_id, 'question' => $question, 'answers' => $answers); |
|
782 | + if ($lang_id != $context['question_answers'][$q_id]['lngfile'] || $question != $context['question_answers'][$q_id]['question'] || $answers != $context['question_answers'][$q_id]['answers']) { |
|
783 | + $changes['replace'][$q_id] = array('lngfile' => $lang_id, 'question' => $question, 'answers' => $answers); |
|
784 | + } |
|
762 | 785 | } |
763 | 786 | |
764 | - if (!isset($qs_per_lang[$lang_id])) |
|
765 | - $qs_per_lang[$lang_id] = 0; |
|
787 | + if (!isset($qs_per_lang[$lang_id])) { |
|
788 | + $qs_per_lang[$lang_id] = 0; |
|
789 | + } |
|
766 | 790 | $qs_per_lang[$lang_id]++; |
767 | 791 | } |
768 | 792 | } |
@@ -812,8 +836,9 @@ discard block |
||
812 | 836 | |
813 | 837 | // Lastly, the count of messages needs to be no more than the lowest number of questions for any one language. |
814 | 838 | $count_questions = empty($qs_per_lang) ? 0 : min($qs_per_lang); |
815 | - if (empty($count_questions) || $_POST['qa_verification_number'] > $count_questions) |
|
816 | - $_POST['qa_verification_number'] = $count_questions; |
|
839 | + if (empty($count_questions) || $_POST['qa_verification_number'] > $count_questions) { |
|
840 | + $_POST['qa_verification_number'] = $count_questions; |
|
841 | + } |
|
817 | 842 | |
818 | 843 | call_integration_hook('integrate_save_spam_settings', array(&$save_vars)); |
819 | 844 | |
@@ -828,24 +853,27 @@ discard block |
||
828 | 853 | |
829 | 854 | $character_range = array_merge(range('A', 'H'), array('K', 'M', 'N', 'P', 'R'), range('T', 'Y')); |
830 | 855 | $_SESSION['visual_verification_code'] = ''; |
831 | - for ($i = 0; $i < 6; $i++) |
|
832 | - $_SESSION['visual_verification_code'] .= $character_range[array_rand($character_range)]; |
|
856 | + for ($i = 0; $i < 6; $i++) { |
|
857 | + $_SESSION['visual_verification_code'] .= $character_range[array_rand($character_range)]; |
|
858 | + } |
|
833 | 859 | |
834 | 860 | // Some javascript for CAPTCHA. |
835 | 861 | $context['settings_post_javascript'] = ''; |
836 | - if ($context['use_graphic_library']) |
|
837 | - $context['settings_post_javascript'] .= ' |
|
862 | + if ($context['use_graphic_library']) { |
|
863 | + $context['settings_post_javascript'] .= ' |
|
838 | 864 | function refreshImages() |
839 | 865 | { |
840 | 866 | var imageType = document.getElementById(\'visual_verification_type\').value; |
841 | 867 | document.getElementById(\'verification_image\').src = \'' . $context['verification_image_href'] . ';type=\' + imageType; |
842 | 868 | }'; |
869 | + } |
|
843 | 870 | |
844 | 871 | // Show the image itself, or text saying we can't. |
845 | - if ($context['use_graphic_library']) |
|
846 | - $config_vars['vv']['postinput'] = '<br><img src="' . $context['verification_image_href'] . ';type=' . (empty($modSettings['visual_verification_type']) ? 0 : $modSettings['visual_verification_type']) . '" alt="' . $txt['setting_image_verification_sample'] . '" id="verification_image"><br>'; |
|
847 | - else |
|
848 | - $config_vars['vv']['postinput'] = '<br><span class="smalltext">' . $txt['setting_image_verification_nogd'] . '</span>'; |
|
872 | + if ($context['use_graphic_library']) { |
|
873 | + $config_vars['vv']['postinput'] = '<br><img src="' . $context['verification_image_href'] . ';type=' . (empty($modSettings['visual_verification_type']) ? 0 : $modSettings['visual_verification_type']) . '" alt="' . $txt['setting_image_verification_sample'] . '" id="verification_image"><br>'; |
|
874 | + } else { |
|
875 | + $config_vars['vv']['postinput'] = '<br><span class="smalltext">' . $txt['setting_image_verification_nogd'] . '</span>'; |
|
876 | + } |
|
849 | 877 | |
850 | 878 | // Hack for PM spam settings. |
851 | 879 | list ($modSettings['max_pm_recipients'], $modSettings['pm_posts_verification'], $modSettings['pm_posts_per_hour']) = explode(',', $modSettings['pm_spam_settings']); |
@@ -855,9 +883,10 @@ discard block |
||
855 | 883 | $modSettings['posts_require_captcha'] = !isset($modSettings['posts_require_captcha']) || $modSettings['posts_require_captcha'] == -1 ? 0 : $modSettings['posts_require_captcha']; |
856 | 884 | |
857 | 885 | // Some minor javascript for the guest post setting. |
858 | - if ($modSettings['posts_require_captcha']) |
|
859 | - $context['settings_post_javascript'] .= ' |
|
886 | + if ($modSettings['posts_require_captcha']) { |
|
887 | + $context['settings_post_javascript'] .= ' |
|
860 | 888 | document.getElementById(\'guests_require_captcha\').disabled = true;'; |
889 | + } |
|
861 | 890 | |
862 | 891 | // And everything else. |
863 | 892 | $context['post_url'] = $scripturl . '?action=admin;area=antispam;save'; |
@@ -904,8 +933,9 @@ discard block |
||
904 | 933 | |
905 | 934 | call_integration_hook('integrate_signature_settings', array(&$config_vars)); |
906 | 935 | |
907 | - if ($return_config) |
|
908 | - return $config_vars; |
|
936 | + if ($return_config) { |
|
937 | + return $config_vars; |
|
938 | + } |
|
909 | 939 | |
910 | 940 | // Setup the template. |
911 | 941 | $context['page_title'] = $txt['signature_settings']; |
@@ -960,8 +990,9 @@ discard block |
||
960 | 990 | $sig = strtr($row['signature'], array('<br>' => "\n")); |
961 | 991 | |
962 | 992 | // Max characters... |
963 | - if (!empty($sig_limits[1])) |
|
964 | - $sig = $smcFunc['substr']($sig, 0, $sig_limits[1]); |
|
993 | + if (!empty($sig_limits[1])) { |
|
994 | + $sig = $smcFunc['substr']($sig, 0, $sig_limits[1]); |
|
995 | + } |
|
965 | 996 | // Max lines... |
966 | 997 | if (!empty($sig_limits[2])) |
967 | 998 | { |
@@ -971,8 +1002,9 @@ discard block |
||
971 | 1002 | if ($sig[$i] == "\n") |
972 | 1003 | { |
973 | 1004 | $count++; |
974 | - if ($count >= $sig_limits[2]) |
|
975 | - $sig = substr($sig, 0, $i) . strtr(substr($sig, $i), array("\n" => ' ')); |
|
1005 | + if ($count >= $sig_limits[2]) { |
|
1006 | + $sig = substr($sig, 0, $i) . strtr(substr($sig, $i), array("\n" => ' ')); |
|
1007 | + } |
|
976 | 1008 | } |
977 | 1009 | } |
978 | 1010 | } |
@@ -983,17 +1015,19 @@ discard block |
||
983 | 1015 | { |
984 | 1016 | $limit_broke = 0; |
985 | 1017 | // Attempt to allow all sizes of abuse, so to speak. |
986 | - if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) |
|
987 | - $limit_broke = $sig_limits[7] . 'px'; |
|
988 | - elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) |
|
989 | - $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt'; |
|
990 | - elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) |
|
991 | - $limit_broke = ((float) $sig_limits[7] / 16) . 'em'; |
|
992 | - elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) |
|
993 | - $limit_broke = 'large'; |
|
994 | - |
|
995 | - if ($limit_broke) |
|
996 | - $sig = str_replace($matches[0][$ind], '[size=' . $sig_limits[7] . 'px', $sig); |
|
1018 | + if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) { |
|
1019 | + $limit_broke = $sig_limits[7] . 'px'; |
|
1020 | + } elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) { |
|
1021 | + $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt'; |
|
1022 | + } elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) { |
|
1023 | + $limit_broke = ((float) $sig_limits[7] / 16) . 'em'; |
|
1024 | + } elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) { |
|
1025 | + $limit_broke = 'large'; |
|
1026 | + } |
|
1027 | + |
|
1028 | + if ($limit_broke) { |
|
1029 | + $sig = str_replace($matches[0][$ind], '[size=' . $sig_limits[7] . 'px', $sig); |
|
1030 | + } |
|
997 | 1031 | } |
998 | 1032 | } |
999 | 1033 | |
@@ -1049,32 +1083,34 @@ discard block |
||
1049 | 1083 | $img_offset = false; |
1050 | 1084 | } |
1051 | 1085 | } |
1086 | + } else { |
|
1087 | + $replaces[$image] = ''; |
|
1052 | 1088 | } |
1053 | - else |
|
1054 | - $replaces[$image] = ''; |
|
1055 | 1089 | |
1056 | 1090 | continue; |
1057 | 1091 | } |
1058 | 1092 | |
1059 | 1093 | // Does it have predefined restraints? Width first. |
1060 | - if ($matches[6][$key]) |
|
1061 | - $matches[2][$key] = $matches[6][$key]; |
|
1094 | + if ($matches[6][$key]) { |
|
1095 | + $matches[2][$key] = $matches[6][$key]; |
|
1096 | + } |
|
1062 | 1097 | if ($matches[2][$key] && $sig_limits[5] && $matches[2][$key] > $sig_limits[5]) |
1063 | 1098 | { |
1064 | 1099 | $width = $sig_limits[5]; |
1065 | 1100 | $matches[4][$key] = $matches[4][$key] * ($width / $matches[2][$key]); |
1101 | + } elseif ($matches[2][$key]) { |
|
1102 | + $width = $matches[2][$key]; |
|
1066 | 1103 | } |
1067 | - elseif ($matches[2][$key]) |
|
1068 | - $width = $matches[2][$key]; |
|
1069 | 1104 | // ... and height. |
1070 | 1105 | if ($matches[4][$key] && $sig_limits[6] && $matches[4][$key] > $sig_limits[6]) |
1071 | 1106 | { |
1072 | 1107 | $height = $sig_limits[6]; |
1073 | - if ($width != -1) |
|
1074 | - $width = $width * ($height / $matches[4][$key]); |
|
1108 | + if ($width != -1) { |
|
1109 | + $width = $width * ($height / $matches[4][$key]); |
|
1110 | + } |
|
1111 | + } elseif ($matches[4][$key]) { |
|
1112 | + $height = $matches[4][$key]; |
|
1075 | 1113 | } |
1076 | - elseif ($matches[4][$key]) |
|
1077 | - $height = $matches[4][$key]; |
|
1078 | 1114 | |
1079 | 1115 | // If the dimensions are still not fixed - we need to check the actual image. |
1080 | 1116 | if (($width == -1 && $sig_limits[5]) || ($height == -1 && $sig_limits[6])) |
@@ -1092,12 +1128,13 @@ discard block |
||
1092 | 1128 | if ($sizes[1] > $sig_limits[6] && $sig_limits[6]) |
1093 | 1129 | { |
1094 | 1130 | $height = $sig_limits[6]; |
1095 | - if ($width == -1) |
|
1096 | - $width = $sizes[0]; |
|
1131 | + if ($width == -1) { |
|
1132 | + $width = $sizes[0]; |
|
1133 | + } |
|
1097 | 1134 | $width = $width * ($height / $sizes[1]); |
1135 | + } elseif ($width != -1) { |
|
1136 | + $height = $sizes[1]; |
|
1098 | 1137 | } |
1099 | - elseif ($width != -1) |
|
1100 | - $height = $sizes[1]; |
|
1101 | 1138 | } |
1102 | 1139 | } |
1103 | 1140 | |
@@ -1110,8 +1147,9 @@ discard block |
||
1110 | 1147 | // Record that we got one. |
1111 | 1148 | $image_count_holder[$image] = isset($image_count_holder[$image]) ? $image_count_holder[$image] + 1 : 1; |
1112 | 1149 | } |
1113 | - if (!empty($replaces)) |
|
1114 | - $sig = str_replace(array_keys($replaces), array_values($replaces), $sig); |
|
1150 | + if (!empty($replaces)) { |
|
1151 | + $sig = str_replace(array_keys($replaces), array_values($replaces), $sig); |
|
1152 | + } |
|
1115 | 1153 | } |
1116 | 1154 | } |
1117 | 1155 | // Try to fix disabled tags. |
@@ -1123,18 +1161,20 @@ discard block |
||
1123 | 1161 | |
1124 | 1162 | $sig = strtr($sig, array("\n" => '<br>')); |
1125 | 1163 | call_integration_hook('integrate_apply_signature_settings', array(&$sig, $sig_limits, $disabledTags)); |
1126 | - if ($sig != $row['signature']) |
|
1127 | - $changes[$row['id_member']] = $sig; |
|
1164 | + if ($sig != $row['signature']) { |
|
1165 | + $changes[$row['id_member']] = $sig; |
|
1166 | + } |
|
1167 | + } |
|
1168 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1169 | + $done = true; |
|
1128 | 1170 | } |
1129 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1130 | - $done = true; |
|
1131 | 1171 | $smcFunc['db_free_result']($request); |
1132 | 1172 | |
1133 | 1173 | // Do we need to delete what we have? |
1134 | 1174 | if (!empty($changes)) |
1135 | 1175 | { |
1136 | - foreach ($changes as $id => $sig) |
|
1137 | - $smcFunc['db_query']('', ' |
|
1176 | + foreach ($changes as $id => $sig) { |
|
1177 | + $smcFunc['db_query']('', ' |
|
1138 | 1178 | UPDATE {db_prefix}members |
1139 | 1179 | SET signature = {string:signature} |
1140 | 1180 | WHERE id_member = {int:id_member}', |
@@ -1143,11 +1183,13 @@ discard block |
||
1143 | 1183 | 'signature' => $sig, |
1144 | 1184 | ) |
1145 | 1185 | ); |
1186 | + } |
|
1146 | 1187 | } |
1147 | 1188 | |
1148 | 1189 | $_GET['step'] += 50; |
1149 | - if (!$done) |
|
1150 | - pauseSignatureApplySettings(); |
|
1190 | + if (!$done) { |
|
1191 | + pauseSignatureApplySettings(); |
|
1192 | + } |
|
1151 | 1193 | } |
1152 | 1194 | $settings_applied = true; |
1153 | 1195 | } |
@@ -1165,8 +1207,9 @@ discard block |
||
1165 | 1207 | ); |
1166 | 1208 | |
1167 | 1209 | // Temporarily make each setting a modSetting! |
1168 | - foreach ($context['signature_settings'] as $key => $value) |
|
1169 | - $modSettings['signature_' . $key] = $value; |
|
1210 | + foreach ($context['signature_settings'] as $key => $value) { |
|
1211 | + $modSettings['signature_' . $key] = $value; |
|
1212 | + } |
|
1170 | 1213 | |
1171 | 1214 | // Make sure we check the right tags! |
1172 | 1215 | $modSettings['bbc_disabled_signature_bbc'] = $disabledTags; |
@@ -1178,23 +1221,26 @@ discard block |
||
1178 | 1221 | |
1179 | 1222 | // Clean up the tag stuff! |
1180 | 1223 | $bbcTags = array(); |
1181 | - foreach (parse_bbc(false) as $tag) |
|
1182 | - $bbcTags[] = $tag['tag']; |
|
1224 | + foreach (parse_bbc(false) as $tag) { |
|
1225 | + $bbcTags[] = $tag['tag']; |
|
1226 | + } |
|
1183 | 1227 | |
1184 | - if (!isset($_POST['signature_bbc_enabledTags'])) |
|
1185 | - $_POST['signature_bbc_enabledTags'] = array(); |
|
1186 | - elseif (!is_array($_POST['signature_bbc_enabledTags'])) |
|
1187 | - $_POST['signature_bbc_enabledTags'] = array($_POST['signature_bbc_enabledTags']); |
|
1228 | + if (!isset($_POST['signature_bbc_enabledTags'])) { |
|
1229 | + $_POST['signature_bbc_enabledTags'] = array(); |
|
1230 | + } elseif (!is_array($_POST['signature_bbc_enabledTags'])) { |
|
1231 | + $_POST['signature_bbc_enabledTags'] = array($_POST['signature_bbc_enabledTags']); |
|
1232 | + } |
|
1188 | 1233 | |
1189 | 1234 | $sig_limits = array(); |
1190 | 1235 | foreach ($context['signature_settings'] as $key => $value) |
1191 | 1236 | { |
1192 | - if ($key == 'allow_smileys') |
|
1193 | - continue; |
|
1194 | - elseif ($key == 'max_smileys' && empty($_POST['signature_allow_smileys'])) |
|
1195 | - $sig_limits[] = -1; |
|
1196 | - else |
|
1197 | - $sig_limits[] = !empty($_POST['signature_' . $key]) ? max(1, (int) $_POST['signature_' . $key]) : 0; |
|
1237 | + if ($key == 'allow_smileys') { |
|
1238 | + continue; |
|
1239 | + } elseif ($key == 'max_smileys' && empty($_POST['signature_allow_smileys'])) { |
|
1240 | + $sig_limits[] = -1; |
|
1241 | + } else { |
|
1242 | + $sig_limits[] = !empty($_POST['signature_' . $key]) ? max(1, (int) $_POST['signature_' . $key]) : 0; |
|
1243 | + } |
|
1198 | 1244 | } |
1199 | 1245 | |
1200 | 1246 | call_integration_hook('integrate_save_signature_settings', array(&$sig_limits, &$bbcTags)); |
@@ -1227,12 +1273,14 @@ discard block |
||
1227 | 1273 | |
1228 | 1274 | // Try get more time... |
1229 | 1275 | @set_time_limit(600); |
1230 | - if (function_exists('apache_reset_timeout')) |
|
1231 | - @apache_reset_timeout(); |
|
1276 | + if (function_exists('apache_reset_timeout')) { |
|
1277 | + @apache_reset_timeout(); |
|
1278 | + } |
|
1232 | 1279 | |
1233 | 1280 | // Have we exhausted all the time we allowed? |
1234 | - if (time() - array_sum(explode(' ', $sig_start)) < 3) |
|
1235 | - return; |
|
1281 | + if (time() - array_sum(explode(' ', $sig_start)) < 3) { |
|
1282 | + return; |
|
1283 | + } |
|
1236 | 1284 | |
1237 | 1285 | $context['continue_get_data'] = '?action=admin;area=featuresettings;sa=sig;apply;step=' . $_GET['step'] . ';' . $context['session_var'] . '=' . $context['session_id']; |
1238 | 1286 | $context['page_title'] = $txt['not_done_title']; |
@@ -1278,9 +1326,10 @@ discard block |
||
1278 | 1326 | $disable_fields = array_flip($standard_fields); |
1279 | 1327 | if (!empty($_POST['active'])) |
1280 | 1328 | { |
1281 | - foreach ($_POST['active'] as $value) |
|
1282 | - if (isset($disable_fields[$value])) |
|
1329 | + foreach ($_POST['active'] as $value) { |
|
1330 | + if (isset($disable_fields[$value])) |
|
1283 | 1331 | unset($disable_fields[$value]); |
1332 | + } |
|
1284 | 1333 | } |
1285 | 1334 | // What we have left! |
1286 | 1335 | $changes['disabled_profile_fields'] = empty($disable_fields) ? '' : implode(',', array_keys($disable_fields)); |
@@ -1289,16 +1338,18 @@ discard block |
||
1289 | 1338 | $reg_fields = array(); |
1290 | 1339 | if (!empty($_POST['reg'])) |
1291 | 1340 | { |
1292 | - foreach ($_POST['reg'] as $value) |
|
1293 | - if (in_array($value, $standard_fields) && !isset($disable_fields[$value])) |
|
1341 | + foreach ($_POST['reg'] as $value) { |
|
1342 | + if (in_array($value, $standard_fields) && !isset($disable_fields[$value])) |
|
1294 | 1343 | $reg_fields[] = $value; |
1344 | + } |
|
1295 | 1345 | } |
1296 | 1346 | // What we have left! |
1297 | 1347 | $changes['registration_fields'] = empty($reg_fields) ? '' : implode(',', $reg_fields); |
1298 | 1348 | |
1299 | 1349 | $_SESSION['adm-save'] = true; |
1300 | - if (!empty($changes)) |
|
1301 | - updateSettings($changes); |
|
1350 | + if (!empty($changes)) { |
|
1351 | + updateSettings($changes); |
|
1352 | + } |
|
1302 | 1353 | } |
1303 | 1354 | |
1304 | 1355 | createToken('admin-scp'); |
@@ -1401,11 +1452,13 @@ discard block |
||
1401 | 1452 | { |
1402 | 1453 | $return = '<p class="centertext bold_text">'. $rowData['field_order'] .'<br>'; |
1403 | 1454 | |
1404 | - if ($rowData['field_order'] > 1) |
|
1405 | - $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_up'] .'"></span></a>'; |
|
1455 | + if ($rowData['field_order'] > 1) { |
|
1456 | + $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_up'] .'"></span></a>'; |
|
1457 | + } |
|
1406 | 1458 | |
1407 | - if ($rowData['field_order'] < $context['custFieldsMaxOrder']) |
|
1408 | - $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_down'] .'"></span></a>'; |
|
1459 | + if ($rowData['field_order'] < $context['custFieldsMaxOrder']) { |
|
1460 | + $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_down'] .'"></span></a>'; |
|
1461 | + } |
|
1409 | 1462 | |
1410 | 1463 | $return .= '</p>'; |
1411 | 1464 | |
@@ -1543,16 +1596,16 @@ discard block |
||
1543 | 1596 | $disabled_fields = isset($modSettings['disabled_profile_fields']) ? explode(',', $modSettings['disabled_profile_fields']) : array(); |
1544 | 1597 | $registration_fields = isset($modSettings['registration_fields']) ? explode(',', $modSettings['registration_fields']) : array(); |
1545 | 1598 | |
1546 | - foreach ($standard_fields as $field) |
|
1547 | - $list[] = array( |
|
1599 | + foreach ($standard_fields as $field) { |
|
1600 | + $list[] = array( |
|
1548 | 1601 | 'id' => $field, |
1549 | 1602 | 'label' => isset($txt['standard_profile_field_' . $field]) ? $txt['standard_profile_field_' . $field] : (isset($txt[$field]) ? $txt[$field] : $field), |
1550 | 1603 | 'disabled' => in_array($field, $disabled_fields), |
1551 | 1604 | 'on_register' => in_array($field, $registration_fields) && !in_array($field, $fields_no_registration), |
1552 | 1605 | 'can_show_register' => !in_array($field, $fields_no_registration), |
1553 | 1606 | ); |
1554 | - } |
|
1555 | - else |
|
1607 | + } |
|
1608 | + } else |
|
1556 | 1609 | { |
1557 | 1610 | // Load all the fields. |
1558 | 1611 | $request = $smcFunc['db_query']('', ' |
@@ -1566,8 +1619,9 @@ discard block |
||
1566 | 1619 | 'items_per_page' => $items_per_page, |
1567 | 1620 | ) |
1568 | 1621 | ); |
1569 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1570 | - $list[] = $row; |
|
1622 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1623 | + $list[] = $row; |
|
1624 | + } |
|
1571 | 1625 | $smcFunc['db_free_result']($request); |
1572 | 1626 | } |
1573 | 1627 | |
@@ -1633,9 +1687,9 @@ discard block |
||
1633 | 1687 | $context['field'] = array(); |
1634 | 1688 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1635 | 1689 | { |
1636 | - if ($row['field_type'] == 'textarea') |
|
1637 | - @list ($rows, $cols) = @explode(',', $row['default_value']); |
|
1638 | - else |
|
1690 | + if ($row['field_type'] == 'textarea') { |
|
1691 | + @list ($rows, $cols) = @explode(',', $row['default_value']); |
|
1692 | + } else |
|
1639 | 1693 | { |
1640 | 1694 | $rows = 3; |
1641 | 1695 | $cols = 30; |
@@ -1671,8 +1725,8 @@ discard block |
||
1671 | 1725 | } |
1672 | 1726 | |
1673 | 1727 | // Setup the default values as needed. |
1674 | - if (empty($context['field'])) |
|
1675 | - $context['field'] = array( |
|
1728 | + if (empty($context['field'])) { |
|
1729 | + $context['field'] = array( |
|
1676 | 1730 | 'name' => '', |
1677 | 1731 | 'col_name' => '???', |
1678 | 1732 | 'desc' => '', |
@@ -1697,6 +1751,7 @@ discard block |
||
1697 | 1751 | 'enclose' => '', |
1698 | 1752 | 'placement' => 0, |
1699 | 1753 | ); |
1754 | + } |
|
1700 | 1755 | |
1701 | 1756 | // Are we moving it? |
1702 | 1757 | if (isset($_GET['move']) && in_array($smcFunc['htmlspecialchars']($_GET['move']), $move_to)) |
@@ -1705,8 +1760,10 @@ discard block |
||
1705 | 1760 | $new_order = ($_GET['move'] == 'up' ? ($context['field']['order'] - 1) : ($context['field']['order'] + 1)); |
1706 | 1761 | |
1707 | 1762 | // Is this a valid position? |
1708 | - if ($new_order <= 0 || $new_order > $order_count) |
|
1709 | - redirectexit('action=admin;area=featuresettings;sa=profile'); // @todo implement an error handler |
|
1763 | + if ($new_order <= 0 || $new_order > $order_count) { |
|
1764 | + redirectexit('action=admin;area=featuresettings;sa=profile'); |
|
1765 | + } |
|
1766 | + // @todo implement an error handler |
|
1710 | 1767 | |
1711 | 1768 | // All good, proceed. |
1712 | 1769 | $smcFunc['db_query']('',' |
@@ -1737,12 +1794,14 @@ discard block |
||
1737 | 1794 | validateToken('admin-ecp'); |
1738 | 1795 | |
1739 | 1796 | // Everyone needs a name - even the (bracket) unknown... |
1740 | - if (trim($_POST['field_name']) == '') |
|
1741 | - redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=need_name'); |
|
1797 | + if (trim($_POST['field_name']) == '') { |
|
1798 | + redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=need_name'); |
|
1799 | + } |
|
1742 | 1800 | |
1743 | 1801 | // Regex you say? Do a very basic test to see if the pattern is valid |
1744 | - if (!empty($_POST['regex']) && @preg_match($_POST['regex'], 'dummy') === false) |
|
1745 | - redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=regex_error'); |
|
1802 | + if (!empty($_POST['regex']) && @preg_match($_POST['regex'], 'dummy') === false) { |
|
1803 | + redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=regex_error'); |
|
1804 | + } |
|
1746 | 1805 | |
1747 | 1806 | $_POST['field_name'] = $smcFunc['htmlspecialchars']($_POST['field_name']); |
1748 | 1807 | $_POST['field_desc'] = $smcFunc['htmlspecialchars']($_POST['field_desc']); |
@@ -1759,8 +1818,9 @@ discard block |
||
1759 | 1818 | |
1760 | 1819 | // Some masking stuff... |
1761 | 1820 | $mask = isset($_POST['mask']) ? $_POST['mask'] : ''; |
1762 | - if ($mask == 'regex' && isset($_POST['regex'])) |
|
1763 | - $mask .= $_POST['regex']; |
|
1821 | + if ($mask == 'regex' && isset($_POST['regex'])) { |
|
1822 | + $mask .= $_POST['regex']; |
|
1823 | + } |
|
1764 | 1824 | |
1765 | 1825 | $field_length = isset($_POST['max_length']) ? (int) $_POST['max_length'] : 255; |
1766 | 1826 | $enclose = isset($_POST['enclose']) ? $_POST['enclose'] : ''; |
@@ -1779,8 +1839,9 @@ discard block |
||
1779 | 1839 | $v = strtr($v, array(',' => '')); |
1780 | 1840 | |
1781 | 1841 | // Nada, zip, etc... |
1782 | - if (trim($v) == '') |
|
1783 | - continue; |
|
1842 | + if (trim($v) == '') { |
|
1843 | + continue; |
|
1844 | + } |
|
1784 | 1845 | |
1785 | 1846 | // Otherwise, save it boy. |
1786 | 1847 | $field_options .= $v . ','; |
@@ -1788,15 +1849,17 @@ discard block |
||
1788 | 1849 | $newOptions[$k] = $v; |
1789 | 1850 | |
1790 | 1851 | // Is it default? |
1791 | - if (isset($_POST['default_select']) && $_POST['default_select'] == $k) |
|
1792 | - $default = $v; |
|
1852 | + if (isset($_POST['default_select']) && $_POST['default_select'] == $k) { |
|
1853 | + $default = $v; |
|
1854 | + } |
|
1793 | 1855 | } |
1794 | 1856 | $field_options = substr($field_options, 0, -1); |
1795 | 1857 | } |
1796 | 1858 | |
1797 | 1859 | // Text area has default has dimensions |
1798 | - if ($_POST['field_type'] == 'textarea') |
|
1799 | - $default = (int) $_POST['rows'] . ',' . (int) $_POST['cols']; |
|
1860 | + if ($_POST['field_type'] == 'textarea') { |
|
1861 | + $default = (int) $_POST['rows'] . ',' . (int) $_POST['cols']; |
|
1862 | + } |
|
1800 | 1863 | |
1801 | 1864 | // Come up with the unique name? |
1802 | 1865 | if (empty($context['fid'])) |
@@ -1805,32 +1868,36 @@ discard block |
||
1805 | 1868 | preg_match('~([\w\d_-]+)~', $col_name, $matches); |
1806 | 1869 | |
1807 | 1870 | // If there is nothing to the name, then let's start out own - for foreign languages etc. |
1808 | - if (isset($matches[1])) |
|
1809 | - $col_name = $initial_col_name = 'cust_' . strtolower($matches[1]); |
|
1810 | - else |
|
1811 | - $col_name = $initial_col_name = 'cust_' . mt_rand(1, 9999); |
|
1871 | + if (isset($matches[1])) { |
|
1872 | + $col_name = $initial_col_name = 'cust_' . strtolower($matches[1]); |
|
1873 | + } else { |
|
1874 | + $col_name = $initial_col_name = 'cust_' . mt_rand(1, 9999); |
|
1875 | + } |
|
1812 | 1876 | |
1813 | 1877 | // Make sure this is unique. |
1814 | 1878 | $current_fields = array(); |
1815 | 1879 | $request = $smcFunc['db_query']('', ' |
1816 | 1880 | SELECT id_field, col_name |
1817 | 1881 | FROM {db_prefix}custom_fields'); |
1818 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1819 | - $current_fields[$row['id_field']] = $row['col_name']; |
|
1882 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1883 | + $current_fields[$row['id_field']] = $row['col_name']; |
|
1884 | + } |
|
1820 | 1885 | $smcFunc['db_free_result']($request); |
1821 | 1886 | |
1822 | 1887 | $unique = false; |
1823 | 1888 | for ($i = 0; !$unique && $i < 9; $i ++) |
1824 | 1889 | { |
1825 | - if (!in_array($col_name, $current_fields)) |
|
1826 | - $unique = true; |
|
1827 | - else |
|
1828 | - $col_name = $initial_col_name . $i; |
|
1890 | + if (!in_array($col_name, $current_fields)) { |
|
1891 | + $unique = true; |
|
1892 | + } else { |
|
1893 | + $col_name = $initial_col_name . $i; |
|
1894 | + } |
|
1829 | 1895 | } |
1830 | 1896 | |
1831 | 1897 | // Still not a unique column name? Leave it up to the user, then. |
1832 | - if (!$unique) |
|
1833 | - fatal_lang_error('custom_option_not_unique'); |
|
1898 | + if (!$unique) { |
|
1899 | + fatal_lang_error('custom_option_not_unique'); |
|
1900 | + } |
|
1834 | 1901 | } |
1835 | 1902 | // Work out what to do with the user data otherwise... |
1836 | 1903 | else |
@@ -1858,8 +1925,9 @@ discard block |
||
1858 | 1925 | // Work out what's changed! |
1859 | 1926 | foreach ($context['field']['options'] as $k => $option) |
1860 | 1927 | { |
1861 | - if (trim($option) == '') |
|
1862 | - continue; |
|
1928 | + if (trim($option) == '') { |
|
1929 | + continue; |
|
1930 | + } |
|
1863 | 1931 | |
1864 | 1932 | // Still exists? |
1865 | 1933 | if (in_array($option, $newOptions)) |
@@ -1873,8 +1941,8 @@ discard block |
||
1873 | 1941 | foreach ($optionChanges as $k => $option) |
1874 | 1942 | { |
1875 | 1943 | // Just been renamed? |
1876 | - if (!in_array($k, $takenKeys) && !empty($newOptions[$k])) |
|
1877 | - $smcFunc['db_query']('', ' |
|
1944 | + if (!in_array($k, $takenKeys) && !empty($newOptions[$k])) { |
|
1945 | + $smcFunc['db_query']('', ' |
|
1878 | 1946 | UPDATE {db_prefix}themes |
1879 | 1947 | SET value = {string:new_value} |
1880 | 1948 | WHERE variable = {string:current_column} |
@@ -1887,6 +1955,7 @@ discard block |
||
1887 | 1955 | 'old_value' => $option, |
1888 | 1956 | ) |
1889 | 1957 | ); |
1958 | + } |
|
1890 | 1959 | } |
1891 | 1960 | } |
1892 | 1961 | // @todo Maybe we should adjust based on new text length limits? |
@@ -1929,8 +1998,8 @@ discard block |
||
1929 | 1998 | ); |
1930 | 1999 | |
1931 | 2000 | // Just clean up any old selects - these are a pain! |
1932 | - if (($_POST['field_type'] == 'select' || $_POST['field_type'] == 'radio') && !empty($newOptions)) |
|
1933 | - $smcFunc['db_query']('', ' |
|
2001 | + if (($_POST['field_type'] == 'select' || $_POST['field_type'] == 'radio') && !empty($newOptions)) { |
|
2002 | + $smcFunc['db_query']('', ' |
|
1934 | 2003 | DELETE FROM {db_prefix}themes |
1935 | 2004 | WHERE variable = {string:current_column} |
1936 | 2005 | AND value NOT IN ({array_string:new_option_values}) |
@@ -1941,8 +2010,8 @@ discard block |
||
1941 | 2010 | 'current_column' => $context['field']['col_name'], |
1942 | 2011 | ) |
1943 | 2012 | ); |
1944 | - } |
|
1945 | - else |
|
2013 | + } |
|
2014 | + } else |
|
1946 | 2015 | { |
1947 | 2016 | // Gotta figure it out the order. |
1948 | 2017 | $new_order = $order_count > 1 ? ($order_count + 1) : 1; |
@@ -2116,11 +2185,13 @@ discard block |
||
2116 | 2185 | call_integration_hook('integrate_prune_settings', array(&$config_vars, &$prune_toggle, false)); |
2117 | 2186 | |
2118 | 2187 | $prune_toggle_dt = array(); |
2119 | - foreach ($prune_toggle as $item) |
|
2120 | - $prune_toggle_dt[] = 'setting_' . $item; |
|
2188 | + foreach ($prune_toggle as $item) { |
|
2189 | + $prune_toggle_dt[] = 'setting_' . $item; |
|
2190 | + } |
|
2121 | 2191 | |
2122 | - if ($return_config) |
|
2123 | - return $config_vars; |
|
2192 | + if ($return_config) { |
|
2193 | + return $config_vars; |
|
2194 | + } |
|
2124 | 2195 | |
2125 | 2196 | addInlineJavaScript(' |
2126 | 2197 | function togglePruned() |
@@ -2158,15 +2229,16 @@ discard block |
||
2158 | 2229 | $vals = array(); |
2159 | 2230 | foreach ($config_vars as $index => $dummy) |
2160 | 2231 | { |
2161 | - if (!is_array($dummy) || $index == 'pruningOptions' || !in_array($dummy[1], $prune_toggle)) |
|
2162 | - continue; |
|
2232 | + if (!is_array($dummy) || $index == 'pruningOptions' || !in_array($dummy[1], $prune_toggle)) { |
|
2233 | + continue; |
|
2234 | + } |
|
2163 | 2235 | |
2164 | 2236 | $vals[] = empty($_POST[$dummy[1]]) || $_POST[$dummy[1]] < 0 ? 0 : (int) $_POST[$dummy[1]]; |
2165 | 2237 | } |
2166 | 2238 | $_POST['pruningOptions'] = implode(',', $vals); |
2239 | + } else { |
|
2240 | + $_POST['pruningOptions'] = ''; |
|
2167 | 2241 | } |
2168 | - else |
|
2169 | - $_POST['pruningOptions'] = ''; |
|
2170 | 2242 | |
2171 | 2243 | saveDBSettings($savevar); |
2172 | 2244 | $_SESSION['adm-save'] = true; |
@@ -2178,10 +2250,11 @@ discard block |
||
2178 | 2250 | $context['sub_template'] = 'show_settings'; |
2179 | 2251 | |
2180 | 2252 | // Get the actual values |
2181 | - if (!empty($modSettings['pruningOptions'])) |
|
2182 | - @list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']); |
|
2183 | - else |
|
2184 | - $modSettings['pruneErrorLog'] = $modSettings['pruneModLog'] = $modSettings['pruneBanLog'] = $modSettings['pruneReportLog'] = $modSettings['pruneScheduledTaskLog'] = $modSettings['pruneSpiderHitLog'] = 0; |
|
2253 | + if (!empty($modSettings['pruningOptions'])) { |
|
2254 | + @list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']); |
|
2255 | + } else { |
|
2256 | + $modSettings['pruneErrorLog'] = $modSettings['pruneModLog'] = $modSettings['pruneBanLog'] = $modSettings['pruneReportLog'] = $modSettings['pruneScheduledTaskLog'] = $modSettings['pruneSpiderHitLog'] = 0; |
|
2257 | + } |
|
2185 | 2258 | |
2186 | 2259 | prepareDBSettingContext($config_vars); |
2187 | 2260 | } |
@@ -2203,8 +2276,9 @@ discard block |
||
2203 | 2276 | // Make it even easier to add new settings. |
2204 | 2277 | call_integration_hook('integrate_general_mod_settings', array(&$config_vars)); |
2205 | 2278 | |
2206 | - if ($return_config) |
|
2207 | - return $config_vars; |
|
2279 | + if ($return_config) { |
|
2280 | + return $config_vars; |
|
2281 | + } |
|
2208 | 2282 | |
2209 | 2283 | $context['post_url'] = $scripturl . '?action=admin;area=modsettings;save;sa=general'; |
2210 | 2284 | $context['settings_title'] = $txt['mods_cat_modifications_misc']; |
@@ -116,9 +116,10 @@ discard block |
||
116 | 116 | <h3 class="catbg">', $txt['attachment_transfer'], '</h3> |
117 | 117 | </div>'; |
118 | 118 | |
119 | - if (!empty($context['results'])) |
|
120 | - echo ' |
|
119 | + if (!empty($context['results'])) { |
|
120 | + echo ' |
|
121 | 121 | <div class="noticebox">', $context['results'], '</div>'; |
122 | + } |
|
122 | 123 | |
123 | 124 | echo ' |
124 | 125 | <div class="windowbg2 noup"> |
@@ -129,9 +130,10 @@ discard block |
||
129 | 130 | <dd><select name="from"> |
130 | 131 | <option value="0">', $txt['attachment_transfer_select'], '</option>'; |
131 | 132 | |
132 | - foreach ($context['attach_dirs'] as $id => $dir) |
|
133 | - echo ' |
|
133 | + foreach ($context['attach_dirs'] as $id => $dir) { |
|
134 | + echo ' |
|
134 | 135 | <option value="', $id, '">', $dir, '</option>'; |
136 | + } |
|
135 | 137 | echo ' |
136 | 138 | </select></dd> |
137 | 139 | <dt>', $txt['attachment_transfer_auto'], '</dt> |
@@ -139,13 +141,14 @@ discard block |
||
139 | 141 | <option value="0">', $txt['attachment_transfer_auto_select'], '</option> |
140 | 142 | <option value="-1">', $txt['attachment_transfer_forum_root'], '</option>'; |
141 | 143 | |
142 | - if (!empty($context['base_dirs'])) |
|
143 | - foreach ($context['base_dirs'] as $id => $dir) |
|
144 | + if (!empty($context['base_dirs'])) { |
|
145 | + foreach ($context['base_dirs'] as $id => $dir) |
|
144 | 146 | echo ' |
145 | 147 | <option value="', $id, '">', $dir, '</option>'; |
146 | - else |
|
147 | - echo ' |
|
148 | + } else { |
|
149 | + echo ' |
|
148 | 150 | <option value="0" disabled>', $txt['attachment_transfer_no_base'], '</option>'; |
151 | + } |
|
149 | 152 | |
150 | 153 | echo ' |
151 | 154 | </select></dd> |
@@ -153,16 +156,18 @@ discard block |
||
153 | 156 | <dd><select name="to"> |
154 | 157 | <option value="0">', $txt['attachment_transfer_select'], '</option>'; |
155 | 158 | |
156 | - foreach ($context['attach_dirs'] as $id => $dir) |
|
157 | - echo ' |
|
159 | + foreach ($context['attach_dirs'] as $id => $dir) { |
|
160 | + echo ' |
|
158 | 161 | <option value="', $id, '">', $dir, '</option>'; |
162 | + } |
|
159 | 163 | echo ' |
160 | 164 | </select></dd>'; |
161 | 165 | |
162 | - if (!empty($modSettings['attachmentDirFileLimit'])) |
|
163 | - echo ' |
|
166 | + if (!empty($modSettings['attachmentDirFileLimit'])) { |
|
167 | + echo ' |
|
164 | 168 | <dt>', $txt['attachment_transfer_empty'], '</dt> |
165 | 169 | <dd><input type="checkbox" name="empty_it"', $context['checked'] ? ' checked' : '', '></dd>'; |
170 | + } |
|
166 | 171 | echo ' |
167 | 172 | </dl> |
168 | 173 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -238,10 +243,11 @@ discard block |
||
238 | 243 | // Loop through each error reporting the status |
239 | 244 | foreach ($context['repair_errors'] as $error => $number) |
240 | 245 | { |
241 | - if (!empty($number)) |
|
242 | - echo ' |
|
246 | + if (!empty($number)) { |
|
247 | + echo ' |
|
243 | 248 | <input type="checkbox" name="to_fix[]" id="', $error, '" value="', $error, '"> |
244 | 249 | <label for="', $error, '">', sprintf($txt['attach_repair_' . $error], $number), '</label><br>'; |
250 | + } |
|
245 | 251 | } |
246 | 252 | |
247 | 253 | echo ' <br> |
@@ -416,8 +416,8 @@ discard block |
||
416 | 416 | </div> |
417 | 417 | <div class="progressBar" role="progressBar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0"><span></span></div> |
418 | 418 | <div class="attach-ui"> |
419 | - <a data-dz-remove class="button_submit cancel">', $txt['modify_cancel'] ,'</a> |
|
420 | - <a class="button_submit upload">', $txt['upload'] ,'</a> |
|
419 | + <a data-dz-remove class="button_submit cancel">', $txt['modify_cancel'], '</a> |
|
420 | + <a class="button_submit upload">', $txt['upload'], '</a> |
|
421 | 421 | </div> |
422 | 422 | </div> |
423 | 423 | </div> |
@@ -435,10 +435,10 @@ discard block |
||
435 | 435 | </dt> |
436 | 436 | <dd class="smalltext fallback"> |
437 | 437 | <div id="attachUpload" class="descbox"> |
438 | - <h5>', $txt['attach_drop_zone'] ,'</h5> |
|
439 | - <a class="button_submit" id="attach-cancelAll">', $txt['attached_cancelAll'] ,'</a> |
|
440 | - <a class="button_submit" id="attach-uploadAll">', $txt['attached_uploadAll'] ,'</a> |
|
441 | - <a class="button_submit fileinput-button">', $txt['attach_add'] ,'</a> |
|
438 | + <h5>', $txt['attach_drop_zone'], '</h5> |
|
439 | + <a class="button_submit" id="attach-cancelAll">', $txt['attached_cancelAll'], '</a> |
|
440 | + <a class="button_submit" id="attach-uploadAll">', $txt['attached_uploadAll'], '</a> |
|
441 | + <a class="button_submit fileinput-button">', $txt['attach_add'], '</a> |
|
442 | 442 | <div id="total-progress" class="progressBar" role="progressBar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0"><span></span></div> |
443 | 443 | <div class="fallback"> |
444 | 444 | <input type="file" multiple="multiple" name="attachment[]" id="attachment1" class="fallback"> (<a href="javascript:void(0);" onclick="cleanFileInput(\'attachment1\');">', $txt['clean_attach'], '</a>) |
@@ -545,7 +545,7 @@ discard block |
||
545 | 545 | // Option to delete an event if user is editing one. |
546 | 546 | if ($context['make_event'] && !$context['event']['new']) |
547 | 547 | echo ' |
548 | - <input type="submit" name="deleteevent" value="', $txt['event_delete'], '" data-confirm="', $txt['event_delete_confirm'] ,'" class="button_submit you_sure">'; |
|
548 | + <input type="submit" name="deleteevent" value="', $txt['event_delete'], '" data-confirm="', $txt['event_delete_confirm'], '" class="button_submit you_sure">'; |
|
549 | 549 | |
550 | 550 | echo ' |
551 | 551 | </span> |
@@ -799,7 +799,7 @@ discard block |
||
799 | 799 | });'; |
800 | 800 | |
801 | 801 | echo ' |
802 | - var oEditorID = "', $context['post_box_name'] ,'"; |
|
802 | + var oEditorID = "', $context['post_box_name'], '"; |
|
803 | 803 | var oEditorObject = oEditorHandle_', $context['post_box_name'], '; |
804 | 804 | </script>'; |
805 | 805 | |
@@ -831,7 +831,7 @@ discard block |
||
831 | 831 | { |
832 | 832 | echo ' |
833 | 833 | <ul class="quickbuttons" id="msg_', $post['id'], '_quote"> |
834 | - <li style="display:none;" id="quoteSelected_', $post['id'], '" data-msgid="', $post['id'], '"><a href="javascript:void(0)"><span class="generic_icons quote_selected"></span>', $txt['quote_selected_action'] ,'</a></li> |
|
834 | + <li style="display:none;" id="quoteSelected_', $post['id'], '" data-msgid="', $post['id'], '"><a href="javascript:void(0)"><span class="generic_icons quote_selected"></span>', $txt['quote_selected_action'], '</a></li> |
|
835 | 835 | <li id="post_modify"><a href="#postmodify" onclick="return insertQuoteFast(', $post['id'], ');"><span class="generic_icons quote"></span>', $txt['quote'], '</a></li> |
836 | 836 | </ul>'; |
837 | 837 | } |
@@ -918,7 +918,7 @@ discard block |
||
918 | 918 | <head> |
919 | 919 | <meta charset="', $context['character_set'], '"> |
920 | 920 | <title>', $txt['spell_check'], '</title> |
921 | - <link rel="stylesheet" href="', $settings['theme_url'], '/css/index', $context['theme_variant'], '.css', $modSettings['browser_cache'] ,'"> |
|
921 | + <link rel="stylesheet" href="', $settings['theme_url'], '/css/index', $context['theme_variant'], '.css', $modSettings['browser_cache'], '"> |
|
922 | 922 | <style> |
923 | 923 | body, td |
924 | 924 | { |
@@ -951,8 +951,8 @@ discard block |
||
951 | 951 | var spell_formname = window.opener.spell_formname; |
952 | 952 | var spell_fieldname = window.opener.spell_fieldname; |
953 | 953 | </script> |
954 | - <script src="', $settings['default_theme_url'], '/scripts/spellcheck.js', $modSettings['browser_cache'] ,'"></script> |
|
955 | - <script src="', $settings['default_theme_url'], '/scripts/script.js', $modSettings['browser_cache'] ,'"></script> |
|
954 | + <script src="', $settings['default_theme_url'], '/scripts/spellcheck.js', $modSettings['browser_cache'], '"></script> |
|
955 | + <script src="', $settings['default_theme_url'], '/scripts/script.js', $modSettings['browser_cache'], '"></script> |
|
956 | 956 | <script> |
957 | 957 | ', $context['spell_js'], ' |
958 | 958 | </script> |
@@ -994,7 +994,7 @@ discard block |
||
994 | 994 | <head> |
995 | 995 | <meta charset="', $context['character_set'], '"> |
996 | 996 | <title>', $txt['retrieving_quote'], '</title> |
997 | - <script src="', $settings['default_theme_url'], '/scripts/script.js', $modSettings['browser_cache'] ,'"></script> |
|
997 | + <script src="', $settings['default_theme_url'], '/scripts/script.js', $modSettings['browser_cache'], '"></script> |
|
998 | 998 | </head> |
999 | 999 | <body> |
1000 | 1000 | ', $txt['retrieving_quote'], ' |
@@ -22,22 +22,24 @@ discard block |
||
22 | 22 | <script>'; |
23 | 23 | |
24 | 24 | // When using Go Back due to fatal_error, allow the form to be re-submitted with changes. |
25 | - if (isBrowser('is_firefox')) |
|
26 | - echo ' |
|
25 | + if (isBrowser('is_firefox')) { |
|
26 | + echo ' |
|
27 | 27 | window.addEventListener("pageshow", reActivate, false);'; |
28 | + } |
|
28 | 29 | |
29 | 30 | // Start with message icons - and any missing from this theme. |
30 | 31 | echo ' |
31 | 32 | var icon_urls = {'; |
32 | - foreach ($context['icons'] as $icon) |
|
33 | - echo ' |
|
33 | + foreach ($context['icons'] as $icon) { |
|
34 | + echo ' |
|
34 | 35 | \'', $icon['value'], '\': \'', $icon['url'], '\'', $icon['is_last'] ? '' : ','; |
36 | + } |
|
35 | 37 | echo ' |
36 | 38 | };'; |
37 | 39 | |
38 | 40 | // If this is a poll - use some javascript to ensure the user doesn't create a poll with illegal option combinations. |
39 | - if ($context['make_poll']) |
|
40 | - echo ' |
|
41 | + if ($context['make_poll']) { |
|
42 | + echo ' |
|
41 | 43 | var pollOptionNum = 0, pollTabIndex; |
42 | 44 | var pollOptionId = ', $context['last_choice_id'], '; |
43 | 45 | function addPollOption() |
@@ -56,11 +58,13 @@ discard block |
||
56 | 58 | |
57 | 59 | setOuterHTML(document.getElementById(\'pollMoreOptions\'), ', JavaScriptEscape('<dt><label for="options-'), ' + pollOptionId + ', JavaScriptEscape('">' . $txt['option'] . ' '), ' + pollOptionNum + ', JavaScriptEscape('</label>:</dt><dd><input type="text" name="options['), ' + pollOptionId + ', JavaScriptEscape(']" id="options-'), ' + pollOptionId + ', JavaScriptEscape('" value="" size="80" maxlength="255" tabindex="'), ' + pollTabIndex + ', JavaScriptEscape('"></dd><p id="pollMoreOptions"></p>'), '); |
58 | 60 | }'; |
61 | + } |
|
59 | 62 | |
60 | 63 | // If we are making a calendar event we want to ensure we show the current days in a month etc... this is done here. |
61 | - if ($context['make_event']) |
|
62 | - echo ' |
|
64 | + if ($context['make_event']) { |
|
65 | + echo ' |
|
63 | 66 | var monthLength = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];'; |
67 | + } |
|
64 | 68 | |
65 | 69 | // End of the javascript, start the form and display the link tree. |
66 | 70 | echo ' |
@@ -80,9 +84,10 @@ discard block |
||
80 | 84 | </div> |
81 | 85 | </div><br>'; |
82 | 86 | |
83 | - if ($context['make_event'] && (!$context['event']['new'] || !empty($context['current_board']))) |
|
84 | - echo ' |
|
87 | + if ($context['make_event'] && (!$context['event']['new'] || !empty($context['current_board']))) { |
|
88 | + echo ' |
|
85 | 89 | <input type="hidden" name="eventid" value="', $context['event']['id'], '">'; |
90 | + } |
|
86 | 91 | |
87 | 92 | // Start the main table. |
88 | 93 | echo ' |
@@ -117,18 +122,20 @@ discard block |
||
117 | 122 | } |
118 | 123 | |
119 | 124 | // If it's locked, show a message to warn the replier. |
120 | - if (!empty($context['locked'])) |
|
121 | - echo ' |
|
125 | + if (!empty($context['locked'])) { |
|
126 | + echo ' |
|
122 | 127 | <p class="errorbox"> |
123 | 128 | ', $txt['topic_locked_no_reply'], ' |
124 | 129 | </p>'; |
130 | + } |
|
125 | 131 | |
126 | - if (!empty($modSettings['drafts_post_enabled'])) |
|
127 | - echo ' |
|
132 | + if (!empty($modSettings['drafts_post_enabled'])) { |
|
133 | + echo ' |
|
128 | 134 | <div id="draft_section" class="infobox"', isset($context['draft_saved']) ? '' : ' style="display: none;"', '>', |
129 | 135 | sprintf($txt['draft_saved'], $scripturl . '?action=profile;u=' . $context['user']['id'] . ';area=showdrafts'), ' |
130 | 136 | ', (!empty($modSettings['drafts_keep_days']) ? ' <strong>' . sprintf($txt['draft_save_warning'], $modSettings['drafts_keep_days']) . '</strong>' : ''), ' |
131 | 137 | </div>'; |
138 | + } |
|
132 | 139 | |
133 | 140 | // The post header... important stuff |
134 | 141 | echo ' |
@@ -180,9 +187,10 @@ discard block |
||
180 | 187 | { |
181 | 188 | echo ' |
182 | 189 | <optgroup label="', $category['name'], '">'; |
183 | - foreach ($category['boards'] as $board) |
|
184 | - echo ' |
|
190 | + foreach ($category['boards'] as $board) { |
|
191 | + echo ' |
|
185 | 192 | <option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level'] - 1) . '=>' : '', ' ', $board['name'], ' </option>'; |
193 | + } |
|
186 | 194 | echo ' |
187 | 195 | </optgroup>'; |
188 | 196 | } |
@@ -218,9 +226,10 @@ discard block |
||
218 | 226 | <span class="label">', $txt['calendar_timezone'], '</span> |
219 | 227 | <select name="tz" id="tz"', !empty($context['event']['allday']) ? ' disabled' : '', '>'; |
220 | 228 | |
221 | - foreach ($context['all_timezones'] as $tz => $tzname) |
|
222 | - echo ' |
|
229 | + foreach ($context['all_timezones'] as $tz => $tzname) { |
|
230 | + echo ' |
|
223 | 231 | <option value="', $tz, '"', $tz == $context['event']['tz'] ? ' selected' : '', '>', $tzname, '</option>'; |
232 | + } |
|
224 | 233 | |
225 | 234 | echo ' |
226 | 235 | </select> |
@@ -286,14 +295,15 @@ discard block |
||
286 | 295 | <input type="checkbox" id="poll_change_vote" name="poll_change_vote"', !empty($context['poll']['change_vote']) ? ' checked' : '', '> |
287 | 296 | </dd>'; |
288 | 297 | |
289 | - if ($context['poll_options']['guest_vote_enabled']) |
|
290 | - echo ' |
|
298 | + if ($context['poll_options']['guest_vote_enabled']) { |
|
299 | + echo ' |
|
291 | 300 | <dt> |
292 | 301 | <label for="poll_guest_vote">', $txt['poll_guest_vote'], ':</label> |
293 | 302 | </dt> |
294 | 303 | <dd> |
295 | 304 | <input type="checkbox" id="poll_guest_vote" name="poll_guest_vote"', !empty($context['poll_options']['guest_vote']) ? ' checked' : '', '> |
296 | 305 | </dd>'; |
306 | + } |
|
297 | 307 | |
298 | 308 | echo ' |
299 | 309 | <dt> |
@@ -314,8 +324,8 @@ discard block |
||
314 | 324 | ', template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message'); |
315 | 325 | |
316 | 326 | // If we're editing and displaying edit details, show a box where they can say why |
317 | - if (isset($context['editing']) && $modSettings['show_modify']) |
|
318 | - echo ' |
|
327 | + if (isset($context['editing']) && $modSettings['show_modify']) { |
|
328 | + echo ' |
|
319 | 329 | <dl> |
320 | 330 | <dt class="clear"> |
321 | 331 | <span id="caption_edit_reason">', $txt['reason_for_edit'], ':</span> |
@@ -324,20 +334,23 @@ discard block |
||
324 | 334 | <input type="text" name="modify_reason"', isset($context['last_modified_reason']) ? ' value="' . $context['last_modified_reason'] . '"' : '', ' tabindex="', $context['tabindex']++, '" size="80" maxlength="80"> |
325 | 335 | </dd> |
326 | 336 | </dl>'; |
337 | + } |
|
327 | 338 | |
328 | 339 | // If this message has been edited in the past - display when it was. |
329 | - if (isset($context['last_modified'])) |
|
330 | - echo ' |
|
340 | + if (isset($context['last_modified'])) { |
|
341 | + echo ' |
|
331 | 342 | <div class="padding smalltext"> |
332 | 343 | ', $context['last_modified_text'], ' |
333 | 344 | </div>'; |
345 | + } |
|
334 | 346 | |
335 | 347 | // If the admin has enabled the hiding of the additional options - show a link and image for it. |
336 | - if (!empty($modSettings['additional_options_collapsable'])) |
|
337 | - echo ' |
|
348 | + if (!empty($modSettings['additional_options_collapsable'])) { |
|
349 | + echo ' |
|
338 | 350 | <div id="postAdditionalOptionsHeader"> |
339 | 351 | <strong><a href="#" id="postMoreExpandLink"> ', $context['can_post_attachment'] ? $txt['post_additionalopt_attach'] : $txt['post_additionalopt'], '</a></strong> |
340 | 352 | </div>'; |
353 | + } |
|
341 | 354 | |
342 | 355 | echo ' |
343 | 356 | <div id="postAdditionalOptions">'; |
@@ -369,19 +382,21 @@ discard block |
||
369 | 382 | <input type="hidden" name="attach_del[]" value="0"> |
370 | 383 | ', $txt['uncheck_unwatchd_attach'], ': |
371 | 384 | </dd>'; |
372 | - foreach ($context['current_attachments'] as $attachment) |
|
373 | - echo ' |
|
385 | + foreach ($context['current_attachments'] as $attachment) { |
|
386 | + echo ' |
|
374 | 387 | <dd class="smalltext"> |
375 | 388 | <label for="attachment_', $attachment['attachID'], '"><input type="checkbox" id="attachment_', $attachment['attachID'], '" name="attach_del[]" value="', $attachment['attachID'], '"', empty($attachment['unchecked']) ? ' checked' : '', '> ', $attachment['name'], (empty($attachment['approved']) ? ' (' . $txt['awaiting_approval'] . ')' : ''), |
376 | 389 | !empty($modSettings['attachmentPostLimit']) || !empty($modSettings['attachmentSizeLimit']) ? sprintf($txt['attach_kb'], comma_format(round(max($attachment['size'], 1028) / 1028), 0)) : '', '</label> |
377 | 390 | </dd>'; |
391 | + } |
|
378 | 392 | |
379 | 393 | echo ' |
380 | 394 | </dl>'; |
381 | 395 | |
382 | - if (!empty($context['files_in_session_warning'])) |
|
383 | - echo ' |
|
396 | + if (!empty($context['files_in_session_warning'])) { |
|
397 | + echo ' |
|
384 | 398 | <div class="smalltext">', $context['files_in_session_warning'], '</div>'; |
399 | + } |
|
385 | 400 | } |
386 | 401 | |
387 | 402 | // Is the user allowed to post any additional ones? If so give them the boxes to do it! |
@@ -445,8 +460,8 @@ discard block |
||
445 | 460 | ', empty($modSettings['attachmentSizeLimit']) ? '' : ('<input type="hidden" name="MAX_FILE_SIZE" value="' . $modSettings['attachmentSizeLimit'] * 1028 . '">'); |
446 | 461 | |
447 | 462 | // Show more boxes if they aren't approaching that limit. |
448 | - if ($context['num_allowed_attachments'] > 1) |
|
449 | - echo ' |
|
463 | + if ($context['num_allowed_attachments'] > 1) { |
|
464 | + echo ' |
|
450 | 465 | <script> |
451 | 466 | var allowed_attachments = ', $context['num_allowed_attachments'], '; |
452 | 467 | var current_attachment = 1; |
@@ -467,9 +482,10 @@ discard block |
||
467 | 482 | </div> |
468 | 483 | </div> |
469 | 484 | </dd>'; |
470 | - else |
|
471 | - echo ' |
|
485 | + } else { |
|
486 | + echo ' |
|
472 | 487 | </dd>'; |
488 | + } |
|
473 | 489 | |
474 | 490 | // Add any template changes for an alternative upload system here. |
475 | 491 | call_integration_hook('integrate_upload_template'); |
@@ -478,21 +494,25 @@ discard block |
||
478 | 494 | <dd class="smalltext">'; |
479 | 495 | |
480 | 496 | // Show some useful information such as allowed extensions, maximum size and amount of attachments allowed. |
481 | - if (!empty($modSettings['attachmentCheckExtensions'])) |
|
482 | - echo ' |
|
497 | + if (!empty($modSettings['attachmentCheckExtensions'])) { |
|
498 | + echo ' |
|
483 | 499 | ', $txt['allowed_types'], ': ', $context['allowed_extensions'], '<br>'; |
500 | + } |
|
484 | 501 | |
485 | - if (!empty($context['attachment_restrictions'])) |
|
486 | - echo ' |
|
502 | + if (!empty($context['attachment_restrictions'])) { |
|
503 | + echo ' |
|
487 | 504 | ', $txt['attach_restrictions'], ' ', implode(', ', $context['attachment_restrictions']), '<br>'; |
505 | + } |
|
488 | 506 | |
489 | - if ($context['num_allowed_attachments'] == 0) |
|
490 | - echo ' |
|
507 | + if ($context['num_allowed_attachments'] == 0) { |
|
508 | + echo ' |
|
491 | 509 | ', $txt['attach_limit_nag'], '<br>'; |
510 | + } |
|
492 | 511 | |
493 | - if (!$context['can_post_attachment_unapproved']) |
|
494 | - echo ' |
|
512 | + if (!$context['can_post_attachment_unapproved']) { |
|
513 | + echo ' |
|
495 | 514 | <span class="alert">', $txt['attachment_requires_approval'], '</span>', '<br>'; |
515 | + } |
|
496 | 516 | |
497 | 517 | echo ' |
498 | 518 | </dd> |
@@ -515,10 +535,11 @@ discard block |
||
515 | 535 | <dt><strong>', $txt['subject'], '</strong></dt> |
516 | 536 | <dd><strong>', $txt['draft_saved_on'], '</strong></dd>'; |
517 | 537 | |
518 | - foreach ($context['drafts'] as $draft) |
|
519 | - echo ' |
|
538 | + foreach ($context['drafts'] as $draft) { |
|
539 | + echo ' |
|
520 | 540 | <dt>', $draft['link'], '</dt> |
521 | 541 | <dd>', $draft['poster_time'], '</dd>'; |
542 | + } |
|
522 | 543 | echo ' |
523 | 544 | </dl> |
524 | 545 | </div>'; |
@@ -543,9 +564,10 @@ discard block |
||
543 | 564 | ', template_control_richedit_buttons($context['post_box_name']); |
544 | 565 | |
545 | 566 | // Option to delete an event if user is editing one. |
546 | - if ($context['make_event'] && !$context['event']['new']) |
|
547 | - echo ' |
|
567 | + if ($context['make_event'] && !$context['event']['new']) { |
|
568 | + echo ' |
|
548 | 569 | <input type="submit" name="deleteevent" value="', $txt['event_delete'], '" data-confirm="', $txt['event_delete_confirm'] ,'" class="button_submit you_sure">'; |
570 | + } |
|
549 | 571 | |
550 | 572 | echo ' |
551 | 573 | </span> |
@@ -554,9 +576,10 @@ discard block |
||
554 | 576 | <br class="clear">'; |
555 | 577 | |
556 | 578 | // Assuming this isn't a new topic pass across the last message id. |
557 | - if (isset($context['topic_last_message'])) |
|
558 | - echo ' |
|
579 | + if (isset($context['topic_last_message'])) { |
|
580 | + echo ' |
|
559 | 581 | <input type="hidden" name="last_msg" value="', $context['topic_last_message'], '">'; |
582 | + } |
|
560 | 583 | |
561 | 584 | echo ' |
562 | 585 | <input type="hidden" name="additional_options" id="additional_options" value="', $context['show_additional_options'] ? '1' : '0', '"> |
@@ -698,9 +721,10 @@ discard block |
||
698 | 721 | |
699 | 722 | newPostsHTML += \'<div class="windowbg\' + (++reply_counter % 2 == 0 ? \'2\' : \'\') + \'"><div id="msg\' + newPosts[i].getAttribute("id") + \'"><div class="floatleft"><h5>', $txt['posted_by'], ': \' + newPosts[i].getElementsByTagName("poster")[0].firstChild.nodeValue + \'</h5><span class="smalltext">« <strong>', $txt['on'], ':</strong> \' + newPosts[i].getElementsByTagName("time")[0].firstChild.nodeValue + \' »</span> <span class="new_posts" id="image_new_\' + newPosts[i].getAttribute("id") + \'">', $txt['new'], '</span></div>\';'; |
700 | 723 | |
701 | - if ($context['can_quote']) |
|
702 | - echo ' |
|
724 | + if ($context['can_quote']) { |
|
725 | + echo ' |
|
703 | 726 | newPostsHTML += \'<ul class="quickbuttons" id="msg_\' + newPosts[i].getAttribute("id") + \'_quote"><li><a href="#postmodify" onclick="return insertQuoteFast(\\\'\' + newPosts[i].getAttribute("id") + \'\\\');" class="quote_button"><span>', $txt['quote'], '</span><\' + \'/a></li></ul>\';'; |
727 | + } |
|
704 | 728 | |
705 | 729 | echo ' |
706 | 730 | newPostsHTML += \'<br class="clear">\'; |
@@ -743,8 +767,8 @@ discard block |
||
743 | 767 | }'; |
744 | 768 | |
745 | 769 | // Code for showing and hiding additional options. |
746 | - if (!empty($modSettings['additional_options_collapsable'])) |
|
747 | - echo ' |
|
770 | + if (!empty($modSettings['additional_options_collapsable'])) { |
|
771 | + echo ' |
|
748 | 772 | var oSwapAdditionalOptions = new smc_Toggle({ |
749 | 773 | bToggleEnabled: true, |
750 | 774 | bCurrentlyCollapsed: ', $context['show_additional_options'] ? 'false' : 'true', ', |
@@ -772,10 +796,11 @@ discard block |
||
772 | 796 | } |
773 | 797 | ] |
774 | 798 | });'; |
799 | + } |
|
775 | 800 | |
776 | 801 | // Code for showing and hiding drafts |
777 | - if (!empty($context['drafts'])) |
|
778 | - echo ' |
|
802 | + if (!empty($context['drafts'])) { |
|
803 | + echo ' |
|
779 | 804 | var oSwapDraftOptions = new smc_Toggle({ |
780 | 805 | bToggleEnabled: true, |
781 | 806 | bCurrentlyCollapsed: true, |
@@ -797,6 +822,7 @@ discard block |
||
797 | 822 | } |
798 | 823 | ] |
799 | 824 | });'; |
825 | + } |
|
800 | 826 | |
801 | 827 | echo ' |
802 | 828 | var oEditorID = "', $context['post_box_name'] ,'"; |
@@ -817,8 +843,9 @@ discard block |
||
817 | 843 | foreach ($context['previous_posts'] as $post) |
818 | 844 | { |
819 | 845 | $ignoring = false; |
820 | - if (!empty($post['is_ignored'])) |
|
821 | - $ignored_posts[] = $ignoring = $post['id']; |
|
846 | + if (!empty($post['is_ignored'])) { |
|
847 | + $ignored_posts[] = $ignoring = $post['id']; |
|
848 | + } |
|
822 | 849 | |
823 | 850 | echo ' |
824 | 851 | <div class="windowbg"> |
@@ -1001,10 +1028,10 @@ discard block |
||
1001 | 1028 | <div id="temporary_posting_area" style="display: none;"></div> |
1002 | 1029 | <script>'; |
1003 | 1030 | |
1004 | - if ($context['close_window']) |
|
1005 | - echo ' |
|
1031 | + if ($context['close_window']) { |
|
1032 | + echo ' |
|
1006 | 1033 | window.close();'; |
1007 | - else |
|
1034 | + } else |
|
1008 | 1035 | { |
1009 | 1036 | // Lucky for us, Internet Explorer has an "innerText" feature which basically converts entities <--> text. Use it if possible ;). |
1010 | 1037 | echo ' |
@@ -1058,11 +1085,12 @@ discard block |
||
1058 | 1085 | </p> |
1059 | 1086 | <ul>'; |
1060 | 1087 | |
1061 | - foreach ($context['groups'] as $group) |
|
1062 | - echo ' |
|
1088 | + foreach ($context['groups'] as $group) { |
|
1089 | + echo ' |
|
1063 | 1090 | <li> |
1064 | 1091 | <label for="who_', $group['id'], '"><input type="checkbox" name="who[', $group['id'], ']" id="who_', $group['id'], '" value="', $group['id'], '" checked> ', $group['name'], '</label> <em>(', $group['member_count'], ')</em> |
1065 | 1092 | </li>'; |
1093 | + } |
|
1066 | 1094 | |
1067 | 1095 | echo ' |
1068 | 1096 | <li> |
@@ -24,11 +24,12 @@ discard block |
||
24 | 24 | <h3 class="catbg">', $txt['paid_' . $context['action_type'] . '_subscription'], '</h3> |
25 | 25 | </div>'; |
26 | 26 | |
27 | - if (!empty($context['disable_groups'])) |
|
28 | - echo ' |
|
27 | + if (!empty($context['disable_groups'])) { |
|
28 | + echo ' |
|
29 | 29 | <div class="information"> |
30 | 30 | <span class="alert">', $txt['paid_mod_edit_note'], '</span> |
31 | 31 | </div>'; |
32 | + } |
|
32 | 33 | |
33 | 34 | echo ' |
34 | 35 | <div class="windowbg2"> |
@@ -68,9 +69,10 @@ discard block |
||
68 | 69 | <option value="0"', $context['sub']['prim_group'] == 0 ? ' selected' : '', '>', $txt['paid_mod_no_group'], '</option>'; |
69 | 70 | |
70 | 71 | // Put each group into the box. |
71 | - foreach ($context['groups'] as $id => $name) |
|
72 | - echo ' |
|
72 | + foreach ($context['groups'] as $id => $name) { |
|
73 | + echo ' |
|
73 | 74 | <option value="', $id, '"', $context['sub']['prim_group'] == $id ? ' selected' : '', '>', $name, '</option>'; |
75 | + } |
|
74 | 76 | |
75 | 77 | echo ' |
76 | 78 | </select> |
@@ -81,9 +83,10 @@ discard block |
||
81 | 83 | <dd>'; |
82 | 84 | |
83 | 85 | // Put a checkbox in for each group |
84 | - foreach ($context['groups'] as $id => $name) |
|
85 | - echo ' |
|
86 | + foreach ($context['groups'] as $id => $name) { |
|
87 | + echo ' |
|
86 | 88 | <label for="addgroup_', $id, '"><input type="checkbox" id="addgroup_', $id, '" name="addgroup[', $id, ']"', in_array($id, $context['sub']['add_groups']) ? ' checked' : '', !empty($context['disable_groups']) ? ' disabled' : '', '> <span class="smalltext">', $name, '</span></label><br>'; |
89 | + } |
|
87 | 90 | |
88 | 91 | echo ' |
89 | 92 | </dd> |
@@ -135,8 +138,8 @@ discard block |
||
135 | 138 | <fieldset>'; |
136 | 139 | |
137 | 140 | //!! Removed until implemented |
138 | - if (!empty($sdflsdhglsdjgs)) |
|
139 | - echo ' |
|
141 | + if (!empty($sdflsdhglsdjgs)) { |
|
142 | + echo ' |
|
140 | 143 | <dl class="settings"> |
141 | 144 | <dt> |
142 | 145 | <label for="allow_partial_check">', $txt['paid_mod_allow_partial'], '</label>:<br><span class="smalltext">', $txt['paid_mod_allow_partial_desc'], '</span> |
@@ -145,6 +148,7 @@ discard block |
||
145 | 148 | <input type="checkbox" name="allow_partial" id="allow_partial_check"', empty($context['sub']['allow_partial']) ? '' : ' checked', '> |
146 | 149 | </dd> |
147 | 150 | </dl>'; |
151 | + } |
|
148 | 152 | |
149 | 153 | echo ' |
150 | 154 | <div class="information"> |
@@ -245,8 +249,8 @@ discard block |
||
245 | 249 | <dl class="settings">'; |
246 | 250 | |
247 | 251 | // Do we need a username? |
248 | - if ($context['action_type'] == 'add') |
|
249 | - echo ' |
|
252 | + if ($context['action_type'] == 'add') { |
|
253 | + echo ' |
|
250 | 254 | |
251 | 255 | <dt> |
252 | 256 | <strong>', $txt['paid_username'], ':</strong><br> |
@@ -255,6 +259,7 @@ discard block |
||
255 | 259 | <dd> |
256 | 260 | <input type="text" name="name" id="name_control" value="', $context['sub']['username'], '" size="30"> |
257 | 261 | </dd>'; |
262 | + } |
|
258 | 263 | |
259 | 264 | echo ' |
260 | 265 | <dt> |
@@ -272,9 +277,10 @@ discard block |
||
272 | 277 | <select name="year" id="year" onchange="generateDays();">'; |
273 | 278 | |
274 | 279 | // Show a list of all the years we allow... |
275 | - for ($year = 2005; $year <= 2030; $year++) |
|
276 | - echo ' |
|
280 | + for ($year = 2005; $year <= 2030; $year++) { |
|
281 | + echo ' |
|
277 | 282 | <option value="', $year, '"', $year == $context['sub']['start']['year'] ? ' selected' : '', '>', $year, '</option>'; |
283 | + } |
|
278 | 284 | |
279 | 285 | echo ' |
280 | 286 | </select> |
@@ -282,9 +288,10 @@ discard block |
||
282 | 288 | <select name="month" id="month" onchange="generateDays();">'; |
283 | 289 | |
284 | 290 | // There are 12 months per year - ensure that they all get listed. |
285 | - for ($month = 1; $month <= 12; $month++) |
|
286 | - echo ' |
|
291 | + for ($month = 1; $month <= 12; $month++) { |
|
292 | + echo ' |
|
287 | 293 | <option value="', $month, '"', $month == $context['sub']['start']['month'] ? ' selected' : '', '>', $txt['months'][$month], '</option>'; |
294 | + } |
|
288 | 295 | |
289 | 296 | echo ' |
290 | 297 | </select> |
@@ -292,9 +299,10 @@ discard block |
||
292 | 299 | <select name="day" id="day">'; |
293 | 300 | |
294 | 301 | // This prints out all the days in the current month - this changes dynamically as we switch months. |
295 | - for ($day = 1; $day <= $context['sub']['start']['last_day']; $day++) |
|
296 | - echo ' |
|
302 | + for ($day = 1; $day <= $context['sub']['start']['last_day']; $day++) { |
|
303 | + echo ' |
|
297 | 304 | <option value="', $day, '"', $day == $context['sub']['start']['day'] ? ' selected' : '', '>', $day, '</option>'; |
305 | + } |
|
298 | 306 | |
299 | 307 | echo ' |
300 | 308 | </select> |
@@ -306,9 +314,10 @@ discard block |
||
306 | 314 | <select name="yearend" id="yearend" onchange="generateDays(\'end\');">'; |
307 | 315 | |
308 | 316 | // Show a list of all the years we allow... |
309 | - for ($year = 2005; $year <= 2030; $year++) |
|
310 | - echo ' |
|
317 | + for ($year = 2005; $year <= 2030; $year++) { |
|
318 | + echo ' |
|
311 | 319 | <option value="', $year, '"', $year == $context['sub']['end']['year'] ? ' selected' : '', '>', $year, '</option>'; |
320 | + } |
|
312 | 321 | |
313 | 322 | echo ' |
314 | 323 | </select> |
@@ -316,9 +325,10 @@ discard block |
||
316 | 325 | <select name="monthend" id="monthend" onchange="generateDays(\'end\');">'; |
317 | 326 | |
318 | 327 | // There are 12 months per year - ensure that they all get listed. |
319 | - for ($month = 1; $month <= 12; $month++) |
|
320 | - echo ' |
|
328 | + for ($month = 1; $month <= 12; $month++) { |
|
329 | + echo ' |
|
321 | 330 | <option value="', $month, '"', $month == $context['sub']['end']['month'] ? ' selected' : '', '>', $txt['months'][$month], '</option>'; |
331 | + } |
|
322 | 332 | |
323 | 333 | echo ' |
324 | 334 | </select> |
@@ -326,9 +336,10 @@ discard block |
||
326 | 336 | <select name="dayend" id="dayend">'; |
327 | 337 | |
328 | 338 | // This prints out all the days in the current month - this changes dynamically as we switch months. |
329 | - for ($day = 1; $day <= $context['sub']['end']['last_day']; $day++) |
|
330 | - echo ' |
|
339 | + for ($day = 1; $day <= $context['sub']['end']['last_day']; $day++) { |
|
340 | + echo ' |
|
331 | 341 | <option value="', $day, '"', $day == $context['sub']['end']['day'] ? ' selected' : '', '>', $day, '</option>'; |
342 | + } |
|
332 | 343 | |
333 | 344 | echo ' |
334 | 345 | </select> |
@@ -410,8 +421,7 @@ discard block |
||
410 | 421 | <div class="information"> |
411 | 422 | ', $txt['paid_subs_none'], ' |
412 | 423 | </div>'; |
413 | - } |
|
414 | - else |
|
424 | + } else |
|
415 | 425 | { |
416 | 426 | echo ' |
417 | 427 | <div class="information"> |
@@ -423,8 +433,9 @@ discard block |
||
423 | 433 | { |
424 | 434 | |
425 | 435 | // Ignore the inactive ones... |
426 | - if (empty($subscription['active'])) |
|
427 | - continue; |
|
436 | + if (empty($subscription['active'])) { |
|
437 | + continue; |
|
438 | + } |
|
428 | 439 | |
429 | 440 | echo ' |
430 | 441 | <div class="cat_bar"> |
@@ -434,9 +445,10 @@ discard block |
||
434 | 445 | <p><strong>', $subscription['name'], '</strong></p> |
435 | 446 | <p class="smalltext">', $subscription['desc'], '</p>'; |
436 | 447 | |
437 | - if (!$subscription['flexible']) |
|
438 | - echo ' |
|
448 | + if (!$subscription['flexible']) { |
|
449 | + echo ' |
|
439 | 450 | <div><strong>', $txt['paid_duration'], ':</strong> ', $subscription['length'], '</div>'; |
451 | + } |
|
440 | 452 | |
441 | 453 | if ($context['user']['is_owner']) |
442 | 454 | { |
@@ -449,24 +461,25 @@ discard block |
||
449 | 461 | <select name="cur[', $subscription['id'], ']">'; |
450 | 462 | |
451 | 463 | // Print out the costs for this one. |
452 | - foreach ($subscription['costs'] as $duration => $value) |
|
453 | - echo ' |
|
464 | + foreach ($subscription['costs'] as $duration => $value) { |
|
465 | + echo ' |
|
454 | 466 | <option value="', $duration, '">', sprintf($modSettings['paid_currency_symbol'], $value), '/', $txt[$duration], '</option>'; |
467 | + } |
|
455 | 468 | |
456 | 469 | echo ' |
457 | 470 | </select>'; |
458 | - } |
|
459 | - else |
|
460 | - echo ' |
|
471 | + } else { |
|
472 | + echo ' |
|
461 | 473 | ', sprintf($modSettings['paid_currency_symbol'], $subscription['costs']['fixed']); |
474 | + } |
|
462 | 475 | |
463 | 476 | echo ' |
464 | 477 | <hr> |
465 | 478 | <input type="submit" name="sub_id[', $subscription['id'], ']" value="', $txt['paid_order'], '" class="button_submit">'; |
466 | - } |
|
467 | - else |
|
468 | - echo ' |
|
479 | + } else { |
|
480 | + echo ' |
|
469 | 481 | <a href="', $scripturl, '?action=admin;area=paidsubscribe;sa=modifyuser;sid=', $subscription['id'], ';uid=', $context['member']['id'], (empty($context['current'][$subscription['id']]) ? '' : ';lid=' . $context['current'][$subscription['id']]['id']), '">', empty($context['current'][$subscription['id']]) ? $txt['paid_admin_add'] : $txt['paid_edit_subscription'], '</a>'; |
482 | + } |
|
470 | 483 | |
471 | 484 | echo ' |
472 | 485 | </div>'; |
@@ -493,19 +506,20 @@ discard block |
||
493 | 506 | </thead> |
494 | 507 | <tbody>'; |
495 | 508 | |
496 | - if (empty($context['current'])) |
|
497 | - echo ' |
|
509 | + if (empty($context['current'])) { |
|
510 | + echo ' |
|
498 | 511 | <tr class="windowbg"> |
499 | 512 | <td colspan="4"> |
500 | 513 | ', $txt['paid_none_yet'], ' |
501 | 514 | </td> |
502 | 515 | </tr>'; |
516 | + } |
|
503 | 517 | |
504 | 518 | foreach ($context['current'] as $sub) |
505 | 519 | { |
506 | 520 | |
507 | - if (!$sub['hide']) |
|
508 | - echo ' |
|
521 | + if (!$sub['hide']) { |
|
522 | + echo ' |
|
509 | 523 | <tr class="windowbg"> |
510 | 524 | <td> |
511 | 525 | ', (allowedTo('admin_forum') ? '<a href="' . $scripturl . '?action=admin;area=paidsubscribe;sa=modifyuser;lid=' . $sub['id'] . '">' . $sub['name'] . '</a>' : $sub['name']), ' |
@@ -517,6 +531,7 @@ discard block |
||
517 | 531 | ', $sub['end'], ' |
518 | 532 | </td> |
519 | 533 | </tr>'; |
534 | + } |
|
520 | 535 | } |
521 | 536 | echo ' |
522 | 537 | </tbody> |
@@ -567,15 +582,17 @@ discard block |
||
567 | 582 | ', $gateway['desc'], '<br> |
568 | 583 | <form action="', $gateway['form'], '" method="post">'; |
569 | 584 | |
570 | - if (!empty($gateway['javascript'])) |
|
571 | - echo ' |
|
585 | + if (!empty($gateway['javascript'])) { |
|
586 | + echo ' |
|
572 | 587 | <script> |
573 | 588 | ', $gateway['javascript'], ' |
574 | 589 | </script>'; |
590 | + } |
|
575 | 591 | |
576 | - foreach ($gateway['hidden'] as $name => $value) |
|
577 | - echo ' |
|
592 | + foreach ($gateway['hidden'] as $name => $value) { |
|
593 | + echo ' |
|
578 | 594 | <input type="hidden" id="', $gateway['id'], '_', $name, '" name="', $name, '" value="', $value, '">'; |
595 | + } |
|
579 | 596 | |
580 | 597 | echo ' |
581 | 598 | <br><input type="submit" value="', $gateway['submit'], '" class="button_submit"> |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | |
232 | 232 | foreach ($message['custom_fields']['above_member'] as $custom) |
233 | 233 | echo ' |
234 | - <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
|
234 | + <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
|
235 | 235 | |
236 | 236 | echo ' |
237 | 237 | </ul> |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | if (!empty($message['custom_fields']['below_avatar'])) |
269 | 269 | foreach ($message['custom_fields']['below_avatar'] as $custom) |
270 | 270 | echo ' |
271 | - <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
|
271 | + <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
|
272 | 272 | |
273 | 273 | if (!$message['member']['is_guest']) |
274 | 274 | echo ' |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | |
311 | 311 | foreach ($message['custom_fields']['icons'] as $custom) |
312 | 312 | echo ' |
313 | - <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
|
313 | + <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
|
314 | 314 | |
315 | 315 | echo ' |
316 | 316 | </ol> |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | if (!empty($message['custom_fields']['standard'])) |
369 | 369 | foreach ($message['custom_fields']['standard'] as $custom) |
370 | 370 | echo ' |
371 | - <li class="custom ', $custom['col_name'] ,'">', $custom['title'], ': ', $custom['value'], '</li>'; |
|
371 | + <li class="custom ', $custom['col_name'], '">', $custom['title'], ': ', $custom['value'], '</li>'; |
|
372 | 372 | |
373 | 373 | // Are we showing the warning status? |
374 | 374 | if ($message['member']['can_see_warning']) |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | if (!empty($message['custom_fields']['bottom_poster'])) |
380 | 380 | foreach ($message['custom_fields']['bottom_poster'] as $custom) |
381 | 381 | echo ' |
382 | - <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
|
382 | + <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
|
383 | 383 | } |
384 | 384 | |
385 | 385 | // Done with the information about the poster... on to the post itself. |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | |
478 | 478 | foreach ($message['custom_fields']['above_signature'] as $custom) |
479 | 479 | echo ' |
480 | - <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
|
480 | + <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
|
481 | 481 | |
482 | 482 | echo ' |
483 | 483 | </ul> |
@@ -498,7 +498,7 @@ discard block |
||
498 | 498 | |
499 | 499 | foreach ($message['custom_fields']['below_signature'] as $custom) |
500 | 500 | echo ' |
501 | - <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
|
501 | + <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
|
502 | 502 | |
503 | 503 | echo ' |
504 | 504 | </ul> |
@@ -630,7 +630,7 @@ discard block |
||
630 | 630 | while ($message = $context['get_pmessage']('subject')) |
631 | 631 | { |
632 | 632 | echo ' |
633 | - <tr class="windowbg', $message['is_unread'] ? ' unread_pm' : '','"> |
|
633 | + <tr class="windowbg', $message['is_unread'] ? ' unread_pm' : '', '"> |
|
634 | 634 | <td class="table_icon"> |
635 | 635 | <script> |
636 | 636 | currentLabels[', $message['id'], '] = {'; |
@@ -902,12 +902,12 @@ discard block |
||
902 | 902 | // You can only reply if they are not a guest... |
903 | 903 | if (!$message['member']['is_guest']) |
904 | 904 | echo ' |
905 | - <a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote;u=', $context['folder'] == 'sent' ? '' : $message['member']['id'], '">', $quote_button , '</a>', $context['menu_separator'], ' |
|
906 | - <a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';u=', $message['member']['id'], '">', $reply_button , '</a> ', $context['menu_separator']; |
|
905 | + <a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote;u=', $context['folder'] == 'sent' ? '' : $message['member']['id'], '">', $quote_button, '</a>', $context['menu_separator'], ' |
|
906 | + <a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';u=', $message['member']['id'], '">', $reply_button, '</a> ', $context['menu_separator']; |
|
907 | 907 | // This is for "forwarding" - even if the member is gone. |
908 | 908 | else |
909 | 909 | echo ' |
910 | - <a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote">', $quote_button , '</a>', $context['menu_separator']; |
|
910 | + <a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote">', $quote_button, '</a>', $context['menu_separator']; |
|
911 | 911 | } |
912 | 912 | |
913 | 913 | echo ' |
@@ -1007,7 +1007,7 @@ discard block |
||
1007 | 1007 | <div class="', empty($context['error_type']) || $context['error_type'] != 'serious' ? 'noticebox' : 'errorbox', '"', empty($context['post_error']['messages']) ? ' style="display: none"' : '', ' id="errors"> |
1008 | 1008 | <dl> |
1009 | 1009 | <dt> |
1010 | - <strong id="error_serious">', $txt['error_while_submitting'] , '</strong> |
|
1010 | + <strong id="error_serious">', $txt['error_while_submitting'], '</strong> |
|
1011 | 1011 | </dt> |
1012 | 1012 | <dd class="error" id="error_list"> |
1013 | 1013 | ', empty($context['post_error']['messages']) ? '' : implode('<br>', $context['post_error']['messages']), ' |
@@ -1063,7 +1063,7 @@ discard block |
||
1063 | 1063 | <span', (isset($context['post_error']['no_subject']) ? ' class="error"' : ''), ' id="caption_subject">', $txt['subject'], ':</span> |
1064 | 1064 | </dt> |
1065 | 1065 | <dd id="pm_subject"> |
1066 | - <input type="text" name="subject" value="', $context['subject'], '" tabindex="', $context['tabindex']++, '" size="80" maxlength="80"',isset($context['post_error']['no_subject']) ? ' class="error"' : '', '/> |
|
1066 | + <input type="text" name="subject" value="', $context['subject'], '" tabindex="', $context['tabindex']++, '" size="80" maxlength="80"', isset($context['post_error']['no_subject']) ? ' class="error"' : '', '/> |
|
1067 | 1067 | </dd> |
1068 | 1068 | </dl><hr>'; |
1069 | 1069 | |
@@ -1426,7 +1426,7 @@ discard block |
||
1426 | 1426 | echo ' |
1427 | 1427 | <div class="padding"> |
1428 | 1428 | <input type="submit" name="save" value="', $txt['save'], '" class="button_submit"> |
1429 | - <input type="submit" name="delete" value="', $txt['quickmod_delete_selected'], '" data-confirm="', $txt['pm_labels_delete'] ,'" class="button_submit you_sure"> |
|
1429 | + <input type="submit" name="delete" value="', $txt['quickmod_delete_selected'], '" data-confirm="', $txt['pm_labels_delete'], '" class="button_submit you_sure"> |
|
1430 | 1430 | </div>'; |
1431 | 1431 | |
1432 | 1432 | echo ' |
@@ -1590,7 +1590,7 @@ discard block |
||
1590 | 1590 | if (!empty($context['rules'])) |
1591 | 1591 | echo ' |
1592 | 1592 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
1593 | - <input type="submit" name="delselected" value="', $txt['pm_delete_selected_rule'], '" data-confirm="', $txt['pm_js_delete_rule_confirm'] ,'" class="button_submit smalltext you_sure">'; |
|
1593 | + <input type="submit" name="delselected" value="', $txt['pm_delete_selected_rule'], '" data-confirm="', $txt['pm_js_delete_rule_confirm'], '" class="button_submit smalltext you_sure">'; |
|
1594 | 1594 | |
1595 | 1595 | echo ' |
1596 | 1596 | </div> |
@@ -1831,9 +1831,9 @@ discard block |
||
1831 | 1831 | |
1832 | 1832 | echo ' |
1833 | 1833 | <select name="acttype[', $k, ']" id="acttype', $k, '" onchange="updateActionDef(', $k, '); rebuildRuleDesc();"> |
1834 | - <option value="">', $txt['pm_rule_sel_action'] , ':</option> |
|
1835 | - <option value="lab"', $action['t'] == 'lab' ? ' selected' : '', '>', $txt['pm_rule_label'] , '</option> |
|
1836 | - <option value="del"', $action['t'] == 'del' ? ' selected' : '', '>', $txt['pm_rule_delete'] , '</option> |
|
1834 | + <option value="">', $txt['pm_rule_sel_action'], ':</option> |
|
1835 | + <option value="lab"', $action['t'] == 'lab' ? ' selected' : '', '>', $txt['pm_rule_label'], '</option> |
|
1836 | + <option value="del"', $action['t'] == 'del' ? ' selected' : '', '>', $txt['pm_rule_delete'], '</option> |
|
1837 | 1837 | </select> |
1838 | 1838 | <span id="labdiv', $k, '"> |
1839 | 1839 | <select name="labdef[', $k, ']" id="labdef', $k, '" onchange="rebuildRuleDesc();"> |
@@ -1945,7 +1945,7 @@ discard block |
||
1945 | 1945 | </div> |
1946 | 1946 | <ul class="quickbuttons"> |
1947 | 1947 | <li><a href="', $scripturl, '?action=pm;sa=showpmdrafts;id_draft=', $draft['id_draft'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons modifybutton"></span>', $txt['draft_edit'], '</a></li> |
1948 | - <li><a href="', $scripturl, '?action=pm;sa=showpmdrafts;delete=', $draft['id_draft'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['draft_remove'] ,'?" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['draft_delete'], '</a></li> |
|
1948 | + <li><a href="', $scripturl, '?action=pm;sa=showpmdrafts;delete=', $draft['id_draft'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['draft_remove'], '?" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['draft_delete'], '</a></li> |
|
1949 | 1949 | </ul> |
1950 | 1950 | </div>'; |
1951 | 1951 | } |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | <div id="personal_messages">'; |
22 | 22 | |
23 | 23 | // Show the capacity bar, if available. |
24 | - if (!empty($context['limit_bar'])) |
|
25 | - echo ' |
|
24 | + if (!empty($context['limit_bar'])) { |
|
25 | + echo ' |
|
26 | 26 | <div class="cat_bar"> |
27 | 27 | <h3 class="catbg"> |
28 | 28 | <span class="floatleft">', $txt['pm_capacity'], ':</span> |
@@ -32,14 +32,16 @@ discard block |
||
32 | 32 | <span class="floatright', $context['limit_bar']['percent'] > 90 ? ' alert' : '', '">', $context['limit_bar']['text'], '</span> |
33 | 33 | </h3> |
34 | 34 | </div>'; |
35 | + } |
|
35 | 36 | |
36 | 37 | // Message sent? Show a small indication. |
37 | - if (isset($context['pm_sent'])) |
|
38 | - echo ' |
|
38 | + if (isset($context['pm_sent'])) { |
|
39 | + echo ' |
|
39 | 40 | <div class="infobox"> |
40 | 41 | ', $txt['pm_sent'], ' |
41 | 42 | </div>'; |
42 | -} |
|
43 | + } |
|
44 | + } |
|
43 | 45 | |
44 | 46 | /** |
45 | 47 | * Just the end of the index bar, nothing special. |
@@ -72,8 +74,7 @@ discard block |
||
72 | 74 | { |
73 | 75 | echo ' |
74 | 76 | <div class="no_unread">', $txt['pm_no_unread'], '</div>'; |
75 | - } |
|
76 | - else |
|
77 | + } else |
|
77 | 78 | { |
78 | 79 | foreach ($context['unread_pms'] as $id_pm => $pm_details) |
79 | 80 | { |
@@ -193,14 +194,15 @@ discard block |
||
193 | 194 | if ($context['get_pmessage']('message', true)) |
194 | 195 | { |
195 | 196 | // Show the helpful titlebar - generally. |
196 | - if ($context['display_mode'] != 1) |
|
197 | - echo ' |
|
197 | + if ($context['display_mode'] != 1) { |
|
198 | + echo ' |
|
198 | 199 | <div class="cat_bar"> |
199 | 200 | <h3 class="catbg"> |
200 | 201 | <span id="author">', $txt['author'], '</span> |
201 | 202 | <span id="topic_title">', $txt[$context['display_mode'] == 0 ? 'messages' : 'conversation'], '</span> |
202 | 203 | </h3> |
203 | 204 | </div>'; |
205 | + } |
|
204 | 206 | |
205 | 207 | // Show a few buttons if we are in conversation mode and outputting the first message. |
206 | 208 | if ($context['display_mode'] == 2) |
@@ -229,9 +231,10 @@ discard block |
||
229 | 231 | <div class="custom_fields_above_member"> |
230 | 232 | <ul class="nolist">'; |
231 | 233 | |
232 | - foreach ($message['custom_fields']['above_member'] as $custom) |
|
233 | - echo ' |
|
234 | + foreach ($message['custom_fields']['above_member'] as $custom) { |
|
235 | + echo ' |
|
234 | 236 | <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
237 | + } |
|
235 | 238 | |
236 | 239 | echo ' |
237 | 240 | </ul> |
@@ -243,9 +246,10 @@ discard block |
||
243 | 246 | <a id="msg', $message['id'], '"></a>'; |
244 | 247 | |
245 | 248 | // Show online and offline buttons? |
246 | - if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest']) |
|
247 | - echo ' |
|
249 | + if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest']) { |
|
250 | + echo ' |
|
248 | 251 | <span class="' . ($message['member']['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $message['member']['online']['text'] . '"></span>'; |
252 | + } |
|
249 | 253 | |
250 | 254 | // Show a link to the member's profile (but only if the sender isn't a guest). |
251 | 255 | echo ' |
@@ -258,48 +262,56 @@ discard block |
||
258 | 262 | <ul class="user_info">'; |
259 | 263 | |
260 | 264 | // Show the user's avatar. |
261 | - if (!empty($modSettings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image'])) |
|
262 | - echo ' |
|
265 | + if (!empty($modSettings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image'])) { |
|
266 | + echo ' |
|
263 | 267 | <li class="avatar"> |
264 | 268 | <a href="', $scripturl, '?action=profile;u=', $message['member']['id'], '">', $message['member']['avatar']['image'], '</a> |
265 | 269 | </li>'; |
270 | + } |
|
266 | 271 | |
267 | 272 | // Are there any custom fields below the avatar? |
268 | - if (!empty($message['custom_fields']['below_avatar'])) |
|
269 | - foreach ($message['custom_fields']['below_avatar'] as $custom) |
|
273 | + if (!empty($message['custom_fields']['below_avatar'])) { |
|
274 | + foreach ($message['custom_fields']['below_avatar'] as $custom) |
|
270 | 275 | echo ' |
271 | 276 | <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
277 | + } |
|
272 | 278 | |
273 | - if (!$message['member']['is_guest']) |
|
274 | - echo ' |
|
279 | + if (!$message['member']['is_guest']) { |
|
280 | + echo ' |
|
275 | 281 | <li class="icons">', $message['member']['group_icons'], '</li>'; |
282 | + } |
|
276 | 283 | // Show the member's primary group (like 'Administrator') if they have one. |
277 | - if (isset($message['member']['group']) && $message['member']['group'] != '') |
|
278 | - echo ' |
|
284 | + if (isset($message['member']['group']) && $message['member']['group'] != '') { |
|
285 | + echo ' |
|
279 | 286 | <li class="membergroup">', $message['member']['group'], '</li>'; |
287 | + } |
|
280 | 288 | |
281 | 289 | // Show the member's custom title, if they have one. |
282 | - if (isset($message['member']['title']) && $message['member']['title'] != '') |
|
283 | - echo ' |
|
290 | + if (isset($message['member']['title']) && $message['member']['title'] != '') { |
|
291 | + echo ' |
|
284 | 292 | <li class="title">', $message['member']['title'], '</li>'; |
293 | + } |
|
285 | 294 | |
286 | 295 | // Don't show these things for guests. |
287 | 296 | if (!$message['member']['is_guest']) |
288 | 297 | { |
289 | 298 | // Show the post group if and only if they have no other group or the option is on, and they are in a post group. |
290 | - if ((empty($modSettings['hide_post_group']) || $message['member']['group'] == '') && $message['member']['post_group'] != '') |
|
291 | - echo ' |
|
299 | + if ((empty($modSettings['hide_post_group']) || $message['member']['group'] == '') && $message['member']['post_group'] != '') { |
|
300 | + echo ' |
|
292 | 301 | <li class="postgroup">', $message['member']['post_group'], '</li>'; |
302 | + } |
|
293 | 303 | |
294 | 304 | // Show how many posts they have made. |
295 | - if (!isset($context['disabled_fields']['posts'])) |
|
296 | - echo ' |
|
305 | + if (!isset($context['disabled_fields']['posts'])) { |
|
306 | + echo ' |
|
297 | 307 | <li class="postcount">', $txt['member_postcount'], ': ', $message['member']['posts'], '</li>'; |
308 | + } |
|
298 | 309 | |
299 | 310 | // Show their personal text? |
300 | - if (!empty($modSettings['show_blurb']) && $message['member']['blurb'] != '') |
|
301 | - echo ' |
|
311 | + if (!empty($modSettings['show_blurb']) && $message['member']['blurb'] != '') { |
|
312 | + echo ' |
|
302 | 313 | <li class="blurb">', $message['member']['blurb'], '</li>'; |
314 | + } |
|
303 | 315 | |
304 | 316 | // Any custom fields to show as icons? |
305 | 317 | if (!empty($message['custom_fields']['icons'])) |
@@ -308,9 +320,10 @@ discard block |
||
308 | 320 | <li class="im_icons"> |
309 | 321 | <ol>'; |
310 | 322 | |
311 | - foreach ($message['custom_fields']['icons'] as $custom) |
|
312 | - echo ' |
|
323 | + foreach ($message['custom_fields']['icons'] as $custom) { |
|
324 | + echo ' |
|
313 | 325 | <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
326 | + } |
|
314 | 327 | |
315 | 328 | echo ' |
316 | 329 | </ol> |
@@ -318,19 +331,22 @@ discard block |
||
318 | 331 | } |
319 | 332 | |
320 | 333 | // Show the IP to this user for this post - because you can moderate? |
321 | - if (!empty($context['can_moderate_forum']) && !empty($message['member']['ip'])) |
|
322 | - echo ' |
|
334 | + if (!empty($context['can_moderate_forum']) && !empty($message['member']['ip'])) { |
|
335 | + echo ' |
|
323 | 336 | <li class="poster_ip"><a href="', $scripturl, '?action=', !empty($message['member']['is_guest']) ? 'trackip' : 'profile;area=tracking;sa=ip;u=' . $message['member']['id'], ';searchip=', $message['member']['ip'], '">', $message['member']['ip'], '</a> <a href="', $scripturl, '?action=helpadmin;help=see_admin_ip" onclick="return reqOverlayDiv(this.href);" class="help">(?)</a></li>'; |
337 | + } |
|
324 | 338 | |
325 | 339 | // Or, should we show it because this is you? |
326 | - elseif ($message['can_see_ip']) |
|
327 | - echo ' |
|
340 | + elseif ($message['can_see_ip']) { |
|
341 | + echo ' |
|
328 | 342 | <li class="poster_ip"><a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $message['member']['ip'], '</a></li>'; |
343 | + } |
|
329 | 344 | |
330 | 345 | // Okay, you are logged in, then we can show something about why IPs are logged... |
331 | - else |
|
332 | - echo ' |
|
346 | + else { |
|
347 | + echo ' |
|
333 | 348 | <li class="poster_ip"><a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $txt['logged'], '</a></li>'; |
349 | + } |
|
334 | 350 | |
335 | 351 | // Show the profile, website, email address, and personal message buttons. |
336 | 352 | if ($message['member']['show_profile_buttons']) |
@@ -340,24 +356,28 @@ discard block |
||
340 | 356 | <ol class="profile_icons">'; |
341 | 357 | |
342 | 358 | // Show the profile button |
343 | - if ($message['member']['can_view_profile']) |
|
344 | - echo ' |
|
359 | + if ($message['member']['can_view_profile']) { |
|
360 | + echo ' |
|
345 | 361 | <li><a href="', $message['member']['href'], '">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/icons/profile_sm.png" alt="' . $txt['view_profile'] . '" title="' . $txt['view_profile'] . '">' : $txt['view_profile']), '</a></li>'; |
362 | + } |
|
346 | 363 | |
347 | 364 | // Don't show an icon if they haven't specified a website. |
348 | - if ($message['member']['website']['url'] != '' && !isset($context['disabled_fields']['website'])) |
|
349 | - echo ' |
|
365 | + if ($message['member']['website']['url'] != '' && !isset($context['disabled_fields']['website'])) { |
|
366 | + echo ' |
|
350 | 367 | <li><a href="', $message['member']['website']['url'], '" title="' . $message['member']['website']['title'] . '" target="_blank" class="new_win">', ($settings['use_image_buttons'] ? '<span class="generic_icons www centericon" title="' . $message['member']['website']['title'] . '"></span>' : $txt['www']), '</a></li>'; |
368 | + } |
|
351 | 369 | |
352 | 370 | // Don't show the email address if they want it hidden. |
353 | - if ($message['member']['show_email']) |
|
354 | - echo ' |
|
371 | + if ($message['member']['show_email']) { |
|
372 | + echo ' |
|
355 | 373 | <li><a href="mailto:', $message['member']['email'], '" rel="nofollow">', ($settings['use_image_buttons'] ? '<span class="generic_icons mail centericon" title="' . $txt['email'] . '"></span>' : $txt['email']), '</a></li>'; |
374 | + } |
|
356 | 375 | |
357 | 376 | // Since we know this person isn't a guest, you *can* message them. |
358 | - if ($context['can_send_pm']) |
|
359 | - echo ' |
|
377 | + if ($context['can_send_pm']) { |
|
378 | + echo ' |
|
360 | 379 | <li><a href="', $scripturl, '?action=pm;sa=send;u=', $message['member']['id'], '" title="', $message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline'], '">', $settings['use_image_buttons'] ? '<span class="generic_icons im_' . ($message['member']['online']['is_online'] ? 'on' : 'off') . ' centericon" title="' . ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']) . '"></span> ' : ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']), '</a></li>'; |
380 | + } |
|
361 | 381 | |
362 | 382 | echo ' |
363 | 383 | </ol> |
@@ -365,21 +385,24 @@ discard block |
||
365 | 385 | } |
366 | 386 | |
367 | 387 | // Any custom fields for standard placement? |
368 | - if (!empty($message['custom_fields']['standard'])) |
|
369 | - foreach ($message['custom_fields']['standard'] as $custom) |
|
388 | + if (!empty($message['custom_fields']['standard'])) { |
|
389 | + foreach ($message['custom_fields']['standard'] as $custom) |
|
370 | 390 | echo ' |
371 | 391 | <li class="custom ', $custom['col_name'] ,'">', $custom['title'], ': ', $custom['value'], '</li>'; |
392 | + } |
|
372 | 393 | |
373 | 394 | // Are we showing the warning status? |
374 | - if ($message['member']['can_see_warning']) |
|
375 | - echo ' |
|
395 | + if ($message['member']['can_see_warning']) { |
|
396 | + echo ' |
|
376 | 397 | <li class="warning">', $context['can_issue_warning'] ? '<a href="' . $scripturl . '?action=profile;area=issuewarning;u=' . $message['member']['id'] . '">' : '', '<span class="generic_icons warning_', $message['member']['warning_status'], '"></span>', $context['can_issue_warning'] ? '</a>' : '', '<span class="warn_', $message['member']['warning_status'], '">', $txt['warn_' . $message['member']['warning_status']], '</span></li>'; |
398 | + } |
|
377 | 399 | |
378 | 400 | // Are there any custom fields to show at the bottom of the poster info? |
379 | - if (!empty($message['custom_fields']['bottom_poster'])) |
|
380 | - foreach ($message['custom_fields']['bottom_poster'] as $custom) |
|
401 | + if (!empty($message['custom_fields']['bottom_poster'])) { |
|
402 | + foreach ($message['custom_fields']['bottom_poster'] as $custom) |
|
381 | 403 | echo ' |
382 | 404 | <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
405 | + } |
|
383 | 406 | } |
384 | 407 | |
385 | 408 | // Done with the information about the poster... on to the post itself. |
@@ -398,24 +421,28 @@ discard block |
||
398 | 421 | <span class="smalltext">« <strong> ', $txt['sent_to'], ':</strong> '; |
399 | 422 | |
400 | 423 | // People it was sent directly to.... |
401 | - if (!empty($message['recipients']['to'])) |
|
402 | - echo implode(', ', $message['recipients']['to']); |
|
424 | + if (!empty($message['recipients']['to'])) { |
|
425 | + echo implode(', ', $message['recipients']['to']); |
|
426 | + } |
|
403 | 427 | // Otherwise, we're just going to say "some people"... |
404 | - elseif ($context['folder'] != 'sent') |
|
405 | - echo '(', $txt['pm_undisclosed_recipients'], ')'; |
|
428 | + elseif ($context['folder'] != 'sent') { |
|
429 | + echo '(', $txt['pm_undisclosed_recipients'], ')'; |
|
430 | + } |
|
406 | 431 | |
407 | 432 | echo ' |
408 | 433 | <strong> ', $txt['on'], ':</strong> ', $message['time'], ' » |
409 | 434 | </span>'; |
410 | 435 | |
411 | 436 | // If we're in the sent items, show who it was sent to besides the "To:" people. |
412 | - if (!empty($message['recipients']['bcc'])) |
|
413 | - echo ' |
|
437 | + if (!empty($message['recipients']['bcc'])) { |
|
438 | + echo ' |
|
414 | 439 | <br><span class="smalltext">« <strong> ', $txt['pm_bcc'], ':</strong> ', implode(', ', $message['recipients']['bcc']), ' »</span>'; |
440 | + } |
|
415 | 441 | |
416 | - if (!empty($message['is_replied_to'])) |
|
417 | - echo ' |
|
442 | + if (!empty($message['is_replied_to'])) { |
|
443 | + echo ' |
|
418 | 444 | <br><span class="smalltext">« ', $context['folder'] == 'sent' ? $txt['pm_sent_is_replied_to'] : $txt['pm_is_replied_to'], ' »</span>'; |
445 | + } |
|
419 | 446 | |
420 | 447 | echo ' |
421 | 448 | </div> |
@@ -423,13 +450,15 @@ discard block |
||
423 | 450 | <div class="post"> |
424 | 451 | <div class="inner" id="msg_', $message['id'], '"', '>', $message['body'], '</div>'; |
425 | 452 | |
426 | - if ($message['can_report'] || $context['can_send_pm']) |
|
427 | - echo ' |
|
453 | + if ($message['can_report'] || $context['can_send_pm']) { |
|
454 | + echo ' |
|
428 | 455 | <div class="under_message">'; |
456 | + } |
|
429 | 457 | |
430 | - if ($message['can_report']) |
|
431 | - echo ' |
|
458 | + if ($message['can_report']) { |
|
459 | + echo ' |
|
432 | 460 | <a href="' . $scripturl . '?action=pm;sa=report;l=' . $context['current_label_id'] . ';pmsg=' . $message['id'] . '" class="floatright">' . $txt['pm_report_to_admin'] . '</a>'; |
461 | + } |
|
433 | 462 | |
434 | 463 | echo ' |
435 | 464 | <ul class="quickbuttons">'; |
@@ -441,32 +470,36 @@ discard block |
||
441 | 470 | if (!$message['member']['is_guest']) |
442 | 471 | { |
443 | 472 | // Is there than more than one recipient you can reply to? |
444 | - if ($message['number_recipients'] > 1) |
|
445 | - echo ' |
|
473 | + if ($message['number_recipients'] > 1) { |
|
474 | + echo ' |
|
446 | 475 | <li><a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote;u=all"><span class="generic_icons reply_all_button"></span>', $txt['reply_to_all'], '</a></li>'; |
476 | + } |
|
447 | 477 | |
448 | 478 | echo ' |
449 | 479 | <li><a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';u=', $message['member']['id'], '"><span class="generic_icons reply_button"></span>', $txt['reply'], '</a></li> |
450 | 480 | <li><a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote', $context['folder'] == 'sent' ? '' : ';u=' . $message['member']['id'], '"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li>'; |
451 | 481 | } |
452 | 482 | // This is for "forwarding" - even if the member is gone. |
453 | - else |
|
454 | - echo ' |
|
483 | + else { |
|
484 | + echo ' |
|
455 | 485 | <li><a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote"><span class="generic_icons quote"></span>', $txt['reply_quote'], '</a></li>'; |
486 | + } |
|
456 | 487 | } |
457 | 488 | echo ' |
458 | 489 | <li><a href="', $scripturl, '?action=pm;sa=pmactions;pm_actions%5b', $message['id'], '%5D=delete;f=', $context['folder'], ';start=', $context['start'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', addslashes($txt['remove_message_question']), '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['delete'], '</a></li>'; |
459 | 490 | |
460 | - if (empty($context['display_mode'])) |
|
461 | - echo ' |
|
491 | + if (empty($context['display_mode'])) { |
|
492 | + echo ' |
|
462 | 493 | <li><input type="checkbox" name="pms[]" id="deletedisplay', $message['id'], '" value="', $message['id'], '" onclick="document.getElementById(\'deletelisting', $message['id'], '\').checked = this.checked;"></li>'; |
494 | + } |
|
463 | 495 | |
464 | 496 | echo ' |
465 | 497 | </ul>'; |
466 | 498 | |
467 | - if ($message['can_report'] || $context['can_send_pm']) |
|
468 | - echo ' |
|
499 | + if ($message['can_report'] || $context['can_send_pm']) { |
|
500 | + echo ' |
|
469 | 501 | </div>'; |
502 | + } |
|
470 | 503 | |
471 | 504 | // Are there any custom profile fields for above the signature? |
472 | 505 | if (!empty($message['custom_fields']['above_signature'])) |
@@ -475,9 +508,10 @@ discard block |
||
475 | 508 | <div class="custom_fields_above_signature"> |
476 | 509 | <ul class="nolist">'; |
477 | 510 | |
478 | - foreach ($message['custom_fields']['above_signature'] as $custom) |
|
479 | - echo ' |
|
511 | + foreach ($message['custom_fields']['above_signature'] as $custom) { |
|
512 | + echo ' |
|
480 | 513 | <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
514 | + } |
|
481 | 515 | |
482 | 516 | echo ' |
483 | 517 | </ul> |
@@ -485,9 +519,10 @@ discard block |
||
485 | 519 | } |
486 | 520 | |
487 | 521 | // Show the member's signature? |
488 | - if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled']) |
|
489 | - echo ' |
|
522 | + if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled']) { |
|
523 | + echo ' |
|
490 | 524 | <div class="signature">', $message['member']['signature'], '</div>'; |
525 | + } |
|
491 | 526 | |
492 | 527 | // Are there any custom profile fields for below the signature? |
493 | 528 | if (!empty($message['custom_fields']['below_signature'])) |
@@ -496,9 +531,10 @@ discard block |
||
496 | 531 | <div class="custom_fields_below_signature"> |
497 | 532 | <ul class="nolist">'; |
498 | 533 | |
499 | - foreach ($message['custom_fields']['below_signature'] as $custom) |
|
500 | - echo ' |
|
534 | + foreach ($message['custom_fields']['below_signature'] as $custom) { |
|
535 | + echo ' |
|
501 | 536 | <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
537 | + } |
|
502 | 538 | |
503 | 539 | echo ' |
504 | 540 | </ul> |
@@ -523,19 +559,21 @@ discard block |
||
523 | 559 | { |
524 | 560 | echo ' |
525 | 561 | <option value="" disabled>', $txt['pm_msg_label_apply'], ':</option>'; |
526 | - foreach ($context['labels'] as $label) |
|
527 | - if (!isset($message['labels'][$label['id']])) |
|
562 | + foreach ($context['labels'] as $label) { |
|
563 | + if (!isset($message['labels'][$label['id']])) |
|
528 | 564 | echo ' |
529 | 565 | <option value="', $label['id'], '"> ', $label['name'], '</option>'; |
566 | + } |
|
530 | 567 | } |
531 | 568 | // ... and are there any that can be removed? |
532 | 569 | if (!empty($message['labels']) && (count($message['labels']) > 1 || !isset($message['labels'][-1]))) |
533 | 570 | { |
534 | 571 | echo ' |
535 | 572 | <option value="" disabled>', $txt['pm_msg_label_remove'], ':</option>'; |
536 | - foreach ($message['labels'] as $label) |
|
537 | - echo ' |
|
573 | + foreach ($message['labels'] as $label) { |
|
574 | + echo ' |
|
538 | 575 | <option value="', $label['id'], '"> ', $label['name'], '</option>'; |
576 | + } |
|
539 | 577 | } |
540 | 578 | echo ' |
541 | 579 | </select> |
@@ -555,13 +593,14 @@ discard block |
||
555 | 593 | </div>'; |
556 | 594 | } |
557 | 595 | |
558 | - if (empty($context['display_mode'])) |
|
559 | - echo ' |
|
596 | + if (empty($context['display_mode'])) { |
|
597 | + echo ' |
|
560 | 598 | |
561 | 599 | <div class="pagesection"> |
562 | 600 | <div class="floatleft">', $context['page_index'], '</div> |
563 | 601 | <div class="floatright"><input type="submit" name="del_selected" value="', $txt['quickmod_delete_selected'], '" style="font-weight: normal;" onclick="if (!confirm(\'', $txt['delete_selected_confirm'], '\')) return false;" class="button_submit"></div> |
564 | 602 | </div>'; |
603 | + } |
|
565 | 604 | |
566 | 605 | // Show a few buttons if we are in conversation mode and outputting the first message. |
567 | 606 | elseif ($context['display_mode'] == 2 && isset($context['conversation_buttons'])) |
@@ -621,11 +660,12 @@ discard block |
||
621 | 660 | </tr> |
622 | 661 | </thead> |
623 | 662 | <tbody>'; |
624 | - if (!$context['show_delete']) |
|
625 | - echo ' |
|
663 | + if (!$context['show_delete']) { |
|
664 | + echo ' |
|
626 | 665 | <tr class="windowbg"> |
627 | 666 | <td colspan="5">', $txt['pm_alert_none'], '</td> |
628 | 667 | </tr>'; |
668 | + } |
|
629 | 669 | |
630 | 670 | while ($message = $context['get_pmessage']('subject')) |
631 | 671 | { |
@@ -678,9 +718,10 @@ discard block |
||
678 | 718 | |
679 | 719 | foreach ($context['labels'] as $label) |
680 | 720 | { |
681 | - if ($label['id'] != $context['current_label_id']) |
|
682 | - echo ' |
|
721 | + if ($label['id'] != $context['current_label_id']) { |
|
722 | + echo ' |
|
683 | 723 | <option value="add_', $label['id'], '"> ', $label['name'], '</option>'; |
724 | + } |
|
684 | 725 | } |
685 | 726 | |
686 | 727 | echo ' |
@@ -765,9 +806,10 @@ discard block |
||
765 | 806 | <dt class="between">', $txt['pm_search_post_age'], ':</dt> |
766 | 807 | <dd>', $txt['pm_search_between'], ' <input type="number" name="minage" value="', empty($context['search_params']['minage']) ? '0' : $context['search_params']['minage'], '" size="5" maxlength="5" min="0" max="9999"> ', $txt['pm_search_between_and'], ' <input type="number" name="maxage" value="', empty($context['search_params']['maxage']) ? '9999' : $context['search_params']['maxage'], '" size="5" maxlength="5" min="0" max="9999"> ', $txt['pm_search_between_days'], '</dd> |
767 | 808 | </dl>'; |
768 | - if (!$context['currently_using_labels']) |
|
769 | - echo ' |
|
809 | + if (!$context['currently_using_labels']) { |
|
810 | + echo ' |
|
770 | 811 | <input type="submit" name="pm_search" value="', $txt['pm_search_go'], '" class="button_submit">'; |
812 | + } |
|
771 | 813 | echo ' |
772 | 814 | <br class="clear_right"> |
773 | 815 | </div> |
@@ -787,12 +829,13 @@ discard block |
||
787 | 829 | <div id="advanced_panel_div"> |
788 | 830 | <ul id="searchLabelsExpand">'; |
789 | 831 | |
790 | - foreach ($context['search_labels'] as $label) |
|
791 | - echo ' |
|
832 | + foreach ($context['search_labels'] as $label) { |
|
833 | + echo ' |
|
792 | 834 | <li> |
793 | 835 | <label for="searchlabel_', $label['id'], '"><input type="checkbox" id="searchlabel_', $label['id'], '" name="searchlabel[', $label['id'], ']" value="', $label['id'], '"', $label['checked'] ? ' checked' : '', '> |
794 | 836 | ', $label['name'], '</label> |
795 | 837 | </li>'; |
838 | + } |
|
796 | 839 | |
797 | 840 | echo ' |
798 | 841 | </ul> |
@@ -852,8 +895,8 @@ discard block |
||
852 | 895 | </div>'; |
853 | 896 | |
854 | 897 | // complete results ? |
855 | - if (empty($context['search_params']['show_complete']) && !empty($context['personal_messages'])) |
|
856 | - echo ' |
|
898 | + if (empty($context['search_params']['show_complete']) && !empty($context['personal_messages'])) { |
|
899 | + echo ' |
|
857 | 900 | <table class="table_grid"> |
858 | 901 | <thead> |
859 | 902 | <tr class="title_bar"> |
@@ -863,6 +906,7 @@ discard block |
||
863 | 906 | </tr> |
864 | 907 | </thead> |
865 | 908 | <tbody>'; |
909 | + } |
|
866 | 910 | |
867 | 911 | // Print each message out... |
868 | 912 | foreach ($context['personal_messages'] as $message) |
@@ -882,11 +926,13 @@ discard block |
||
882 | 926 | |
883 | 927 | // Show the recipients. |
884 | 928 | // @todo This doesn't deal with the sent item searching quite right for bcc. |
885 | - if (!empty($message['recipients']['to'])) |
|
886 | - echo implode(', ', $message['recipients']['to']); |
|
929 | + if (!empty($message['recipients']['to'])) { |
|
930 | + echo implode(', ', $message['recipients']['to']); |
|
931 | + } |
|
887 | 932 | // Otherwise, we're just going to say "some people"... |
888 | - elseif ($context['folder'] != 'sent') |
|
889 | - echo '(', $txt['pm_undisclosed_recipients'], ')'; |
|
933 | + elseif ($context['folder'] != 'sent') { |
|
934 | + echo '(', $txt['pm_undisclosed_recipients'], ')'; |
|
935 | + } |
|
890 | 936 | |
891 | 937 | echo ' |
892 | 938 | </h3> |
@@ -900,14 +946,16 @@ discard block |
||
900 | 946 | $quote_button = create_button('quote.png', 'reply_quote', 'reply_quote', 'class="centericon"'); |
901 | 947 | $reply_button = create_button('im_reply.png', 'reply', 'reply', 'class="centericon"'); |
902 | 948 | // You can only reply if they are not a guest... |
903 | - if (!$message['member']['is_guest']) |
|
904 | - echo ' |
|
949 | + if (!$message['member']['is_guest']) { |
|
950 | + echo ' |
|
905 | 951 | <a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote;u=', $context['folder'] == 'sent' ? '' : $message['member']['id'], '">', $quote_button , '</a>', $context['menu_separator'], ' |
906 | 952 | <a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';u=', $message['member']['id'], '">', $reply_button , '</a> ', $context['menu_separator']; |
953 | + } |
|
907 | 954 | // This is for "forwarding" - even if the member is gone. |
908 | - else |
|
909 | - echo ' |
|
955 | + else { |
|
956 | + echo ' |
|
910 | 957 | <a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote">', $quote_button , '</a>', $context['menu_separator']; |
958 | + } |
|
911 | 959 | } |
912 | 960 | |
913 | 961 | echo ' |
@@ -928,17 +976,19 @@ discard block |
||
928 | 976 | } |
929 | 977 | |
930 | 978 | // Finish off the page... |
931 | - if (empty($context['search_params']['show_complete']) && !empty($context['personal_messages'])) |
|
932 | - echo ' |
|
979 | + if (empty($context['search_params']['show_complete']) && !empty($context['personal_messages'])) { |
|
980 | + echo ' |
|
933 | 981 | </tbody> |
934 | 982 | </table>'; |
983 | + } |
|
935 | 984 | |
936 | 985 | // No results? |
937 | - if (empty($context['personal_messages'])) |
|
938 | - echo ' |
|
986 | + if (empty($context['personal_messages'])) { |
|
987 | + echo ' |
|
939 | 988 | <div class="windowbg"> |
940 | 989 | <p class="centertext">', $txt['pm_search_none_found'], '</p> |
941 | 990 | </div>'; |
991 | + } |
|
942 | 992 | |
943 | 993 | echo ' |
944 | 994 | <div class="pagesection"> |
@@ -962,12 +1012,14 @@ discard block |
||
962 | 1012 | <h3 class="catbg">', $txt['pm_send_report'], '</h3> |
963 | 1013 | </div> |
964 | 1014 | <div class="windowbg">'; |
965 | - if (!empty($context['send_log']['sent'])) |
|
966 | - foreach ($context['send_log']['sent'] as $log_entry) |
|
1015 | + if (!empty($context['send_log']['sent'])) { |
|
1016 | + foreach ($context['send_log']['sent'] as $log_entry) |
|
967 | 1017 | echo '<span class="error">', $log_entry, '</span><br>'; |
968 | - if (!empty($context['send_log']['failed'])) |
|
969 | - foreach ($context['send_log']['failed'] as $log_entry) |
|
1018 | + } |
|
1019 | + if (!empty($context['send_log']['failed'])) { |
|
1020 | + foreach ($context['send_log']['failed'] as $log_entry) |
|
970 | 1021 | echo '<span class="error">', $log_entry, '</span><br>'; |
1022 | + } |
|
971 | 1023 | echo ' |
972 | 1024 | </div> |
973 | 1025 | <br>'; |
@@ -1015,12 +1067,13 @@ discard block |
||
1015 | 1067 | </dl> |
1016 | 1068 | </div>'; |
1017 | 1069 | |
1018 | - if (!empty($modSettings['drafts_pm_enabled'])) |
|
1019 | - echo ' |
|
1070 | + if (!empty($modSettings['drafts_pm_enabled'])) { |
|
1071 | + echo ' |
|
1020 | 1072 | <div id="draft_section" class="infobox"', isset($context['draft_saved']) ? '' : ' style="display: none;"', '>', |
1021 | 1073 | sprintf($txt['draft_pm_saved'], $scripturl . '?action=pm;sa=showpmdrafts'), ' |
1022 | 1074 | ', (!empty($modSettings['drafts_keep_days']) ? ' <strong>' . sprintf($txt['draft_save_warning'], $modSettings['drafts_keep_days']) . '</strong>' : ''), ' |
1023 | 1075 | </div>'; |
1076 | + } |
|
1024 | 1077 | |
1025 | 1078 | echo ' |
1026 | 1079 | <dl id="post_header">'; |
@@ -1075,9 +1128,10 @@ discard block |
||
1075 | 1128 | } |
1076 | 1129 | |
1077 | 1130 | // What about smileys? |
1078 | - if (!empty($context['smileys']['postform']) || !empty($context['smileys']['popup'])) |
|
1079 | - echo ' |
|
1131 | + if (!empty($context['smileys']['postform']) || !empty($context['smileys']['popup'])) { |
|
1132 | + echo ' |
|
1080 | 1133 | <div id="smileyBox_message"></div>'; |
1134 | + } |
|
1081 | 1135 | |
1082 | 1136 | // Show BBC buttons, smileys and textbox. |
1083 | 1137 | echo ' |
@@ -1124,10 +1178,11 @@ discard block |
||
1124 | 1178 | <dt><strong>', $txt['subject'], '</strong></dt> |
1125 | 1179 | <dd><strong>', $txt['draft_saved_on'], '</strong></dd>'; |
1126 | 1180 | |
1127 | - foreach ($context['drafts'] as $draft) |
|
1128 | - echo ' |
|
1181 | + foreach ($context['drafts'] as $draft) { |
|
1182 | + echo ' |
|
1129 | 1183 | <dt>', $draft['link'], '</dt> |
1130 | 1184 | <dd>', $draft['poster_time'], '</dd>'; |
1185 | + } |
|
1131 | 1186 | echo ' |
1132 | 1187 | </dl> |
1133 | 1188 | </div>'; |
@@ -1233,8 +1288,8 @@ discard block |
||
1233 | 1288 | }'; |
1234 | 1289 | |
1235 | 1290 | // Code for showing and hiding drafts |
1236 | - if (!empty($context['drafts'])) |
|
1237 | - echo ' |
|
1291 | + if (!empty($context['drafts'])) { |
|
1292 | + echo ' |
|
1238 | 1293 | var oSwapDraftOptions = new smc_Toggle({ |
1239 | 1294 | bToggleEnabled: true, |
1240 | 1295 | bCurrentlyCollapsed: true, |
@@ -1256,13 +1311,14 @@ discard block |
||
1256 | 1311 | } |
1257 | 1312 | ] |
1258 | 1313 | });'; |
1314 | + } |
|
1259 | 1315 | |
1260 | 1316 | echo ' |
1261 | 1317 | </script>'; |
1262 | 1318 | |
1263 | 1319 | // Show the message you're replying to. |
1264 | - if ($context['reply']) |
|
1265 | - echo ' |
|
1320 | + if ($context['reply']) { |
|
1321 | + echo ' |
|
1266 | 1322 | <br> |
1267 | 1323 | <br> |
1268 | 1324 | <div class="cat_bar"> |
@@ -1276,6 +1332,7 @@ discard block |
||
1276 | 1332 | <hr> |
1277 | 1333 | ', $context['quoted_message']['body'], ' |
1278 | 1334 | </div><br class="clear">'; |
1335 | + } |
|
1279 | 1336 | |
1280 | 1337 | echo ' |
1281 | 1338 | <script> |
@@ -1286,22 +1343,24 @@ discard block |
||
1286 | 1343 | sTextDeleteItem: \'', $txt['autosuggest_delete_item'], '\', |
1287 | 1344 | sToControlId: \'to_control\', |
1288 | 1345 | aToRecipients: ['; |
1289 | - foreach ($context['recipients']['to'] as $i => $member) |
|
1290 | - echo ' |
|
1346 | + foreach ($context['recipients']['to'] as $i => $member) { |
|
1347 | + echo ' |
|
1291 | 1348 | { |
1292 | 1349 | sItemId: ', JavaScriptEscape($member['id']), ', |
1293 | 1350 | sItemName: ', JavaScriptEscape($member['name']), ' |
1294 | 1351 | }', $i == count($context['recipients']['to']) - 1 ? '' : ','; |
1352 | + } |
|
1295 | 1353 | |
1296 | 1354 | echo ' |
1297 | 1355 | ], |
1298 | 1356 | aBccRecipients: ['; |
1299 | - foreach ($context['recipients']['bcc'] as $i => $member) |
|
1300 | - echo ' |
|
1357 | + foreach ($context['recipients']['bcc'] as $i => $member) { |
|
1358 | + echo ' |
|
1301 | 1359 | { |
1302 | 1360 | sItemId: ', JavaScriptEscape($member['id']), ', |
1303 | 1361 | sItemName: ', JavaScriptEscape($member['name']), ' |
1304 | 1362 | }', $i == count($context['recipients']['bcc']) - 1 ? '' : ','; |
1363 | + } |
|
1305 | 1364 | |
1306 | 1365 | echo ' |
1307 | 1366 | ], |
@@ -1388,26 +1447,28 @@ discard block |
||
1388 | 1447 | </th> |
1389 | 1448 | <th class="centertext table_icon">'; |
1390 | 1449 | |
1391 | - if (count($context['labels']) > 2) |
|
1392 | - echo ' |
|
1450 | + if (count($context['labels']) > 2) { |
|
1451 | + echo ' |
|
1393 | 1452 | <input type="checkbox" onclick="invertAll(this, this.form);">'; |
1453 | + } |
|
1394 | 1454 | |
1395 | 1455 | echo ' |
1396 | 1456 | </th> |
1397 | 1457 | </tr> |
1398 | 1458 | </thead> |
1399 | 1459 | <tbody>'; |
1400 | - if (count($context['labels']) < 2) |
|
1401 | - echo ' |
|
1460 | + if (count($context['labels']) < 2) { |
|
1461 | + echo ' |
|
1402 | 1462 | <tr class="windowbg"> |
1403 | 1463 | <td colspan="2">', $txt['pm_labels_no_exist'], '</td> |
1404 | 1464 | </tr>'; |
1405 | - else |
|
1465 | + } else |
|
1406 | 1466 | { |
1407 | 1467 | foreach ($context['labels'] as $label) |
1408 | 1468 | { |
1409 | - if ($label['id'] == -1) |
|
1410 | - continue; |
|
1469 | + if ($label['id'] == -1) { |
|
1470 | + continue; |
|
1471 | + } |
|
1411 | 1472 | |
1412 | 1473 | echo ' |
1413 | 1474 | <tr class="windowbg"> |
@@ -1422,12 +1483,13 @@ discard block |
||
1422 | 1483 | </tbody> |
1423 | 1484 | </table>'; |
1424 | 1485 | |
1425 | - if (!count($context['labels']) < 2) |
|
1426 | - echo ' |
|
1486 | + if (!count($context['labels']) < 2) { |
|
1487 | + echo ' |
|
1427 | 1488 | <div class="padding"> |
1428 | 1489 | <input type="submit" name="save" value="', $txt['save'], '" class="button_submit"> |
1429 | 1490 | <input type="submit" name="delete" value="', $txt['quickmod_delete_selected'], '" data-confirm="', $txt['pm_labels_delete'] ,'" class="button_submit you_sure"> |
1430 | 1491 | </div>'; |
1492 | + } |
|
1431 | 1493 | |
1432 | 1494 | echo ' |
1433 | 1495 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -1482,9 +1544,10 @@ discard block |
||
1482 | 1544 | <dd> |
1483 | 1545 | <select name="id_admin"> |
1484 | 1546 | <option value="0">', $txt['pm_report_all_admins'], '</option>'; |
1485 | - foreach ($context['admins'] as $id => $name) |
|
1486 | - echo ' |
|
1547 | + foreach ($context['admins'] as $id => $name) { |
|
1548 | + echo ' |
|
1487 | 1549 | <option value="', $id, '">', $name, '</option>'; |
1550 | + } |
|
1488 | 1551 | echo ' |
1489 | 1552 | </select> |
1490 | 1553 | </dd>'; |
@@ -1546,9 +1609,10 @@ discard block |
||
1546 | 1609 | </th> |
1547 | 1610 | <th class="centertext table_icon">'; |
1548 | 1611 | |
1549 | - if (!empty($context['rules'])) |
|
1550 | - echo ' |
|
1612 | + if (!empty($context['rules'])) { |
|
1613 | + echo ' |
|
1551 | 1614 | <input type="checkbox" onclick="invertAll(this, this.form);">'; |
1615 | + } |
|
1552 | 1616 | |
1553 | 1617 | echo ' |
1554 | 1618 | </th> |
@@ -1556,13 +1620,14 @@ discard block |
||
1556 | 1620 | </thead> |
1557 | 1621 | <tbody>'; |
1558 | 1622 | |
1559 | - if (empty($context['rules'])) |
|
1560 | - echo ' |
|
1623 | + if (empty($context['rules'])) { |
|
1624 | + echo ' |
|
1561 | 1625 | <tr class="windowbg"> |
1562 | 1626 | <td colspan="2"> |
1563 | 1627 | ', $txt['pm_rules_none'], ' |
1564 | 1628 | </td> |
1565 | 1629 | </tr>'; |
1630 | + } |
|
1566 | 1631 | |
1567 | 1632 | foreach ($context['rules'] as $rule) |
1568 | 1633 | { |
@@ -1583,14 +1648,16 @@ discard block |
||
1583 | 1648 | <div class="righttext"> |
1584 | 1649 | <a class="button_link" href="', $scripturl, '?action=pm;sa=manrules;add;rid=0">', $txt['pm_add_rule'], '</a>'; |
1585 | 1650 | |
1586 | - if (!empty($context['rules'])) |
|
1587 | - echo ' |
|
1651 | + if (!empty($context['rules'])) { |
|
1652 | + echo ' |
|
1588 | 1653 | [<a href="', $scripturl, '?action=pm;sa=manrules;apply;', $context['session_var'], '=', $context['session_id'], '" onclick="return confirm(\'', $txt['pm_js_apply_rules_confirm'], '\');">', $txt['pm_apply_rules'], '</a>]'; |
1654 | + } |
|
1589 | 1655 | |
1590 | - if (!empty($context['rules'])) |
|
1591 | - echo ' |
|
1656 | + if (!empty($context['rules'])) { |
|
1657 | + echo ' |
|
1592 | 1658 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
1593 | 1659 | <input type="submit" name="delselected" value="', $txt['pm_delete_selected_rule'], '" data-confirm="', $txt['pm_js_delete_rule_confirm'] ,'" class="button_submit smalltext you_sure">'; |
1660 | + } |
|
1594 | 1661 | |
1595 | 1662 | echo ' |
1596 | 1663 | </div> |
@@ -1612,14 +1679,16 @@ discard block |
||
1612 | 1679 | var groups = new Array() |
1613 | 1680 | var labels = new Array()'; |
1614 | 1681 | |
1615 | - foreach ($context['groups'] as $id => $title) |
|
1616 | - echo ' |
|
1682 | + foreach ($context['groups'] as $id => $title) { |
|
1683 | + echo ' |
|
1617 | 1684 | groups[', $id, '] = "', addslashes($title), '";'; |
1685 | + } |
|
1618 | 1686 | |
1619 | - foreach ($context['labels'] as $label) |
|
1620 | - if ($label['id'] != -1) |
|
1687 | + foreach ($context['labels'] as $label) { |
|
1688 | + if ($label['id'] != -1) |
|
1621 | 1689 | echo ' |
1622 | 1690 | labels[', ($label['id']), '] = "', addslashes($label['name']), '";'; |
1691 | + } |
|
1623 | 1692 | |
1624 | 1693 | echo ' |
1625 | 1694 | function addCriteriaOption() |
@@ -1634,8 +1703,9 @@ discard block |
||
1634 | 1703 | |
1635 | 1704 | setOuterHTML(document.getElementById("criteriaAddHere"), \'<br><select name="ruletype[\' + criteriaNum + \']" id="ruletype\' + criteriaNum + \'" onchange="updateRuleDef(\' + criteriaNum + \'); rebuildRuleDesc();"><option value="">', addslashes($txt['pm_rule_criteria_pick']), ':<\' + \'/option><option value="mid">', addslashes($txt['pm_rule_mid']), '<\' + \'/option><option value="gid">', addslashes($txt['pm_rule_gid']), '<\' + \'/option><option value="sub">', addslashes($txt['pm_rule_sub']), '<\' + \'/option><option value="msg">', addslashes($txt['pm_rule_msg']), '<\' + \'/option><option value="bud">', addslashes($txt['pm_rule_bud']), '<\' + \'/option><\' + \'/select> <span id="defdiv\' + criteriaNum + \'" style="display: none;"><input type="text" name="ruledef[\' + criteriaNum + \']" id="ruledef\' + criteriaNum + \'" onkeyup="rebuildRuleDesc();" value=""><\' + \'/span><span id="defseldiv\' + criteriaNum + \'" style="display: none;"><select name="ruledefgroup[\' + criteriaNum + \']" id="ruledefgroup\' + criteriaNum + \'" onchange="rebuildRuleDesc();"><option value="">', addslashes($txt['pm_rule_sel_group']), '<\' + \'/option>'; |
1636 | 1705 | |
1637 | - foreach ($context['groups'] as $id => $group) |
|
1638 | - echo '<option value="', $id, '">', strtr($group, array("'" => "\'")), '<\' + \'/option>'; |
|
1706 | + foreach ($context['groups'] as $id => $group) { |
|
1707 | + echo '<option value="', $id, '">', strtr($group, array("'" => "\'")), '<\' + \'/option>'; |
|
1708 | + } |
|
1639 | 1709 | |
1640 | 1710 | echo '<\' + \'/select><\' + \'/span><span id="criteriaAddHere"><\' + \'/span>\'); |
1641 | 1711 | } |
@@ -1652,9 +1722,10 @@ discard block |
||
1652 | 1722 | |
1653 | 1723 | setOuterHTML(document.getElementById("actionAddHere"), \'<br><select name="acttype[\' + actionNum + \']" id="acttype\' + actionNum + \'" onchange="updateActionDef(\' + actionNum + \'); rebuildRuleDesc();"><option value="">', addslashes($txt['pm_rule_sel_action']), ':<\' + \'/option><option value="lab">', addslashes($txt['pm_rule_label']), '<\' + \'/option><option value="del">', addslashes($txt['pm_rule_delete']), '<\' + \'/option><\' + \'/select> <span id="labdiv\' + actionNum + \'" style="display: none;"><select name="labdef[\' + actionNum + \']" id="labdef\' + actionNum + \'" onchange="rebuildRuleDesc();"><option value="">', addslashes($txt['pm_rule_sel_label']), '<\' + \'/option>'; |
1654 | 1724 | |
1655 | - foreach ($context['labels'] as $label) |
|
1656 | - if ($label['id'] != -1) |
|
1725 | + foreach ($context['labels'] as $label) { |
|
1726 | + if ($label['id'] != -1) |
|
1657 | 1727 | echo '<option value="', ($label['id']), '">', addslashes($label['name']), '<\' + \'/option>'; |
1728 | + } |
|
1658 | 1729 | |
1659 | 1730 | echo '<\' + \'/select><\' + \'/span><span id="actionAddHere"><\' + \'/span>\'); |
1660 | 1731 | } |
@@ -1768,18 +1839,20 @@ discard block |
||
1768 | 1839 | $isFirst = true; |
1769 | 1840 | foreach ($context['rule']['criteria'] as $k => $criteria) |
1770 | 1841 | { |
1771 | - if (!$isFirst && $criteria['t'] == '') |
|
1772 | - echo '<div id="removeonjs1">'; |
|
1773 | - elseif (!$isFirst) |
|
1774 | - echo '<br>'; |
|
1842 | + if (!$isFirst && $criteria['t'] == '') { |
|
1843 | + echo '<div id="removeonjs1">'; |
|
1844 | + } elseif (!$isFirst) { |
|
1845 | + echo '<br>'; |
|
1846 | + } |
|
1775 | 1847 | |
1776 | 1848 | echo ' |
1777 | 1849 | <select name="ruletype[', $k, ']" id="ruletype', $k, '" onchange="updateRuleDef(', $k, '); rebuildRuleDesc();"> |
1778 | 1850 | <option value="">', $txt['pm_rule_criteria_pick'], ':</option>'; |
1779 | 1851 | |
1780 | - foreach (array('mid', 'gid', 'sub', 'msg', 'bud') as $cr) |
|
1781 | - echo ' |
|
1852 | + foreach (array('mid', 'gid', 'sub', 'msg', 'bud') as $cr) { |
|
1853 | + echo ' |
|
1782 | 1854 | <option value="', $cr, '"', $criteria['t'] == $cr ? ' selected' : '', '>', $txt['pm_rule_' . $cr], '</option>'; |
1855 | + } |
|
1783 | 1856 | |
1784 | 1857 | echo ' |
1785 | 1858 | </select> |
@@ -1790,18 +1863,20 @@ discard block |
||
1790 | 1863 | <select name="ruledefgroup[', $k, ']" id="ruledefgroup', $k, '" onchange="rebuildRuleDesc();"> |
1791 | 1864 | <option value="">', $txt['pm_rule_sel_group'], '</option>'; |
1792 | 1865 | |
1793 | - foreach ($context['groups'] as $id => $group) |
|
1794 | - echo ' |
|
1866 | + foreach ($context['groups'] as $id => $group) { |
|
1867 | + echo ' |
|
1795 | 1868 | <option value="', $id, '"', $criteria['t'] == 'gid' && $criteria['v'] == $id ? ' selected' : '', '>', $group, '</option>'; |
1869 | + } |
|
1796 | 1870 | echo ' |
1797 | 1871 | </select> |
1798 | 1872 | </span>'; |
1799 | 1873 | |
1800 | 1874 | // If this is the dummy we add a means to hide for non js users. |
1801 | - if ($isFirst) |
|
1802 | - $isFirst = false; |
|
1803 | - elseif ($criteria['t'] == '') |
|
1804 | - echo '</div>'; |
|
1875 | + if ($isFirst) { |
|
1876 | + $isFirst = false; |
|
1877 | + } elseif ($criteria['t'] == '') { |
|
1878 | + echo '</div>'; |
|
1879 | + } |
|
1805 | 1880 | } |
1806 | 1881 | |
1807 | 1882 | echo ' |
@@ -1824,10 +1899,11 @@ discard block |
||
1824 | 1899 | $isFirst = true; |
1825 | 1900 | foreach ($context['rule']['actions'] as $k => $action) |
1826 | 1901 | { |
1827 | - if (!$isFirst && $action['t'] == '') |
|
1828 | - echo '<div id="removeonjs2">'; |
|
1829 | - elseif (!$isFirst) |
|
1830 | - echo '<br>'; |
|
1902 | + if (!$isFirst && $action['t'] == '') { |
|
1903 | + echo '<div id="removeonjs2">'; |
|
1904 | + } elseif (!$isFirst) { |
|
1905 | + echo '<br>'; |
|
1906 | + } |
|
1831 | 1907 | |
1832 | 1908 | echo ' |
1833 | 1909 | <select name="acttype[', $k, ']" id="acttype', $k, '" onchange="updateActionDef(', $k, '); rebuildRuleDesc();"> |
@@ -1838,20 +1914,22 @@ discard block |
||
1838 | 1914 | <span id="labdiv', $k, '"> |
1839 | 1915 | <select name="labdef[', $k, ']" id="labdef', $k, '" onchange="rebuildRuleDesc();"> |
1840 | 1916 | <option value="">', $txt['pm_rule_sel_label'], '</option>'; |
1841 | - foreach ($context['labels'] as $label) |
|
1842 | - if ($label['id'] != -1) |
|
1917 | + foreach ($context['labels'] as $label) { |
|
1918 | + if ($label['id'] != -1) |
|
1843 | 1919 | echo ' |
1844 | 1920 | <option value="', ($label['id']), '"', $action['t'] == 'lab' && $action['v'] == $label['id'] ? ' selected' : '', '>', $label['name'], '</option>'; |
1921 | + } |
|
1845 | 1922 | |
1846 | 1923 | echo ' |
1847 | 1924 | </select> |
1848 | 1925 | </span>'; |
1849 | 1926 | |
1850 | - if ($isFirst) |
|
1851 | - $isFirst = false; |
|
1852 | - elseif ($action['t'] == '') |
|
1853 | - echo ' |
|
1927 | + if ($isFirst) { |
|
1928 | + $isFirst = false; |
|
1929 | + } elseif ($action['t'] == '') { |
|
1930 | + echo ' |
|
1854 | 1931 | </div>'; |
1932 | + } |
|
1855 | 1933 | } |
1856 | 1934 | |
1857 | 1935 | echo ' |
@@ -1875,22 +1953,25 @@ discard block |
||
1875 | 1953 | echo ' |
1876 | 1954 | <script>'; |
1877 | 1955 | |
1878 | - foreach ($context['rule']['criteria'] as $k => $c) |
|
1879 | - echo ' |
|
1956 | + foreach ($context['rule']['criteria'] as $k => $c) { |
|
1957 | + echo ' |
|
1880 | 1958 | updateRuleDef(', $k, ');'; |
1959 | + } |
|
1881 | 1960 | |
1882 | - foreach ($context['rule']['actions'] as $k => $c) |
|
1883 | - echo ' |
|
1961 | + foreach ($context['rule']['actions'] as $k => $c) { |
|
1962 | + echo ' |
|
1884 | 1963 | updateActionDef(', $k, ');'; |
1964 | + } |
|
1885 | 1965 | |
1886 | 1966 | echo ' |
1887 | 1967 | rebuildRuleDesc();'; |
1888 | 1968 | |
1889 | 1969 | // If this isn't a new rule and we have JS enabled remove the JS compatibility stuff. |
1890 | - if ($context['rid']) |
|
1891 | - echo ' |
|
1970 | + if ($context['rid']) { |
|
1971 | + echo ' |
|
1892 | 1972 | document.getElementById("removeonjs1").style.display = "none"; |
1893 | 1973 | document.getElementById("removeonjs2").style.display = "none";'; |
1974 | + } |
|
1894 | 1975 | |
1895 | 1976 | echo ' |
1896 | 1977 | document.getElementById("addonjs1").style.display = ""; |
@@ -1918,12 +1999,12 @@ discard block |
||
1918 | 1999 | </div>'; |
1919 | 2000 | |
1920 | 2001 | // No drafts? Just show an informative message. |
1921 | - if (empty($context['drafts'])) |
|
1922 | - echo ' |
|
2002 | + if (empty($context['drafts'])) { |
|
2003 | + echo ' |
|
1923 | 2004 | <div class="windowbg2 centertext"> |
1924 | 2005 | ', $txt['draft_none'], ' |
1925 | 2006 | </div>'; |
1926 | - else |
|
2007 | + } else |
|
1927 | 2008 | { |
1928 | 2009 | // For every draft to be displayed, give it its own div, and show the important details of the draft. |
1929 | 2010 | foreach ($context['drafts'] as $draft) |