@@ -19,8 +19,9 @@ discard block |
||
19 | 19 | * @version 2.1 Beta 4 |
20 | 20 | */ |
21 | 21 | |
22 | -if (!defined('SMF')) |
|
22 | +if (!defined('SMF')) { |
|
23 | 23 | die('No direct access...'); |
24 | +} |
|
24 | 25 | |
25 | 26 | /** |
26 | 27 | * Class gif_lzw_compression |
@@ -52,13 +53,15 @@ discard block |
||
52 | 53 | |
53 | 54 | $this->LZWCommand($data, true); |
54 | 55 | |
55 | - while (($iIndex = $this->LZWCommand($data, false)) >= 0) |
|
56 | - $ret .= chr($iIndex); |
|
56 | + while (($iIndex = $this->LZWCommand($data, false)) >= 0) { |
|
57 | + $ret .= chr($iIndex); |
|
58 | + } |
|
57 | 59 | |
58 | 60 | $datLen = $stLen - strlen($data); |
59 | 61 | |
60 | - if ($iIndex != -2) |
|
61 | - return false; |
|
62 | + if ($iIndex != -2) { |
|
63 | + return false; |
|
64 | + } |
|
62 | 65 | |
63 | 66 | return $ret; |
64 | 67 | } |
@@ -140,8 +143,9 @@ discard block |
||
140 | 143 | return $this->FirstCode; |
141 | 144 | } |
142 | 145 | |
143 | - if ($Code == $this->EndCode) |
|
144 | - return -2; |
|
146 | + if ($Code == $this->EndCode) { |
|
147 | + return -2; |
|
148 | + } |
|
145 | 149 | |
146 | 150 | $InCode = $Code; |
147 | 151 | if ($Code >= $this->MaxCode) |
@@ -156,8 +160,10 @@ discard block |
||
156 | 160 | $this->Stack[$this->sp] = $this->Vals[$Code]; |
157 | 161 | $this->sp++; |
158 | 162 | |
159 | - if ($Code == $this->Next[$Code]) // Circular table entry, big GIF Error! |
|
163 | + if ($Code == $this->Next[$Code]) { |
|
164 | + // Circular table entry, big GIF Error! |
|
160 | 165 | return -1; |
166 | + } |
|
161 | 167 | |
162 | 168 | $Code = $this->Next[$Code]; |
163 | 169 | } |
@@ -207,8 +213,9 @@ discard block |
||
207 | 213 | if ($this->Done) |
208 | 214 | { |
209 | 215 | // Ran off the end of my bits... |
210 | - if ($this->CurBit >= $this->LastBit) |
|
211 | - return 0; |
|
216 | + if ($this->CurBit >= $this->LastBit) { |
|
217 | + return 0; |
|
218 | + } |
|
212 | 219 | |
213 | 220 | return -1; |
214 | 221 | } |
@@ -221,13 +228,14 @@ discard block |
||
221 | 228 | |
222 | 229 | if ($count) |
223 | 230 | { |
224 | - for ($i = 0; $i < $count; $i++) |
|
225 | - $this->Buf[2 + $i] = ord($data{$i}); |
|
231 | + for ($i = 0; $i < $count; $i++) { |
|
232 | + $this->Buf[2 + $i] = ord($data{$i}); |
|
233 | + } |
|
226 | 234 | |
227 | 235 | $data = substr($data, $count); |
236 | + } else { |
|
237 | + $this->Done = 1; |
|
228 | 238 | } |
229 | - else |
|
230 | - $this->Done = 1; |
|
231 | 239 | |
232 | 240 | $this->LastByte = 2 + $count; |
233 | 241 | $this->CurBit = ($this->CurBit - $this->LastBit) + 16; |
@@ -235,8 +243,9 @@ discard block |
||
235 | 243 | } |
236 | 244 | |
237 | 245 | $iRet = 0; |
238 | - for ($i = $this->CurBit, $j = 0; $j < $this->CodeSize; $i++, $j++) |
|
239 | - $iRet |= (($this->Buf[intval($i / 8)] & (1 << ($i % 8))) != 0) << $j; |
|
246 | + for ($i = $this->CurBit, $j = 0; $j < $this->CodeSize; $i++, $j++) { |
|
247 | + $iRet |= (($this->Buf[intval($i / 8)] & (1 << ($i % 8))) != 0) << $j; |
|
248 | + } |
|
240 | 249 | |
241 | 250 | $this->CurBit += $this->CodeSize; |
242 | 251 | return $iRet; |
@@ -261,8 +270,9 @@ discard block |
||
261 | 270 | for ($i = 0; $i < $num; $i++) |
262 | 271 | { |
263 | 272 | $rgb = substr($lpData, $i * 3, 3); |
264 | - if (strlen($rgb) < 3) |
|
265 | - return false; |
|
273 | + if (strlen($rgb) < 3) { |
|
274 | + return false; |
|
275 | + } |
|
266 | 276 | |
267 | 277 | $this->m_arColors[] = (ord($rgb[2]) << 16) + (ord($rgb[1]) << 8) + ord($rgb[0]); |
268 | 278 | $this->m_nColors++; |
@@ -329,13 +339,15 @@ discard block |
||
329 | 339 | $hdrLen = 0; |
330 | 340 | |
331 | 341 | $this->m_lpVer = substr($lpData, 0, 6); |
332 | - if (($this->m_lpVer != 'GIF87a') && ($this->m_lpVer != 'GIF89a')) |
|
333 | - return false; |
|
342 | + if (($this->m_lpVer != 'GIF87a') && ($this->m_lpVer != 'GIF89a')) { |
|
343 | + return false; |
|
344 | + } |
|
334 | 345 | |
335 | 346 | list ($this->m_nWidth, $this->m_nHeight) = array_values(unpack('v2', substr($lpData, 6, 4))); |
336 | 347 | |
337 | - if (!$this->m_nWidth || !$this->m_nHeight) |
|
338 | - return false; |
|
348 | + if (!$this->m_nWidth || !$this->m_nHeight) { |
|
349 | + return false; |
|
350 | + } |
|
339 | 351 | |
340 | 352 | $b = ord(substr($lpData, 10, 1)); |
341 | 353 | $this->m_bGlobalClr = ($b & 0x80) ? true : false; |
@@ -349,8 +361,9 @@ discard block |
||
349 | 361 | if ($this->m_bGlobalClr) |
350 | 362 | { |
351 | 363 | $this->m_colorTable = new gif_color_table(); |
352 | - if (!$this->m_colorTable->load(substr($lpData, $hdrLen), $this->m_nTableSize)) |
|
353 | - return false; |
|
364 | + if (!$this->m_colorTable->load(substr($lpData, $hdrLen), $this->m_nTableSize)) { |
|
365 | + return false; |
|
366 | + } |
|
354 | 367 | |
355 | 368 | $hdrLen += 3 * $this->m_nTableSize; |
356 | 369 | } |
@@ -377,8 +390,9 @@ discard block |
||
377 | 390 | // Get the width/height/etc. from the header. |
378 | 391 | list ($this->m_nLeft, $this->m_nTop, $this->m_nWidth, $this->m_nHeight) = array_values(unpack('v4', substr($lpData, 0, 8))); |
379 | 392 | |
380 | - if (!$this->m_nWidth || !$this->m_nHeight) |
|
381 | - return false; |
|
393 | + if (!$this->m_nWidth || !$this->m_nHeight) { |
|
394 | + return false; |
|
395 | + } |
|
382 | 396 | |
383 | 397 | $b = ord($lpData[8]); |
384 | 398 | $this->m_bLocalClr = ($b & 0x80) ? true : false; |
@@ -390,8 +404,9 @@ discard block |
||
390 | 404 | if ($this->m_bLocalClr) |
391 | 405 | { |
392 | 406 | $this->m_colorTable = new gif_color_table(); |
393 | - if (!$this->m_colorTable->load(substr($lpData, $hdrLen), $this->m_nTableSize)) |
|
394 | - return false; |
|
407 | + if (!$this->m_colorTable->load(substr($lpData, $hdrLen), $this->m_nTableSize)) { |
|
408 | + return false; |
|
409 | + } |
|
395 | 410 | |
396 | 411 | $hdrLen += 3 * $this->m_nTableSize; |
397 | 412 | } |
@@ -427,8 +442,9 @@ discard block |
||
427 | 442 | // Extension... |
428 | 443 | case 0x21: |
429 | 444 | $len = 0; |
430 | - if (!$this->skipExt($data, $len)) |
|
431 | - return false; |
|
445 | + if (!$this->skipExt($data, $len)) { |
|
446 | + return false; |
|
447 | + } |
|
432 | 448 | |
433 | 449 | $datLen += $len; |
434 | 450 | break; |
@@ -437,21 +453,24 @@ discard block |
||
437 | 453 | case 0x2C: |
438 | 454 | // Load the header and color table. |
439 | 455 | $len = 0; |
440 | - if (!$this->m_gih->load($data, $len)) |
|
441 | - return false; |
|
456 | + if (!$this->m_gih->load($data, $len)) { |
|
457 | + return false; |
|
458 | + } |
|
442 | 459 | |
443 | 460 | $data = substr($data, $len); |
444 | 461 | $datLen += $len; |
445 | 462 | |
446 | 463 | // Decompress the data, and ride on home ;). |
447 | 464 | $len = 0; |
448 | - if (!($this->m_data = $this->m_lzw->decompress($data, $len))) |
|
449 | - return false; |
|
465 | + if (!($this->m_data = $this->m_lzw->decompress($data, $len))) { |
|
466 | + return false; |
|
467 | + } |
|
450 | 468 | |
451 | 469 | $datLen += $len; |
452 | 470 | |
453 | - if ($this->m_gih->m_bInterlace) |
|
454 | - $this->deInterlace(); |
|
471 | + if ($this->m_gih->m_bInterlace) { |
|
472 | + $this->deInterlace(); |
|
473 | + } |
|
455 | 474 | |
456 | 475 | return true; |
457 | 476 | |
@@ -571,17 +590,20 @@ discard block |
||
571 | 590 | |
572 | 591 | public function loadFile($filename, $iIndex) |
573 | 592 | { |
574 | - if ($iIndex < 0) |
|
575 | - return false; |
|
593 | + if ($iIndex < 0) { |
|
594 | + return false; |
|
595 | + } |
|
576 | 596 | |
577 | 597 | $this->data = @file_get_contents($filename); |
578 | - if ($this->data === false) |
|
579 | - return false; |
|
598 | + if ($this->data === false) { |
|
599 | + return false; |
|
600 | + } |
|
580 | 601 | |
581 | 602 | // Tell the header to load up.... |
582 | 603 | $len = 0; |
583 | - if (!$this->header->load($this->data, $len)) |
|
584 | - return false; |
|
604 | + if (!$this->header->load($this->data, $len)) { |
|
605 | + return false; |
|
606 | + } |
|
585 | 607 | |
586 | 608 | $this->data = substr($this->data, $len); |
587 | 609 | |
@@ -589,8 +611,9 @@ discard block |
||
589 | 611 | for ($j = 0; $j <= $iIndex; $j++) |
590 | 612 | { |
591 | 613 | $imgLen = 0; |
592 | - if (!$this->image->load($this->data, $imgLen)) |
|
593 | - return false; |
|
614 | + if (!$this->image->load($this->data, $imgLen)) { |
|
615 | + return false; |
|
616 | + } |
|
594 | 617 | |
595 | 618 | $this->data = substr($this->data, $imgLen); |
596 | 619 | } |
@@ -601,8 +624,9 @@ discard block |
||
601 | 624 | |
602 | 625 | public function get_png_data($background_color) |
603 | 626 | { |
604 | - if (!$this->loaded) |
|
605 | - return false; |
|
627 | + if (!$this->loaded) { |
|
628 | + return false; |
|
629 | + } |
|
606 | 630 | |
607 | 631 | // Prepare the color table. |
608 | 632 | if ($this->image->m_gih->m_bLocalClr) |
@@ -610,25 +634,26 @@ discard block |
||
610 | 634 | $colors = $this->image->m_gih->m_nTableSize; |
611 | 635 | $pal = $this->image->m_gih->m_colorTable->toString(); |
612 | 636 | |
613 | - if ($background_color != -1) |
|
614 | - $background_color = $this->image->m_gih->m_colorTable->colorIndex($background_color); |
|
615 | - } |
|
616 | - elseif ($this->header->m_bGlobalClr) |
|
637 | + if ($background_color != -1) { |
|
638 | + $background_color = $this->image->m_gih->m_colorTable->colorIndex($background_color); |
|
639 | + } |
|
640 | + } elseif ($this->header->m_bGlobalClr) |
|
617 | 641 | { |
618 | 642 | $colors = $this->header->m_nTableSize; |
619 | 643 | $pal = $this->header->m_colorTable->toString(); |
620 | 644 | |
621 | - if ($background_color != -1) |
|
622 | - $background_color = $this->header->m_colorTable->colorIndex($background_color); |
|
623 | - } |
|
624 | - else |
|
645 | + if ($background_color != -1) { |
|
646 | + $background_color = $this->header->m_colorTable->colorIndex($background_color); |
|
647 | + } |
|
648 | + } else |
|
625 | 649 | { |
626 | 650 | $colors = 0; |
627 | 651 | $background_color = -1; |
628 | 652 | } |
629 | 653 | |
630 | - if ($background_color == -1) |
|
631 | - $background_color = $this->header->m_nBgColor; |
|
654 | + if ($background_color == -1) { |
|
655 | + $background_color = $this->header->m_nBgColor; |
|
656 | + } |
|
632 | 657 | |
633 | 658 | $data = &$this->image->m_data; |
634 | 659 | $header = &$this->image->m_gih; |
@@ -644,11 +669,13 @@ discard block |
||
644 | 669 | for ($x = 0; $x < $this->header->m_nWidth; $x++, $i++) |
645 | 670 | { |
646 | 671 | // Is this in the proper range? If so, get the specific pixel data... |
647 | - if ($x >= $header->m_nLeft && $y >= $header->m_nTop && $x < ($header->m_nLeft + $header->m_nWidth) && $y < ($header->m_nTop + $header->m_nHeight)) |
|
648 | - $bmp .= $data{$i}; |
|
672 | + if ($x >= $header->m_nLeft && $y >= $header->m_nTop && $x < ($header->m_nLeft + $header->m_nWidth) && $y < ($header->m_nTop + $header->m_nHeight)) { |
|
673 | + $bmp .= $data{$i}; |
|
674 | + } |
|
649 | 675 | // Otherwise, this is background... |
650 | - else |
|
651 | - $bmp .= chr($background_color); |
|
676 | + else { |
|
677 | + $bmp .= chr($background_color); |
|
678 | + } |
|
652 | 679 | } |
653 | 680 | } |
654 | 681 | |
@@ -677,8 +704,9 @@ discard block |
||
677 | 704 | $tmp = 'tRNS'; |
678 | 705 | |
679 | 706 | // Stick each color on - full transparency or none. |
680 | - for ($i = 0; $i < $colors; $i++) |
|
681 | - $tmp .= $i == $this->image->m_nTrans ? "\x00" : "\xFF"; |
|
707 | + for ($i = 0; $i < $colors; $i++) { |
|
708 | + $tmp .= $i == $this->image->m_nTrans ? "\x00" : "\xFF"; |
|
709 | + } |
|
682 | 710 | |
683 | 711 | $out .= $tmp . pack('N', smf_crc32($tmp)); |
684 | 712 | } |
@@ -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 | * Our Cache API class |
@@ -34,8 +35,9 @@ discard block |
||
34 | 35 | |
35 | 36 | $supported = class_exists('memcache'); |
36 | 37 | |
37 | - if ($test) |
|
38 | - return $supported; |
|
38 | + if ($test) { |
|
39 | + return $supported; |
|
40 | + } |
|
39 | 41 | return parent::isSupported() && $supported && !empty($cache_memcached); |
40 | 42 | } |
41 | 43 | |
@@ -61,9 +63,9 @@ discard block |
||
61 | 63 | $server = trim($servers[array_rand($servers)]); |
62 | 64 | |
63 | 65 | // Normal host names do not contain slashes, while e.g. unix sockets do. Assume alternative transport pipe with port 0. |
64 | - if (strpos($server,'/') !== false) |
|
65 | - $host = $server; |
|
66 | - else |
|
66 | + if (strpos($server,'/') !== false) { |
|
67 | + $host = $server; |
|
68 | + } else |
|
67 | 69 | { |
68 | 70 | $server = explode(':', $server); |
69 | 71 | $host = $server[0]; |
@@ -71,10 +73,11 @@ discard block |
||
71 | 73 | } |
72 | 74 | |
73 | 75 | // Don't wait too long: yes, we want the server, but we might be able to run the query faster! |
74 | - if (empty($db_persist)) |
|
75 | - $connected = $this->memcache->connect($host, $port); |
|
76 | - else |
|
77 | - $connected = $this->memcache->pconnect($host, $port); |
|
76 | + if (empty($db_persist)) { |
|
77 | + $connected = $this->memcache->connect($host, $port); |
|
78 | + } else { |
|
79 | + $connected = $this->memcache->pconnect($host, $port); |
|
80 | + } |
|
78 | 81 | } |
79 | 82 | |
80 | 83 | return $connected; |
@@ -90,8 +93,9 @@ discard block |
||
90 | 93 | $value = $this->memcache->get($key); |
91 | 94 | |
92 | 95 | // $value should return either data or false (from failure, key not found or empty array). |
93 | - if ($value === false) |
|
94 | - return null; |
|
96 | + if ($value === false) { |
|
97 | + return null; |
|
98 | + } |
|
95 | 99 | return $value; |
96 | 100 | } |
97 | 101 | |
@@ -132,8 +136,9 @@ discard block |
||
132 | 136 | $config_vars[] = $txt['cache_memcache_settings']; |
133 | 137 | $config_vars[] = array('cache_memcached', $txt['cache_memcache_servers'], 'file', 'text', 0, 'cache_memcached', 'postinput' => '<br /><div class="smalltext"><em>' . $txt['cache_memcache_servers_subtext'] . '</em></div>'); |
134 | 138 | |
135 | - if (!isset($context['settings_post_javascript'])) |
|
136 | - $context['settings_post_javascript'] = ''; |
|
139 | + if (!isset($context['settings_post_javascript'])) { |
|
140 | + $context['settings_post_javascript'] = ''; |
|
141 | + } |
|
137 | 142 | |
138 | 143 | $context['settings_post_javascript'] .= ' |
139 | 144 | $("#cache_accelerator").change(function (e) { |
@@ -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 handler and designator for AJAX stuff - jumpto, message icons and previews |
@@ -32,8 +33,9 @@ discard block |
||
32 | 33 | // Easy adding of sub actions. |
33 | 34 | call_integration_hook('integrate_XMLhttpMain_subActions', array(&$subActions)); |
34 | 35 | |
35 | - if (!isset($_REQUEST['sa'], $subActions[$_REQUEST['sa']])) |
|
36 | - fatal_lang_error('no_access', false); |
|
36 | + if (!isset($_REQUEST['sa'], $subActions[$_REQUEST['sa']])) { |
|
37 | + fatal_lang_error('no_access', false); |
|
38 | + } |
|
37 | 39 | |
38 | 40 | call_helper($subActions[$_REQUEST['sa']]); |
39 | 41 | } |
@@ -57,8 +59,9 @@ discard block |
||
57 | 59 | foreach ($context['jump_to'] as $id_cat => $cat) |
58 | 60 | { |
59 | 61 | $context['jump_to'][$id_cat]['name'] = un_htmlspecialchars(strip_tags($cat['name'])); |
60 | - foreach ($cat['boards'] as $id_board => $board) |
|
61 | - $context['jump_to'][$id_cat]['boards'][$id_board]['name'] = un_htmlspecialchars(strip_tags($board['name'])); |
|
62 | + foreach ($cat['boards'] as $id_board => $board) { |
|
63 | + $context['jump_to'][$id_cat]['boards'][$id_board]['name'] = un_htmlspecialchars(strip_tags($board['name'])); |
|
64 | + } |
|
62 | 65 | } |
63 | 66 | |
64 | 67 | $context['sub_template'] = 'jump_to'; |
@@ -95,8 +98,9 @@ discard block |
||
95 | 98 | |
96 | 99 | $context['sub_template'] = 'generic_xml'; |
97 | 100 | |
98 | - if (!isset($_POST['item']) || !in_array($_POST['item'], $items)) |
|
99 | - return false; |
|
101 | + if (!isset($_POST['item']) || !in_array($_POST['item'], $items)) { |
|
102 | + return false; |
|
103 | + } |
|
100 | 104 | |
101 | 105 | $_POST['item'](); |
102 | 106 | } |
@@ -112,10 +116,11 @@ discard block |
||
112 | 116 | |
113 | 117 | $errors = array(); |
114 | 118 | $news = !isset($_POST['news']) ? '' : $smcFunc['htmlspecialchars']($_POST['news'], ENT_QUOTES); |
115 | - if (empty($news)) |
|
116 | - $errors[] = array('value' => 'no_news'); |
|
117 | - else |
|
118 | - preparsecode($news); |
|
119 | + if (empty($news)) { |
|
120 | + $errors[] = array('value' => 'no_news'); |
|
121 | + } else { |
|
122 | + preparsecode($news); |
|
123 | + } |
|
119 | 124 | |
120 | 125 | $context['xml_data'] = array( |
121 | 126 | 'news' => array( |
@@ -148,10 +153,12 @@ discard block |
||
148 | 153 | $context['send_pm'] = !empty($_POST['send_pm']) ? 1 : 0; |
149 | 154 | $context['send_html'] = !empty($_POST['send_html']) ? 1 : 0; |
150 | 155 | |
151 | - if (empty($_POST['subject'])) |
|
152 | - $context['post_error']['messages'][] = $txt['error_no_subject']; |
|
153 | - if (empty($_POST['message'])) |
|
154 | - $context['post_error']['messages'][] = $txt['error_no_message']; |
|
156 | + if (empty($_POST['subject'])) { |
|
157 | + $context['post_error']['messages'][] = $txt['error_no_subject']; |
|
158 | + } |
|
159 | + if (empty($_POST['message'])) { |
|
160 | + $context['post_error']['messages'][] = $txt['error_no_message']; |
|
161 | + } |
|
155 | 162 | |
156 | 163 | prepareMailingForPreview(); |
157 | 164 | |
@@ -196,38 +203,41 @@ discard block |
||
196 | 203 | $preview_signature = !empty($_POST['signature']) ? $_POST['signature'] : $txt['no_signature_preview']; |
197 | 204 | $validation = profileValidateSignature($preview_signature); |
198 | 205 | |
199 | - if ($validation !== true && $validation !== false) |
|
200 | - $errors[] = array('value' => $txt['profile_error_' . $validation], 'attributes' => array('type' => 'error')); |
|
206 | + if ($validation !== true && $validation !== false) { |
|
207 | + $errors[] = array('value' => $txt['profile_error_' . $validation], 'attributes' => array('type' => 'error')); |
|
208 | + } |
|
201 | 209 | |
202 | 210 | censorText($preview_signature); |
203 | 211 | $preview_signature = parse_bbc($preview_signature, true, 'sig' . $user); |
204 | - } |
|
205 | - elseif (!$can_change) |
|
212 | + } elseif (!$can_change) |
|
206 | 213 | { |
207 | - if ($is_owner) |
|
208 | - $errors[] = array('value' => $txt['cannot_profile_extra_own'], 'attributes' => array('type' => 'error')); |
|
209 | - else |
|
210 | - $errors[] = array('value' => $txt['cannot_profile_extra_any'], 'attributes' => array('type' => 'error')); |
|
214 | + if ($is_owner) { |
|
215 | + $errors[] = array('value' => $txt['cannot_profile_extra_own'], 'attributes' => array('type' => 'error')); |
|
216 | + } else { |
|
217 | + $errors[] = array('value' => $txt['cannot_profile_extra_any'], 'attributes' => array('type' => 'error')); |
|
218 | + } |
|
219 | + } else { |
|
220 | + $errors[] = array('value' => $txt['no_user_selected'], 'attributes' => array('type' => 'error')); |
|
211 | 221 | } |
212 | - else |
|
213 | - $errors[] = array('value' => $txt['no_user_selected'], 'attributes' => array('type' => 'error')); |
|
214 | 222 | |
215 | 223 | $context['xml_data']['signatures'] = array( |
216 | 224 | 'identifier' => 'signature', |
217 | 225 | 'children' => array() |
218 | 226 | ); |
219 | - if (isset($current_signature)) |
|
220 | - $context['xml_data']['signatures']['children'][] = array( |
|
227 | + if (isset($current_signature)) { |
|
228 | + $context['xml_data']['signatures']['children'][] = array( |
|
221 | 229 | 'value' => $current_signature, |
222 | 230 | 'attributes' => array('type' => 'current'), |
223 | 231 | ); |
224 | - if (isset($preview_signature)) |
|
225 | - $context['xml_data']['signatures']['children'][] = array( |
|
232 | + } |
|
233 | + if (isset($preview_signature)) { |
|
234 | + $context['xml_data']['signatures']['children'][] = array( |
|
226 | 235 | 'value' => $preview_signature, |
227 | 236 | 'attributes' => array('type' => 'preview'), |
228 | 237 | ); |
229 | - if (!empty($errors)) |
|
230 | - $context['xml_data']['errors'] = array( |
|
238 | + } |
|
239 | + if (!empty($errors)) { |
|
240 | + $context['xml_data']['errors'] = array( |
|
231 | 241 | 'identifier' => 'error', |
232 | 242 | 'children' => array_merge( |
233 | 243 | array( |
@@ -239,7 +249,8 @@ discard block |
||
239 | 249 | $errors |
240 | 250 | ), |
241 | 251 | ); |
242 | -} |
|
252 | + } |
|
253 | + } |
|
243 | 254 | |
244 | 255 | /** |
245 | 256 | * Handles previewing user warnings |
@@ -259,15 +270,17 @@ discard block |
||
259 | 270 | $context['preview_subject'] = !empty($_POST['title']) ? trim($smcFunc['htmlspecialchars']($_POST['title'])) : ''; |
260 | 271 | if (isset($_POST['issuing'])) |
261 | 272 | { |
262 | - if (empty($_POST['title']) || empty($_POST['body'])) |
|
263 | - $context['post_error']['messages'][] = $txt['warning_notify_blank']; |
|
264 | - } |
|
265 | - else |
|
273 | + if (empty($_POST['title']) || empty($_POST['body'])) { |
|
274 | + $context['post_error']['messages'][] = $txt['warning_notify_blank']; |
|
275 | + } |
|
276 | + } else |
|
266 | 277 | { |
267 | - if (empty($_POST['title'])) |
|
268 | - $context['post_error']['messages'][] = $txt['mc_warning_template_error_no_title']; |
|
269 | - if (empty($_POST['body'])) |
|
270 | - $context['post_error']['messages'][] = $txt['mc_warning_template_error_no_body']; |
|
278 | + if (empty($_POST['title'])) { |
|
279 | + $context['post_error']['messages'][] = $txt['mc_warning_template_error_no_title']; |
|
280 | + } |
|
281 | + if (empty($_POST['body'])) { |
|
282 | + $context['post_error']['messages'][] = $txt['mc_warning_template_error_no_body']; |
|
283 | + } |
|
271 | 284 | // Add in few replacements. |
272 | 285 | /** |
273 | 286 | * These are the defaults: |
@@ -298,9 +311,9 @@ discard block |
||
298 | 311 | $warning_body = parse_bbc($warning_body, true); |
299 | 312 | } |
300 | 313 | $context['preview_message'] = $warning_body; |
314 | + } else { |
|
315 | + $context['post_error']['messages'][] = array('value' => $txt['cannot_issue_warning'], 'attributes' => array('type' => 'error')); |
|
301 | 316 | } |
302 | - else |
|
303 | - $context['post_error']['messages'][] = array('value' => $txt['cannot_issue_warning'], 'attributes' => array('type' => 'error')); |
|
304 | 317 | |
305 | 318 | $context['sub_template'] = 'warning'; |
306 | 319 | } |
@@ -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 | * Edit the position and properties of a category. |
@@ -42,8 +43,9 @@ discard block |
||
42 | 43 | $cat_order = array(); |
43 | 44 | |
44 | 45 | // Setting 'move_after' to '0' moves the category to the top. |
45 | - if ($catOptions['move_after'] == 0) |
|
46 | - $cats[] = $category_id; |
|
46 | + if ($catOptions['move_after'] == 0) { |
|
47 | + $cats[] = $category_id; |
|
48 | + } |
|
47 | 49 | |
48 | 50 | // Grab the categories sorted by cat_order. |
49 | 51 | $request = $smcFunc['db_query']('', ' |
@@ -55,17 +57,19 @@ discard block |
||
55 | 57 | ); |
56 | 58 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
57 | 59 | { |
58 | - if ($row['id_cat'] != $category_id) |
|
59 | - $cats[] = $row['id_cat']; |
|
60 | - if ($row['id_cat'] == $catOptions['move_after']) |
|
61 | - $cats[] = $category_id; |
|
60 | + if ($row['id_cat'] != $category_id) { |
|
61 | + $cats[] = $row['id_cat']; |
|
62 | + } |
|
63 | + if ($row['id_cat'] == $catOptions['move_after']) { |
|
64 | + $cats[] = $category_id; |
|
65 | + } |
|
62 | 66 | $cat_order[$row['id_cat']] = $row['cat_order']; |
63 | 67 | } |
64 | 68 | $smcFunc['db_free_result']($request); |
65 | 69 | |
66 | 70 | // Set the new order for the categories. |
67 | - foreach ($cats as $index => $cat) |
|
68 | - if ($index != $cat_order[$cat]) |
|
71 | + foreach ($cats as $index => $cat) { |
|
72 | + if ($index != $cat_order[$cat]) |
|
69 | 73 | $smcFunc['db_query']('', ' |
70 | 74 | UPDATE {db_prefix}categories |
71 | 75 | SET cat_order = {int:new_order} |
@@ -75,6 +79,7 @@ discard block |
||
75 | 79 | 'current_category' => $cat, |
76 | 80 | ) |
77 | 81 | ); |
82 | + } |
|
78 | 83 | |
79 | 84 | // If the category order changed, so did the board order. |
80 | 85 | require_once($sourcedir . '/Subs-Boards.php'); |
@@ -117,8 +122,9 @@ discard block |
||
117 | 122 | )) |
118 | 123 | ); |
119 | 124 | |
120 | - if (empty($catOptions['dont_log'])) |
|
121 | - logAction('edit_cat', array('catname' => isset($catOptions['cat_name']) ? $catOptions['cat_name'] : $category_id), 'admin'); |
|
125 | + if (empty($catOptions['dont_log'])) { |
|
126 | + logAction('edit_cat', array('catname' => isset($catOptions['cat_name']) ? $catOptions['cat_name'] : $category_id), 'admin'); |
|
127 | + } |
|
122 | 128 | } |
123 | 129 | } |
124 | 130 | |
@@ -135,16 +141,20 @@ discard block |
||
135 | 141 | global $smcFunc; |
136 | 142 | |
137 | 143 | // Check required values. |
138 | - if (!isset($catOptions['cat_name']) || trim($catOptions['cat_name']) == '') |
|
139 | - trigger_error('createCategory(): A category name is required', E_USER_ERROR); |
|
144 | + if (!isset($catOptions['cat_name']) || trim($catOptions['cat_name']) == '') { |
|
145 | + trigger_error('createCategory(): A category name is required', E_USER_ERROR); |
|
146 | + } |
|
140 | 147 | |
141 | 148 | // Set default values. |
142 | - if (!isset($catOptions['cat_desc'])) |
|
143 | - $catOptions['cat_desc'] = ''; |
|
144 | - if (!isset($catOptions['move_after'])) |
|
145 | - $catOptions['move_after'] = 0; |
|
146 | - if (!isset($catOptions['is_collapsible'])) |
|
147 | - $catOptions['is_collapsible'] = true; |
|
149 | + if (!isset($catOptions['cat_desc'])) { |
|
150 | + $catOptions['cat_desc'] = ''; |
|
151 | + } |
|
152 | + if (!isset($catOptions['move_after'])) { |
|
153 | + $catOptions['move_after'] = 0; |
|
154 | + } |
|
155 | + if (!isset($catOptions['is_collapsible'])) { |
|
156 | + $catOptions['is_collapsible'] = true; |
|
157 | + } |
|
148 | 158 | // Don't log an edit right after. |
149 | 159 | $catOptions['dont_log'] = true; |
150 | 160 | |
@@ -210,21 +220,24 @@ discard block |
||
210 | 220 | ) |
211 | 221 | ); |
212 | 222 | $boards_inside = array(); |
213 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
214 | - $boards_inside[] = $row['id_board']; |
|
223 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
224 | + $boards_inside[] = $row['id_board']; |
|
225 | + } |
|
215 | 226 | $smcFunc['db_free_result']($request); |
216 | 227 | |
217 | - if (!empty($boards_inside)) |
|
218 | - deleteBoards($boards_inside, null); |
|
228 | + if (!empty($boards_inside)) { |
|
229 | + deleteBoards($boards_inside, null); |
|
230 | + } |
|
219 | 231 | } |
220 | 232 | |
221 | 233 | // Make sure the safe category is really safe. |
222 | - elseif (in_array($moveBoardsTo, $categories)) |
|
223 | - trigger_error('deleteCategories(): You cannot move the boards to a category that\'s being deleted', E_USER_ERROR); |
|
234 | + elseif (in_array($moveBoardsTo, $categories)) { |
|
235 | + trigger_error('deleteCategories(): You cannot move the boards to a category that\'s being deleted', E_USER_ERROR); |
|
236 | + } |
|
224 | 237 | |
225 | 238 | // Move the boards inside the categories to a safe category. |
226 | - else |
|
227 | - $smcFunc['db_query']('', ' |
|
239 | + else { |
|
240 | + $smcFunc['db_query']('', ' |
|
228 | 241 | UPDATE {db_prefix}boards |
229 | 242 | SET id_cat = {int:new_parent_cat} |
230 | 243 | WHERE id_cat IN ({array_int:category_list})', |
@@ -233,6 +246,7 @@ discard block |
||
233 | 246 | 'new_parent_cat' => $moveBoardsTo, |
234 | 247 | ) |
235 | 248 | ); |
249 | + } |
|
236 | 250 | |
237 | 251 | // Do the deletion of the category itself |
238 | 252 | $smcFunc['db_query']('', ' |
@@ -244,8 +258,9 @@ discard block |
||
244 | 258 | ); |
245 | 259 | |
246 | 260 | // Log what we've done. |
247 | - foreach ($categories as $category) |
|
248 | - logAction('delete_cat', array('catname' => $cat_tree[$category]['node']['name']), 'admin'); |
|
261 | + foreach ($categories as $category) { |
|
262 | + logAction('delete_cat', array('catname' => $cat_tree[$category]['node']['name']), 'admin'); |
|
263 | + } |
|
249 | 264 | |
250 | 265 | // Get all boards back into the right order. |
251 | 266 | reorderBoards(); |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 4 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * Show the list of topics in this board, along with any child boards. |
@@ -56,8 +57,9 @@ discard block |
||
56 | 57 | |
57 | 58 | $context['name'] = $board_info['name']; |
58 | 59 | $context['description'] = $board_info['description']; |
59 | - if (!empty($board_info['description'])) |
|
60 | - $context['meta_description'] = strip_tags($board_info['description']); |
|
60 | + if (!empty($board_info['description'])) { |
|
61 | + $context['meta_description'] = strip_tags($board_info['description']); |
|
62 | + } |
|
61 | 63 | |
62 | 64 | // How many topics do we have in total? |
63 | 65 | $board_info['total_topics'] = allowedTo('approve_posts') ? $board_info['num_topics'] + $board_info['unapproved_topics'] : $board_info['num_topics'] + $board_info['unapproved_user_topics']; |
@@ -73,12 +75,14 @@ discard block |
||
73 | 75 | $session_name = session_name(); |
74 | 76 | foreach ($_GET as $k => $v) |
75 | 77 | { |
76 | - if (!in_array($k, array('board', 'start', $session_name))) |
|
77 | - $context['robot_no_index'] = true; |
|
78 | + if (!in_array($k, array('board', 'start', $session_name))) { |
|
79 | + $context['robot_no_index'] = true; |
|
80 | + } |
|
78 | 81 | } |
79 | 82 | } |
80 | - if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) |
|
81 | - $context['robot_no_index'] = true; |
|
83 | + if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) { |
|
84 | + $context['robot_no_index'] = true; |
|
85 | + } |
|
82 | 86 | |
83 | 87 | // If we can view unapproved messages and there are some build up a list. |
84 | 88 | if (allowedTo('approve_posts') && ($board_info['unapproved_topics'] || $board_info['unapproved_posts'])) |
@@ -89,14 +93,16 @@ discard block |
||
89 | 93 | } |
90 | 94 | |
91 | 95 | // We only know these. |
92 | - if (isset($_REQUEST['sort']) && !in_array($_REQUEST['sort'], array('subject', 'starter', 'last_poster', 'replies', 'views', 'first_post', 'last_post'))) |
|
93 | - $_REQUEST['sort'] = 'last_post'; |
|
96 | + if (isset($_REQUEST['sort']) && !in_array($_REQUEST['sort'], array('subject', 'starter', 'last_poster', 'replies', 'views', 'first_post', 'last_post'))) { |
|
97 | + $_REQUEST['sort'] = 'last_post'; |
|
98 | + } |
|
94 | 99 | |
95 | 100 | // Make sure the starting place makes sense and construct the page index. |
96 | - if (isset($_REQUEST['sort'])) |
|
97 | - $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d;sort=' . $_REQUEST['sort'] . (isset($_REQUEST['desc']) ? ';desc' : ''), $_REQUEST['start'], $board_info['total_topics'], $maxindex, true); |
|
98 | - else |
|
99 | - $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d', $_REQUEST['start'], $board_info['total_topics'], $maxindex, true); |
|
101 | + if (isset($_REQUEST['sort'])) { |
|
102 | + $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d;sort=' . $_REQUEST['sort'] . (isset($_REQUEST['desc']) ? ';desc' : ''), $_REQUEST['start'], $board_info['total_topics'], $maxindex, true); |
|
103 | + } else { |
|
104 | + $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d', $_REQUEST['start'], $board_info['total_topics'], $maxindex, true); |
|
105 | + } |
|
100 | 106 | $context['start'] = &$_REQUEST['start']; |
101 | 107 | |
102 | 108 | // Set a canonical URL for this page. |
@@ -132,14 +138,16 @@ discard block |
||
132 | 138 | $context['link_moderators'] = array(); |
133 | 139 | if (!empty($board_info['moderators'])) |
134 | 140 | { |
135 | - foreach ($board_info['moderators'] as $mod) |
|
136 | - $context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>'; |
|
141 | + foreach ($board_info['moderators'] as $mod) { |
|
142 | + $context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>'; |
|
143 | + } |
|
137 | 144 | } |
138 | 145 | if (!empty($board_info['moderator_groups'])) |
139 | 146 | { |
140 | 147 | // By default just tack the moderator groups onto the end of the members |
141 | - foreach ($board_info['moderator_groups'] as $mod_group) |
|
142 | - $context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>'; |
|
148 | + foreach ($board_info['moderator_groups'] as $mod_group) { |
|
149 | + $context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>'; |
|
150 | + } |
|
143 | 151 | } |
144 | 152 | |
145 | 153 | // Now we tack the info onto the end of the linktree |
@@ -191,20 +199,24 @@ discard block |
||
191 | 199 | ); |
192 | 200 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
193 | 201 | { |
194 | - if (empty($row['id_member'])) |
|
195 | - continue; |
|
202 | + if (empty($row['id_member'])) { |
|
203 | + continue; |
|
204 | + } |
|
196 | 205 | |
197 | - if (!empty($row['online_color'])) |
|
198 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
199 | - else |
|
200 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
206 | + if (!empty($row['online_color'])) { |
|
207 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
208 | + } else { |
|
209 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
210 | + } |
|
201 | 211 | |
202 | 212 | $is_buddy = in_array($row['id_member'], $user_info['buddies']); |
203 | - if ($is_buddy) |
|
204 | - $link = '<strong>' . $link . '</strong>'; |
|
213 | + if ($is_buddy) { |
|
214 | + $link = '<strong>' . $link . '</strong>'; |
|
215 | + } |
|
205 | 216 | |
206 | - if (!empty($row['show_online']) || allowedTo('moderate_forum')) |
|
207 | - $context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
|
217 | + if (!empty($row['show_online']) || allowedTo('moderate_forum')) { |
|
218 | + $context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
|
219 | + } |
|
208 | 220 | // @todo why are we filling this array of data that are just counted (twice) and discarded? ??? |
209 | 221 | $context['view_members'][$row['log_time'] . $row['member_name']] = array( |
210 | 222 | 'id' => $row['id_member'], |
@@ -217,8 +229,9 @@ discard block |
||
217 | 229 | 'hidden' => empty($row['show_online']), |
218 | 230 | ); |
219 | 231 | |
220 | - if (empty($row['show_online'])) |
|
221 | - $context['view_num_hidden']++; |
|
232 | + if (empty($row['show_online'])) { |
|
233 | + $context['view_num_hidden']++; |
|
234 | + } |
|
222 | 235 | } |
223 | 236 | $context['view_num_guests'] = $smcFunc['db_num_rows']($request) - count($context['view_members']); |
224 | 237 | $smcFunc['db_free_result']($request); |
@@ -257,8 +270,9 @@ discard block |
||
257 | 270 | $context['sort_direction'] = $ascending ? 'up' : 'down'; |
258 | 271 | $txt['starter'] = $txt['started_by']; |
259 | 272 | |
260 | - foreach ($sort_methods as $key => $val) |
|
261 | - $context['topics_headers'][$key] = '<a href="' . $scripturl . '?board=' . $context['current_board'] . '.' . $context['start'] . ';sort=' . $key . ($context['sort_by'] == $key && $context['sort_direction'] == 'up' ? ';desc' : '') . '">' . $txt[$key] . ($context['sort_by'] == $key ? '<span class="sort sort_' . $context['sort_direction'] . '"></span>' : '') . '</a>'; |
|
273 | + foreach ($sort_methods as $key => $val) { |
|
274 | + $context['topics_headers'][$key] = '<a href="' . $scripturl . '?board=' . $context['current_board'] . '.' . $context['start'] . ';sort=' . $key . ($context['sort_by'] == $key && $context['sort_direction'] == 'up' ? ';desc' : '') . '">' . $txt[$key] . ($context['sort_by'] == $key ? '<span class="sort sort_' . $context['sort_direction'] . '"></span>' : '') . '</a>'; |
|
275 | + } |
|
262 | 276 | |
263 | 277 | // Calculate the fastest way to get the topics. |
264 | 278 | $start = (int) $_REQUEST['start']; |
@@ -268,14 +282,15 @@ discard block |
||
268 | 282 | $fake_ascending = true; |
269 | 283 | $maxindex = $board_info['total_topics'] < $start + $maxindex + 1 ? $board_info['total_topics'] - $start : $maxindex; |
270 | 284 | $start = $board_info['total_topics'] < $start + $maxindex + 1 ? 0 : $board_info['total_topics'] - $start - $maxindex; |
285 | + } else { |
|
286 | + $fake_ascending = false; |
|
271 | 287 | } |
272 | - else |
|
273 | - $fake_ascending = false; |
|
274 | 288 | |
275 | 289 | // Setup the default topic icons... |
276 | 290 | $context['icon_sources'] = array(); |
277 | - foreach ($context['stable_icons'] as $icon) |
|
278 | - $context['icon_sources'][$icon] = 'images_url'; |
|
291 | + foreach ($context['stable_icons'] as $icon) { |
|
292 | + $context['icon_sources'][$icon] = 'images_url'; |
|
293 | + } |
|
279 | 294 | |
280 | 295 | $topic_ids = array(); |
281 | 296 | $context['topics'] = array(); |
@@ -306,8 +321,9 @@ discard block |
||
306 | 321 | ) |
307 | 322 | ); |
308 | 323 | $topic_ids = array(); |
309 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
310 | - $topic_ids[] = $row['id_topic']; |
|
324 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
325 | + $topic_ids[] = $row['id_topic']; |
|
326 | + } |
|
311 | 327 | } |
312 | 328 | |
313 | 329 | // Grab the appropriate topic information... |
@@ -363,11 +379,13 @@ discard block |
||
363 | 379 | // Begin 'printing' the message index for current board. |
364 | 380 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
365 | 381 | { |
366 | - if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') |
|
367 | - continue; |
|
382 | + if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') { |
|
383 | + continue; |
|
384 | + } |
|
368 | 385 | |
369 | - if (!$pre_query) |
|
370 | - $topic_ids[] = $row['id_topic']; |
|
386 | + if (!$pre_query) { |
|
387 | + $topic_ids[] = $row['id_topic']; |
|
388 | + } |
|
371 | 389 | |
372 | 390 | // Reference the main color class. |
373 | 391 | $colorClass = 'windowbg'; |
@@ -377,8 +395,9 @@ discard block |
||
377 | 395 | { |
378 | 396 | // Limit them to $modSettings['preview_characters'] characters |
379 | 397 | $row['first_body'] = strip_tags(strtr(parse_bbc($row['first_body'], $row['first_smileys'], $row['id_first_msg']), array('<br>' => ' '))); |
380 | - if ($smcFunc['strlen']($row['first_body']) > $modSettings['preview_characters']) |
|
381 | - $row['first_body'] = $smcFunc['substr']($row['first_body'], 0, $modSettings['preview_characters']) . '...'; |
|
398 | + if ($smcFunc['strlen']($row['first_body']) > $modSettings['preview_characters']) { |
|
399 | + $row['first_body'] = $smcFunc['substr']($row['first_body'], 0, $modSettings['preview_characters']) . '...'; |
|
400 | + } |
|
382 | 401 | |
383 | 402 | // Censor the subject and message preview. |
384 | 403 | censorText($row['first_subject']); |
@@ -389,27 +408,27 @@ discard block |
||
389 | 408 | { |
390 | 409 | $row['last_subject'] = $row['first_subject']; |
391 | 410 | $row['last_body'] = $row['first_body']; |
392 | - } |
|
393 | - else |
|
411 | + } else |
|
394 | 412 | { |
395 | 413 | $row['last_body'] = strip_tags(strtr(parse_bbc($row['last_body'], $row['last_smileys'], $row['id_last_msg']), array('<br>' => ' '))); |
396 | - if ($smcFunc['strlen']($row['last_body']) > $modSettings['preview_characters']) |
|
397 | - $row['last_body'] = $smcFunc['substr']($row['last_body'], 0, $modSettings['preview_characters']) . '...'; |
|
414 | + if ($smcFunc['strlen']($row['last_body']) > $modSettings['preview_characters']) { |
|
415 | + $row['last_body'] = $smcFunc['substr']($row['last_body'], 0, $modSettings['preview_characters']) . '...'; |
|
416 | + } |
|
398 | 417 | |
399 | 418 | censorText($row['last_subject']); |
400 | 419 | censorText($row['last_body']); |
401 | 420 | } |
402 | - } |
|
403 | - else |
|
421 | + } else |
|
404 | 422 | { |
405 | 423 | $row['first_body'] = ''; |
406 | 424 | $row['last_body'] = ''; |
407 | 425 | censorText($row['first_subject']); |
408 | 426 | |
409 | - if ($row['id_first_msg'] == $row['id_last_msg']) |
|
410 | - $row['last_subject'] = $row['first_subject']; |
|
411 | - else |
|
412 | - censorText($row['last_subject']); |
|
427 | + if ($row['id_first_msg'] == $row['id_last_msg']) { |
|
428 | + $row['last_subject'] = $row['first_subject']; |
|
429 | + } else { |
|
430 | + censorText($row['last_subject']); |
|
431 | + } |
|
413 | 432 | } |
414 | 433 | |
415 | 434 | // Decide how many pages the topic should have. |
@@ -420,42 +439,50 @@ discard block |
||
420 | 439 | $pages = constructPageIndex($scripturl . '?topic=' . $row['id_topic'] . '.%1$d', $start, $row['num_replies'] + 1, $context['messages_per_page'], true, false); |
421 | 440 | |
422 | 441 | // If we can use all, show all. |
423 | - if (!empty($modSettings['enableAllMessages']) && $row['num_replies'] + 1 < $modSettings['enableAllMessages']) |
|
424 | - $pages .= ' <a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>'; |
|
442 | + if (!empty($modSettings['enableAllMessages']) && $row['num_replies'] + 1 < $modSettings['enableAllMessages']) { |
|
443 | + $pages .= ' <a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>'; |
|
444 | + } |
|
445 | + } else { |
|
446 | + $pages = ''; |
|
425 | 447 | } |
426 | - else |
|
427 | - $pages = ''; |
|
428 | 448 | |
429 | 449 | // We need to check the topic icons exist... |
430 | 450 | if (!empty($modSettings['messageIconChecks_enable'])) |
431 | 451 | { |
432 | - if (!isset($context['icon_sources'][$row['first_icon']])) |
|
433 | - $context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
434 | - if (!isset($context['icon_sources'][$row['last_icon']])) |
|
435 | - $context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
436 | - } |
|
437 | - else |
|
452 | + if (!isset($context['icon_sources'][$row['first_icon']])) { |
|
453 | + $context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
454 | + } |
|
455 | + if (!isset($context['icon_sources'][$row['last_icon']])) { |
|
456 | + $context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
457 | + } |
|
458 | + } else |
|
438 | 459 | { |
439 | - if (!isset($context['icon_sources'][$row['first_icon']])) |
|
440 | - $context['icon_sources'][$row['first_icon']] = 'images_url'; |
|
441 | - if (!isset($context['icon_sources'][$row['last_icon']])) |
|
442 | - $context['icon_sources'][$row['last_icon']] = 'images_url'; |
|
460 | + if (!isset($context['icon_sources'][$row['first_icon']])) { |
|
461 | + $context['icon_sources'][$row['first_icon']] = 'images_url'; |
|
462 | + } |
|
463 | + if (!isset($context['icon_sources'][$row['last_icon']])) { |
|
464 | + $context['icon_sources'][$row['last_icon']] = 'images_url'; |
|
465 | + } |
|
443 | 466 | } |
444 | 467 | |
445 | - if (!empty($board_info['recycle'])) |
|
446 | - $row['first_icon'] = 'recycled'; |
|
468 | + if (!empty($board_info['recycle'])) { |
|
469 | + $row['first_icon'] = 'recycled'; |
|
470 | + } |
|
447 | 471 | |
448 | 472 | // Is this topic pending approval, or does it have any posts pending approval? |
449 | - if ($context['can_approve_posts'] && $row['unapproved_posts']) |
|
450 | - $colorClass .= (!$row['approved'] ? ' approvetopic' : ' approvepost'); |
|
473 | + if ($context['can_approve_posts'] && $row['unapproved_posts']) { |
|
474 | + $colorClass .= (!$row['approved'] ? ' approvetopic' : ' approvepost'); |
|
475 | + } |
|
451 | 476 | |
452 | 477 | // Sticky topics should get a different color, too. |
453 | - if ($row['is_sticky']) |
|
454 | - $colorClass .= ' sticky'; |
|
478 | + if ($row['is_sticky']) { |
|
479 | + $colorClass .= ' sticky'; |
|
480 | + } |
|
455 | 481 | |
456 | 482 | // Locked topics get special treatment as well. |
457 | - if ($row['locked']) |
|
458 | - $colorClass .= ' locked'; |
|
483 | + if ($row['locked']) { |
|
484 | + $colorClass .= ' locked'; |
|
485 | + } |
|
459 | 486 | |
460 | 487 | // 'Print' the topic info. |
461 | 488 | $context['topics'][$row['id_topic']] = array_merge($row, array( |
@@ -536,8 +563,9 @@ discard block |
||
536 | 563 | $smcFunc['db_free_result']($result); |
537 | 564 | |
538 | 565 | // Fix the sequence of topics if they were retrieved in the wrong order. (for speed reasons...) |
539 | - if ($fake_ascending) |
|
540 | - $context['topics'] = array_reverse($context['topics'], true); |
|
566 | + if ($fake_ascending) { |
|
567 | + $context['topics'] = array_reverse($context['topics'], true); |
|
568 | + } |
|
541 | 569 | |
542 | 570 | if (!empty($modSettings['enableParticipation']) && !$user_info['is_guest'] && !empty($topic_ids)) |
543 | 571 | { |
@@ -554,8 +582,9 @@ discard block |
||
554 | 582 | 'limit' => count($topic_ids), |
555 | 583 | ) |
556 | 584 | ); |
557 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
558 | - $context['topics'][$row['id_topic']]['is_posted_in'] = true; |
|
585 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
586 | + $context['topics'][$row['id_topic']]['is_posted_in'] = true; |
|
587 | + } |
|
559 | 588 | $smcFunc['db_free_result']($result); |
560 | 589 | } |
561 | 590 | } |
@@ -580,9 +609,9 @@ discard block |
||
580 | 609 | // Can we restore topics? |
581 | 610 | $context['can_restore'] = allowedTo('move_any') && !empty($board_info['recycle']); |
582 | 611 | |
583 | - if ($user_info['is_admin'] || $modSettings['topic_move_any']) |
|
584 | - $context['can_move_any'] = true; |
|
585 | - else |
|
612 | + if ($user_info['is_admin'] || $modSettings['topic_move_any']) { |
|
613 | + $context['can_move_any'] = true; |
|
614 | + } else |
|
586 | 615 | { |
587 | 616 | // We'll use this in a minute |
588 | 617 | $boards_allowed = boardsAllowedTo('post_new'); |
@@ -609,11 +638,13 @@ discard block |
||
609 | 638 | } |
610 | 639 | |
611 | 640 | // Can we use quick moderation checkboxes? |
612 | - if ($options['display_quick_mod'] == 1) |
|
613 | - $context['can_quick_mod'] = $context['user']['is_logged'] || $context['can_approve'] || $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move'] || $context['can_merge'] || $context['can_restore']; |
|
641 | + if ($options['display_quick_mod'] == 1) { |
|
642 | + $context['can_quick_mod'] = $context['user']['is_logged'] || $context['can_approve'] || $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move'] || $context['can_merge'] || $context['can_restore']; |
|
643 | + } |
|
614 | 644 | // Or the icons? |
615 | - else |
|
616 | - $context['can_quick_mod'] = $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move']; |
|
645 | + else { |
|
646 | + $context['can_quick_mod'] = $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move']; |
|
647 | + } |
|
617 | 648 | } |
618 | 649 | |
619 | 650 | if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1) |
@@ -647,13 +678,15 @@ discard block |
||
647 | 678 | ); |
648 | 679 | |
649 | 680 | // We've seen all these boards now! |
650 | - foreach ($board_info['parent_boards'] as $k => $dummy) |
|
651 | - if (isset($_SESSION['topicseen_cache'][$k])) |
|
681 | + foreach ($board_info['parent_boards'] as $k => $dummy) { |
|
682 | + if (isset($_SESSION['topicseen_cache'][$k])) |
|
652 | 683 | unset($_SESSION['topicseen_cache'][$k]); |
684 | + } |
|
653 | 685 | } |
654 | 686 | |
655 | - if (isset($_SESSION['topicseen_cache'][$board])) |
|
656 | - unset($_SESSION['topicseen_cache'][$board]); |
|
687 | + if (isset($_SESSION['topicseen_cache'][$board])) { |
|
688 | + unset($_SESSION['topicseen_cache'][$board]); |
|
689 | + } |
|
657 | 690 | |
658 | 691 | $request = $smcFunc['db_query']('', ' |
659 | 692 | SELECT id_topic, id_board, sent |
@@ -674,8 +707,9 @@ discard block |
||
674 | 707 | $context['is_marked_notify'] = true; |
675 | 708 | $board_sent = $row['sent']; |
676 | 709 | } |
677 | - if (!empty($row['id_topic'])) |
|
678 | - $context['topics'][$row['id_topic']]['is_watched'] = true; |
|
710 | + if (!empty($row['id_topic'])) { |
|
711 | + $context['topics'][$row['id_topic']]['is_watched'] = true; |
|
712 | + } |
|
679 | 713 | } |
680 | 714 | $smcFunc['db_free_result']($request); |
681 | 715 | |
@@ -699,8 +733,7 @@ discard block |
||
699 | 733 | $pref = !empty($pref[$user_info['id']]) ? $pref[$user_info['id']] : array(); |
700 | 734 | $pref = isset($pref['board_notify_' . $board]) ? $pref['board_notify_' . $board] : (!empty($pref['board_notify']) ? $pref['board_notify'] : 0); |
701 | 735 | $context['board_notification_mode'] = !$context['is_marked_notify'] ? 1 : ($pref & 0x02 ? 3 : ($pref & 0x01 ? 2 : 1)); |
702 | - } |
|
703 | - else |
|
736 | + } else |
|
704 | 737 | { |
705 | 738 | $context['is_marked_notify'] = false; |
706 | 739 | $context['board_notification_mode'] = 1; |
@@ -713,23 +746,27 @@ discard block |
||
713 | 746 | $context['becomesUnapproved'] = !empty($_SESSION['becomesUnapproved']) ? true : false; |
714 | 747 | |
715 | 748 | // Don't want to show this forever... |
716 | - if ($context['becomesUnapproved']) |
|
717 | - unset($_SESSION['becomesUnapproved']); |
|
749 | + if ($context['becomesUnapproved']) { |
|
750 | + unset($_SESSION['becomesUnapproved']); |
|
751 | + } |
|
718 | 752 | |
719 | 753 | // Build the message index button array. |
720 | 754 | $context['normal_buttons'] = array(); |
721 | 755 | |
722 | - if ($context['can_post_new']) |
|
723 | - $context['normal_buttons']['new_topic'] = array('text' => 'new_topic', 'image' => 'new_topic.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0', 'active' => true); |
|
756 | + if ($context['can_post_new']) { |
|
757 | + $context['normal_buttons']['new_topic'] = array('text' => 'new_topic', 'image' => 'new_topic.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0', 'active' => true); |
|
758 | + } |
|
724 | 759 | |
725 | - if ($context['can_post_poll']) |
|
726 | - $context['normal_buttons']['post_poll'] = array('text' => 'new_poll', 'image' => 'new_poll.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0;poll'); |
|
760 | + if ($context['can_post_poll']) { |
|
761 | + $context['normal_buttons']['post_poll'] = array('text' => 'new_poll', 'image' => 'new_poll.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0;poll'); |
|
762 | + } |
|
727 | 763 | |
728 | - if (!$context['user']['is_logged']) |
|
729 | - $context['normal_buttons']['markread'] = array('text' => 'mark_read_short', 'image' => 'markread.png', 'lang' => true, 'custom' => 'data-confirm="' . $txt['are_sure_mark_read'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=board;board=' . $context['current_board'] . '.0;' . $context['session_var'] . '=' . $context['session_id']); |
|
764 | + if (!$context['user']['is_logged']) { |
|
765 | + $context['normal_buttons']['markread'] = array('text' => 'mark_read_short', 'image' => 'markread.png', 'lang' => true, 'custom' => 'data-confirm="' . $txt['are_sure_mark_read'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=board;board=' . $context['current_board'] . '.0;' . $context['session_var'] . '=' . $context['session_id']); |
|
766 | + } |
|
730 | 767 | |
731 | - if ($context['can_mark_notify']) |
|
732 | - $context['normal_buttons']['notify'] = array( |
|
768 | + if ($context['can_mark_notify']) { |
|
769 | + $context['normal_buttons']['notify'] = array( |
|
733 | 770 | 'lang' => true, |
734 | 771 | 'text' => 'notify_board_' . $context['board_notification_mode'], |
735 | 772 | 'sub_buttons' => array( |
@@ -747,6 +784,7 @@ discard block |
||
747 | 784 | ), |
748 | 785 | ), |
749 | 786 | ); |
787 | + } |
|
750 | 788 | |
751 | 789 | // Javascript for inline editing. |
752 | 790 | loadJavaScriptFile('topic.js', array('defer' => false), 'smf_topic'); |
@@ -768,18 +806,21 @@ discard block |
||
768 | 806 | checkSession('request'); |
769 | 807 | |
770 | 808 | // Lets go straight to the restore area. |
771 | - if (isset($_REQUEST['qaction']) && $_REQUEST['qaction'] == 'restore' && !empty($_REQUEST['topics'])) |
|
772 | - redirectexit('action=restoretopic;topics=' . implode(',', $_REQUEST['topics']) . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
809 | + if (isset($_REQUEST['qaction']) && $_REQUEST['qaction'] == 'restore' && !empty($_REQUEST['topics'])) { |
|
810 | + redirectexit('action=restoretopic;topics=' . implode(',', $_REQUEST['topics']) . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
811 | + } |
|
773 | 812 | |
774 | - if (isset($_SESSION['topicseen_cache'])) |
|
775 | - $_SESSION['topicseen_cache'] = array(); |
|
813 | + if (isset($_SESSION['topicseen_cache'])) { |
|
814 | + $_SESSION['topicseen_cache'] = array(); |
|
815 | + } |
|
776 | 816 | |
777 | 817 | // This is going to be needed to send off the notifications and for updateLastMessages(). |
778 | 818 | require_once($sourcedir . '/Subs-Post.php'); |
779 | 819 | |
780 | 820 | // Remember the last board they moved things to. |
781 | - if (isset($_REQUEST['move_to'])) |
|
782 | - $_SESSION['move_to_topic'] = $_REQUEST['move_to']; |
|
821 | + if (isset($_REQUEST['move_to'])) { |
|
822 | + $_SESSION['move_to_topic'] = $_REQUEST['move_to']; |
|
823 | + } |
|
783 | 824 | |
784 | 825 | // Only a few possible actions. |
785 | 826 | $possibleActions = array(); |
@@ -799,8 +840,7 @@ discard block |
||
799 | 840 | ); |
800 | 841 | |
801 | 842 | $redirect_url = 'board=' . $board . '.' . $_REQUEST['start']; |
802 | - } |
|
803 | - else |
|
843 | + } else |
|
804 | 844 | { |
805 | 845 | /** |
806 | 846 | * @todo Ugly. There's no getting around this, is there? |
@@ -818,8 +858,7 @@ discard block |
||
818 | 858 | if (!empty($board)) |
819 | 859 | { |
820 | 860 | $boards_can['post_new'] = array_diff(boardsAllowedTo('post_new'), array($board)); |
821 | - } |
|
822 | - else |
|
861 | + } else |
|
823 | 862 | { |
824 | 863 | $boards_can['post_new'] = boardsAllowedTo('post_new'); |
825 | 864 | } |
@@ -830,55 +869,67 @@ discard block |
||
830 | 869 | } |
831 | 870 | } |
832 | 871 | |
833 | - if (!$user_info['is_guest']) |
|
834 | - $possibleActions[] = 'markread'; |
|
835 | - if (!empty($boards_can['make_sticky'])) |
|
836 | - $possibleActions[] = 'sticky'; |
|
837 | - if (!empty($boards_can['move_any']) || !empty($boards_can['move_own'])) |
|
838 | - $possibleActions[] = 'move'; |
|
839 | - if (!empty($boards_can['remove_any']) || !empty($boards_can['remove_own'])) |
|
840 | - $possibleActions[] = 'remove'; |
|
841 | - if (!empty($boards_can['lock_any']) || !empty($boards_can['lock_own'])) |
|
842 | - $possibleActions[] = 'lock'; |
|
843 | - if (!empty($boards_can['merge_any'])) |
|
844 | - $possibleActions[] = 'merge'; |
|
845 | - if (!empty($boards_can['approve_posts'])) |
|
846 | - $possibleActions[] = 'approve'; |
|
872 | + if (!$user_info['is_guest']) { |
|
873 | + $possibleActions[] = 'markread'; |
|
874 | + } |
|
875 | + if (!empty($boards_can['make_sticky'])) { |
|
876 | + $possibleActions[] = 'sticky'; |
|
877 | + } |
|
878 | + if (!empty($boards_can['move_any']) || !empty($boards_can['move_own'])) { |
|
879 | + $possibleActions[] = 'move'; |
|
880 | + } |
|
881 | + if (!empty($boards_can['remove_any']) || !empty($boards_can['remove_own'])) { |
|
882 | + $possibleActions[] = 'remove'; |
|
883 | + } |
|
884 | + if (!empty($boards_can['lock_any']) || !empty($boards_can['lock_own'])) { |
|
885 | + $possibleActions[] = 'lock'; |
|
886 | + } |
|
887 | + if (!empty($boards_can['merge_any'])) { |
|
888 | + $possibleActions[] = 'merge'; |
|
889 | + } |
|
890 | + if (!empty($boards_can['approve_posts'])) { |
|
891 | + $possibleActions[] = 'approve'; |
|
892 | + } |
|
847 | 893 | |
848 | 894 | // Two methods: $_REQUEST['actions'] (id_topic => action), and $_REQUEST['topics'] and $_REQUEST['qaction']. |
849 | 895 | // (if action is 'move', $_REQUEST['move_to'] or $_REQUEST['move_tos'][$topic] is used.) |
850 | 896 | if (!empty($_REQUEST['topics'])) |
851 | 897 | { |
852 | 898 | // If the action isn't valid, just quit now. |
853 | - if (empty($_REQUEST['qaction']) || !in_array($_REQUEST['qaction'], $possibleActions)) |
|
854 | - redirectexit($redirect_url); |
|
899 | + if (empty($_REQUEST['qaction']) || !in_array($_REQUEST['qaction'], $possibleActions)) { |
|
900 | + redirectexit($redirect_url); |
|
901 | + } |
|
855 | 902 | |
856 | 903 | // Merge requires all topics as one parameter and can be done at once. |
857 | 904 | if ($_REQUEST['qaction'] == 'merge') |
858 | 905 | { |
859 | 906 | // Merge requires at least two topics. |
860 | - if (empty($_REQUEST['topics']) || count($_REQUEST['topics']) < 2) |
|
861 | - redirectexit($redirect_url); |
|
907 | + if (empty($_REQUEST['topics']) || count($_REQUEST['topics']) < 2) { |
|
908 | + redirectexit($redirect_url); |
|
909 | + } |
|
862 | 910 | |
863 | 911 | require_once($sourcedir . '/SplitTopics.php'); |
864 | 912 | return MergeExecute($_REQUEST['topics']); |
865 | 913 | } |
866 | 914 | |
867 | 915 | // Just convert to the other method, to make it easier. |
868 | - foreach ($_REQUEST['topics'] as $topic) |
|
869 | - $_REQUEST['actions'][(int) $topic] = $_REQUEST['qaction']; |
|
916 | + foreach ($_REQUEST['topics'] as $topic) { |
|
917 | + $_REQUEST['actions'][(int) $topic] = $_REQUEST['qaction']; |
|
918 | + } |
|
870 | 919 | } |
871 | 920 | |
872 | 921 | // Weird... how'd you get here? |
873 | - if (empty($_REQUEST['actions'])) |
|
874 | - redirectexit($redirect_url); |
|
922 | + if (empty($_REQUEST['actions'])) { |
|
923 | + redirectexit($redirect_url); |
|
924 | + } |
|
875 | 925 | |
876 | 926 | // Validate each action. |
877 | 927 | $temp = array(); |
878 | 928 | foreach ($_REQUEST['actions'] as $topic => $action) |
879 | 929 | { |
880 | - if (in_array($action, $possibleActions)) |
|
881 | - $temp[(int) $topic] = $action; |
|
930 | + if (in_array($action, $possibleActions)) { |
|
931 | + $temp[(int) $topic] = $action; |
|
932 | + } |
|
882 | 933 | } |
883 | 934 | $_REQUEST['actions'] = $temp; |
884 | 935 | |
@@ -899,27 +950,31 @@ discard block |
||
899 | 950 | { |
900 | 951 | if (!empty($board)) |
901 | 952 | { |
902 | - if ($row['id_board'] != $board || ($modSettings['postmod_active'] && !$row['approved'] && !allowedTo('approve_posts'))) |
|
903 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
904 | - } |
|
905 | - else |
|
953 | + if ($row['id_board'] != $board || ($modSettings['postmod_active'] && !$row['approved'] && !allowedTo('approve_posts'))) { |
|
954 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
955 | + } |
|
956 | + } else |
|
906 | 957 | { |
907 | 958 | // Don't allow them to act on unapproved posts they can't see... |
908 | - if ($modSettings['postmod_active'] && !$row['approved'] && !in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])) |
|
909 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
959 | + if ($modSettings['postmod_active'] && !$row['approved'] && !in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])) { |
|
960 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
961 | + } |
|
910 | 962 | // Goodness, this is fun. We need to validate the action. |
911 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'sticky' && !in_array(0, $boards_can['make_sticky']) && !in_array($row['id_board'], $boards_can['make_sticky'])) |
|
912 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
913 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'move' && !in_array(0, $boards_can['move_any']) && !in_array($row['id_board'], $boards_can['move_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['move_own']) && !in_array($row['id_board'], $boards_can['move_own'])))) |
|
914 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
915 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'remove' && !in_array(0, $boards_can['remove_any']) && !in_array($row['id_board'], $boards_can['remove_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['remove_own']) && !in_array($row['id_board'], $boards_can['remove_own'])))) |
|
916 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
963 | + elseif ($_REQUEST['actions'][$row['id_topic']] == 'sticky' && !in_array(0, $boards_can['make_sticky']) && !in_array($row['id_board'], $boards_can['make_sticky'])) { |
|
964 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
965 | + } elseif ($_REQUEST['actions'][$row['id_topic']] == 'move' && !in_array(0, $boards_can['move_any']) && !in_array($row['id_board'], $boards_can['move_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['move_own']) && !in_array($row['id_board'], $boards_can['move_own'])))) { |
|
966 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
967 | + } elseif ($_REQUEST['actions'][$row['id_topic']] == 'remove' && !in_array(0, $boards_can['remove_any']) && !in_array($row['id_board'], $boards_can['remove_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['remove_own']) && !in_array($row['id_board'], $boards_can['remove_own'])))) { |
|
968 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
969 | + } |
|
917 | 970 | // @todo $locked is not set, what are you trying to do? (taking the change it is supposed to be $row['locked']) |
918 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'lock' && !in_array(0, $boards_can['lock_any']) && !in_array($row['id_board'], $boards_can['lock_any']) && ($row['id_member_started'] != $user_info['id'] || $row['locked'] == 1 || (!in_array(0, $boards_can['lock_own']) && !in_array($row['id_board'], $boards_can['lock_own'])))) |
|
919 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
971 | + elseif ($_REQUEST['actions'][$row['id_topic']] == 'lock' && !in_array(0, $boards_can['lock_any']) && !in_array($row['id_board'], $boards_can['lock_any']) && ($row['id_member_started'] != $user_info['id'] || $row['locked'] == 1 || (!in_array(0, $boards_can['lock_own']) && !in_array($row['id_board'], $boards_can['lock_own'])))) { |
|
972 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
973 | + } |
|
920 | 974 | // If the topic is approved then you need permission to approve the posts within. |
921 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'approve' && (!$row['unapproved_posts'] || (!in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])))) |
|
922 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
975 | + elseif ($_REQUEST['actions'][$row['id_topic']] == 'approve' && (!$row['unapproved_posts'] || (!in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])))) { |
|
976 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
977 | + } |
|
923 | 978 | } |
924 | 979 | } |
925 | 980 | $smcFunc['db_free_result']($request); |
@@ -937,11 +992,11 @@ discard block |
||
937 | 992 | { |
938 | 993 | $topic = (int) $topic; |
939 | 994 | |
940 | - if ($action == 'markread') |
|
941 | - $markCache[] = $topic; |
|
942 | - elseif ($action == 'sticky') |
|
943 | - $stickyCache[] = $topic; |
|
944 | - elseif ($action == 'move') |
|
995 | + if ($action == 'markread') { |
|
996 | + $markCache[] = $topic; |
|
997 | + } elseif ($action == 'sticky') { |
|
998 | + $stickyCache[] = $topic; |
|
999 | + } elseif ($action == 'move') |
|
945 | 1000 | { |
946 | 1001 | require_once($sourcedir . '/MoveTopic.php'); |
947 | 1002 | moveTopicConcurrence(); |
@@ -949,23 +1004,25 @@ discard block |
||
949 | 1004 | // $moveCache[0] is the topic, $moveCache[1] is the board to move to. |
950 | 1005 | $moveCache[1][$topic] = (int) (isset($_REQUEST['move_tos'][$topic]) ? $_REQUEST['move_tos'][$topic] : $_REQUEST['move_to']); |
951 | 1006 | |
952 | - if (empty($moveCache[1][$topic])) |
|
953 | - continue; |
|
1007 | + if (empty($moveCache[1][$topic])) { |
|
1008 | + continue; |
|
1009 | + } |
|
954 | 1010 | |
955 | 1011 | $moveCache[0][] = $topic; |
1012 | + } elseif ($action == 'remove') { |
|
1013 | + $removeCache[] = $topic; |
|
1014 | + } elseif ($action == 'lock') { |
|
1015 | + $lockCache[] = $topic; |
|
1016 | + } elseif ($action == 'approve') { |
|
1017 | + $approveCache[] = $topic; |
|
956 | 1018 | } |
957 | - elseif ($action == 'remove') |
|
958 | - $removeCache[] = $topic; |
|
959 | - elseif ($action == 'lock') |
|
960 | - $lockCache[] = $topic; |
|
961 | - elseif ($action == 'approve') |
|
962 | - $approveCache[] = $topic; |
|
963 | 1019 | } |
964 | 1020 | |
965 | - if (empty($board)) |
|
966 | - $affectedBoards = array(); |
|
967 | - else |
|
968 | - $affectedBoards = array($board => array(0, 0)); |
|
1021 | + if (empty($board)) { |
|
1022 | + $affectedBoards = array(); |
|
1023 | + } else { |
|
1024 | + $affectedBoards = array($board => array(0, 0)); |
|
1025 | + } |
|
969 | 1026 | |
970 | 1027 | // Do all the stickies... |
971 | 1028 | if (!empty($stickyCache)) |
@@ -1025,14 +1082,16 @@ discard block |
||
1025 | 1082 | { |
1026 | 1083 | $to = $moveCache[1][$row['id_topic']]; |
1027 | 1084 | |
1028 | - if (empty($to)) |
|
1029 | - continue; |
|
1085 | + if (empty($to)) { |
|
1086 | + continue; |
|
1087 | + } |
|
1030 | 1088 | |
1031 | 1089 | // Does this topic's board count the posts or not? |
1032 | 1090 | $countPosts[$row['id_topic']] = empty($row['count_posts']); |
1033 | 1091 | |
1034 | - if (!isset($moveTos[$to])) |
|
1035 | - $moveTos[$to] = array(); |
|
1092 | + if (!isset($moveTos[$to])) { |
|
1093 | + $moveTos[$to] = array(); |
|
1094 | + } |
|
1036 | 1095 | |
1037 | 1096 | $moveTos[$to][] = $row['id_topic']; |
1038 | 1097 | |
@@ -1046,8 +1105,9 @@ discard block |
||
1046 | 1105 | require_once($sourcedir . '/MoveTopic.php'); |
1047 | 1106 | |
1048 | 1107 | // Do the actual moves... |
1049 | - foreach ($moveTos as $to => $topics) |
|
1050 | - moveTopics($topics, $to); |
|
1108 | + foreach ($moveTos as $to => $topics) { |
|
1109 | + moveTopics($topics, $to); |
|
1110 | + } |
|
1051 | 1111 | |
1052 | 1112 | // Does the post counts need to be updated? |
1053 | 1113 | if (!empty($moveTos)) |
@@ -1096,20 +1156,23 @@ discard block |
||
1096 | 1156 | |
1097 | 1157 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1098 | 1158 | { |
1099 | - if (!isset($members[$row['id_member']])) |
|
1100 | - $members[$row['id_member']] = 0; |
|
1159 | + if (!isset($members[$row['id_member']])) { |
|
1160 | + $members[$row['id_member']] = 0; |
|
1161 | + } |
|
1101 | 1162 | |
1102 | - if ($topicRecounts[$row['id_topic']] === '+') |
|
1103 | - $members[$row['id_member']] += 1; |
|
1104 | - else |
|
1105 | - $members[$row['id_member']] -= 1; |
|
1163 | + if ($topicRecounts[$row['id_topic']] === '+') { |
|
1164 | + $members[$row['id_member']] += 1; |
|
1165 | + } else { |
|
1166 | + $members[$row['id_member']] -= 1; |
|
1167 | + } |
|
1106 | 1168 | } |
1107 | 1169 | |
1108 | 1170 | $smcFunc['db_free_result']($request); |
1109 | 1171 | |
1110 | 1172 | // And now update them member's post counts |
1111 | - foreach ($members as $id_member => $post_adj) |
|
1112 | - updateMemberData($id_member, array('posts' => 'posts + ' . $post_adj)); |
|
1173 | + foreach ($members as $id_member => $post_adj) { |
|
1174 | + updateMemberData($id_member, array('posts' => 'posts + ' . $post_adj)); |
|
1175 | + } |
|
1113 | 1176 | |
1114 | 1177 | } |
1115 | 1178 | } |
@@ -1189,8 +1252,9 @@ discard block |
||
1189 | 1252 | approveTopics($approveCache); |
1190 | 1253 | |
1191 | 1254 | // Time for some logging! |
1192 | - foreach ($approveCache as $topic) |
|
1193 | - logAction('approve_topic', array('topic' => $topic, 'member' => $approveCacheMembers[$topic])); |
|
1255 | + foreach ($approveCache as $topic) { |
|
1256 | + logAction('approve_topic', array('topic' => $topic, 'member' => $approveCacheMembers[$topic])); |
|
1257 | + } |
|
1194 | 1258 | } |
1195 | 1259 | } |
1196 | 1260 | |
@@ -1225,8 +1289,7 @@ discard block |
||
1225 | 1289 | $lockStatus[$row['id_topic']] = empty($row['locked']); |
1226 | 1290 | } |
1227 | 1291 | $smcFunc['db_free_result']($result); |
1228 | - } |
|
1229 | - else |
|
1292 | + } else |
|
1230 | 1293 | { |
1231 | 1294 | $result = $smcFunc['db_query']('', ' |
1232 | 1295 | SELECT id_topic, locked, id_board |
@@ -1276,13 +1339,15 @@ discard block |
||
1276 | 1339 | ) |
1277 | 1340 | ); |
1278 | 1341 | $logged_topics = array(); |
1279 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1280 | - $logged_topics[$row['id_topic']] = $row['unwatched']; |
|
1342 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1343 | + $logged_topics[$row['id_topic']] = $row['unwatched']; |
|
1344 | + } |
|
1281 | 1345 | $smcFunc['db_free_result']($request); |
1282 | 1346 | |
1283 | 1347 | $markArray = array(); |
1284 | - foreach ($markCache as $topic) |
|
1285 | - $markArray[] = array($modSettings['maxMsgID'], $user_info['id'], $topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0)); |
|
1348 | + foreach ($markCache as $topic) { |
|
1349 | + $markArray[] = array($modSettings['maxMsgID'], $user_info['id'], $topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0)); |
|
1350 | + } |
|
1286 | 1351 | |
1287 | 1352 | $smcFunc['db_insert']('replace', |
1288 | 1353 | '{db_prefix}log_topics', |
@@ -1295,8 +1360,9 @@ discard block |
||
1295 | 1360 | foreach ($moveCache as $topic) |
1296 | 1361 | { |
1297 | 1362 | // Didn't actually move anything! |
1298 | - if (!isset($topic[0])) |
|
1299 | - break; |
|
1363 | + if (!isset($topic[0])) { |
|
1364 | + break; |
|
1365 | + } |
|
1300 | 1366 | |
1301 | 1367 | logAction('move', array('topic' => $topic[0], 'board_from' => $topic[1], 'board_to' => $topic[2])); |
1302 | 1368 | sendNotifications($topic[0], 'move'); |
@@ -1318,8 +1384,9 @@ discard block |
||
1318 | 1384 | 'calendar_updated' => time(), |
1319 | 1385 | )); |
1320 | 1386 | |
1321 | - if (!empty($affectedBoards)) |
|
1322 | - updateLastMessages(array_keys($affectedBoards)); |
|
1387 | + if (!empty($affectedBoards)) { |
|
1388 | + updateLastMessages(array_keys($affectedBoards)); |
|
1389 | + } |
|
1323 | 1390 | |
1324 | 1391 | redirectexit($redirect_url); |
1325 | 1392 | } |
@@ -21,8 +21,9 @@ discard block |
||
21 | 21 | * @version 2.1 Beta 4 |
22 | 22 | */ |
23 | 23 | |
24 | -if (!defined('SMF')) |
|
24 | +if (!defined('SMF')) { |
|
25 | 25 | die('No direct access...'); |
26 | +} |
|
26 | 27 | |
27 | 28 | /** |
28 | 29 | * Handling function for generating reports. |
@@ -69,14 +70,15 @@ discard block |
||
69 | 70 | ); |
70 | 71 | |
71 | 72 | $is_first = 0; |
72 | - foreach ($context['report_types'] as $k => $temp) |
|
73 | - $context['report_types'][$k] = array( |
|
73 | + foreach ($context['report_types'] as $k => $temp) { |
|
74 | + $context['report_types'][$k] = array( |
|
74 | 75 | 'id' => $k, |
75 | 76 | 'title' => isset($txt['gr_type_' . $k]) ? $txt['gr_type_' . $k] : $k, |
76 | 77 | 'description' => isset($txt['gr_type_desc_' . $k]) ? $txt['gr_type_desc_' . $k] : null, |
77 | 78 | 'function' => $temp, |
78 | 79 | 'is_first' => $is_first++ == 0, |
79 | 80 | ); |
81 | + } |
|
80 | 82 | |
81 | 83 | // If they haven't chosen a report type which is valid, send them off to the report type chooser! |
82 | 84 | if (empty($_REQUEST['rt']) || !isset($context['report_types'][$_REQUEST['rt']])) |
@@ -102,8 +104,9 @@ discard block |
||
102 | 104 | $context['sub_template'] = $_REQUEST['st']; |
103 | 105 | |
104 | 106 | // Are we disabling the other layers - print friendly for example? |
105 | - if ($reportTemplates[$_REQUEST['st']]['layers'] !== null) |
|
106 | - $context['template_layers'] = $reportTemplates[$_REQUEST['st']]['layers']; |
|
107 | + if ($reportTemplates[$_REQUEST['st']]['layers'] !== null) { |
|
108 | + $context['template_layers'] = $reportTemplates[$_REQUEST['st']]['layers']; |
|
109 | + } |
|
107 | 110 | } |
108 | 111 | |
109 | 112 | // Make the page title more descriptive. |
@@ -151,8 +154,9 @@ discard block |
||
151 | 154 | ) |
152 | 155 | ); |
153 | 156 | $moderators = array(); |
154 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
155 | - $moderators[$row['id_board']][] = $row['real_name']; |
|
157 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
158 | + $moderators[$row['id_board']][] = $row['real_name']; |
|
159 | + } |
|
156 | 160 | $smcFunc['db_free_result']($request); |
157 | 161 | |
158 | 162 | // Get every moderator gruop. |
@@ -164,8 +168,9 @@ discard block |
||
164 | 168 | ) |
165 | 169 | ); |
166 | 170 | $moderator_groups = array(); |
167 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
168 | - $moderator_groups[$row['id_board']][] = $row['group_name']; |
|
171 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
172 | + $moderator_groups[$row['id_board']][] = $row['group_name']; |
|
173 | + } |
|
169 | 174 | $smcFunc['db_free_result']($request); |
170 | 175 | |
171 | 176 | // Get all the possible membergroups! |
@@ -176,8 +181,9 @@ discard block |
||
176 | 181 | ) |
177 | 182 | ); |
178 | 183 | $groups = array(-1 => $txt['guest_title'], 0 => $txt['full_member']); |
179 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
180 | - $groups[$row['id_group']] = empty($row['online_color']) ? $row['group_name'] : '<span style="color: ' . $row['online_color'] . '">' . $row['group_name'] . '</span>'; |
|
184 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
185 | + $groups[$row['id_group']] = empty($row['online_color']) ? $row['group_name'] : '<span style="color: ' . $row['online_color'] . '">' . $row['group_name'] . '</span>'; |
|
186 | + } |
|
181 | 187 | $smcFunc['db_free_result']($request); |
182 | 188 | |
183 | 189 | // All the fields we'll show. |
@@ -195,8 +201,9 @@ discard block |
||
195 | 201 | 'moderator_groups' => $txt['board_moderator_groups'], |
196 | 202 | 'groups' => $txt['board_groups'], |
197 | 203 | ); |
198 | - if (!empty($modSettings['deny_boards_access'])) |
|
199 | - $boardSettings['disallowed_groups'] = $txt['board_disallowed_groups']; |
|
204 | + if (!empty($modSettings['deny_boards_access'])) { |
|
205 | + $boardSettings['disallowed_groups'] = $txt['board_disallowed_groups']; |
|
206 | + } |
|
200 | 207 | |
201 | 208 | // Do it in columns, it's just easier. |
202 | 209 | setKeys('cols'); |
@@ -222,8 +229,9 @@ discard block |
||
222 | 229 | newTable($row['name'], '', 'left', 'auto', 'left', 200, 'left'); |
223 | 230 | |
224 | 231 | $this_boardSettings = $boardSettings; |
225 | - if (empty($row['redirect'])) |
|
226 | - unset($this_boardSettings['redirect']); |
|
232 | + if (empty($row['redirect'])) { |
|
233 | + unset($this_boardSettings['redirect']); |
|
234 | + } |
|
227 | 235 | |
228 | 236 | // First off, add in the side key. |
229 | 237 | addData($this_boardSettings); |
@@ -250,10 +258,11 @@ discard block |
||
250 | 258 | $allowedGroups = explode(',', $row['member_groups']); |
251 | 259 | foreach ($allowedGroups as $key => $group) |
252 | 260 | { |
253 | - if (isset($groups[$group])) |
|
254 | - $allowedGroups[$key] = $groups[$group]; |
|
255 | - else |
|
256 | - unset($allowedGroups[$key]); |
|
261 | + if (isset($groups[$group])) { |
|
262 | + $allowedGroups[$key] = $groups[$group]; |
|
263 | + } else { |
|
264 | + unset($allowedGroups[$key]); |
|
265 | + } |
|
257 | 266 | } |
258 | 267 | $boardData['groups'] = implode(', ', $allowedGroups); |
259 | 268 | if (!empty($modSettings['deny_boards_access'])) |
@@ -261,16 +270,18 @@ discard block |
||
261 | 270 | $disallowedGroups = explode(',', $row['deny_member_groups']); |
262 | 271 | foreach ($disallowedGroups as $key => $group) |
263 | 272 | { |
264 | - if (isset($groups[$group])) |
|
265 | - $disallowedGroups[$key] = $groups[$group]; |
|
266 | - else |
|
267 | - unset($disallowedGroups[$key]); |
|
273 | + if (isset($groups[$group])) { |
|
274 | + $disallowedGroups[$key] = $groups[$group]; |
|
275 | + } else { |
|
276 | + unset($disallowedGroups[$key]); |
|
277 | + } |
|
268 | 278 | } |
269 | 279 | $boardData['disallowed_groups'] = implode(', ', $disallowedGroups); |
270 | 280 | } |
271 | 281 | |
272 | - if (empty($row['redirect'])) |
|
273 | - unset ($boardData['redirect']); |
|
282 | + if (empty($row['redirect'])) { |
|
283 | + unset ($boardData['redirect']); |
|
284 | + } |
|
274 | 285 | |
275 | 286 | // Next add the main data. |
276 | 287 | addData($boardData); |
@@ -295,27 +306,31 @@ discard block |
||
295 | 306 | |
296 | 307 | if (isset($_REQUEST['boards'])) |
297 | 308 | { |
298 | - if (!is_array($_REQUEST['boards'])) |
|
299 | - $_REQUEST['boards'] = explode(',', $_REQUEST['boards']); |
|
300 | - foreach ($_REQUEST['boards'] as $k => $dummy) |
|
301 | - $_REQUEST['boards'][$k] = (int) $dummy; |
|
309 | + if (!is_array($_REQUEST['boards'])) { |
|
310 | + $_REQUEST['boards'] = explode(',', $_REQUEST['boards']); |
|
311 | + } |
|
312 | + foreach ($_REQUEST['boards'] as $k => $dummy) { |
|
313 | + $_REQUEST['boards'][$k] = (int) $dummy; |
|
314 | + } |
|
302 | 315 | |
303 | 316 | $board_clause = 'id_board IN ({array_int:boards})'; |
317 | + } else { |
|
318 | + $board_clause = '1=1'; |
|
304 | 319 | } |
305 | - else |
|
306 | - $board_clause = '1=1'; |
|
307 | 320 | |
308 | 321 | if (isset($_REQUEST['groups'])) |
309 | 322 | { |
310 | - if (!is_array($_REQUEST['groups'])) |
|
311 | - $_REQUEST['groups'] = explode(',', $_REQUEST['groups']); |
|
312 | - foreach ($_REQUEST['groups'] as $k => $dummy) |
|
313 | - $_REQUEST['groups'][$k] = (int) $dummy; |
|
323 | + if (!is_array($_REQUEST['groups'])) { |
|
324 | + $_REQUEST['groups'] = explode(',', $_REQUEST['groups']); |
|
325 | + } |
|
326 | + foreach ($_REQUEST['groups'] as $k => $dummy) { |
|
327 | + $_REQUEST['groups'][$k] = (int) $dummy; |
|
328 | + } |
|
314 | 329 | |
315 | 330 | $group_clause = 'id_group IN ({array_int:groups})'; |
331 | + } else { |
|
332 | + $group_clause = '1=1'; |
|
316 | 333 | } |
317 | - else |
|
318 | - $group_clause = '1=1'; |
|
319 | 334 | |
320 | 335 | // Fetch all the board names. |
321 | 336 | $request = $smcFunc['db_query']('', ' |
@@ -369,12 +384,14 @@ discard block |
||
369 | 384 | 'groups' => isset($_REQUEST['groups']) ? $_REQUEST['groups'] : array(), |
370 | 385 | ) |
371 | 386 | ); |
372 | - if (!isset($_REQUEST['groups']) || in_array(-1, $_REQUEST['groups']) || in_array(0, $_REQUEST['groups'])) |
|
373 | - $member_groups = array('col' => '', -1 => $txt['membergroups_guests'], 0 => $txt['membergroups_members']); |
|
374 | - else |
|
375 | - $member_groups = array('col' => ''); |
|
376 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
377 | - $member_groups[$row['id_group']] = $row['group_name']; |
|
387 | + if (!isset($_REQUEST['groups']) || in_array(-1, $_REQUEST['groups']) || in_array(0, $_REQUEST['groups'])) { |
|
388 | + $member_groups = array('col' => '', -1 => $txt['membergroups_guests'], 0 => $txt['membergroups_members']); |
|
389 | + } else { |
|
390 | + $member_groups = array('col' => ''); |
|
391 | + } |
|
392 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
393 | + $member_groups[$row['id_group']] = $row['group_name']; |
|
394 | + } |
|
378 | 395 | $smcFunc['db_free_result']($request); |
379 | 396 | |
380 | 397 | // Make sure that every group is represented - plus in rows! |
@@ -411,12 +428,14 @@ discard block |
||
411 | 428 | ); |
412 | 429 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
413 | 430 | { |
414 | - if (in_array($row['permission'], $disabled_permissions)) |
|
415 | - continue; |
|
431 | + if (in_array($row['permission'], $disabled_permissions)) { |
|
432 | + continue; |
|
433 | + } |
|
416 | 434 | |
417 | - foreach ($boards as $id => $board) |
|
418 | - if ($board['profile'] == $row['id_profile']) |
|
435 | + foreach ($boards as $id => $board) { |
|
436 | + if ($board['profile'] == $row['id_profile']) |
|
419 | 437 | $board_permissions[$id][$row['id_group']][$row['permission']] = $row['add_deny']; |
438 | + } |
|
420 | 439 | |
421 | 440 | // Make sure we get every permission. |
422 | 441 | if (!isset($permissions[$row['permission']])) |
@@ -451,8 +470,9 @@ discard block |
||
451 | 470 | foreach ($member_groups as $id_group => $name) |
452 | 471 | { |
453 | 472 | // Don't overwrite the key column! |
454 | - if ($id_group === 'col') |
|
455 | - continue; |
|
473 | + if ($id_group === 'col') { |
|
474 | + continue; |
|
475 | + } |
|
456 | 476 | |
457 | 477 | $group_permissions = isset($groups[$id_group]) ? $groups[$id_group] : array(); |
458 | 478 | |
@@ -474,16 +494,18 @@ discard block |
||
474 | 494 | } |
475 | 495 | |
476 | 496 | // Now actually make the data for the group look right. |
477 | - if (empty($curData[$id_group])) |
|
478 | - $curData[$id_group] = '<span class="red">' . $txt['board_perms_deny'] . '</span>'; |
|
479 | - elseif ($curData[$id_group] == 1) |
|
480 | - $curData[$id_group] = '<span style="color: darkgreen;">' . $txt['board_perms_allow'] . '</span>'; |
|
481 | - else |
|
482 | - $curData[$id_group] = 'x'; |
|
497 | + if (empty($curData[$id_group])) { |
|
498 | + $curData[$id_group] = '<span class="red">' . $txt['board_perms_deny'] . '</span>'; |
|
499 | + } elseif ($curData[$id_group] == 1) { |
|
500 | + $curData[$id_group] = '<span style="color: darkgreen;">' . $txt['board_perms_allow'] . '</span>'; |
|
501 | + } else { |
|
502 | + $curData[$id_group] = 'x'; |
|
503 | + } |
|
483 | 504 | |
484 | 505 | // Embolden those permissions different from global (makes it a lot easier!) |
485 | - if (@$board_permissions[0][$id_group][$ID_PERM] != @$group_permissions[$ID_PERM]) |
|
486 | - $curData[$id_group] = '<strong>' . $curData[$id_group] . '</strong>'; |
|
506 | + if (@$board_permissions[0][$id_group][$ID_PERM] != @$group_permissions[$ID_PERM]) { |
|
507 | + $curData[$id_group] = '<strong>' . $curData[$id_group] . '</strong>'; |
|
508 | + } |
|
487 | 509 | } |
488 | 510 | |
489 | 511 | // Now add the data for this permission. |
@@ -513,15 +535,17 @@ discard block |
||
513 | 535 | ); |
514 | 536 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
515 | 537 | { |
516 | - if (trim($row['member_groups']) == '') |
|
517 | - $groups = array(1); |
|
518 | - else |
|
519 | - $groups = array_merge(array(1), explode(',', $row['member_groups'])); |
|
538 | + if (trim($row['member_groups']) == '') { |
|
539 | + $groups = array(1); |
|
540 | + } else { |
|
541 | + $groups = array_merge(array(1), explode(',', $row['member_groups'])); |
|
542 | + } |
|
520 | 543 | |
521 | - if (trim($row['deny_member_groups']) == '') |
|
522 | - $denyGroups = array(); |
|
523 | - else |
|
524 | - $denyGroups = explode(',', $row['deny_member_groups']); |
|
544 | + if (trim($row['deny_member_groups']) == '') { |
|
545 | + $denyGroups = array(); |
|
546 | + } else { |
|
547 | + $denyGroups = explode(',', $row['deny_member_groups']); |
|
548 | + } |
|
525 | 549 | |
526 | 550 | $boards[$row['id_board']] = array( |
527 | 551 | 'id' => $row['id_board'], |
@@ -545,8 +569,9 @@ discard block |
||
545 | 569 | ); |
546 | 570 | |
547 | 571 | // Add on the boards! |
548 | - foreach ($boards as $board) |
|
549 | - $mgSettings['board_' . $board['id']] = $board['name']; |
|
572 | + foreach ($boards as $board) { |
|
573 | + $mgSettings['board_' . $board['id']] = $board['name']; |
|
574 | + } |
|
550 | 575 | |
551 | 576 | // Add all the membergroup settings, plus we'll be adding in columns! |
552 | 577 | setKeys('cols', $mgSettings); |
@@ -591,8 +616,9 @@ discard block |
||
591 | 616 | 'icons' => '' |
592 | 617 | ), |
593 | 618 | ); |
594 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
595 | - $rows[] = $row; |
|
619 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
620 | + $rows[] = $row; |
|
621 | + } |
|
596 | 622 | $smcFunc['db_free_result']($request); |
597 | 623 | |
598 | 624 | foreach ($rows as $row) |
@@ -608,8 +634,9 @@ discard block |
||
608 | 634 | ); |
609 | 635 | |
610 | 636 | // Board permissions. |
611 | - foreach ($boards as $board) |
|
612 | - $group['board_' . $board['id']] = in_array($row['id_group'], $board['groups']) ? '<span class="success">' . $txt['board_perms_allow'] . '</span>' : (!empty($modSettings['deny_boards_access']) && in_array($row['id_group'], $board['deny_groups']) ? '<span class="alert">' . $txt['board_perms_deny'] . '</span>' : 'x'); |
|
637 | + foreach ($boards as $board) { |
|
638 | + $group['board_' . $board['id']] = in_array($row['id_group'], $board['groups']) ? '<span class="success">' . $txt['board_perms_allow'] . '</span>' : (!empty($modSettings['deny_boards_access']) && in_array($row['id_group'], $board['deny_groups']) ? '<span class="alert">' . $txt['board_perms_deny'] . '</span>' : 'x'); |
|
639 | + } |
|
613 | 640 | |
614 | 641 | addData($group); |
615 | 642 | } |
@@ -629,16 +656,18 @@ discard block |
||
629 | 656 | |
630 | 657 | if (isset($_REQUEST['groups'])) |
631 | 658 | { |
632 | - if (!is_array($_REQUEST['groups'])) |
|
633 | - $_REQUEST['groups'] = explode(',', $_REQUEST['groups']); |
|
634 | - foreach ($_REQUEST['groups'] as $k => $dummy) |
|
635 | - $_REQUEST['groups'][$k] = (int) $dummy; |
|
659 | + if (!is_array($_REQUEST['groups'])) { |
|
660 | + $_REQUEST['groups'] = explode(',', $_REQUEST['groups']); |
|
661 | + } |
|
662 | + foreach ($_REQUEST['groups'] as $k => $dummy) { |
|
663 | + $_REQUEST['groups'][$k] = (int) $dummy; |
|
664 | + } |
|
636 | 665 | $_REQUEST['groups'] = array_diff($_REQUEST['groups'], array(3)); |
637 | 666 | |
638 | 667 | $clause = 'id_group IN ({array_int:groups})'; |
668 | + } else { |
|
669 | + $clause = 'id_group != {int:moderator_group}'; |
|
639 | 670 | } |
640 | - else |
|
641 | - $clause = 'id_group != {int:moderator_group}'; |
|
642 | 671 | |
643 | 672 | // Get all the possible membergroups, except admin! |
644 | 673 | $request = $smcFunc['db_query']('', ' |
@@ -656,12 +685,14 @@ discard block |
||
656 | 685 | 'groups' => isset($_REQUEST['groups']) ? $_REQUEST['groups'] : array(), |
657 | 686 | ) |
658 | 687 | ); |
659 | - if (!isset($_REQUEST['groups']) || in_array(-1, $_REQUEST['groups']) || in_array(0, $_REQUEST['groups'])) |
|
660 | - $groups = array('col' => '', -1 => $txt['membergroups_guests'], 0 => $txt['membergroups_members']); |
|
661 | - else |
|
662 | - $groups = array('col' => ''); |
|
663 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
664 | - $groups[$row['id_group']] = $row['group_name']; |
|
688 | + if (!isset($_REQUEST['groups']) || in_array(-1, $_REQUEST['groups']) || in_array(0, $_REQUEST['groups'])) { |
|
689 | + $groups = array('col' => '', -1 => $txt['membergroups_guests'], 0 => $txt['membergroups_members']); |
|
690 | + } else { |
|
691 | + $groups = array('col' => ''); |
|
692 | + } |
|
693 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
694 | + $groups[$row['id_group']] = $row['group_name']; |
|
695 | + } |
|
665 | 696 | $smcFunc['db_free_result']($request); |
666 | 697 | |
667 | 698 | // Make sure that every group is represented! |
@@ -685,8 +716,9 @@ discard block |
||
685 | 716 | $disabled_permissions[] = 'calendar_edit_own'; |
686 | 717 | $disabled_permissions[] = 'calendar_edit_any'; |
687 | 718 | } |
688 | - if (empty($modSettings['warning_settings']) || $modSettings['warning_settings'][0] == 0) |
|
689 | - $disabled_permissions[] = 'issue_warning'; |
|
719 | + if (empty($modSettings['warning_settings']) || $modSettings['warning_settings'][0] == 0) { |
|
720 | + $disabled_permissions[] = 'issue_warning'; |
|
721 | + } |
|
690 | 722 | |
691 | 723 | call_integration_hook('integrate_reports_groupperm', array(&$disabled_permissions)); |
692 | 724 | |
@@ -707,15 +739,17 @@ discard block |
||
707 | 739 | $curData = array(); |
708 | 740 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
709 | 741 | { |
710 | - if (in_array($row['permission'], $disabled_permissions)) |
|
711 | - continue; |
|
742 | + if (in_array($row['permission'], $disabled_permissions)) { |
|
743 | + continue; |
|
744 | + } |
|
712 | 745 | |
713 | 746 | // If this is a new permission flush the last row. |
714 | 747 | if ($row['permission'] != $lastPermission) |
715 | 748 | { |
716 | 749 | // Send the data! |
717 | - if ($lastPermission !== null) |
|
718 | - addData($curData); |
|
750 | + if ($lastPermission !== null) { |
|
751 | + addData($curData); |
|
752 | + } |
|
719 | 753 | |
720 | 754 | // Add the permission name in the left column. |
721 | 755 | $curData = array('col' => isset($txt['group_perms_name_' . $row['permission']]) ? $txt['group_perms_name_' . $row['permission']] : $row['permission']); |
@@ -724,10 +758,11 @@ discard block |
||
724 | 758 | } |
725 | 759 | |
726 | 760 | // Good stuff - add the permission to the list! |
727 | - if ($row['add_deny']) |
|
728 | - $curData[$row['id_group']] = '<span style="color: darkgreen;">' . $txt['board_perms_allow'] . '</span>'; |
|
729 | - else |
|
730 | - $curData[$row['id_group']] = '<span class="red">' . $txt['board_perms_deny'] . '</span>'; |
|
761 | + if ($row['add_deny']) { |
|
762 | + $curData[$row['id_group']] = '<span style="color: darkgreen;">' . $txt['board_perms_allow'] . '</span>'; |
|
763 | + } else { |
|
764 | + $curData[$row['id_group']] = '<span class="red">' . $txt['board_perms_deny'] . '</span>'; |
|
765 | + } |
|
731 | 766 | } |
732 | 767 | $smcFunc['db_free_result']($request); |
733 | 768 | |
@@ -757,8 +792,9 @@ discard block |
||
757 | 792 | ) |
758 | 793 | ); |
759 | 794 | $boards = array(); |
760 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
761 | - $boards[$row['id_board']] = $row['name']; |
|
795 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
796 | + $boards[$row['id_board']] = $row['name']; |
|
797 | + } |
|
762 | 798 | $smcFunc['db_free_result']($request); |
763 | 799 | |
764 | 800 | // Get every moderator. |
@@ -790,12 +826,14 @@ discard block |
||
790 | 826 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
791 | 827 | { |
792 | 828 | // Either we don't have them as a moderator at all or at least not as a moderator of this board |
793 | - if (!array_key_exists($row['id_member'], $moderators) || !in_array($row['id_board'], $moderators[$row['id_member']])) |
|
794 | - $moderators[$row['id_member']][] = $row['id_board']; |
|
829 | + if (!array_key_exists($row['id_member'], $moderators) || !in_array($row['id_board'], $moderators[$row['id_member']])) { |
|
830 | + $moderators[$row['id_member']][] = $row['id_board']; |
|
831 | + } |
|
795 | 832 | |
796 | 833 | // We don't have them listed as a moderator yet |
797 | - if (!array_key_exists($row['id_member'], $local_mods)) |
|
798 | - $local_mods[$row['id_member']] = $row['id_member']; |
|
834 | + if (!array_key_exists($row['id_member'], $local_mods)) { |
|
835 | + $local_mods[$row['id_member']] = $row['id_member']; |
|
836 | + } |
|
799 | 837 | } |
800 | 838 | |
801 | 839 | // Get a list of global moderators (i.e. members with moderation powers). |
@@ -808,8 +846,9 @@ discard block |
||
808 | 846 | $allStaff = array_unique($allStaff); |
809 | 847 | |
810 | 848 | // This is a bit of a cop out - but we're protecting their forum, really! |
811 | - if (count($allStaff) > 300) |
|
812 | - fatal_lang_error('report_error_too_many_staff'); |
|
849 | + if (count($allStaff) > 300) { |
|
850 | + fatal_lang_error('report_error_too_many_staff'); |
|
851 | + } |
|
813 | 852 | |
814 | 853 | // Get all the possible membergroups! |
815 | 854 | $request = $smcFunc['db_query']('', ' |
@@ -819,8 +858,9 @@ discard block |
||
819 | 858 | ) |
820 | 859 | ); |
821 | 860 | $groups = array(0 => $txt['full_member']); |
822 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
823 | - $groups[$row['id_group']] = empty($row['online_color']) ? $row['group_name'] : '<span style="color: ' . $row['online_color'] . '">' . $row['group_name'] . '</span>'; |
|
861 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
862 | + $groups[$row['id_group']] = empty($row['online_color']) ? $row['group_name'] : '<span style="color: ' . $row['online_color'] . '">' . $row['group_name'] . '</span>'; |
|
863 | + } |
|
824 | 864 | $smcFunc['db_free_result']($request); |
825 | 865 | |
826 | 866 | // All the fields we'll show. |
@@ -861,19 +901,20 @@ discard block |
||
861 | 901 | ); |
862 | 902 | |
863 | 903 | // What do they moderate? |
864 | - if (in_array($row['id_member'], $global_mods)) |
|
865 | - $staffData['moderates'] = '<em>' . $txt['report_staff_all_boards'] . '</em>'; |
|
866 | - elseif (isset($moderators[$row['id_member']])) |
|
904 | + if (in_array($row['id_member'], $global_mods)) { |
|
905 | + $staffData['moderates'] = '<em>' . $txt['report_staff_all_boards'] . '</em>'; |
|
906 | + } elseif (isset($moderators[$row['id_member']])) |
|
867 | 907 | { |
868 | 908 | // Get the names |
869 | - foreach ($moderators[$row['id_member']] as $board) |
|
870 | - if (isset($boards[$board])) |
|
909 | + foreach ($moderators[$row['id_member']] as $board) { |
|
910 | + if (isset($boards[$board])) |
|
871 | 911 | $staffData['moderates'][] = $boards[$board]; |
912 | + } |
|
872 | 913 | |
873 | 914 | $staffData['moderates'] = implode(', ', $staffData['moderates']); |
915 | + } else { |
|
916 | + $staffData['moderates'] = '<em>' . $txt['report_staff_no_boards'] . '</em>'; |
|
874 | 917 | } |
875 | - else |
|
876 | - $staffData['moderates'] = '<em>' . $txt['report_staff_no_boards'] . '</em>'; |
|
877 | 918 | |
878 | 919 | // Next add the main data. |
879 | 920 | addData($staffData); |
@@ -901,8 +942,9 @@ discard block |
||
901 | 942 | global $context; |
902 | 943 | |
903 | 944 | // Set the table count if needed. |
904 | - if (empty($context['table_count'])) |
|
905 | - $context['table_count'] = 0; |
|
945 | + if (empty($context['table_count'])) { |
|
946 | + $context['table_count'] = 0; |
|
947 | + } |
|
906 | 948 | |
907 | 949 | // Create the table! |
908 | 950 | $context['tables'][$context['table_count']] = array( |
@@ -952,16 +994,18 @@ discard block |
||
952 | 994 | global $context; |
953 | 995 | |
954 | 996 | // No tables? Create one even though we are probably already in a bad state! |
955 | - if (empty($context['table_count'])) |
|
956 | - newTable(); |
|
997 | + if (empty($context['table_count'])) { |
|
998 | + newTable(); |
|
999 | + } |
|
957 | 1000 | |
958 | 1001 | // Specific table? |
959 | - if ($custom_table !== null && !isset($context['tables'][$custom_table])) |
|
960 | - return false; |
|
961 | - elseif ($custom_table !== null) |
|
962 | - $table = $custom_table; |
|
963 | - else |
|
964 | - $table = $context['current_table']; |
|
1002 | + if ($custom_table !== null && !isset($context['tables'][$custom_table])) { |
|
1003 | + return false; |
|
1004 | + } elseif ($custom_table !== null) { |
|
1005 | + $table = $custom_table; |
|
1006 | + } else { |
|
1007 | + $table = $context['current_table']; |
|
1008 | + } |
|
965 | 1009 | |
966 | 1010 | // If we have keys, sanitise the data... |
967 | 1011 | if (!empty($context['keys'])) |
@@ -973,11 +1017,11 @@ discard block |
||
973 | 1017 | 'v' => empty($inc_data[$key]) ? $context['tables'][$table]['default_value'] : $inc_data[$key], |
974 | 1018 | ); |
975 | 1019 | // Special "hack" the adding separators when doing data by column. |
976 | - if (substr($key, 0, 5) == '#sep#') |
|
977 | - $data[$key]['separator'] = true; |
|
1020 | + if (substr($key, 0, 5) == '#sep#') { |
|
1021 | + $data[$key]['separator'] = true; |
|
1022 | + } |
|
978 | 1023 | } |
979 | - } |
|
980 | - else |
|
1024 | + } else |
|
981 | 1025 | { |
982 | 1026 | $data = $inc_data; |
983 | 1027 | foreach ($data as $key => $value) |
@@ -985,8 +1029,9 @@ discard block |
||
985 | 1029 | $data[$key] = array( |
986 | 1030 | 'v' => $value, |
987 | 1031 | ); |
988 | - if (substr($key, 0, 5) == '#sep#') |
|
989 | - $data[$key]['separator'] = true; |
|
1032 | + if (substr($key, 0, 5) == '#sep#') { |
|
1033 | + $data[$key]['separator'] = true; |
|
1034 | + } |
|
990 | 1035 | } |
991 | 1036 | } |
992 | 1037 | |
@@ -999,8 +1044,9 @@ discard block |
||
999 | 1044 | // Otherwise, tricky! |
1000 | 1045 | else |
1001 | 1046 | { |
1002 | - foreach ($data as $key => $item) |
|
1003 | - $context['tables'][$table]['data'][$key][] = $item; |
|
1047 | + foreach ($data as $key => $item) { |
|
1048 | + $context['tables'][$table]['data'][$key][] = $item; |
|
1049 | + } |
|
1004 | 1050 | } |
1005 | 1051 | } |
1006 | 1052 | |
@@ -1017,16 +1063,18 @@ discard block |
||
1017 | 1063 | global $context; |
1018 | 1064 | |
1019 | 1065 | // No tables - return? |
1020 | - if (empty($context['table_count'])) |
|
1021 | - return; |
|
1066 | + if (empty($context['table_count'])) { |
|
1067 | + return; |
|
1068 | + } |
|
1022 | 1069 | |
1023 | 1070 | // Specific table? |
1024 | - if ($custom_table !== null && !isset($context['tables'][$table])) |
|
1025 | - return false; |
|
1026 | - elseif ($custom_table !== null) |
|
1027 | - $table = $custom_table; |
|
1028 | - else |
|
1029 | - $table = $context['current_table']; |
|
1071 | + if ($custom_table !== null && !isset($context['tables'][$table])) { |
|
1072 | + return false; |
|
1073 | + } elseif ($custom_table !== null) { |
|
1074 | + $table = $custom_table; |
|
1075 | + } else { |
|
1076 | + $table = $context['current_table']; |
|
1077 | + } |
|
1030 | 1078 | |
1031 | 1079 | // Plumb in the separator |
1032 | 1080 | $context['tables'][$table]['data'][] = array(0 => array( |
@@ -1047,8 +1095,9 @@ discard block |
||
1047 | 1095 | { |
1048 | 1096 | global $context; |
1049 | 1097 | |
1050 | - if (empty($context['tables'])) |
|
1051 | - return; |
|
1098 | + if (empty($context['tables'])) { |
|
1099 | + return; |
|
1100 | + } |
|
1052 | 1101 | |
1053 | 1102 | // Loop through each table counting up some basic values, to help with the templating. |
1054 | 1103 | foreach ($context['tables'] as $id => $table) |
@@ -1059,12 +1108,13 @@ discard block |
||
1059 | 1108 | $context['tables'][$id]['column_count'] = count($curElement); |
1060 | 1109 | |
1061 | 1110 | // Work out the rough width - for templates like the print template. Without this we might get funny tables. |
1062 | - if ($table['shading']['left'] && $table['width']['shaded'] != 'auto' && $table['width']['normal'] != 'auto') |
|
1063 | - $context['tables'][$id]['max_width'] = $table['width']['shaded'] + ($context['tables'][$id]['column_count'] - 1) * $table['width']['normal']; |
|
1064 | - elseif ($table['width']['normal'] != 'auto') |
|
1065 | - $context['tables'][$id]['max_width'] = $context['tables'][$id]['column_count'] * $table['width']['normal']; |
|
1066 | - else |
|
1067 | - $context['tables'][$id]['max_width'] = 'auto'; |
|
1111 | + if ($table['shading']['left'] && $table['width']['shaded'] != 'auto' && $table['width']['normal'] != 'auto') { |
|
1112 | + $context['tables'][$id]['max_width'] = $table['width']['shaded'] + ($context['tables'][$id]['column_count'] - 1) * $table['width']['normal']; |
|
1113 | + } elseif ($table['width']['normal'] != 'auto') { |
|
1114 | + $context['tables'][$id]['max_width'] = $context['tables'][$id]['column_count'] * $table['width']['normal']; |
|
1115 | + } else { |
|
1116 | + $context['tables'][$id]['max_width'] = 'auto'; |
|
1117 | + } |
|
1068 | 1118 | } |
1069 | 1119 | } |
1070 | 1120 | |
@@ -1089,10 +1139,11 @@ discard block |
||
1089 | 1139 | global $context; |
1090 | 1140 | |
1091 | 1141 | // Do we want to use the keys of the keys as the keys? :P |
1092 | - if ($reverse) |
|
1093 | - $context['keys'] = array_flip($keys); |
|
1094 | - else |
|
1095 | - $context['keys'] = $keys; |
|
1142 | + if ($reverse) { |
|
1143 | + $context['keys'] = array_flip($keys); |
|
1144 | + } else { |
|
1145 | + $context['keys'] = $keys; |
|
1146 | + } |
|
1096 | 1147 | |
1097 | 1148 | // Rows or columns? |
1098 | 1149 | $context['key_method'] = $method == 'rows' ? 'rows' : 'cols'; |
@@ -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 = 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']; |
@@ -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 | * Delete one of more membergroups. |
@@ -31,15 +32,16 @@ discard block |
||
31 | 32 | global $smcFunc, $modSettings, $txt; |
32 | 33 | |
33 | 34 | // Make sure it's an array. |
34 | - if (!is_array($groups)) |
|
35 | - $groups = array((int) $groups); |
|
36 | - else |
|
35 | + if (!is_array($groups)) { |
|
36 | + $groups = array((int) $groups); |
|
37 | + } else |
|
37 | 38 | { |
38 | 39 | $groups = array_unique($groups); |
39 | 40 | |
40 | 41 | // Make sure all groups are integer. |
41 | - foreach ($groups as $key => $value) |
|
42 | - $groups[$key] = (int) $value; |
|
42 | + foreach ($groups as $key => $value) { |
|
43 | + $groups[$key] = (int) $value; |
|
44 | + } |
|
43 | 45 | } |
44 | 46 | |
45 | 47 | // Some groups are protected (guests, administrators, moderators, newbies). |
@@ -56,15 +58,17 @@ discard block |
||
56 | 58 | 'is_protected' => 1, |
57 | 59 | ) |
58 | 60 | ); |
59 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
60 | - $protected_groups[] = $row['id_group']; |
|
61 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
62 | + $protected_groups[] = $row['id_group']; |
|
63 | + } |
|
61 | 64 | $smcFunc['db_free_result']($request); |
62 | 65 | } |
63 | 66 | |
64 | 67 | // Make sure they don't delete protected groups! |
65 | 68 | $groups = array_diff($groups, array_unique($protected_groups)); |
66 | - if (empty($groups)) |
|
67 | - return 'no_group_found'; |
|
69 | + if (empty($groups)) { |
|
70 | + return 'no_group_found'; |
|
71 | + } |
|
68 | 72 | |
69 | 73 | // Make sure they don't try to delete a group attached to a paid subscription. |
70 | 74 | $subscriptions = array(); |
@@ -74,13 +78,14 @@ discard block |
||
74 | 78 | ORDER BY name'); |
75 | 79 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
76 | 80 | { |
77 | - if (in_array($row['id_group'], $groups)) |
|
78 | - $subscriptions[] = $row['name']; |
|
79 | - else |
|
81 | + if (in_array($row['id_group'], $groups)) { |
|
82 | + $subscriptions[] = $row['name']; |
|
83 | + } else |
|
80 | 84 | { |
81 | 85 | $add_groups = explode(',', $row['add_groups']); |
82 | - if (count(array_intersect($add_groups, $groups)) != 0) |
|
83 | - $subscriptions[] = $row['name']; |
|
86 | + if (count(array_intersect($add_groups, $groups)) != 0) { |
|
87 | + $subscriptions[] = $row['name']; |
|
88 | + } |
|
84 | 89 | } |
85 | 90 | } |
86 | 91 | $smcFunc['db_free_result']($request); |
@@ -101,8 +106,9 @@ discard block |
||
101 | 106 | 'group_list' => $groups, |
102 | 107 | ) |
103 | 108 | ); |
104 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
105 | - logAction('delete_group', array('group' => $row['group_name']), 'admin'); |
|
109 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
110 | + logAction('delete_group', array('group' => $row['group_name']), 'admin'); |
|
111 | + } |
|
106 | 112 | $smcFunc['db_free_result']($request); |
107 | 113 | |
108 | 114 | call_integration_hook('integrate_delete_membergroups', array($groups)); |
@@ -187,12 +193,14 @@ discard block |
||
187 | 193 | ) |
188 | 194 | ); |
189 | 195 | $updates = array(); |
190 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
191 | - $updates[$row['additional_groups']][] = $row['id_member']; |
|
196 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
197 | + $updates[$row['additional_groups']][] = $row['id_member']; |
|
198 | + } |
|
192 | 199 | $smcFunc['db_free_result']($request); |
193 | 200 | |
194 | - foreach ($updates as $additional_groups => $memberArray) |
|
195 | - updateMemberData($memberArray, array('additional_groups' => implode(',', array_diff(explode(',', $additional_groups), $groups)))); |
|
201 | + foreach ($updates as $additional_groups => $memberArray) { |
|
202 | + updateMemberData($memberArray, array('additional_groups' => implode(',', array_diff(explode(',', $additional_groups), $groups)))); |
|
203 | + } |
|
196 | 204 | |
197 | 205 | // No boards can provide access to these membergroups anymore. |
198 | 206 | $request = $smcFunc['db_query']('', ' |
@@ -204,12 +212,13 @@ discard block |
||
204 | 212 | ) |
205 | 213 | ); |
206 | 214 | $updates = array(); |
207 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
208 | - $updates[$row['member_groups']][] = $row['id_board']; |
|
215 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
216 | + $updates[$row['member_groups']][] = $row['id_board']; |
|
217 | + } |
|
209 | 218 | $smcFunc['db_free_result']($request); |
210 | 219 | |
211 | - foreach ($updates as $member_groups => $boardArray) |
|
212 | - $smcFunc['db_query']('', ' |
|
220 | + foreach ($updates as $member_groups => $boardArray) { |
|
221 | + $smcFunc['db_query']('', ' |
|
213 | 222 | UPDATE {db_prefix}boards |
214 | 223 | SET member_groups = {string:member_groups} |
215 | 224 | WHERE id_board IN ({array_int:board_lists})', |
@@ -218,6 +227,7 @@ discard block |
||
218 | 227 | 'member_groups' => implode(',', array_diff(explode(',', $member_groups), $groups)), |
219 | 228 | ) |
220 | 229 | ); |
230 | + } |
|
221 | 231 | |
222 | 232 | // Recalculate the post groups, as they likely changed. |
223 | 233 | updateStats('postgroups'); |
@@ -225,8 +235,9 @@ discard block |
||
225 | 235 | // Make a note of the fact that the cache may be wrong. |
226 | 236 | $settings_update = array('settings_updated' => time()); |
227 | 237 | // Have we deleted the spider group? |
228 | - if (isset($modSettings['spider_group']) && in_array($modSettings['spider_group'], $groups)) |
|
229 | - $settings_update['spider_group'] = 0; |
|
238 | + if (isset($modSettings['spider_group']) && in_array($modSettings['spider_group'], $groups)) { |
|
239 | + $settings_update['spider_group'] = 0; |
|
240 | + } |
|
230 | 241 | |
231 | 242 | updateSettings($settings_update); |
232 | 243 | |
@@ -250,22 +261,24 @@ discard block |
||
250 | 261 | global $smcFunc, $modSettings, $sourcedir; |
251 | 262 | |
252 | 263 | // You're getting nowhere without this permission, unless of course you are the group's moderator. |
253 | - if (!$permissionCheckDone) |
|
254 | - isAllowedTo('manage_membergroups'); |
|
264 | + if (!$permissionCheckDone) { |
|
265 | + isAllowedTo('manage_membergroups'); |
|
266 | + } |
|
255 | 267 | |
256 | 268 | // Assume something will happen. |
257 | 269 | updateSettings(array('settings_updated' => time())); |
258 | 270 | |
259 | 271 | // Cleaning the input. |
260 | - if (!is_array($members)) |
|
261 | - $members = array((int) $members); |
|
262 | - else |
|
272 | + if (!is_array($members)) { |
|
273 | + $members = array((int) $members); |
|
274 | + } else |
|
263 | 275 | { |
264 | 276 | $members = array_unique($members); |
265 | 277 | |
266 | 278 | // Cast the members to integer. |
267 | - foreach ($members as $key => $value) |
|
268 | - $members[$key] = (int) $value; |
|
279 | + foreach ($members as $key => $value) { |
|
280 | + $members[$key] = (int) $value; |
|
281 | + } |
|
269 | 282 | } |
270 | 283 | |
271 | 284 | // Before we get started, let's check we won't leave the admin group empty! |
@@ -277,14 +290,15 @@ discard block |
||
277 | 290 | // Remove any admins if there are too many. |
278 | 291 | $non_changing_admins = array_diff(array_keys($admins), $members); |
279 | 292 | |
280 | - if (empty($non_changing_admins)) |
|
281 | - $members = array_diff($members, array_keys($admins)); |
|
293 | + if (empty($non_changing_admins)) { |
|
294 | + $members = array_diff($members, array_keys($admins)); |
|
295 | + } |
|
282 | 296 | } |
283 | 297 | |
284 | 298 | // Just in case. |
285 | - if (empty($members)) |
|
286 | - return false; |
|
287 | - elseif ($groups === null) |
|
299 | + if (empty($members)) { |
|
300 | + return false; |
|
301 | + } elseif ($groups === null) |
|
288 | 302 | { |
289 | 303 | // Wanna remove all groups from these members? That's easy. |
290 | 304 | $smcFunc['db_query']('', ' |
@@ -306,20 +320,21 @@ discard block |
||
306 | 320 | updateStats('postgroups', $members); |
307 | 321 | |
308 | 322 | // Log what just happened. |
309 | - foreach ($members as $member) |
|
310 | - logAction('removed_all_groups', array('member' => $member), 'admin'); |
|
323 | + foreach ($members as $member) { |
|
324 | + logAction('removed_all_groups', array('member' => $member), 'admin'); |
|
325 | + } |
|
311 | 326 | |
312 | 327 | return true; |
313 | - } |
|
314 | - elseif (!is_array($groups)) |
|
315 | - $groups = array((int) $groups); |
|
316 | - else |
|
328 | + } elseif (!is_array($groups)) { |
|
329 | + $groups = array((int) $groups); |
|
330 | + } else |
|
317 | 331 | { |
318 | 332 | $groups = array_unique($groups); |
319 | 333 | |
320 | 334 | // Make sure all groups are integer. |
321 | - foreach ($groups as $key => $value) |
|
322 | - $groups[$key] = (int) $value; |
|
335 | + foreach ($groups as $key => $value) { |
|
336 | + $groups[$key] = (int) $value; |
|
337 | + } |
|
323 | 338 | } |
324 | 339 | |
325 | 340 | // Fetch a list of groups members cannot be assigned to explicitly, and the group names of the ones we want. |
@@ -335,10 +350,11 @@ discard block |
||
335 | 350 | $group_names = array(); |
336 | 351 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
337 | 352 | { |
338 | - if ($row['min_posts'] != -1) |
|
339 | - $implicitGroups[] = $row['id_group']; |
|
340 | - else |
|
341 | - $group_names[$row['id_group']] = $row['group_name']; |
|
353 | + if ($row['min_posts'] != -1) { |
|
354 | + $implicitGroups[] = $row['id_group']; |
|
355 | + } else { |
|
356 | + $group_names[$row['id_group']] = $row['group_name']; |
|
357 | + } |
|
342 | 358 | } |
343 | 359 | $smcFunc['db_free_result']($request); |
344 | 360 | |
@@ -357,8 +373,9 @@ discard block |
||
357 | 373 | ) |
358 | 374 | ); |
359 | 375 | $protected_groups = array(1); |
360 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
361 | - $protected_groups[] = $row['id_group']; |
|
376 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
377 | + $protected_groups[] = $row['id_group']; |
|
378 | + } |
|
362 | 379 | $smcFunc['db_free_result']($request); |
363 | 380 | |
364 | 381 | // If you're not an admin yourself, you can't touch protected groups! |
@@ -366,8 +383,9 @@ discard block |
||
366 | 383 | } |
367 | 384 | |
368 | 385 | // Only continue if there are still groups and members left. |
369 | - if (empty($groups) || empty($members)) |
|
370 | - return false; |
|
386 | + if (empty($groups) || empty($members)) { |
|
387 | + return false; |
|
388 | + } |
|
371 | 389 | |
372 | 390 | // First, reset those who have this as their primary group - this is the easy one. |
373 | 391 | $log_inserts = array(); |
@@ -381,8 +399,9 @@ discard block |
||
381 | 399 | 'member_list' => $members, |
382 | 400 | ) |
383 | 401 | ); |
384 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
385 | - $log_inserts[] = array('group' => $group_names[$row['id_group']], 'member' => $row['id_member']); |
|
402 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
403 | + $log_inserts[] = array('group' => $group_names[$row['id_group']], 'member' => $row['id_member']); |
|
404 | + } |
|
386 | 405 | $smcFunc['db_free_result']($request); |
387 | 406 | |
388 | 407 | $smcFunc['db_query']('', ' |
@@ -414,16 +433,17 @@ discard block |
||
414 | 433 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
415 | 434 | { |
416 | 435 | // What log entries must we make for this one, eh? |
417 | - foreach (explode(',', $row['additional_groups']) as $group) |
|
418 | - if (in_array($group, $groups)) |
|
436 | + foreach (explode(',', $row['additional_groups']) as $group) { |
|
437 | + if (in_array($group, $groups)) |
|
419 | 438 | $log_inserts[] = array('group' => $group_names[$group], 'member' => $row['id_member']); |
439 | + } |
|
420 | 440 | |
421 | 441 | $updates[$row['additional_groups']][] = $row['id_member']; |
422 | 442 | } |
423 | 443 | $smcFunc['db_free_result']($request); |
424 | 444 | |
425 | - foreach ($updates as $additional_groups => $memberArray) |
|
426 | - $smcFunc['db_query']('', ' |
|
445 | + foreach ($updates as $additional_groups => $memberArray) { |
|
446 | + $smcFunc['db_query']('', ' |
|
427 | 447 | UPDATE {db_prefix}members |
428 | 448 | SET additional_groups = {string:additional_groups} |
429 | 449 | WHERE id_member IN ({array_int:member_list})', |
@@ -432,6 +452,7 @@ discard block |
||
432 | 452 | 'additional_groups' => implode(',', array_diff(explode(',', $additional_groups), $groups)), |
433 | 453 | ) |
434 | 454 | ); |
455 | + } |
|
435 | 456 | |
436 | 457 | // Their post groups may have changed now... |
437 | 458 | updateStats('postgroups', $members); |
@@ -440,8 +461,9 @@ discard block |
||
440 | 461 | if (!empty($log_inserts) && !empty($modSettings['modlog_enabled'])) |
441 | 462 | { |
442 | 463 | require_once($sourcedir . '/Logging.php'); |
443 | - foreach ($log_inserts as $extra) |
|
444 | - logAction('removed_from_group', $extra, 'admin'); |
|
464 | + foreach ($log_inserts as $extra) { |
|
465 | + logAction('removed_from_group', $extra, 'admin'); |
|
466 | + } |
|
445 | 467 | } |
446 | 468 | |
447 | 469 | // Mission successful. |
@@ -477,21 +499,23 @@ discard block |
||
477 | 499 | global $smcFunc, $sourcedir; |
478 | 500 | |
479 | 501 | // Show your licence, but only if it hasn't been done yet. |
480 | - if (!$permissionCheckDone) |
|
481 | - isAllowedTo('manage_membergroups'); |
|
502 | + if (!$permissionCheckDone) { |
|
503 | + isAllowedTo('manage_membergroups'); |
|
504 | + } |
|
482 | 505 | |
483 | 506 | // Make sure we don't keep old stuff cached. |
484 | 507 | updateSettings(array('settings_updated' => time())); |
485 | 508 | |
486 | - if (!is_array($members)) |
|
487 | - $members = array((int) $members); |
|
488 | - else |
|
509 | + if (!is_array($members)) { |
|
510 | + $members = array((int) $members); |
|
511 | + } else |
|
489 | 512 | { |
490 | 513 | $members = array_unique($members); |
491 | 514 | |
492 | 515 | // Make sure all members are integer. |
493 | - foreach ($members as $key => $value) |
|
494 | - $members[$key] = (int) $value; |
|
516 | + foreach ($members as $key => $value) { |
|
517 | + $members[$key] = (int) $value; |
|
518 | + } |
|
495 | 519 | } |
496 | 520 | $group = (int) $group; |
497 | 521 | |
@@ -508,20 +532,23 @@ discard block |
||
508 | 532 | $group_names = array(); |
509 | 533 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
510 | 534 | { |
511 | - if ($row['min_posts'] != -1) |
|
512 | - $implicitGroups[] = $row['id_group']; |
|
513 | - else |
|
514 | - $group_names[$row['id_group']] = $row['group_name']; |
|
535 | + if ($row['min_posts'] != -1) { |
|
536 | + $implicitGroups[] = $row['id_group']; |
|
537 | + } else { |
|
538 | + $group_names[$row['id_group']] = $row['group_name']; |
|
539 | + } |
|
515 | 540 | } |
516 | 541 | $smcFunc['db_free_result']($request); |
517 | 542 | |
518 | 543 | // Sorry, you can't join an implicit group. |
519 | - if (in_array($group, $implicitGroups) || empty($members)) |
|
520 | - return false; |
|
544 | + if (in_array($group, $implicitGroups) || empty($members)) { |
|
545 | + return false; |
|
546 | + } |
|
521 | 547 | |
522 | 548 | // Only admins can add admins... |
523 | - if (!allowedTo('admin_forum') && $group == 1) |
|
524 | - return false; |
|
549 | + if (!allowedTo('admin_forum') && $group == 1) { |
|
550 | + return false; |
|
551 | + } |
|
525 | 552 | // ... and assign protected groups! |
526 | 553 | elseif (!allowedTo('admin_forum') && !$ignoreProtected) |
527 | 554 | { |
@@ -539,13 +566,14 @@ discard block |
||
539 | 566 | $smcFunc['db_free_result']($request); |
540 | 567 | |
541 | 568 | // Is it protected? |
542 | - if ($is_protected == 1) |
|
543 | - return false; |
|
569 | + if ($is_protected == 1) { |
|
570 | + return false; |
|
571 | + } |
|
544 | 572 | } |
545 | 573 | |
546 | 574 | // Do the actual updates. |
547 | - if ($type == 'only_additional') |
|
548 | - $smcFunc['db_query']('', ' |
|
575 | + if ($type == 'only_additional') { |
|
576 | + $smcFunc['db_query']('', ' |
|
549 | 577 | UPDATE {db_prefix}members |
550 | 578 | SET additional_groups = CASE WHEN additional_groups = {string:blank_string} THEN {string:id_group_string} ELSE CONCAT(additional_groups, {string:id_group_string_extend}) END |
551 | 579 | WHERE id_member IN ({array_int:member_list}) |
@@ -559,8 +587,8 @@ discard block |
||
559 | 587 | 'blank_string' => '', |
560 | 588 | ) |
561 | 589 | ); |
562 | - elseif ($type == 'only_primary' || $type == 'force_primary') |
|
563 | - $smcFunc['db_query']('', ' |
|
590 | + } elseif ($type == 'only_primary' || $type == 'force_primary') { |
|
591 | + $smcFunc['db_query']('', ' |
|
564 | 592 | UPDATE {db_prefix}members |
565 | 593 | SET id_group = {int:id_group} |
566 | 594 | WHERE id_member IN ({array_int:member_list})' . ($type == 'force_primary' ? '' : ' |
@@ -572,8 +600,8 @@ discard block |
||
572 | 600 | 'regular_group' => 0, |
573 | 601 | ) |
574 | 602 | ); |
575 | - elseif ($type == 'auto') |
|
576 | - $smcFunc['db_query']('', ' |
|
603 | + } elseif ($type == 'auto') { |
|
604 | + $smcFunc['db_query']('', ' |
|
577 | 605 | UPDATE {db_prefix}members |
578 | 606 | SET |
579 | 607 | id_group = CASE WHEN id_group = {int:regular_group} THEN {int:id_group} ELSE id_group END, |
@@ -592,9 +620,11 @@ discard block |
||
592 | 620 | 'id_group_string_extend' => ',' . $group, |
593 | 621 | ) |
594 | 622 | ); |
623 | + } |
|
595 | 624 | // Ack!!? What happened? |
596 | - else |
|
597 | - trigger_error('addMembersToGroup(): Unknown type \'' . $type . '\'', E_USER_WARNING); |
|
625 | + else { |
|
626 | + trigger_error('addMembersToGroup(): Unknown type \'' . $type . '\'', E_USER_WARNING); |
|
627 | + } |
|
598 | 628 | |
599 | 629 | call_integration_hook('integrate_add_members_to_group', array($members, $group, &$group_names)); |
600 | 630 | |
@@ -603,8 +633,9 @@ discard block |
||
603 | 633 | |
604 | 634 | // Log the data. |
605 | 635 | require_once($sourcedir . '/Logging.php'); |
606 | - foreach ($members as $member) |
|
607 | - logAction('added_to_group', array('group' => $group_names[$group], 'member' => $member), 'admin'); |
|
636 | + foreach ($members as $member) { |
|
637 | + logAction('added_to_group', array('group' => $group_names[$group], 'member' => $member), 'admin'); |
|
638 | + } |
|
608 | 639 | |
609 | 640 | return true; |
610 | 641 | } |
@@ -632,8 +663,9 @@ discard block |
||
632 | 663 | ) |
633 | 664 | ); |
634 | 665 | $members = array(); |
635 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
636 | - $members[$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
666 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
667 | + $members[$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
668 | + } |
|
637 | 669 | $smcFunc['db_free_result']($request); |
638 | 670 | |
639 | 671 | // If there are more than $limit members, add a 'more' link. |
@@ -641,10 +673,10 @@ discard block |
||
641 | 673 | { |
642 | 674 | array_pop($members); |
643 | 675 | return true; |
676 | + } else { |
|
677 | + return false; |
|
678 | + } |
|
644 | 679 | } |
645 | - else |
|
646 | - return false; |
|
647 | -} |
|
648 | 680 | |
649 | 681 | /** |
650 | 682 | * Retrieve a list of (visible) membergroups used by the cache. |
@@ -669,8 +701,9 @@ discard block |
||
669 | 701 | ) |
670 | 702 | ); |
671 | 703 | $groupCache = array(); |
672 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
673 | - $groupCache[] = '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_group'] . '" ' . ($row['online_color'] ? 'style="color: ' . $row['online_color'] . '"' : '') . '>' . $row['group_name'] . '</a>'; |
|
704 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
705 | + $groupCache[] = '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_group'] . '" ' . ($row['online_color'] ? 'style="color: ' . $row['online_color'] . '"' : '') . '>' . $row['group_name'] . '</a>'; |
|
706 | + } |
|
674 | 707 | $smcFunc['db_free_result']($request); |
675 | 708 | |
676 | 709 | return array( |
@@ -716,8 +749,9 @@ discard block |
||
716 | 749 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
717 | 750 | { |
718 | 751 | // We only list the groups they can see. |
719 | - if ($row['hidden'] && !$row['can_moderate'] && !allowedTo('manage_membergroups')) |
|
720 | - continue; |
|
752 | + if ($row['hidden'] && !$row['can_moderate'] && !allowedTo('manage_membergroups')) { |
|
753 | + continue; |
|
754 | + } |
|
721 | 755 | |
722 | 756 | $row['icons'] = explode('#', $row['icons']); |
723 | 757 | |
@@ -752,12 +786,11 @@ discard block |
||
752 | 786 | 'group_list' => $group_ids, |
753 | 787 | ) |
754 | 788 | ); |
755 | - while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
756 | - $groups[$row['id_group']]['num_members'] += $row['num_members']; |
|
789 | + while ($row = $smcFunc['db_fetch_assoc']($query)) { |
|
790 | + $groups[$row['id_group']]['num_members'] += $row['num_members']; |
|
791 | + } |
|
757 | 792 | $smcFunc['db_free_result']($query); |
758 | - } |
|
759 | - |
|
760 | - else |
|
793 | + } else |
|
761 | 794 | { |
762 | 795 | $query = $smcFunc['db_query']('', ' |
763 | 796 | SELECT id_group, COUNT(*) AS num_members |
@@ -768,8 +801,9 @@ discard block |
||
768 | 801 | 'group_list' => $group_ids, |
769 | 802 | ) |
770 | 803 | ); |
771 | - while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
772 | - $groups[$row['id_group']]['num_members'] += $row['num_members']; |
|
804 | + while ($row = $smcFunc['db_fetch_assoc']($query)) { |
|
805 | + $groups[$row['id_group']]['num_members'] += $row['num_members']; |
|
806 | + } |
|
773 | 807 | $smcFunc['db_free_result']($query); |
774 | 808 | |
775 | 809 | // Only do additional groups if we can moderate... |
@@ -788,8 +822,9 @@ discard block |
||
788 | 822 | 'blank_string' => '', |
789 | 823 | ) |
790 | 824 | ); |
791 | - while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
792 | - $groups[$row['id_group']]['num_members'] += $row['num_members']; |
|
825 | + while ($row = $smcFunc['db_fetch_assoc']($query)) { |
|
826 | + $groups[$row['id_group']]['num_members'] += $row['num_members']; |
|
827 | + } |
|
793 | 828 | $smcFunc['db_free_result']($query); |
794 | 829 | } |
795 | 830 | } |
@@ -803,8 +838,9 @@ discard block |
||
803 | 838 | 'group_list' => $group_ids, |
804 | 839 | ) |
805 | 840 | ); |
806 | - while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
807 | - $groups[$row['id_group']]['moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
841 | + while ($row = $smcFunc['db_fetch_assoc']($query)) { |
|
842 | + $groups[$row['id_group']]['moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
843 | + } |
|
808 | 844 | $smcFunc['db_free_result']($query); |
809 | 845 | } |
810 | 846 | |
@@ -813,8 +849,9 @@ discard block |
||
813 | 849 | { |
814 | 850 | $sort_ascending = strpos($sort, 'DESC') === false; |
815 | 851 | |
816 | - foreach ($groups as $group) |
|
817 | - $sort_array[] = $group['id_group'] != 3 ? (int) $group['num_members'] : -1; |
|
852 | + foreach ($groups as $group) { |
|
853 | + $sort_array[] = $group['id_group'] != 3 ? (int) $group['num_members'] : -1; |
|
854 | + } |
|
818 | 855 | |
819 | 856 | array_multisort($sort_array, $sort_ascending ? SORT_ASC : SORT_DESC, SORT_REGULAR, $groups); |
820 | 857 | } |
@@ -17,8 +17,9 @@ discard block |
||
17 | 17 | * @version 2.1 Beta 4 |
18 | 18 | */ |
19 | 19 | |
20 | -if (!defined('SMF')) |
|
20 | +if (!defined('SMF')) { |
|
21 | 21 | die('No direct access...'); |
22 | +} |
|
22 | 23 | |
23 | 24 | /** |
24 | 25 | * Attempt to start the session, unless it already has been. |
@@ -38,8 +39,9 @@ discard block |
||
38 | 39 | { |
39 | 40 | $parsed_url = parse_url($boardurl); |
40 | 41 | |
41 | - if (preg_match('~^\d{1,3}(\.\d{1,3}){3}$~', $parsed_url['host']) == 0 && preg_match('~(?:[^\.]+\.)?([^\.]{2,}\..+)\z~i', $parsed_url['host'], $parts) == 1) |
|
42 | - @ini_set('session.cookie_domain', '.' . $parts[1]); |
|
42 | + if (preg_match('~^\d{1,3}(\.\d{1,3}){3}$~', $parsed_url['host']) == 0 && preg_match('~(?:[^\.]+\.)?([^\.]{2,}\..+)\z~i', $parsed_url['host'], $parts) == 1) { |
|
43 | + @ini_set('session.cookie_domain', '.' . $parts[1]); |
|
44 | + } |
|
43 | 45 | } |
44 | 46 | // @todo Set the session cookie path? |
45 | 47 | |
@@ -47,8 +49,9 @@ discard block |
||
47 | 49 | if ((ini_get('session.auto_start') == 1 && !empty($modSettings['databaseSession_enable'])) || session_id() == '') |
48 | 50 | { |
49 | 51 | // Attempt to end the already-started session. |
50 | - if (ini_get('session.auto_start') == 1) |
|
51 | - session_write_close(); |
|
52 | + if (ini_get('session.auto_start') == 1) { |
|
53 | + session_write_close(); |
|
54 | + } |
|
52 | 55 | |
53 | 56 | // This is here to stop people from using bad junky PHPSESSIDs. |
54 | 57 | if (isset($_REQUEST[session_name()]) && preg_match('~^[A-Za-z0-9,-]{16,64}$~', $_REQUEST[session_name()]) == 0 && !isset($_COOKIE[session_name()])) |
@@ -65,19 +68,21 @@ discard block |
||
65 | 68 | @ini_set('session.serialize_handler', 'php'); |
66 | 69 | session_set_save_handler('sessionOpen', 'sessionClose', 'sessionRead', 'sessionWrite', 'sessionDestroy', 'sessionGC'); |
67 | 70 | @ini_set('session.gc_probability', '1'); |
71 | + } elseif (ini_get('session.gc_maxlifetime') <= 1440 && !empty($modSettings['databaseSession_lifetime'])) { |
|
72 | + @ini_set('session.gc_maxlifetime', max($modSettings['databaseSession_lifetime'], 60)); |
|
68 | 73 | } |
69 | - elseif (ini_get('session.gc_maxlifetime') <= 1440 && !empty($modSettings['databaseSession_lifetime'])) |
|
70 | - @ini_set('session.gc_maxlifetime', max($modSettings['databaseSession_lifetime'], 60)); |
|
71 | 74 | |
72 | 75 | // Use cache setting sessions? |
73 | - if (empty($modSettings['databaseSession_enable']) && !empty($modSettings['cache_enable']) && php_sapi_name() != 'cli') |
|
74 | - call_integration_hook('integrate_session_handlers'); |
|
76 | + if (empty($modSettings['databaseSession_enable']) && !empty($modSettings['cache_enable']) && php_sapi_name() != 'cli') { |
|
77 | + call_integration_hook('integrate_session_handlers'); |
|
78 | + } |
|
75 | 79 | |
76 | 80 | session_start(); |
77 | 81 | |
78 | 82 | // Change it so the cache settings are a little looser than default. |
79 | - if (!empty($modSettings['databaseSession_loose'])) |
|
80 | - header('Cache-Control: private'); |
|
83 | + if (!empty($modSettings['databaseSession_loose'])) { |
|
84 | + header('Cache-Control: private'); |
|
85 | + } |
|
81 | 86 | } |
82 | 87 | |
83 | 88 | // Set the randomly generated code. |
@@ -123,8 +128,9 @@ discard block |
||
123 | 128 | { |
124 | 129 | global $smcFunc; |
125 | 130 | |
126 | - if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) |
|
127 | - return ''; |
|
131 | + if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) { |
|
132 | + return ''; |
|
133 | + } |
|
128 | 134 | |
129 | 135 | // Look for it in the database. |
130 | 136 | $result = $smcFunc['db_query']('', ' |
@@ -153,8 +159,9 @@ discard block |
||
153 | 159 | { |
154 | 160 | global $smcFunc; |
155 | 161 | |
156 | - if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) |
|
157 | - return false; |
|
162 | + if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) { |
|
163 | + return false; |
|
164 | + } |
|
158 | 165 | |
159 | 166 | // First try to update an existing row... |
160 | 167 | $smcFunc['db_query']('', ' |
@@ -169,13 +176,14 @@ discard block |
||
169 | 176 | ); |
170 | 177 | |
171 | 178 | // If that didn't work, try inserting a new one. |
172 | - if ($smcFunc['db_affected_rows']() == 0) |
|
173 | - $smcFunc['db_insert']('ignore', |
|
179 | + if ($smcFunc['db_affected_rows']() == 0) { |
|
180 | + $smcFunc['db_insert']('ignore', |
|
174 | 181 | '{db_prefix}sessions', |
175 | 182 | array('session_id' => 'string', 'data' => 'string', 'last_update' => 'int'), |
176 | 183 | array($session_id, $data, time()), |
177 | 184 | array('session_id') |
178 | 185 | ); |
186 | + } |
|
179 | 187 | |
180 | 188 | return ($smcFunc['db_affected_rows']() == 0 ? false : true); |
181 | 189 | } |
@@ -190,8 +198,9 @@ discard block |
||
190 | 198 | { |
191 | 199 | global $smcFunc; |
192 | 200 | |
193 | - if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) |
|
194 | - return false; |
|
201 | + if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) { |
|
202 | + return false; |
|
203 | + } |
|
195 | 204 | |
196 | 205 | // Just delete the row... |
197 | 206 | $smcFunc['db_query']('', ' |
@@ -217,8 +226,9 @@ discard block |
||
217 | 226 | global $modSettings, $smcFunc; |
218 | 227 | |
219 | 228 | // Just set to the default or lower? Ignore it for a higher value. (hopefully) |
220 | - if (!empty($modSettings['databaseSession_lifetime']) && ($max_lifetime <= 1440 || $modSettings['databaseSession_lifetime'] > $max_lifetime)) |
|
221 | - $max_lifetime = max($modSettings['databaseSession_lifetime'], 60); |
|
229 | + if (!empty($modSettings['databaseSession_lifetime']) && ($max_lifetime <= 1440 || $modSettings['databaseSession_lifetime'] > $max_lifetime)) { |
|
230 | + $max_lifetime = max($modSettings['databaseSession_lifetime'], 60); |
|
231 | + } |
|
222 | 232 | |
223 | 233 | // Clean up after yerself ;). |
224 | 234 | $smcFunc['db_query']('', ' |