@@ -433,7 +433,6 @@ |
||
433 | 433 | * Formats data retrieved in other functions into xml format. |
434 | 434 | * Additionally formats data based on the specific format passed. |
435 | 435 | * This function is recursively called to handle sub arrays of data. |
436 | - |
|
437 | 436 | * @param array $data The array to output as xml data |
438 | 437 | * @param int $i The amount of indentation to use. |
439 | 438 | * @param null|string $tag If specified, it will be used instead of the keys of data. |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | if (empty($modSettings['queryless_urls']) || ($context['server']['is_cgi'] && ini_get('cgi.fix_pathinfo') == 0 && @get_cfg_var('cgi.fix_pathinfo') == 0) || (!$context['server']['is_apache'] && !$context['server']['is_lighttpd'])) |
346 | 346 | return $val; |
347 | 347 | |
348 | - $val = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+)(#[^"]*)?$~', function ($m) use ($scripturl) |
|
348 | + $val = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+)(#[^"]*)?$~', function($m) use ($scripturl) |
|
349 | 349 | { |
350 | 350 | return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html' . (isset($m[2]) ? $m[2] : ""); |
351 | 351 | }, $val); |
@@ -668,7 +668,7 @@ discard block |
||
668 | 668 | 'title' => $row['subject'], |
669 | 669 | 'link' => $scripturl . '?topic=' . $row['id_topic'] . '.0', |
670 | 670 | 'description' => $row['body'], |
671 | - 'author' => (allowedTo('moderate_forum') || $row['id_member'] == $user_info['id']) ? $row['poster_email'] . ' ('.$row['poster_name'].')' : null, |
|
671 | + 'author' => (allowedTo('moderate_forum') || $row['id_member'] == $user_info['id']) ? $row['poster_email'] . ' (' . $row['poster_name'] . ')' : null, |
|
672 | 672 | 'comments' => $scripturl . '?action=post;topic=' . $row['id_topic'] . '.0', |
673 | 673 | 'category' => $row['bname'], |
674 | 674 | 'pubDate' => gmdate('D, d M Y H:i:s \G\M\T', $row['poster_time']), |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Outputs xml data representing recent information or a profile. |
@@ -37,8 +38,9 @@ discard block |
||
37 | 38 | global $query_this_board, $smcFunc, $forum_version; |
38 | 39 | |
39 | 40 | // If it's not enabled, die. |
40 | - if (empty($modSettings['xmlnews_enable'])) |
|
41 | - obExit(false); |
|
41 | + if (empty($modSettings['xmlnews_enable'])) { |
|
42 | + obExit(false); |
|
43 | + } |
|
42 | 44 | |
43 | 45 | loadLanguage('Stats'); |
44 | 46 | |
@@ -53,8 +55,9 @@ discard block |
||
53 | 55 | if (!empty($_REQUEST['c']) && empty($board)) |
54 | 56 | { |
55 | 57 | $_REQUEST['c'] = explode(',', $_REQUEST['c']); |
56 | - foreach ($_REQUEST['c'] as $i => $c) |
|
57 | - $_REQUEST['c'][$i] = (int) $c; |
|
58 | + foreach ($_REQUEST['c'] as $i => $c) { |
|
59 | + $_REQUEST['c'][$i] = (int) $c; |
|
60 | + } |
|
58 | 61 | |
59 | 62 | if (count($_REQUEST['c']) == 1) |
60 | 63 | { |
@@ -90,18 +93,20 @@ discard block |
||
90 | 93 | } |
91 | 94 | $smcFunc['db_free_result']($request); |
92 | 95 | |
93 | - if (!empty($boards)) |
|
94 | - $query_this_board = 'b.id_board IN (' . implode(', ', $boards) . ')'; |
|
96 | + if (!empty($boards)) { |
|
97 | + $query_this_board = 'b.id_board IN (' . implode(', ', $boards) . ')'; |
|
98 | + } |
|
95 | 99 | |
96 | 100 | // Try to limit the number of messages we look through. |
97 | - if ($total_cat_posts > 100 && $total_cat_posts > $modSettings['totalMessages'] / 15) |
|
98 | - $context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 400 - $_GET['limit'] * 5); |
|
99 | - } |
|
100 | - elseif (!empty($_REQUEST['boards'])) |
|
101 | + if ($total_cat_posts > 100 && $total_cat_posts > $modSettings['totalMessages'] / 15) { |
|
102 | + $context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 400 - $_GET['limit'] * 5); |
|
103 | + } |
|
104 | + } elseif (!empty($_REQUEST['boards'])) |
|
101 | 105 | { |
102 | 106 | $_REQUEST['boards'] = explode(',', $_REQUEST['boards']); |
103 | - foreach ($_REQUEST['boards'] as $i => $b) |
|
104 | - $_REQUEST['boards'][$i] = (int) $b; |
|
107 | + foreach ($_REQUEST['boards'] as $i => $b) { |
|
108 | + $_REQUEST['boards'][$i] = (int) $b; |
|
109 | + } |
|
105 | 110 | |
106 | 111 | $request = $smcFunc['db_query']('', ' |
107 | 112 | SELECT b.id_board, b.num_posts, b.name |
@@ -117,29 +122,32 @@ discard block |
||
117 | 122 | |
118 | 123 | // Either the board specified doesn't exist or you have no access. |
119 | 124 | $num_boards = $smcFunc['db_num_rows']($request); |
120 | - if ($num_boards == 0) |
|
121 | - fatal_lang_error('no_board'); |
|
125 | + if ($num_boards == 0) { |
|
126 | + fatal_lang_error('no_board'); |
|
127 | + } |
|
122 | 128 | |
123 | 129 | $total_posts = 0; |
124 | 130 | $boards = array(); |
125 | 131 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
126 | 132 | { |
127 | - if ($num_boards == 1) |
|
128 | - $feed_title = ' - ' . strip_tags($row['name']); |
|
133 | + if ($num_boards == 1) { |
|
134 | + $feed_title = ' - ' . strip_tags($row['name']); |
|
135 | + } |
|
129 | 136 | |
130 | 137 | $boards[] = $row['id_board']; |
131 | 138 | $total_posts += $row['num_posts']; |
132 | 139 | } |
133 | 140 | $smcFunc['db_free_result']($request); |
134 | 141 | |
135 | - if (!empty($boards)) |
|
136 | - $query_this_board = 'b.id_board IN (' . implode(', ', $boards) . ')'; |
|
142 | + if (!empty($boards)) { |
|
143 | + $query_this_board = 'b.id_board IN (' . implode(', ', $boards) . ')'; |
|
144 | + } |
|
137 | 145 | |
138 | 146 | // The more boards, the more we're going to look through... |
139 | - if ($total_posts > 100 && $total_posts > $modSettings['totalMessages'] / 12) |
|
140 | - $context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 500 - $_GET['limit'] * 5); |
|
141 | - } |
|
142 | - elseif (!empty($board)) |
|
147 | + if ($total_posts > 100 && $total_posts > $modSettings['totalMessages'] / 12) { |
|
148 | + $context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 500 - $_GET['limit'] * 5); |
|
149 | + } |
|
150 | + } elseif (!empty($board)) |
|
143 | 151 | { |
144 | 152 | $request = $smcFunc['db_query']('', ' |
145 | 153 | SELECT num_posts |
@@ -158,10 +166,10 @@ discard block |
||
158 | 166 | $query_this_board = 'b.id_board = ' . $board; |
159 | 167 | |
160 | 168 | // Try to look through just a few messages, if at all possible. |
161 | - if ($total_posts > 80 && $total_posts > $modSettings['totalMessages'] / 10) |
|
162 | - $context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 600 - $_GET['limit'] * 5); |
|
163 | - } |
|
164 | - else |
|
169 | + if ($total_posts > 80 && $total_posts > $modSettings['totalMessages'] / 10) { |
|
170 | + $context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 600 - $_GET['limit'] * 5); |
|
171 | + } |
|
172 | + } else |
|
165 | 173 | { |
166 | 174 | $query_this_board = '{query_see_board}' . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? ' |
167 | 175 | AND b.id_board != ' . $modSettings['recycle_board'] : ''); |
@@ -184,30 +192,35 @@ discard block |
||
184 | 192 | // Easy adding of sub actions |
185 | 193 | call_integration_hook('integrate_xmlfeeds', array(&$subActions)); |
186 | 194 | |
187 | - if (empty($_GET['sa']) || !isset($subActions[$_GET['sa']])) |
|
188 | - $_GET['sa'] = 'recent'; |
|
195 | + if (empty($_GET['sa']) || !isset($subActions[$_GET['sa']])) { |
|
196 | + $_GET['sa'] = 'recent'; |
|
197 | + } |
|
189 | 198 | |
190 | 199 | // We only want some information, not all of it. |
191 | 200 | $cachekey = array($xml_format, $_GET['action'], $_GET['limit'], $_GET['sa']); |
192 | - foreach (array('board', 'boards', 'c') as $var) |
|
193 | - if (isset($_REQUEST[$var])) |
|
201 | + foreach (array('board', 'boards', 'c') as $var) { |
|
202 | + if (isset($_REQUEST[$var])) |
|
194 | 203 | $cachekey[] = $_REQUEST[$var]; |
204 | + } |
|
195 | 205 | $cachekey = md5(json_encode($cachekey) . (!empty($query_this_board) ? $query_this_board : '')); |
196 | 206 | $cache_t = microtime(); |
197 | 207 | |
198 | 208 | // Get the associative array representing the xml. |
199 | - if (!empty($modSettings['cache_enable']) && (!$user_info['is_guest'] || $modSettings['cache_enable'] >= 3)) |
|
200 | - $xml = cache_get_data('xmlfeed-' . $xml_format . ':' . ($user_info['is_guest'] ? '' : $user_info['id'] . '-') . $cachekey, 240); |
|
209 | + if (!empty($modSettings['cache_enable']) && (!$user_info['is_guest'] || $modSettings['cache_enable'] >= 3)) { |
|
210 | + $xml = cache_get_data('xmlfeed-' . $xml_format . ':' . ($user_info['is_guest'] ? '' : $user_info['id'] . '-') . $cachekey, 240); |
|
211 | + } |
|
201 | 212 | if (empty($xml)) |
202 | 213 | { |
203 | 214 | $call = call_helper($subActions[$_GET['sa']][0], true); |
204 | 215 | |
205 | - if (!empty($call)) |
|
206 | - $xml = call_user_func($call, $xml_format); |
|
216 | + if (!empty($call)) { |
|
217 | + $xml = call_user_func($call, $xml_format); |
|
218 | + } |
|
207 | 219 | |
208 | 220 | if (!empty($modSettings['cache_enable']) && (($user_info['is_guest'] && $modSettings['cache_enable'] >= 3) |
209 | - || (!$user_info['is_guest'] && (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.2)))) |
|
210 | - cache_put_data('xmlfeed-' . $xml_format . ':' . ($user_info['is_guest'] ? '' : $user_info['id'] . '-') . $cachekey, $xml, 240); |
|
221 | + || (!$user_info['is_guest'] && (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.2)))) { |
|
222 | + cache_put_data('xmlfeed-' . $xml_format . ':' . ($user_info['is_guest'] ? '' : $user_info['id'] . '-') . $cachekey, $xml, 240); |
|
223 | + } |
|
211 | 224 | } |
212 | 225 | |
213 | 226 | $feed_title = $smcFunc['htmlspecialchars'](strip_tags($context['forum_name'])) . (isset($feed_title) ? $feed_title : ''); |
@@ -218,19 +231,21 @@ discard block |
||
218 | 231 | |
219 | 232 | // This is an xml file.... |
220 | 233 | ob_end_clean(); |
221 | - if (!empty($modSettings['enableCompressedOutput'])) |
|
222 | - @ob_start('ob_gzhandler'); |
|
223 | - else |
|
224 | - ob_start(); |
|
234 | + if (!empty($modSettings['enableCompressedOutput'])) { |
|
235 | + @ob_start('ob_gzhandler'); |
|
236 | + } else { |
|
237 | + ob_start(); |
|
238 | + } |
|
225 | 239 | |
226 | - if ($xml_format == 'smf' || isset($_REQUEST['debug'])) |
|
227 | - header('Content-Type: text/xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
228 | - elseif ($xml_format == 'rss' || $xml_format == 'rss2') |
|
229 | - header('Content-Type: application/rss+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
230 | - elseif ($xml_format == 'atom') |
|
231 | - header('Content-Type: application/atom+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
232 | - elseif ($xml_format == 'rdf') |
|
233 | - header('Content-Type: ' . (isBrowser('ie') ? 'text/xml' : 'application/rdf+xml') . '; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
240 | + if ($xml_format == 'smf' || isset($_REQUEST['debug'])) { |
|
241 | + header('Content-Type: text/xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
242 | + } elseif ($xml_format == 'rss' || $xml_format == 'rss2') { |
|
243 | + header('Content-Type: application/rss+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
244 | + } elseif ($xml_format == 'atom') { |
|
245 | + header('Content-Type: application/atom+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
246 | + } elseif ($xml_format == 'rdf') { |
|
247 | + header('Content-Type: ' . (isBrowser('ie') ? 'text/xml' : 'application/rdf+xml') . '; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
248 | + } |
|
234 | 249 | |
235 | 250 | // First, output the xml header. |
236 | 251 | echo '<?xml version="1.0" encoding="', $context['character_set'], '"?' . '>'; |
@@ -247,8 +262,9 @@ discard block |
||
247 | 262 | <description>', cdata_parse(strip_tags($txt['xml_rss_desc'])), '</description>'; |
248 | 263 | |
249 | 264 | // RSS2 calls for this. |
250 | - if ($xml_format == 'rss2') |
|
251 | - echo '<atom:link rel="self" type="application/rss+xml" href="', $scripturl, '?action=.xml', !empty($_GET['sa']) ? ';sa=' . $_GET['sa'] : '', ';type=rss2" />'; |
|
265 | + if ($xml_format == 'rss2') { |
|
266 | + echo '<atom:link rel="self" type="application/rss+xml" href="', $scripturl, '?action=.xml', !empty($_GET['sa']) ? ';sa=' . $_GET['sa'] : '', ';type=rss2" />'; |
|
267 | + } |
|
252 | 268 | |
253 | 269 | // Output all of the associative array, start indenting with 2 tabs, and name everything "item". |
254 | 270 | dumpTags($xml, 2, 'item', $xml_format); |
@@ -257,12 +273,12 @@ discard block |
||
257 | 273 | echo ' |
258 | 274 | </channel> |
259 | 275 | </rss>'; |
260 | - } |
|
261 | - elseif ($xml_format == 'atom') |
|
276 | + } elseif ($xml_format == 'atom') |
|
262 | 277 | { |
263 | - foreach ($_REQUEST as $var => $val) |
|
264 | - if (in_array($var, array('action', 'sa', 'type', 'board', 'boards', 'c', 'u', 'limit'))) |
|
278 | + foreach ($_REQUEST as $var => $val) { |
|
279 | + if (in_array($var, array('action', 'sa', 'type', 'board', 'boards', 'c', 'u', 'limit'))) |
|
265 | 280 | $url_parts[] = $var . '=' . (is_array($_REQUEST[$var]) ? implode(',', $_REQUEST[$var]) : $_REQUEST[$var]); |
281 | + } |
|
266 | 282 | |
267 | 283 | echo ' |
268 | 284 | <feed xmlns="http://www.w3.org/2005/Atom"> |
@@ -283,8 +299,7 @@ discard block |
||
283 | 299 | |
284 | 300 | echo ' |
285 | 301 | </feed>'; |
286 | - } |
|
287 | - elseif ($xml_format == 'rdf') |
|
302 | + } elseif ($xml_format == 'rdf') |
|
288 | 303 | { |
289 | 304 | echo ' |
290 | 305 | <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns="http://purl.org/rss/1.0/"> |
@@ -295,9 +310,10 @@ discard block |
||
295 | 310 | <items> |
296 | 311 | <rdf:Seq>'; |
297 | 312 | |
298 | - foreach ($xml as $item) |
|
299 | - echo ' |
|
313 | + foreach ($xml as $item) { |
|
314 | + echo ' |
|
300 | 315 | <rdf:li rdf:resource="', $item['link'], '" />'; |
316 | + } |
|
301 | 317 | |
302 | 318 | echo ' |
303 | 319 | </rdf:Seq> |
@@ -337,13 +353,15 @@ discard block |
||
337 | 353 | { |
338 | 354 | global $modSettings, $context, $scripturl; |
339 | 355 | |
340 | - if (substr($val, 0, strlen($scripturl)) != $scripturl) |
|
341 | - return $val; |
|
356 | + if (substr($val, 0, strlen($scripturl)) != $scripturl) { |
|
357 | + return $val; |
|
358 | + } |
|
342 | 359 | |
343 | 360 | call_integration_hook('integrate_fix_url', array(&$val)); |
344 | 361 | |
345 | - if (empty($modSettings['queryless_urls']) || ($context['server']['is_cgi'] && ini_get('cgi.fix_pathinfo') == 0 && @get_cfg_var('cgi.fix_pathinfo') == 0) || (!$context['server']['is_apache'] && !$context['server']['is_lighttpd'])) |
|
346 | - return $val; |
|
362 | + if (empty($modSettings['queryless_urls']) || ($context['server']['is_cgi'] && ini_get('cgi.fix_pathinfo') == 0 && @get_cfg_var('cgi.fix_pathinfo') == 0) || (!$context['server']['is_apache'] && !$context['server']['is_lighttpd'])) { |
|
363 | + return $val; |
|
364 | + } |
|
347 | 365 | |
348 | 366 | $val = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+)(#[^"]*)?$~', function ($m) use ($scripturl) |
349 | 367 | { |
@@ -365,8 +383,9 @@ discard block |
||
365 | 383 | global $smcFunc; |
366 | 384 | |
367 | 385 | // Do we even need to do this? |
368 | - if (strpbrk($data, '<>&') == false) |
|
369 | - return $data; |
|
386 | + if (strpbrk($data, '<>&') == false) { |
|
387 | + return $data; |
|
388 | + } |
|
370 | 389 | |
371 | 390 | $cdata = '<, |
377 | 396 | $smcFunc['strpos']($data, ']', $pos), |
378 | 397 | ); |
379 | - if ($ns != '') |
|
380 | - $positions[] = $smcFunc['strpos']($data, '<', $pos); |
|
398 | + if ($ns != '') { |
|
399 | + $positions[] = $smcFunc['strpos']($data, '<', $pos); |
|
400 | + } |
|
381 | 401 | foreach ($positions as $k => $dummy) |
382 | 402 | { |
383 | - if ($dummy === false) |
|
384 | - unset($positions[$k]); |
|
403 | + if ($dummy === false) { |
|
404 | + unset($positions[$k]); |
|
405 | + } |
|
385 | 406 | } |
386 | 407 | |
387 | 408 | $old = $pos; |
388 | 409 | $pos = empty($positions) ? $n : min($positions); |
389 | 410 | |
390 | - if ($pos - $old > 0) |
|
391 | - $cdata .= $smcFunc['substr']($data, $old, $pos - $old); |
|
392 | - if ($pos >= $n) |
|
393 | - break; |
|
411 | + if ($pos - $old > 0) { |
|
412 | + $cdata .= $smcFunc['substr']($data, $old, $pos - $old); |
|
413 | + } |
|
414 | + if ($pos >= $n) { |
|
415 | + break; |
|
416 | + } |
|
394 | 417 | |
395 | 418 | if ($smcFunc['substr']($data, $pos, 1) == '<') |
396 | 419 | { |
397 | 420 | $pos2 = $smcFunc['strpos']($data, '>', $pos); |
398 | - if ($pos2 === false) |
|
399 | - $pos2 = $n; |
|
400 | - if ($smcFunc['substr']($data, $pos + 1, 1) == '/') |
|
401 | - $cdata .= ']]></' . $ns . ':' . $smcFunc['substr']($data, $pos + 2, $pos2 - $pos - 1) . '<![CDATA['; |
|
402 | - else |
|
403 | - $cdata .= ']]><' . $ns . ':' . $smcFunc['substr']($data, $pos + 1, $pos2 - $pos) . '< == '/') { |
|
425 | + $cdata .= ']]></' . $ns . ':' . $smcFunc['substr']($data, $pos + 2, $pos2 - $pos - 1) . '<![CDATA['; |
|
426 | + } else { |
|
427 | + $cdata .= ']]><' . $ns . ':' . $smcFunc['substr']($data, $pos + 1, $pos2 - $pos) . '< == ']') |
|
430 | + } elseif ($smcFunc['substr']($data, $pos, 1) == ']') |
|
407 | 431 | { |
408 | 432 | $cdata .= ']]>]< == '&') |
|
434 | + } elseif ($smcFunc['substr']($data, $pos, 1) == '&') |
|
412 | 435 | { |
413 | 436 | $pos2 = $smcFunc['strpos']($data, ';', $pos); |
414 | - if ($pos2 === false) |
|
415 | - $pos2 = $n; |
|
437 | + if ($pos2 === false) { |
|
438 | + $pos2 = $n; |
|
439 | + } |
|
416 | 440 | $ent = $smcFunc['substr']($data, $pos + 1, $pos2 - $pos - 1); |
417 | 441 | |
418 | - if ($smcFunc['substr']($data, $pos + 1, 1) == '#') |
|
419 | - $cdata .= ']]>' . $smcFunc['substr']($data, $pos, $pos2 - $pos + 1) . '<![CDATA['; |
|
420 | - elseif (in_array($ent, array('amp', 'lt', 'gt', 'quot'))) |
|
421 | - $cdata .= ']]>' . $smcFunc['substr']($data, $pos, $pos2 - $pos + 1) . '< == '#') { |
|
443 | + $cdata .= ']]>' . $smcFunc['substr']($data, $pos, $pos2 - $pos + 1) . '<![CDATA['; |
|
444 | + } elseif (in_array($ent, array('amp', 'lt', 'gt', 'quot'))) { |
|
445 | + $cdata .= ']]>' . $smcFunc['substr']($data, $pos, $pos2 - $pos + 1) . '<![CDATA['; |
|
446 | + } |
|
422 | 447 | |
423 | 448 | $pos = $pos2 + 1; |
424 | 449 | } |
@@ -456,19 +481,22 @@ discard block |
||
456 | 481 | 'gender', |
457 | 482 | 'blurb', |
458 | 483 | ); |
459 | - if ($xml_format != 'atom') |
|
460 | - $keysToCdata[] = 'category'; |
|
484 | + if ($xml_format != 'atom') { |
|
485 | + $keysToCdata[] = 'category'; |
|
486 | + } |
|
461 | 487 | |
462 | 488 | // For every array in the data... |
463 | 489 | foreach ($data as $key => $val) |
464 | 490 | { |
465 | 491 | // Skip it, it's been set to null. |
466 | - if ($val === null) |
|
467 | - continue; |
|
492 | + if ($val === null) { |
|
493 | + continue; |
|
494 | + } |
|
468 | 495 | |
469 | 496 | // If the value should maybe be CDATA, do that now. |
470 | - if (!is_array($val) && in_array($key, $keysToCdata)) |
|
471 | - $val = cdata_parse($val); |
|
497 | + if (!is_array($val) && in_array($key, $keysToCdata)) { |
|
498 | + $val = cdata_parse($val); |
|
499 | + } |
|
472 | 500 | |
473 | 501 | // If a tag was passed, use it instead of the key. |
474 | 502 | $key = isset($tag) ? $tag : $key; |
@@ -484,11 +512,11 @@ discard block |
||
484 | 512 | } |
485 | 513 | |
486 | 514 | // If it's empty/0/nothing simply output an empty tag. |
487 | - if ($val == '') |
|
488 | - echo '<', $key, ' />'; |
|
489 | - elseif ($xml_format == 'atom' && $key == 'category') |
|
490 | - echo '<', $key, ' term="', $val, '" />'; |
|
491 | - else |
|
515 | + if ($val == '') { |
|
516 | + echo '<', $key, ' />'; |
|
517 | + } elseif ($xml_format == 'atom' && $key == 'category') { |
|
518 | + echo '<', $key, ' term="', $val, '" />'; |
|
519 | + } else |
|
492 | 520 | { |
493 | 521 | // Beginning tag. |
494 | 522 | if ($xml_format == 'rdf' && $key == 'item' && isset($val['link'])) |
@@ -496,11 +524,11 @@ discard block |
||
496 | 524 | echo '<', $key, ' rdf:about="', fix_possible_url($val['link']), '">'; |
497 | 525 | echo "\n", str_repeat("\t", $i + 1); |
498 | 526 | echo '<dc:format>text/html</dc:format>'; |
527 | + } elseif ($xml_format == 'atom' && $key == 'summary') { |
|
528 | + echo '<', $key, ' type="html">'; |
|
529 | + } else { |
|
530 | + echo '<', $key, '>'; |
|
499 | 531 | } |
500 | - elseif ($xml_format == 'atom' && $key == 'summary') |
|
501 | - echo '<', $key, ' type="html">'; |
|
502 | - else |
|
503 | - echo '<', $key, '>'; |
|
504 | 532 | |
505 | 533 | // The element's value. |
506 | 534 | if (is_array($val)) |
@@ -510,11 +538,13 @@ discard block |
||
510 | 538 | echo "\n", str_repeat("\t", $i); |
511 | 539 | } |
512 | 540 | // A string with returns in it.... show this as a multiline element. |
513 | - elseif (strpos($val, "\n") !== false || preg_match('~<br ?/?' . '>~', $val) !== false) |
|
514 | - echo "\n", fix_possible_url($val), "\n", str_repeat("\t", $i); |
|
541 | + elseif (strpos($val, "\n") !== false || preg_match('~<br ?/?' . '>~', $val) !== false) { |
|
542 | + echo "\n", fix_possible_url($val), "\n", str_repeat("\t", $i); |
|
543 | + } |
|
515 | 544 | // A simple string. |
516 | - else |
|
517 | - echo fix_possible_url($val); |
|
545 | + else { |
|
546 | + echo fix_possible_url($val); |
|
547 | + } |
|
518 | 548 | |
519 | 549 | // Ending tag. |
520 | 550 | echo '</', $key, '>'; |
@@ -534,8 +564,9 @@ discard block |
||
534 | 564 | { |
535 | 565 | global $scripturl, $smcFunc; |
536 | 566 | |
537 | - if (!allowedTo('view_mlist')) |
|
538 | - return array(); |
|
567 | + if (!allowedTo('view_mlist')) { |
|
568 | + return array(); |
|
569 | + } |
|
539 | 570 | |
540 | 571 | // Find the most recent members. |
541 | 572 | $request = $smcFunc['db_query']('', ' |
@@ -551,35 +582,37 @@ discard block |
||
551 | 582 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
552 | 583 | { |
553 | 584 | // Make the data look rss-ish. |
554 | - if ($xml_format == 'rss' || $xml_format == 'rss2') |
|
555 | - $data[] = array( |
|
585 | + if ($xml_format == 'rss' || $xml_format == 'rss2') { |
|
586 | + $data[] = array( |
|
556 | 587 | 'title' => $row['real_name'], |
557 | 588 | 'link' => $scripturl . '?action=profile;u=' . $row['id_member'], |
558 | 589 | 'comments' => $scripturl . '?action=pm;sa=send;u=' . $row['id_member'], |
559 | 590 | 'pubDate' => gmdate('D, d M Y H:i:s \G\M\T', $row['date_registered']), |
560 | 591 | 'guid' => $scripturl . '?action=profile;u=' . $row['id_member'], |
561 | 592 | ); |
562 | - elseif ($xml_format == 'rdf') |
|
563 | - $data[] = array( |
|
593 | + } elseif ($xml_format == 'rdf') { |
|
594 | + $data[] = array( |
|
564 | 595 | 'title' => $row['real_name'], |
565 | 596 | 'link' => $scripturl . '?action=profile;u=' . $row['id_member'], |
566 | 597 | ); |
567 | - elseif ($xml_format == 'atom') |
|
568 | - $data[] = array( |
|
598 | + } elseif ($xml_format == 'atom') { |
|
599 | + $data[] = array( |
|
569 | 600 | 'title' => $row['real_name'], |
570 | 601 | 'link' => $scripturl . '?action=profile;u=' . $row['id_member'], |
571 | 602 | 'published' => gmstrftime('%Y-%m-%dT%H:%M:%SZ', $row['date_registered']), |
572 | 603 | 'updated' => gmstrftime('%Y-%m-%dT%H:%M:%SZ', $row['last_login']), |
573 | 604 | 'id' => $scripturl . '?action=profile;u=' . $row['id_member'], |
574 | 605 | ); |
606 | + } |
|
575 | 607 | // More logical format for the data, but harder to apply. |
576 | - else |
|
577 | - $data[] = array( |
|
608 | + else { |
|
609 | + $data[] = array( |
|
578 | 610 | 'name' => $row['real_name'], |
579 | 611 | 'time' => $smcFunc['htmlspecialchars'](strip_tags(timeformat($row['date_registered']))), |
580 | 612 | 'id' => $row['id_member'], |
581 | 613 | 'link' => $scripturl . '?action=profile;u=' . $row['id_member'] |
582 | 614 | ); |
615 | + } |
|
583 | 616 | } |
584 | 617 | $smcFunc['db_free_result']($request); |
585 | 618 | |
@@ -640,22 +673,24 @@ discard block |
||
640 | 673 | if ($loops < 2 && $smcFunc['db_num_rows']($request) < $_GET['limit']) |
641 | 674 | { |
642 | 675 | $smcFunc['db_free_result']($request); |
643 | - if (empty($_REQUEST['boards']) && empty($board)) |
|
644 | - unset($context['optimize_msg']['lowest']); |
|
645 | - else |
|
646 | - $context['optimize_msg']['lowest'] = 'm.id_msg >= t.id_first_msg'; |
|
676 | + if (empty($_REQUEST['boards']) && empty($board)) { |
|
677 | + unset($context['optimize_msg']['lowest']); |
|
678 | + } else { |
|
679 | + $context['optimize_msg']['lowest'] = 'm.id_msg >= t.id_first_msg'; |
|
680 | + } |
|
647 | 681 | $context['optimize_msg']['highest'] = 'm.id_msg <= t.id_last_msg'; |
648 | 682 | $loops++; |
683 | + } else { |
|
684 | + $done = true; |
|
649 | 685 | } |
650 | - else |
|
651 | - $done = true; |
|
652 | 686 | } |
653 | 687 | $data = array(); |
654 | 688 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
655 | 689 | { |
656 | 690 | // Limit the length of the message, if the option is set. |
657 | - if (!empty($modSettings['xmlnews_maxlen']) && $smcFunc['strlen'](str_replace('<br>', "\n", $row['body'])) > $modSettings['xmlnews_maxlen']) |
|
658 | - $row['body'] = strtr($smcFunc['substr'](str_replace('<br>', "\n", $row['body']), 0, $modSettings['xmlnews_maxlen'] - 3), array("\n" => '<br>')) . '...'; |
|
691 | + if (!empty($modSettings['xmlnews_maxlen']) && $smcFunc['strlen'](str_replace('<br>', "\n", $row['body'])) > $modSettings['xmlnews_maxlen']) { |
|
692 | + $row['body'] = strtr($smcFunc['substr'](str_replace('<br>', "\n", $row['body']), 0, $modSettings['xmlnews_maxlen'] - 3), array("\n" => '<br>')) . '...'; |
|
693 | + } |
|
659 | 694 | |
660 | 695 | $row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']); |
661 | 696 | |
@@ -663,8 +698,8 @@ discard block |
||
663 | 698 | censorText($row['subject']); |
664 | 699 | |
665 | 700 | // Being news, this actually makes sense in rss format. |
666 | - if ($xml_format == 'rss' || $xml_format == 'rss2') |
|
667 | - $data[] = array( |
|
701 | + if ($xml_format == 'rss' || $xml_format == 'rss2') { |
|
702 | + $data[] = array( |
|
668 | 703 | 'title' => $row['subject'], |
669 | 704 | 'link' => $scripturl . '?topic=' . $row['id_topic'] . '.0', |
670 | 705 | 'description' => $row['body'], |
@@ -674,14 +709,14 @@ discard block |
||
674 | 709 | 'pubDate' => gmdate('D, d M Y H:i:s \G\M\T', $row['poster_time']), |
675 | 710 | 'guid' => $scripturl . '?topic=' . $row['id_topic'] . '.0', |
676 | 711 | ); |
677 | - elseif ($xml_format == 'rdf') |
|
678 | - $data[] = array( |
|
712 | + } elseif ($xml_format == 'rdf') { |
|
713 | + $data[] = array( |
|
679 | 714 | 'title' => $row['subject'], |
680 | 715 | 'link' => $scripturl . '?topic=' . $row['id_topic'] . '.0', |
681 | 716 | 'description' => $row['body'], |
682 | 717 | ); |
683 | - elseif ($xml_format == 'atom') |
|
684 | - $data[] = array( |
|
718 | + } elseif ($xml_format == 'atom') { |
|
719 | + $data[] = array( |
|
685 | 720 | 'title' => $row['subject'], |
686 | 721 | 'link' => $scripturl . '?topic=' . $row['id_topic'] . '.0', |
687 | 722 | 'summary' => $row['body'], |
@@ -695,9 +730,10 @@ discard block |
||
695 | 730 | 'updated' => gmstrftime('%Y-%m-%dT%H:%M:%SZ', empty($row['modified_time']) ? $row['poster_time'] : $row['modified_time']), |
696 | 731 | 'id' => $scripturl . '?topic=' . $row['id_topic'] . '.0', |
697 | 732 | ); |
733 | + } |
|
698 | 734 | // The biggest difference here is more information. |
699 | - else |
|
700 | - $data[] = array( |
|
735 | + else { |
|
736 | + $data[] = array( |
|
701 | 737 | 'time' => $smcFunc['htmlspecialchars'](strip_tags(timeformat($row['poster_time']))), |
702 | 738 | 'id' => $row['id_topic'], |
703 | 739 | 'subject' => $row['subject'], |
@@ -715,6 +751,7 @@ discard block |
||
715 | 751 | ), |
716 | 752 | 'link' => $scripturl . '?topic=' . $row['id_topic'] . '.0', |
717 | 753 | ); |
754 | + } |
|
718 | 755 | } |
719 | 756 | $smcFunc['db_free_result']($request); |
720 | 757 | |
@@ -761,22 +798,25 @@ discard block |
||
761 | 798 | if ($loops < 2 && $smcFunc['db_num_rows']($request) < $_GET['limit']) |
762 | 799 | { |
763 | 800 | $smcFunc['db_free_result']($request); |
764 | - if (empty($_REQUEST['boards']) && empty($board)) |
|
765 | - unset($context['optimize_msg']['lowest']); |
|
766 | - else |
|
767 | - $context['optimize_msg']['lowest'] = $loops ? 'm.id_msg >= t.id_first_msg' : 'm.id_msg >= (t.id_last_msg - t.id_first_msg) / 2'; |
|
801 | + if (empty($_REQUEST['boards']) && empty($board)) { |
|
802 | + unset($context['optimize_msg']['lowest']); |
|
803 | + } else { |
|
804 | + $context['optimize_msg']['lowest'] = $loops ? 'm.id_msg >= t.id_first_msg' : 'm.id_msg >= (t.id_last_msg - t.id_first_msg) / 2'; |
|
805 | + } |
|
768 | 806 | $loops++; |
807 | + } else { |
|
808 | + $done = true; |
|
769 | 809 | } |
770 | - else |
|
771 | - $done = true; |
|
772 | 810 | } |
773 | 811 | $messages = array(); |
774 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
775 | - $messages[] = $row['id_msg']; |
|
812 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
813 | + $messages[] = $row['id_msg']; |
|
814 | + } |
|
776 | 815 | $smcFunc['db_free_result']($request); |
777 | 816 | |
778 | - if (empty($messages)) |
|
779 | - return array(); |
|
817 | + if (empty($messages)) { |
|
818 | + return array(); |
|
819 | + } |
|
780 | 820 | |
781 | 821 | // Find the most recent posts this user can see. |
782 | 822 | $request = $smcFunc['db_query']('', ' |
@@ -806,8 +846,9 @@ discard block |
||
806 | 846 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
807 | 847 | { |
808 | 848 | // Limit the length of the message, if the option is set. |
809 | - if (!empty($modSettings['xmlnews_maxlen']) && $smcFunc['strlen'](str_replace('<br>', "\n", $row['body'])) > $modSettings['xmlnews_maxlen']) |
|
810 | - $row['body'] = strtr($smcFunc['substr'](str_replace('<br>', "\n", $row['body']), 0, $modSettings['xmlnews_maxlen'] - 3), array("\n" => '<br>')) . '...'; |
|
849 | + if (!empty($modSettings['xmlnews_maxlen']) && $smcFunc['strlen'](str_replace('<br>', "\n", $row['body'])) > $modSettings['xmlnews_maxlen']) { |
|
850 | + $row['body'] = strtr($smcFunc['substr'](str_replace('<br>', "\n", $row['body']), 0, $modSettings['xmlnews_maxlen'] - 3), array("\n" => '<br>')) . '...'; |
|
851 | + } |
|
811 | 852 | |
812 | 853 | $row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']); |
813 | 854 | |
@@ -815,8 +856,8 @@ discard block |
||
815 | 856 | censorText($row['subject']); |
816 | 857 | |
817 | 858 | // Doesn't work as well as news, but it kinda does.. |
818 | - if ($xml_format == 'rss' || $xml_format == 'rss2') |
|
819 | - $data[] = array( |
|
859 | + if ($xml_format == 'rss' || $xml_format == 'rss2') { |
|
860 | + $data[] = array( |
|
820 | 861 | 'title' => $row['subject'], |
821 | 862 | 'link' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'], |
822 | 863 | 'description' => $row['body'], |
@@ -826,14 +867,14 @@ discard block |
||
826 | 867 | 'pubDate' => gmdate('D, d M Y H:i:s \G\M\T', $row['poster_time']), |
827 | 868 | 'guid' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] |
828 | 869 | ); |
829 | - elseif ($xml_format == 'rdf') |
|
830 | - $data[] = array( |
|
870 | + } elseif ($xml_format == 'rdf') { |
|
871 | + $data[] = array( |
|
831 | 872 | 'title' => $row['subject'], |
832 | 873 | 'link' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'], |
833 | 874 | 'description' => $row['body'], |
834 | 875 | ); |
835 | - elseif ($xml_format == 'atom') |
|
836 | - $data[] = array( |
|
876 | + } elseif ($xml_format == 'atom') { |
|
877 | + $data[] = array( |
|
837 | 878 | 'title' => $row['subject'], |
838 | 879 | 'link' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'], |
839 | 880 | 'summary' => $row['body'], |
@@ -847,9 +888,10 @@ discard block |
||
847 | 888 | 'updated' => gmstrftime('%Y-%m-%dT%H:%M:%SZ', empty($row['modified_time']) ? $row['poster_time'] : $row['modified_time']), |
848 | 889 | 'id' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'], |
849 | 890 | ); |
891 | + } |
|
850 | 892 | // A lot of information here. Should be enough to please the rss-ers. |
851 | - else |
|
852 | - $data[] = array( |
|
893 | + else { |
|
894 | + $data[] = array( |
|
853 | 895 | 'time' => $smcFunc['htmlspecialchars'](strip_tags(timeformat($row['poster_time']))), |
854 | 896 | 'id' => $row['id_msg'], |
855 | 897 | 'subject' => $row['subject'], |
@@ -876,6 +918,7 @@ discard block |
||
876 | 918 | ), |
877 | 919 | 'link' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] |
878 | 920 | ); |
921 | + } |
|
879 | 922 | } |
880 | 923 | $smcFunc['db_free_result']($request); |
881 | 924 | |
@@ -895,20 +938,22 @@ discard block |
||
895 | 938 | global $scripturl, $memberContext, $user_profile, $user_info; |
896 | 939 | |
897 | 940 | // You must input a valid user.... |
898 | - if (empty($_GET['u']) || !loadMemberData((int) $_GET['u'])) |
|
899 | - return array(); |
|
941 | + if (empty($_GET['u']) || !loadMemberData((int) $_GET['u'])) { |
|
942 | + return array(); |
|
943 | + } |
|
900 | 944 | |
901 | 945 | // Make sure the id is a number and not "I like trying to hack the database". |
902 | 946 | $_GET['u'] = (int) $_GET['u']; |
903 | 947 | // Load the member's contextual information! |
904 | - if (!loadMemberContext($_GET['u']) || !allowedTo('profile_view')) |
|
905 | - return array(); |
|
948 | + if (!loadMemberContext($_GET['u']) || !allowedTo('profile_view')) { |
|
949 | + return array(); |
|
950 | + } |
|
906 | 951 | |
907 | 952 | // Okay, I admit it, I'm lazy. Stupid $_GET['u'] is long and hard to type. |
908 | 953 | $profile = &$memberContext[$_GET['u']]; |
909 | 954 | |
910 | - if ($xml_format == 'rss' || $xml_format == 'rss2') |
|
911 | - $data = array(array( |
|
955 | + if ($xml_format == 'rss' || $xml_format == 'rss2') { |
|
956 | + $data = array(array( |
|
912 | 957 | 'title' => $profile['name'], |
913 | 958 | 'link' => $scripturl . '?action=profile;u=' . $profile['id'], |
914 | 959 | 'description' => isset($profile['group']) ? $profile['group'] : $profile['post_group'], |
@@ -916,14 +961,14 @@ discard block |
||
916 | 961 | 'pubDate' => gmdate('D, d M Y H:i:s \G\M\T', $user_profile[$profile['id']]['date_registered']), |
917 | 962 | 'guid' => $scripturl . '?action=profile;u=' . $profile['id'], |
918 | 963 | )); |
919 | - elseif ($xml_format == 'rdf') |
|
920 | - $data = array(array( |
|
964 | + } elseif ($xml_format == 'rdf') { |
|
965 | + $data = array(array( |
|
921 | 966 | 'title' => $profile['name'], |
922 | 967 | 'link' => $scripturl . '?action=profile;u=' . $profile['id'], |
923 | 968 | 'description' => isset($profile['group']) ? $profile['group'] : $profile['post_group'], |
924 | 969 | )); |
925 | - elseif ($xml_format == 'atom') |
|
926 | - $data[] = array( |
|
970 | + } elseif ($xml_format == 'atom') { |
|
971 | + $data[] = array( |
|
927 | 972 | 'title' => $profile['name'], |
928 | 973 | 'link' => $scripturl . '?action=profile;u=' . $profile['id'], |
929 | 974 | 'summary' => isset($profile['group']) ? $profile['group'] : $profile['post_group'], |
@@ -937,7 +982,7 @@ discard block |
||
937 | 982 | 'id' => $scripturl . '?action=profile;u=' . $profile['id'], |
938 | 983 | 'logo' => !empty($profile['avatar']) ? $profile['avatar']['url'] : '', |
939 | 984 | ); |
940 | - else |
|
985 | + } else |
|
941 | 986 | { |
942 | 987 | $data = array( |
943 | 988 | 'username' => $user_info['is_admin'] || $user_info['id'] == $profile['id'] ? $profile['username'] : '', |
@@ -951,34 +996,43 @@ discard block |
||
951 | 996 | ); |
952 | 997 | |
953 | 998 | // Everything below here might not be set, and thus maybe shouldn't be displayed. |
954 | - if ($profile['gender']['name'] != '') |
|
955 | - $data['gender'] = $profile['gender']['name']; |
|
999 | + if ($profile['gender']['name'] != '') { |
|
1000 | + $data['gender'] = $profile['gender']['name']; |
|
1001 | + } |
|
956 | 1002 | |
957 | - if ($profile['avatar']['name'] != '') |
|
958 | - $data['avatar'] = $profile['avatar']['url']; |
|
1003 | + if ($profile['avatar']['name'] != '') { |
|
1004 | + $data['avatar'] = $profile['avatar']['url']; |
|
1005 | + } |
|
959 | 1006 | |
960 | 1007 | // If they are online, show an empty tag... no reason to put anything inside it. |
961 | - if ($profile['online']['is_online']) |
|
962 | - $data['online'] = ''; |
|
963 | - |
|
964 | - if ($profile['signature'] != '') |
|
965 | - $data['signature'] = $profile['signature']; |
|
966 | - if ($profile['blurb'] != '') |
|
967 | - $data['blurb'] = $profile['blurb']; |
|
968 | - if ($profile['title'] != '') |
|
969 | - $data['title'] = $profile['title']; |
|
970 | - |
|
971 | - if ($profile['website']['title'] != '') |
|
972 | - $data['website'] = array( |
|
1008 | + if ($profile['online']['is_online']) { |
|
1009 | + $data['online'] = ''; |
|
1010 | + } |
|
1011 | + |
|
1012 | + if ($profile['signature'] != '') { |
|
1013 | + $data['signature'] = $profile['signature']; |
|
1014 | + } |
|
1015 | + if ($profile['blurb'] != '') { |
|
1016 | + $data['blurb'] = $profile['blurb']; |
|
1017 | + } |
|
1018 | + if ($profile['title'] != '') { |
|
1019 | + $data['title'] = $profile['title']; |
|
1020 | + } |
|
1021 | + |
|
1022 | + if ($profile['website']['title'] != '') { |
|
1023 | + $data['website'] = array( |
|
973 | 1024 | 'title' => $profile['website']['title'], |
974 | 1025 | 'link' => $profile['website']['url'] |
975 | 1026 | ); |
1027 | + } |
|
976 | 1028 | |
977 | - if ($profile['group'] != '') |
|
978 | - $data['position'] = $profile['group']; |
|
1029 | + if ($profile['group'] != '') { |
|
1030 | + $data['position'] = $profile['group']; |
|
1031 | + } |
|
979 | 1032 | |
980 | - if ($profile['show_email']) |
|
981 | - $data['email'] = $profile['email']; |
|
1033 | + if ($profile['show_email']) { |
|
1034 | + $data['email'] = $profile['email']; |
|
1035 | + } |
|
982 | 1036 | |
983 | 1037 | if (!empty($profile['birth_date']) && substr($profile['birth_date'], 0, 4) != '0000') |
984 | 1038 | { |
@@ -1799,9 +1799,9 @@ |
||
1799 | 1799 | } |
1800 | 1800 | |
1801 | 1801 | /** |
1802 | - * Callback for createList(). |
|
1803 | - * @return int The total number of warning templates |
|
1804 | - */ |
|
1802 | + * Callback for createList(). |
|
1803 | + * @return int The total number of warning templates |
|
1804 | + */ |
|
1805 | 1805 | function list_getWarningTemplateCount() |
1806 | 1806 | { |
1807 | 1807 | global $smcFunc, $user_info; |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | $note_owner = $smcFunc['db_num_rows']($get_owner); |
403 | 403 | $smcFunc['db_free_result']($get_owner); |
404 | 404 | |
405 | - if(empty($note_owner)) |
|
405 | + if (empty($note_owner)) |
|
406 | 406 | fatal_lang_error('mc_notes_delete_own', false); |
407 | 407 | } |
408 | 408 | |
@@ -585,7 +585,7 @@ discard block |
||
585 | 585 | 'status_open' => 0, |
586 | 586 | ) |
587 | 587 | ); |
588 | - for ($i = 0; $row = $smcFunc['db_fetch_assoc']($request); $i ++) |
|
588 | + for ($i = 0; $row = $smcFunc['db_fetch_assoc']($request); $i++) |
|
589 | 589 | { |
590 | 590 | $context['group_requests'][] = array( |
591 | 591 | 'id' => $row['id_request'], |
@@ -735,7 +735,7 @@ discard block |
||
735 | 735 | $smcFunc['db_free_result']($request); |
736 | 736 | |
737 | 737 | // Stick this in string format for consistency |
738 | - $extra['member'] = (string)$extra['member']; |
|
738 | + $extra['member'] = (string) $extra['member']; |
|
739 | 739 | |
740 | 740 | // Tell the user about it. |
741 | 741 | $context['report_member_action'] = isset($_GET['ignore']) ? (!empty($_GET['ignore']) ? 'ignore' : 'unignore') : (!empty($_GET['close']) ? 'close' : 'open'); |
@@ -777,7 +777,7 @@ discard block |
||
777 | 777 | 'extra' => array( |
778 | 778 | 'report' => $reports['id_report'], |
779 | 779 | 'membername' => $reports['membername'], |
780 | - 'member' => (string)$reports['id_member'], |
|
780 | + 'member' => (string) $reports['id_member'], |
|
781 | 781 | ), |
782 | 782 | ); |
783 | 783 | } |
@@ -1073,7 +1073,7 @@ discard block |
||
1073 | 1073 | 'value' => $txt['mc_watched_users_warning'], |
1074 | 1074 | ), |
1075 | 1075 | 'data' => array( |
1076 | - 'function' => function ($member) use ($scripturl) |
|
1076 | + 'function' => function($member) use ($scripturl) |
|
1077 | 1077 | { |
1078 | 1078 | return allowedTo('issue_warning') ? '<a href="' . $scripturl . '?action=profile;area=issuewarning;u=' . $member['id'] . '">' . $member['warning'] . '%</a>' : $member['warning'] . '%'; |
1079 | 1079 | }, |
@@ -1118,7 +1118,7 @@ discard block |
||
1118 | 1118 | 'value' => $txt['mc_watched_users_last_post'], |
1119 | 1119 | ), |
1120 | 1120 | 'data' => array( |
1121 | - 'function' => function ($member) use ($scripturl) |
|
1121 | + 'function' => function($member) use ($scripturl) |
|
1122 | 1122 | { |
1123 | 1123 | if ($member['last_post_id']) |
1124 | 1124 | return '<a href="' . $scripturl . '?msg=' . $member['last_post_id'] . '">' . $member['last_post'] . '</a>'; |
@@ -1153,7 +1153,7 @@ discard block |
||
1153 | 1153 | $listOptions['columns'] = array( |
1154 | 1154 | 'posts' => array( |
1155 | 1155 | 'data' => array( |
1156 | - 'function' => function ($post) |
|
1156 | + 'function' => function($post) |
|
1157 | 1157 | { |
1158 | 1158 | return template_user_watch_post_callback($post); |
1159 | 1159 | }, |
@@ -1393,7 +1393,7 @@ discard block |
||
1393 | 1393 | |
1394 | 1394 | call_integration_hook('integrate_warning_log_actions', array(&$subActions)); |
1395 | 1395 | |
1396 | - $_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) && (empty($subActions[$_REQUEST['sa']][1]) || allowedTo($subActions[$_REQUEST['sa']]))? $_REQUEST['sa'] : 'log'; |
|
1396 | + $_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) && (empty($subActions[$_REQUEST['sa']][1]) || allowedTo($subActions[$_REQUEST['sa']])) ? $_REQUEST['sa'] : 'log'; |
|
1397 | 1397 | |
1398 | 1398 | // Some of this stuff is overseas, so to speak. |
1399 | 1399 | loadTemplate('ModerationCenter'); |
@@ -1459,7 +1459,7 @@ discard block |
||
1459 | 1459 | 'type' => $search_params_type, |
1460 | 1460 | ); |
1461 | 1461 | |
1462 | - $context['url_start'] = '?action=moderate;area=warnings;sa=log;sort='. $context['order']; |
|
1462 | + $context['url_start'] = '?action=moderate;area=warnings;sa=log;sort=' . $context['order']; |
|
1463 | 1463 | |
1464 | 1464 | // Setup the search context. |
1465 | 1465 | $context['search_params'] = empty($search_params['string']) ? '' : base64_encode(json_encode($search_params)); |
@@ -1528,7 +1528,7 @@ discard block |
||
1528 | 1528 | 'value' => $txt['profile_warning_previous_reason'], |
1529 | 1529 | ), |
1530 | 1530 | 'data' => array( |
1531 | - 'function' => function ($rowData) use ($scripturl, $txt) |
|
1531 | + 'function' => function($rowData) use ($scripturl, $txt) |
|
1532 | 1532 | { |
1533 | 1533 | $output = ' |
1534 | 1534 | <div class="floatleft"> |
@@ -1564,7 +1564,7 @@ discard block |
||
1564 | 1564 | array( |
1565 | 1565 | 'position' => 'below_table_data', |
1566 | 1566 | 'value' => ' |
1567 | - ' . $txt['modlog_search'] .': |
|
1567 | + ' . $txt['modlog_search'] . ': |
|
1568 | 1568 | <input type="text" name="search" size="18" value="' . $smcFunc['htmlspecialchars']($context['search']['string']) . '" class="input_text"> |
1569 | 1569 | <input type="submit" name="is_search" value="' . $txt['modlog_go'] . '" class="button_submit">', |
1570 | 1570 | 'class' => 'floatright', |
@@ -1766,7 +1766,7 @@ discard block |
||
1766 | 1766 | 'class' => 'centercol', |
1767 | 1767 | ), |
1768 | 1768 | 'data' => array( |
1769 | - 'function' => function ($rowData) |
|
1769 | + 'function' => function($rowData) |
|
1770 | 1770 | { |
1771 | 1771 | return '<input type="checkbox" name="deltpl[]" value="' . $rowData['id_comment'] . '" class="input_check">'; |
1772 | 1772 | }, |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Entry point for the moderation center. |
@@ -26,8 +27,9 @@ discard block |
||
26 | 27 | global $txt, $context, $scripturl, $modSettings, $user_info, $sourcedir, $options; |
27 | 28 | |
28 | 29 | // Don't run this twice... and don't conflict with the admin bar. |
29 | - if (isset($context['admin_area'])) |
|
30 | - return; |
|
30 | + if (isset($context['admin_area'])) { |
|
31 | + return; |
|
32 | + } |
|
31 | 33 | |
32 | 34 | $context['can_moderate_boards'] = $user_info['mod_cache']['bq'] != '0=1'; |
33 | 35 | $context['can_moderate_groups'] = $user_info['mod_cache']['gq'] != '0=1'; |
@@ -35,8 +37,9 @@ discard block |
||
35 | 37 | $context['can_moderate_users'] = allowedTo('moderate_forum'); |
36 | 38 | |
37 | 39 | // Everyone using this area must be allowed here! |
38 | - if (!$context['can_moderate_boards'] && !$context['can_moderate_groups'] && !$context['can_moderate_approvals'] && !$context['can_moderate_users']) |
|
39 | - isAllowedTo('access_mod_center'); |
|
40 | + if (!$context['can_moderate_boards'] && !$context['can_moderate_groups'] && !$context['can_moderate_approvals'] && !$context['can_moderate_users']) { |
|
41 | + isAllowedTo('access_mod_center'); |
|
42 | + } |
|
40 | 43 | |
41 | 44 | // We're gonna want a menu of some kind. |
42 | 45 | require_once($sourcedir . '/Subs-Menu.php'); |
@@ -195,8 +198,9 @@ discard block |
||
195 | 198 | unset($moderation_areas); |
196 | 199 | |
197 | 200 | // We got something - didn't we? DIDN'T WE! |
198 | - if ($mod_include_data == false) |
|
199 | - fatal_lang_error('no_access', false); |
|
201 | + if ($mod_include_data == false) { |
|
202 | + fatal_lang_error('no_access', false); |
|
203 | + } |
|
200 | 204 | |
201 | 205 | // Retain the ID information in case required by a subaction. |
202 | 206 | $context['moderation_menu_id'] = $context['max_menu_id']; |
@@ -219,22 +223,25 @@ discard block |
||
219 | 223 | 'url' => $scripturl . '?action=moderate', |
220 | 224 | 'name' => $txt['moderation_center'], |
221 | 225 | ); |
222 | - if (isset($mod_include_data['current_area']) && $mod_include_data['current_area'] != 'index') |
|
223 | - $context['linktree'][] = array( |
|
226 | + if (isset($mod_include_data['current_area']) && $mod_include_data['current_area'] != 'index') { |
|
227 | + $context['linktree'][] = array( |
|
224 | 228 | 'url' => $scripturl . '?action=moderate;area=' . $mod_include_data['current_area'], |
225 | 229 | 'name' => $mod_include_data['label'], |
226 | 230 | ); |
227 | - if (!empty($mod_include_data['current_subsection']) && $mod_include_data['subsections'][$mod_include_data['current_subsection']][0] != $mod_include_data['label']) |
|
228 | - $context['linktree'][] = array( |
|
231 | + } |
|
232 | + if (!empty($mod_include_data['current_subsection']) && $mod_include_data['subsections'][$mod_include_data['current_subsection']][0] != $mod_include_data['label']) { |
|
233 | + $context['linktree'][] = array( |
|
229 | 234 | 'url' => $scripturl . '?action=moderate;area=' . $mod_include_data['current_area'] . ';sa=' . $mod_include_data['current_subsection'], |
230 | 235 | 'name' => $mod_include_data['subsections'][$mod_include_data['current_subsection']][0], |
231 | 236 | ); |
237 | + } |
|
232 | 238 | |
233 | 239 | // Now - finally - the bit before the encore - the main performance of course! |
234 | 240 | if (!$dont_call) |
235 | 241 | { |
236 | - if (isset($mod_include_data['file'])) |
|
237 | - require_once($sourcedir . '/' . $mod_include_data['file']); |
|
242 | + if (isset($mod_include_data['file'])) { |
|
243 | + require_once($sourcedir . '/' . $mod_include_data['file']); |
|
244 | + } |
|
238 | 245 | |
239 | 246 | call_helper($mod_include_data['function']); |
240 | 247 | } |
@@ -259,8 +266,9 @@ discard block |
||
259 | 266 | // Load what blocks the user actually can see... |
260 | 267 | $valid_blocks = array(); |
261 | 268 | |
262 | - if ($context['can_moderate_groups']) |
|
263 | - $valid_blocks['g'] = 'GroupRequests'; |
|
269 | + if ($context['can_moderate_groups']) { |
|
270 | + $valid_blocks['g'] = 'GroupRequests'; |
|
271 | + } |
|
264 | 272 | if ($context['can_moderate_boards']) |
265 | 273 | { |
266 | 274 | $valid_blocks['r'] = 'ReportedPosts'; |
@@ -269,8 +277,9 @@ discard block |
||
269 | 277 | if ($context['can_moderate_users']) |
270 | 278 | { |
271 | 279 | // This falls under the category of moderating users as well... |
272 | - if (!$context['can_moderate_boards']) |
|
273 | - $valid_blocks['w'] = 'WatchedUsers'; |
|
280 | + if (!$context['can_moderate_boards']) { |
|
281 | + $valid_blocks['w'] = 'WatchedUsers'; |
|
282 | + } |
|
274 | 283 | |
275 | 284 | $valid_blocks['rm'] = 'ReportedMembers'; |
276 | 285 | } |
@@ -281,8 +290,9 @@ discard block |
||
281 | 290 | foreach ($valid_blocks as $k => $block) |
282 | 291 | { |
283 | 292 | $block = 'ModBlock' . $block; |
284 | - if (function_exists($block)) |
|
285 | - $context['mod_blocks'][] = $block(); |
|
293 | + if (function_exists($block)) { |
|
294 | + $context['mod_blocks'][] = $block(); |
|
295 | + } |
|
286 | 296 | } |
287 | 297 | |
288 | 298 | $context['admin_prefs'] = !empty($options['admin_preferences']) ? smf_json_decode($options['admin_preferences'], true) : array(); |
@@ -309,8 +319,9 @@ discard block |
||
309 | 319 | ) |
310 | 320 | ); |
311 | 321 | $watched_users = array(); |
312 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
313 | - $watched_users[] = $row; |
|
322 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
323 | + $watched_users[] = $row; |
|
324 | + } |
|
314 | 325 | $smcFunc['db_free_result']($request); |
315 | 326 | |
316 | 327 | cache_put_data('recent_user_watches', $watched_users, 240); |
@@ -402,8 +413,9 @@ discard block |
||
402 | 413 | $note_owner = $smcFunc['db_num_rows']($get_owner); |
403 | 414 | $smcFunc['db_free_result']($get_owner); |
404 | 415 | |
405 | - if(empty($note_owner)) |
|
406 | - fatal_lang_error('mc_notes_delete_own', false); |
|
416 | + if(empty($note_owner)) { |
|
417 | + fatal_lang_error('mc_notes_delete_own', false); |
|
418 | + } |
|
407 | 419 | } |
408 | 420 | |
409 | 421 | // Lets delete it. |
@@ -460,12 +472,14 @@ discard block |
||
460 | 472 | ) |
461 | 473 | ); |
462 | 474 | $moderator_notes = array(); |
463 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
464 | - $moderator_notes[] = $row; |
|
475 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
476 | + $moderator_notes[] = $row; |
|
477 | + } |
|
465 | 478 | $smcFunc['db_free_result']($request); |
466 | 479 | |
467 | - if ($offset == 0) |
|
468 | - cache_put_data('moderator_notes', $moderator_notes, 240); |
|
480 | + if ($offset == 0) { |
|
481 | + cache_put_data('moderator_notes', $moderator_notes, 240); |
|
482 | + } |
|
469 | 483 | } |
470 | 484 | |
471 | 485 | // Lets construct a page index. |
@@ -504,8 +518,9 @@ discard block |
||
504 | 518 | // Got the info already? |
505 | 519 | $cachekey = md5(json_encode($user_info['mod_cache']['bq'])); |
506 | 520 | $context['reported_posts'] = array(); |
507 | - if ($user_info['mod_cache']['bq'] == '0=1') |
|
508 | - return 'reported_posts_block'; |
|
521 | + if ($user_info['mod_cache']['bq'] == '0=1') { |
|
522 | + return 'reported_posts_block'; |
|
523 | + } |
|
509 | 524 | |
510 | 525 | if (($reported_posts = cache_get_data('reported_posts_' . $cachekey, 90)) === null) |
511 | 526 | { |
@@ -529,8 +544,9 @@ discard block |
||
529 | 544 | ) |
530 | 545 | ); |
531 | 546 | $reported_posts = array(); |
532 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
533 | - $reported_posts[] = $row; |
|
547 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
548 | + $reported_posts[] = $row; |
|
549 | + } |
|
534 | 550 | $smcFunc['db_free_result']($request); |
535 | 551 | |
536 | 552 | // Cache it. |
@@ -568,8 +584,9 @@ discard block |
||
568 | 584 | |
569 | 585 | $context['group_requests'] = array(); |
570 | 586 | // Make sure they can even moderate someone! |
571 | - if ($user_info['mod_cache']['gq'] == '0=1') |
|
572 | - return 'group_requests_block'; |
|
587 | + if ($user_info['mod_cache']['gq'] == '0=1') { |
|
588 | + return 'group_requests_block'; |
|
589 | + } |
|
573 | 590 | |
574 | 591 | // What requests are outstanding? |
575 | 592 | $request = $smcFunc['db_query']('', ' |
@@ -618,8 +635,9 @@ discard block |
||
618 | 635 | // Got the info already? |
619 | 636 | $cachekey = md5(json_encode((int) allowedTo('moderate_forum'))); |
620 | 637 | $context['reported_users'] = array(); |
621 | - if (!allowedTo('moderate_forum')) |
|
622 | - return 'reported_users_block'; |
|
638 | + if (!allowedTo('moderate_forum')) { |
|
639 | + return 'reported_users_block'; |
|
640 | + } |
|
623 | 641 | |
624 | 642 | if (($reported_users = cache_get_data('reported_users_' . $cachekey, 90)) === null) |
625 | 643 | { |
@@ -642,8 +660,9 @@ discard block |
||
642 | 660 | ) |
643 | 661 | ); |
644 | 662 | $reported_users = array(); |
645 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
646 | - $reported_users[] = $row; |
|
663 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
664 | + $reported_users[] = $row; |
|
665 | + } |
|
647 | 666 | $smcFunc['db_free_result']($request); |
648 | 667 | |
649 | 668 | // Cache it. |
@@ -691,8 +710,9 @@ discard block |
||
691 | 710 | isAllowedTo('moderate_forum'); |
692 | 711 | |
693 | 712 | // Are they wanting to view a particular report? |
694 | - if (!empty($_REQUEST['report'])) |
|
695 | - return MemberReport(); |
|
713 | + if (!empty($_REQUEST['report'])) { |
|
714 | + return MemberReport(); |
|
715 | + } |
|
696 | 716 | |
697 | 717 | // Set up the comforting bits... |
698 | 718 | $context['page_title'] = $txt['mc_reported_members']; |
@@ -746,15 +766,15 @@ discard block |
||
746 | 766 | // Time to update. |
747 | 767 | updateSettings(array('last_mod_report_action' => time())); |
748 | 768 | recountOpenReports('members'); |
749 | - } |
|
750 | - elseif (isset($_POST['close']) && isset($_POST['close_selected'])) |
|
769 | + } elseif (isset($_POST['close']) && isset($_POST['close_selected'])) |
|
751 | 770 | { |
752 | 771 | checkSession(); |
753 | 772 | |
754 | 773 | // All the ones to update... |
755 | 774 | $toClose = array(); |
756 | - foreach ($_POST['close'] as $rid) |
|
757 | - $toClose[] = (int) $rid; |
|
775 | + foreach ($_POST['close'] as $rid) { |
|
776 | + $toClose[] = (int) $rid; |
|
777 | + } |
|
758 | 778 | |
759 | 779 | if (!empty($toClose)) |
760 | 780 | { |
@@ -907,8 +927,9 @@ discard block |
||
907 | 927 | global $context, $user_info; |
908 | 928 | |
909 | 929 | // You need to be allowed to moderate groups... |
910 | - if ($user_info['mod_cache']['gq'] == '0=1') |
|
911 | - isAllowedTo('manage_membergroups'); |
|
930 | + if ($user_info['mod_cache']['gq'] == '0=1') { |
|
931 | + isAllowedTo('manage_membergroups'); |
|
932 | + } |
|
912 | 933 | |
913 | 934 | // Load the group templates. |
914 | 935 | loadTemplate('ModerationCenter'); |
@@ -919,8 +940,9 @@ discard block |
||
919 | 940 | 'view' => 'ViewGroups', |
920 | 941 | ); |
921 | 942 | |
922 | - if (!isset($_GET['sa']) || !isset($subActions[$_GET['sa']])) |
|
923 | - $_GET['sa'] = 'view'; |
|
943 | + if (!isset($_GET['sa']) || !isset($subActions[$_GET['sa']])) { |
|
944 | + $_GET['sa'] = 'view'; |
|
945 | + } |
|
924 | 946 | $context['sub_action'] = $_GET['sa']; |
925 | 947 | |
926 | 948 | // Call the relevant function. |
@@ -950,8 +972,9 @@ discard block |
||
950 | 972 | 'id_notice' => $id_notice, |
951 | 973 | ) |
952 | 974 | ); |
953 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
954 | - fatal_lang_error('no_access', false); |
|
975 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
976 | + fatal_lang_error('no_access', false); |
|
977 | + } |
|
955 | 978 | list ($context['notice_body'], $context['notice_subject']) = $smcFunc['db_fetch_row']($request); |
956 | 979 | $smcFunc['db_free_result']($request); |
957 | 980 | |
@@ -988,18 +1011,20 @@ discard block |
||
988 | 1011 | checkSession(!is_array($_REQUEST['delete']) ? 'get' : 'post'); |
989 | 1012 | |
990 | 1013 | $toDelete = array(); |
991 | - if (!is_array($_REQUEST['delete'])) |
|
992 | - $toDelete[] = (int) $_REQUEST['delete']; |
|
993 | - else |
|
994 | - foreach ($_REQUEST['delete'] as $did) |
|
1014 | + if (!is_array($_REQUEST['delete'])) { |
|
1015 | + $toDelete[] = (int) $_REQUEST['delete']; |
|
1016 | + } else { |
|
1017 | + foreach ($_REQUEST['delete'] as $did) |
|
995 | 1018 | $toDelete[] = (int) $did; |
1019 | + } |
|
996 | 1020 | |
997 | 1021 | if (!empty($toDelete)) |
998 | 1022 | { |
999 | 1023 | require_once($sourcedir . '/RemoveTopic.php'); |
1000 | 1024 | // If they don't have permission we'll let it error - either way no chance of a security slip here! |
1001 | - foreach ($toDelete as $did) |
|
1002 | - removeMessage($did); |
|
1025 | + foreach ($toDelete as $did) { |
|
1026 | + removeMessage($did); |
|
1027 | + } |
|
1003 | 1028 | } |
1004 | 1029 | } |
1005 | 1030 | |
@@ -1008,20 +1033,21 @@ discard block |
||
1008 | 1033 | { |
1009 | 1034 | $approve_query = ''; |
1010 | 1035 | $delete_boards = array(); |
1011 | - } |
|
1012 | - else |
|
1036 | + } else |
|
1013 | 1037 | { |
1014 | 1038 | // Still obey permissions! |
1015 | 1039 | $approve_boards = boardsAllowedTo('approve_posts'); |
1016 | 1040 | $delete_boards = boardsAllowedTo('delete_any'); |
1017 | 1041 | |
1018 | - if ($approve_boards == array(0)) |
|
1019 | - $approve_query = ''; |
|
1020 | - elseif (!empty($approve_boards)) |
|
1021 | - $approve_query = ' AND m.id_board IN (' . implode(',', $approve_boards) . ')'; |
|
1042 | + if ($approve_boards == array(0)) { |
|
1043 | + $approve_query = ''; |
|
1044 | + } elseif (!empty($approve_boards)) { |
|
1045 | + $approve_query = ' AND m.id_board IN (' . implode(',', $approve_boards) . ')'; |
|
1046 | + } |
|
1022 | 1047 | // Nada, zip, etc... |
1023 | - else |
|
1024 | - $approve_query = ' AND 1=0'; |
|
1048 | + else { |
|
1049 | + $approve_query = ' AND 1=0'; |
|
1050 | + } |
|
1025 | 1051 | } |
1026 | 1052 | |
1027 | 1053 | require_once($sourcedir . '/Subs-List.php'); |
@@ -1120,10 +1146,11 @@ discard block |
||
1120 | 1146 | 'data' => array( |
1121 | 1147 | 'function' => function ($member) use ($scripturl) |
1122 | 1148 | { |
1123 | - if ($member['last_post_id']) |
|
1124 | - return '<a href="' . $scripturl . '?msg=' . $member['last_post_id'] . '">' . $member['last_post'] . '</a>'; |
|
1125 | - else |
|
1126 | - return $member['last_post']; |
|
1149 | + if ($member['last_post_id']) { |
|
1150 | + return '<a href="' . $scripturl . '?msg=' . $member['last_post_id'] . '">' . $member['last_post'] . '</a>'; |
|
1151 | + } else { |
|
1152 | + return $member['last_post']; |
|
1153 | + } |
|
1127 | 1154 | }, |
1128 | 1155 | ), |
1129 | 1156 | ), |
@@ -1251,8 +1278,9 @@ discard block |
||
1251 | 1278 | ) |
1252 | 1279 | ); |
1253 | 1280 | $latest_posts = array(); |
1254 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1255 | - $latest_posts[$row['id_member']] = $row['last_post_id']; |
|
1281 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1282 | + $latest_posts[$row['id_member']] = $row['last_post_id']; |
|
1283 | + } |
|
1256 | 1284 | |
1257 | 1285 | if (!empty($latest_posts)) |
1258 | 1286 | { |
@@ -1443,15 +1471,17 @@ discard block |
||
1443 | 1471 | // Setup the direction stuff... |
1444 | 1472 | $context['order'] = isset($_REQUEST['sort']) && isset($sort_types[$_REQUEST['sort']]) ? $_REQUEST['sort'] : 'member'; |
1445 | 1473 | |
1446 | - if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search'])) |
|
1447 | - $search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search']; |
|
1448 | - else |
|
1449 | - $search_params_string = $search_params['string']; |
|
1474 | + if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search'])) { |
|
1475 | + $search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search']; |
|
1476 | + } else { |
|
1477 | + $search_params_string = $search_params['string']; |
|
1478 | + } |
|
1450 | 1479 | |
1451 | - if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']])) |
|
1452 | - $search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member'); |
|
1453 | - else |
|
1454 | - $search_params_type = $search_params['type']; |
|
1480 | + if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']])) { |
|
1481 | + $search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member'); |
|
1482 | + } else { |
|
1483 | + $search_params_type = $search_params['type']; |
|
1484 | + } |
|
1455 | 1485 | |
1456 | 1486 | $search_params_column = $searchTypes[$search_params_type]['sql']; |
1457 | 1487 | $search_params = array( |
@@ -1535,9 +1565,10 @@ discard block |
||
1535 | 1565 | ' . $rowData['reason'] . ' |
1536 | 1566 | </div>'; |
1537 | 1567 | |
1538 | - if (!empty($rowData['id_notice'])) |
|
1539 | - $output .= ' |
|
1568 | + if (!empty($rowData['id_notice'])) { |
|
1569 | + $output .= ' |
|
1540 | 1570 | <a href="' . $scripturl . '?action=moderate;area=notice;nid=' . $rowData['id_notice'] . '" onclick="window.open(this.href, \'\', \'scrollbars=yes,resizable=yes,width=400,height=250\');return false;" target="_blank" class="new_win" title="' . $txt['profile_warning_previous_notice'] . '"><span class="generic_icons filter centericon"></span></a>'; |
1571 | + } |
|
1541 | 1572 | return $output; |
1542 | 1573 | }, |
1543 | 1574 | ), |
@@ -1655,9 +1686,9 @@ discard block |
||
1655 | 1686 | global $smcFunc, $modSettings, $context, $txt, $scripturl, $sourcedir, $user_info; |
1656 | 1687 | |
1657 | 1688 | // Submitting a new one? |
1658 | - if (isset($_POST['add'])) |
|
1659 | - return ModifyWarningTemplate(); |
|
1660 | - elseif (isset($_POST['delete']) && !empty($_POST['deltpl'])) |
|
1689 | + if (isset($_POST['add'])) { |
|
1690 | + return ModifyWarningTemplate(); |
|
1691 | + } elseif (isset($_POST['delete']) && !empty($_POST['deltpl'])) |
|
1661 | 1692 | { |
1662 | 1693 | checkSession(); |
1663 | 1694 | validateToken('mod-wt'); |
@@ -1676,8 +1707,9 @@ discard block |
||
1676 | 1707 | 'current_member' => $user_info['id'], |
1677 | 1708 | ) |
1678 | 1709 | ); |
1679 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1680 | - logAction('delete_warn_template', array('template' => $row['recipient_name'])); |
|
1710 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1711 | + logAction('delete_warn_template', array('template' => $row['recipient_name'])); |
|
1712 | + } |
|
1681 | 1713 | $smcFunc['db_free_result']($request); |
1682 | 1714 | |
1683 | 1715 | // Do the deletes. |
@@ -1968,16 +2000,18 @@ discard block |
||
1968 | 2000 | ); |
1969 | 2001 | |
1970 | 2002 | // If it wasn't visible and now is they've effectively added it. |
1971 | - if ($context['template_data']['personal'] && !$recipient_id) |
|
1972 | - logAction('add_warn_template', array('template' => $_POST['template_title'])); |
|
2003 | + if ($context['template_data']['personal'] && !$recipient_id) { |
|
2004 | + logAction('add_warn_template', array('template' => $_POST['template_title'])); |
|
2005 | + } |
|
1973 | 2006 | // Conversely if they made it personal it's a delete. |
1974 | - elseif (!$context['template_data']['personal'] && $recipient_id) |
|
1975 | - logAction('delete_warn_template', array('template' => $_POST['template_title'])); |
|
2007 | + elseif (!$context['template_data']['personal'] && $recipient_id) { |
|
2008 | + logAction('delete_warn_template', array('template' => $_POST['template_title'])); |
|
2009 | + } |
|
1976 | 2010 | // Otherwise just an edit. |
1977 | - else |
|
1978 | - logAction('modify_warn_template', array('template' => $_POST['template_title'])); |
|
1979 | - } |
|
1980 | - else |
|
2011 | + else { |
|
2012 | + logAction('modify_warn_template', array('template' => $_POST['template_title'])); |
|
2013 | + } |
|
2014 | + } else |
|
1981 | 2015 | { |
1982 | 2016 | $smcFunc['db_insert']('', |
1983 | 2017 | '{db_prefix}log_comments', |
@@ -1997,17 +2031,18 @@ discard block |
||
1997 | 2031 | |
1998 | 2032 | // Get out of town... |
1999 | 2033 | redirectexit('action=moderate;area=warnings;sa=templates'); |
2000 | - } |
|
2001 | - else |
|
2034 | + } else |
|
2002 | 2035 | { |
2003 | 2036 | $context['warning_errors'] = array(); |
2004 | 2037 | $context['template_data']['title'] = !empty($_POST['template_title']) ? $_POST['template_title'] : ''; |
2005 | 2038 | $context['template_data']['body'] = !empty($_POST['template_body']) ? $_POST['template_body'] : $txt['mc_warning_template_body_default']; |
2006 | 2039 | $context['template_data']['personal'] = !empty($_POST['make_personal']); |
2007 | - if (empty($_POST['template_title'])) |
|
2008 | - $context['warning_errors'][] = $txt['mc_warning_template_error_no_title']; |
|
2009 | - if (empty($_POST['template_body'])) |
|
2010 | - $context['warning_errors'][] = $txt['mc_warning_template_error_no_body']; |
|
2040 | + if (empty($_POST['template_title'])) { |
|
2041 | + $context['warning_errors'][] = $txt['mc_warning_template_error_no_title']; |
|
2042 | + } |
|
2043 | + if (empty($_POST['template_body'])) { |
|
2044 | + $context['warning_errors'][] = $txt['mc_warning_template_error_no_body']; |
|
2045 | + } |
|
2011 | 2046 | } |
2012 | 2047 | } |
2013 | 2048 | |
@@ -2054,8 +2089,9 @@ discard block |
||
2054 | 2089 | // Now check other options! |
2055 | 2090 | $pref_binary = 0; |
2056 | 2091 | |
2057 | - if ($context['can_moderate_approvals'] && !empty($_POST['mod_notify_approval'])) |
|
2058 | - $pref_binary |= 4; |
|
2092 | + if ($context['can_moderate_approvals'] && !empty($_POST['mod_notify_approval'])) { |
|
2093 | + $pref_binary |= 4; |
|
2094 | + } |
|
2059 | 2095 | |
2060 | 2096 | // Put it all together. |
2061 | 2097 | $mod_prefs = '0||' . $pref_binary; |
@@ -2079,9 +2115,10 @@ discard block |
||
2079 | 2115 | unset($_SESSION['moderate_time']); |
2080 | 2116 | |
2081 | 2117 | // Clean any moderator tokens as well. |
2082 | - foreach ($_SESSION['token'] as $key => $token) |
|
2083 | - if (strpos($key, '-mod') !== false) |
|
2118 | + foreach ($_SESSION['token'] as $key => $token) { |
|
2119 | + if (strpos($key, '-mod') !== false) |
|
2084 | 2120 | unset($_SESSION['token'][$key]); |
2121 | + } |
|
2085 | 2122 | |
2086 | 2123 | redirectexit(); |
2087 | 2124 | } |
@@ -760,7 +760,7 @@ discard block |
||
760 | 760 | array( |
761 | 761 | 'visible' => 0, |
762 | 762 | 'negative_one' => -1, |
763 | - 'invalid_groups' => array(1,3), |
|
763 | + 'invalid_groups' => array(1, 3), |
|
764 | 764 | 'moderator_group_list' => $moderator_groups, |
765 | 765 | 'limit' => count($moderator_groups), |
766 | 766 | ) |
@@ -838,7 +838,7 @@ discard block |
||
838 | 838 | 'member_groups' => 'string', 'redirect' => 'string', |
839 | 839 | ); |
840 | 840 | $board_parameters = array( |
841 | - $boardOptions['target_category'], $boardOptions['board_name'] , '', 0, |
|
841 | + $boardOptions['target_category'], $boardOptions['board_name'], '', 0, |
|
842 | 842 | '-1,0', '', |
843 | 843 | ); |
844 | 844 |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 3 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * Mark a board or multiple boards read. |
@@ -28,14 +29,16 @@ discard block |
||
28 | 29 | global $user_info, $modSettings, $smcFunc; |
29 | 30 | |
30 | 31 | // Force $boards to be an array. |
31 | - if (!is_array($boards)) |
|
32 | - $boards = array($boards); |
|
33 | - else |
|
34 | - $boards = array_unique($boards); |
|
32 | + if (!is_array($boards)) { |
|
33 | + $boards = array($boards); |
|
34 | + } else { |
|
35 | + $boards = array_unique($boards); |
|
36 | + } |
|
35 | 37 | |
36 | 38 | // No boards, nothing to mark as read. |
37 | - if (empty($boards)) |
|
38 | - return; |
|
39 | + if (empty($boards)) { |
|
40 | + return; |
|
41 | + } |
|
39 | 42 | |
40 | 43 | // Allow the user to mark a board as unread. |
41 | 44 | if ($unread) |
@@ -65,8 +68,9 @@ discard block |
||
65 | 68 | else |
66 | 69 | { |
67 | 70 | $markRead = array(); |
68 | - foreach ($boards as $board) |
|
69 | - $markRead[] = array($modSettings['maxMsgID'], $user_info['id'], $board); |
|
71 | + foreach ($boards as $board) { |
|
72 | + $markRead[] = array($modSettings['maxMsgID'], $user_info['id'], $board); |
|
73 | + } |
|
70 | 74 | |
71 | 75 | // Update log_mark_read and log_boards. |
72 | 76 | $smcFunc['db_insert']('replace', |
@@ -99,8 +103,9 @@ discard block |
||
99 | 103 | list ($lowest_topic) = $smcFunc['db_fetch_row']($result); |
100 | 104 | $smcFunc['db_free_result']($result); |
101 | 105 | |
102 | - if (empty($lowest_topic)) |
|
103 | - return; |
|
106 | + if (empty($lowest_topic)) { |
|
107 | + return; |
|
108 | + } |
|
104 | 109 | |
105 | 110 | // @todo SLOW This query seems to eat it sometimes. |
106 | 111 | $result = $smcFunc['db_query']('', ' |
@@ -118,12 +123,13 @@ discard block |
||
118 | 123 | ) |
119 | 124 | ); |
120 | 125 | $topics = array(); |
121 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
122 | - $topics[] = $row['id_topic']; |
|
126 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
127 | + $topics[] = $row['id_topic']; |
|
128 | + } |
|
123 | 129 | $smcFunc['db_free_result']($result); |
124 | 130 | |
125 | - if (!empty($topics)) |
|
126 | - $smcFunc['db_query']('', ' |
|
131 | + if (!empty($topics)) { |
|
132 | + $smcFunc['db_query']('', ' |
|
127 | 133 | DELETE FROM {db_prefix}log_topics |
128 | 134 | WHERE id_member = {int:current_member} |
129 | 135 | AND id_topic IN ({array_int:topic_list})', |
@@ -132,7 +138,8 @@ discard block |
||
132 | 138 | 'topic_list' => $topics, |
133 | 139 | ) |
134 | 140 | ); |
135 | -} |
|
141 | + } |
|
142 | + } |
|
136 | 143 | |
137 | 144 | /** |
138 | 145 | * Mark one or more boards as read. |
@@ -157,23 +164,26 @@ discard block |
||
157 | 164 | ) |
158 | 165 | ); |
159 | 166 | $boards = array(); |
160 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
161 | - $boards[] = $row['id_board']; |
|
167 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
168 | + $boards[] = $row['id_board']; |
|
169 | + } |
|
162 | 170 | $smcFunc['db_free_result']($result); |
163 | 171 | |
164 | - if (!empty($boards)) |
|
165 | - markBoardsRead($boards, isset($_REQUEST['unread'])); |
|
172 | + if (!empty($boards)) { |
|
173 | + markBoardsRead($boards, isset($_REQUEST['unread'])); |
|
174 | + } |
|
166 | 175 | |
167 | 176 | $_SESSION['id_msg_last_visit'] = $modSettings['maxMsgID']; |
168 | - if (!empty($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'action=unread') !== false) |
|
169 | - redirectexit('action=unread'); |
|
177 | + if (!empty($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'action=unread') !== false) { |
|
178 | + redirectexit('action=unread'); |
|
179 | + } |
|
170 | 180 | |
171 | - if (isset($_SESSION['topicseen_cache'])) |
|
172 | - $_SESSION['topicseen_cache'] = array(); |
|
181 | + if (isset($_SESSION['topicseen_cache'])) { |
|
182 | + $_SESSION['topicseen_cache'] = array(); |
|
183 | + } |
|
173 | 184 | |
174 | 185 | redirectexit(); |
175 | - } |
|
176 | - elseif (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'unreadreplies') |
|
186 | + } elseif (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'unreadreplies') |
|
177 | 187 | { |
178 | 188 | // Make sure all the topics are integers! |
179 | 189 | $topics = array_map('intval', explode('-', $_REQUEST['topics'])); |
@@ -189,13 +199,15 @@ discard block |
||
189 | 199 | ) |
190 | 200 | ); |
191 | 201 | $logged_topics = array(); |
192 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
193 | - $logged_topics[$row['id_topic']] = $row['unwatched']; |
|
202 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
203 | + $logged_topics[$row['id_topic']] = $row['unwatched']; |
|
204 | + } |
|
194 | 205 | $smcFunc['db_free_result']($request); |
195 | 206 | |
196 | 207 | $markRead = array(); |
197 | - foreach ($topics as $id_topic) |
|
198 | - $markRead[] = array($modSettings['maxMsgID'], $user_info['id'], $id_topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0)); |
|
208 | + foreach ($topics as $id_topic) { |
|
209 | + $markRead[] = array($modSettings['maxMsgID'], $user_info['id'], $id_topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0)); |
|
210 | + } |
|
199 | 211 | |
200 | 212 | $smcFunc['db_insert']('replace', |
201 | 213 | '{db_prefix}log_topics', |
@@ -204,8 +216,9 @@ discard block |
||
204 | 216 | array('id_member', 'id_topic') |
205 | 217 | ); |
206 | 218 | |
207 | - if (isset($_SESSION['topicseen_cache'])) |
|
208 | - $_SESSION['topicseen_cache'] = array(); |
|
219 | + if (isset($_SESSION['topicseen_cache'])) { |
|
220 | + $_SESSION['topicseen_cache'] = array(); |
|
221 | + } |
|
209 | 222 | |
210 | 223 | redirectexit('action=unreadreplies'); |
211 | 224 | } |
@@ -230,11 +243,13 @@ discard block |
||
230 | 243 | if (!empty($_GET['t'])) |
231 | 244 | { |
232 | 245 | // If they read the whole topic, go back to the beginning. |
233 | - if ($_GET['t'] >= $topicinfo['id_last_msg']) |
|
234 | - $earlyMsg = 0; |
|
246 | + if ($_GET['t'] >= $topicinfo['id_last_msg']) { |
|
247 | + $earlyMsg = 0; |
|
248 | + } |
|
235 | 249 | // If they want to mark the whole thing read, same. |
236 | - elseif ($_GET['t'] <= $topicinfo['id_first_msg']) |
|
237 | - $earlyMsg = 0; |
|
250 | + elseif ($_GET['t'] <= $topicinfo['id_first_msg']) { |
|
251 | + $earlyMsg = 0; |
|
252 | + } |
|
238 | 253 | // Otherwise, get the latest message before the named one. |
239 | 254 | else |
240 | 255 | { |
@@ -255,9 +270,9 @@ discard block |
||
255 | 270 | } |
256 | 271 | } |
257 | 272 | // Marking read from first page? That's the whole topic. |
258 | - elseif ($_REQUEST['start'] == 0) |
|
259 | - $earlyMsg = 0; |
|
260 | - else |
|
273 | + elseif ($_REQUEST['start'] == 0) { |
|
274 | + $earlyMsg = 0; |
|
275 | + } else |
|
261 | 276 | { |
262 | 277 | $result = $smcFunc['db_query']('', ' |
263 | 278 | SELECT id_msg |
@@ -285,8 +300,7 @@ discard block |
||
285 | 300 | ); |
286 | 301 | |
287 | 302 | redirectexit('board=' . $board . '.0'); |
288 | - } |
|
289 | - else |
|
303 | + } else |
|
290 | 304 | { |
291 | 305 | $categories = array(); |
292 | 306 | $boards = array(); |
@@ -294,17 +308,20 @@ discard block |
||
294 | 308 | if (isset($_REQUEST['c'])) |
295 | 309 | { |
296 | 310 | $_REQUEST['c'] = explode(',', $_REQUEST['c']); |
297 | - foreach ($_REQUEST['c'] as $c) |
|
298 | - $categories[] = (int) $c; |
|
311 | + foreach ($_REQUEST['c'] as $c) { |
|
312 | + $categories[] = (int) $c; |
|
313 | + } |
|
299 | 314 | } |
300 | 315 | if (isset($_REQUEST['boards'])) |
301 | 316 | { |
302 | 317 | $_REQUEST['boards'] = explode(',', $_REQUEST['boards']); |
303 | - foreach ($_REQUEST['boards'] as $b) |
|
304 | - $boards[] = (int) $b; |
|
318 | + foreach ($_REQUEST['boards'] as $b) { |
|
319 | + $boards[] = (int) $b; |
|
320 | + } |
|
321 | + } |
|
322 | + if (!empty($board)) { |
|
323 | + $boards[] = (int) $board; |
|
305 | 324 | } |
306 | - if (!empty($board)) |
|
307 | - $boards[] = (int) $board; |
|
308 | 325 | |
309 | 326 | if (isset($_REQUEST['children']) && !empty($boards)) |
310 | 327 | { |
@@ -324,9 +341,10 @@ discard block |
||
324 | 341 | 'board_list' => $boards, |
325 | 342 | ) |
326 | 343 | ); |
327 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
328 | - if (in_array($row['id_parent'], $boards)) |
|
344 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
345 | + if (in_array($row['id_parent'], $boards)) |
|
329 | 346 | $boards[] = $row['id_board']; |
347 | + } |
|
330 | 348 | $smcFunc['db_free_result']($request); |
331 | 349 | } |
332 | 350 | |
@@ -343,8 +361,9 @@ discard block |
||
343 | 361 | $clauseParameters['board_list'] = $boards; |
344 | 362 | } |
345 | 363 | |
346 | - if (empty($clauses)) |
|
347 | - redirectexit(); |
|
364 | + if (empty($clauses)) { |
|
365 | + redirectexit(); |
|
366 | + } |
|
348 | 367 | |
349 | 368 | $request = $smcFunc['db_query']('', ' |
350 | 369 | SELECT b.id_board |
@@ -355,19 +374,22 @@ discard block |
||
355 | 374 | )) |
356 | 375 | ); |
357 | 376 | $boards = array(); |
358 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
359 | - $boards[] = $row['id_board']; |
|
377 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
378 | + $boards[] = $row['id_board']; |
|
379 | + } |
|
360 | 380 | $smcFunc['db_free_result']($request); |
361 | 381 | |
362 | - if (empty($boards)) |
|
363 | - redirectexit(); |
|
382 | + if (empty($boards)) { |
|
383 | + redirectexit(); |
|
384 | + } |
|
364 | 385 | |
365 | 386 | markBoardsRead($boards, isset($_REQUEST['unread'])); |
366 | 387 | |
367 | 388 | foreach ($boards as $b) |
368 | 389 | { |
369 | - if (isset($_SESSION['topicseen_cache'][$b])) |
|
370 | - $_SESSION['topicseen_cache'][$b] = array(); |
|
390 | + if (isset($_SESSION['topicseen_cache'][$b])) { |
|
391 | + $_SESSION['topicseen_cache'][$b] = array(); |
|
392 | + } |
|
371 | 393 | } |
372 | 394 | |
373 | 395 | if (!isset($_REQUEST['unread'])) |
@@ -385,8 +407,9 @@ discard block |
||
385 | 407 | if ($smcFunc['db_num_rows']($result) > 0) |
386 | 408 | { |
387 | 409 | $logBoardInserts = ''; |
388 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
389 | - $logBoardInserts[] = array($modSettings['maxMsgID'], $user_info['id'], $row['id_board']); |
|
410 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
411 | + $logBoardInserts[] = array($modSettings['maxMsgID'], $user_info['id'], $row['id_board']); |
|
412 | + } |
|
390 | 413 | |
391 | 414 | $smcFunc['db_insert']('replace', |
392 | 415 | '{db_prefix}log_boards', |
@@ -397,17 +420,18 @@ discard block |
||
397 | 420 | } |
398 | 421 | $smcFunc['db_free_result']($result); |
399 | 422 | |
400 | - if (empty($board)) |
|
401 | - redirectexit(); |
|
402 | - else |
|
403 | - redirectexit('board=' . $board . '.0'); |
|
404 | - } |
|
405 | - else |
|
423 | + if (empty($board)) { |
|
424 | + redirectexit(); |
|
425 | + } else { |
|
426 | + redirectexit('board=' . $board . '.0'); |
|
427 | + } |
|
428 | + } else |
|
406 | 429 | { |
407 | - if (empty($board_info['parent'])) |
|
408 | - redirectexit(); |
|
409 | - else |
|
410 | - redirectexit('board=' . $board_info['parent'] . '.0'); |
|
430 | + if (empty($board_info['parent'])) { |
|
431 | + redirectexit(); |
|
432 | + } else { |
|
433 | + redirectexit('board=' . $board_info['parent'] . '.0'); |
|
434 | + } |
|
411 | 435 | } |
412 | 436 | } |
413 | 437 | } |
@@ -432,11 +456,13 @@ discard block |
||
432 | 456 | 'selected_message' => (int) $messageID, |
433 | 457 | ) |
434 | 458 | ); |
435 | - if ($smcFunc['db_num_rows']($result) > 0) |
|
436 | - list ($memberID) = $smcFunc['db_fetch_row']($result); |
|
459 | + if ($smcFunc['db_num_rows']($result) > 0) { |
|
460 | + list ($memberID) = $smcFunc['db_fetch_row']($result); |
|
461 | + } |
|
437 | 462 | // The message doesn't even exist. |
438 | - else |
|
439 | - $memberID = 0; |
|
463 | + else { |
|
464 | + $memberID = 0; |
|
465 | + } |
|
440 | 466 | $smcFunc['db_free_result']($result); |
441 | 467 | |
442 | 468 | return (int) $memberID; |
@@ -457,8 +483,9 @@ discard block |
||
457 | 483 | getBoardTree(); |
458 | 484 | |
459 | 485 | // Make sure given boards and categories exist. |
460 | - if (!isset($boards[$board_id]) || (isset($boardOptions['target_board']) && !isset($boards[$boardOptions['target_board']])) || (isset($boardOptions['target_category']) && !isset($cat_tree[$boardOptions['target_category']]))) |
|
461 | - fatal_lang_error('no_board'); |
|
486 | + if (!isset($boards[$board_id]) || (isset($boardOptions['target_board']) && !isset($boards[$boardOptions['target_board']])) || (isset($boardOptions['target_category']) && !isset($cat_tree[$boardOptions['target_category']]))) { |
|
487 | + fatal_lang_error('no_board'); |
|
488 | + } |
|
462 | 489 | |
463 | 490 | $id = $board_id; |
464 | 491 | call_integration_hook('integrate_pre_modify_board', array($id, &$boardOptions)); |
@@ -486,8 +513,9 @@ discard block |
||
486 | 513 | $child_level = 0; |
487 | 514 | $id_parent = 0; |
488 | 515 | $after = 0; |
489 | - foreach ($cat_tree[$id_cat]['children'] as $id_board => $dummy) |
|
490 | - $after = max($after, $boards[$id_board]['order']); |
|
516 | + foreach ($cat_tree[$id_cat]['children'] as $id_board => $dummy) { |
|
517 | + $after = max($after, $boards[$id_board]['order']); |
|
518 | + } |
|
491 | 519 | } |
492 | 520 | |
493 | 521 | // Make the board a child of a given board. |
@@ -498,17 +526,19 @@ discard block |
||
498 | 526 | $id_parent = $boardOptions['target_board']; |
499 | 527 | |
500 | 528 | // People can be creative, in many ways... |
501 | - if (isChildOf($id_parent, $board_id)) |
|
502 | - fatal_lang_error('mboards_parent_own_child_error', false); |
|
503 | - elseif ($id_parent == $board_id) |
|
504 | - fatal_lang_error('mboards_board_own_child_error', false); |
|
529 | + if (isChildOf($id_parent, $board_id)) { |
|
530 | + fatal_lang_error('mboards_parent_own_child_error', false); |
|
531 | + } elseif ($id_parent == $board_id) { |
|
532 | + fatal_lang_error('mboards_board_own_child_error', false); |
|
533 | + } |
|
505 | 534 | |
506 | 535 | $after = $boards[$boardOptions['target_board']]['order']; |
507 | 536 | |
508 | 537 | // Check if there are already children and (if so) get the max board order. |
509 | - if (!empty($boards[$id_parent]['tree']['children']) && empty($boardOptions['move_first_child'])) |
|
510 | - foreach ($boards[$id_parent]['tree']['children'] as $childBoard_id => $dummy) |
|
538 | + if (!empty($boards[$id_parent]['tree']['children']) && empty($boardOptions['move_first_child'])) { |
|
539 | + foreach ($boards[$id_parent]['tree']['children'] as $childBoard_id => $dummy) |
|
511 | 540 | $after = max($after, $boards[$childBoard_id]['order']); |
541 | + } |
|
512 | 542 | } |
513 | 543 | |
514 | 544 | // Place a board before or after another board, on the same child level. |
@@ -521,8 +551,9 @@ discard block |
||
521 | 551 | } |
522 | 552 | |
523 | 553 | // Oops...? |
524 | - else |
|
525 | - trigger_error('modifyBoard(): The move_to value \'' . $boardOptions['move_to'] . '\' is incorrect', E_USER_ERROR); |
|
554 | + else { |
|
555 | + trigger_error('modifyBoard(): The move_to value \'' . $boardOptions['move_to'] . '\' is incorrect', E_USER_ERROR); |
|
556 | + } |
|
526 | 557 | |
527 | 558 | // Get a list of children of this board. |
528 | 559 | $childList = array(); |
@@ -531,14 +562,16 @@ discard block |
||
531 | 562 | // See if there are changes that affect children. |
532 | 563 | $childUpdates = array(); |
533 | 564 | $levelDiff = $child_level - $boards[$board_id]['level']; |
534 | - if ($levelDiff != 0) |
|
535 | - $childUpdates[] = 'child_level = child_level ' . ($levelDiff > 0 ? '+ ' : '') . '{int:level_diff}'; |
|
536 | - if ($id_cat != $boards[$board_id]['category']) |
|
537 | - $childUpdates[] = 'id_cat = {int:category}'; |
|
565 | + if ($levelDiff != 0) { |
|
566 | + $childUpdates[] = 'child_level = child_level ' . ($levelDiff > 0 ? '+ ' : '') . '{int:level_diff}'; |
|
567 | + } |
|
568 | + if ($id_cat != $boards[$board_id]['category']) { |
|
569 | + $childUpdates[] = 'id_cat = {int:category}'; |
|
570 | + } |
|
538 | 571 | |
539 | 572 | // Fix the children of this board. |
540 | - if (!empty($childList) && !empty($childUpdates)) |
|
541 | - $smcFunc['db_query']('', ' |
|
573 | + if (!empty($childList) && !empty($childUpdates)) { |
|
574 | + $smcFunc['db_query']('', ' |
|
542 | 575 | UPDATE {db_prefix}boards |
543 | 576 | SET ' . implode(', |
544 | 577 | ', $childUpdates) . ' |
@@ -549,6 +582,7 @@ discard block |
||
549 | 582 | 'level_diff' => $levelDiff, |
550 | 583 | ) |
551 | 584 | ); |
585 | + } |
|
552 | 586 | |
553 | 587 | // Make some room for this spot. |
554 | 588 | $smcFunc['db_query']('', ' |
@@ -644,8 +678,8 @@ discard block |
||
644 | 678 | call_integration_hook('integrate_modify_board', array($id, &$boardUpdates, &$boardUpdateParameters)); |
645 | 679 | |
646 | 680 | // Do the updates (if any). |
647 | - if (!empty($boardUpdates)) |
|
648 | - $request = $smcFunc['db_query']('', ' |
|
681 | + if (!empty($boardUpdates)) { |
|
682 | + $request = $smcFunc['db_query']('', ' |
|
649 | 683 | UPDATE {db_prefix}boards |
650 | 684 | SET |
651 | 685 | ' . implode(', |
@@ -655,6 +689,7 @@ discard block |
||
655 | 689 | 'selected_board' => $board_id, |
656 | 690 | )) |
657 | 691 | ); |
692 | + } |
|
658 | 693 | |
659 | 694 | // Set moderators of this board. |
660 | 695 | if (isset($boardOptions['moderators']) || isset($boardOptions['moderator_string']) || isset($boardOptions['moderator_groups']) || isset($boardOptions['moderator_group_string'])) |
@@ -679,13 +714,15 @@ discard block |
||
679 | 714 | { |
680 | 715 | $moderators[$k] = trim($moderators[$k]); |
681 | 716 | |
682 | - if (strlen($moderators[$k]) == 0) |
|
683 | - unset($moderators[$k]); |
|
717 | + if (strlen($moderators[$k]) == 0) { |
|
718 | + unset($moderators[$k]); |
|
719 | + } |
|
684 | 720 | } |
685 | 721 | |
686 | 722 | // Find all the id_member's for the member_name's in the list. |
687 | - if (empty($boardOptions['moderators'])) |
|
688 | - $boardOptions['moderators'] = array(); |
|
723 | + if (empty($boardOptions['moderators'])) { |
|
724 | + $boardOptions['moderators'] = array(); |
|
725 | + } |
|
689 | 726 | if (!empty($moderators)) |
690 | 727 | { |
691 | 728 | $request = $smcFunc['db_query']('', ' |
@@ -698,8 +735,9 @@ discard block |
||
698 | 735 | 'limit' => count($moderators), |
699 | 736 | ) |
700 | 737 | ); |
701 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
702 | - $boardOptions['moderators'][] = $row['id_member']; |
|
738 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
739 | + $boardOptions['moderators'][] = $row['id_member']; |
|
740 | + } |
|
703 | 741 | $smcFunc['db_free_result']($request); |
704 | 742 | } |
705 | 743 | } |
@@ -708,8 +746,9 @@ discard block |
||
708 | 746 | if (!empty($boardOptions['moderators'])) |
709 | 747 | { |
710 | 748 | $inserts = array(); |
711 | - foreach ($boardOptions['moderators'] as $moderator) |
|
712 | - $inserts[] = array($board_id, $moderator); |
|
749 | + foreach ($boardOptions['moderators'] as $moderator) { |
|
750 | + $inserts[] = array($board_id, $moderator); |
|
751 | + } |
|
713 | 752 | |
714 | 753 | $smcFunc['db_insert']('insert', |
715 | 754 | '{db_prefix}moderators', |
@@ -739,14 +778,16 @@ discard block |
||
739 | 778 | { |
740 | 779 | $moderator_groups[$k] = trim($moderator_groups[$k]); |
741 | 780 | |
742 | - if (strlen($moderator_groups[$k]) == 0) |
|
743 | - unset($moderator_groups[$k]); |
|
781 | + if (strlen($moderator_groups[$k]) == 0) { |
|
782 | + unset($moderator_groups[$k]); |
|
783 | + } |
|
744 | 784 | } |
745 | 785 | |
746 | 786 | /* Find all the id_group's for all the group names in the list |
747 | 787 | But skip any invalid ones (invisible/post groups/Administrator/Moderator) */ |
748 | - if (empty($boardOptions['moderator_groups'])) |
|
749 | - $boardOptions['moderator_groups'] = array(); |
|
788 | + if (empty($boardOptions['moderator_groups'])) { |
|
789 | + $boardOptions['moderator_groups'] = array(); |
|
790 | + } |
|
750 | 791 | if (!empty($moderator_groups)) |
751 | 792 | { |
752 | 793 | $request = $smcFunc['db_query']('', ' |
@@ -777,8 +818,9 @@ discard block |
||
777 | 818 | if (!empty($boardOptions['moderator_groups'])) |
778 | 819 | { |
779 | 820 | $inserts = array(); |
780 | - foreach ($boardOptions['moderator_groups'] as $moderator_group) |
|
781 | - $inserts[] = array($board_id, $moderator_group); |
|
821 | + foreach ($boardOptions['moderator_groups'] as $moderator_group) { |
|
822 | + $inserts[] = array($board_id, $moderator_group); |
|
823 | + } |
|
782 | 824 | |
783 | 825 | $smcFunc['db_insert']('insert', |
784 | 826 | '{db_prefix}moderator_groups', |
@@ -792,14 +834,16 @@ discard block |
||
792 | 834 | updateSettings(array('settings_updated' => time())); |
793 | 835 | } |
794 | 836 | |
795 | - if (isset($boardOptions['move_to'])) |
|
796 | - reorderBoards(); |
|
837 | + if (isset($boardOptions['move_to'])) { |
|
838 | + reorderBoards(); |
|
839 | + } |
|
797 | 840 | |
798 | 841 | clean_cache('data'); |
799 | 842 | |
800 | - if (empty($boardOptions['dont_log'])) |
|
801 | - logAction('edit_board', array('board' => $board_id), 'admin'); |
|
802 | -} |
|
843 | + if (empty($boardOptions['dont_log'])) { |
|
844 | + logAction('edit_board', array('board' => $board_id), 'admin'); |
|
845 | + } |
|
846 | + } |
|
803 | 847 | |
804 | 848 | /** |
805 | 849 | * Create a new board and set its properties and position. |
@@ -815,11 +859,13 @@ discard block |
||
815 | 859 | global $boards, $smcFunc; |
816 | 860 | |
817 | 861 | // Trigger an error if one of the required values is not set. |
818 | - if (!isset($boardOptions['board_name']) || trim($boardOptions['board_name']) == '' || !isset($boardOptions['move_to']) || !isset($boardOptions['target_category'])) |
|
819 | - trigger_error('createBoard(): One or more of the required options is not set', E_USER_ERROR); |
|
862 | + if (!isset($boardOptions['board_name']) || trim($boardOptions['board_name']) == '' || !isset($boardOptions['move_to']) || !isset($boardOptions['target_category'])) { |
|
863 | + trigger_error('createBoard(): One or more of the required options is not set', E_USER_ERROR); |
|
864 | + } |
|
820 | 865 | |
821 | - if (in_array($boardOptions['move_to'], array('child', 'before', 'after')) && !isset($boardOptions['target_board'])) |
|
822 | - trigger_error('createBoard(): Target board is not set', E_USER_ERROR); |
|
866 | + if (in_array($boardOptions['move_to'], array('child', 'before', 'after')) && !isset($boardOptions['target_board'])) { |
|
867 | + trigger_error('createBoard(): Target board is not set', E_USER_ERROR); |
|
868 | + } |
|
823 | 869 | |
824 | 870 | // Set every optional value to its default value. |
825 | 871 | $boardOptions += array( |
@@ -853,8 +899,9 @@ discard block |
||
853 | 899 | ); |
854 | 900 | $board_id = $smcFunc['db_insert_id']('{db_prefix}boards', 'id_board'); |
855 | 901 | |
856 | - if (empty($board_id)) |
|
857 | - return 0; |
|
902 | + if (empty($board_id)) { |
|
903 | + return 0; |
|
904 | + } |
|
858 | 905 | |
859 | 906 | // Change the board according to the given specifications. |
860 | 907 | modifyBoard($board_id, $boardOptions); |
@@ -917,8 +964,9 @@ discard block |
||
917 | 964 | global $sourcedir, $boards, $smcFunc; |
918 | 965 | |
919 | 966 | // No boards to delete? Return! |
920 | - if (empty($boards_to_remove)) |
|
921 | - return; |
|
967 | + if (empty($boards_to_remove)) { |
|
968 | + return; |
|
969 | + } |
|
922 | 970 | |
923 | 971 | getBoardTree(); |
924 | 972 | |
@@ -929,12 +977,14 @@ discard block |
||
929 | 977 | { |
930 | 978 | // Get a list of the child boards that will also be removed. |
931 | 979 | $child_boards_to_remove = array(); |
932 | - foreach ($boards_to_remove as $board_to_remove) |
|
933 | - recursiveBoards($child_boards_to_remove, $boards[$board_to_remove]['tree']); |
|
980 | + foreach ($boards_to_remove as $board_to_remove) { |
|
981 | + recursiveBoards($child_boards_to_remove, $boards[$board_to_remove]['tree']); |
|
982 | + } |
|
934 | 983 | |
935 | 984 | // Merge the children with their parents. |
936 | - if (!empty($child_boards_to_remove)) |
|
937 | - $boards_to_remove = array_unique(array_merge($boards_to_remove, $child_boards_to_remove)); |
|
985 | + if (!empty($child_boards_to_remove)) { |
|
986 | + $boards_to_remove = array_unique(array_merge($boards_to_remove, $child_boards_to_remove)); |
|
987 | + } |
|
938 | 988 | } |
939 | 989 | // Move the children to a safe home. |
940 | 990 | else |
@@ -942,10 +992,11 @@ discard block |
||
942 | 992 | foreach ($boards_to_remove as $id_board) |
943 | 993 | { |
944 | 994 | // @todo Separate category? |
945 | - if ($moveChildrenTo === 0) |
|
946 | - fixChildren($id_board, 0, 0); |
|
947 | - else |
|
948 | - fixChildren($id_board, $boards[$moveChildrenTo]['level'] + 1, $moveChildrenTo); |
|
995 | + if ($moveChildrenTo === 0) { |
|
996 | + fixChildren($id_board, 0, 0); |
|
997 | + } else { |
|
998 | + fixChildren($id_board, $boards[$moveChildrenTo]['level'] + 1, $moveChildrenTo); |
|
999 | + } |
|
949 | 1000 | } |
950 | 1001 | } |
951 | 1002 | |
@@ -959,8 +1010,9 @@ discard block |
||
959 | 1010 | ) |
960 | 1011 | ); |
961 | 1012 | $topics = array(); |
962 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
963 | - $topics[] = $row['id_topic']; |
|
1013 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1014 | + $topics[] = $row['id_topic']; |
|
1015 | + } |
|
964 | 1016 | $smcFunc['db_free_result']($request); |
965 | 1017 | |
966 | 1018 | require_once($sourcedir . '/RemoveTopic.php'); |
@@ -1048,8 +1100,9 @@ discard block |
||
1048 | 1100 | clean_cache('data'); |
1049 | 1101 | |
1050 | 1102 | // Let's do some serious logging. |
1051 | - foreach ($boards_to_remove as $id_board) |
|
1052 | - logAction('delete_board', array('boardname' => $boards[$id_board]['name']), 'admin'); |
|
1103 | + foreach ($boards_to_remove as $id_board) { |
|
1104 | + logAction('delete_board', array('boardname' => $boards[$id_board]['name']), 'admin'); |
|
1105 | + } |
|
1053 | 1106 | |
1054 | 1107 | reorderBoards(); |
1055 | 1108 | } |
@@ -1068,8 +1121,8 @@ discard block |
||
1068 | 1121 | $board_order = 0; |
1069 | 1122 | foreach ($cat_tree as $catID => $dummy) |
1070 | 1123 | { |
1071 | - foreach ($boardList[$catID] as $boardID) |
|
1072 | - if ($boards[$boardID]['order'] != ++$board_order) |
|
1124 | + foreach ($boardList[$catID] as $boardID) { |
|
1125 | + if ($boards[$boardID]['order'] != ++$board_order) |
|
1073 | 1126 | $smcFunc['db_query']('', ' |
1074 | 1127 | UPDATE {db_prefix}boards |
1075 | 1128 | SET board_order = {int:new_order} |
@@ -1079,6 +1132,7 @@ discard block |
||
1079 | 1132 | 'selected_board' => $boardID, |
1080 | 1133 | ) |
1081 | 1134 | ); |
1135 | + } |
|
1082 | 1136 | } |
1083 | 1137 | |
1084 | 1138 | // Empty the board order cache |
@@ -1107,8 +1161,9 @@ discard block |
||
1107 | 1161 | ) |
1108 | 1162 | ); |
1109 | 1163 | $children = array(); |
1110 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
1111 | - $children[] = $row['id_board']; |
|
1164 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
1165 | + $children[] = $row['id_board']; |
|
1166 | + } |
|
1112 | 1167 | $smcFunc['db_free_result']($result); |
1113 | 1168 | |
1114 | 1169 | // ...and set it to a new parent and child_level. |
@@ -1124,9 +1179,10 @@ discard block |
||
1124 | 1179 | ); |
1125 | 1180 | |
1126 | 1181 | // Recursively fix the children of the children. |
1127 | - foreach ($children as $child) |
|
1128 | - fixChildren($child, $newLevel + 1, $child); |
|
1129 | -} |
|
1182 | + foreach ($children as $child) { |
|
1183 | + fixChildren($child, $newLevel + 1, $child); |
|
1184 | + } |
|
1185 | + } |
|
1130 | 1186 | |
1131 | 1187 | /** |
1132 | 1188 | * Tries to load up the entire board order and category very very quickly |
@@ -1143,8 +1199,9 @@ discard block |
||
1143 | 1199 | 'boards' => array(), |
1144 | 1200 | ); |
1145 | 1201 | |
1146 | - if (!empty($tree_order['boards'])) |
|
1147 | - return $tree_order; |
|
1202 | + if (!empty($tree_order['boards'])) { |
|
1203 | + return $tree_order; |
|
1204 | + } |
|
1148 | 1205 | |
1149 | 1206 | if (($cached = cache_get_data('board_order', 86400)) !== null) |
1150 | 1207 | { |
@@ -1160,8 +1217,9 @@ discard block |
||
1160 | 1217 | ); |
1161 | 1218 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1162 | 1219 | { |
1163 | - if (!in_array($row['id_cat'], $tree_order['cats'])) |
|
1164 | - $tree_order['cats'][] = $row['id_cat']; |
|
1220 | + if (!in_array($row['id_cat'], $tree_order['cats'])) { |
|
1221 | + $tree_order['cats'][] = $row['id_cat']; |
|
1222 | + } |
|
1165 | 1223 | $tree_order['boards'][] = $row['id_board']; |
1166 | 1224 | } |
1167 | 1225 | $smcFunc['db_free_result']($request); |
@@ -1181,16 +1239,19 @@ discard block |
||
1181 | 1239 | $tree = getTreeOrder(); |
1182 | 1240 | |
1183 | 1241 | $ordered = array(); |
1184 | - foreach ($tree['boards'] as $board) |
|
1185 | - if (!empty($boards[$board])) |
|
1242 | + foreach ($tree['boards'] as $board) { |
|
1243 | + if (!empty($boards[$board])) |
|
1186 | 1244 | { |
1187 | 1245 | $ordered[$board] = $boards[$board]; |
1246 | + } |
|
1188 | 1247 | |
1189 | - if (is_array($ordered[$board]) && !empty($ordered[$board]['boards'])) |
|
1190 | - sortBoards($ordered[$board]['boards']); |
|
1248 | + if (is_array($ordered[$board]) && !empty($ordered[$board]['boards'])) { |
|
1249 | + sortBoards($ordered[$board]['boards']); |
|
1250 | + } |
|
1191 | 1251 | |
1192 | - if (is_array($ordered[$board]) && !empty($ordered[$board]['children'])) |
|
1193 | - sortBoards($ordered[$board]['children']); |
|
1252 | + if (is_array($ordered[$board]) && !empty($ordered[$board]['children'])) { |
|
1253 | + sortBoards($ordered[$board]['children']); |
|
1254 | + } |
|
1194 | 1255 | } |
1195 | 1256 | |
1196 | 1257 | $boards = $ordered; |
@@ -1206,12 +1267,14 @@ discard block |
||
1206 | 1267 | $tree = getTreeOrder(); |
1207 | 1268 | |
1208 | 1269 | $ordered = array(); |
1209 | - foreach ($tree['cats'] as $cat) |
|
1210 | - if (!empty($categories[$cat])) |
|
1270 | + foreach ($tree['cats'] as $cat) { |
|
1271 | + if (!empty($categories[$cat])) |
|
1211 | 1272 | { |
1212 | 1273 | $ordered[$cat] = $categories[$cat]; |
1213 | - if (!empty($ordered[$cat]['boards'])) |
|
1214 | - sortBoards($ordered[$cat]['boards']); |
|
1274 | + } |
|
1275 | + if (!empty($ordered[$cat]['boards'])) { |
|
1276 | + sortBoards($ordered[$cat]['boards']); |
|
1277 | + } |
|
1215 | 1278 | } |
1216 | 1279 | |
1217 | 1280 | $categories = $ordered; |
@@ -1227,8 +1290,9 @@ discard block |
||
1227 | 1290 | { |
1228 | 1291 | global $smcFunc, $scripturl, $txt; |
1229 | 1292 | |
1230 | - if (empty($boards)) |
|
1231 | - return array(); |
|
1293 | + if (empty($boards)) { |
|
1294 | + return array(); |
|
1295 | + } |
|
1232 | 1296 | |
1233 | 1297 | $request = $smcFunc['db_query']('', ' |
1234 | 1298 | SELECT mem.id_member, mem.real_name, mo.id_board |
@@ -1242,8 +1306,9 @@ discard block |
||
1242 | 1306 | $moderators = array(); |
1243 | 1307 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1244 | 1308 | { |
1245 | - if (empty($moderators[$row['id_board']])) |
|
1246 | - $moderators[$row['id_board']] = array(); |
|
1309 | + if (empty($moderators[$row['id_board']])) { |
|
1310 | + $moderators[$row['id_board']] = array(); |
|
1311 | + } |
|
1247 | 1312 | |
1248 | 1313 | $moderators[$row['id_board']][] = array( |
1249 | 1314 | 'id' => $row['id_member'], |
@@ -1267,8 +1332,9 @@ discard block |
||
1267 | 1332 | { |
1268 | 1333 | global $smcFunc, $scripturl, $txt; |
1269 | 1334 | |
1270 | - if (empty($boards)) |
|
1271 | - return array(); |
|
1335 | + if (empty($boards)) { |
|
1336 | + return array(); |
|
1337 | + } |
|
1272 | 1338 | |
1273 | 1339 | $request = $smcFunc['db_query']('', ' |
1274 | 1340 | SELECT mg.id_group, mg.group_name, bg.id_board |
@@ -1282,8 +1348,9 @@ discard block |
||
1282 | 1348 | $groups = array(); |
1283 | 1349 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1284 | 1350 | { |
1285 | - if (empty($groups[$row['id_board']])) |
|
1286 | - $groups[$row['id_board']] = array(); |
|
1351 | + if (empty($groups[$row['id_board']])) { |
|
1352 | + $groups[$row['id_board']] = array(); |
|
1353 | + } |
|
1287 | 1354 | |
1288 | 1355 | $groups[$row['id_board']][] = array( |
1289 | 1356 | 'id' => $row['id_group'], |
@@ -1345,8 +1412,9 @@ discard block |
||
1345 | 1412 | |
1346 | 1413 | if (!empty($row['id_board'])) |
1347 | 1414 | { |
1348 | - if ($row['child_level'] != $curLevel) |
|
1349 | - $prevBoard = 0; |
|
1415 | + if ($row['child_level'] != $curLevel) { |
|
1416 | + $prevBoard = 0; |
|
1417 | + } |
|
1350 | 1418 | |
1351 | 1419 | $boards[$row['id_board']] = array( |
1352 | 1420 | 'id' => $row['id_board'], |
@@ -1378,16 +1446,16 @@ discard block |
||
1378 | 1446 | 'children' => array() |
1379 | 1447 | ); |
1380 | 1448 | $boards[$row['id_board']]['tree'] = &$cat_tree[$row['id_cat']]['children'][$row['id_board']]; |
1381 | - } |
|
1382 | - else |
|
1449 | + } else |
|
1383 | 1450 | { |
1384 | 1451 | // Parent doesn't exist! |
1385 | - if (!isset($boards[$row['id_parent']]['tree'])) |
|
1386 | - fatal_lang_error('no_valid_parent', false, array($row['board_name'])); |
|
1452 | + if (!isset($boards[$row['id_parent']]['tree'])) { |
|
1453 | + fatal_lang_error('no_valid_parent', false, array($row['board_name'])); |
|
1454 | + } |
|
1387 | 1455 | |
1388 | 1456 | // Wrong childlevel...we can silently fix this... |
1389 | - if ($boards[$row['id_parent']]['tree']['node']['level'] != $row['child_level'] - 1) |
|
1390 | - $smcFunc['db_query']('', ' |
|
1457 | + if ($boards[$row['id_parent']]['tree']['node']['level'] != $row['child_level'] - 1) { |
|
1458 | + $smcFunc['db_query']('', ' |
|
1391 | 1459 | UPDATE {db_prefix}boards |
1392 | 1460 | SET child_level = {int:new_child_level} |
1393 | 1461 | WHERE id_board = {int:selected_board}', |
@@ -1396,6 +1464,7 @@ discard block |
||
1396 | 1464 | 'selected_board' => $row['id_board'], |
1397 | 1465 | ) |
1398 | 1466 | ); |
1467 | + } |
|
1399 | 1468 | |
1400 | 1469 | $boards[$row['id_parent']]['tree']['children'][$row['id_board']] = array( |
1401 | 1470 | 'node' => &$boards[$row['id_board']], |
@@ -1426,8 +1495,9 @@ discard block |
||
1426 | 1495 | */ |
1427 | 1496 | function recursiveBoards(&$_boardList, &$_tree) |
1428 | 1497 | { |
1429 | - if (empty($_tree['children'])) |
|
1430 | - return; |
|
1498 | + if (empty($_tree['children'])) { |
|
1499 | + return; |
|
1500 | + } |
|
1431 | 1501 | |
1432 | 1502 | foreach ($_tree['children'] as $id => $node) |
1433 | 1503 | { |
@@ -1446,11 +1516,13 @@ discard block |
||
1446 | 1516 | { |
1447 | 1517 | global $boards; |
1448 | 1518 | |
1449 | - if (empty($boards[$child]['parent'])) |
|
1450 | - return false; |
|
1519 | + if (empty($boards[$child]['parent'])) { |
|
1520 | + return false; |
|
1521 | + } |
|
1451 | 1522 | |
1452 | - if ($boards[$child]['parent'] == $parent) |
|
1453 | - return true; |
|
1523 | + if ($boards[$child]['parent'] == $parent) { |
|
1524 | + return true; |
|
1525 | + } |
|
1454 | 1526 | |
1455 | 1527 | return isChildOf($boards[$child]['parent'], $parent); |
1456 | 1528 | } |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | return null; |
49 | 49 | } |
50 | 50 | if (PasswordCompat\binary\_strlen($password) > 72) { |
51 | - $password = PasswordCompat\binary\_substr($password, 0,72); |
|
51 | + $password = PasswordCompat\binary\_substr($password, 0, 72); |
|
52 | 52 | } |
53 | 53 | $resultLength = 0; |
54 | 54 | switch ($algo) { |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | return false; |
237 | 237 | } |
238 | 238 | if (PasswordCompat\binary\_strlen($password) > 72) { |
239 | - $password = PasswordCompat\binary\_substr($password, 0,72); |
|
239 | + $password = PasswordCompat\binary\_substr($password, 0, 72); |
|
240 | 240 | } |
241 | 241 | $ret = crypt($password, $hash); |
242 | 242 | if (!is_string($ret) || PasswordCompat\binary\_strlen($ret) != PasswordCompat\binary\_strlen($hash) || PasswordCompat\binary\_strlen($ret) <= 13) { |
@@ -11,8 +11,9 @@ |
||
11 | 11 | * @version 2.1 Beta 3 |
12 | 12 | */ |
13 | 13 | |
14 | -if (!defined('SMF')) |
|
14 | +if (!defined('SMF')) { |
|
15 | 15 | die('No direct access...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * Standard non full index, non custom index search |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | 'value' => $txt['membergroups_name'], |
102 | 102 | ), |
103 | 103 | 'data' => array( |
104 | - 'function' => function ($rowData) use ($scripturl) |
|
104 | + 'function' => function($rowData) use ($scripturl) |
|
105 | 105 | { |
106 | 106 | // Since the moderator group has no explicit members, no link is needed. |
107 | 107 | if ($rowData['id_group'] == 3) |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | 'class' => 'centercol', |
145 | 145 | ), |
146 | 146 | 'data' => array( |
147 | - 'function' => function ($rowData) use ($txt) |
|
147 | + 'function' => function($rowData) use ($txt) |
|
148 | 148 | { |
149 | 149 | // No explicit members for the moderator group. |
150 | 150 | return $rowData['id_group'] == 3 ? $txt['membergroups_guests_na'] : comma_format($rowData['num_members']); |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | 'value' => $txt['membergroups_name'], |
211 | 211 | ), |
212 | 212 | 'data' => array( |
213 | - 'function' => function ($rowData) use ($scripturl) |
|
213 | + 'function' => function($rowData) use ($scripturl) |
|
214 | 214 | { |
215 | 215 | $colorStyle = empty($rowData['online_color']) ? '' : sprintf(' style="color: %1$s;"', $rowData['online_color']); |
216 | 216 | return sprintf('<a href="%1$s?action=moderate;area=viewgroups;sa=members;group=%2$d"%3$s>%4$s</a>', $scripturl, $rowData['id_group'], $colorStyle, $rowData['group_name']); |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | |
20 | 21 | /** |
@@ -44,8 +45,9 @@ discard block |
||
44 | 45 | $_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : (allowedTo('manage_membergroups') ? 'index' : 'settings'); |
45 | 46 | |
46 | 47 | // Is it elsewhere? |
47 | - if (isset($subActions[$_REQUEST['sa']][2])) |
|
48 | - require_once($sourcedir . '/' . $subActions[$_REQUEST['sa']][2]); |
|
48 | + if (isset($subActions[$_REQUEST['sa']][2])) { |
|
49 | + require_once($sourcedir . '/' . $subActions[$_REQUEST['sa']][2]); |
|
50 | + } |
|
49 | 51 | |
50 | 52 | // Do the permission check, you might not be allowed her. |
51 | 53 | isAllowedTo($subActions[$_REQUEST['sa']][1]); |
@@ -104,19 +106,20 @@ discard block |
||
104 | 106 | 'function' => function ($rowData) use ($scripturl) |
105 | 107 | { |
106 | 108 | // Since the moderator group has no explicit members, no link is needed. |
107 | - if ($rowData['id_group'] == 3) |
|
108 | - $group_name = $rowData['group_name']; |
|
109 | - else |
|
109 | + if ($rowData['id_group'] == 3) { |
|
110 | + $group_name = $rowData['group_name']; |
|
111 | + } else |
|
110 | 112 | { |
111 | 113 | $color_style = empty($rowData['online_color']) ? '' : sprintf(' style="color: %1$s;"', $rowData['online_color']); |
112 | 114 | $group_name = sprintf('<a href="%1$s?action=admin;area=membergroups;sa=members;group=%2$d"%3$s>%4$s</a>', $scripturl, $rowData['id_group'], $color_style, $rowData['group_name']); |
113 | 115 | } |
114 | 116 | |
115 | 117 | // Add a help option for moderator and administrator. |
116 | - if ($rowData['id_group'] == 1) |
|
117 | - $group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_administrator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl); |
|
118 | - elseif ($rowData['id_group'] == 3) |
|
119 | - $group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_moderator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl); |
|
118 | + if ($rowData['id_group'] == 1) { |
|
119 | + $group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_administrator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl); |
|
120 | + } elseif ($rowData['id_group'] == 3) { |
|
121 | + $group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_moderator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl); |
|
122 | + } |
|
120 | 123 | |
121 | 124 | return $group_name; |
122 | 125 | }, |
@@ -330,12 +333,14 @@ discard block |
||
330 | 333 | call_integration_hook('integrate_add_membergroup', array($id_group, $postCountBasedGroup)); |
331 | 334 | |
332 | 335 | // Update the post groups now, if this is a post group! |
333 | - if (isset($_POST['min_posts'])) |
|
334 | - updateStats('postgroups'); |
|
336 | + if (isset($_POST['min_posts'])) { |
|
337 | + updateStats('postgroups'); |
|
338 | + } |
|
335 | 339 | |
336 | 340 | // You cannot set permissions for post groups if they are disabled. |
337 | - if ($postCountBasedGroup && empty($modSettings['permission_enable_postgroups'])) |
|
338 | - $_POST['perm_type'] = ''; |
|
341 | + if ($postCountBasedGroup && empty($modSettings['permission_enable_postgroups'])) { |
|
342 | + $_POST['perm_type'] = ''; |
|
343 | + } |
|
339 | 344 | |
340 | 345 | if ($_POST['perm_type'] == 'predefined') |
341 | 346 | { |
@@ -365,8 +370,9 @@ discard block |
||
365 | 370 | $smcFunc['db_free_result']($request); |
366 | 371 | |
367 | 372 | // Protected groups are... well, protected! |
368 | - if ($copy_type == 1) |
|
369 | - fatal_lang_error('membergroup_does_not_exist'); |
|
373 | + if ($copy_type == 1) { |
|
374 | + fatal_lang_error('membergroup_does_not_exist'); |
|
375 | + } |
|
370 | 376 | } |
371 | 377 | |
372 | 378 | // Don't allow copying of a real priviledged person! |
@@ -384,18 +390,20 @@ discard block |
||
384 | 390 | $inserts = array(); |
385 | 391 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
386 | 392 | { |
387 | - if (empty($context['illegal_permissions']) || !in_array($row['permission'], $context['illegal_permissions'])) |
|
388 | - $inserts[] = array($id_group, $row['permission'], $row['add_deny']); |
|
393 | + if (empty($context['illegal_permissions']) || !in_array($row['permission'], $context['illegal_permissions'])) { |
|
394 | + $inserts[] = array($id_group, $row['permission'], $row['add_deny']); |
|
395 | + } |
|
389 | 396 | } |
390 | 397 | $smcFunc['db_free_result']($request); |
391 | 398 | |
392 | - if (!empty($inserts)) |
|
393 | - $smcFunc['db_insert']('insert', |
|
399 | + if (!empty($inserts)) { |
|
400 | + $smcFunc['db_insert']('insert', |
|
394 | 401 | '{db_prefix}permissions', |
395 | 402 | array('id_group' => 'int', 'permission' => 'string', 'add_deny' => 'int'), |
396 | 403 | $inserts, |
397 | 404 | array('id_group', 'permission') |
398 | 405 | ); |
406 | + } |
|
399 | 407 | |
400 | 408 | $request = $smcFunc['db_query']('', ' |
401 | 409 | SELECT id_profile, permission, add_deny |
@@ -406,17 +414,19 @@ discard block |
||
406 | 414 | ) |
407 | 415 | ); |
408 | 416 | $inserts = array(); |
409 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
410 | - $inserts[] = array($id_group, $row['id_profile'], $row['permission'], $row['add_deny']); |
|
417 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
418 | + $inserts[] = array($id_group, $row['id_profile'], $row['permission'], $row['add_deny']); |
|
419 | + } |
|
411 | 420 | $smcFunc['db_free_result']($request); |
412 | 421 | |
413 | - if (!empty($inserts)) |
|
414 | - $smcFunc['db_insert']('insert', |
|
422 | + if (!empty($inserts)) { |
|
423 | + $smcFunc['db_insert']('insert', |
|
415 | 424 | '{db_prefix}board_permissions', |
416 | 425 | array('id_group' => 'int', 'id_profile' => 'int', 'permission' => 'string', 'add_deny' => 'int'), |
417 | 426 | $inserts, |
418 | 427 | array('id_group', 'id_profile', 'permission') |
419 | 428 | ); |
429 | + } |
|
420 | 430 | |
421 | 431 | // Also get some membergroup information if we're copying and not copying from guests... |
422 | 432 | if ($copy_id > 0 && $_POST['perm_type'] == 'copy') |
@@ -469,14 +479,15 @@ discard block |
||
469 | 479 | $changed_boards['allow'] = array(); |
470 | 480 | $changed_boards['deny'] = array(); |
471 | 481 | $changed_boards['ignore'] = array(); |
472 | - foreach ($accesses as $group_id => $action) |
|
473 | - $changed_boards[$action][] = (int) $group_id; |
|
482 | + foreach ($accesses as $group_id => $action) { |
|
483 | + $changed_boards[$action][] = (int) $group_id; |
|
484 | + } |
|
474 | 485 | |
475 | 486 | foreach (array('allow', 'deny') as $board_action) |
476 | 487 | { |
477 | 488 | // Only do this if they have special access requirements. |
478 | - if (!empty($changed_boards[$board_action])) |
|
479 | - $smcFunc['db_query']('', ' |
|
489 | + if (!empty($changed_boards[$board_action])) { |
|
490 | + $smcFunc['db_query']('', ' |
|
480 | 491 | UPDATE {db_prefix}boards |
481 | 492 | SET {raw:column} = CASE WHEN {raw:column} = {string:blank_string} THEN {string:group_id_string} ELSE CONCAT({raw:column}, {string:comma_group}) END |
482 | 493 | WHERE id_board IN ({array_int:board_list})', |
@@ -488,11 +499,13 @@ discard block |
||
488 | 499 | 'column' => $board_action == 'allow' ? 'member_groups' : 'deny_member_groups', |
489 | 500 | ) |
490 | 501 | ); |
502 | + } |
|
491 | 503 | } |
492 | 504 | |
493 | 505 | // If this is joinable then set it to show group membership in people's profiles. |
494 | - if (empty($modSettings['show_group_membership']) && $_POST['group_type'] > 1) |
|
495 | - updateSettings(array('show_group_membership' => 1)); |
|
506 | + if (empty($modSettings['show_group_membership']) && $_POST['group_type'] > 1) { |
|
507 | + updateSettings(array('show_group_membership' => 1)); |
|
508 | + } |
|
496 | 509 | |
497 | 510 | // Rebuild the group cache. |
498 | 511 | updateSettings(array( |
@@ -513,8 +526,9 @@ discard block |
||
513 | 526 | $context['undefined_group'] = !isset($_REQUEST['postgroup']) && !isset($_REQUEST['generalgroup']); |
514 | 527 | $context['allow_protected'] = allowedTo('admin_forum'); |
515 | 528 | |
516 | - if (!empty($modSettings['deny_boards_access'])) |
|
517 | - loadLanguage('ManagePermissions'); |
|
529 | + if (!empty($modSettings['deny_boards_access'])) { |
|
530 | + loadLanguage('ManagePermissions'); |
|
531 | + } |
|
518 | 532 | |
519 | 533 | $result = $smcFunc['db_query']('', ' |
520 | 534 | SELECT id_group, group_name |
@@ -531,11 +545,12 @@ discard block |
||
531 | 545 | ) |
532 | 546 | ); |
533 | 547 | $context['groups'] = array(); |
534 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
535 | - $context['groups'][] = array( |
|
548 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
549 | + $context['groups'][] = array( |
|
536 | 550 | 'id' => $row['id_group'], |
537 | 551 | 'name' => $row['group_name'] |
538 | 552 | ); |
553 | + } |
|
539 | 554 | $smcFunc['db_free_result']($result); |
540 | 555 | |
541 | 556 | $request = $smcFunc['db_query']('', ' |
@@ -552,12 +567,13 @@ discard block |
||
552 | 567 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
553 | 568 | { |
554 | 569 | // This category hasn't been set up yet.. |
555 | - if (!isset($context['categories'][$row['id_cat']])) |
|
556 | - $context['categories'][$row['id_cat']] = array( |
|
570 | + if (!isset($context['categories'][$row['id_cat']])) { |
|
571 | + $context['categories'][$row['id_cat']] = array( |
|
557 | 572 | 'id' => $row['id_cat'], |
558 | 573 | 'name' => $row['cat_name'], |
559 | 574 | 'boards' => array() |
560 | 575 | ); |
576 | + } |
|
561 | 577 | |
562 | 578 | // Set this board up, and let the template know when it's a child. (indent them..) |
563 | 579 | $context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array( |
@@ -605,8 +621,9 @@ discard block |
||
605 | 621 | require_once($sourcedir . '/Subs-Membergroups.php'); |
606 | 622 | $result = deleteMembergroups((int) $_REQUEST['group']); |
607 | 623 | // Need to throw a warning if it went wrong, but this is the only one we have a message for... |
608 | - if ($result === 'group_cannot_delete_sub') |
|
609 | - fatal_lang_error('membergroups_cannot_delete_paid', false); |
|
624 | + if ($result === 'group_cannot_delete_sub') { |
|
625 | + fatal_lang_error('membergroups_cannot_delete_paid', false); |
|
626 | + } |
|
610 | 627 | |
611 | 628 | // Go back to the membergroup index. |
612 | 629 | redirectexit('action=admin;area=membergroups;'); |
@@ -628,8 +645,9 @@ discard block |
||
628 | 645 | |
629 | 646 | $_REQUEST['group'] = isset($_REQUEST['group']) && $_REQUEST['group'] > 0 ? (int) $_REQUEST['group'] : 0; |
630 | 647 | |
631 | - if (!empty($modSettings['deny_boards_access'])) |
|
632 | - loadLanguage('ManagePermissions'); |
|
648 | + if (!empty($modSettings['deny_boards_access'])) { |
|
649 | + loadLanguage('ManagePermissions'); |
|
650 | + } |
|
633 | 651 | |
634 | 652 | // Make sure this group is editable. |
635 | 653 | if (!empty($_REQUEST['group'])) |
@@ -651,8 +669,9 @@ discard block |
||
651 | 669 | } |
652 | 670 | |
653 | 671 | // Now, do we have a valid id? |
654 | - if (empty($_REQUEST['group'])) |
|
655 | - fatal_lang_error('membergroup_does_not_exist', false); |
|
672 | + if (empty($_REQUEST['group'])) { |
|
673 | + fatal_lang_error('membergroup_does_not_exist', false); |
|
674 | + } |
|
656 | 675 | |
657 | 676 | // People who can manage boards are a bit special. |
658 | 677 | require_once($sourcedir . '/Subs-Members.php'); |
@@ -683,8 +702,9 @@ discard block |
||
683 | 702 | require_once($sourcedir . '/Subs-Membergroups.php'); |
684 | 703 | $result = deleteMembergroups($_REQUEST['group']); |
685 | 704 | // Need to throw a warning if it went wrong, but this is the only one we have a message for... |
686 | - if ($result === 'group_cannot_delete_sub') |
|
687 | - fatal_lang_error('membergroups_cannot_delete_paid', false); |
|
705 | + if ($result === 'group_cannot_delete_sub') { |
|
706 | + fatal_lang_error('membergroups_cannot_delete_paid', false); |
|
707 | + } |
|
688 | 708 | |
689 | 709 | redirectexit('action=admin;area=membergroups;'); |
690 | 710 | } |
@@ -761,16 +781,18 @@ discard block |
||
761 | 781 | $request = $smcFunc['db_query']('', ' |
762 | 782 | SELECT id_board |
763 | 783 | FROM {db_prefix}boards'); |
764 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
765 | - $accesses[(int) $row['id_board']] = 'allow'; |
|
784 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
785 | + $accesses[(int) $row['id_board']] = 'allow'; |
|
786 | + } |
|
766 | 787 | $smcFunc['db_free_result']($request); |
767 | 788 | } |
768 | 789 | |
769 | 790 | $changed_boards['allow'] = array(); |
770 | 791 | $changed_boards['deny'] = array(); |
771 | 792 | $changed_boards['ignore'] = array(); |
772 | - foreach ($accesses as $group_id => $action) |
|
773 | - $changed_boards[$action][] = (int) $group_id; |
|
793 | + foreach ($accesses as $group_id => $action) { |
|
794 | + $changed_boards[$action][] = (int) $group_id; |
|
795 | + } |
|
774 | 796 | |
775 | 797 | foreach (array('allow', 'deny') as $board_action) |
776 | 798 | { |
@@ -786,8 +808,8 @@ discard block |
||
786 | 808 | 'column' => $board_action == 'allow' ? 'member_groups' : 'deny_member_groups', |
787 | 809 | ) |
788 | 810 | ); |
789 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
790 | - $smcFunc['db_query']('', ' |
|
811 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
812 | + $smcFunc['db_query']('', ' |
|
791 | 813 | UPDATE {db_prefix}boards |
792 | 814 | SET {raw:column} = {string:member_group_access} |
793 | 815 | WHERE id_board = {int:current_board}', |
@@ -797,11 +819,12 @@ discard block |
||
797 | 819 | 'column' => $board_action == 'allow' ? 'member_groups' : 'deny_member_groups', |
798 | 820 | ) |
799 | 821 | ); |
822 | + } |
|
800 | 823 | $smcFunc['db_free_result']($request); |
801 | 824 | |
802 | 825 | // Add the membergroup to all boards that hadn't been set yet. |
803 | - if (!empty($changed_boards[$board_action])) |
|
804 | - $smcFunc['db_query']('', ' |
|
826 | + if (!empty($changed_boards[$board_action])) { |
|
827 | + $smcFunc['db_query']('', ' |
|
805 | 828 | UPDATE {db_prefix}boards |
806 | 829 | SET {raw:column} = CASE WHEN {raw:column} = {string:blank_string} THEN {string:group_id_string} ELSE CONCAT({raw:column}, {string:comma_group}) END |
807 | 830 | WHERE id_board IN ({array_int:board_list}) |
@@ -815,6 +838,7 @@ discard block |
||
815 | 838 | 'column' => $board_action == 'allow' ? 'member_groups' : 'deny_member_groups', |
816 | 839 | ) |
817 | 840 | ); |
841 | + } |
|
818 | 842 | } |
819 | 843 | } |
820 | 844 | |
@@ -840,12 +864,14 @@ discard block |
||
840 | 864 | ) |
841 | 865 | ); |
842 | 866 | $updates = array(); |
843 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
844 | - $updates[$row['additional_groups']][] = $row['id_member']; |
|
867 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
868 | + $updates[$row['additional_groups']][] = $row['id_member']; |
|
869 | + } |
|
845 | 870 | $smcFunc['db_free_result']($request); |
846 | 871 | |
847 | - foreach ($updates as $additional_groups => $memberArray) |
|
848 | - updateMemberData($memberArray, array('additional_groups' => implode(',', array_diff(explode(',', $additional_groups), array((int) $_REQUEST['group']))))); |
|
872 | + foreach ($updates as $additional_groups => $memberArray) { |
|
873 | + updateMemberData($memberArray, array('additional_groups' => implode(',', array_diff(explode(',', $additional_groups), array((int) $_REQUEST['group']))))); |
|
874 | + } |
|
849 | 875 | |
850 | 876 | // Sorry, but post groups can't moderate boards |
851 | 877 | $request = $smcFunc['db_query']('', ' |
@@ -855,8 +881,7 @@ discard block |
||
855 | 881 | 'current_group' => (int) $_REQUEST['group'], |
856 | 882 | ) |
857 | 883 | ); |
858 | - } |
|
859 | - elseif ($_REQUEST['group'] != 3) |
|
884 | + } elseif ($_REQUEST['group'] != 3) |
|
860 | 885 | { |
861 | 886 | // Making it a hidden group? If so remove everyone with it as primary group (Actually, just make them additional). |
862 | 887 | if ($_POST['group_hidden'] == 2) |
@@ -871,8 +896,9 @@ discard block |
||
871 | 896 | ) |
872 | 897 | ); |
873 | 898 | $updates = array(); |
874 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
875 | - $updates[$row['additional_groups']][] = $row['id_member']; |
|
899 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
900 | + $updates[$row['additional_groups']][] = $row['id_member']; |
|
901 | + } |
|
876 | 902 | $smcFunc['db_free_result']($request); |
877 | 903 | |
878 | 904 | foreach ($updates as $additional_groups => $memberArray) |
@@ -914,8 +940,9 @@ discard block |
||
914 | 940 | $smcFunc['db_free_result']($request); |
915 | 941 | |
916 | 942 | // Do we need to update the setting? |
917 | - if ((empty($modSettings['show_group_membership']) && $have_joinable) || (!empty($modSettings['show_group_membership']) && !$have_joinable)) |
|
918 | - updateSettings(array('show_group_membership' => $have_joinable ? 1 : 0)); |
|
943 | + if ((empty($modSettings['show_group_membership']) && $have_joinable) || (!empty($modSettings['show_group_membership']) && !$have_joinable)) { |
|
944 | + updateSettings(array('show_group_membership' => $have_joinable ? 1 : 0)); |
|
945 | + } |
|
919 | 946 | } |
920 | 947 | |
921 | 948 | // Do we need to set inherited permissions? |
@@ -948,8 +975,9 @@ discard block |
||
948 | 975 | { |
949 | 976 | $moderators[$k] = trim($moderators[$k]); |
950 | 977 | |
951 | - if (strlen($moderators[$k]) == 0) |
|
952 | - unset($moderators[$k]); |
|
978 | + if (strlen($moderators[$k]) == 0) { |
|
979 | + unset($moderators[$k]); |
|
980 | + } |
|
953 | 981 | } |
954 | 982 | |
955 | 983 | // Find all the id_member's for the member_name's in the list. |
@@ -965,8 +993,9 @@ discard block |
||
965 | 993 | 'count' => count($moderators), |
966 | 994 | ) |
967 | 995 | ); |
968 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
969 | - $group_moderators[] = $row['id_member']; |
|
996 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
997 | + $group_moderators[] = $row['id_member']; |
|
998 | + } |
|
970 | 999 | $smcFunc['db_free_result']($request); |
971 | 1000 | } |
972 | 1001 | } |
@@ -974,8 +1003,9 @@ discard block |
||
974 | 1003 | if (!empty($_POST['moderator_list'])) |
975 | 1004 | { |
976 | 1005 | $moderators = array(); |
977 | - foreach ($_POST['moderator_list'] as $moderator) |
|
978 | - $moderators[] = (int) $moderator; |
|
1006 | + foreach ($_POST['moderator_list'] as $moderator) { |
|
1007 | + $moderators[] = (int) $moderator; |
|
1008 | + } |
|
979 | 1009 | |
980 | 1010 | if (!empty($moderators)) |
981 | 1011 | { |
@@ -989,8 +1019,9 @@ discard block |
||
989 | 1019 | 'num_moderators' => count($moderators), |
990 | 1020 | ) |
991 | 1021 | ); |
992 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
993 | - $group_moderators[] = $row['id_member']; |
|
1022 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1023 | + $group_moderators[] = $row['id_member']; |
|
1024 | + } |
|
994 | 1025 | $smcFunc['db_free_result']($request); |
995 | 1026 | } |
996 | 1027 | } |
@@ -1002,8 +1033,9 @@ discard block |
||
1002 | 1033 | if (!empty($group_moderators)) |
1003 | 1034 | { |
1004 | 1035 | $mod_insert = array(); |
1005 | - foreach ($group_moderators as $moderator) |
|
1006 | - $mod_insert[] = array($_REQUEST['group'], $moderator); |
|
1036 | + foreach ($group_moderators as $moderator) { |
|
1037 | + $mod_insert[] = array($_REQUEST['group'], $moderator); |
|
1038 | + } |
|
1007 | 1039 | |
1008 | 1040 | $smcFunc['db_insert']('insert', |
1009 | 1041 | '{db_prefix}group_moderators', |
@@ -1037,8 +1069,9 @@ discard block |
||
1037 | 1069 | 'current_group' => (int) $_REQUEST['group'], |
1038 | 1070 | ) |
1039 | 1071 | ); |
1040 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1041 | - fatal_lang_error('membergroup_does_not_exist', false); |
|
1072 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1073 | + fatal_lang_error('membergroup_does_not_exist', false); |
|
1074 | + } |
|
1042 | 1075 | $row = $smcFunc['db_fetch_assoc']($request); |
1043 | 1076 | $smcFunc['db_free_result']($request); |
1044 | 1077 | |
@@ -1075,14 +1108,16 @@ discard block |
||
1075 | 1108 | ) |
1076 | 1109 | ); |
1077 | 1110 | $context['group']['moderators'] = array(); |
1078 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1079 | - $context['group']['moderators'][$row['id_member']] = $row['real_name']; |
|
1111 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1112 | + $context['group']['moderators'][$row['id_member']] = $row['real_name']; |
|
1113 | + } |
|
1080 | 1114 | $smcFunc['db_free_result']($request); |
1081 | 1115 | |
1082 | 1116 | $context['group']['moderator_list'] = empty($context['group']['moderators']) ? '' : '"' . implode('", "', $context['group']['moderators']) . '"'; |
1083 | 1117 | |
1084 | - if (!empty($context['group']['moderators'])) |
|
1085 | - list ($context['group']['last_moderator_id']) = array_slice(array_keys($context['group']['moderators']), -1); |
|
1118 | + if (!empty($context['group']['moderators'])) { |
|
1119 | + list ($context['group']['last_moderator_id']) = array_slice(array_keys($context['group']['moderators']), -1); |
|
1120 | + } |
|
1086 | 1121 | |
1087 | 1122 | // Get a list of boards this membergroup is allowed to see. |
1088 | 1123 | $context['boards'] = array(); |
@@ -1102,12 +1137,13 @@ discard block |
||
1102 | 1137 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1103 | 1138 | { |
1104 | 1139 | // This category hasn't been set up yet.. |
1105 | - if (!isset($context['categories'][$row['id_cat']])) |
|
1106 | - $context['categories'][$row['id_cat']] = array( |
|
1140 | + if (!isset($context['categories'][$row['id_cat']])) { |
|
1141 | + $context['categories'][$row['id_cat']] = array( |
|
1107 | 1142 | 'id' => $row['id_cat'], |
1108 | 1143 | 'name' => $row['cat_name'], |
1109 | 1144 | 'boards' => array() |
1110 | 1145 | ); |
1146 | + } |
|
1111 | 1147 | |
1112 | 1148 | // Set this board up, and let the template know when it's a child. (indent them..) |
1113 | 1149 | $context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array( |
@@ -1135,8 +1171,9 @@ discard block |
||
1135 | 1171 | } |
1136 | 1172 | |
1137 | 1173 | $max_boards = ceil(count($temp_boards) / 2); |
1138 | - if ($max_boards == 1) |
|
1139 | - $max_boards = 2; |
|
1174 | + if ($max_boards == 1) { |
|
1175 | + $max_boards = 2; |
|
1176 | + } |
|
1140 | 1177 | } |
1141 | 1178 | |
1142 | 1179 | // Get a list of all the image formats we can select. |
@@ -1159,19 +1196,22 @@ discard block |
||
1159 | 1196 | $image_info = getimagesize($settings['default_theme_dir'] . '/images/membericons/' . $value); |
1160 | 1197 | |
1161 | 1198 | // If this is bigger than 128 in width or 32 in height, skip this one. |
1162 | - if ($image_info == false || $image_info[0] > 128 || $image_info[1] > 32) |
|
1163 | - continue; |
|
1199 | + if ($image_info == false || $image_info[0] > 128 || $image_info[1] > 32) { |
|
1200 | + continue; |
|
1201 | + } |
|
1164 | 1202 | |
1165 | 1203 | // Else it's valid. Add it in. |
1166 | - else |
|
1167 | - $context['possible_icons'][] = $value; |
|
1204 | + else { |
|
1205 | + $context['possible_icons'][] = $value; |
|
1206 | + } |
|
1168 | 1207 | } |
1169 | 1208 | } |
1170 | 1209 | } |
1171 | 1210 | |
1172 | 1211 | // Insert our JS, if we have possible icons. |
1173 | - if (!empty($context['possible_icons'])) |
|
1174 | - loadJavaScriptFile('icondropdown.js', array('validate' => true), 'smf_icondropdown'); |
|
1212 | + if (!empty($context['possible_icons'])) { |
|
1213 | + loadJavaScriptFile('icondropdown.js', array('validate' => true), 'smf_icondropdown'); |
|
1214 | + } |
|
1175 | 1215 | |
1176 | 1216 | loadJavaScriptFile('suggest.js', array('defer' => false), 'smf_suggest'); |
1177 | 1217 | |
@@ -1193,8 +1233,9 @@ discard block |
||
1193 | 1233 | ) |
1194 | 1234 | ); |
1195 | 1235 | $context['inheritable_groups'] = array(); |
1196 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1197 | - $context['inheritable_groups'][$row['id_group']] = $row['group_name']; |
|
1236 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1237 | + $context['inheritable_groups'][$row['id_group']] = $row['group_name']; |
|
1238 | + } |
|
1198 | 1239 | $smcFunc['db_free_result']($request); |
1199 | 1240 | |
1200 | 1241 | call_integration_hook('integrate_view_membergroup'); |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | 'style' => 'width: 20%;', |
303 | 303 | ), |
304 | 304 | 'data' => array( |
305 | - 'function' => function ($warning) |
|
305 | + 'function' => function($warning) |
|
306 | 306 | { |
307 | 307 | return $warning['issuer']['link']; |
308 | 308 | }, |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | 'value' => $txt['profile_warning_previous_reason'], |
331 | 331 | ), |
332 | 332 | 'data' => array( |
333 | - 'function' => function ($warning) use ($scripturl, $txt) |
|
333 | + 'function' => function($warning) use ($scripturl, $txt) |
|
334 | 334 | { |
335 | 335 | $ret = ' |
336 | 336 | <div class="floatleft"> |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Activate an account. |
@@ -48,8 +49,9 @@ discard block |
||
48 | 49 | logAction('approve_member', array('member' => $memID), 'admin'); |
49 | 50 | |
50 | 51 | // If we are doing approval, update the stats for the member just in case. |
51 | - if (in_array($user_profile[$memID]['is_activated'], array(3, 4, 5, 13, 14, 15))) |
|
52 | - updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > 1 ? $modSettings['unapprovedMembers'] - 1 : 0))); |
|
52 | + if (in_array($user_profile[$memID]['is_activated'], array(3, 4, 5, 13, 14, 15))) { |
|
53 | + updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > 1 ? $modSettings['unapprovedMembers'] - 1 : 0))); |
|
54 | + } |
|
53 | 55 | |
54 | 56 | // Make sure we update the stats too. |
55 | 57 | updateStats('member', false); |
@@ -76,8 +78,9 @@ discard block |
||
76 | 78 | $issueErrors = array(); |
77 | 79 | |
78 | 80 | // Doesn't hurt to be overly cautious. |
79 | - if (empty($modSettings['warning_enable']) || ($context['user']['is_owner'] && !$cur_profile['warning']) || !allowedTo('issue_warning')) |
|
80 | - fatal_lang_error('no_access', false); |
|
81 | + if (empty($modSettings['warning_enable']) || ($context['user']['is_owner'] && !$cur_profile['warning']) || !allowedTo('issue_warning')) { |
|
82 | + fatal_lang_error('no_access', false); |
|
83 | + } |
|
81 | 84 | |
82 | 85 | // Get the base (errors related) stuff done. |
83 | 86 | loadLanguage('Errors'); |
@@ -135,16 +138,18 @@ discard block |
||
135 | 138 | |
136 | 139 | // This cannot be empty! |
137 | 140 | $_POST['warn_reason'] = isset($_POST['warn_reason']) ? trim($_POST['warn_reason']) : ''; |
138 | - if ($_POST['warn_reason'] == '' && !$context['user']['is_owner']) |
|
139 | - $issueErrors[] = 'warning_no_reason'; |
|
141 | + if ($_POST['warn_reason'] == '' && !$context['user']['is_owner']) { |
|
142 | + $issueErrors[] = 'warning_no_reason'; |
|
143 | + } |
|
140 | 144 | $_POST['warn_reason'] = $smcFunc['htmlspecialchars']($_POST['warn_reason']); |
141 | 145 | |
142 | 146 | $_POST['warning_level'] = (int) $_POST['warning_level']; |
143 | 147 | $_POST['warning_level'] = max(0, min(100, $_POST['warning_level'])); |
144 | - if ($_POST['warning_level'] < $context['min_allowed']) |
|
145 | - $_POST['warning_level'] = $context['min_allowed']; |
|
146 | - elseif ($_POST['warning_level'] > $context['max_allowed']) |
|
147 | - $_POST['warning_level'] = $context['max_allowed']; |
|
148 | + if ($_POST['warning_level'] < $context['min_allowed']) { |
|
149 | + $_POST['warning_level'] = $context['min_allowed']; |
|
150 | + } elseif ($_POST['warning_level'] > $context['max_allowed']) { |
|
151 | + $_POST['warning_level'] = $context['max_allowed']; |
|
152 | + } |
|
148 | 153 | |
149 | 154 | // Do we actually have to issue them with a PM? |
150 | 155 | $id_notice = 0; |
@@ -152,8 +157,9 @@ discard block |
||
152 | 157 | { |
153 | 158 | $_POST['warn_sub'] = trim($_POST['warn_sub']); |
154 | 159 | $_POST['warn_body'] = trim($_POST['warn_body']); |
155 | - if (empty($_POST['warn_sub']) || empty($_POST['warn_body'])) |
|
156 | - $issueErrors[] = 'warning_notify_blank'; |
|
160 | + if (empty($_POST['warn_sub']) || empty($_POST['warn_body'])) { |
|
161 | + $issueErrors[] = 'warning_notify_blank'; |
|
162 | + } |
|
157 | 163 | // Send the PM? |
158 | 164 | else |
159 | 165 | { |
@@ -190,8 +196,8 @@ discard block |
||
190 | 196 | if (empty($issueErrors)) |
191 | 197 | { |
192 | 198 | // Log what we've done! |
193 | - if (!$context['user']['is_owner']) |
|
194 | - $smcFunc['db_insert']('', |
|
199 | + if (!$context['user']['is_owner']) { |
|
200 | + $smcFunc['db_insert']('', |
|
195 | 201 | '{db_prefix}log_comments', |
196 | 202 | array( |
197 | 203 | 'id_member' => 'int', 'member_name' => 'string', 'comment_type' => 'string', 'id_recipient' => 'int', 'recipient_name' => 'string-255', |
@@ -203,14 +209,14 @@ discard block |
||
203 | 209 | ), |
204 | 210 | array('id_comment') |
205 | 211 | ); |
212 | + } |
|
206 | 213 | |
207 | 214 | // Make the change. |
208 | 215 | updateMemberData($memID, array('warning' => $_POST['warning_level'])); |
209 | 216 | |
210 | 217 | // Leave a lovely message. |
211 | 218 | $context['profile_updated'] = $context['user']['is_owner'] ? $txt['profile_updated_own'] : $txt['profile_warning_success']; |
212 | - } |
|
213 | - else |
|
219 | + } else |
|
214 | 220 | { |
215 | 221 | // Try to remember some bits. |
216 | 222 | $context['warning_data'] = array( |
@@ -229,8 +235,9 @@ discard block |
||
229 | 235 | { |
230 | 236 | $warning_body = !empty($_POST['warn_body']) ? trim(censorText($_POST['warn_body'])) : ''; |
231 | 237 | $context['preview_subject'] = !empty($_POST['warn_sub']) ? trim($smcFunc['htmlspecialchars']($_POST['warn_sub'])) : ''; |
232 | - if (empty($_POST['warn_sub']) || empty($_POST['warn_body'])) |
|
233 | - $issueErrors[] = 'warning_notify_blank'; |
|
238 | + if (empty($_POST['warn_sub']) || empty($_POST['warn_body'])) { |
|
239 | + $issueErrors[] = 'warning_notify_blank'; |
|
240 | + } |
|
234 | 241 | |
235 | 242 | if (!empty($_POST['warn_body'])) |
236 | 243 | { |
@@ -254,8 +261,9 @@ discard block |
||
254 | 261 | { |
255 | 262 | // Fill in the suite of errors. |
256 | 263 | $context['post_errors'] = array(); |
257 | - foreach ($issueErrors as $error) |
|
258 | - $context['post_errors'][] = $txt[$error]; |
|
264 | + foreach ($issueErrors as $error) { |
|
265 | + $context['post_errors'][] = $txt[$error]; |
|
266 | + } |
|
259 | 267 | } |
260 | 268 | |
261 | 269 | |
@@ -272,9 +280,10 @@ discard block |
||
272 | 280 | $modSettings['warning_mute'] => $txt['profile_warning_effect_mute'], |
273 | 281 | ); |
274 | 282 | $context['current_level'] = 0; |
275 | - foreach ($context['level_effects'] as $limit => $dummy) |
|
276 | - if ($context['member']['warning'] >= $limit) |
|
283 | + foreach ($context['level_effects'] as $limit => $dummy) { |
|
284 | + if ($context['member']['warning'] >= $limit) |
|
277 | 285 | $context['current_level'] = $limit; |
286 | + } |
|
278 | 287 | |
279 | 288 | $listOptions = array( |
280 | 289 | 'id' => 'view_warnings', |
@@ -337,11 +346,12 @@ discard block |
||
337 | 346 | ' . $warning['reason'] . ' |
338 | 347 | </div>'; |
339 | 348 | |
340 | - if (!empty($warning['id_notice'])) |
|
341 | - $ret .= ' |
|
349 | + if (!empty($warning['id_notice'])) { |
|
350 | + $ret .= ' |
|
342 | 351 | <div class="floatright"> |
343 | 352 | <a href="' . $scripturl . '?action=moderate;area=notice;nid=' . $warning['id_notice'] . '" onclick="window.open(this.href, \'\', \'scrollbars=yes,resizable=yes,width=400,height=250\');return false;" target="_blank" class="new_win" title="' . $txt['profile_warning_previous_notice'] . '"><span class="generic_icons filter centericon"></span></a> |
344 | 353 | </div>'; |
354 | + } |
|
345 | 355 | |
346 | 356 | return $ret; |
347 | 357 | }, |
@@ -413,8 +423,9 @@ discard block |
||
413 | 423 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
414 | 424 | { |
415 | 425 | // If we're not warning for a message skip any that are. |
416 | - if (!$context['warning_for_message'] && strpos($row['body'], '{MESSAGE}') !== false) |
|
417 | - continue; |
|
426 | + if (!$context['warning_for_message'] && strpos($row['body'], '{MESSAGE}') !== false) { |
|
427 | + continue; |
|
428 | + } |
|
418 | 429 | |
419 | 430 | $context['notification_templates'][] = array( |
420 | 431 | 'title' => $row['template_title'], |
@@ -424,16 +435,18 @@ discard block |
||
424 | 435 | $smcFunc['db_free_result']($request); |
425 | 436 | |
426 | 437 | // Setup the "default" templates. |
427 | - foreach (array('spamming', 'offence', 'insulting') as $type) |
|
428 | - $context['notification_templates'][] = array( |
|
438 | + foreach (array('spamming', 'offence', 'insulting') as $type) { |
|
439 | + $context['notification_templates'][] = array( |
|
429 | 440 | 'title' => $txt['profile_warning_notify_title_' . $type], |
430 | 441 | 'body' => sprintf($txt['profile_warning_notify_template_outline' . (!empty($context['warning_for_message']) ? '_post' : '')], $txt['profile_warning_notify_for_' . $type]), |
431 | 442 | ); |
443 | + } |
|
432 | 444 | |
433 | 445 | // Replace all the common variables in the templates. |
434 | - foreach ($context['notification_templates'] as $k => $name) |
|
435 | - $context['notification_templates'][$k]['body'] = strtr($name['body'], array('{MEMBER}' => un_htmlspecialchars($context['member']['name']), '{MESSAGE}' => '[url=' . $scripturl . '?msg=' . $context['warning_for_message'] . ']' . un_htmlspecialchars($context['warned_message_subject']) . '[/url]', '{SCRIPTURL}' => $scripturl, '{FORUMNAME}' => $mbname, '{REGARDS}' => $txt['regards_team'])); |
|
436 | -} |
|
446 | + foreach ($context['notification_templates'] as $k => $name) { |
|
447 | + $context['notification_templates'][$k]['body'] = strtr($name['body'], array('{MEMBER}' => un_htmlspecialchars($context['member']['name']), '{MESSAGE}' => '[url=' . $scripturl . '?msg=' . $context['warning_for_message'] . ']' . un_htmlspecialchars($context['warned_message_subject']) . '[/url]', '{SCRIPTURL}' => $scripturl, '{FORUMNAME}' => $mbname, '{REGARDS}' => $txt['regards_team'])); |
|
448 | + } |
|
449 | + } |
|
437 | 450 | |
438 | 451 | /** |
439 | 452 | * Get the number of warnings a user has. Callback for $listOptions['get_count'] in issueWarning() |
@@ -517,10 +530,11 @@ discard block |
||
517 | 530 | { |
518 | 531 | global $txt, $context, $modSettings, $cur_profile; |
519 | 532 | |
520 | - if (!$context['user']['is_owner']) |
|
521 | - isAllowedTo('profile_remove_any'); |
|
522 | - elseif (!allowedTo('profile_remove_any')) |
|
523 | - isAllowedTo('profile_remove_own'); |
|
533 | + if (!$context['user']['is_owner']) { |
|
534 | + isAllowedTo('profile_remove_any'); |
|
535 | + } elseif (!allowedTo('profile_remove_any')) { |
|
536 | + isAllowedTo('profile_remove_own'); |
|
537 | + } |
|
524 | 538 | |
525 | 539 | // Permissions for removing stuff... |
526 | 540 | $context['can_delete_posts'] = !$context['user']['is_owner'] && allowedTo('moderate_forum'); |
@@ -547,10 +561,11 @@ discard block |
||
547 | 561 | |
548 | 562 | // @todo Add a way to delete pms as well? |
549 | 563 | |
550 | - if (!$context['user']['is_owner']) |
|
551 | - isAllowedTo('profile_remove_any'); |
|
552 | - elseif (!allowedTo('profile_remove_any')) |
|
553 | - isAllowedTo('profile_remove_own'); |
|
564 | + if (!$context['user']['is_owner']) { |
|
565 | + isAllowedTo('profile_remove_any'); |
|
566 | + } elseif (!allowedTo('profile_remove_any')) { |
|
567 | + isAllowedTo('profile_remove_own'); |
|
568 | + } |
|
554 | 569 | |
555 | 570 | checkSession(); |
556 | 571 | |
@@ -576,8 +591,9 @@ discard block |
||
576 | 591 | list ($another) = $smcFunc['db_fetch_row']($request); |
577 | 592 | $smcFunc['db_free_result']($request); |
578 | 593 | |
579 | - if (empty($another)) |
|
580 | - fatal_lang_error('at_least_one_admin', 'critical'); |
|
594 | + if (empty($another)) { |
|
595 | + fatal_lang_error('at_least_one_admin', 'critical'); |
|
596 | + } |
|
581 | 597 | } |
582 | 598 | |
583 | 599 | // This file is needed for the deleteMembers function. |
@@ -656,8 +672,9 @@ discard block |
||
656 | 672 | ) |
657 | 673 | ); |
658 | 674 | $topicIDs = array(); |
659 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
660 | - $topicIDs[] = $row['id_topic']; |
|
675 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
676 | + $topicIDs[] = $row['id_topic']; |
|
677 | + } |
|
661 | 678 | $smcFunc['db_free_result']($request); |
662 | 679 | |
663 | 680 | // Actually remove the topics. Ignore recycling if we want to perma-delete things... |
@@ -680,8 +697,9 @@ discard block |
||
680 | 697 | // This could take a while... but ya know it's gonna be worth it in the end. |
681 | 698 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
682 | 699 | { |
683 | - if (function_exists('apache_reset_timeout')) |
|
684 | - @apache_reset_timeout(); |
|
700 | + if (function_exists('apache_reset_timeout')) { |
|
701 | + @apache_reset_timeout(); |
|
702 | + } |
|
685 | 703 | |
686 | 704 | removeMessage($row['id_msg']); |
687 | 705 | } |
@@ -689,8 +707,9 @@ discard block |
||
689 | 707 | } |
690 | 708 | |
691 | 709 | // Only delete this poor members account if they are actually being booted out of camp. |
692 | - if (isset($_POST['deleteAccount'])) |
|
693 | - deleteMembers($memID); |
|
710 | + if (isset($_POST['deleteAccount'])) { |
|
711 | + deleteMembers($memID); |
|
712 | + } |
|
694 | 713 | } |
695 | 714 | // Do they need approval to delete? |
696 | 715 | elseif (!empty($modSettings['approveAccountDeletion']) && !allowedTo('moderate_forum')) |
@@ -741,18 +760,18 @@ discard block |
||
741 | 760 | { |
742 | 761 | foreach ($costs as $duration => $cost) |
743 | 762 | { |
744 | - if ($cost != 0) |
|
745 | - $cost_array[$duration] = $cost; |
|
763 | + if ($cost != 0) { |
|
764 | + $cost_array[$duration] = $cost; |
|
765 | + } |
|
746 | 766 | } |
747 | - } |
|
748 | - else |
|
767 | + } else |
|
749 | 768 | { |
750 | 769 | $cost_array['fixed'] = $costs['fixed']; |
751 | 770 | } |
752 | 771 | |
753 | - if (empty($cost_array)) |
|
754 | - unset($context['subscriptions'][$id]); |
|
755 | - else |
|
772 | + if (empty($cost_array)) { |
|
773 | + unset($context['subscriptions'][$id]); |
|
774 | + } else |
|
756 | 775 | { |
757 | 776 | $context['subscriptions'][$id]['member'] = 0; |
758 | 777 | $context['subscriptions'][$id]['subscribed'] = false; |
@@ -765,13 +784,15 @@ discard block |
||
765 | 784 | foreach ($gateways as $id => $gateway) |
766 | 785 | { |
767 | 786 | $gateways[$id] = new $gateway['display_class'](); |
768 | - if (!$gateways[$id]->gatewayEnabled()) |
|
769 | - unset($gateways[$id]); |
|
787 | + if (!$gateways[$id]->gatewayEnabled()) { |
|
788 | + unset($gateways[$id]); |
|
789 | + } |
|
770 | 790 | } |
771 | 791 | |
772 | 792 | // No gateways yet? |
773 | - if (empty($gateways)) |
|
774 | - fatal_error($txt['paid_admin_not_setup_gateway']); |
|
793 | + if (empty($gateways)) { |
|
794 | + fatal_error($txt['paid_admin_not_setup_gateway']); |
|
795 | + } |
|
775 | 796 | |
776 | 797 | // Get the current subscriptions. |
777 | 798 | $request = $smcFunc['db_query']('', ' |
@@ -786,8 +807,9 @@ discard block |
||
786 | 807 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
787 | 808 | { |
788 | 809 | // The subscription must exist! |
789 | - if (!isset($context['subscriptions'][$row['id_subscribe']])) |
|
790 | - continue; |
|
810 | + if (!isset($context['subscriptions'][$row['id_subscribe']])) { |
|
811 | + continue; |
|
812 | + } |
|
791 | 813 | |
792 | 814 | $context['current'][$row['id_subscribe']] = array( |
793 | 815 | 'id' => $row['id_sublog'], |
@@ -801,8 +823,9 @@ discard block |
||
801 | 823 | 'status_text' => $row['status'] == 0 ? ($row['payments_pending'] ? $txt['paid_pending'] : $txt['paid_finished']) : $txt['paid_active'], |
802 | 824 | ); |
803 | 825 | |
804 | - if ($row['status'] == 1) |
|
805 | - $context['subscriptions'][$row['id_subscribe']]['subscribed'] = true; |
|
826 | + if ($row['status'] == 1) { |
|
827 | + $context['subscriptions'][$row['id_subscribe']]['subscribed'] = true; |
|
828 | + } |
|
806 | 829 | } |
807 | 830 | $smcFunc['db_free_result']($request); |
808 | 831 | |
@@ -853,21 +876,25 @@ discard block |
||
853 | 876 | if (isset($_GET['confirm']) && isset($_POST['sub_id']) && is_array($_POST['sub_id'])) |
854 | 877 | { |
855 | 878 | // Hopefully just one. |
856 | - foreach ($_POST['sub_id'] as $k => $v) |
|
857 | - $ID_SUB = (int) $k; |
|
879 | + foreach ($_POST['sub_id'] as $k => $v) { |
|
880 | + $ID_SUB = (int) $k; |
|
881 | + } |
|
858 | 882 | |
859 | - if (!isset($context['subscriptions'][$ID_SUB]) || $context['subscriptions'][$ID_SUB]['active'] == 0) |
|
860 | - fatal_lang_error('paid_sub_not_active'); |
|
883 | + if (!isset($context['subscriptions'][$ID_SUB]) || $context['subscriptions'][$ID_SUB]['active'] == 0) { |
|
884 | + fatal_lang_error('paid_sub_not_active'); |
|
885 | + } |
|
861 | 886 | |
862 | 887 | // Simplify... |
863 | 888 | $context['sub'] = $context['subscriptions'][$ID_SUB]; |
864 | 889 | $period = 'xx'; |
865 | - if ($context['sub']['flexible']) |
|
866 | - $period = isset($_POST['cur'][$ID_SUB]) && isset($context['sub']['costs'][$_POST['cur'][$ID_SUB]]) ? $_POST['cur'][$ID_SUB] : 'xx'; |
|
890 | + if ($context['sub']['flexible']) { |
|
891 | + $period = isset($_POST['cur'][$ID_SUB]) && isset($context['sub']['costs'][$_POST['cur'][$ID_SUB]]) ? $_POST['cur'][$ID_SUB] : 'xx'; |
|
892 | + } |
|
867 | 893 | |
868 | 894 | // Check we have a valid cost. |
869 | - if ($context['sub']['flexible'] && $period == 'xx') |
|
870 | - fatal_lang_error('paid_sub_not_active'); |
|
895 | + if ($context['sub']['flexible'] && $period == 'xx') { |
|
896 | + fatal_lang_error('paid_sub_not_active'); |
|
897 | + } |
|
871 | 898 | |
872 | 899 | // Sort out the cost/currency. |
873 | 900 | $context['currency'] = $modSettings['paid_currency_code']; |
@@ -880,8 +907,7 @@ discard block |
||
880 | 907 | $context['cost'] = sprintf($modSettings['paid_currency_symbol'], $context['value']) . '/' . $txt[$_POST['cur'][$ID_SUB]]; |
881 | 908 | // The period value for paypal. |
882 | 909 | $context['paypal_period'] = strtoupper(substr($_POST['cur'][$ID_SUB], 0, 1)); |
883 | - } |
|
884 | - else |
|
910 | + } else |
|
885 | 911 | { |
886 | 912 | // Real cost... |
887 | 913 | $context['value'] = $context['sub']['costs']['fixed']; |
@@ -898,13 +924,15 @@ discard block |
||
898 | 924 | foreach ($gateways as $id => $gateway) |
899 | 925 | { |
900 | 926 | $fields = $gateways[$id]->fetchGatewayFields($context['sub']['id'] . '+' . $memID, $context['sub'], $context['value'], $period, $scripturl . '?action=profile;u=' . $memID . ';area=subscriptions;sub_id=' . $context['sub']['id'] . ';done'); |
901 | - if (!empty($fields['form'])) |
|
902 | - $context['gateways'][] = $fields; |
|
927 | + if (!empty($fields['form'])) { |
|
928 | + $context['gateways'][] = $fields; |
|
929 | + } |
|
903 | 930 | } |
904 | 931 | |
905 | 932 | // Bugger?! |
906 | - if (empty($context['gateways'])) |
|
907 | - fatal_error($txt['paid_admin_not_setup_gateway']); |
|
933 | + if (empty($context['gateways'])) { |
|
934 | + fatal_error($txt['paid_admin_not_setup_gateway']); |
|
935 | + } |
|
908 | 936 | |
909 | 937 | // Now we are going to assume they want to take this out ;) |
910 | 938 | $new_data = array($context['sub']['id'], $context['value'], $period, 'prepay'); |
@@ -912,16 +940,19 @@ discard block |
||
912 | 940 | { |
913 | 941 | // What are the details like? |
914 | 942 | $current_pending = array(); |
915 | - if ($context['current'][$context['sub']['id']]['pending_details'] != '') |
|
916 | - $current_pending = smf_json_decode($context['current'][$context['sub']['id']]['pending_details'], true); |
|
943 | + if ($context['current'][$context['sub']['id']]['pending_details'] != '') { |
|
944 | + $current_pending = smf_json_decode($context['current'][$context['sub']['id']]['pending_details'], true); |
|
945 | + } |
|
917 | 946 | // Don't get silly. |
918 | - if (count($current_pending) > 9) |
|
919 | - $current_pending = array(); |
|
947 | + if (count($current_pending) > 9) { |
|
948 | + $current_pending = array(); |
|
949 | + } |
|
920 | 950 | $pending_count = 0; |
921 | 951 | // Only record real pending payments as will otherwise confuse the admin! |
922 | - foreach ($current_pending as $pending) |
|
923 | - if ($pending[3] == 'payback') |
|
952 | + foreach ($current_pending as $pending) { |
|
953 | + if ($pending[3] == 'payback') |
|
924 | 954 | $pending_count++; |
955 | + } |
|
925 | 956 | |
926 | 957 | if (!in_array($new_data, $current_pending)) |
927 | 958 | { |
@@ -966,9 +997,9 @@ discard block |
||
966 | 997 | |
967 | 998 | // Quit. |
968 | 999 | return; |
1000 | + } else { |
|
1001 | + $context['sub_template'] = 'user_subscription'; |
|
1002 | + } |
|
969 | 1003 | } |
970 | - else |
|
971 | - $context['sub_template'] = 'user_subscription'; |
|
972 | -} |
|
973 | 1004 | |
974 | 1005 | ?> |
975 | 1006 | \ No newline at end of file |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 3 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * Allow the user to vote. |
@@ -51,8 +52,9 @@ discard block |
||
51 | 52 | 'not_guest' => 0, |
52 | 53 | ) |
53 | 54 | ); |
54 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
55 | - fatal_lang_error('poll_error', false); |
|
55 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
56 | + fatal_lang_error('poll_error', false); |
|
57 | + } |
|
56 | 58 | $row = $smcFunc['db_fetch_assoc']($request); |
57 | 59 | $smcFunc['db_free_result']($request); |
58 | 60 | |
@@ -60,8 +62,9 @@ discard block |
||
60 | 62 | if ($user_info['is_guest']) |
61 | 63 | { |
62 | 64 | // Guest voting disabled? |
63 | - if (!$row['guest_vote']) |
|
64 | - fatal_lang_error('guest_vote_disabled'); |
|
65 | + if (!$row['guest_vote']) { |
|
66 | + fatal_lang_error('guest_vote_disabled'); |
|
67 | + } |
|
65 | 68 | // Guest already voted? |
66 | 69 | elseif (!empty($_COOKIE['guest_poll_vote']) && preg_match('~^[0-9,;]+$~', $_COOKIE['guest_poll_vote']) && strpos($_COOKIE['guest_poll_vote'], ';' . $row['id_poll'] . ',') !== false) |
67 | 70 | { |
@@ -71,32 +74,36 @@ discard block |
||
71 | 74 | foreach ($guestinfo as $i => $guestvoted) |
72 | 75 | { |
73 | 76 | $guestvoted = explode(',', $guestvoted); |
74 | - if ($guestvoted[0] == $row['id_poll']) |
|
75 | - break; |
|
77 | + if ($guestvoted[0] == $row['id_poll']) { |
|
78 | + break; |
|
79 | + } |
|
76 | 80 | } |
77 | 81 | // Has the poll been reset since guest voted? |
78 | 82 | if ($row['reset_poll'] > $guestvoted[1]) |
79 | 83 | { |
80 | 84 | // Remove the poll info from the cookie to allow guest to vote again |
81 | 85 | unset($guestinfo[$i]); |
82 | - if (!empty($guestinfo)) |
|
83 | - $_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo); |
|
84 | - else |
|
85 | - unset($_COOKIE['guest_poll_vote']); |
|
86 | + if (!empty($guestinfo)) { |
|
87 | + $_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo); |
|
88 | + } else { |
|
89 | + unset($_COOKIE['guest_poll_vote']); |
|
90 | + } |
|
91 | + } else { |
|
92 | + fatal_lang_error('poll_error', false); |
|
86 | 93 | } |
87 | - else |
|
88 | - fatal_lang_error('poll_error', false); |
|
89 | 94 | unset($guestinfo, $guestvoted, $i); |
90 | 95 | } |
91 | 96 | } |
92 | 97 | |
93 | 98 | // Is voting locked or has it expired? |
94 | - if (!empty($row['voting_locked']) || (!empty($row['expire_time']) && time() > $row['expire_time'])) |
|
95 | - fatal_lang_error('poll_error', false); |
|
99 | + if (!empty($row['voting_locked']) || (!empty($row['expire_time']) && time() > $row['expire_time'])) { |
|
100 | + fatal_lang_error('poll_error', false); |
|
101 | + } |
|
96 | 102 | |
97 | 103 | // If they have already voted and aren't allowed to change their vote - hence they are outta here! |
98 | - if (!$user_info['is_guest'] && $row['selected'] != -1 && empty($row['change_vote'])) |
|
99 | - fatal_lang_error('poll_error', false); |
|
104 | + if (!$user_info['is_guest'] && $row['selected'] != -1 && empty($row['change_vote'])) { |
|
105 | + fatal_lang_error('poll_error', false); |
|
106 | + } |
|
100 | 107 | // Otherwise if they can change their vote yet they haven't sent any options... remove their vote and redirect. |
101 | 108 | elseif (!empty($row['change_vote']) && !$user_info['is_guest'] && empty($_POST['options'])) |
102 | 109 | { |
@@ -114,8 +121,9 @@ discard block |
||
114 | 121 | 'id_poll' => $row['id_poll'], |
115 | 122 | ) |
116 | 123 | ); |
117 | - while ($choice = $smcFunc['db_fetch_row']($request)) |
|
118 | - $pollOptions[] = $choice[0]; |
|
124 | + while ($choice = $smcFunc['db_fetch_row']($request)) { |
|
125 | + $pollOptions[] = $choice[0]; |
|
126 | + } |
|
119 | 127 | $smcFunc['db_free_result']($request); |
120 | 128 | |
121 | 129 | // Just skip it if they had voted for nothing before. |
@@ -148,19 +156,22 @@ discard block |
||
148 | 156 | } |
149 | 157 | |
150 | 158 | // Redirect back to the topic so the user can vote again! |
151 | - if (empty($_POST['options'])) |
|
152 | - redirectexit('topic=' . $topic . '.' . $_REQUEST['start']); |
|
159 | + if (empty($_POST['options'])) { |
|
160 | + redirectexit('topic=' . $topic . '.' . $_REQUEST['start']); |
|
161 | + } |
|
153 | 162 | } |
154 | 163 | |
155 | 164 | checkSession('request'); |
156 | 165 | |
157 | 166 | // Make sure the option(s) are valid. |
158 | - if (empty($_POST['options'])) |
|
159 | - fatal_lang_error('didnt_select_vote', false); |
|
167 | + if (empty($_POST['options'])) { |
|
168 | + fatal_lang_error('didnt_select_vote', false); |
|
169 | + } |
|
160 | 170 | |
161 | 171 | // Too many options checked! |
162 | - if (count($_REQUEST['options']) > $row['max_votes']) |
|
163 | - fatal_lang_error('poll_too_many_votes', false, array($row['max_votes'])); |
|
172 | + if (count($_REQUEST['options']) > $row['max_votes']) { |
|
173 | + fatal_lang_error('poll_too_many_votes', false, array($row['max_votes'])); |
|
174 | + } |
|
164 | 175 | |
165 | 176 | $pollOptions = array(); |
166 | 177 | $inserts = array(); |
@@ -250,24 +261,30 @@ discard block |
||
250 | 261 | list ($memberID, $pollID, $voting_locked) = $smcFunc['db_fetch_row']($request); |
251 | 262 | |
252 | 263 | // If the user _can_ modify the poll.... |
253 | - if (!allowedTo('poll_lock_any')) |
|
254 | - isAllowedTo('poll_lock_' . ($user_info['id'] == $memberID ? 'own' : 'any')); |
|
264 | + if (!allowedTo('poll_lock_any')) { |
|
265 | + isAllowedTo('poll_lock_' . ($user_info['id'] == $memberID ? 'own' : 'any')); |
|
266 | + } |
|
255 | 267 | |
256 | 268 | // It's been locked by a non-moderator. |
257 | - if ($voting_locked == '1') |
|
258 | - $voting_locked = '0'; |
|
269 | + if ($voting_locked == '1') { |
|
270 | + $voting_locked = '0'; |
|
271 | + } |
|
259 | 272 | // Locked by a moderator, and this is a moderator. |
260 | - elseif ($voting_locked == '2' && allowedTo('moderate_board')) |
|
261 | - $voting_locked = '0'; |
|
273 | + elseif ($voting_locked == '2' && allowedTo('moderate_board')) { |
|
274 | + $voting_locked = '0'; |
|
275 | + } |
|
262 | 276 | // Sorry, a moderator locked it. |
263 | - elseif ($voting_locked == '2' && !allowedTo('moderate_board')) |
|
264 | - fatal_lang_error('locked_by_admin', 'user'); |
|
277 | + elseif ($voting_locked == '2' && !allowedTo('moderate_board')) { |
|
278 | + fatal_lang_error('locked_by_admin', 'user'); |
|
279 | + } |
|
265 | 280 | // A moderator *is* locking it. |
266 | - elseif ($voting_locked == '0' && allowedTo('moderate_board')) |
|
267 | - $voting_locked = '2'; |
|
281 | + elseif ($voting_locked == '0' && allowedTo('moderate_board')) { |
|
282 | + $voting_locked = '2'; |
|
283 | + } |
|
268 | 284 | // Well, it's gonna be locked one way or another otherwise... |
269 | - else |
|
270 | - $voting_locked = '1'; |
|
285 | + else { |
|
286 | + $voting_locked = '1'; |
|
287 | + } |
|
271 | 288 | |
272 | 289 | // Lock! *Poof* - no one can vote. |
273 | 290 | $smcFunc['db_query']('', ' |
@@ -302,8 +319,9 @@ discard block |
||
302 | 319 | { |
303 | 320 | global $txt, $user_info, $context, $topic, $board, $smcFunc, $sourcedir, $scripturl; |
304 | 321 | |
305 | - if (empty($topic)) |
|
306 | - fatal_lang_error('no_access', false); |
|
322 | + if (empty($topic)) { |
|
323 | + fatal_lang_error('no_access', false); |
|
324 | + } |
|
307 | 325 | |
308 | 326 | loadLanguage('Post'); |
309 | 327 | loadTemplate('Poll'); |
@@ -327,24 +345,28 @@ discard block |
||
327 | 345 | ); |
328 | 346 | |
329 | 347 | // Assume the the topic exists, right? |
330 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
331 | - fatal_lang_error('no_board'); |
|
348 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
349 | + fatal_lang_error('no_board'); |
|
350 | + } |
|
332 | 351 | // Get the poll information. |
333 | 352 | $pollinfo = $smcFunc['db_fetch_assoc']($request); |
334 | 353 | $smcFunc['db_free_result']($request); |
335 | 354 | |
336 | 355 | // If we are adding a new poll - make sure that there isn't already a poll there. |
337 | - if (!$context['is_edit'] && !empty($pollinfo['id_poll'])) |
|
338 | - fatal_lang_error('poll_already_exists'); |
|
356 | + if (!$context['is_edit'] && !empty($pollinfo['id_poll'])) { |
|
357 | + fatal_lang_error('poll_already_exists'); |
|
358 | + } |
|
339 | 359 | // Otherwise, if we're editing it, it does exist I assume? |
340 | - elseif ($context['is_edit'] && empty($pollinfo['id_poll'])) |
|
341 | - fatal_lang_error('poll_not_found'); |
|
360 | + elseif ($context['is_edit'] && empty($pollinfo['id_poll'])) { |
|
361 | + fatal_lang_error('poll_not_found'); |
|
362 | + } |
|
342 | 363 | |
343 | 364 | // Can you do this? |
344 | - if ($context['is_edit'] && !allowedTo('poll_edit_any')) |
|
345 | - isAllowedTo('poll_edit_' . ($user_info['id'] == $pollinfo['id_member_started'] || ($pollinfo['poll_starter'] != 0 && $user_info['id'] == $pollinfo['poll_starter']) ? 'own' : 'any')); |
|
346 | - elseif (!$context['is_edit'] && !allowedTo('poll_add_any')) |
|
347 | - isAllowedTo('poll_add_' . ($user_info['id'] == $pollinfo['id_member_started'] ? 'own' : 'any')); |
|
365 | + if ($context['is_edit'] && !allowedTo('poll_edit_any')) { |
|
366 | + isAllowedTo('poll_edit_' . ($user_info['id'] == $pollinfo['id_member_started'] || ($pollinfo['poll_starter'] != 0 && $user_info['id'] == $pollinfo['poll_starter']) ? 'own' : 'any')); |
|
367 | + } elseif (!$context['is_edit'] && !allowedTo('poll_add_any')) { |
|
368 | + isAllowedTo('poll_add_' . ($user_info['id'] == $pollinfo['id_member_started'] ? 'own' : 'any')); |
|
369 | + } |
|
348 | 370 | $context['can_moderate_poll'] = isset($_REQUEST['add']) ? true : allowedTo('poll_edit_' . ($user_info['id'] == $pollinfo['id_member_started'] || ($pollinfo['poll_starter'] != 0 && $user_info['id'] == $pollinfo['poll_starter']) ? 'own' : 'any')); |
349 | 371 | |
350 | 372 | // Do we enable guest voting? |
@@ -386,12 +408,14 @@ discard block |
||
386 | 408 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
387 | 409 | { |
388 | 410 | // Get the highest id so we can add more without reusing. |
389 | - if ($row['id_choice'] >= $last_id) |
|
390 | - $last_id = $row['id_choice'] + 1; |
|
411 | + if ($row['id_choice'] >= $last_id) { |
|
412 | + $last_id = $row['id_choice'] + 1; |
|
413 | + } |
|
391 | 414 | |
392 | 415 | // They cleared this by either omitting it or emptying it. |
393 | - if (!isset($_POST['options'][$row['id_choice']]) || $_POST['options'][$row['id_choice']] == '') |
|
394 | - continue; |
|
416 | + if (!isset($_POST['options'][$row['id_choice']]) || $_POST['options'][$row['id_choice']] == '') { |
|
417 | + continue; |
|
418 | + } |
|
395 | 419 | |
396 | 420 | censorText($row['label']); |
397 | 421 | |
@@ -409,9 +433,10 @@ discard block |
||
409 | 433 | |
410 | 434 | // Work out how many options we have, so we get the 'is_last' field right... |
411 | 435 | $totalPostOptions = 0; |
412 | - foreach ($_POST['options'] as $id => $label) |
|
413 | - if ($label != '') |
|
436 | + foreach ($_POST['options'] as $id => $label) { |
|
437 | + if ($label != '') |
|
414 | 438 | $totalPostOptions++; |
439 | + } |
|
415 | 440 | |
416 | 441 | $count = 1; |
417 | 442 | // If an option exists, update it. If it is new, add it - but don't reuse ids! |
@@ -420,30 +445,32 @@ discard block |
||
420 | 445 | $label = $smcFunc['htmlspecialchars']($label); |
421 | 446 | censorText($label); |
422 | 447 | |
423 | - if (isset($context['choices'][$id])) |
|
424 | - $context['choices'][$id]['label'] = $label; |
|
425 | - elseif ($label != '') |
|
426 | - $context['choices'][] = array( |
|
448 | + if (isset($context['choices'][$id])) { |
|
449 | + $context['choices'][$id]['label'] = $label; |
|
450 | + } elseif ($label != '') { |
|
451 | + $context['choices'][] = array( |
|
427 | 452 | 'id' => $last_id++, |
428 | 453 | 'number' => $number++, |
429 | 454 | 'label' => $label, |
430 | 455 | 'votes' => -1, |
431 | 456 | 'is_last' => $count++ == $totalPostOptions && $totalPostOptions > 1 ? true : false, |
432 | 457 | ); |
458 | + } |
|
433 | 459 | } |
434 | 460 | |
435 | 461 | // Make sure we have two choices for sure! |
436 | 462 | if ($totalPostOptions < 2) |
437 | 463 | { |
438 | 464 | // Need two? |
439 | - if ($totalPostOptions == 0) |
|
440 | - $context['choices'][] = array( |
|
465 | + if ($totalPostOptions == 0) { |
|
466 | + $context['choices'][] = array( |
|
441 | 467 | 'id' => $last_id++, |
442 | 468 | 'number' => $number++, |
443 | 469 | 'label' => '', |
444 | 470 | 'votes' => -1, |
445 | 471 | 'is_last' => false |
446 | 472 | ); |
473 | + } |
|
447 | 474 | $poll_errors[] = 'poll_few'; |
448 | 475 | } |
449 | 476 | |
@@ -458,12 +485,14 @@ discard block |
||
458 | 485 | |
459 | 486 | $context['last_choice_id'] = $last_id; |
460 | 487 | |
461 | - if ($context['can_moderate_poll']) |
|
462 | - $context['poll']['expiration'] = $_POST['poll_expire']; |
|
488 | + if ($context['can_moderate_poll']) { |
|
489 | + $context['poll']['expiration'] = $_POST['poll_expire']; |
|
490 | + } |
|
463 | 491 | |
464 | 492 | // Check the question/option count for errors. |
465 | - if (trim($_POST['question']) == '' && empty($context['poll_error'])) |
|
466 | - $poll_errors[] = 'no_question'; |
|
493 | + if (trim($_POST['question']) == '' && empty($context['poll_error'])) { |
|
494 | + $poll_errors[] = 'no_question'; |
|
495 | + } |
|
467 | 496 | |
468 | 497 | // No check is needed, since nothing is really posted. |
469 | 498 | checkSubmitOnce('free'); |
@@ -480,8 +509,7 @@ discard block |
||
480 | 509 | $context['poll_error']['messages'][] = $txt['error_' . $poll_error]; |
481 | 510 | } |
482 | 511 | } |
483 | - } |
|
484 | - else |
|
512 | + } else |
|
485 | 513 | { |
486 | 514 | // Basic theme info... |
487 | 515 | $context['poll'] = array( |
@@ -596,18 +624,22 @@ discard block |
||
596 | 624 | global $user_info, $smcFunc, $sourcedir; |
597 | 625 | |
598 | 626 | // Sneaking off, are we? |
599 | - if (empty($_POST)) |
|
600 | - redirectexit('action=editpoll;topic=' . $topic . '.0'); |
|
627 | + if (empty($_POST)) { |
|
628 | + redirectexit('action=editpoll;topic=' . $topic . '.0'); |
|
629 | + } |
|
601 | 630 | |
602 | - if (checkSession('post', '', false) != '') |
|
603 | - $poll_errors[] = 'session_timeout'; |
|
631 | + if (checkSession('post', '', false) != '') { |
|
632 | + $poll_errors[] = 'session_timeout'; |
|
633 | + } |
|
604 | 634 | |
605 | - if (isset($_POST['preview'])) |
|
606 | - return EditPoll(); |
|
635 | + if (isset($_POST['preview'])) { |
|
636 | + return EditPoll(); |
|
637 | + } |
|
607 | 638 | |
608 | 639 | // HACKERS (!!) can't edit :P. |
609 | - if (empty($topic)) |
|
610 | - fatal_lang_error('no_access', false); |
|
640 | + if (empty($topic)) { |
|
641 | + fatal_lang_error('no_access', false); |
|
642 | + } |
|
611 | 643 | |
612 | 644 | // Is this a new poll, or editing an existing? |
613 | 645 | $isEdit = isset($_REQUEST['add']) ? 0 : 1; |
@@ -623,23 +655,27 @@ discard block |
||
623 | 655 | 'current_topic' => $topic, |
624 | 656 | ) |
625 | 657 | ); |
626 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
627 | - fatal_lang_error('no_board'); |
|
658 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
659 | + fatal_lang_error('no_board'); |
|
660 | + } |
|
628 | 661 | $bcinfo = $smcFunc['db_fetch_assoc']($request); |
629 | 662 | $smcFunc['db_free_result']($request); |
630 | 663 | |
631 | 664 | // Check their adding/editing is valid. |
632 | - if (!$isEdit && !empty($bcinfo['id_poll'])) |
|
633 | - fatal_lang_error('poll_already_exists'); |
|
665 | + if (!$isEdit && !empty($bcinfo['id_poll'])) { |
|
666 | + fatal_lang_error('poll_already_exists'); |
|
667 | + } |
|
634 | 668 | // Are we editing a poll which doesn't exist? |
635 | - elseif ($isEdit && empty($bcinfo['id_poll'])) |
|
636 | - fatal_lang_error('poll_not_found'); |
|
669 | + elseif ($isEdit && empty($bcinfo['id_poll'])) { |
|
670 | + fatal_lang_error('poll_not_found'); |
|
671 | + } |
|
637 | 672 | |
638 | 673 | // Check if they have the power to add or edit the poll. |
639 | - if ($isEdit && !allowedTo('poll_edit_any')) |
|
640 | - isAllowedTo('poll_edit_' . ($user_info['id'] == $bcinfo['id_member_started'] || ($bcinfo['poll_starter'] != 0 && $user_info['id'] == $bcinfo['poll_starter']) ? 'own' : 'any')); |
|
641 | - elseif (!$isEdit && !allowedTo('poll_add_any')) |
|
642 | - isAllowedTo('poll_add_' . ($user_info['id'] == $bcinfo['id_member_started'] ? 'own' : 'any')); |
|
674 | + if ($isEdit && !allowedTo('poll_edit_any')) { |
|
675 | + isAllowedTo('poll_edit_' . ($user_info['id'] == $bcinfo['id_member_started'] || ($bcinfo['poll_starter'] != 0 && $user_info['id'] == $bcinfo['poll_starter']) ? 'own' : 'any')); |
|
676 | + } elseif (!$isEdit && !allowedTo('poll_add_any')) { |
|
677 | + isAllowedTo('poll_add_' . ($user_info['id'] == $bcinfo['id_member_started'] ? 'own' : 'any')); |
|
678 | + } |
|
643 | 679 | |
644 | 680 | $optionCount = 0; |
645 | 681 | $idCount = 0; |
@@ -652,14 +688,16 @@ discard block |
||
652 | 688 | $idCount = max($idCount, $k); |
653 | 689 | } |
654 | 690 | } |
655 | - if ($optionCount < 2) |
|
656 | - $poll_errors[] = 'poll_few'; |
|
657 | - elseif ($optionCount > 256 || $idCount > 255) |
|
658 | - $poll_errors[] = 'poll_many'; |
|
691 | + if ($optionCount < 2) { |
|
692 | + $poll_errors[] = 'poll_few'; |
|
693 | + } elseif ($optionCount > 256 || $idCount > 255) { |
|
694 | + $poll_errors[] = 'poll_many'; |
|
695 | + } |
|
659 | 696 | |
660 | 697 | // Also - ensure they are not removing the question. |
661 | - if (trim($_POST['question']) == '') |
|
662 | - $poll_errors[] = 'no_question'; |
|
698 | + if (trim($_POST['question']) == '') { |
|
699 | + $poll_errors[] = 'no_question'; |
|
700 | + } |
|
663 | 701 | |
664 | 702 | // Got any errors to report? |
665 | 703 | if (!empty($poll_errors)) |
@@ -695,8 +733,9 @@ discard block |
||
695 | 733 | { |
696 | 734 | require_once($sourcedir . '/Subs-Members.php'); |
697 | 735 | $allowedGroups = groupsAllowedTo('poll_vote', $board); |
698 | - if (!in_array(-1, $allowedGroups['allowed'])) |
|
699 | - $_POST['poll_guest_vote'] = 0; |
|
736 | + if (!in_array(-1, $allowedGroups['allowed'])) { |
|
737 | + $_POST['poll_guest_vote'] = 0; |
|
738 | + } |
|
700 | 739 | } |
701 | 740 | |
702 | 741 | // Ensure that the number options allowed makes sense, and the expiration date is valid. |
@@ -704,17 +743,19 @@ discard block |
||
704 | 743 | { |
705 | 744 | $_POST['poll_expire'] = $_POST['poll_expire'] > 9999 ? 9999 : ($_POST['poll_expire'] < 0 ? 0 : $_POST['poll_expire']); |
706 | 745 | |
707 | - if (empty($_POST['poll_expire']) && $_POST['poll_hide'] == 2) |
|
708 | - $_POST['poll_hide'] = 1; |
|
709 | - elseif (!$isEdit || $_POST['poll_expire'] != ceil($bcinfo['expire_time'] <= time() ? -1 : ($bcinfo['expire_time'] - time()) / (3600 * 24))) |
|
710 | - $_POST['poll_expire'] = empty($_POST['poll_expire']) ? '0' : time() + $_POST['poll_expire'] * 3600 * 24; |
|
711 | - else |
|
712 | - $_POST['poll_expire'] = $bcinfo['expire_time']; |
|
746 | + if (empty($_POST['poll_expire']) && $_POST['poll_hide'] == 2) { |
|
747 | + $_POST['poll_hide'] = 1; |
|
748 | + } elseif (!$isEdit || $_POST['poll_expire'] != ceil($bcinfo['expire_time'] <= time() ? -1 : ($bcinfo['expire_time'] - time()) / (3600 * 24))) { |
|
749 | + $_POST['poll_expire'] = empty($_POST['poll_expire']) ? '0' : time() + $_POST['poll_expire'] * 3600 * 24; |
|
750 | + } else { |
|
751 | + $_POST['poll_expire'] = $bcinfo['expire_time']; |
|
752 | + } |
|
713 | 753 | |
714 | - if (empty($_POST['poll_max_votes']) || $_POST['poll_max_votes'] <= 0) |
|
715 | - $_POST['poll_max_votes'] = 1; |
|
716 | - else |
|
717 | - $_POST['poll_max_votes'] = (int) $_POST['poll_max_votes']; |
|
754 | + if (empty($_POST['poll_max_votes']) || $_POST['poll_max_votes'] <= 0) { |
|
755 | + $_POST['poll_max_votes'] = 1; |
|
756 | + } else { |
|
757 | + $_POST['poll_max_votes'] = (int) $_POST['poll_max_votes']; |
|
758 | + } |
|
718 | 759 | } |
719 | 760 | |
720 | 761 | // If we're editing, let's commit the changes. |
@@ -781,8 +822,9 @@ discard block |
||
781 | 822 | ) |
782 | 823 | ); |
783 | 824 | $choices = array(); |
784 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
785 | - $choices[] = $row['id_choice']; |
|
825 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
826 | + $choices[] = $row['id_choice']; |
|
827 | + } |
|
786 | 828 | $smcFunc['db_free_result']($request); |
787 | 829 | |
788 | 830 | $delete_options = array(); |
@@ -795,8 +837,9 @@ discard block |
||
795 | 837 | if (trim($option) == '') |
796 | 838 | { |
797 | 839 | // They want it deleted. Bye. |
798 | - if (in_array($k, $choices)) |
|
799 | - $delete_options[] = $k; |
|
840 | + if (in_array($k, $choices)) { |
|
841 | + $delete_options[] = $k; |
|
842 | + } |
|
800 | 843 | |
801 | 844 | // Skip the rest... |
802 | 845 | continue; |
@@ -806,8 +849,8 @@ discard block |
||
806 | 849 | $option = $smcFunc['htmlspecialchars']($option); |
807 | 850 | |
808 | 851 | // If it's already there, update it. If it's not... add it. |
809 | - if (in_array($k, $choices)) |
|
810 | - $smcFunc['db_query']('', ' |
|
852 | + if (in_array($k, $choices)) { |
|
853 | + $smcFunc['db_query']('', ' |
|
811 | 854 | UPDATE {db_prefix}poll_choices |
812 | 855 | SET label = {string:option_name} |
813 | 856 | WHERE id_poll = {int:id_poll} |
@@ -818,8 +861,8 @@ discard block |
||
818 | 861 | 'option_name' => $option, |
819 | 862 | ) |
820 | 863 | ); |
821 | - else |
|
822 | - $smcFunc['db_insert']('', |
|
864 | + } else { |
|
865 | + $smcFunc['db_insert']('', |
|
823 | 866 | '{db_prefix}poll_choices', |
824 | 867 | array( |
825 | 868 | 'id_poll' => 'int', 'id_choice' => 'int', 'label' => 'string-255', 'votes' => 'int', |
@@ -829,6 +872,7 @@ discard block |
||
829 | 872 | ), |
830 | 873 | array() |
831 | 874 | ); |
875 | + } |
|
832 | 876 | } |
833 | 877 | |
834 | 878 | // I'm sorry, but... well, no one was choosing you. Poor options, I'll put you out of your misery. |
@@ -894,13 +938,11 @@ discard block |
||
894 | 938 | { |
895 | 939 | // Added a poll |
896 | 940 | logAction('add_poll', array('topic' => $topic)); |
897 | - } |
|
898 | - elseif (isset($_REQUEST['deletevotes'])) |
|
941 | + } elseif (isset($_REQUEST['deletevotes'])) |
|
899 | 942 | { |
900 | 943 | // Reset votes |
901 | 944 | logAction('reset_poll', array('topic' => $topic)); |
902 | - } |
|
903 | - else |
|
945 | + } else |
|
904 | 946 | { |
905 | 947 | // Something else |
906 | 948 | logAction('editpoll', array('topic' => $topic)); |
@@ -923,8 +965,9 @@ discard block |
||
923 | 965 | global $topic, $user_info, $smcFunc; |
924 | 966 | |
925 | 967 | // Make sure the topic is not empty. |
926 | - if (empty($topic)) |
|
927 | - fatal_lang_error('no_access', false); |
|
968 | + if (empty($topic)) { |
|
969 | + fatal_lang_error('no_access', false); |
|
970 | + } |
|
928 | 971 | |
929 | 972 | // Verify the session. |
930 | 973 | checkSession('get'); |
@@ -942,8 +985,9 @@ discard block |
||
942 | 985 | 'current_topic' => $topic, |
943 | 986 | ) |
944 | 987 | ); |
945 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
946 | - fatal_lang_error('no_access', false); |
|
988 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
989 | + fatal_lang_error('no_access', false); |
|
990 | + } |
|
947 | 991 | list ($topicStarter, $pollStarter) = $smcFunc['db_fetch_row']($request); |
948 | 992 | $smcFunc['db_free_result']($request); |
949 | 993 |
@@ -1,9 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | // Try to handle it with the upper level index.php. (it should know what to do.) |
4 | -if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) |
|
4 | +if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) { |
|
5 | 5 | include (dirname(dirname(__FILE__)) . '/index.php'); |
6 | -else |
|
6 | +} else { |
|
7 | 7 | exit; |
8 | +} |
|
8 | 9 | |
9 | 10 | ?> |
10 | 11 | \ No newline at end of file |