@@ -61,7 +61,7 @@ |
||
| 61 | 61 | $server = trim($servers[array_rand($servers)]); |
| 62 | 62 | |
| 63 | 63 | // Normal host names do not contain slashes, while e.g. unix sockets do. Assume alternative transport pipe with port 0. |
| 64 | - if (strpos($server,'/') !== false) |
|
| 64 | + if (strpos($server, '/') !== false) |
|
| 65 | 65 | $host = $server; |
| 66 | 66 | else |
| 67 | 67 | { |
@@ -11,8 +11,9 @@ discard block |
||
| 11 | 11 | * @version 2.1 Beta 3 |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if (!defined('SMF')) |
|
| 14 | +if (!defined('SMF')) { |
|
| 15 | 15 | die('Hacking attempt...'); |
| 16 | +} |
|
| 16 | 17 | |
| 17 | 18 | /** |
| 18 | 19 | * Our Cache API class |
@@ -34,8 +35,9 @@ discard block |
||
| 34 | 35 | |
| 35 | 36 | $supported = class_exists('memcache'); |
| 36 | 37 | |
| 37 | - if ($test) |
|
| 38 | - return $supported; |
|
| 38 | + if ($test) { |
|
| 39 | + return $supported; |
|
| 40 | + } |
|
| 39 | 41 | return parent::isSupported() && $supported && !empty($cache_memcached); |
| 40 | 42 | } |
| 41 | 43 | |
@@ -61,9 +63,9 @@ discard block |
||
| 61 | 63 | $server = trim($servers[array_rand($servers)]); |
| 62 | 64 | |
| 63 | 65 | // Normal host names do not contain slashes, while e.g. unix sockets do. Assume alternative transport pipe with port 0. |
| 64 | - if (strpos($server,'/') !== false) |
|
| 65 | - $host = $server; |
|
| 66 | - else |
|
| 66 | + if (strpos($server,'/') !== false) { |
|
| 67 | + $host = $server; |
|
| 68 | + } else |
|
| 67 | 69 | { |
| 68 | 70 | $server = explode(':', $server); |
| 69 | 71 | $host = $server[0]; |
@@ -71,10 +73,11 @@ discard block |
||
| 71 | 73 | } |
| 72 | 74 | |
| 73 | 75 | // Don't wait too long: yes, we want the server, but we might be able to run the query faster! |
| 74 | - if (empty($db_persist)) |
|
| 75 | - $connected = $this->memcache->connect($host, $port); |
|
| 76 | - else |
|
| 77 | - $connected = $this->memcache->pconnect($host, $port); |
|
| 76 | + if (empty($db_persist)) { |
|
| 77 | + $connected = $this->memcache->connect($host, $port); |
|
| 78 | + } else { |
|
| 79 | + $connected = $this->memcache->pconnect($host, $port); |
|
| 80 | + } |
|
| 78 | 81 | } |
| 79 | 82 | |
| 80 | 83 | return $connected; |
@@ -90,8 +93,9 @@ discard block |
||
| 90 | 93 | $value = $this->memcache->get($key); |
| 91 | 94 | |
| 92 | 95 | // $value should return either data or false (from failure, key not found or empty array). |
| 93 | - if ($value === false) |
|
| 94 | - return null; |
|
| 96 | + if ($value === false) { |
|
| 97 | + return null; |
|
| 98 | + } |
|
| 95 | 99 | return $value; |
| 96 | 100 | } |
| 97 | 101 | |
@@ -132,8 +136,9 @@ discard block |
||
| 132 | 136 | $config_vars[] = $txt['cache_memcache_settings']; |
| 133 | 137 | $config_vars[] = array('cache_memcached', $txt['cache_memcache_servers'], 'file', 'text', 0, 'cache_memcached', 'postinput' => '<br /><div class="smalltext"><em>' . $txt['cache_memcache_servers_subtext'] . '</em></div>'); |
| 134 | 138 | |
| 135 | - if (!isset($context['settings_post_javascript'])) |
|
| 136 | - $context['settings_post_javascript'] = ''; |
|
| 139 | + if (!isset($context['settings_post_javascript'])) { |
|
| 140 | + $context['settings_post_javascript'] = ''; |
|
| 141 | + } |
|
| 137 | 142 | |
| 138 | 143 | $context['settings_post_javascript'] .= ' |
| 139 | 144 | $("#cache_accelerator").change(function (e) { |
@@ -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 | * Locks a topic... either by way of a moderator or the topic starter. |
@@ -32,8 +33,9 @@ discard block |
||
| 32 | 33 | global $topic, $user_info, $sourcedir, $board, $smcFunc; |
| 33 | 34 | |
| 34 | 35 | // Just quit if there's no topic to lock. |
| 35 | - if (empty($topic)) |
|
| 36 | - fatal_lang_error('not_a_topic', false); |
|
| 36 | + if (empty($topic)) { |
|
| 37 | + fatal_lang_error('not_a_topic', false); |
|
| 38 | + } |
|
| 37 | 39 | |
| 38 | 40 | checkSession('get'); |
| 39 | 41 | |
@@ -55,23 +57,28 @@ discard block |
||
| 55 | 57 | |
| 56 | 58 | // Can you lock topics here, mister? |
| 57 | 59 | $user_lock = !allowedTo('lock_any'); |
| 58 | - if ($user_lock && $starter == $user_info['id']) |
|
| 59 | - isAllowedTo('lock_own'); |
|
| 60 | - else |
|
| 61 | - isAllowedTo('lock_any'); |
|
| 60 | + if ($user_lock && $starter == $user_info['id']) { |
|
| 61 | + isAllowedTo('lock_own'); |
|
| 62 | + } else { |
|
| 63 | + isAllowedTo('lock_any'); |
|
| 64 | + } |
|
| 62 | 65 | |
| 63 | 66 | // Locking with high privileges. |
| 64 | - if ($locked == '0' && !$user_lock) |
|
| 65 | - $locked = '1'; |
|
| 67 | + if ($locked == '0' && !$user_lock) { |
|
| 68 | + $locked = '1'; |
|
| 69 | + } |
|
| 66 | 70 | // Locking with low privileges. |
| 67 | - elseif ($locked == '0') |
|
| 68 | - $locked = '2'; |
|
| 71 | + elseif ($locked == '0') { |
|
| 72 | + $locked = '2'; |
|
| 73 | + } |
|
| 69 | 74 | // Unlocking - make sure you don't unlock what you can't. |
| 70 | - elseif ($locked == '2' || ($locked == '1' && !$user_lock)) |
|
| 71 | - $locked = '0'; |
|
| 75 | + elseif ($locked == '2' || ($locked == '1' && !$user_lock)) { |
|
| 76 | + $locked = '0'; |
|
| 77 | + } |
|
| 72 | 78 | // You cannot unlock this! |
| 73 | - else |
|
| 74 | - fatal_lang_error('locked_by_admin', 'user'); |
|
| 79 | + else { |
|
| 80 | + fatal_lang_error('locked_by_admin', 'user'); |
|
| 81 | + } |
|
| 75 | 82 | |
| 76 | 83 | // Actually lock the topic in the database with the new value. |
| 77 | 84 | $smcFunc['db_query']('', ' |
@@ -85,8 +92,9 @@ discard block |
||
| 85 | 92 | ); |
| 86 | 93 | |
| 87 | 94 | // If they are allowed a "moderator" permission, log it in the moderator log. |
| 88 | - if (!$user_lock) |
|
| 89 | - logAction($locked ? 'lock' : 'unlock', array('topic' => $topic, 'board' => $board)); |
|
| 95 | + if (!$user_lock) { |
|
| 96 | + logAction($locked ? 'lock' : 'unlock', array('topic' => $topic, 'board' => $board)); |
|
| 97 | + } |
|
| 90 | 98 | // Notify people that this topic has been locked? |
| 91 | 99 | sendNotifications($topic, empty($locked) ? 'unlock' : 'lock'); |
| 92 | 100 | |
@@ -112,8 +120,9 @@ discard block |
||
| 112 | 120 | isAllowedTo('make_sticky'); |
| 113 | 121 | |
| 114 | 122 | // You can't sticky a board or something! |
| 115 | - if (empty($topic)) |
|
| 116 | - fatal_lang_error('not_a_topic', false); |
|
| 123 | + if (empty($topic)) { |
|
| 124 | + fatal_lang_error('not_a_topic', false); |
|
| 125 | + } |
|
| 117 | 126 | |
| 118 | 127 | checkSession('get'); |
| 119 | 128 | |
@@ -147,8 +156,9 @@ discard block |
||
| 147 | 156 | // Log this sticky action - always a moderator thing. |
| 148 | 157 | logAction(empty($is_sticky) ? 'sticky' : 'unsticky', array('topic' => $topic, 'board' => $board)); |
| 149 | 158 | // Notify people that this topic has been stickied? |
| 150 | - if (empty($is_sticky)) |
|
| 151 | - sendNotifications($topic, 'sticky'); |
|
| 159 | + if (empty($is_sticky)) { |
|
| 160 | + sendNotifications($topic, 'sticky'); |
|
| 161 | + } |
|
| 152 | 162 | |
| 153 | 163 | // Take them back to the now stickied topic. |
| 154 | 164 | redirectexit('topic=' . $topic . '.' . $_REQUEST['start'] . ';moderate'); |
@@ -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 | * Fetches a list of boards and (optional) categories including |
@@ -37,11 +38,12 @@ discard block |
||
| 37 | 38 | require_once($sourcedir . '/Subs-Boards.php'); |
| 38 | 39 | |
| 39 | 40 | // For performance, track the latest post while going through the boards. |
| 40 | - if (!empty($boardIndexOptions['set_latest_post'])) |
|
| 41 | - $latest_post = array( |
|
| 41 | + if (!empty($boardIndexOptions['set_latest_post'])) { |
|
| 42 | + $latest_post = array( |
|
| 42 | 43 | 'timestamp' => 0, |
| 43 | 44 | 'ref' => 0, |
| 44 | 45 | ); |
| 46 | + } |
|
| 45 | 47 | |
| 46 | 48 | // Find all boards and categories, as well as related information. This will be sorted by the natural order of boards and categories, which we control. |
| 47 | 49 | $result_boards = $smcFunc['db_query']('boardindex_fetch_boards', ' |
@@ -74,10 +76,11 @@ discard block |
||
| 74 | 76 | ); |
| 75 | 77 | |
| 76 | 78 | // Start with an empty array. |
| 77 | - if ($boardIndexOptions['include_categories']) |
|
| 78 | - $categories = array(); |
|
| 79 | - else |
|
| 80 | - $this_category = array(); |
|
| 79 | + if ($boardIndexOptions['include_categories']) { |
|
| 80 | + $categories = array(); |
|
| 81 | + } else { |
|
| 82 | + $this_category = array(); |
|
| 83 | + } |
|
| 81 | 84 | $boards = array(); |
| 82 | 85 | |
| 83 | 86 | // Run through the categories and boards (or only boards).... |
@@ -88,8 +91,9 @@ discard block |
||
| 88 | 91 | $row_board['is_read'] = !empty($row_board['is_read']) || $ignoreThisBoard ? '1' : '0'; |
| 89 | 92 | |
| 90 | 93 | // Add parent boards to the $boards list later used to fetch moderators |
| 91 | - if ($row_board['id_parent'] == $boardIndexOptions['parent_id']) |
|
| 92 | - $boards[] = $row_board['id_board']; |
|
| 94 | + if ($row_board['id_parent'] == $boardIndexOptions['parent_id']) { |
|
| 95 | + $boards[] = $row_board['id_board']; |
|
| 96 | + } |
|
| 93 | 97 | |
| 94 | 98 | if ($boardIndexOptions['include_categories']) |
| 95 | 99 | { |
@@ -111,8 +115,9 @@ discard block |
||
| 111 | 115 | } |
| 112 | 116 | |
| 113 | 117 | // If this board has new posts in it (and isn't the recycle bin!) then the category is new. |
| 114 | - if (empty($modSettings['recycle_enable']) || $modSettings['recycle_board'] != $row_board['id_board']) |
|
| 115 | - $categories[$row_board['id_cat']]['new'] |= empty($row_board['is_read']) && $row_board['poster_name'] != ''; |
|
| 118 | + if (empty($modSettings['recycle_enable']) || $modSettings['recycle_board'] != $row_board['id_board']) { |
|
| 119 | + $categories[$row_board['id_cat']]['new'] |= empty($row_board['is_read']) && $row_board['poster_name'] != ''; |
|
| 120 | + } |
|
| 116 | 121 | |
| 117 | 122 | // Avoid showing category unread link where it only has redirection boards. |
| 118 | 123 | $categories[$row_board['id_cat']]['show_unread'] = !empty($categories[$row_board['id_cat']]['show_unread']) ? 1 : !$row_board['is_redirect']; |
@@ -160,14 +165,12 @@ discard block |
||
| 160 | 165 | { |
| 161 | 166 | $this_category[$row_board['id_board']]['board_class'] = 'redirect'; |
| 162 | 167 | $this_category[$row_board['id_board']]['board_tooltip'] = $txt['redirect_board']; |
| 163 | - } |
|
| 164 | - elseif ($this_category[$row_board['id_board']]['new'] || $context['user']['is_guest']) |
|
| 168 | + } elseif ($this_category[$row_board['id_board']]['new'] || $context['user']['is_guest']) |
|
| 165 | 169 | { |
| 166 | 170 | // If we're showing to guests, we want to give them the idea that something interesting is going on! |
| 167 | 171 | $this_category[$row_board['id_board']]['board_class'] = 'on'; |
| 168 | 172 | $this_category[$row_board['id_board']]['board_tooltip'] = $txt['new_posts']; |
| 169 | - } |
|
| 170 | - else |
|
| 173 | + } else |
|
| 171 | 174 | { |
| 172 | 175 | $this_category[$row_board['id_board']]['board_tooltip'] = $txt['old_posts']; |
| 173 | 176 | } |
@@ -218,14 +221,16 @@ discard block |
||
| 218 | 221 | // Child of a child... just add it on... |
| 219 | 222 | elseif (!empty($boardIndexOptions['countChildPosts'])) |
| 220 | 223 | { |
| 221 | - if (!isset($parent_map)) |
|
| 222 | - $parent_map = array(); |
|
| 224 | + if (!isset($parent_map)) { |
|
| 225 | + $parent_map = array(); |
|
| 226 | + } |
|
| 223 | 227 | |
| 224 | - if (!isset($parent_map[$row_board['id_parent']])) |
|
| 225 | - foreach ($this_category as $id => $board) |
|
| 228 | + if (!isset($parent_map[$row_board['id_parent']])) { |
|
| 229 | + foreach ($this_category as $id => $board) |
|
| 226 | 230 | { |
| 227 | 231 | if (!isset($board['children'][$row_board['id_parent']])) |
| 228 | 232 | continue; |
| 233 | + } |
|
| 229 | 234 | |
| 230 | 235 | $parent_map[$row_board['id_parent']] = array(&$this_category[$id], &$this_category[$id]['children'][$row_board['id_parent']]); |
| 231 | 236 | $parent_map[$row_board['id_board']] = array(&$this_category[$id], &$this_category[$id]['children'][$row_board['id_parent']]); |
@@ -246,8 +251,9 @@ discard block |
||
| 246 | 251 | continue; |
| 247 | 252 | } |
| 248 | 253 | // Found a child of a child - skip. |
| 249 | - else |
|
| 250 | - continue; |
|
| 254 | + else { |
|
| 255 | + continue; |
|
| 256 | + } |
|
| 251 | 257 | |
| 252 | 258 | // Prepare the subject, and make sure it's not too long. |
| 253 | 259 | censorText($row_board['subject']); |
@@ -268,12 +274,13 @@ discard block |
||
| 268 | 274 | 'topic' => $row_board['id_topic'] |
| 269 | 275 | ); |
| 270 | 276 | |
| 271 | - if (!empty($settings['avatars_on_boardIndex'])) |
|
| 272 | - $this_last_post['member']['avatar'] = set_avatar_data(array( |
|
| 277 | + if (!empty($settings['avatars_on_boardIndex'])) { |
|
| 278 | + $this_last_post['member']['avatar'] = set_avatar_data(array( |
|
| 273 | 279 | 'avatar' => $row_board['avatar'], |
| 274 | 280 | 'email' => $row_board['email_address'], |
| 275 | 281 | 'filename' => !empty($row['member_filename']) ? $row_board['member_filename'] : '', |
| 276 | 282 | )); |
| 283 | + } |
|
| 277 | 284 | |
| 278 | 285 | // Provide the href and link. |
| 279 | 286 | if ($row_board['subject'] != '') |
@@ -285,8 +292,7 @@ discard block |
||
| 285 | 292 | link, href, subject, start (where they should go for the first unread post.), |
| 286 | 293 | and member. (which has id, name, link, href, username in it.) */ |
| 287 | 294 | $this_last_post['last_post_message'] = sprintf($txt['last_post_message'], $this_last_post['member']['link'], $this_last_post['link'], $this_last_post['time']); |
| 288 | - } |
|
| 289 | - else |
|
| 295 | + } else |
|
| 290 | 296 | { |
| 291 | 297 | $this_last_post['href'] = ''; |
| 292 | 298 | $this_last_post['link'] = $txt['not_applicable']; |
@@ -294,8 +300,9 @@ discard block |
||
| 294 | 300 | } |
| 295 | 301 | |
| 296 | 302 | // Set the last post in the parent board. |
| 297 | - if ($row_board['id_parent'] == $boardIndexOptions['parent_id'] || ($isChild && !empty($row_board['poster_time']) && $this_category[$row_board['id_parent']]['last_post']['timestamp'] < forum_time(true, $row_board['poster_time']))) |
|
| 298 | - $this_category[$isChild ? $row_board['id_parent'] : $row_board['id_board']]['last_post'] = $this_last_post; |
|
| 303 | + if ($row_board['id_parent'] == $boardIndexOptions['parent_id'] || ($isChild && !empty($row_board['poster_time']) && $this_category[$row_board['id_parent']]['last_post']['timestamp'] < forum_time(true, $row_board['poster_time']))) { |
|
| 304 | + $this_category[$isChild ? $row_board['id_parent'] : $row_board['id_board']]['last_post'] = $this_last_post; |
|
| 305 | + } |
|
| 299 | 306 | // Just in the child...? |
| 300 | 307 | if ($isChild) |
| 301 | 308 | { |
@@ -305,15 +312,17 @@ discard block |
||
| 305 | 312 | $this_category[$row_board['id_parent']]['children'][$row_board['id_board']]['new'] &= $row_board['poster_name'] != ''; |
| 306 | 313 | } |
| 307 | 314 | // No last post for this board? It's not new then, is it..? |
| 308 | - elseif ($row_board['poster_name'] == '') |
|
| 309 | - $this_category[$row_board['id_board']]['new'] = false; |
|
| 315 | + elseif ($row_board['poster_name'] == '') { |
|
| 316 | + $this_category[$row_board['id_board']]['new'] = false; |
|
| 317 | + } |
|
| 310 | 318 | |
| 311 | 319 | // Determine a global most recent topic. |
| 312 | - if (!empty($boardIndexOptions['set_latest_post']) && !empty($row_board['poster_time']) && $row_board['poster_time'] > $latest_post['timestamp'] && !$ignoreThisBoard) |
|
| 313 | - $latest_post = array( |
|
| 320 | + if (!empty($boardIndexOptions['set_latest_post']) && !empty($row_board['poster_time']) && $row_board['poster_time'] > $latest_post['timestamp'] && !$ignoreThisBoard) { |
|
| 321 | + $latest_post = array( |
|
| 314 | 322 | 'timestamp' => $row_board['poster_time'], |
| 315 | 323 | 'ref' => &$this_category[$isChild ? $row_board['id_parent'] : $row_board['id_board']]['last_post'], |
| 316 | 324 | ); |
| 325 | + } |
|
| 317 | 326 | } |
| 318 | 327 | $smcFunc['db_free_result']($result_boards); |
| 319 | 328 | |
@@ -330,8 +339,9 @@ discard block |
||
| 330 | 339 | if (!empty($moderators[$board['id']])) |
| 331 | 340 | { |
| 332 | 341 | $categories[$k]['boards'][$j]['moderators'] = $moderators[$board['id']]; |
| 333 | - foreach ($moderators[$board['id']] as $moderator) |
|
| 334 | - $categories[$k]['boards'][$j]['link_moderators'][] = $moderator['link']; |
|
| 342 | + foreach ($moderators[$board['id']] as $moderator) { |
|
| 343 | + $categories[$k]['boards'][$j]['link_moderators'][] = $moderator['link']; |
|
| 344 | + } |
|
| 335 | 345 | } |
| 336 | 346 | if (!empty($groups[$board['id']])) |
| 337 | 347 | { |
@@ -344,16 +354,16 @@ discard block |
||
| 344 | 354 | } |
| 345 | 355 | } |
| 346 | 356 | } |
| 347 | - } |
|
| 348 | - else |
|
| 357 | + } else |
|
| 349 | 358 | { |
| 350 | 359 | foreach ($this_category as $k => $board) |
| 351 | 360 | { |
| 352 | 361 | if (!empty($moderators[$board['id']])) |
| 353 | 362 | { |
| 354 | 363 | $this_category[$k]['moderators'] = $moderators[$board['id']]; |
| 355 | - foreach ($moderators[$board['id']] as $moderator) |
|
| 356 | - $this_category[$k]['link_moderators'][] = $moderator['link']; |
|
| 364 | + foreach ($moderators[$board['id']] as $moderator) { |
|
| 365 | + $this_category[$k]['link_moderators'][] = $moderator['link']; |
|
| 366 | + } |
|
| 357 | 367 | } |
| 358 | 368 | if (!empty($groups[$board['id']])) |
| 359 | 369 | { |
@@ -367,20 +377,23 @@ discard block |
||
| 367 | 377 | } |
| 368 | 378 | } |
| 369 | 379 | |
| 370 | - if ($boardIndexOptions['include_categories']) |
|
| 371 | - sortCategories($categories); |
|
| 372 | - else |
|
| 373 | - sortBoards($this_category); |
|
| 380 | + if ($boardIndexOptions['include_categories']) { |
|
| 381 | + sortCategories($categories); |
|
| 382 | + } else { |
|
| 383 | + sortBoards($this_category); |
|
| 384 | + } |
|
| 374 | 385 | |
| 375 | 386 | // By now we should know the most recent post...if we wanna know it that is. |
| 376 | - if (!empty($boardIndexOptions['set_latest_post']) && !empty($latest_post['ref'])) |
|
| 377 | - $context['latest_post'] = $latest_post['ref']; |
|
| 387 | + if (!empty($boardIndexOptions['set_latest_post']) && !empty($latest_post['ref'])) { |
|
| 388 | + $context['latest_post'] = $latest_post['ref']; |
|
| 389 | + } |
|
| 378 | 390 | |
| 379 | 391 | // I can't remember why but trying to make a ternary to get this all in one line is actually a Very Bad Idea. |
| 380 | - if ($boardIndexOptions['include_categories']) |
|
| 381 | - call_integration_hook('integrate_getboardtree', array($boardIndexOptions, &$categories)); |
|
| 382 | - else |
|
| 383 | - call_integration_hook('integrate_getboardtree', array($boardIndexOptions, &$this_category)); |
|
| 392 | + if ($boardIndexOptions['include_categories']) { |
|
| 393 | + call_integration_hook('integrate_getboardtree', array($boardIndexOptions, &$categories)); |
|
| 394 | + } else { |
|
| 395 | + call_integration_hook('integrate_getboardtree', array($boardIndexOptions, &$this_category)); |
|
| 396 | + } |
|
| 384 | 397 | |
| 385 | 398 | return $boardIndexOptions['include_categories'] ? $categories : $this_category; |
| 386 | 399 | } |
@@ -19,10 +19,10 @@ |
||
| 19 | 19 | */ |
| 20 | 20 | class GroupAct_Notify_Background extends SMF_BackgroundTask |
| 21 | 21 | { |
| 22 | - /** |
|
| 23 | - * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed. |
|
| 24 | - * @return bool Always returns true |
|
| 25 | - */ |
|
| 22 | + /** |
|
| 23 | + * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed. |
|
| 24 | + * @return bool Always returns true |
|
| 25 | + */ |
|
| 26 | 26 | public function execute() |
| 27 | 27 | { |
| 28 | 28 | global $sourcedir, $smcFunc, $language, $modSettings; |
@@ -132,8 +132,9 @@ discard block |
||
| 132 | 132 | 'GROUPNAME' => $user['group_name'], |
| 133 | 133 | ); |
| 134 | 134 | |
| 135 | - if (!empty($custom_reason)) |
|
| 136 | - $replacements['REASON'] = $custom_reason; |
|
| 135 | + if (!empty($custom_reason)) { |
|
| 136 | + $replacements['REASON'] = $custom_reason; |
|
| 137 | + } |
|
| 137 | 138 | |
| 138 | 139 | $emaildata = loadEmailTemplate($email_template_name, $replacements, $user['language']); |
| 139 | 140 | |
@@ -142,8 +143,8 @@ discard block |
||
| 142 | 143 | } |
| 143 | 144 | |
| 144 | 145 | // Insert the alerts if any |
| 145 | - if (!empty($alert_rows)) |
|
| 146 | - $smcFunc['db_insert']('', |
|
| 146 | + if (!empty($alert_rows)) { |
|
| 147 | + $smcFunc['db_insert']('', |
|
| 147 | 148 | '{db_prefix}user_alerts', |
| 148 | 149 | array( |
| 149 | 150 | 'alert_time' => 'int', 'id_member' => 'int', 'content_type' => 'string', |
@@ -152,6 +153,7 @@ discard block |
||
| 152 | 153 | $alert_rows, |
| 153 | 154 | array() |
| 154 | 155 | ); |
| 156 | + } |
|
| 155 | 157 | } |
| 156 | 158 | |
| 157 | 159 | return true; |
@@ -40,8 +40,9 @@ discard block |
||
| 40 | 40 | 'last_comment' => $this->_details['comment_id'], |
| 41 | 41 | ) |
| 42 | 42 | ); |
| 43 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 44 | - $possible_members[] = $row[0]; |
|
| 43 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 44 | + $possible_members[] = $row[0]; |
|
| 45 | + } |
|
| 45 | 46 | $smcFunc['db_free_result']($request); |
| 46 | 47 | |
| 47 | 48 | // Presumably, there are some people? |
@@ -50,8 +51,9 @@ discard block |
||
| 50 | 51 | $possible_members = array_flip(array_flip($possible_members)); |
| 51 | 52 | $possible_members = array_diff($possible_members, array($this->_details['sender_id'])); |
| 52 | 53 | } |
| 53 | - if (empty($possible_members)) |
|
| 54 | - return true; |
|
| 54 | + if (empty($possible_members)) { |
|
| 55 | + return true; |
|
| 56 | + } |
|
| 55 | 57 | |
| 56 | 58 | // We need to know who can moderate this board - and therefore who can see this report. |
| 57 | 59 | // First up, people who have moderate_board in the board this topic was in. |
@@ -67,8 +69,9 @@ discard block |
||
| 67 | 69 | 'current_board' => $this->_details['board_id'], |
| 68 | 70 | ) |
| 69 | 71 | ); |
| 70 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 71 | - $members[] = $row['id_member']; |
|
| 72 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 73 | + $members[] = $row['id_member']; |
|
| 74 | + } |
|
| 72 | 75 | $smcFunc['db_free_result']($request); |
| 73 | 76 | |
| 74 | 77 | // Thirdly, anyone assigned to be a moderator of this group as a group->board moderator. |
@@ -85,8 +88,9 @@ discard block |
||
| 85 | 88 | ) |
| 86 | 89 | ); |
| 87 | 90 | |
| 88 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 89 | - $members[] = $row['id_member']; |
|
| 91 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 92 | + $members[] = $row['id_member']; |
|
| 93 | + } |
|
| 90 | 94 | $smcFunc['db_free_result']($request); |
| 91 | 95 | |
| 92 | 96 | // So now we have two lists: the people who replied to a report in the past, |
@@ -108,8 +112,9 @@ discard block |
||
| 108 | 112 | { |
| 109 | 113 | foreach ($alert_bits as $type => $bitvalue) |
| 110 | 114 | { |
| 111 | - if ($pref_option['msg_report_reply'] & $bitvalue) |
|
| 112 | - $notifies[$type][] = $member; |
|
| 115 | + if ($pref_option['msg_report_reply'] & $bitvalue) { |
|
| 116 | + $notifies[$type][] = $member; |
|
| 117 | + } |
|
| 113 | 118 | } |
| 114 | 119 | } |
| 115 | 120 | |
@@ -170,8 +175,9 @@ discard block |
||
| 170 | 175 | ); |
| 171 | 176 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 172 | 177 | { |
| 173 | - if (empty($row['lngfile'])) |
|
| 174 | - $row['lngfile'] = $language; |
|
| 178 | + if (empty($row['lngfile'])) { |
|
| 179 | + $row['lngfile'] = $language; |
|
| 180 | + } |
|
| 175 | 181 | $emails[$row['lngfile']][$row['id_member']] = $row['email_address']; |
| 176 | 182 | } |
| 177 | 183 | $smcFunc['db_free_result']($request); |
@@ -203,8 +209,9 @@ discard block |
||
| 203 | 209 | $emaildata = loadEmailTemplate('reply_to_moderator', $replacements, empty($modSettings['userLanguage']) ? $language : $this_lang); |
| 204 | 210 | |
| 205 | 211 | // And do the actual sending... |
| 206 | - foreach ($recipients as $id_member => $email_address) |
|
| 207 | - sendmail($email_address, $emaildata['subject'], $emaildata['body'], null, 'rptrpy' . $this->_details['comment_id'], $emaildata['is_html'], 3); |
|
| 212 | + foreach ($recipients as $id_member => $email_address) { |
|
| 213 | + sendmail($email_address, $emaildata['subject'], $emaildata['body'], null, 'rptrpy' . $this->_details['comment_id'], $emaildata['is_html'], 3); |
|
| 214 | + } |
|
| 208 | 215 | } |
| 209 | 216 | } |
| 210 | 217 | |
@@ -19,7 +19,7 @@ |
||
| 19 | 19 | class Likes_Notify_Background extends SMF_BackgroundTask |
| 20 | 20 | { |
| 21 | 21 | /** |
| 22 | - * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed. |
|
| 22 | + * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed. |
|
| 23 | 23 | * @return bool Always returns true |
| 24 | 24 | */ |
| 25 | 25 | public function execute() |
@@ -19,7 +19,7 @@ |
||
| 19 | 19 | class Buddy_Notify_Background extends SMF_BackgroundTask |
| 20 | 20 | { |
| 21 | 21 | /** |
| 22 | - * This executes the task - loads up the info, sets the alerts and loads up the email queue. |
|
| 22 | + * This executes the task - loads up the info, sets the alerts and loads up the email queue. |
|
| 23 | 23 | * @return bool Always returns true |
| 24 | 24 | */ |
| 25 | 25 | public function execute() |
@@ -18,10 +18,10 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | class Birthday_Notify_Background extends SMF_BackgroundTask |
| 20 | 20 | { |
| 21 | - /** |
|
| 22 | - * This executes the task. It loads up the birthdays, figures out the greeting, etc. |
|
| 23 | - * @return bool Always returns true |
|
| 24 | - */ |
|
| 21 | + /** |
|
| 22 | + * This executes the task. It loads up the birthdays, figures out the greeting, etc. |
|
| 23 | + * @return bool Always returns true |
|
| 24 | + */ |
|
| 25 | 25 | public function execute() |
| 26 | 26 | { |
| 27 | 27 | global $txt, $smcFunc, $txtBirthdayEmails, $language, $modSettings, $sourcedir; |
@@ -51,8 +51,9 @@ discard block |
||
| 51 | 51 | $birthdays = array(); |
| 52 | 52 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 53 | 53 | { |
| 54 | - if (!isset($birthdays[$row['lngfile']])) |
|
| 55 | - $birthdays[$row['lngfile']] = array(); |
|
| 54 | + if (!isset($birthdays[$row['lngfile']])) { |
|
| 55 | + $birthdays[$row['lngfile']] = array(); |
|
| 56 | + } |
|
| 56 | 57 | $birthdays[$row['lngfile']][$row['id_member']] = array( |
| 57 | 58 | 'name' => $row['real_name'], |
| 58 | 59 | 'email' => $row['email_address'] |
@@ -117,8 +118,8 @@ discard block |
||
| 117 | 118 | AddMailQueue(true); |
| 118 | 119 | |
| 119 | 120 | // Insert the alerts if any |
| 120 | - if (!empty($alert_rows)) |
|
| 121 | - $smcFunc['db_insert']('', |
|
| 121 | + if (!empty($alert_rows)) { |
|
| 122 | + $smcFunc['db_insert']('', |
|
| 122 | 123 | '{db_prefix}user_alerts', |
| 123 | 124 | array( |
| 124 | 125 | 'alert_time' => 'int', 'id_member' => 'int', 'content_type' => 'string', |
@@ -127,6 +128,7 @@ discard block |
||
| 127 | 128 | $alert_rows, |
| 128 | 129 | array() |
| 129 | 130 | ); |
| 131 | + } |
|
| 130 | 132 | } |
| 131 | 133 | |
| 132 | 134 | return true; |
@@ -46,9 +46,10 @@ discard block |
||
| 46 | 46 | |
| 47 | 47 | foreach ($prefs as $member => $pref_option) |
| 48 | 48 | { |
| 49 | - foreach ($alert_bits as $type => $bitvalue) |
|
| 50 | - if ($pref_option['member_report'] & $bitvalue) |
|
| 49 | + foreach ($alert_bits as $type => $bitvalue) { |
|
| 50 | + if ($pref_option['member_report'] & $bitvalue) |
|
| 51 | 51 | $notifies[$type][] = $member; |
| 52 | + } |
|
| 52 | 53 | } |
| 53 | 54 | |
| 54 | 55 | // Firstly, anyone who wants alerts. |
@@ -109,8 +110,9 @@ discard block |
||
| 109 | 110 | ); |
| 110 | 111 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 111 | 112 | { |
| 112 | - if (empty($row['lngfile'])) |
|
| 113 | - $row['lngfile'] = $language; |
|
| 113 | + if (empty($row['lngfile'])) { |
|
| 114 | + $row['lngfile'] = $language; |
|
| 115 | + } |
|
| 114 | 116 | $emails[$row['lngfile']][$row['id_member']] = $row['email_address']; |
| 115 | 117 | } |
| 116 | 118 | $smcFunc['db_free_result']($request); |
@@ -129,8 +131,9 @@ discard block |
||
| 129 | 131 | $emaildata = loadEmailTemplate('report_member_profile', $replacements, empty($modSettings['userLanguage']) ? $language : $this_lang); |
| 130 | 132 | |
| 131 | 133 | // And do the actual sending... |
| 132 | - foreach ($recipients as $id_member => $email_address) |
|
| 133 | - sendmail($email_address, $emaildata['subject'], $emaildata['body'], null, 'ureport' . $this->_details['report_id'], $emaildata['is_html'], 2); |
|
| 134 | + foreach ($recipients as $id_member => $email_address) { |
|
| 135 | + sendmail($email_address, $emaildata['subject'], $emaildata['body'], null, 'ureport' . $this->_details['report_id'], $emaildata['is_html'], 2); |
|
| 136 | + } |
|
| 134 | 137 | } |
| 135 | 138 | } |
| 136 | 139 | |
@@ -19,7 +19,7 @@ |
||
| 19 | 19 | class Likes_Notify_Background extends SMF_BackgroundTask |
| 20 | 20 | { |
| 21 | 21 | /** |
| 22 | - * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed. |
|
| 22 | + * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed. |
|
| 23 | 23 | * @return bool Always returns true |
| 24 | 24 | */ |
| 25 | 25 | public function execute() |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | class CreatePost_Notify_Background extends SMF_BackgroundTask |
| 19 | 19 | { |
| 20 | 20 | /** |
| 21 | - * This handles notifications when a new post is created - new topic, reply, quotes and mentions. |
|
| 21 | + * This handles notifications when a new post is created - new topic, reply, quotes and mentions. |
|
| 22 | 22 | * @return bool Always returns true |
| 23 | 23 | */ |
| 24 | 24 | public function execute() |
@@ -72,8 +72,9 @@ discard block |
||
| 72 | 72 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 73 | 73 | { |
| 74 | 74 | $groups = array_merge(array($row['id_group'], $row['id_post_group']), (empty($row['additional_groups']) ? array() : explode(',', $row['additional_groups']))); |
| 75 | - if (!in_array(1, $groups) && count(array_intersect($groups, explode(',', $row['member_groups']))) == 0) |
|
| 76 | - continue; |
|
| 75 | + if (!in_array(1, $groups) && count(array_intersect($groups, explode(',', $row['member_groups']))) == 0) { |
|
| 76 | + continue; |
|
| 77 | + } |
|
| 77 | 78 | |
| 78 | 79 | $members[] = $row['id_member']; |
| 79 | 80 | $watched[$row['id_member']] = $row; |
@@ -81,8 +82,9 @@ discard block |
||
| 81 | 82 | |
| 82 | 83 | $smcFunc['db_free_result']($request); |
| 83 | 84 | |
| 84 | - if (empty($members)) |
|
| 85 | - return true; |
|
| 85 | + if (empty($members)) { |
|
| 86 | + return true; |
|
| 87 | + } |
|
| 86 | 88 | |
| 87 | 89 | $members = array_unique($members); |
| 88 | 90 | $prefs = getNotifyPrefs($members, '', true); |
@@ -103,18 +105,20 @@ discard block |
||
| 103 | 105 | $frequency = !empty($prefs[$member]['msg_notify_pref']) ? $prefs[$member]['msg_notify_pref'] : 1; |
| 104 | 106 | $notify_types = !empty($prefs[$member]['msg_notify_type']) ? $prefs[$member]['msg_notify_type'] : 1; |
| 105 | 107 | |
| 106 | - if (!in_array($type, array('reply', 'topic')) && $notify_types == 2 && $member != $data['id_member_started']) |
|
| 107 | - continue; |
|
| 108 | - elseif (in_array($type, array('reply', 'topic')) && $member == $posterOptions['id']) |
|
| 109 | - continue; |
|
| 110 | - elseif (!in_array($type, array('reply', 'topic')) && $notify_types == 3) |
|
| 111 | - continue; |
|
| 112 | - elseif ($notify_types == 4) |
|
| 113 | - continue; |
|
| 108 | + if (!in_array($type, array('reply', 'topic')) && $notify_types == 2 && $member != $data['id_member_started']) { |
|
| 109 | + continue; |
|
| 110 | + } elseif (in_array($type, array('reply', 'topic')) && $member == $posterOptions['id']) { |
|
| 111 | + continue; |
|
| 112 | + } elseif (!in_array($type, array('reply', 'topic')) && $notify_types == 3) { |
|
| 113 | + continue; |
|
| 114 | + } elseif ($notify_types == 4) { |
|
| 115 | + continue; |
|
| 116 | + } |
|
| 114 | 117 | |
| 115 | 118 | if ($frequency > 2 || (!empty($frequency) && $data['sent']) || in_array($member, $done_members) |
| 116 | - || (!empty($this->_details['members_only']) && !in_array($member, $this->_details['members_only']))) |
|
| 117 | - continue; |
|
| 119 | + || (!empty($this->_details['members_only']) && !in_array($member, $this->_details['members_only']))) { |
|
| 120 | + continue; |
|
| 121 | + } |
|
| 118 | 122 | |
| 119 | 123 | // Watched topic? |
| 120 | 124 | if (!empty($data['id_topic']) && $type != 'topic' && !empty($prefs[$member])) |
@@ -124,10 +128,12 @@ discard block |
||
| 124 | 128 | |
| 125 | 129 | if ($type == 'reply') |
| 126 | 130 | { |
| 127 | - if (!empty($prefs[$member]['msg_receive_body'])) |
|
| 128 | - $message_type .= '_body'; |
|
| 129 | - if (!empty($frequency)) |
|
| 130 | - $message_type .= '_once'; |
|
| 131 | + if (!empty($prefs[$member]['msg_receive_body'])) { |
|
| 132 | + $message_type .= '_body'; |
|
| 133 | + } |
|
| 134 | + if (!empty($frequency)) { |
|
| 135 | + $message_type .= '_once'; |
|
| 136 | + } |
|
| 131 | 137 | } |
| 132 | 138 | |
| 133 | 139 | $content_type = 'topic'; |
@@ -140,12 +146,14 @@ discard block |
||
| 140 | 146 | $content_type = 'board'; |
| 141 | 147 | |
| 142 | 148 | $message_type = !empty($frequency) ? 'notify_boards_once' : 'notify_boards'; |
| 143 | - if (!empty($prefs[$member]['msg_receive_body'])) |
|
| 144 | - $message_type .= '_body'; |
|
| 149 | + if (!empty($prefs[$member]['msg_receive_body'])) { |
|
| 150 | + $message_type .= '_body'; |
|
| 151 | + } |
|
| 145 | 152 | } |
| 146 | 153 | // If neither of the above, this might be a redundent row due to the OR clause in our SQL query, skip |
| 147 | - else |
|
| 148 | - continue; |
|
| 154 | + else { |
|
| 155 | + continue; |
|
| 156 | + } |
|
| 149 | 157 | |
| 150 | 158 | if ($pref & 0x02) |
| 151 | 159 | { |
@@ -208,14 +216,15 @@ discard block |
||
| 208 | 216 | ); |
| 209 | 217 | |
| 210 | 218 | // Insert the alerts if any |
| 211 | - if (!empty($alert_rows)) |
|
| 212 | - $smcFunc['db_insert']('', |
|
| 219 | + if (!empty($alert_rows)) { |
|
| 220 | + $smcFunc['db_insert']('', |
|
| 213 | 221 | '{db_prefix}user_alerts', |
| 214 | 222 | array('alert_time' => 'int', 'id_member' => 'int', 'id_member_started' => 'int', 'member_name' => 'string', |
| 215 | 223 | 'content_type' => 'string', 'content_id' => 'int', 'content_action' => 'string', 'is_read' => 'int', 'extra' => 'string'), |
| 216 | 224 | $alert_rows, |
| 217 | 225 | array() |
| 218 | 226 | ); |
| 227 | + } |
|
| 219 | 228 | |
| 220 | 229 | return true; |
| 221 | 230 | } |
@@ -226,8 +235,9 @@ discard block |
||
| 226 | 235 | |
| 227 | 236 | foreach ($quotedMembers as $id => $member) |
| 228 | 237 | { |
| 229 | - if (!isset($prefs[$id]) || $id == $posterOptions['id'] || empty($prefs[$id]['msg_quote'])) |
|
| 230 | - continue; |
|
| 238 | + if (!isset($prefs[$id]) || $id == $posterOptions['id'] || empty($prefs[$id]['msg_quote'])) { |
|
| 239 | + continue; |
|
| 240 | + } |
|
| 231 | 241 | |
| 232 | 242 | $done_members[] = $id; |
| 233 | 243 | |
@@ -279,32 +289,35 @@ discard block |
||
| 279 | 289 | { |
| 280 | 290 | if (preg_match('/\[quote(.*)?\]/i', $block, $matches)) |
| 281 | 291 | { |
| 282 | - if ($quote_level == 0) |
|
| 283 | - $message .= '[quote' . $matches[1] . ']'; |
|
| 292 | + if ($quote_level == 0) { |
|
| 293 | + $message .= '[quote' . $matches[1] . ']'; |
|
| 294 | + } |
|
| 284 | 295 | $quote_level++; |
| 285 | - } |
|
| 286 | - elseif (preg_match('/\[\/quote\]/i', $block)) |
|
| 296 | + } elseif (preg_match('/\[\/quote\]/i', $block)) |
|
| 287 | 297 | { |
| 288 | - if ($quote_level <= 1) |
|
| 289 | - $message .= '[/quote]'; |
|
| 298 | + if ($quote_level <= 1) { |
|
| 299 | + $message .= '[/quote]'; |
|
| 300 | + } |
|
| 290 | 301 | if ($quote_level >= 1) |
| 291 | 302 | { |
| 292 | 303 | $quote_level--; |
| 293 | 304 | $message .= "\n"; |
| 294 | 305 | } |
| 306 | + } elseif ($quote_level <= 1) { |
|
| 307 | + $message .= $block; |
|
| 295 | 308 | } |
| 296 | - elseif ($quote_level <= 1) |
|
| 297 | - $message .= $block; |
|
| 298 | 309 | } |
| 299 | 310 | |
| 300 | 311 | preg_match_all('/\[quote.*?link=msg=([0-9]+).*?\]/i', $message, $matches); |
| 301 | 312 | |
| 302 | 313 | $id_msgs = $matches[1]; |
| 303 | - foreach ($id_msgs as $k => $id_msg) |
|
| 304 | - $id_msgs[$k] = (int) $id_msg; |
|
| 314 | + foreach ($id_msgs as $k => $id_msg) { |
|
| 315 | + $id_msgs[$k] = (int) $id_msg; |
|
| 316 | + } |
|
| 305 | 317 | |
| 306 | - if (empty($id_msgs)) |
|
| 307 | - return array(); |
|
| 318 | + if (empty($id_msgs)) { |
|
| 319 | + return array(); |
|
| 320 | + } |
|
| 308 | 321 | |
| 309 | 322 | // Get the messages |
| 310 | 323 | $request = $smcFunc['db_query']('', ' |
@@ -322,8 +335,9 @@ discard block |
||
| 322 | 335 | $members = array(); |
| 323 | 336 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 324 | 337 | { |
| 325 | - if ($posterOptions['id'] == $row['id_member']) |
|
| 326 | - continue; |
|
| 338 | + if ($posterOptions['id'] == $row['id_member']) { |
|
| 339 | + continue; |
|
| 340 | + } |
|
| 327 | 341 | |
| 328 | 342 | $members[$row['id_member']] = $row; |
| 329 | 343 | } |
@@ -337,10 +351,11 @@ discard block |
||
| 337 | 351 | |
| 338 | 352 | foreach ($members as $id => $member) |
| 339 | 353 | { |
| 340 | - if (!empty($prefs[$id]['msg_mention'])) |
|
| 341 | - $done_members[] = $id; |
|
| 342 | - else |
|
| 343 | - continue; |
|
| 354 | + if (!empty($prefs[$id]['msg_mention'])) { |
|
| 355 | + $done_members[] = $id; |
|
| 356 | + } else { |
|
| 357 | + continue; |
|
| 358 | + } |
|
| 344 | 359 | |
| 345 | 360 | // Alerts' emails are always instant |
| 346 | 361 | if ($prefs[$id]['msg_mention'] & 0x02) |