@@ -37,9 +37,10 @@ discard block |
||
| 37 | 37 | echo ' |
| 38 | 38 | <optgroup label="', $category['name'], '">'; |
| 39 | 39 | |
| 40 | - foreach ($category['boards'] as $board) |
|
| 41 | - echo ' |
|
| 40 | + foreach ($category['boards'] as $board) { |
|
| 41 | + echo ' |
|
| 42 | 42 | <option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', $board['id'] == $context['current_board'] ? ' disabled' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level']-1) . '=> ' : '', $board['name'], '</option>'; |
| 43 | + } |
|
| 43 | 44 | echo ' |
| 44 | 45 | </optgroup>'; |
| 45 | 46 | } |
@@ -70,9 +71,10 @@ discard block |
||
| 70 | 71 | </div><!-- .move_topic --> |
| 71 | 72 | </div><!-- .windowbg -->'; |
| 72 | 73 | |
| 73 | - if ($context['back_to_topic']) |
|
| 74 | - echo ' |
|
| 74 | + if ($context['back_to_topic']) { |
|
| 75 | + echo ' |
|
| 75 | 76 | <input type="hidden" name="goback" value="1">'; |
| 77 | + } |
|
| 76 | 78 | |
| 77 | 79 | echo ' |
| 78 | 80 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -125,10 +127,10 @@ discard block |
||
| 125 | 127 | <option value="86400">', $txt['two_months'], '</option> |
| 126 | 128 | </select> |
| 127 | 129 | </dd>'; |
| 128 | - } |
|
| 129 | - else |
|
| 130 | - echo ' |
|
| 130 | + } else { |
|
| 131 | + echo ' |
|
| 131 | 132 | <input type="hidden" name="redirect_expires" value="0">'; |
| 133 | + } |
|
| 132 | 134 | |
| 133 | 135 | echo ' |
| 134 | 136 | </dl> |
@@ -207,9 +209,10 @@ discard block |
||
| 207 | 209 | echo ' |
| 208 | 210 | <optgroup label="', $cat['name'], '">'; |
| 209 | 211 | |
| 210 | - foreach ($cat['boards'] as $board) |
|
| 211 | - echo ' |
|
| 212 | + foreach ($cat['boards'] as $board) { |
|
| 213 | + echo ' |
|
| 212 | 214 | <option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level'] - 1) . '=>' : '', ' ', $board['name'], '</option>'; |
| 215 | + } |
|
| 213 | 216 | |
| 214 | 217 | echo ' |
| 215 | 218 | </optgroup>'; |
@@ -220,9 +223,9 @@ discard block |
||
| 220 | 223 | <input type="submit" value="', $txt['go'], '" class="button"> |
| 221 | 224 | </form>'; |
| 222 | 225 | |
| 226 | + } else { |
|
| 227 | + echo $txt['target_below']; |
|
| 223 | 228 | } |
| 224 | - else |
|
| 225 | - echo $txt['target_below']; |
|
| 226 | 229 | |
| 227 | 230 | echo ' </h4> |
| 228 | 231 | </div><!-- .title_bar -->'; |
@@ -240,12 +243,13 @@ discard block |
||
| 240 | 243 | |
| 241 | 244 | $merge_button = create_button('merge', 'merge', ''); |
| 242 | 245 | |
| 243 | - foreach ($context['topics'] as $topic) |
|
| 244 | - echo ' |
|
| 246 | + foreach ($context['topics'] as $topic) { |
|
| 247 | + echo ' |
|
| 245 | 248 | <li> |
| 246 | 249 | <a href="', $scripturl, '?action=mergetopics;sa=options;board=', $context['current_board'], '.0;from=', $context['origin_topic'], ';to=', $topic['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $merge_button, '</a> |
| 247 | 250 | <a href="', $scripturl, '?topic=', $topic['id'], '.0" target="_blank">', $topic['subject'], '</a> ', $txt['started_by'], ' ', $topic['poster']['link'], ' |
| 248 | 251 | </li>'; |
| 252 | + } |
|
| 249 | 253 | |
| 250 | 254 | echo ' |
| 251 | 255 | </ul> |
@@ -256,9 +260,10 @@ discard block |
||
| 256 | 260 | </div>'; |
| 257 | 261 | } |
| 258 | 262 | // Just a nice "There aren't any topics" message |
| 259 | - else |
|
| 260 | - echo ' |
|
| 263 | + else { |
|
| 264 | + echo ' |
|
| 261 | 265 | <div class="windowbg2">', $txt['topic_alert_none'], '</div>'; |
| 266 | + } |
|
| 262 | 267 | |
| 263 | 268 | echo ' |
| 264 | 269 | <br> |
@@ -308,8 +313,8 @@ discard block |
||
| 308 | 313 | </thead> |
| 309 | 314 | <tbody>'; |
| 310 | 315 | |
| 311 | - foreach ($context['topics'] as $topic) |
|
| 312 | - echo ' |
|
| 316 | + foreach ($context['topics'] as $topic) { |
|
| 317 | + echo ' |
|
| 313 | 318 | <tr class="windowbg"> |
| 314 | 319 | <td> |
| 315 | 320 | <input type="checkbox" name="topics[]" value="' . $topic['id'] . '" checked> |
@@ -329,6 +334,7 @@ discard block |
||
| 329 | 334 | <input type="checkbox" name="notifications[]" value="' . $topic['id'] . '" checked> |
| 330 | 335 | </td> |
| 331 | 336 | </tr>'; |
| 337 | + } |
|
| 332 | 338 | echo ' |
| 333 | 339 | </tbody> |
| 334 | 340 | </table> |
@@ -338,9 +344,10 @@ discard block |
||
| 338 | 344 | <legend>', $txt['merge_select_subject'], '</legend> |
| 339 | 345 | <select name="subject" onchange="this.form.custom_subject.style.display = (this.options[this.selectedIndex].value != 0) ? \'none\': \'\' ;">'; |
| 340 | 346 | |
| 341 | - foreach ($context['topics'] as $topic) |
|
| 342 | - echo ' |
|
| 347 | + foreach ($context['topics'] as $topic) { |
|
| 348 | + echo ' |
|
| 343 | 349 | <option value="', $topic['id'], '"' . ($topic['selected'] ? ' selected' : '') . '>', $topic['subject'], '</option>'; |
| 350 | + } |
|
| 344 | 351 | echo ' |
| 345 | 352 | <option value="0">', $txt['merge_custom_subject'], ':</option> |
| 346 | 353 | </select> |
@@ -359,11 +366,12 @@ discard block |
||
| 359 | 366 | <legend>', $txt['merge_select_target_board'], '</legend> |
| 360 | 367 | <ul>'; |
| 361 | 368 | |
| 362 | - foreach ($context['boards'] as $board) |
|
| 363 | - echo ' |
|
| 369 | + foreach ($context['boards'] as $board) { |
|
| 370 | + echo ' |
|
| 364 | 371 | <li> |
| 365 | 372 | <input type="radio" name="board" value="' . $board['id'] . '"' . ($board['selected'] ? ' checked' : '') . '> ' . $board['name'] . ' |
| 366 | 373 | </li>'; |
| 374 | + } |
|
| 367 | 375 | echo ' |
| 368 | 376 | </ul> |
| 369 | 377 | </fieldset>'; |
@@ -375,11 +383,12 @@ discard block |
||
| 375 | 383 | <legend>' . $txt['merge_select_poll'] . '</legend> |
| 376 | 384 | <ul>'; |
| 377 | 385 | |
| 378 | - foreach ($context['polls'] as $poll) |
|
| 379 | - echo ' |
|
| 386 | + foreach ($context['polls'] as $poll) { |
|
| 387 | + echo ' |
|
| 380 | 388 | <li> |
| 381 | 389 | <input type="radio" name="poll" value="' . $poll['id'] . '"' . ($poll['selected'] ? ' checked' : '') . '> ' . $poll['question'] . ' (' . $txt['topic'] . ': <a href="' . $scripturl . '?topic=' . $poll['topic']['id'] . '.0" target="_blank">' . $poll['topic']['subject'] . '</a>) |
| 382 | 390 | </li>'; |
| 391 | + } |
|
| 383 | 392 | echo ' |
| 384 | 393 | <li> |
| 385 | 394 | <input type="radio" name="poll" value="-1"> (' . $txt['merge_no_poll'] . ') |
@@ -25,15 +25,17 @@ discard block |
||
| 25 | 25 | </h3> |
| 26 | 26 | </div>'; |
| 27 | 27 | |
| 28 | - if (!empty($context['search_errors'])) |
|
| 29 | - echo ' |
|
| 28 | + if (!empty($context['search_errors'])) { |
|
| 29 | + echo ' |
|
| 30 | 30 | <div class="errorbox">', implode('<br>', $context['search_errors']['messages']), '</div>'; |
| 31 | + } |
|
| 31 | 32 | |
| 32 | - if (!empty($context['search_ignored'])) |
|
| 33 | - echo ' |
|
| 33 | + if (!empty($context['search_ignored'])) { |
|
| 34 | + echo ' |
|
| 34 | 35 | <p class="noticebox"> |
| 35 | 36 | ', $txt['search_warning_ignored_word' . (count($context['search_ignored']) == 1 ? '' : 's')], ': ', implode(', ', $context['search_ignored']), ' |
| 36 | 37 | </p>'; |
| 38 | + } |
|
| 37 | 39 | |
| 38 | 40 | echo ' |
| 39 | 41 | <div id="advanced_search" class="roundframe"> |
@@ -44,9 +46,10 @@ discard block |
||
| 44 | 46 | <dd> |
| 45 | 47 | <input type="search" name="search" id="searchfor" ', !empty($context['search_params']['search']) ? ' value="' . $context['search_params']['search'] . '"' : '', ' maxlength="', $context['search_string_limit'], '" size="40">'; |
| 46 | 48 | |
| 47 | - if (empty($modSettings['search_simple_fulltext'])) |
|
| 48 | - echo ' |
|
| 49 | + if (empty($modSettings['search_simple_fulltext'])) { |
|
| 50 | + echo ' |
|
| 49 | 51 | <br><em class="smalltext">', $txt['search_example'], '</em>'; |
| 52 | + } |
|
| 50 | 53 | |
| 51 | 54 | echo ' |
| 52 | 55 | </dd> |
@@ -110,21 +113,23 @@ discard block |
||
| 110 | 113 | <input type="hidden" name="advanced" value="1">'; |
| 111 | 114 | |
| 112 | 115 | // Require an image to be typed to save spamming? |
| 113 | - if ($context['require_verification']) |
|
| 114 | - echo ' |
|
| 116 | + if ($context['require_verification']) { |
|
| 117 | + echo ' |
|
| 115 | 118 | <p> |
| 116 | 119 | <strong>', $txt['verification'], ':</strong> |
| 117 | 120 | ', template_control_verification($context['visual_verification_id'], 'all'), ' |
| 118 | 121 | </p>'; |
| 122 | + } |
|
| 119 | 123 | |
| 120 | 124 | // If $context['search_params']['topic'] is set, that means we're searching just one topic. |
| 121 | - if (!empty($context['search_params']['topic'])) |
|
| 122 | - echo ' |
|
| 125 | + if (!empty($context['search_params']['topic'])) { |
|
| 126 | + echo ' |
|
| 123 | 127 | <p> |
| 124 | 128 | ', $txt['search_specific_topic'], ' "', $context['search_topic']['link'], '". |
| 125 | 129 | </p> |
| 126 | 130 | <input type="hidden" name="topic" value="', $context['search_topic']['id'], '"> |
| 127 | 131 | <input type="submit" name="b_search" value="', $txt['search'], '" class="button">'; |
| 132 | + } |
|
| 128 | 133 | |
| 129 | 134 | echo ' |
| 130 | 135 | </div>'; |
@@ -154,14 +159,15 @@ discard block |
||
| 154 | 159 | |
| 155 | 160 | foreach ($category['boards'] as $board) |
| 156 | 161 | { |
| 157 | - if ($i == $limit) |
|
| 158 | - echo ' |
|
| 162 | + if ($i == $limit) { |
|
| 163 | + echo ' |
|
| 159 | 164 | </ul> |
| 160 | 165 | </li> |
| 161 | 166 | </ul> |
| 162 | 167 | <ul class="ignoreboards floatright"> |
| 163 | 168 | <li class="category"> |
| 164 | 169 | <ul>'; |
| 170 | + } |
|
| 165 | 171 | |
| 166 | 172 | echo ' |
| 167 | 173 | <li class="board"> |
@@ -249,17 +255,19 @@ discard block |
||
| 249 | 255 | <div class="roundframe">'; |
| 250 | 256 | |
| 251 | 257 | // Did they make any typos or mistakes, perhaps? |
| 252 | - if (isset($context['did_you_mean'])) |
|
| 253 | - echo ' |
|
| 258 | + if (isset($context['did_you_mean'])) { |
|
| 259 | + echo ' |
|
| 254 | 260 | <p> |
| 255 | 261 | ', $txt['search_did_you_mean'], ' <a href="', $scripturl, '?action=search2;params=', $context['did_you_mean_params'], '">', $context['did_you_mean'], '</a>. |
| 256 | 262 | </p>'; |
| 263 | + } |
|
| 257 | 264 | |
| 258 | - if (!empty($context['search_ignored'])) |
|
| 259 | - echo ' |
|
| 265 | + if (!empty($context['search_ignored'])) { |
|
| 266 | + echo ' |
|
| 260 | 267 | <p> |
| 261 | 268 | ', $txt['search_warning_ignored_word' . (count($context['search_ignored']) == 1 ? '' : 's')], ': ', implode(', ', $context['search_ignored']), ' |
| 262 | 269 | </p>'; |
| 270 | + } |
|
| 263 | 271 | |
| 264 | 272 | echo ' |
| 265 | 273 | <form action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '"> |
@@ -282,10 +290,11 @@ discard block |
||
| 282 | 290 | <input type="hidden" name="sort" value="', !empty($context['search_params']['sort']) ? $context['search_params']['sort'] : 'relevance', '"> |
| 283 | 291 | </div>'; |
| 284 | 292 | |
| 285 | - if (!empty($context['search_params']['brd'])) |
|
| 286 | - foreach ($context['search_params']['brd'] as $board_id) |
|
| 293 | + if (!empty($context['search_params']['brd'])) { |
|
| 294 | + foreach ($context['search_params']['brd'] as $board_id) |
|
| 287 | 295 | echo ' |
| 288 | 296 | <input type="hidden" name="brd[', $board_id, ']" value="', $board_id, '">'; |
| 297 | + } |
|
| 289 | 298 | |
| 290 | 299 | echo ' |
| 291 | 300 | </form> |
@@ -297,18 +306,20 @@ discard block |
||
| 297 | 306 | if ($context['compact']) |
| 298 | 307 | { |
| 299 | 308 | // Quick moderation set to checkboxes? Oh, how fun :/ |
| 300 | - if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) |
|
| 301 | - echo ' |
|
| 309 | + if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) { |
|
| 310 | + echo ' |
|
| 302 | 311 | <form action="', $scripturl, '?action=quickmod" method="post" accept-charset="', $context['character_set'], '" name="topicForm">'; |
| 312 | + } |
|
| 303 | 313 | |
| 304 | 314 | echo ' |
| 305 | 315 | <div class="cat_bar"> |
| 306 | 316 | <h3 class="catbg"> |
| 307 | 317 | <span class="floatright">'; |
| 308 | 318 | |
| 309 | - if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) |
|
| 310 | - echo ' |
|
| 319 | + if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) { |
|
| 320 | + echo ' |
|
| 311 | 321 | <input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');">'; |
| 322 | + } |
|
| 312 | 323 | echo ' |
| 313 | 324 | </span> |
| 314 | 325 | <span class="generic_icons filter"></span> ', $txt['mlist_search_results'], ': ', $context['search_params']['search'], ' |
@@ -316,15 +327,15 @@ discard block |
||
| 316 | 327 | </div>'; |
| 317 | 328 | |
| 318 | 329 | // Was anything even found? |
| 319 | - if (!empty($context['topics'])) |
|
| 320 | - echo ' |
|
| 330 | + if (!empty($context['topics'])) { |
|
| 331 | + echo ' |
|
| 321 | 332 | <div class="pagesection"> |
| 322 | 333 | <span>', $context['page_index'], '</span> |
| 323 | 334 | </div>'; |
| 324 | - |
|
| 325 | - else |
|
| 326 | - echo ' |
|
| 335 | + } else { |
|
| 336 | + echo ' |
|
| 327 | 337 | <div class="roundframe">', $txt['find_no_results'], '</div>'; |
| 338 | + } |
|
| 328 | 339 | |
| 329 | 340 | // While we have results to show ... |
| 330 | 341 | while ($topic = $context['get_topics']()) |
@@ -347,41 +358,46 @@ discard block |
||
| 347 | 358 | echo ' |
| 348 | 359 | <div class="floatright">'; |
| 349 | 360 | |
| 350 | - if ($options['display_quick_mod'] == 1) |
|
| 351 | - echo ' |
|
| 361 | + if ($options['display_quick_mod'] == 1) { |
|
| 362 | + echo ' |
|
| 352 | 363 | <input type="checkbox" name="topics[]" value="', $topic['id'], '">'; |
| 353 | - |
|
| 354 | - else |
|
| 364 | + } else |
|
| 355 | 365 | { |
| 356 | - if ($topic['quick_mod']['remove']) |
|
| 357 | - echo ' |
|
| 366 | + if ($topic['quick_mod']['remove']) { |
|
| 367 | + echo ' |
|
| 358 | 368 | <a href="', $scripturl, '?action=quickmod;board=' . $topic['board']['id'] . '.0;actions%5B', $topic['id'], '%5D=remove;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons delete" title="', $txt['remove_topic'], '"></span></a>'; |
| 369 | + } |
|
| 359 | 370 | |
| 360 | - if ($topic['quick_mod']['lock']) |
|
| 361 | - echo ' |
|
| 371 | + if ($topic['quick_mod']['lock']) { |
|
| 372 | + echo ' |
|
| 362 | 373 | <a href="', $scripturl, '?action=quickmod;board=' . $topic['board']['id'] . '.0;actions%5B', $topic['id'], '%5D=lock;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons lock" title="', $topic['is_locked'] ? $txt['set_unlock'] : $txt['set_lock'], '"></span></a>'; |
| 374 | + } |
|
| 363 | 375 | |
| 364 | - if ($topic['quick_mod']['lock'] || $topic['quick_mod']['remove']) |
|
| 365 | - echo ' |
|
| 376 | + if ($topic['quick_mod']['lock'] || $topic['quick_mod']['remove']) { |
|
| 377 | + echo ' |
|
| 366 | 378 | <br>'; |
| 379 | + } |
|
| 367 | 380 | |
| 368 | - if ($topic['quick_mod']['sticky']) |
|
| 369 | - echo ' |
|
| 381 | + if ($topic['quick_mod']['sticky']) { |
|
| 382 | + echo ' |
|
| 370 | 383 | <a href="', $scripturl, '?action=quickmod;board=' . $topic['board']['id'] . '.0;actions%5B', $topic['id'], '%5D=sticky;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons sticky" title="', $topic['is_sticky'] ? $txt['set_nonsticky'] : $txt['set_sticky'], '"></span></a>'; |
| 384 | + } |
|
| 371 | 385 | |
| 372 | - if ($topic['quick_mod']['move']) |
|
| 373 | - echo ' |
|
| 386 | + if ($topic['quick_mod']['move']) { |
|
| 387 | + echo ' |
|
| 374 | 388 | <a href="', $scripturl, '?action=movetopic;topic=', $topic['id'], '.0"><span class="generic_icons move" title="', $txt['move_topic'], '"></span></a>'; |
| 389 | + } |
|
| 375 | 390 | } |
| 376 | 391 | |
| 377 | 392 | echo ' |
| 378 | 393 | </div><!-- .floatright -->'; |
| 379 | 394 | } |
| 380 | 395 | |
| 381 | - if ($message['body_highlighted'] != '') |
|
| 382 | - echo ' |
|
| 396 | + if ($message['body_highlighted'] != '') { |
|
| 397 | + echo ' |
|
| 383 | 398 | <br class="clear"> |
| 384 | 399 | <div class="list_posts double_height">', $message['body_highlighted'], '</div>'; |
| 400 | + } |
|
| 385 | 401 | } |
| 386 | 402 | |
| 387 | 403 | echo ' |
@@ -389,11 +405,12 @@ discard block |
||
| 389 | 405 | </div><!-- $topic[css_class] -->'; |
| 390 | 406 | |
| 391 | 407 | } |
| 392 | - if (!empty($context['topics'])) |
|
| 393 | - echo ' |
|
| 408 | + if (!empty($context['topics'])) { |
|
| 409 | + echo ' |
|
| 394 | 410 | <div class="pagesection"> |
| 395 | 411 | <span>', $context['page_index'], '</span> |
| 396 | 412 | </div>'; |
| 413 | + } |
|
| 397 | 414 | |
| 398 | 415 | if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics'])) |
| 399 | 416 | { |
@@ -402,17 +419,19 @@ discard block |
||
| 402 | 419 | <select class="qaction" name="qaction"', $context['can_move'] ? ' onchange="this.form.move_to.disabled = (this.options[this.selectedIndex].value != \'move\');"' : '', '> |
| 403 | 420 | <option value="">--------</option>'; |
| 404 | 421 | |
| 405 | - foreach ($context['qmod_actions'] as $qmod_action) |
|
| 406 | - if ($context['can_' . $qmod_action]) |
|
| 422 | + foreach ($context['qmod_actions'] as $qmod_action) { |
|
| 423 | + if ($context['can_' . $qmod_action]) |
|
| 407 | 424 | echo ' |
| 408 | 425 | <option value="' . $qmod_action . '">' . $txt['quick_mod_' . $qmod_action] . '</option>'; |
| 426 | + } |
|
| 409 | 427 | |
| 410 | 428 | echo ' |
| 411 | 429 | </select>'; |
| 412 | 430 | |
| 413 | - if ($context['can_move']) |
|
| 414 | - echo ' |
|
| 431 | + if ($context['can_move']) { |
|
| 432 | + echo ' |
|
| 415 | 433 | <span id="quick_mod_jump_to"></span>'; |
| 434 | + } |
|
| 416 | 435 | |
| 417 | 436 | echo ' |
| 418 | 437 | <input type="hidden" name="redirect_url" value="', $scripturl . '?action=search2;params=' . $context['params'], '"> |
@@ -421,13 +440,13 @@ discard block |
||
| 421 | 440 | } |
| 422 | 441 | |
| 423 | 442 | |
| 424 | - if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics'])) |
|
| 425 | - echo ' |
|
| 443 | + if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics'])) { |
|
| 444 | + echo ' |
|
| 426 | 445 | <input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '"> |
| 427 | 446 | </form>'; |
| 447 | + } |
|
| 428 | 448 | |
| 429 | - } |
|
| 430 | - else |
|
| 449 | + } else |
|
| 431 | 450 | { |
| 432 | 451 | echo ' |
| 433 | 452 | <div class="cat_bar"> |
@@ -439,9 +458,10 @@ discard block |
||
| 439 | 458 | <span>', $context['page_index'], '</span> |
| 440 | 459 | </div>'; |
| 441 | 460 | |
| 442 | - if (empty($context['topics'])) |
|
| 443 | - echo ' |
|
| 461 | + if (empty($context['topics'])) { |
|
| 462 | + echo ' |
|
| 444 | 463 | <div class="information">(', $txt['search_no_results'], ')</div>'; |
| 464 | + } |
|
| 445 | 465 | |
| 446 | 466 | while ($topic = $context['get_topics']()) |
| 447 | 467 | { |
@@ -458,23 +478,27 @@ discard block |
||
| 458 | 478 | </div> |
| 459 | 479 | <div class="list_posts">', $message['body_highlighted'], '</div>'; |
| 460 | 480 | |
| 461 | - if ($topic['can_reply']) |
|
| 462 | - echo ' |
|
| 481 | + if ($topic['can_reply']) { |
|
| 482 | + echo ' |
|
| 463 | 483 | <ul class="quickbuttons">'; |
| 484 | + } |
|
| 464 | 485 | |
| 465 | 486 | // If they *can* reply? |
| 466 | - if ($topic['can_reply']) |
|
| 467 | - echo ' |
|
| 487 | + if ($topic['can_reply']) { |
|
| 488 | + echo ' |
|
| 468 | 489 | <li><a href="', $scripturl . '?action=post;topic=' . $topic['id'] . '.' . $message['start'], '"><span class="generic_icons reply_button"></span>', $txt['reply'], '</a></li>'; |
| 490 | + } |
|
| 469 | 491 | |
| 470 | 492 | // If they *can* quote? |
| 471 | - if ($topic['can_quote']) |
|
| 472 | - echo ' |
|
| 493 | + if ($topic['can_quote']) { |
|
| 494 | + echo ' |
|
| 473 | 495 | <li><a href="', $scripturl . '?action=post;topic=' . $topic['id'] . '.' . $message['start'] . ';quote=' . $message['id'] . '"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li>'; |
| 496 | + } |
|
| 474 | 497 | |
| 475 | - if ($topic['can_reply']) |
|
| 476 | - echo ' |
|
| 498 | + if ($topic['can_reply']) { |
|
| 499 | + echo ' |
|
| 477 | 500 | </ul>'; |
| 501 | + } |
|
| 478 | 502 | echo ' |
| 479 | 503 | <br class="clear"> |
| 480 | 504 | </div><!-- $topic[css_class] -->'; |
@@ -493,8 +517,8 @@ discard block |
||
| 493 | 517 | <div class="smalltext righttext" id="search_jump_to"></div> |
| 494 | 518 | <script>'; |
| 495 | 519 | |
| 496 | - if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']) && $context['can_move']) |
|
| 497 | - echo ' |
|
| 520 | + if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']) && $context['can_move']) { |
|
| 521 | + echo ' |
|
| 498 | 522 | if (typeof(window.XMLHttpRequest) != "undefined") |
| 499 | 523 | aJumpTo[aJumpTo.length] = new JumpTo({ |
| 500 | 524 | sContainerId: "quick_mod_jump_to", |
@@ -509,6 +533,7 @@ discard block |
||
| 509 | 533 | bDisabled: true, |
| 510 | 534 | sCustomName: "move_to" |
| 511 | 535 | });'; |
| 536 | + } |
|
| 512 | 537 | |
| 513 | 538 | echo ' |
| 514 | 539 | if (typeof(window.XMLHttpRequest) != "undefined") |
@@ -23,15 +23,15 @@ discard block |
||
| 23 | 23 | { |
| 24 | 24 | global $context, $txt; |
| 25 | 25 | |
| 26 | - if (!empty($context['simple_action'])) |
|
| 27 | - echo ' |
|
| 26 | + if (!empty($context['simple_action'])) { |
|
| 27 | + echo ' |
|
| 28 | 28 | <strong> |
| 29 | 29 | ', $context['error_title'], ' |
| 30 | 30 | </strong><br> |
| 31 | 31 | <div ', $context['error_code'], 'class="padding"> |
| 32 | 32 | ', $context['error_message'], ' |
| 33 | 33 | </div>'; |
| 34 | - else |
|
| 34 | + } else |
|
| 35 | 35 | { |
| 36 | 36 | echo ' |
| 37 | 37 | <div id="fatal_error"> |
@@ -85,21 +85,23 @@ discard block |
||
| 85 | 85 | |
| 86 | 86 | $error_types = array(); |
| 87 | 87 | |
| 88 | - foreach ($context['error_types'] as $type => $details) |
|
| 89 | - $error_types[] = ($details['is_selected'] ? '<img src="' . $settings['images_url'] . '/selected.png" alt=""> ' : '') . '<a href="' . $details['url'] . '" ' . ($details['is_selected'] ? 'style="font-weight: bold;"' : '') . ' title="' . $details['description'] . '">' . $details['label'] . '</a>'; |
|
| 88 | + foreach ($context['error_types'] as $type => $details) { |
|
| 89 | + $error_types[] = ($details['is_selected'] ? '<img src="' . $settings['images_url'] . '/selected.png" alt=""> ' : '') . '<a href="' . $details['url'] . '" ' . ($details['is_selected'] ? 'style="font-weight: bold;"' : '') . ' title="' . $details['description'] . '">' . $details['label'] . '</a>'; |
|
| 90 | + } |
|
| 90 | 91 | |
| 91 | 92 | echo ' |
| 92 | 93 | ', implode(' | ', $error_types), ' |
| 93 | 94 | </td> |
| 94 | 95 | </tr>'; |
| 95 | 96 | |
| 96 | - if ($context['has_filter']) |
|
| 97 | - echo ' |
|
| 97 | + if ($context['has_filter']) { |
|
| 98 | + echo ' |
|
| 98 | 99 | <tr> |
| 99 | 100 | <td colspan="3" class="windowbg"> |
| 100 | 101 | <strong>', $txt['applying_filter'], ':</strong> ', $context['filter']['entity'], ' ', $context['filter']['value']['html'], ' [<a href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? ';desc' : '', '">', $txt['clear_filter'], '</a>] |
| 101 | 102 | </td> |
| 102 | 103 | </tr>'; |
| 104 | + } |
|
| 103 | 105 | |
| 104 | 106 | echo ' |
| 105 | 107 | <tr> |
@@ -110,11 +112,12 @@ discard block |
||
| 110 | 112 | </tr>'; |
| 111 | 113 | |
| 112 | 114 | // No errors, then show a message |
| 113 | - if (count($context['errors']) == 0) |
|
| 114 | - echo ' |
|
| 115 | + if (count($context['errors']) == 0) { |
|
| 116 | + echo ' |
|
| 115 | 117 | <tr class="windowbg"> |
| 116 | 118 | <td class="centertext" colspan="2">', $txt['errlog_no_entries'], '</td> |
| 117 | 119 | </tr>'; |
| 120 | + } |
|
| 118 | 121 | |
| 119 | 122 | // We have some errors, must be some mods installed :P |
| 120 | 123 | foreach ($context['errors'] as $error) |
@@ -128,19 +131,21 @@ discard block |
||
| 128 | 131 | <a href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? '' : ';desc', $context['has_filter'] ? $context['filter']['href'] : '', '" title="', $txt['reverse_direction'], '"><span class="generic_icons sort_' . $context['sort_direction'] . '"></span></a> |
| 129 | 132 | ', $error['time'], '<br>'; |
| 130 | 133 | |
| 131 | - if (!empty($error['member']['ip'])) |
|
| 132 | - echo ' |
|
| 134 | + if (!empty($error['member']['ip'])) { |
|
| 135 | + echo ' |
|
| 133 | 136 | <a href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? ';desc' : '', ';filter=ip;value=', $error['member']['ip'], '" title="', $txt['apply_filter'], ': ', $txt['filter_only_ip'], '"><span class="generic_icons filter centericon"></span></a> |
| 134 | 137 | <strong><a href="', $scripturl, '?action=trackip;searchip=', $error['member']['ip'], '">', $error['member']['ip'], '</a></strong>'; |
| 138 | + } |
|
| 135 | 139 | |
| 136 | 140 | echo ' |
| 137 | 141 | </div> |
| 138 | 142 | <div class="error_info">'; |
| 139 | 143 | |
| 140 | - if ($error['member']['session'] != '') |
|
| 141 | - echo ' |
|
| 144 | + if ($error['member']['session'] != '') { |
|
| 145 | + echo ' |
|
| 142 | 146 | <a href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? ';desc' : '', ';filter=session;value=', $error['member']['session'], '" title="', $txt['apply_filter'], ': ', $txt['filter_only_session'], '"><span class="generic_icons filter centericon"></span></a> |
| 143 | 147 | ', $error['member']['session'], '<br>'; |
| 148 | + } |
|
| 144 | 149 | |
| 145 | 150 | echo ' |
| 146 | 151 | <a href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? ';desc' : '', ';filter=error_type;value=', $error['error_type']['type'], '" title="', $txt['apply_filter'], ': ', $txt['filter_only_type'], '"><span class="generic_icons filter centericon"></span></a> |
@@ -154,8 +159,8 @@ discard block |
||
| 154 | 159 | <a href="', $error['url']['html'], '">', $error['url']['html'], '</a> |
| 155 | 160 | </div>'; |
| 156 | 161 | |
| 157 | - if (!empty($error['file'])) |
|
| 158 | - echo ' |
|
| 162 | + if (!empty($error['file'])) { |
|
| 163 | + echo ' |
|
| 159 | 164 | <div class="error_location"> |
| 160 | 165 | <a href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? ';desc' : '', ';filter=file;value=', $error['file']['search'], '" title="', $txt['apply_filter'], ': ', $txt['filter_only_file'], '"><span class="generic_icons filter"></span></a> |
| 161 | 166 | <div> |
@@ -163,6 +168,7 @@ discard block |
||
| 163 | 168 | ', $txt['line'], ': ', $error['file']['line'], ' |
| 164 | 169 | </div> |
| 165 | 170 | </div>'; |
| 171 | + } |
|
| 166 | 172 | |
| 167 | 173 | echo ' |
| 168 | 174 | </td> |
@@ -190,9 +196,10 @@ discard block |
||
| 190 | 196 | </div> |
| 191 | 197 | </div>'; |
| 192 | 198 | |
| 193 | - if ($context['sort_direction'] == 'down') |
|
| 194 | - echo ' |
|
| 199 | + if ($context['sort_direction'] == 'down') { |
|
| 200 | + echo ' |
|
| 195 | 201 | <input type="hidden" name="desc" value="1">'; |
| 202 | + } |
|
| 196 | 203 | |
| 197 | 204 | echo ' |
| 198 | 205 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -24,11 +24,12 @@ discard block |
||
| 24 | 24 | <h3 class="catbg">', $txt['paid_' . $context['action_type'] . '_subscription'], '</h3> |
| 25 | 25 | </div>'; |
| 26 | 26 | |
| 27 | - if (!empty($context['disable_groups'])) |
|
| 28 | - echo ' |
|
| 27 | + if (!empty($context['disable_groups'])) { |
|
| 28 | + echo ' |
|
| 29 | 29 | <div class="information"> |
| 30 | 30 | <span class="alert">', $txt['paid_mod_edit_note'], '</span> |
| 31 | 31 | </div>'; |
| 32 | + } |
|
| 32 | 33 | |
| 33 | 34 | echo ' |
| 34 | 35 | <div class="windowbg2"> |
@@ -69,9 +70,10 @@ discard block |
||
| 69 | 70 | <option value="0"', $context['sub']['prim_group'] == 0 ? ' selected' : '', '>', $txt['paid_mod_no_group'], '</option>'; |
| 70 | 71 | |
| 71 | 72 | // Put each group into the box. |
| 72 | - foreach ($context['groups'] as $id => $name) |
|
| 73 | - echo ' |
|
| 73 | + foreach ($context['groups'] as $id => $name) { |
|
| 74 | + echo ' |
|
| 74 | 75 | <option value="', $id, '"', $context['sub']['prim_group'] == $id ? ' selected' : '', '>', $name, '</option>'; |
| 76 | + } |
|
| 75 | 77 | |
| 76 | 78 | echo ' |
| 77 | 79 | </select> |
@@ -83,12 +85,13 @@ discard block |
||
| 83 | 85 | <dd>'; |
| 84 | 86 | |
| 85 | 87 | // Put a checkbox in for each group |
| 86 | - foreach ($context['groups'] as $id => $name) |
|
| 87 | - echo ' |
|
| 88 | + foreach ($context['groups'] as $id => $name) { |
|
| 89 | + echo ' |
|
| 88 | 90 | <label for="addgroup_', $id, '"> |
| 89 | 91 | <input type="checkbox" id="addgroup_', $id, '" name="addgroup[', $id, ']"', in_array($id, $context['sub']['add_groups']) ? ' checked' : '', !empty($context['disable_groups']) ? ' disabled' : '', '> |
| 90 | 92 | <span class="smalltext">', $name, '</span> |
| 91 | 93 | </label><br>'; |
| 94 | + } |
|
| 92 | 95 | |
| 93 | 96 | echo ' |
| 94 | 97 | </dd> |
@@ -142,8 +145,8 @@ discard block |
||
| 142 | 145 | <fieldset>'; |
| 143 | 146 | |
| 144 | 147 | //!! Removed until implemented |
| 145 | - if (!empty($sdflsdhglsdjgs)) |
|
| 146 | - echo ' |
|
| 148 | + if (!empty($sdflsdhglsdjgs)) { |
|
| 149 | + echo ' |
|
| 147 | 150 | <dl class="settings"> |
| 148 | 151 | <dt> |
| 149 | 152 | <label for="allow_partial_check">', $txt['paid_mod_allow_partial'], '</label>:<br><span class="smalltext">', $txt['paid_mod_allow_partial_desc'], '</span> |
@@ -152,6 +155,7 @@ discard block |
||
| 152 | 155 | <input type="checkbox" name="allow_partial" id="allow_partial_check"', empty($context['sub']['allow_partial']) ? '' : ' checked', '> |
| 153 | 156 | </dd> |
| 154 | 157 | </dl>'; |
| 158 | + } |
|
| 155 | 159 | |
| 156 | 160 | echo ' |
| 157 | 161 | <div class="information"> |
@@ -250,8 +254,8 @@ discard block |
||
| 250 | 254 | <dl class="settings">'; |
| 251 | 255 | |
| 252 | 256 | // Do we need a username? |
| 253 | - if ($context['action_type'] == 'add') |
|
| 254 | - echo ' |
|
| 257 | + if ($context['action_type'] == 'add') { |
|
| 258 | + echo ' |
|
| 255 | 259 | <dt> |
| 256 | 260 | <strong>', $txt['paid_username'], ':</strong><br> |
| 257 | 261 | <span class="smalltext">', $txt['one_username'], '</span> |
@@ -259,6 +263,7 @@ discard block |
||
| 259 | 263 | <dd> |
| 260 | 264 | <input type="text" name="name" id="name_control" value="', $context['sub']['username'], '" size="30"> |
| 261 | 265 | </dd>'; |
| 266 | + } |
|
| 262 | 267 | |
| 263 | 268 | echo ' |
| 264 | 269 | <dt> |
@@ -276,9 +281,10 @@ discard block |
||
| 276 | 281 | <select name="year" id="year" onchange="generateDays();">'; |
| 277 | 282 | |
| 278 | 283 | // Show a list of all the years we allow... |
| 279 | - for ($year = 2005; $year <= 2030; $year++) |
|
| 280 | - echo ' |
|
| 284 | + for ($year = 2005; $year <= 2030; $year++) { |
|
| 285 | + echo ' |
|
| 281 | 286 | <option value="', $year, '"', $year == $context['sub']['start']['year'] ? ' selected' : '', '>', $year, '</option>'; |
| 287 | + } |
|
| 282 | 288 | |
| 283 | 289 | echo ' |
| 284 | 290 | </select> |
@@ -286,9 +292,10 @@ discard block |
||
| 286 | 292 | <select name="month" id="month" onchange="generateDays();">'; |
| 287 | 293 | |
| 288 | 294 | // There are 12 months per year - ensure that they all get listed. |
| 289 | - for ($month = 1; $month <= 12; $month++) |
|
| 290 | - echo ' |
|
| 295 | + for ($month = 1; $month <= 12; $month++) { |
|
| 296 | + echo ' |
|
| 291 | 297 | <option value="', $month, '"', $month == $context['sub']['start']['month'] ? ' selected' : '', '>', $txt['months'][$month], '</option>'; |
| 298 | + } |
|
| 292 | 299 | |
| 293 | 300 | echo ' |
| 294 | 301 | </select> |
@@ -296,9 +303,10 @@ discard block |
||
| 296 | 303 | <select name="day" id="day">'; |
| 297 | 304 | |
| 298 | 305 | // This prints out all the days in the current month - this changes dynamically as we switch months. |
| 299 | - for ($day = 1; $day <= $context['sub']['start']['last_day']; $day++) |
|
| 300 | - echo ' |
|
| 306 | + for ($day = 1; $day <= $context['sub']['start']['last_day']; $day++) { |
|
| 307 | + echo ' |
|
| 301 | 308 | <option value="', $day, '"', $day == $context['sub']['start']['day'] ? ' selected' : '', '>', $day, '</option>'; |
| 309 | + } |
|
| 302 | 310 | |
| 303 | 311 | echo ' |
| 304 | 312 | </select> |
@@ -310,9 +318,10 @@ discard block |
||
| 310 | 318 | <select name="yearend" id="yearend" onchange="generateDays(\'end\');">'; |
| 311 | 319 | |
| 312 | 320 | // Show a list of all the years we allow... |
| 313 | - for ($year = 2005; $year <= 2030; $year++) |
|
| 314 | - echo ' |
|
| 321 | + for ($year = 2005; $year <= 2030; $year++) { |
|
| 322 | + echo ' |
|
| 315 | 323 | <option value="', $year, '"', $year == $context['sub']['end']['year'] ? ' selected' : '', '>', $year, '</option>'; |
| 324 | + } |
|
| 316 | 325 | |
| 317 | 326 | echo ' |
| 318 | 327 | </select> |
@@ -320,9 +329,10 @@ discard block |
||
| 320 | 329 | <select name="monthend" id="monthend" onchange="generateDays(\'end\');">'; |
| 321 | 330 | |
| 322 | 331 | // There are 12 months per year - ensure that they all get listed. |
| 323 | - for ($month = 1; $month <= 12; $month++) |
|
| 324 | - echo ' |
|
| 332 | + for ($month = 1; $month <= 12; $month++) { |
|
| 333 | + echo ' |
|
| 325 | 334 | <option value="', $month, '"', $month == $context['sub']['end']['month'] ? ' selected' : '', '>', $txt['months'][$month], '</option>'; |
| 335 | + } |
|
| 326 | 336 | |
| 327 | 337 | echo ' |
| 328 | 338 | </select> |
@@ -330,9 +340,10 @@ discard block |
||
| 330 | 340 | <select name="dayend" id="dayend">'; |
| 331 | 341 | |
| 332 | 342 | // This prints out all the days in the current month - this changes dynamically as we switch months. |
| 333 | - for ($day = 1; $day <= $context['sub']['end']['last_day']; $day++) |
|
| 334 | - echo ' |
|
| 343 | + for ($day = 1; $day <= $context['sub']['end']['last_day']; $day++) { |
|
| 344 | + echo ' |
|
| 335 | 345 | <option value="', $day, '"', $day == $context['sub']['end']['day'] ? ' selected' : '', '>', $day, '</option>'; |
| 346 | + } |
|
| 336 | 347 | |
| 337 | 348 | echo ' |
| 338 | 349 | </select> |
@@ -371,8 +382,8 @@ discard block |
||
| 371 | 382 | <div class="windowbg"> |
| 372 | 383 | <ul>'; |
| 373 | 384 | |
| 374 | - foreach ($context['pending_payments'] as $id => $payment) |
|
| 375 | - echo ' |
|
| 385 | + foreach ($context['pending_payments'] as $id => $payment) { |
|
| 386 | + echo ' |
|
| 376 | 387 | <li> |
| 377 | 388 | ', $payment['desc'], ' |
| 378 | 389 | <span class="floatleft"> |
@@ -382,6 +393,7 @@ discard block |
||
| 382 | 393 | <a href="', $scripturl, '?action=admin;area=paidsubscribe;sa=modifyuser;lid=', $context['log_id'], ';pending=', $id, ';remove">', $txt['pending_payments_remove'], '</a> |
| 383 | 394 | </span> |
| 384 | 395 | </li>'; |
| 396 | + } |
|
| 385 | 397 | |
| 386 | 398 | echo ' |
| 387 | 399 | </ul> |
@@ -406,12 +418,12 @@ discard block |
||
| 406 | 418 | <h3 class="catbg">', $txt['subscriptions'], '</h3> |
| 407 | 419 | </div>'; |
| 408 | 420 | |
| 409 | - if (empty($context['subscriptions'])) |
|
| 410 | - echo ' |
|
| 421 | + if (empty($context['subscriptions'])) { |
|
| 422 | + echo ' |
|
| 411 | 423 | <div class="information"> |
| 412 | 424 | ', $txt['paid_subs_none'], ' |
| 413 | 425 | </div>'; |
| 414 | - else |
|
| 426 | + } else |
|
| 415 | 427 | { |
| 416 | 428 | echo ' |
| 417 | 429 | <div class="information"> |
@@ -423,8 +435,9 @@ discard block |
||
| 423 | 435 | { |
| 424 | 436 | |
| 425 | 437 | // Ignore the inactive ones... |
| 426 | - if (empty($subscription['active'])) |
|
| 427 | - continue; |
|
| 438 | + if (empty($subscription['active'])) { |
|
| 439 | + continue; |
|
| 440 | + } |
|
| 428 | 441 | |
| 429 | 442 | echo ' |
| 430 | 443 | <div class="cat_bar"> |
@@ -434,9 +447,10 @@ discard block |
||
| 434 | 447 | <p><strong>', $subscription['name'], '</strong></p> |
| 435 | 448 | <p class="smalltext">', $subscription['desc'], '</p>'; |
| 436 | 449 | |
| 437 | - if (!$subscription['flexible']) |
|
| 438 | - echo ' |
|
| 450 | + if (!$subscription['flexible']) { |
|
| 451 | + echo ' |
|
| 439 | 452 | <div><strong>', $txt['paid_duration'], ':</strong> ', $subscription['length'], '</div>'; |
| 453 | + } |
|
| 440 | 454 | |
| 441 | 455 | if ($context['user']['is_owner']) |
| 442 | 456 | { |
@@ -449,24 +463,25 @@ discard block |
||
| 449 | 463 | <select name="cur[', $subscription['id'], ']">'; |
| 450 | 464 | |
| 451 | 465 | // Print out the costs for this one. |
| 452 | - foreach ($subscription['costs'] as $duration => $value) |
|
| 453 | - echo ' |
|
| 466 | + foreach ($subscription['costs'] as $duration => $value) { |
|
| 467 | + echo ' |
|
| 454 | 468 | <option value="', $duration, '">', sprintf($modSettings['paid_currency_symbol'], $value), '/', $txt[$duration], '</option>'; |
| 469 | + } |
|
| 455 | 470 | |
| 456 | 471 | echo ' |
| 457 | 472 | </select>'; |
| 458 | - } |
|
| 459 | - else |
|
| 460 | - echo ' |
|
| 473 | + } else { |
|
| 474 | + echo ' |
|
| 461 | 475 | ', sprintf($modSettings['paid_currency_symbol'], $subscription['costs']['fixed']); |
| 476 | + } |
|
| 462 | 477 | |
| 463 | 478 | echo ' |
| 464 | 479 | <hr> |
| 465 | 480 | <input type="submit" name="sub_id[', $subscription['id'], ']" value="', $txt['paid_order'], '" class="button">'; |
| 466 | - } |
|
| 467 | - else |
|
| 468 | - echo ' |
|
| 481 | + } else { |
|
| 482 | + echo ' |
|
| 469 | 483 | <a href="', $scripturl, '?action=admin;area=paidsubscribe;sa=modifyuser;sid=', $subscription['id'], ';uid=', $context['member']['id'], (empty($context['current'][$subscription['id']]) ? '' : ';lid=' . $context['current'][$subscription['id']]['id']), '">', empty($context['current'][$subscription['id']]) ? $txt['paid_admin_add'] : $txt['paid_edit_subscription'], '</a>'; |
| 484 | + } |
|
| 470 | 485 | |
| 471 | 486 | echo ' |
| 472 | 487 | </div><!-- .windowbg -->'; |
@@ -493,19 +508,20 @@ discard block |
||
| 493 | 508 | </thead> |
| 494 | 509 | <tbody>'; |
| 495 | 510 | |
| 496 | - if (empty($context['current'])) |
|
| 497 | - echo ' |
|
| 511 | + if (empty($context['current'])) { |
|
| 512 | + echo ' |
|
| 498 | 513 | <tr class="windowbg"> |
| 499 | 514 | <td colspan="4"> |
| 500 | 515 | ', $txt['paid_none_yet'], ' |
| 501 | 516 | </td> |
| 502 | 517 | </tr>'; |
| 518 | + } |
|
| 503 | 519 | |
| 504 | 520 | foreach ($context['current'] as $sub) |
| 505 | 521 | { |
| 506 | 522 | |
| 507 | - if (!$sub['hide']) |
|
| 508 | - echo ' |
|
| 523 | + if (!$sub['hide']) { |
|
| 524 | + echo ' |
|
| 509 | 525 | <tr class="windowbg"> |
| 510 | 526 | <td> |
| 511 | 527 | ', (allowedTo('admin_forum') ? '<a href="' . $scripturl . '?action=admin;area=paidsubscribe;sa=modifyuser;lid=' . $sub['id'] . '">' . $sub['name'] . '</a>' : $sub['name']), ' |
@@ -516,6 +532,7 @@ discard block |
||
| 516 | 532 | <td>', $sub['start'], '</td> |
| 517 | 533 | <td>', $sub['end'], '</td> |
| 518 | 534 | </tr>'; |
| 535 | + } |
|
| 519 | 536 | } |
| 520 | 537 | |
| 521 | 538 | echo ' |
@@ -567,15 +584,17 @@ discard block |
||
| 567 | 584 | ', $gateway['desc'], '<br> |
| 568 | 585 | <form action="', $gateway['form'], '" method="post">'; |
| 569 | 586 | |
| 570 | - if (!empty($gateway['javascript'])) |
|
| 571 | - echo ' |
|
| 587 | + if (!empty($gateway['javascript'])) { |
|
| 588 | + echo ' |
|
| 572 | 589 | <script> |
| 573 | 590 | ', $gateway['javascript'], ' |
| 574 | 591 | </script>'; |
| 592 | + } |
|
| 575 | 593 | |
| 576 | - foreach ($gateway['hidden'] as $name => $value) |
|
| 577 | - echo ' |
|
| 594 | + foreach ($gateway['hidden'] as $name => $value) { |
|
| 595 | + echo ' |
|
| 578 | 596 | <input type="hidden" id="', $gateway['id'], '_', $name, '" name="', $name, '" value="', $value, '">'; |
| 597 | + } |
|
| 579 | 598 | |
| 580 | 599 | echo ' |
| 581 | 600 | <br> |
@@ -65,9 +65,10 @@ discard block |
||
| 65 | 65 | ', implode(', ', $context['administrators']); |
| 66 | 66 | |
| 67 | 67 | // If we have lots of admins... don't show them all. |
| 68 | - if (!empty($context['more_admins_link'])) |
|
| 69 | - echo ' |
|
| 68 | + if (!empty($context['more_admins_link'])) { |
|
| 69 | + echo ' |
|
| 70 | 70 | (', $context['more_admins_link'], ')'; |
| 71 | + } |
|
| 71 | 72 | |
| 72 | 73 | echo ' |
| 73 | 74 | </div><!-- #version_details --> |
@@ -84,17 +85,19 @@ discard block |
||
| 84 | 85 | foreach ($area['areas'] as $item_id => $item) |
| 85 | 86 | { |
| 86 | 87 | // No point showing the 'home' page here, we're already on it! |
| 87 | - if ($area_id == 'forum' && $item_id == 'index') |
|
| 88 | - continue; |
|
| 88 | + if ($area_id == 'forum' && $item_id == 'index') { |
|
| 89 | + continue; |
|
| 90 | + } |
|
| 89 | 91 | |
| 90 | 92 | $url = isset($item['url']) ? $item['url'] : $scripturl . '?action=admin;area=' . $item_id . (!empty($context[$context['admin_menu_name']]['extra_parameters']) ? $context[$context['admin_menu_name']]['extra_parameters'] : ''); |
| 91 | 93 | |
| 92 | - if (!empty($item['icon_file'])) |
|
| 93 | - echo ' |
|
| 94 | + if (!empty($item['icon_file'])) { |
|
| 95 | + echo ' |
|
| 94 | 96 | <a href="', $url, '" class="admin_group', !empty($item['inactive']) ? ' inactive' : '', '"><img class="large_admin_menu_icon_file" src="', $item['icon_file'], '" alt="">', $item['label'], '</a>'; |
| 95 | - else |
|
| 96 | - echo ' |
|
| 97 | + } else { |
|
| 98 | + echo ' |
|
| 97 | 99 | <a href="', $url, '"><span class="large_', $item['icon_class'], !empty($item['inactive']) ? ' inactive' : '', '"></span>', $item['label'], '</a>'; |
| 100 | + } |
|
| 98 | 101 | } |
| 99 | 102 | |
| 100 | 103 | echo ' |
@@ -105,10 +108,11 @@ discard block |
||
| 105 | 108 | </div><!-- #admincenter -->'; |
| 106 | 109 | |
| 107 | 110 | // The below functions include all the scripts needed from the simplemachines.org site. The language and format are passed for internationalization. |
| 108 | - if (empty($modSettings['disable_smf_js'])) |
|
| 109 | - echo ' |
|
| 111 | + if (empty($modSettings['disable_smf_js'])) { |
|
| 112 | + echo ' |
|
| 110 | 113 | <script src="', $scripturl, '?action=viewsmfile;filename=current-version.js"></script> |
| 111 | 114 | <script src="', $scripturl, '?action=viewsmfile;filename=latest-news.js"></script>'; |
| 115 | + } |
|
| 112 | 116 | |
| 113 | 117 | // This sets the announcements and current versions themselves ;). |
| 114 | 118 | echo ' |
@@ -187,9 +191,10 @@ discard block |
||
| 187 | 191 | <em>', $version['version'], '</em>'; |
| 188 | 192 | |
| 189 | 193 | // more details for this item, show them a link |
| 190 | - if ($context['can_admin'] && isset($version['more'])) |
|
| 191 | - echo |
|
| 194 | + if ($context['can_admin'] && isset($version['more'])) { |
|
| 195 | + echo |
|
| 192 | 196 | ' <a href="', $scripturl, $version['more'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['version_check_more'], '</a>'; |
| 197 | + } |
|
| 193 | 198 | echo ' |
| 194 | 199 | <br>'; |
| 195 | 200 | } |
@@ -220,21 +225,23 @@ discard block |
||
| 220 | 225 | |
| 221 | 226 | foreach ($context['credits'] as $section) |
| 222 | 227 | { |
| 223 | - if (isset($section['pretext'])) |
|
| 224 | - echo ' |
|
| 228 | + if (isset($section['pretext'])) { |
|
| 229 | + echo ' |
|
| 225 | 230 | <p>', $section['pretext'], '</p> |
| 226 | 231 | <hr>'; |
| 232 | + } |
|
| 227 | 233 | |
| 228 | 234 | echo ' |
| 229 | 235 | <dl>'; |
| 230 | 236 | |
| 231 | 237 | foreach ($section['groups'] as $group) |
| 232 | 238 | { |
| 233 | - if (isset($group['title'])) |
|
| 234 | - echo ' |
|
| 239 | + if (isset($group['title'])) { |
|
| 240 | + echo ' |
|
| 235 | 241 | <dt> |
| 236 | 242 | <strong>', $group['title'], ':</strong> |
| 237 | 243 | </dt>'; |
| 244 | + } |
|
| 238 | 245 | |
| 239 | 246 | echo ' |
| 240 | 247 | <dd>', implode(', ', $group['members']), '</dd>'; |
@@ -243,10 +250,11 @@ discard block |
||
| 243 | 250 | echo ' |
| 244 | 251 | </dl>'; |
| 245 | 252 | |
| 246 | - if (isset($section['posttext'])) |
|
| 247 | - echo ' |
|
| 253 | + if (isset($section['posttext'])) { |
|
| 254 | + echo ' |
|
| 248 | 255 | <hr> |
| 249 | 256 | <p>', $section['posttext'], '</p>'; |
| 257 | + } |
|
| 250 | 258 | } |
| 251 | 259 | |
| 252 | 260 | echo ' |
@@ -262,9 +270,10 @@ discard block |
||
| 262 | 270 | smfSupportVersions.forum = "', $context['forum_version'], '";'; |
| 263 | 271 | |
| 264 | 272 | // Don't worry, none of this is logged, it's just used to give information that might be of use. |
| 265 | - foreach ($context['current_versions'] as $variable => $version) |
|
| 266 | - echo ' |
|
| 273 | + foreach ($context['current_versions'] as $variable => $version) { |
|
| 274 | + echo ' |
|
| 267 | 275 | smfSupportVersions.', $variable, ' = "', $version['version'], '";'; |
| 276 | + } |
|
| 268 | 277 | |
| 269 | 278 | // Now we just have to include the script and wait ;). |
| 270 | 279 | echo ' |
@@ -361,8 +370,8 @@ discard block |
||
| 361 | 370 | <tbody>'; |
| 362 | 371 | |
| 363 | 372 | // Loop through every source file displaying its version - using javascript. |
| 364 | - foreach ($context['file_versions'] as $filename => $version) |
|
| 365 | - echo ' |
|
| 373 | + foreach ($context['file_versions'] as $filename => $version) { |
|
| 374 | + echo ' |
|
| 366 | 375 | <tr class="windowbg"> |
| 367 | 376 | <td class="half_table"> |
| 368 | 377 | ', $filename, ' |
@@ -374,6 +383,7 @@ discard block |
||
| 374 | 383 | <em id="currentSources', $filename, '">??</em> |
| 375 | 384 | </td> |
| 376 | 385 | </tr>'; |
| 386 | + } |
|
| 377 | 387 | |
| 378 | 388 | // Default template files. |
| 379 | 389 | echo ' |
@@ -399,8 +409,8 @@ discard block |
||
| 399 | 409 | <table id="Default" class="table_grid"> |
| 400 | 410 | <tbody>'; |
| 401 | 411 | |
| 402 | - foreach ($context['default_template_versions'] as $filename => $version) |
|
| 403 | - echo ' |
|
| 412 | + foreach ($context['default_template_versions'] as $filename => $version) { |
|
| 413 | + echo ' |
|
| 404 | 414 | <tr class="windowbg"> |
| 405 | 415 | <td class="half_table"> |
| 406 | 416 | ', $filename, ' |
@@ -412,6 +422,7 @@ discard block |
||
| 412 | 422 | <em id="currentDefault', $filename, '">??</em> |
| 413 | 423 | </td> |
| 414 | 424 | </tr>'; |
| 425 | + } |
|
| 415 | 426 | |
| 416 | 427 | // Now the language files... |
| 417 | 428 | echo ' |
@@ -439,8 +450,8 @@ discard block |
||
| 439 | 450 | |
| 440 | 451 | foreach ($context['default_language_versions'] as $language => $files) |
| 441 | 452 | { |
| 442 | - foreach ($files as $filename => $version) |
|
| 443 | - echo ' |
|
| 453 | + foreach ($files as $filename => $version) { |
|
| 454 | + echo ' |
|
| 444 | 455 | <tr class="windowbg"> |
| 445 | 456 | <td class="half_table"> |
| 446 | 457 | ', $filename, '.<em>', $language, '</em>.php |
@@ -452,6 +463,7 @@ discard block |
||
| 452 | 463 | <em id="current', $filename, '.', $language, '">??</em> |
| 453 | 464 | </td> |
| 454 | 465 | </tr>'; |
| 466 | + } |
|
| 455 | 467 | } |
| 456 | 468 | |
| 457 | 469 | echo ' |
@@ -481,8 +493,8 @@ discard block |
||
| 481 | 493 | <table id="Templates" class="table_grid"> |
| 482 | 494 | <tbody>'; |
| 483 | 495 | |
| 484 | - foreach ($context['template_versions'] as $filename => $version) |
|
| 485 | - echo ' |
|
| 496 | + foreach ($context['template_versions'] as $filename => $version) { |
|
| 497 | + echo ' |
|
| 486 | 498 | <tr class="windowbg"> |
| 487 | 499 | <td class="half_table"> |
| 488 | 500 | ', $filename, ' |
@@ -494,6 +506,7 @@ discard block |
||
| 494 | 506 | <em id="currentTemplates', $filename, '">??</em> |
| 495 | 507 | </td> |
| 496 | 508 | </tr>'; |
| 509 | + } |
|
| 497 | 510 | |
| 498 | 511 | echo ' |
| 499 | 512 | </tbody> |
@@ -523,8 +536,8 @@ discard block |
||
| 523 | 536 | <table id="Tasks" class="table_grid"> |
| 524 | 537 | <tbody>'; |
| 525 | 538 | |
| 526 | - foreach ($context['tasks_versions'] as $filename => $version) |
|
| 527 | - echo ' |
|
| 539 | + foreach ($context['tasks_versions'] as $filename => $version) { |
|
| 540 | + echo ' |
|
| 528 | 541 | <tr class="windowbg"> |
| 529 | 542 | <td class="half_table"> |
| 530 | 543 | ', $filename, ' |
@@ -536,6 +549,7 @@ discard block |
||
| 536 | 549 | <em id="currentTasks', $filename, '">??</em> |
| 537 | 550 | </td> |
| 538 | 551 | </tr>'; |
| 552 | + } |
|
| 539 | 553 | |
| 540 | 554 | echo ' |
| 541 | 555 | </tbody> |
@@ -577,9 +591,10 @@ discard block |
||
| 577 | 591 | { |
| 578 | 592 | global $context, $scripturl, $txt, $modSettings; |
| 579 | 593 | |
| 580 | - if (!empty($context['saved_successful'])) |
|
| 581 | - echo ' |
|
| 594 | + if (!empty($context['saved_successful'])) { |
|
| 595 | + echo ' |
|
| 582 | 596 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
| 597 | + } |
|
| 583 | 598 | |
| 584 | 599 | // First section is for adding/removing words from the censored list. |
| 585 | 600 | echo ' |
@@ -594,11 +609,12 @@ discard block |
||
| 594 | 609 | <p>', $txt['admin_censored_where'], '</p>'; |
| 595 | 610 | |
| 596 | 611 | // Show text boxes for censoring [bad ] => [good ]. |
| 597 | - foreach ($context['censored_words'] as $vulgar => $proper) |
|
| 598 | - echo ' |
|
| 612 | + foreach ($context['censored_words'] as $vulgar => $proper) { |
|
| 613 | + echo ' |
|
| 599 | 614 | <div class="block"> |
| 600 | 615 | <input type="text" name="censor_vulgar[]" value="', $vulgar, '" size="30"> => <input type="text" name="censor_proper[]" value="', $proper, '" size="30"> |
| 601 | 616 | </div>'; |
| 617 | + } |
|
| 602 | 618 | |
| 603 | 619 | // Now provide a way to censor more words. |
| 604 | 620 | echo ' |
@@ -673,19 +689,21 @@ discard block |
||
| 673 | 689 | <div class="windowbg2 noup"> |
| 674 | 690 | ', $txt['not_done_reason']; |
| 675 | 691 | |
| 676 | - if (!empty($context['continue_percent'])) |
|
| 677 | - echo ' |
|
| 692 | + if (!empty($context['continue_percent'])) { |
|
| 693 | + echo ' |
|
| 678 | 694 | <div class="progress_bar"> |
| 679 | 695 | <div class="full_bar">', $context['continue_percent'], '%</div> |
| 680 | 696 | <div class="green_percent" style="width: ', $context['continue_percent'], '%;"></div> |
| 681 | 697 | </div>'; |
| 698 | + } |
|
| 682 | 699 | |
| 683 | - if (!empty($context['substep_enabled'])) |
|
| 684 | - echo ' |
|
| 700 | + if (!empty($context['substep_enabled'])) { |
|
| 701 | + echo ' |
|
| 685 | 702 | <div class="progress_bar"> |
| 686 | 703 | <div class="full_bar">', $context['substep_title'], ' (', $context['substep_continue_percent'], '%)</div> |
| 687 | 704 | <div class="blue_percent" style="width: ', $context['substep_continue_percent'], '%;"></div> |
| 688 | 705 | </div>'; |
| 706 | + } |
|
| 689 | 707 | |
| 690 | 708 | echo ' |
| 691 | 709 | <form action="', $scripturl, $context['continue_get_data'], '" method="post" accept-charset="', $context['character_set'], '" name="autoSubmit" id="autoSubmit"> |
@@ -720,35 +738,40 @@ discard block |
||
| 720 | 738 | { |
| 721 | 739 | global $context, $txt, $scripturl; |
| 722 | 740 | |
| 723 | - if (!empty($context['saved_successful'])) |
|
| 724 | - echo ' |
|
| 741 | + if (!empty($context['saved_successful'])) { |
|
| 742 | + echo ' |
|
| 725 | 743 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
| 726 | - elseif (!empty($context['saved_failed'])) |
|
| 727 | - echo ' |
|
| 744 | + } elseif (!empty($context['saved_failed'])) { |
|
| 745 | + echo ' |
|
| 728 | 746 | <div class="errorbox">', sprintf($txt['settings_not_saved'], $context['saved_failed']), '</div>'; |
| 747 | + } |
|
| 729 | 748 | |
| 730 | - if (!empty($context['settings_pre_javascript'])) |
|
| 731 | - echo ' |
|
| 749 | + if (!empty($context['settings_pre_javascript'])) { |
|
| 750 | + echo ' |
|
| 732 | 751 | <script>', $context['settings_pre_javascript'], '</script>'; |
| 752 | + } |
|
| 733 | 753 | |
| 734 | - if (!empty($context['settings_insert_above'])) |
|
| 735 | - echo $context['settings_insert_above']; |
|
| 754 | + if (!empty($context['settings_insert_above'])) { |
|
| 755 | + echo $context['settings_insert_above']; |
|
| 756 | + } |
|
| 736 | 757 | |
| 737 | 758 | echo ' |
| 738 | 759 | <div id="admincenter"> |
| 739 | 760 | <form id="admin_form_wrapper" action="', $context['post_url'], '" method="post" accept-charset="', $context['character_set'], '"', !empty($context['force_form_onsubmit']) ? ' onsubmit="' . $context['force_form_onsubmit'] . '"' : '', '>'; |
| 740 | 761 | |
| 741 | 762 | // Is there a custom title? |
| 742 | - if (isset($context['settings_title'])) |
|
| 743 | - echo ' |
|
| 763 | + if (isset($context['settings_title'])) { |
|
| 764 | + echo ' |
|
| 744 | 765 | <div class="cat_bar"> |
| 745 | 766 | <h3 class="catbg">', $context['settings_title'], '</h3> |
| 746 | 767 | </div>'; |
| 768 | + } |
|
| 747 | 769 | |
| 748 | 770 | // Have we got a message to display? |
| 749 | - if (!empty($context['settings_message'])) |
|
| 750 | - echo ' |
|
| 771 | + if (!empty($context['settings_message'])) { |
|
| 772 | + echo ' |
|
| 751 | 773 | <div class="information">', $context['settings_message'], '</div>'; |
| 774 | + } |
|
| 752 | 775 | |
| 753 | 776 | // Now actually loop through all the variables. |
| 754 | 777 | $is_open = false; |
@@ -801,8 +824,9 @@ discard block |
||
| 801 | 824 | // Hang about? Are you pulling my leg - a callback?! |
| 802 | 825 | if (is_array($config_var) && $config_var['type'] == 'callback') |
| 803 | 826 | { |
| 804 | - if (function_exists('template_callback_' . $config_var['name'])) |
|
| 805 | - call_user_func('template_callback_' . $config_var['name']); |
|
| 827 | + if (function_exists('template_callback_' . $config_var['name'])) { |
|
| 828 | + call_user_func('template_callback_' . $config_var['name']); |
|
| 829 | + } |
|
| 806 | 830 | |
| 807 | 831 | continue; |
| 808 | 832 | } |
@@ -832,9 +856,10 @@ discard block |
||
| 832 | 856 | $text_types = array('color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'time'); |
| 833 | 857 | |
| 834 | 858 | // Show the [?] button. |
| 835 | - if ($config_var['help']) |
|
| 836 | - echo ' |
|
| 859 | + if ($config_var['help']) { |
|
| 860 | + echo ' |
|
| 837 | 861 | <a id="setting_', $config_var['name'], '_help" href="', $scripturl, '?action=helpadmin;help=', $config_var['help'], '" onclick="return reqOverlayDiv(this.href);"><span class="generic_icons help" title="', $txt['help'], '"></span></a> '; |
| 862 | + } |
|
| 838 | 863 | |
| 839 | 864 | echo ' |
| 840 | 865 | <a id="setting_', $config_var['name'], '"></a> <span', ($config_var['disabled'] ? ' style="color: #777777;"' : ($config_var['invalid'] ? ' class="error"' : '')), '><label for="', $config_var['name'], '">', $config_var['label'], '</label>', $subtext, ($config_var['type'] == 'password' ? '<br><em>' . $txt['admin_confirm_password'] . '</em>' : ''), '</span> |
@@ -843,23 +868,26 @@ discard block |
||
| 843 | 868 | $config_var['preinput']; |
| 844 | 869 | |
| 845 | 870 | // Show a check box. |
| 846 | - if ($config_var['type'] == 'check') |
|
| 847 | - echo ' |
|
| 871 | + if ($config_var['type'] == 'check') { |
|
| 872 | + echo ' |
|
| 848 | 873 | <input type="checkbox"', $javascript, $disabled, ' name="', $config_var['name'], '" id="', $config_var['name'], '"', ($config_var['value'] ? ' checked' : ''), ' value="1">'; |
| 874 | + } |
|
| 849 | 875 | // Escape (via htmlspecialchars.) the text box. |
| 850 | - elseif ($config_var['type'] == 'password') |
|
| 851 | - echo ' |
|
| 876 | + elseif ($config_var['type'] == 'password') { |
|
| 877 | + echo ' |
|
| 852 | 878 | <input type="password"', $disabled, $javascript, ' name="', $config_var['name'], '[0]"', ($config_var['size'] ? ' size="' . $config_var['size'] . '"' : ''), ' value="*#fakepass#*" onfocus="this.value = \'\'; this.form.', $config_var['name'], '.disabled = false;"><br> |
| 853 | 879 | <input type="password" disabled id="', $config_var['name'], '" name="', $config_var['name'], '[1]"', ($config_var['size'] ? ' size="' . $config_var['size'] . '"' : ''), '>'; |
| 880 | + } |
|
| 854 | 881 | // Show a selection box. |
| 855 | 882 | elseif ($config_var['type'] == 'select') |
| 856 | 883 | { |
| 857 | 884 | echo ' |
| 858 | 885 | <select name="', $config_var['name'], '" id="', $config_var['name'], '" ', $javascript, $disabled, (!empty($config_var['multiple']) ? ' multiple="multiple"' : ''), (!empty($config_var['multiple']) && !empty($config_var['size']) ? ' size="' . $config_var['size'] . '"' : ''), '>'; |
| 859 | 886 | |
| 860 | - foreach ($config_var['data'] as $option) |
|
| 861 | - echo ' |
|
| 887 | + foreach ($config_var['data'] as $option) { |
|
| 888 | + echo ' |
|
| 862 | 889 | <option value="', $option[0], '"', (!empty($config_var['value']) && ($option[0] == $config_var['value'] || (!empty($config_var['multiple']) && in_array($option[0], $config_var['value']))) ? ' selected' : ''), '>', $option[1], '</option>'; |
| 890 | + } |
|
| 863 | 891 | echo ' |
| 864 | 892 | </select>'; |
| 865 | 893 | } |
@@ -876,16 +904,18 @@ discard block |
||
| 876 | 904 | |
| 877 | 905 | foreach ($context['board_list'] as $id_cat => $cat) |
| 878 | 906 | { |
| 879 | - if (!$first) |
|
| 880 | - echo ' |
|
| 907 | + if (!$first) { |
|
| 908 | + echo ' |
|
| 881 | 909 | <hr>'; |
| 910 | + } |
|
| 882 | 911 | echo ' |
| 883 | 912 | <strong>', $cat['name'], '</strong> |
| 884 | 913 | <ul>'; |
| 885 | 914 | |
| 886 | - foreach ($cat['boards'] as $id_board => $brd) |
|
| 887 | - echo ' |
|
| 915 | + foreach ($cat['boards'] as $id_board => $brd) { |
|
| 916 | + echo ' |
|
| 888 | 917 | <li><label><input type="checkbox" name="', $config_var['name'], '[', $brd['id'], ']" value="1"', in_array($brd['id'], $config_var['value']) ? ' checked' : '', '> ', $brd['child_level'] > 0 ? str_repeat(' ', $brd['child_level']) : '', $brd['name'], '</label></li>'; |
| 918 | + } |
|
| 889 | 919 | |
| 890 | 920 | echo ' |
| 891 | 921 | </ul>'; |
@@ -895,12 +925,14 @@ discard block |
||
| 895 | 925 | </fieldset>'; |
| 896 | 926 | } |
| 897 | 927 | // Text area? |
| 898 | - elseif ($config_var['type'] == 'large_text') |
|
| 899 | - echo ' |
|
| 928 | + elseif ($config_var['type'] == 'large_text') { |
|
| 929 | + echo ' |
|
| 900 | 930 | <textarea rows="', (!empty($config_var['size']) ? $config_var['size'] : (!empty($config_var['rows']) ? $config_var['rows'] : 4)), '" cols="', (!empty($config_var['cols']) ? $config_var['cols'] : 30), '" ', $javascript, $disabled, ' name="', $config_var['name'], '" id="', $config_var['name'], '">', $config_var['value'], '</textarea>'; |
| 931 | + } |
|
| 901 | 932 | // Permission group? |
| 902 | - elseif ($config_var['type'] == 'permissions') |
|
| 903 | - theme_inline_permissions($config_var['name']); |
|
| 933 | + elseif ($config_var['type'] == 'permissions') { |
|
| 934 | + theme_inline_permissions($config_var['name']); |
|
| 935 | + } |
|
| 904 | 936 | |
| 905 | 937 | // BBC selection? |
| 906 | 938 | elseif ($config_var['type'] == 'bbc') |
@@ -912,22 +944,24 @@ discard block |
||
| 912 | 944 | |
| 913 | 945 | foreach ($context['bbc_columns'] as $bbcColumn) |
| 914 | 946 | { |
| 915 | - foreach ($bbcColumn as $bbcTag) |
|
| 916 | - echo ' |
|
| 947 | + foreach ($bbcColumn as $bbcTag) { |
|
| 948 | + echo ' |
|
| 917 | 949 | <li class="list_bbc floatleft"> |
| 918 | 950 | <input type="checkbox" name="', $config_var['name'], '_enabledTags[]" id="tag_', $config_var['name'], '_', $bbcTag['tag'], '" value="', $bbcTag['tag'], '"', !in_array($bbcTag['tag'], $context['bbc_sections'][$config_var['name']]['disabled']) ? ' checked' : '', '> <label for="tag_', $config_var['name'], '_', $bbcTag['tag'], '">', $bbcTag['tag'], '</label>', $bbcTag['show_help'] ? ' (<a href="' . $scripturl . '?action=helpadmin;help=tag_' . $bbcTag['tag'] . '" onclick="return reqOverlayDiv(this.href);">?</a>)' : '', ' |
| 919 | 951 | </li>'; |
| 952 | + } |
|
| 920 | 953 | } |
| 921 | 954 | echo ' </ul> |
| 922 | 955 | <input type="checkbox" id="bbc_', $config_var['name'], '_select_all" onclick="invertAll(this, this.form, \'', $config_var['name'], '_enabledTags\');"', $context['bbc_sections'][$config_var['name']]['all_selected'] ? ' checked' : '', '> <label for="bbc_', $config_var['name'], '_select_all"><em>', $txt['bbcTagsToUse_select_all'], '</em></label> |
| 923 | 956 | </fieldset>'; |
| 924 | 957 | } |
| 925 | 958 | // A simple message? |
| 926 | - elseif ($config_var['type'] == 'var_message') |
|
| 927 | - echo ' |
|
| 959 | + elseif ($config_var['type'] == 'var_message') { |
|
| 960 | + echo ' |
|
| 928 | 961 | <div', !empty($config_var['name']) ? ' id="' . $config_var['name'] . '"' : '', '> |
| 929 | 962 | ', $config_var['var_message'], ' |
| 930 | 963 | </div>'; |
| 964 | + } |
|
| 931 | 965 | // Assume it must be a text box |
| 932 | 966 | else |
| 933 | 967 | { |
@@ -952,62 +986,70 @@ discard block |
||
| 952 | 986 | ' . $config_var['postinput'] : '',' |
| 953 | 987 | </dd>'; |
| 954 | 988 | } |
| 955 | - } |
|
| 956 | - else |
|
| 989 | + } else |
|
| 957 | 990 | { |
| 958 | 991 | // Just show a separator. |
| 959 | - if ($config_var == '') |
|
| 960 | - echo ' |
|
| 992 | + if ($config_var == '') { |
|
| 993 | + echo ' |
|
| 961 | 994 | </dl> |
| 962 | 995 | <hr> |
| 963 | 996 | <dl class="settings">'; |
| 964 | - else |
|
| 965 | - echo ' |
|
| 997 | + } else { |
|
| 998 | + echo ' |
|
| 966 | 999 | <dd> |
| 967 | 1000 | <strong>' . $config_var . '</strong> |
| 968 | 1001 | </dd>'; |
| 1002 | + } |
|
| 969 | 1003 | } |
| 970 | 1004 | } |
| 971 | 1005 | |
| 972 | - if ($is_open) |
|
| 973 | - echo ' |
|
| 1006 | + if ($is_open) { |
|
| 1007 | + echo ' |
|
| 974 | 1008 | </dl>'; |
| 1009 | + } |
|
| 975 | 1010 | |
| 976 | - if (empty($context['settings_save_dont_show'])) |
|
| 977 | - echo ' |
|
| 1011 | + if (empty($context['settings_save_dont_show'])) { |
|
| 1012 | + echo ' |
|
| 978 | 1013 | <input type="submit" value="', $txt['save'], '"', (!empty($context['save_disabled']) ? ' disabled' : ''), (!empty($context['settings_save_onclick']) ? ' onclick="' . $context['settings_save_onclick'] . '"' : ''), ' class="button">'; |
| 1014 | + } |
|
| 979 | 1015 | |
| 980 | - if ($is_open) |
|
| 981 | - echo ' |
|
| 1016 | + if ($is_open) { |
|
| 1017 | + echo ' |
|
| 982 | 1018 | </div><!-- .windowbg2 -->'; |
| 1019 | + } |
|
| 983 | 1020 | |
| 984 | 1021 | |
| 985 | 1022 | // At least one token has to be used! |
| 986 | - if (isset($context['admin-ssc_token'])) |
|
| 987 | - echo ' |
|
| 1023 | + if (isset($context['admin-ssc_token'])) { |
|
| 1024 | + echo ' |
|
| 988 | 1025 | <input type="hidden" name="', $context['admin-ssc_token_var'], '" value="', $context['admin-ssc_token'], '">'; |
| 1026 | + } |
|
| 989 | 1027 | |
| 990 | - if (isset($context['admin-dbsc_token'])) |
|
| 991 | - echo ' |
|
| 1028 | + if (isset($context['admin-dbsc_token'])) { |
|
| 1029 | + echo ' |
|
| 992 | 1030 | <input type="hidden" name="', $context['admin-dbsc_token_var'], '" value="', $context['admin-dbsc_token'], '">'; |
| 1031 | + } |
|
| 993 | 1032 | |
| 994 | - if (isset($context['admin-mp_token'])) |
|
| 995 | - echo ' |
|
| 1033 | + if (isset($context['admin-mp_token'])) { |
|
| 1034 | + echo ' |
|
| 996 | 1035 | <input type="hidden" name="', $context['admin-mp_token_var'], '" value="', $context['admin-mp_token'], '">'; |
| 1036 | + } |
|
| 997 | 1037 | |
| 998 | 1038 | echo ' |
| 999 | 1039 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
| 1000 | 1040 | </form> |
| 1001 | 1041 | </div><!-- #admincenter -->'; |
| 1002 | 1042 | |
| 1003 | - if (!empty($context['settings_post_javascript'])) |
|
| 1004 | - echo ' |
|
| 1043 | + if (!empty($context['settings_post_javascript'])) { |
|
| 1044 | + echo ' |
|
| 1005 | 1045 | <script> |
| 1006 | 1046 | ', $context['settings_post_javascript'], ' |
| 1007 | 1047 | </script>'; |
| 1048 | + } |
|
| 1008 | 1049 | |
| 1009 | - if (!empty($context['settings_insert_below'])) |
|
| 1010 | - echo $context['settings_insert_below']; |
|
| 1050 | + if (!empty($context['settings_insert_below'])) { |
|
| 1051 | + echo $context['settings_insert_below']; |
|
| 1052 | + } |
|
| 1011 | 1053 | |
| 1012 | 1054 | // We may have added a board listing. If we did, we need to make it work. |
| 1013 | 1055 | addInlineJavascript(' |
@@ -1030,9 +1072,10 @@ discard block |
||
| 1030 | 1072 | { |
| 1031 | 1073 | global $context, $txt; |
| 1032 | 1074 | |
| 1033 | - if (!empty($context['saved_successful'])) |
|
| 1034 | - echo ' |
|
| 1075 | + if (!empty($context['saved_successful'])) { |
|
| 1076 | + echo ' |
|
| 1035 | 1077 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
| 1078 | + } |
|
| 1036 | 1079 | |
| 1037 | 1080 | // Standard fields. |
| 1038 | 1081 | template_show_list('standard_profile_fields'); |
@@ -1066,11 +1109,12 @@ discard block |
||
| 1066 | 1109 | { |
| 1067 | 1110 | loadLanguage('Errors'); |
| 1068 | 1111 | |
| 1069 | - if (isset($txt['custom_option_' . $_GET['msg']])) |
|
| 1070 | - echo ' |
|
| 1112 | + if (isset($txt['custom_option_' . $_GET['msg']])) { |
|
| 1113 | + echo ' |
|
| 1071 | 1114 | <div class="errorbox">', |
| 1072 | 1115 | $txt['custom_option_' . $_GET['msg']], ' |
| 1073 | 1116 | </div>'; |
| 1117 | + } |
|
| 1074 | 1118 | } |
| 1075 | 1119 | |
| 1076 | 1120 | echo ' |
@@ -1137,9 +1181,10 @@ discard block |
||
| 1137 | 1181 | <dd> |
| 1138 | 1182 | <select name="placement" id="placement">'; |
| 1139 | 1183 | |
| 1140 | - foreach ($context['cust_profile_fields_placement'] as $order => $name) |
|
| 1141 | - echo ' |
|
| 1184 | + foreach ($context['cust_profile_fields_placement'] as $order => $name) { |
|
| 1185 | + echo ' |
|
| 1142 | 1186 | <option value="', $order, '"', $context['field']['placement'] == $order ? ' selected' : '', '>', $txt['custom_profile_placement_' . $name], '</option>'; |
| 1187 | + } |
|
| 1143 | 1188 | |
| 1144 | 1189 | echo ' |
| 1145 | 1190 | </select> |
@@ -1163,9 +1208,10 @@ discard block |
||
| 1163 | 1208 | <dd> |
| 1164 | 1209 | <select name="field_type" id="field_type" onchange="updateInputBoxes();">'; |
| 1165 | 1210 | |
| 1166 | - foreach (array('text', 'textarea', 'select', 'radio', 'check') as $field_type) |
|
| 1167 | - echo ' |
|
| 1211 | + foreach (array('text', 'textarea', 'select', 'radio', 'check') as $field_type) { |
|
| 1212 | + echo ' |
|
| 1168 | 1213 | <option value="', $field_type, '"', $context['field']['type'] == $field_type ? ' selected' : '', '>', $txt['custom_profile_type_' . $field_type], '</option>'; |
| 1214 | + } |
|
| 1169 | 1215 | |
| 1170 | 1216 | echo ' |
| 1171 | 1217 | </select> |
@@ -1197,9 +1243,10 @@ discard block |
||
| 1197 | 1243 | </dt> |
| 1198 | 1244 | <dd id="options_dd">'; |
| 1199 | 1245 | |
| 1200 | - foreach ($context['field']['options'] as $k => $option) |
|
| 1201 | - echo ' |
|
| 1246 | + foreach ($context['field']['options'] as $k => $option) { |
|
| 1247 | + echo ' |
|
| 1202 | 1248 | ', $k == 0 ? '' : '<br>', '<input type="radio" name="default_select" value="', $k, '"', $context['field']['default_select'] == $option ? ' checked' : '', '><input type="text" name="select_option[', $k, ']" value="', $option, '">'; |
| 1249 | + } |
|
| 1203 | 1250 | |
| 1204 | 1251 | echo ' |
| 1205 | 1252 | <span id="addopt"></span> |
@@ -1263,9 +1310,10 @@ discard block |
||
| 1263 | 1310 | </fieldset> |
| 1264 | 1311 | <input type="submit" name="save" value="', $txt['save'], '" class="button">'; |
| 1265 | 1312 | |
| 1266 | - if ($context['fid']) |
|
| 1267 | - echo ' |
|
| 1313 | + if ($context['fid']) { |
|
| 1314 | + echo ' |
|
| 1268 | 1315 | <input type="submit" name="delete" value="', $txt['delete'], '" data-confirm="', $txt['custom_edit_delete_sure'], '" class="button you_sure">'; |
| 1316 | + } |
|
| 1269 | 1317 | |
| 1270 | 1318 | echo ' |
| 1271 | 1319 | </div><!-- .windowbg2 --> |
@@ -1312,8 +1360,7 @@ discard block |
||
| 1312 | 1360 | <p class="centertext"> |
| 1313 | 1361 | <strong>', $txt['admin_search_results_none'], '</strong> |
| 1314 | 1362 | </p>'; |
| 1315 | - } |
|
| 1316 | - else |
|
| 1363 | + } else |
|
| 1317 | 1364 | { |
| 1318 | 1365 | echo ' |
| 1319 | 1366 | <ol class="search_results">'; |
@@ -1340,9 +1387,10 @@ discard block |
||
| 1340 | 1387 | <li> |
| 1341 | 1388 | <a href="', $result['url'], '"><strong>', $result['name'], '</strong></a> [', isset($txt['admin_search_section_' . $result['type']]) ? $txt['admin_search_section_' . $result['type']] : $result['type'], ']'; |
| 1342 | 1389 | |
| 1343 | - if ($result['help']) |
|
| 1344 | - echo ' |
|
| 1390 | + if ($result['help']) { |
|
| 1391 | + echo ' |
|
| 1345 | 1392 | <p class="double_height">', $result['help'], '</p>'; |
| 1393 | + } |
|
| 1346 | 1394 | |
| 1347 | 1395 | echo ' |
| 1348 | 1396 | </li>'; |
@@ -1382,10 +1430,11 @@ discard block |
||
| 1382 | 1430 | <strong>', $txt['setup_verification_answer'], '</strong> |
| 1383 | 1431 | </dd>'; |
| 1384 | 1432 | |
| 1385 | - if (!empty($context['qa_by_lang'][$lang_id])) |
|
| 1386 | - foreach ($context['qa_by_lang'][$lang_id] as $q_id) |
|
| 1433 | + if (!empty($context['qa_by_lang'][$lang_id])) { |
|
| 1434 | + foreach ($context['qa_by_lang'][$lang_id] as $q_id) |
|
| 1387 | 1435 | { |
| 1388 | 1436 | $question = $context['question_answers'][$q_id]; |
| 1437 | + } |
|
| 1389 | 1438 | |
| 1390 | 1439 | echo ' |
| 1391 | 1440 | <dt> |
@@ -1393,9 +1442,10 @@ discard block |
||
| 1393 | 1442 | </dt> |
| 1394 | 1443 | <dd>'; |
| 1395 | 1444 | |
| 1396 | - foreach ($question['answers'] as $answer) |
|
| 1397 | - echo ' |
|
| 1445 | + foreach ($question['answers'] as $answer) { |
|
| 1446 | + echo ' |
|
| 1398 | 1447 | <input type="text" name="answer[', $lang_id, '][', $q_id, '][]" value="', $answer, '" size="50" class="verification_answer">'; |
| 1448 | + } |
|
| 1399 | 1449 | |
| 1400 | 1450 | echo ' |
| 1401 | 1451 | <div class="qa_add_answer"><a href="javascript:void(0);" onclick="return addAnswer(this);">[ ', $txt['setup_verification_add_answer'], ' ]</a></div> |
@@ -1434,11 +1484,12 @@ discard block |
||
| 1434 | 1484 | ', $txt['errors_found'], ': |
| 1435 | 1485 | <ul>'; |
| 1436 | 1486 | |
| 1437 | - foreach ($context['repair_errors'] as $error) |
|
| 1438 | - echo ' |
|
| 1487 | + foreach ($context['repair_errors'] as $error) { |
|
| 1488 | + echo ' |
|
| 1439 | 1489 | <li> |
| 1440 | 1490 | ', $error, ' |
| 1441 | 1491 | </li>'; |
| 1492 | + } |
|
| 1442 | 1493 | |
| 1443 | 1494 | echo ' |
| 1444 | 1495 | </ul> |
@@ -1448,16 +1499,15 @@ discard block |
||
| 1448 | 1499 | <p class="padding"> |
| 1449 | 1500 | <strong><a href="', $scripturl, '?action=admin;area=repairboards;fixErrors;', $context['session_var'], '=', $context['session_id'], '">', $txt['yes'], '</a> - <a href="', $scripturl, '?action=admin;area=maintain">', $txt['no'], '</a></strong> |
| 1450 | 1501 | </p>'; |
| 1451 | - } |
|
| 1452 | - else |
|
| 1453 | - echo ' |
|
| 1502 | + } else { |
|
| 1503 | + echo ' |
|
| 1454 | 1504 | <p>', $txt['maintain_no_errors'], '</p> |
| 1455 | 1505 | <p class="padding"> |
| 1456 | 1506 | <a href="', $scripturl, '?action=admin;area=maintain;sa=routine">', $txt['maintain_return'], '</a> |
| 1457 | 1507 | </p>'; |
| 1508 | + } |
|
| 1458 | 1509 | |
| 1459 | - } |
|
| 1460 | - else |
|
| 1510 | + } else |
|
| 1461 | 1511 | { |
| 1462 | 1512 | if (!empty($context['redirect_to_recount'])) |
| 1463 | 1513 | { |
@@ -1469,8 +1519,7 @@ discard block |
||
| 1469 | 1519 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
| 1470 | 1520 | <input type="submit" name="recount" id="recount_now" value="', $txt['errors_recount_now'], '"> |
| 1471 | 1521 | </form>'; |
| 1472 | - } |
|
| 1473 | - else |
|
| 1522 | + } else |
|
| 1474 | 1523 | { |
| 1475 | 1524 | echo ' |
| 1476 | 1525 | <p>', $txt['errors_fixed'], '</p> |
@@ -1561,9 +1610,10 @@ discard block |
||
| 1561 | 1610 | <tr class="windowbg"> |
| 1562 | 1611 | <td class="equal_table">', $key, '</td>'; |
| 1563 | 1612 | |
| 1564 | - foreach ($setting as $key_lm => $value) |
|
| 1565 | - echo ' |
|
| 1613 | + foreach ($setting as $key_lm => $value) { |
|
| 1614 | + echo ' |
|
| 1566 | 1615 | <td class="equal_table">', $value, '</td>'; |
| 1616 | + } |
|
| 1567 | 1617 | |
| 1568 | 1618 | echo ' |
| 1569 | 1619 | </tr>'; |
@@ -1623,8 +1673,8 @@ discard block |
||
| 1623 | 1673 | { |
| 1624 | 1674 | global $context, $txt; |
| 1625 | 1675 | |
| 1626 | - if ($context['user']['is_admin']) |
|
| 1627 | - echo ' |
|
| 1676 | + if ($context['user']['is_admin']) { |
|
| 1677 | + echo ' |
|
| 1628 | 1678 | <span class="floatright admin_search"> |
| 1629 | 1679 | <span class="generic_icons filter centericon"></span> |
| 1630 | 1680 | <input type="search" name="search_term" value="', $txt['admin_search'], '" onclick="if (this.value == \'', $txt['admin_search'], '\') this.value = \'\';"> |
@@ -1635,6 +1685,7 @@ discard block |
||
| 1635 | 1685 | </select> |
| 1636 | 1686 | <input type="submit" name="search_go" id="search_go" value="', $txt['admin_search_go'], '" class="button"> |
| 1637 | 1687 | </span>'; |
| 1638 | -} |
|
| 1688 | + } |
|
| 1689 | + } |
|
| 1639 | 1690 | |
| 1640 | 1691 | ?> |
| 1641 | 1692 | \ No newline at end of file |
@@ -31,9 +31,10 @@ discard block |
||
| 31 | 31 | echo ' |
| 32 | 32 | <ul id="smf_slider" class="roundframe">'; |
| 33 | 33 | |
| 34 | - foreach ($context['news_lines'] as $news) |
|
| 35 | - echo ' |
|
| 34 | + foreach ($context['news_lines'] as $news) { |
|
| 35 | + echo ' |
|
| 36 | 36 | <li>', $news, '</li>'; |
| 37 | + } |
|
| 37 | 38 | |
| 38 | 39 | echo ' |
| 39 | 40 | </ul> |
@@ -65,8 +66,9 @@ discard block |
||
| 65 | 66 | foreach ($context['categories'] as $category) |
| 66 | 67 | { |
| 67 | 68 | // If theres no parent boards we can see, avoid showing an empty category (unless its collapsed) |
| 68 | - if (empty($category['boards']) && !$category['is_collapsed']) |
|
| 69 | - continue; |
|
| 69 | + if (empty($category['boards']) && !$category['is_collapsed']) { |
|
| 70 | + continue; |
|
| 71 | + } |
|
| 70 | 72 | |
| 71 | 73 | echo ' |
| 72 | 74 | <div class="main_container"> |
@@ -74,9 +76,10 @@ discard block |
||
| 74 | 76 | <h3 class="catbg">'; |
| 75 | 77 | |
| 76 | 78 | // If this category even can collapse, show a link to collapse it. |
| 77 | - if ($category['can_collapse']) |
|
| 78 | - echo ' |
|
| 79 | + if ($category['can_collapse']) { |
|
| 80 | + echo ' |
|
| 79 | 81 | <span id="category_', $category['id'], '_upshrink" class="', $category['is_collapsed'] ? 'toggle_down' : 'toggle_up', ' floatright" data-collapsed="', (int) $category['is_collapsed'], '" title="', !$category['is_collapsed'] ? $txt['hide_category'] : $txt['show_category'], '" style="display: none;"></span>'; |
| 82 | + } |
|
| 80 | 83 | |
| 81 | 84 | echo ' |
| 82 | 85 | ', $category['link'], ' |
@@ -106,10 +109,11 @@ discard block |
||
| 106 | 109 | </div>'; |
| 107 | 110 | |
| 108 | 111 | // Won't somebody think of the children! |
| 109 | - if (function_exists('template_bi_' . $board['type'] . '_children')) |
|
| 110 | - call_user_func('template_bi_' . $board['type'] . '_children', $board); |
|
| 111 | - else |
|
| 112 | - template_bi_board_children($board); |
|
| 112 | + if (function_exists('template_bi_' . $board['type'] . '_children')) { |
|
| 113 | + call_user_func('template_bi_' . $board['type'] . '_children', $board); |
|
| 114 | + } else { |
|
| 115 | + template_bi_board_children($board); |
|
| 116 | + } |
|
| 113 | 117 | |
| 114 | 118 | echo ' |
| 115 | 119 | </div><!-- #board_[id] -->'; |
@@ -124,12 +128,13 @@ discard block |
||
| 124 | 128 | </div><!-- #boardindex_table -->'; |
| 125 | 129 | |
| 126 | 130 | // Show the mark all as read button? |
| 127 | - if ($context['user']['is_logged'] && !empty($context['categories'])) |
|
| 128 | - echo ' |
|
| 131 | + if ($context['user']['is_logged'] && !empty($context['categories'])) { |
|
| 132 | + echo ' |
|
| 129 | 133 | <div class="mark_read"> |
| 130 | 134 | ', template_button_strip($context['mark_read_button'], 'right'), ' |
| 131 | 135 | </div>'; |
| 132 | -} |
|
| 136 | + } |
|
| 137 | + } |
|
| 133 | 138 | |
| 134 | 139 | /** |
| 135 | 140 | * Outputs the board icon for a standard board. |
@@ -173,18 +178,20 @@ discard block |
||
| 173 | 178 | </a>'; |
| 174 | 179 | |
| 175 | 180 | // Has it outstanding posts for approval? |
| 176 | - if ($board['can_approve_posts'] && ($board['unapproved_posts'] || $board['unapproved_topics'])) |
|
| 177 | - echo ' |
|
| 181 | + if ($board['can_approve_posts'] && ($board['unapproved_posts'] || $board['unapproved_topics'])) { |
|
| 182 | + echo ' |
|
| 178 | 183 | <a href="', $scripturl, '?action=moderate;area=postmod;sa=', ($board['unapproved_topics'] > 0 ? 'topics' : 'posts'), ';brd=', $board['id'], ';', $context['session_var'], '=', $context['session_id'], '" title="', sprintf($txt['unapproved_posts'], $board['unapproved_topics'], $board['unapproved_posts']), '" class="moderation_link">(!)</a>'; |
| 184 | + } |
|
| 179 | 185 | |
| 180 | 186 | echo ' |
| 181 | 187 | <p class="board_description">', $board['description'], '</p>'; |
| 182 | 188 | |
| 183 | 189 | // Show the "Moderators: ". Each has name, href, link, and id. (but we're gonna use link_moderators.) |
| 184 | - if (!empty($board['link_moderators'])) |
|
| 185 | - echo ' |
|
| 190 | + if (!empty($board['link_moderators'])) { |
|
| 191 | + echo ' |
|
| 186 | 192 | <p class="moderators">', count($board['link_moderators']) == 1 ? $txt['moderator'] : $txt['moderators'], ': ', implode(', ', $board['link_moderators']), '</p>'; |
| 187 | -} |
|
| 193 | + } |
|
| 194 | + } |
|
| 188 | 195 | |
| 189 | 196 | /** |
| 190 | 197 | * Outputs the board stats for a standard board. |
@@ -225,10 +232,11 @@ discard block |
||
| 225 | 232 | */ |
| 226 | 233 | function template_bi_board_lastpost($board) |
| 227 | 234 | { |
| 228 | - if (!empty($board['last_post']['id'])) |
|
| 229 | - echo ' |
|
| 235 | + if (!empty($board['last_post']['id'])) { |
|
| 236 | + echo ' |
|
| 230 | 237 | <p>', $board['last_post']['last_post_message'], '</p>'; |
| 231 | -} |
|
| 238 | + } |
|
| 239 | + } |
|
| 232 | 240 | |
| 233 | 241 | /** |
| 234 | 242 | * Outputs the board children for a standard board. |
@@ -248,14 +256,16 @@ discard block |
||
| 248 | 256 | id, name, description, new (is it new?), topics (#), posts (#), href, link, and last_post. */ |
| 249 | 257 | foreach ($board['children'] as $child) |
| 250 | 258 | { |
| 251 | - if (!$child['is_redirect']) |
|
| 252 | - $child['link'] = ''. ($child['new'] ? '<a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')"><span class="new_posts">' . $txt['new'] . '</span></a>' : '') . '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . '</a>'; |
|
| 253 | - else |
|
| 254 | - $child['link'] = '<a href="' . $child['href'] . '" title="' . comma_format($child['posts']) . ' ' . $txt['redirects'] . ' - ' . $child['short_description'] . '">' . $child['name'] . '</a>'; |
|
| 259 | + if (!$child['is_redirect']) { |
|
| 260 | + $child['link'] = ''. ($child['new'] ? '<a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')"><span class="new_posts">' . $txt['new'] . '</span></a>' : '') . '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . '</a>'; |
|
| 261 | + } else { |
|
| 262 | + $child['link'] = '<a href="' . $child['href'] . '" title="' . comma_format($child['posts']) . ' ' . $txt['redirects'] . ' - ' . $child['short_description'] . '">' . $child['name'] . '</a>'; |
|
| 263 | + } |
|
| 255 | 264 | |
| 256 | 265 | // Has it posts awaiting approval? |
| 257 | - if ($child['can_approve_posts'] && ($child['unapproved_posts'] || $child['unapproved_topics'])) |
|
| 258 | - $child['link'] .= ' <a href="' . $scripturl . '?action=moderate;area=postmod;sa=' . ($child['unapproved_topics'] > 0 ? 'topics' : 'posts') . ';brd=' . $child['id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" title="' . sprintf($txt['unapproved_posts'], $child['unapproved_topics'], $child['unapproved_posts']) . '" class="moderation_link">(!)</a>'; |
|
| 266 | + if ($child['can_approve_posts'] && ($child['unapproved_posts'] || $child['unapproved_topics'])) { |
|
| 267 | + $child['link'] .= ' <a href="' . $scripturl . '?action=moderate;area=postmod;sa=' . ($child['unapproved_topics'] > 0 ? 'topics' : 'posts') . ';brd=' . $child['id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" title="' . sprintf($txt['unapproved_posts'], $child['unapproved_topics'], $child['unapproved_posts']) . '" class="moderation_link">(!)</a>'; |
|
| 268 | + } |
|
| 259 | 269 | |
| 260 | 270 | $children[] = $child['new'] ? '<span class="strong">' . $child['link'] . '</span>' : '<span>' . $child['link'] . '</span>'; |
| 261 | 271 | } |
@@ -282,8 +292,9 @@ discard block |
||
| 282 | 292 | { |
| 283 | 293 | global $context, $options, $txt; |
| 284 | 294 | |
| 285 | - if (empty($context['info_center'])) |
|
| 286 | - return; |
|
| 295 | + if (empty($context['info_center'])) { |
|
| 296 | + return; |
|
| 297 | + } |
|
| 287 | 298 | |
| 288 | 299 | // Here's where the "Info Center" starts... |
| 289 | 300 | echo ' |
@@ -383,14 +394,15 @@ discard block |
||
| 383 | 394 | /* Each post in latest_posts has: |
| 384 | 395 | board (with an id, name, and link.), topic (the topic's id.), poster (with id, name, and link.), |
| 385 | 396 | subject, short_subject (shortened with...), time, link, and href. */ |
| 386 | - foreach ($context['latest_posts'] as $post) |
|
| 387 | - echo ' |
|
| 397 | + foreach ($context['latest_posts'] as $post) { |
|
| 398 | + echo ' |
|
| 388 | 399 | <tr class="windowbg"> |
| 389 | 400 | <td class="recentpost"><strong>', $post['link'], '</strong></td> |
| 390 | 401 | <td class="recentposter">', $post['poster']['link'], '</td> |
| 391 | 402 | <td class="recentboard">', $post['board']['link'], '</td> |
| 392 | 403 | <td class="recenttime">', $post['time'], '</td> |
| 393 | 404 | </tr>'; |
| 405 | + } |
|
| 394 | 406 | echo ' |
| 395 | 407 | </table>'; |
| 396 | 408 | } |
@@ -414,11 +426,12 @@ discard block |
||
| 414 | 426 | </div>'; |
| 415 | 427 | |
| 416 | 428 | // Holidays like "Christmas", "Chanukah", and "We Love [Unknown] Day" :P |
| 417 | - if (!empty($context['calendar_holidays'])) |
|
| 418 | - echo ' |
|
| 429 | + if (!empty($context['calendar_holidays'])) { |
|
| 430 | + echo ' |
|
| 419 | 431 | <p class="inline holiday"> |
| 420 | 432 | <span>', $txt['calendar_prompt'], '</span> ', implode(', ', $context['calendar_holidays']), ' |
| 421 | 433 | </p>'; |
| 434 | + } |
|
| 422 | 435 | |
| 423 | 436 | // People's birthdays. Like mine. And yours, I guess. Kidding. |
| 424 | 437 | if (!empty($context['calendar_birthdays'])) |
@@ -428,9 +441,10 @@ discard block |
||
| 428 | 441 | <span class="birthday">', $context['calendar_only_today'] ? $txt['birthdays'] : $txt['birthdays_upcoming'], '</span>'; |
| 429 | 442 | |
| 430 | 443 | // Each member in calendar_birthdays has: id, name (person), age (if they have one set?), is_last. (last in list?), and is_today (birthday is today?) |
| 431 | - foreach ($context['calendar_birthdays'] as $member) |
|
| 432 | - echo ' |
|
| 444 | + foreach ($context['calendar_birthdays'] as $member) { |
|
| 445 | + echo ' |
|
| 433 | 446 | <a href="', $scripturl, '?action=profile;u=', $member['id'], '">', $member['is_today'] ? '<strong class="fix_rtl_names">' : '', $member['name'], $member['is_today'] ? '</strong>' : '', isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a>', $member['is_last'] ? '' : ', '; |
| 447 | + } |
|
| 434 | 448 | |
| 435 | 449 | echo ' |
| 436 | 450 | </p>'; |
@@ -445,9 +459,10 @@ discard block |
||
| 445 | 459 | |
| 446 | 460 | // Each event in calendar_events should have: |
| 447 | 461 | // title, href, is_last, can_edit (are they allowed?), modify_href, and is_today. |
| 448 | - foreach ($context['calendar_events'] as $event) |
|
| 449 | - echo ' |
|
| 462 | + foreach ($context['calendar_events'] as $event) { |
|
| 463 | + echo ' |
|
| 450 | 464 | ', $event['can_edit'] ? '<a href="' . $event['modify_href'] . '" title="' . $txt['calendar_edit'] . '"><span class="generic_icons calendar_modify"></span></a> ' : '', $event['href'] == '' ? '' : '<a href="' . $event['href'] . '">', $event['is_today'] ? '<strong>' . $event['title'] . '</strong>' : $event['title'], $event['href'] == '' ? '' : '</a>', $event['is_last'] ? '<br>' : ', '; |
| 465 | + } |
|
| 451 | 466 | echo ' |
| 452 | 467 | </p>'; |
| 453 | 468 | } |
@@ -493,17 +508,21 @@ discard block |
||
| 493 | 508 | // Handle hidden users and buddies. |
| 494 | 509 | $bracketList = array(); |
| 495 | 510 | |
| 496 | - if ($context['show_buddies']) |
|
| 497 | - $bracketList[] = comma_format($context['num_buddies']) . ' ' . ($context['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']); |
|
| 511 | + if ($context['show_buddies']) { |
|
| 512 | + $bracketList[] = comma_format($context['num_buddies']) . ' ' . ($context['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']); |
|
| 513 | + } |
|
| 498 | 514 | |
| 499 | - if (!empty($context['num_spiders'])) |
|
| 500 | - $bracketList[] = comma_format($context['num_spiders']) . ' ' . ($context['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']); |
|
| 515 | + if (!empty($context['num_spiders'])) { |
|
| 516 | + $bracketList[] = comma_format($context['num_spiders']) . ' ' . ($context['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']); |
|
| 517 | + } |
|
| 501 | 518 | |
| 502 | - if (!empty($context['num_users_hidden'])) |
|
| 503 | - $bracketList[] = comma_format($context['num_users_hidden']) . ' ' . ($context['num_spiders'] == 1 ? $txt['hidden'] : $txt['hidden_s']); |
|
| 519 | + if (!empty($context['num_users_hidden'])) { |
|
| 520 | + $bracketList[] = comma_format($context['num_users_hidden']) . ' ' . ($context['num_spiders'] == 1 ? $txt['hidden'] : $txt['hidden_s']); |
|
| 521 | + } |
|
| 504 | 522 | |
| 505 | - if (!empty($bracketList)) |
|
| 506 | - echo ' (' . implode(', ', $bracketList) . ')'; |
|
| 523 | + if (!empty($bracketList)) { |
|
| 524 | + echo ' (' . implode(', ', $bracketList) . ')'; |
|
| 525 | + } |
|
| 507 | 526 | |
| 508 | 527 | echo $context['show_who'] ? '</a>' : '', ' |
| 509 | 528 | |
@@ -517,9 +536,10 @@ discard block |
||
| 517 | 536 | ', sprintf($txt['users_active'], $modSettings['lastActive']), ': ', implode(', ', $context['list_users_online']); |
| 518 | 537 | |
| 519 | 538 | // Showing membergroups? |
| 520 | - if (!empty($settings['show_group_key']) && !empty($context['membergroups'])) |
|
| 521 | - echo ' |
|
| 539 | + if (!empty($settings['show_group_key']) && !empty($context['membergroups'])) { |
|
| 540 | + echo ' |
|
| 522 | 541 | <span class="membergroups">' . implode(', ', $context['membergroups']) . '</span>'; |
| 542 | + } |
|
| 523 | 543 | } |
| 524 | 544 | |
| 525 | 545 | echo ' |
@@ -22,27 +22,31 @@ discard block |
||
| 22 | 22 | // Get a shortcut to the current list. |
| 23 | 23 | $list_id = $list_id === null ? (!empty($context['default_list']) ? $context['default_list'] : '') : $list_id; |
| 24 | 24 | |
| 25 | - if (empty($list_id) || empty($context[$list_id])) |
|
| 26 | - return; |
|
| 25 | + if (empty($list_id) || empty($context[$list_id])) { |
|
| 26 | + return; |
|
| 27 | + } |
|
| 27 | 28 | |
| 28 | 29 | $cur_list = &$context[$list_id]; |
| 29 | 30 | |
| 30 | 31 | // These are the main tabs that is used all around the template. |
| 31 | - if (isset($cur_list['list_menu'], $cur_list['list_menu']['show_on']) && ($cur_list['list_menu']['show_on'] == 'both' || $cur_list['list_menu']['show_on'] == 'top')) |
|
| 32 | - template_create_list_menu($cur_list['list_menu'], 'top'); |
|
| 32 | + if (isset($cur_list['list_menu'], $cur_list['list_menu']['show_on']) && ($cur_list['list_menu']['show_on'] == 'both' || $cur_list['list_menu']['show_on'] == 'top')) { |
|
| 33 | + template_create_list_menu($cur_list['list_menu'], 'top'); |
|
| 34 | + } |
|
| 33 | 35 | |
| 34 | - if (isset($cur_list['form'])) |
|
| 35 | - echo ' |
|
| 36 | + if (isset($cur_list['form'])) { |
|
| 37 | + echo ' |
|
| 36 | 38 | <form action="', $cur_list['form']['href'], '" method="post"', empty($cur_list['form']['name']) ? '' : ' name="' . $cur_list['form']['name'] . '" id="' . $cur_list['form']['name'] . '"', ' accept-charset="', $context['character_set'], '">'; |
| 39 | + } |
|
| 37 | 40 | |
| 38 | 41 | // Show the title of the table (if any). |
| 39 | - if (!empty($cur_list['title'])) |
|
| 40 | - echo ' |
|
| 42 | + if (!empty($cur_list['title'])) { |
|
| 43 | + echo ' |
|
| 41 | 44 | <div class="cat_bar"> |
| 42 | 45 | <h3 class="catbg"> |
| 43 | 46 | ', $cur_list['title'], ' |
| 44 | 47 | </h3> |
| 45 | 48 | </div>'; |
| 49 | + } |
|
| 46 | 50 | |
| 47 | 51 | if (isset($cur_list['additional_rows']['after_title'])) |
| 48 | 52 | { |
@@ -55,20 +59,23 @@ discard block |
||
| 55 | 59 | </div>'; |
| 56 | 60 | } |
| 57 | 61 | |
| 58 | - if (isset($cur_list['additional_rows']['top_of_list'])) |
|
| 59 | - template_additional_rows('top_of_list', $cur_list); |
|
| 62 | + if (isset($cur_list['additional_rows']['top_of_list'])) { |
|
| 63 | + template_additional_rows('top_of_list', $cur_list); |
|
| 64 | + } |
|
| 60 | 65 | |
| 61 | 66 | if ((!empty($cur_list['items_per_page']) && !empty($cur_list['page_index'])) || isset($cur_list['additional_rows']['above_column_headers'])) |
| 62 | 67 | { |
| 63 | 68 | // Show the page index (if this list doesn't intend to show all items). |
| 64 | - if (!empty($cur_list['items_per_page']) && !empty($cur_list['page_index'])) |
|
| 65 | - echo ' |
|
| 69 | + if (!empty($cur_list['items_per_page']) && !empty($cur_list['page_index'])) { |
|
| 70 | + echo ' |
|
| 66 | 71 | <div class="floatleft"> |
| 67 | 72 | <div class="pagesection">', $cur_list['page_index'], '</div> |
| 68 | 73 | </div>'; |
| 74 | + } |
|
| 69 | 75 | |
| 70 | - if (isset($cur_list['additional_rows']['above_column_headers'])) |
|
| 71 | - template_additional_rows('above_column_headers', $cur_list); |
|
| 76 | + if (isset($cur_list['additional_rows']['above_column_headers'])) { |
|
| 77 | + template_additional_rows('above_column_headers', $cur_list); |
|
| 78 | + } |
|
| 72 | 79 | } |
| 73 | 80 | |
| 74 | 81 | echo ' |
@@ -83,11 +90,12 @@ discard block |
||
| 83 | 90 | <tr class="title_bar">'; |
| 84 | 91 | |
| 85 | 92 | // Loop through each column and add a table header. |
| 86 | - foreach ($cur_list['headers'] as $col_header) |
|
| 87 | - echo ' |
|
| 93 | + foreach ($cur_list['headers'] as $col_header) { |
|
| 94 | + echo ' |
|
| 88 | 95 | <th scope="col" id="header_', $list_id, '_', $col_header['id'], '"', empty($col_header['class']) ? '' : ' class="' . $col_header['class'] . '"', empty($col_header['style']) ? '' : ' style="' . $col_header['style'] . '"', empty($col_header['colspan']) ? '' : ' colspan="' . $col_header['colspan'] . '"', '> |
| 89 | 96 | ', empty($col_header['href']) ? '' : '<a href="' . $col_header['href'] . '" rel="nofollow">', empty($col_header['label']) ? '' : $col_header['label'], empty($col_header['href']) ? '' : (empty($col_header['sort_image']) ? '</a>' : ' <span class="generic_icons sort_' . $col_header['sort_image'] . '"></span></a>'), ' |
| 90 | 97 | </th>'; |
| 98 | + } |
|
| 91 | 99 | |
| 92 | 100 | echo ' |
| 93 | 101 | </tr> |
@@ -98,13 +106,14 @@ discard block |
||
| 98 | 106 | <tbody>'; |
| 99 | 107 | |
| 100 | 108 | // Show a nice message informing there are no items in this list. |
| 101 | - if (empty($cur_list['rows']) && !empty($cur_list['no_items_label'])) |
|
| 102 | - echo ' |
|
| 109 | + if (empty($cur_list['rows']) && !empty($cur_list['no_items_label'])) { |
|
| 110 | + echo ' |
|
| 103 | 111 | <tr class="windowbg"> |
| 104 | 112 | <td colspan="', $cur_list['num_columns'], '" class="', !empty($cur_list['no_items_align']) ? $cur_list['no_items_align'] : 'centertext', '"> |
| 105 | 113 | ', $cur_list['no_items_label'], ' |
| 106 | 114 | </td> |
| 107 | 115 | </tr>'; |
| 116 | + } |
|
| 108 | 117 | |
| 109 | 118 | // Show the list rows. |
| 110 | 119 | elseif (!empty($cur_list['rows'])) |
@@ -114,12 +123,13 @@ discard block |
||
| 114 | 123 | echo ' |
| 115 | 124 | <tr class="windowbg', empty($row['class']) ? '' : ' ' . $row['class'], '"', empty($row['style']) ? '' : ' style="' . $row['style'] . '"', ' id="list_', $list_id, '_', $id, '">'; |
| 116 | 125 | |
| 117 | - if (!empty($row['data'])) |
|
| 118 | - foreach ($row['data'] as $row_data) |
|
| 126 | + if (!empty($row['data'])) { |
|
| 127 | + foreach ($row['data'] as $row_data) |
|
| 119 | 128 | echo ' |
| 120 | 129 | <td', empty($row_data['class']) ? '' : ' class="' . $row_data['class'] . '"', empty($row_data['style']) ? '' : ' style="' . $row_data['style'] . '"', '> |
| 121 | 130 | ', $row_data['value'], ' |
| 122 | 131 | </td>'; |
| 132 | + } |
|
| 123 | 133 | |
| 124 | 134 | echo ' |
| 125 | 135 | </tr>'; |
@@ -136,46 +146,53 @@ discard block |
||
| 136 | 146 | <div class="flow_auto">'; |
| 137 | 147 | |
| 138 | 148 | // Show the page index (if this list doesn't intend to show all items). |
| 139 | - if (!empty($cur_list['items_per_page']) && !empty($cur_list['page_index'])) |
|
| 140 | - echo ' |
|
| 149 | + if (!empty($cur_list['items_per_page']) && !empty($cur_list['page_index'])) { |
|
| 150 | + echo ' |
|
| 141 | 151 | <div class="floatleft"> |
| 142 | 152 | <div class="pagesection">', $cur_list['page_index'], '</div> |
| 143 | 153 | </div>'; |
| 154 | + } |
|
| 144 | 155 | |
| 145 | - if (isset($cur_list['additional_rows']['below_table_data'])) |
|
| 146 | - template_additional_rows('below_table_data', $cur_list); |
|
| 156 | + if (isset($cur_list['additional_rows']['below_table_data'])) { |
|
| 157 | + template_additional_rows('below_table_data', $cur_list); |
|
| 158 | + } |
|
| 147 | 159 | |
| 148 | 160 | echo ' |
| 149 | 161 | </div>'; |
| 150 | 162 | } |
| 151 | 163 | |
| 152 | - if (isset($cur_list['additional_rows']['bottom_of_list'])) |
|
| 153 | - template_additional_rows('bottom_of_list', $cur_list); |
|
| 164 | + if (isset($cur_list['additional_rows']['bottom_of_list'])) { |
|
| 165 | + template_additional_rows('bottom_of_list', $cur_list); |
|
| 166 | + } |
|
| 154 | 167 | |
| 155 | 168 | if (isset($cur_list['form'])) |
| 156 | 169 | { |
| 157 | - foreach ($cur_list['form']['hidden_fields'] as $name => $value) |
|
| 158 | - echo ' |
|
| 170 | + foreach ($cur_list['form']['hidden_fields'] as $name => $value) { |
|
| 171 | + echo ' |
|
| 159 | 172 | <input type="hidden" name="', $name, '" value="', $value, '">'; |
| 173 | + } |
|
| 160 | 174 | |
| 161 | - if (isset($cur_list['form']['token'])) |
|
| 162 | - echo ' |
|
| 175 | + if (isset($cur_list['form']['token'])) { |
|
| 176 | + echo ' |
|
| 163 | 177 | <input type="hidden" name="', $context[$cur_list['form']['token'] . '_token_var'], '" value="', $context[$cur_list['form']['token'] . '_token'], '">'; |
| 178 | + } |
|
| 164 | 179 | |
| 165 | 180 | echo ' |
| 166 | 181 | </form>'; |
| 167 | 182 | } |
| 168 | 183 | |
| 169 | 184 | // Tabs at the bottom. Usually bottom aligned. |
| 170 | - if (isset($cur_list['list_menu'], $cur_list['list_menu']['show_on']) && ($cur_list['list_menu']['show_on'] == 'both' || $cur_list['list_menu']['show_on'] == 'bottom')) |
|
| 171 | - template_create_list_menu($cur_list['list_menu'], 'bottom'); |
|
| 185 | + if (isset($cur_list['list_menu'], $cur_list['list_menu']['show_on']) && ($cur_list['list_menu']['show_on'] == 'both' || $cur_list['list_menu']['show_on'] == 'bottom')) { |
|
| 186 | + template_create_list_menu($cur_list['list_menu'], 'bottom'); |
|
| 187 | + } |
|
| 172 | 188 | |
| 173 | - if (isset($cur_list['javascript'])) |
|
| 174 | - echo ' |
|
| 189 | + if (isset($cur_list['javascript'])) { |
|
| 190 | + echo ' |
|
| 175 | 191 | <script> |
| 176 | 192 | ', $cur_list['javascript'], ' |
| 177 | 193 | </script>'; |
| 178 | -} |
|
| 194 | + } |
|
| 195 | + } |
|
| 179 | 196 | |
| 180 | 197 | /** |
| 181 | 198 | * This template displays additional rows above or below the list. |
@@ -185,12 +202,13 @@ discard block |
||
| 185 | 202 | */ |
| 186 | 203 | function template_additional_rows($row_position, $cur_list) |
| 187 | 204 | { |
| 188 | - foreach ($cur_list['additional_rows'][$row_position] as $row) |
|
| 189 | - echo ' |
|
| 205 | + foreach ($cur_list['additional_rows'][$row_position] as $row) { |
|
| 206 | + echo ' |
|
| 190 | 207 | <div class="additional_row', empty($row['class']) ? '' : ' ' . $row['class'], '"', empty($row['style']) ? '' : ' style="' . $row['style'] . '"', '> |
| 191 | 208 | ', $row['value'], ' |
| 192 | 209 | </div>'; |
| 193 | -} |
|
| 210 | + } |
|
| 211 | + } |
|
| 194 | 212 | |
| 195 | 213 | /** |
| 196 | 214 | * This function creates a menu |
@@ -249,18 +267,19 @@ discard block |
||
| 249 | 267 | |
| 250 | 268 | foreach ($list_menu['links'] as $link) |
| 251 | 269 | { |
| 252 | - if ($link['is_selected']) |
|
| 253 | - echo ' |
|
| 270 | + if ($link['is_selected']) { |
|
| 271 | + echo ' |
|
| 254 | 272 | <td class="', $direction == 'top' ? 'mirror' : 'main', 'tab_active_', $first, '"></td> |
| 255 | 273 | <td class="', $direction == 'top' ? 'mirrortab' : 'maintab', '_active_back"> |
| 256 | 274 | <a href="', $link['href'], '">', $link['label'], '</a> |
| 257 | 275 | </td> |
| 258 | 276 | <td class="', $direction == 'top' ? 'mirror' : 'main', 'tab_active_', $last, '"></td>'; |
| 259 | - else |
|
| 260 | - echo ' |
|
| 277 | + } else { |
|
| 278 | + echo ' |
|
| 261 | 279 | <td class="', $direction == 'top' ? 'mirror' : 'main', 'tab_back"> |
| 262 | 280 | <a href="', $link['href'], '">', $link['label'], '</a> |
| 263 | 281 | </td>'; |
| 282 | + } |
|
| 264 | 283 | } |
| 265 | 284 | |
| 266 | 285 | echo ' |
@@ -271,12 +290,12 @@ discard block |
||
| 271 | 290 | <td></td>' : '', ' |
| 272 | 291 | </tr> |
| 273 | 292 | </table>'; |
| 274 | - } |
|
| 275 | - elseif (isset($list_menu['style']) && $list_menu['style'] == 'buttons') |
|
| 293 | + } elseif (isset($list_menu['style']) && $list_menu['style'] == 'buttons') |
|
| 276 | 294 | { |
| 277 | 295 | $links = array(); |
| 278 | - foreach ($list_menu['links'] as $link) |
|
| 279 | - $links[] = '<a href="' . $link['href'] . '">' . $link['label'] . '</a>'; |
|
| 296 | + foreach ($list_menu['links'] as $link) { |
|
| 297 | + $links[] = '<a href="' . $link['href'] . '">' . $link['label'] . '</a>'; |
|
| 298 | + } |
|
| 280 | 299 | |
| 281 | 300 | echo ' |
| 282 | 301 | <table style="margin-', $list_menu['position'], ': 10px; width: 100%;"> |
@@ -15,8 +15,9 @@ discard block |
||
| 15 | 15 | * @version 2.1 Beta 4 |
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | -if (!defined('SMF')) |
|
| 18 | +if (!defined('SMF')) { |
|
| 19 | 19 | die('No direct access...'); |
| 20 | +} |
|
| 20 | 21 | |
| 21 | 22 | /** |
| 22 | 23 | * This helps organize things... |
@@ -37,13 +38,14 @@ discard block |
||
| 37 | 38 | |
| 38 | 39 | loadLanguage('PersonalMessage+Drafts'); |
| 39 | 40 | |
| 40 | - if (!isset($_REQUEST['xml'])) |
|
| 41 | - loadTemplate('PersonalMessage'); |
|
| 41 | + if (!isset($_REQUEST['xml'])) { |
|
| 42 | + loadTemplate('PersonalMessage'); |
|
| 43 | + } |
|
| 42 | 44 | |
| 43 | 45 | // Load up the members maximum message capacity. |
| 44 | - if ($user_info['is_admin']) |
|
| 45 | - $context['message_limit'] = 0; |
|
| 46 | - elseif (($context['message_limit'] = cache_get_data('msgLimit:' . $user_info['id'], 360)) === null) |
|
| 46 | + if ($user_info['is_admin']) { |
|
| 47 | + $context['message_limit'] = 0; |
|
| 48 | + } elseif (($context['message_limit'] = cache_get_data('msgLimit:' . $user_info['id'], 360)) === null) |
|
| 47 | 49 | { |
| 48 | 50 | // @todo Why do we do this? It seems like if they have any limit we should use it. |
| 49 | 51 | $request = $smcFunc['db_query']('', ' |
@@ -78,8 +80,9 @@ discard block |
||
| 78 | 80 | } |
| 79 | 81 | |
| 80 | 82 | // a previous message was sent successfully? show a small indication. |
| 81 | - if (isset($_GET['done']) && ($_GET['done'] == 'sent')) |
|
| 82 | - $context['pm_sent'] = true; |
|
| 83 | + if (isset($_GET['done']) && ($_GET['done'] == 'sent')) { |
|
| 84 | + $context['pm_sent'] = true; |
|
| 85 | + } |
|
| 83 | 86 | |
| 84 | 87 | $context['labels'] = array(); |
| 85 | 88 | |
@@ -210,11 +213,11 @@ discard block |
||
| 210 | 213 | { |
| 211 | 214 | $_REQUEST['sa'] = ''; |
| 212 | 215 | MessageFolder(); |
| 213 | - } |
|
| 214 | - else |
|
| 216 | + } else |
|
| 215 | 217 | { |
| 216 | - if (!isset($_REQUEST['xml']) && $_REQUEST['sa'] != 'popup') |
|
| 217 | - messageIndexBar($_REQUEST['sa']); |
|
| 218 | + if (!isset($_REQUEST['xml']) && $_REQUEST['sa'] != 'popup') { |
|
| 219 | + messageIndexBar($_REQUEST['sa']); |
|
| 220 | + } |
|
| 218 | 221 | |
| 219 | 222 | call_helper($subActions[$_REQUEST['sa']]); |
| 220 | 223 | } |
@@ -291,16 +294,17 @@ discard block |
||
| 291 | 294 | ); |
| 292 | 295 | |
| 293 | 296 | // Handle labels. |
| 294 | - if (empty($context['currently_using_labels'])) |
|
| 295 | - unset($pm_areas['labels']); |
|
| 296 | - else |
|
| 297 | + if (empty($context['currently_using_labels'])) { |
|
| 298 | + unset($pm_areas['labels']); |
|
| 299 | + } else |
|
| 297 | 300 | { |
| 298 | 301 | // Note we send labels by id as it will have less problems in the querystring. |
| 299 | 302 | $unread_in_labels = 0; |
| 300 | 303 | foreach ($context['labels'] as $label) |
| 301 | 304 | { |
| 302 | - if ($label['id'] == -1) |
|
| 303 | - continue; |
|
| 305 | + if ($label['id'] == -1) { |
|
| 306 | + continue; |
|
| 307 | + } |
|
| 304 | 308 | |
| 305 | 309 | // Count the amount of unread items in labels. |
| 306 | 310 | $unread_in_labels += $label['unread_messages']; |
@@ -314,8 +318,9 @@ discard block |
||
| 314 | 318 | ); |
| 315 | 319 | } |
| 316 | 320 | |
| 317 | - if (!empty($unread_in_labels)) |
|
| 318 | - $pm_areas['labels']['title'] .= ' <span class="amt">' . $unread_in_labels . '</span>'; |
|
| 321 | + if (!empty($unread_in_labels)) { |
|
| 322 | + $pm_areas['labels']['title'] .= ' <span class="amt">' . $unread_in_labels . '</span>'; |
|
| 323 | + } |
|
| 319 | 324 | } |
| 320 | 325 | |
| 321 | 326 | $pm_areas['folders']['areas']['inbox']['unread_messages'] = &$context['labels'][-1]['unread_messages']; |
@@ -353,8 +358,9 @@ discard block |
||
| 353 | 358 | unset($pm_areas); |
| 354 | 359 | |
| 355 | 360 | // No menu means no access. |
| 356 | - if (!$pm_include_data && (!$user_info['is_guest'] || validateSession())) |
|
| 357 | - fatal_lang_error('no_access', false); |
|
| 361 | + if (!$pm_include_data && (!$user_info['is_guest'] || validateSession())) { |
|
| 362 | + fatal_lang_error('no_access', false); |
|
| 363 | + } |
|
| 358 | 364 | |
| 359 | 365 | // Make a note of the Unique ID for this menu. |
| 360 | 366 | $context['pm_menu_id'] = $context['max_menu_id']; |
@@ -365,9 +371,10 @@ discard block |
||
| 365 | 371 | $context['menu_item_selected'] = $current_area; |
| 366 | 372 | |
| 367 | 373 | // Set the template for this area and add the profile layer. |
| 368 | - if (!isset($_REQUEST['xml'])) |
|
| 369 | - $context['template_layers'][] = 'pm'; |
|
| 370 | -} |
|
| 374 | + if (!isset($_REQUEST['xml'])) { |
|
| 375 | + $context['template_layers'][] = 'pm'; |
|
| 376 | + } |
|
| 377 | + } |
|
| 371 | 378 | |
| 372 | 379 | /** |
| 373 | 380 | * The popup for when we ask for the popup from the user. |
@@ -399,8 +406,9 @@ discard block |
||
| 399 | 406 | ) |
| 400 | 407 | ); |
| 401 | 408 | $pms = array(); |
| 402 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 403 | - $pms[] = $row[0]; |
|
| 409 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 410 | + $pms[] = $row[0]; |
|
| 411 | + } |
|
| 404 | 412 | $smcFunc['db_free_result']($request); |
| 405 | 413 | |
| 406 | 414 | if (!empty($pms)) |
@@ -428,8 +436,9 @@ discard block |
||
| 428 | 436 | ); |
| 429 | 437 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 430 | 438 | { |
| 431 | - if (!empty($row['id_member_from'])) |
|
| 432 | - $senders[] = $row['id_member_from']; |
|
| 439 | + if (!empty($row['id_member_from'])) { |
|
| 440 | + $senders[] = $row['id_member_from']; |
|
| 441 | + } |
|
| 433 | 442 | |
| 434 | 443 | $row['replied_to_you'] = $row['id_pm'] != $row['id_pm_head']; |
| 435 | 444 | $row['time'] = timeformat($row['timestamp']); |
@@ -439,13 +448,15 @@ discard block |
||
| 439 | 448 | $smcFunc['db_free_result']($request); |
| 440 | 449 | |
| 441 | 450 | $senders = loadMemberData($senders); |
| 442 | - foreach ($senders as $member) |
|
| 443 | - loadMemberContext($member); |
|
| 451 | + foreach ($senders as $member) { |
|
| 452 | + loadMemberContext($member); |
|
| 453 | + } |
|
| 444 | 454 | |
| 445 | 455 | // Having loaded everyone, attach them to the PMs. |
| 446 | - foreach ($context['unread_pms'] as $id_pm => $details) |
|
| 447 | - if (!empty($memberContext[$details['id_member_from']])) |
|
| 456 | + foreach ($context['unread_pms'] as $id_pm => $details) { |
|
| 457 | + if (!empty($memberContext[$details['id_member_from']])) |
|
| 448 | 458 | $context['unread_pms'][$id_pm]['member'] = &$memberContext[$details['id_member_from']]; |
| 459 | + } |
|
| 449 | 460 | } |
| 450 | 461 | } |
| 451 | 462 | |
@@ -465,12 +476,13 @@ discard block |
||
| 465 | 476 | } |
| 466 | 477 | |
| 467 | 478 | // Make sure the starting location is valid. |
| 468 | - if (isset($_GET['start']) && $_GET['start'] != 'new') |
|
| 469 | - $_GET['start'] = (int) $_GET['start']; |
|
| 470 | - elseif (!isset($_GET['start']) && !empty($options['view_newest_pm_first'])) |
|
| 471 | - $_GET['start'] = 0; |
|
| 472 | - else |
|
| 473 | - $_GET['start'] = 'new'; |
|
| 479 | + if (isset($_GET['start']) && $_GET['start'] != 'new') { |
|
| 480 | + $_GET['start'] = (int) $_GET['start']; |
|
| 481 | + } elseif (!isset($_GET['start']) && !empty($options['view_newest_pm_first'])) { |
|
| 482 | + $_GET['start'] = 0; |
|
| 483 | + } else { |
|
| 484 | + $_GET['start'] = 'new'; |
|
| 485 | + } |
|
| 474 | 486 | |
| 475 | 487 | // Set up some basic theme stuff. |
| 476 | 488 | $context['from_or_to'] = $context['folder'] != 'sent' ? 'from' : 'to'; |
@@ -487,8 +499,7 @@ discard block |
||
| 487 | 499 | { |
| 488 | 500 | $labelQuery = ' |
| 489 | 501 | AND pmr.in_inbox = 1'; |
| 490 | - } |
|
| 491 | - elseif ($context['folder'] != 'sent') |
|
| 502 | + } elseif ($context['folder'] != 'sent') |
|
| 492 | 503 | { |
| 493 | 504 | $labelJoin = ' |
| 494 | 505 | INNER JOIN {db_prefix}pm_labeled_messages AS pl ON (pl.id_pm = pmr.id_pm)'; |
@@ -530,22 +541,24 @@ discard block |
||
| 530 | 541 | $txt['delete_all'] = str_replace('PMBOX', $pmbox, $txt['delete_all']); |
| 531 | 542 | |
| 532 | 543 | // Now, build the link tree! |
| 533 | - if ($context['current_label_id'] == -1) |
|
| 534 | - $context['linktree'][] = array( |
|
| 544 | + if ($context['current_label_id'] == -1) { |
|
| 545 | + $context['linktree'][] = array( |
|
| 535 | 546 | 'url' => $scripturl . '?action=pm;f=' . $context['folder'], |
| 536 | 547 | 'name' => $pmbox |
| 537 | 548 | ); |
| 549 | + } |
|
| 538 | 550 | |
| 539 | 551 | // Build it further for a label. |
| 540 | - if ($context['current_label_id'] != -1) |
|
| 541 | - $context['linktree'][] = array( |
|
| 552 | + if ($context['current_label_id'] != -1) { |
|
| 553 | + $context['linktree'][] = array( |
|
| 542 | 554 | 'url' => $scripturl . '?action=pm;f=' . $context['folder'] . ';l=' . $context['current_label_id'], |
| 543 | 555 | 'name' => $txt['pm_current_label'] . ': ' . $context['current_label'] |
| 544 | 556 | ); |
| 557 | + } |
|
| 545 | 558 | |
| 546 | 559 | // Figure out how many messages there are. |
| 547 | - if ($context['folder'] == 'sent') |
|
| 548 | - $request = $smcFunc['db_query']('', ' |
|
| 560 | + if ($context['folder'] == 'sent') { |
|
| 561 | + $request = $smcFunc['db_query']('', ' |
|
| 549 | 562 | SELECT COUNT(' . ($context['display_mode'] == 2 ? 'DISTINCT pm.id_pm_head' : '*') . ') |
| 550 | 563 | FROM {db_prefix}personal_messages AS pm |
| 551 | 564 | WHERE pm.id_member_from = {int:current_member} |
@@ -555,8 +568,8 @@ discard block |
||
| 555 | 568 | 'not_deleted' => 0, |
| 556 | 569 | ) |
| 557 | 570 | ); |
| 558 | - else |
|
| 559 | - $request = $smcFunc['db_query']('', ' |
|
| 571 | + } else { |
|
| 572 | + $request = $smcFunc['db_query']('', ' |
|
| 560 | 573 | SELECT COUNT(' . ($context['display_mode'] == 2 ? 'DISTINCT pm.id_pm_head' : '*') . ') |
| 561 | 574 | FROM {db_prefix}pm_recipients AS pmr' . ($context['display_mode'] == 2 ? ' |
| 562 | 575 | INNER JOIN {db_prefix}personal_messages AS pm ON (pm.id_pm = pmr.id_pm)' : '') . $labelJoin . ' |
@@ -567,6 +580,7 @@ discard block |
||
| 567 | 580 | 'not_deleted' => 0, |
| 568 | 581 | ) |
| 569 | 582 | ); |
| 583 | + } |
|
| 570 | 584 | list ($max_messages) = $smcFunc['db_fetch_row']($request); |
| 571 | 585 | $smcFunc['db_free_result']($request); |
| 572 | 586 | |
@@ -575,10 +589,11 @@ discard block |
||
| 575 | 589 | $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages']; |
| 576 | 590 | |
| 577 | 591 | // Start on the last page. |
| 578 | - if (!is_numeric($_GET['start']) || $_GET['start'] >= $max_messages) |
|
| 579 | - $_GET['start'] = ($max_messages - 1) - (($max_messages - 1) % $maxPerPage); |
|
| 580 | - elseif ($_GET['start'] < 0) |
|
| 581 | - $_GET['start'] = 0; |
|
| 592 | + if (!is_numeric($_GET['start']) || $_GET['start'] >= $max_messages) { |
|
| 593 | + $_GET['start'] = ($max_messages - 1) - (($max_messages - 1) % $maxPerPage); |
|
| 594 | + } elseif ($_GET['start'] < 0) { |
|
| 595 | + $_GET['start'] = 0; |
|
| 596 | + } |
|
| 582 | 597 | |
| 583 | 598 | // ... but wait - what if we want to start from a specific message? |
| 584 | 599 | if (isset($_GET['pmid'])) |
@@ -586,19 +601,21 @@ discard block |
||
| 586 | 601 | $pmID = (int) $_GET['pmid']; |
| 587 | 602 | |
| 588 | 603 | // Make sure you have access to this PM. |
| 589 | - if (!isAccessiblePM($pmID, $context['folder'] == 'sent' ? 'outbox' : 'inbox')) |
|
| 590 | - fatal_lang_error('no_access', false); |
|
| 604 | + if (!isAccessiblePM($pmID, $context['folder'] == 'sent' ? 'outbox' : 'inbox')) { |
|
| 605 | + fatal_lang_error('no_access', false); |
|
| 606 | + } |
|
| 591 | 607 | |
| 592 | 608 | $context['current_pm'] = $pmID; |
| 593 | 609 | |
| 594 | 610 | // With only one page of PM's we're gonna want page 1. |
| 595 | - if ($max_messages <= $maxPerPage) |
|
| 596 | - $_GET['start'] = 0; |
|
| 611 | + if ($max_messages <= $maxPerPage) { |
|
| 612 | + $_GET['start'] = 0; |
|
| 613 | + } |
|
| 597 | 614 | // If we pass kstart we assume we're in the right place. |
| 598 | 615 | elseif (!isset($_GET['kstart'])) |
| 599 | 616 | { |
| 600 | - if ($context['folder'] == 'sent') |
|
| 601 | - $request = $smcFunc['db_query']('', ' |
|
| 617 | + if ($context['folder'] == 'sent') { |
|
| 618 | + $request = $smcFunc['db_query']('', ' |
|
| 602 | 619 | SELECT COUNT(' . ($context['display_mode'] == 2 ? 'DISTINCT pm.id_pm_head' : '*') . ') |
| 603 | 620 | FROM {db_prefix}personal_messages |
| 604 | 621 | WHERE id_member_from = {int:current_member} |
@@ -610,8 +627,8 @@ discard block |
||
| 610 | 627 | 'id_pm' => $pmID, |
| 611 | 628 | ) |
| 612 | 629 | ); |
| 613 | - else |
|
| 614 | - $request = $smcFunc['db_query']('', ' |
|
| 630 | + } else { |
|
| 631 | + $request = $smcFunc['db_query']('', ' |
|
| 615 | 632 | SELECT COUNT(' . ($context['display_mode'] == 2 ? 'DISTINCT pm.id_pm_head' : '*') . ') |
| 616 | 633 | FROM {db_prefix}pm_recipients AS pmr' . ($context['display_mode'] == 2 ? ' |
| 617 | 634 | INNER JOIN {db_prefix}personal_messages AS pm ON (pm.id_pm = pmr.id_pm)' : '') . $labelJoin . ' |
@@ -624,6 +641,7 @@ discard block |
||
| 624 | 641 | 'id_pm' => $pmID, |
| 625 | 642 | ) |
| 626 | 643 | ); |
| 644 | + } |
|
| 627 | 645 | |
| 628 | 646 | list ($_GET['start']) = $smcFunc['db_fetch_row']($request); |
| 629 | 647 | $smcFunc['db_free_result']($request); |
@@ -638,8 +656,9 @@ discard block |
||
| 638 | 656 | { |
| 639 | 657 | $pmsg = (int) $_GET['pmsg']; |
| 640 | 658 | |
| 641 | - if (!isAccessiblePM($pmsg, $context['folder'] == 'sent' ? 'outbox' : 'inbox')) |
|
| 642 | - fatal_lang_error('no_access', false); |
|
| 659 | + if (!isAccessiblePM($pmsg, $context['folder'] == 'sent' ? 'outbox' : 'inbox')) { |
|
| 660 | + fatal_lang_error('no_access', false); |
|
| 661 | + } |
|
| 643 | 662 | } |
| 644 | 663 | |
| 645 | 664 | // Set up the page index. |
@@ -734,8 +753,9 @@ discard block |
||
| 734 | 753 | { |
| 735 | 754 | if (!isset($recipients[$row['id_pm']])) |
| 736 | 755 | { |
| 737 | - if (isset($row['id_member_from'])) |
|
| 738 | - $posters[$row['id_pm']] = $row['id_member_from']; |
|
| 756 | + if (isset($row['id_member_from'])) { |
|
| 757 | + $posters[$row['id_pm']] = $row['id_member_from']; |
|
| 758 | + } |
|
| 739 | 759 | $pms[$row['id_pm']] = $row['id_pm']; |
| 740 | 760 | $recipients[$row['id_pm']] = array( |
| 741 | 761 | 'to' => array(), |
@@ -744,29 +764,33 @@ discard block |
||
| 744 | 764 | } |
| 745 | 765 | |
| 746 | 766 | // Keep track of the last message so we know what the head is without another query! |
| 747 | - if ((empty($pmID) && (empty($options['view_newest_pm_first']) || !isset($lastData))) || empty($lastData) || (!empty($pmID) && $pmID == $row['id_pm'])) |
|
| 748 | - $lastData = array( |
|
| 767 | + if ((empty($pmID) && (empty($options['view_newest_pm_first']) || !isset($lastData))) || empty($lastData) || (!empty($pmID) && $pmID == $row['id_pm'])) { |
|
| 768 | + $lastData = array( |
|
| 749 | 769 | 'id' => $row['id_pm'], |
| 750 | 770 | 'head' => $row['id_pm_head'], |
| 751 | 771 | ); |
| 772 | + } |
|
| 752 | 773 | } |
| 753 | 774 | $smcFunc['db_free_result']($request); |
| 754 | 775 | |
| 755 | 776 | // Make sure that we have been given a correct head pm id! |
| 756 | - if ($context['display_mode'] == 2 && !empty($pmID) && $pmID != $lastData['id']) |
|
| 757 | - fatal_lang_error('no_access', false); |
|
| 777 | + if ($context['display_mode'] == 2 && !empty($pmID) && $pmID != $lastData['id']) { |
|
| 778 | + fatal_lang_error('no_access', false); |
|
| 779 | + } |
|
| 758 | 780 | |
| 759 | 781 | if (!empty($pms)) |
| 760 | 782 | { |
| 761 | 783 | // Select the correct current message. |
| 762 | - if (empty($pmID)) |
|
| 763 | - $context['current_pm'] = $lastData['id']; |
|
| 784 | + if (empty($pmID)) { |
|
| 785 | + $context['current_pm'] = $lastData['id']; |
|
| 786 | + } |
|
| 764 | 787 | |
| 765 | 788 | // This is a list of the pm's that are used for "full" display. |
| 766 | - if ($context['display_mode'] == 0) |
|
| 767 | - $display_pms = $pms; |
|
| 768 | - else |
|
| 769 | - $display_pms = array($context['current_pm']); |
|
| 789 | + if ($context['display_mode'] == 0) { |
|
| 790 | + $display_pms = $pms; |
|
| 791 | + } else { |
|
| 792 | + $display_pms = array($context['current_pm']); |
|
| 793 | + } |
|
| 770 | 794 | |
| 771 | 795 | // At this point we know the main id_pm's. But - if we are looking at conversations we need the others! |
| 772 | 796 | if ($context['display_mode'] == 2) |
@@ -788,16 +812,18 @@ discard block |
||
| 788 | 812 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 789 | 813 | { |
| 790 | 814 | // This is, frankly, a joke. We will put in a workaround for people sending to themselves - yawn! |
| 791 | - if ($context['folder'] == 'sent' && $row['id_member_from'] == $user_info['id'] && $row['deleted_by_sender'] == 1) |
|
| 792 | - continue; |
|
| 793 | - elseif ($row['id_member'] == $user_info['id'] & $row['deleted'] == 1) |
|
| 794 | - continue; |
|
| 815 | + if ($context['folder'] == 'sent' && $row['id_member_from'] == $user_info['id'] && $row['deleted_by_sender'] == 1) { |
|
| 816 | + continue; |
|
| 817 | + } elseif ($row['id_member'] == $user_info['id'] & $row['deleted'] == 1) { |
|
| 818 | + continue; |
|
| 819 | + } |
|
| 795 | 820 | |
| 796 | - if (!isset($recipients[$row['id_pm']])) |
|
| 797 | - $recipients[$row['id_pm']] = array( |
|
| 821 | + if (!isset($recipients[$row['id_pm']])) { |
|
| 822 | + $recipients[$row['id_pm']] = array( |
|
| 798 | 823 | 'to' => array(), |
| 799 | 824 | 'bcc' => array() |
| 800 | 825 | ); |
| 826 | + } |
|
| 801 | 827 | $display_pms[] = $row['id_pm']; |
| 802 | 828 | $posters[$row['id_pm']] = $row['id_member_from']; |
| 803 | 829 | } |
@@ -848,8 +874,9 @@ discard block |
||
| 848 | 874 | while ($row2 = $smcFunc['db_fetch_assoc']($request2)) |
| 849 | 875 | { |
| 850 | 876 | $l_id = $row2['id_label']; |
| 851 | - if (isset($context['labels'][$l_id])) |
|
| 852 | - $context['message_labels'][$row['id_pm']][$l_id] = array('id' => $l_id, 'name' => $context['labels'][$l_id]['name']); |
|
| 877 | + if (isset($context['labels'][$l_id])) { |
|
| 878 | + $context['message_labels'][$row['id_pm']][$l_id] = array('id' => $l_id, 'name' => $context['labels'][$l_id]['name']); |
|
| 879 | + } |
|
| 853 | 880 | } |
| 854 | 881 | |
| 855 | 882 | $smcFunc['db_free_result']($request2); |
@@ -866,9 +893,10 @@ discard block |
||
| 866 | 893 | // Make sure we don't load unnecessary data. |
| 867 | 894 | if ($context['display_mode'] == 1) |
| 868 | 895 | { |
| 869 | - foreach ($posters as $k => $v) |
|
| 870 | - if (!in_array($k, $display_pms)) |
|
| 896 | + foreach ($posters as $k => $v) { |
|
| 897 | + if (!in_array($k, $display_pms)) |
|
| 871 | 898 | unset($posters[$k]); |
| 899 | + } |
|
| 872 | 900 | } |
| 873 | 901 | |
| 874 | 902 | // Load any users.... |
@@ -879,8 +907,9 @@ discard block |
||
| 879 | 907 | { |
| 880 | 908 | // Get the order right. |
| 881 | 909 | $orderBy = array(); |
| 882 | - foreach (array_reverse($pms) as $pm) |
|
| 883 | - $orderBy[] = 'pm.id_pm = ' . $pm; |
|
| 910 | + foreach (array_reverse($pms) as $pm) { |
|
| 911 | + $orderBy[] = 'pm.id_pm = ' . $pm; |
|
| 912 | + } |
|
| 884 | 913 | |
| 885 | 914 | // Seperate query for these bits! |
| 886 | 915 | $subjects_request = $smcFunc['db_query']('', ' |
@@ -926,9 +955,9 @@ discard block |
||
| 926 | 955 | // Allow mods to add additional buttons here |
| 927 | 956 | call_integration_hook('integrate_conversation_buttons'); |
| 928 | 957 | } |
| 958 | + } else { |
|
| 959 | + $messages_request = false; |
|
| 929 | 960 | } |
| 930 | - else |
|
| 931 | - $messages_request = false; |
|
| 932 | 961 | |
| 933 | 962 | $context['can_send_pm'] = allowedTo('pm_send'); |
| 934 | 963 | $context['can_send_email'] = allowedTo('moderate_forum'); |
@@ -939,11 +968,13 @@ discard block |
||
| 939 | 968 | if ($context['folder'] != 'sent' && !empty($context['labels'][(int) $context['current_label_id']]['unread_messages'])) |
| 940 | 969 | { |
| 941 | 970 | // If the display mode is "old sk00l" do them all... |
| 942 | - if ($context['display_mode'] == 0) |
|
| 943 | - markMessages(null, $context['current_label_id']); |
|
| 971 | + if ($context['display_mode'] == 0) { |
|
| 972 | + markMessages(null, $context['current_label_id']); |
|
| 973 | + } |
|
| 944 | 974 | // Otherwise do just the current one! |
| 945 | - elseif (!empty($context['current_pm'])) |
|
| 946 | - markMessages($display_pms, $context['current_label_id']); |
|
| 975 | + elseif (!empty($context['current_pm'])) { |
|
| 976 | + markMessages($display_pms, $context['current_label_id']); |
|
| 977 | + } |
|
| 947 | 978 | } |
| 948 | 979 | } |
| 949 | 980 | |
@@ -961,8 +992,9 @@ discard block |
||
| 961 | 992 | |
| 962 | 993 | // Count the current message number.... |
| 963 | 994 | static $counter = null; |
| 964 | - if ($counter === null || $reset) |
|
| 965 | - $counter = $context['start']; |
|
| 995 | + if ($counter === null || $reset) { |
|
| 996 | + $counter = $context['start']; |
|
| 997 | + } |
|
| 966 | 998 | |
| 967 | 999 | static $temp_pm_selected = null; |
| 968 | 1000 | if ($temp_pm_selected === null) |
@@ -1007,19 +1039,22 @@ discard block |
||
| 1007 | 1039 | } |
| 1008 | 1040 | |
| 1009 | 1041 | // Bail if it's false, ie. no messages. |
| 1010 | - if ($messages_request == false) |
|
| 1011 | - return false; |
|
| 1042 | + if ($messages_request == false) { |
|
| 1043 | + return false; |
|
| 1044 | + } |
|
| 1012 | 1045 | |
| 1013 | 1046 | // Reset the data? |
| 1014 | - if ($reset == true) |
|
| 1015 | - return @$smcFunc['db_data_seek']($messages_request, 0); |
|
| 1047 | + if ($reset == true) { |
|
| 1048 | + return @$smcFunc['db_data_seek']($messages_request, 0); |
|
| 1049 | + } |
|
| 1016 | 1050 | |
| 1017 | 1051 | // Get the next one... bail if anything goes wrong. |
| 1018 | 1052 | $message = $smcFunc['db_fetch_assoc']($messages_request); |
| 1019 | 1053 | if (!$message) |
| 1020 | 1054 | { |
| 1021 | - if ($type != 'subject') |
|
| 1022 | - $smcFunc['db_free_result']($messages_request); |
|
| 1055 | + if ($type != 'subject') { |
|
| 1056 | + $smcFunc['db_free_result']($messages_request); |
|
| 1057 | + } |
|
| 1023 | 1058 | |
| 1024 | 1059 | return false; |
| 1025 | 1060 | } |
@@ -1039,8 +1074,7 @@ discard block |
||
| 1039 | 1074 | $memberContext[$message['id_member_from']]['email'] = ''; |
| 1040 | 1075 | $memberContext[$message['id_member_from']]['show_email'] = false; |
| 1041 | 1076 | $memberContext[$message['id_member_from']]['is_guest'] = true; |
| 1042 | - } |
|
| 1043 | - else |
|
| 1077 | + } else |
|
| 1044 | 1078 | { |
| 1045 | 1079 | $memberContext[$message['id_member_from']]['can_view_profile'] = allowedTo('profile_view') || ($message['id_member_from'] == $user_info['id'] && !$user_info['is_guest']); |
| 1046 | 1080 | $memberContext[$message['id_member_from']]['can_see_warning'] = !isset($context['disabled_fields']['warning_status']) && $memberContext[$message['id_member_from']]['warning_status'] && ($context['user']['can_mod'] || (!empty($modSettings['warning_show']) && ($modSettings['warning_show'] > 1 || $message['id_member_from'] == $user_info['id']))); |
@@ -1081,9 +1115,10 @@ discard block |
||
| 1081 | 1115 | $counter++; |
| 1082 | 1116 | |
| 1083 | 1117 | // Any custom profile fields? |
| 1084 | - if (!empty($memberContext[$message['id_member_from']]['custom_fields'])) |
|
| 1085 | - foreach ($memberContext[$message['id_member_from']]['custom_fields'] as $custom) |
|
| 1118 | + if (!empty($memberContext[$message['id_member_from']]['custom_fields'])) { |
|
| 1119 | + foreach ($memberContext[$message['id_member_from']]['custom_fields'] as $custom) |
|
| 1086 | 1120 | $output['custom_fields'][$context['cust_profile_fields_placement'][$custom['placement']]][] = $custom; |
| 1121 | + } |
|
| 1087 | 1122 | |
| 1088 | 1123 | call_integration_hook('integrate_prepare_pm_context', array(&$output, &$message, $counter)); |
| 1089 | 1124 | |
@@ -1107,22 +1142,28 @@ discard block |
||
| 1107 | 1142 | $context['search_params'][$k] = $v; |
| 1108 | 1143 | } |
| 1109 | 1144 | } |
| 1110 | - if (isset($_REQUEST['search'])) |
|
| 1111 | - $context['search_params']['search'] = un_htmlspecialchars($_REQUEST['search']); |
|
| 1145 | + if (isset($_REQUEST['search'])) { |
|
| 1146 | + $context['search_params']['search'] = un_htmlspecialchars($_REQUEST['search']); |
|
| 1147 | + } |
|
| 1112 | 1148 | |
| 1113 | - if (isset($context['search_params']['search'])) |
|
| 1114 | - $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']); |
|
| 1115 | - if (isset($context['search_params']['userspec'])) |
|
| 1116 | - $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']); |
|
| 1149 | + if (isset($context['search_params']['search'])) { |
|
| 1150 | + $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']); |
|
| 1151 | + } |
|
| 1152 | + if (isset($context['search_params']['userspec'])) { |
|
| 1153 | + $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']); |
|
| 1154 | + } |
|
| 1117 | 1155 | |
| 1118 | - if (!empty($context['search_params']['searchtype'])) |
|
| 1119 | - $context['search_params']['searchtype'] = 2; |
|
| 1156 | + if (!empty($context['search_params']['searchtype'])) { |
|
| 1157 | + $context['search_params']['searchtype'] = 2; |
|
| 1158 | + } |
|
| 1120 | 1159 | |
| 1121 | - if (!empty($context['search_params']['minage'])) |
|
| 1122 | - $context['search_params']['minage'] = (int) $context['search_params']['minage']; |
|
| 1160 | + if (!empty($context['search_params']['minage'])) { |
|
| 1161 | + $context['search_params']['minage'] = (int) $context['search_params']['minage']; |
|
| 1162 | + } |
|
| 1123 | 1163 | |
| 1124 | - if (!empty($context['search_params']['maxage'])) |
|
| 1125 | - $context['search_params']['maxage'] = (int) $context['search_params']['maxage']; |
|
| 1164 | + if (!empty($context['search_params']['maxage'])) { |
|
| 1165 | + $context['search_params']['maxage'] = (int) $context['search_params']['maxage']; |
|
| 1166 | + } |
|
| 1126 | 1167 | |
| 1127 | 1168 | $context['search_params']['subject_only'] = !empty($context['search_params']['subject_only']); |
| 1128 | 1169 | $context['search_params']['show_complete'] = !empty($context['search_params']['show_complete']); |
@@ -1149,8 +1190,9 @@ discard block |
||
| 1149 | 1190 | $context['search_errors']['messages'] = array(); |
| 1150 | 1191 | foreach ($context['search_errors'] as $search_error => $dummy) |
| 1151 | 1192 | { |
| 1152 | - if ($search_error == 'messages') |
|
| 1153 | - continue; |
|
| 1193 | + if ($search_error == 'messages') { |
|
| 1194 | + continue; |
|
| 1195 | + } |
|
| 1154 | 1196 | |
| 1155 | 1197 | $context['search_errors']['messages'][] = $txt['error_' . $search_error]; |
| 1156 | 1198 | } |
@@ -1172,8 +1214,9 @@ discard block |
||
| 1172 | 1214 | global $scripturl, $modSettings, $user_info, $context, $txt; |
| 1173 | 1215 | global $memberContext, $smcFunc; |
| 1174 | 1216 | |
| 1175 | - if (!empty($context['load_average']) && !empty($modSettings['loadavg_search']) && $context['load_average'] >= $modSettings['loadavg_search']) |
|
| 1176 | - fatal_lang_error('loadavg_search_disabled', false); |
|
| 1217 | + if (!empty($context['load_average']) && !empty($modSettings['loadavg_search']) && $context['load_average'] >= $modSettings['loadavg_search']) { |
|
| 1218 | + fatal_lang_error('loadavg_search_disabled', false); |
|
| 1219 | + } |
|
| 1177 | 1220 | |
| 1178 | 1221 | /** |
| 1179 | 1222 | * @todo For the moment force the folder to the inbox. |
@@ -1202,35 +1245,40 @@ discard block |
||
| 1202 | 1245 | $context['start'] = isset($_GET['start']) ? (int) $_GET['start'] : 0; |
| 1203 | 1246 | |
| 1204 | 1247 | // Store whether simple search was used (needed if the user wants to do another query). |
| 1205 | - if (!isset($search_params['advanced'])) |
|
| 1206 | - $search_params['advanced'] = empty($_REQUEST['advanced']) ? 0 : 1; |
|
| 1248 | + if (!isset($search_params['advanced'])) { |
|
| 1249 | + $search_params['advanced'] = empty($_REQUEST['advanced']) ? 0 : 1; |
|
| 1250 | + } |
|
| 1207 | 1251 | |
| 1208 | 1252 | // 1 => 'allwords' (default, don't set as param) / 2 => 'anywords'. |
| 1209 | - if (!empty($search_params['searchtype']) || (!empty($_REQUEST['searchtype']) && $_REQUEST['searchtype'] == 2)) |
|
| 1210 | - $search_params['searchtype'] = 2; |
|
| 1253 | + if (!empty($search_params['searchtype']) || (!empty($_REQUEST['searchtype']) && $_REQUEST['searchtype'] == 2)) { |
|
| 1254 | + $search_params['searchtype'] = 2; |
|
| 1255 | + } |
|
| 1211 | 1256 | |
| 1212 | 1257 | // Minimum age of messages. Default to zero (don't set param in that case). |
| 1213 | - if (!empty($search_params['minage']) || (!empty($_REQUEST['minage']) && $_REQUEST['minage'] > 0)) |
|
| 1214 | - $search_params['minage'] = !empty($search_params['minage']) ? (int) $search_params['minage'] : (int) $_REQUEST['minage']; |
|
| 1258 | + if (!empty($search_params['minage']) || (!empty($_REQUEST['minage']) && $_REQUEST['minage'] > 0)) { |
|
| 1259 | + $search_params['minage'] = !empty($search_params['minage']) ? (int) $search_params['minage'] : (int) $_REQUEST['minage']; |
|
| 1260 | + } |
|
| 1215 | 1261 | |
| 1216 | 1262 | // Maximum age of messages. Default to infinite (9999 days: param not set). |
| 1217 | - if (!empty($search_params['maxage']) || (!empty($_REQUEST['maxage']) && $_REQUEST['maxage'] != 9999)) |
|
| 1218 | - $search_params['maxage'] = !empty($search_params['maxage']) ? (int) $search_params['maxage'] : (int) $_REQUEST['maxage']; |
|
| 1263 | + if (!empty($search_params['maxage']) || (!empty($_REQUEST['maxage']) && $_REQUEST['maxage'] != 9999)) { |
|
| 1264 | + $search_params['maxage'] = !empty($search_params['maxage']) ? (int) $search_params['maxage'] : (int) $_REQUEST['maxage']; |
|
| 1265 | + } |
|
| 1219 | 1266 | |
| 1220 | 1267 | $search_params['subject_only'] = !empty($search_params['subject_only']) || !empty($_REQUEST['subject_only']); |
| 1221 | 1268 | $search_params['show_complete'] = !empty($search_params['show_complete']) || !empty($_REQUEST['show_complete']); |
| 1222 | 1269 | |
| 1223 | 1270 | // Default the user name to a wildcard matching every user (*). |
| 1224 | - if (!empty($search_params['user_spec']) || (!empty($_REQUEST['userspec']) && $_REQUEST['userspec'] != '*')) |
|
| 1225 | - $search_params['userspec'] = isset($search_params['userspec']) ? $search_params['userspec'] : $_REQUEST['userspec']; |
|
| 1271 | + if (!empty($search_params['user_spec']) || (!empty($_REQUEST['userspec']) && $_REQUEST['userspec'] != '*')) { |
|
| 1272 | + $search_params['userspec'] = isset($search_params['userspec']) ? $search_params['userspec'] : $_REQUEST['userspec']; |
|
| 1273 | + } |
|
| 1226 | 1274 | |
| 1227 | 1275 | // This will be full of all kinds of parameters! |
| 1228 | 1276 | $searchq_parameters = array(); |
| 1229 | 1277 | |
| 1230 | 1278 | // If there's no specific user, then don't mention it in the main query. |
| 1231 | - if (empty($search_params['userspec'])) |
|
| 1232 | - $userQuery = ''; |
|
| 1233 | - else |
|
| 1279 | + if (empty($search_params['userspec'])) { |
|
| 1280 | + $userQuery = ''; |
|
| 1281 | + } else |
|
| 1234 | 1282 | { |
| 1235 | 1283 | $userString = strtr($smcFunc['htmlspecialchars']($search_params['userspec'], ENT_QUOTES), array('"' => '"')); |
| 1236 | 1284 | $userString = strtr($userString, array('%' => '\%', '_' => '\_', '*' => '%', '?' => '_')); |
@@ -1242,8 +1290,9 @@ discard block |
||
| 1242 | 1290 | { |
| 1243 | 1291 | $possible_users[$k] = trim($possible_users[$k]); |
| 1244 | 1292 | |
| 1245 | - if (strlen($possible_users[$k]) == 0) |
|
| 1246 | - unset($possible_users[$k]); |
|
| 1293 | + if (strlen($possible_users[$k]) == 0) { |
|
| 1294 | + unset($possible_users[$k]); |
|
| 1295 | + } |
|
| 1247 | 1296 | } |
| 1248 | 1297 | |
| 1249 | 1298 | if (!empty($possible_users)) |
@@ -1255,8 +1304,9 @@ discard block |
||
| 1255 | 1304 | { |
| 1256 | 1305 | $where_params['name_' . $k] = $v; |
| 1257 | 1306 | $where_clause[] = '{raw:real_name} LIKE {string:name_' . $k . '}'; |
| 1258 | - if (!isset($where_params['real_name'])) |
|
| 1259 | - $where_params['real_name'] = $smcFunc['db_case_sensitive'] ? 'LOWER(real_name)' : 'real_name'; |
|
| 1307 | + if (!isset($where_params['real_name'])) { |
|
| 1308 | + $where_params['real_name'] = $smcFunc['db_case_sensitive'] ? 'LOWER(real_name)' : 'real_name'; |
|
| 1309 | + } |
|
| 1260 | 1310 | } |
| 1261 | 1311 | |
| 1262 | 1312 | // Who matches those criteria? |
@@ -1269,28 +1319,28 @@ discard block |
||
| 1269 | 1319 | ); |
| 1270 | 1320 | |
| 1271 | 1321 | // Simply do nothing if there're too many members matching the criteria. |
| 1272 | - if ($smcFunc['db_num_rows']($request) > $maxMembersToSearch) |
|
| 1273 | - $userQuery = ''; |
|
| 1274 | - elseif ($smcFunc['db_num_rows']($request) == 0) |
|
| 1322 | + if ($smcFunc['db_num_rows']($request) > $maxMembersToSearch) { |
|
| 1323 | + $userQuery = ''; |
|
| 1324 | + } elseif ($smcFunc['db_num_rows']($request) == 0) |
|
| 1275 | 1325 | { |
| 1276 | 1326 | $userQuery = 'AND pm.id_member_from = 0 AND ({raw:pm_from_name} LIKE {raw:guest_user_name_implode})'; |
| 1277 | 1327 | $searchq_parameters['guest_user_name_implode'] = '\'' . implode('\' OR ' . ($smcFunc['db_case_sensitive'] ? 'LOWER(pm.from_name)' : 'pm.from_name') . ' LIKE \'', $possible_users) . '\''; |
| 1278 | 1328 | $searchq_parameters['pm_from_name'] = $smcFunc['db_case_sensitive'] ? 'LOWER(pm.from_name)' : 'pm.from_name'; |
| 1279 | - } |
|
| 1280 | - else |
|
| 1329 | + } else |
|
| 1281 | 1330 | { |
| 1282 | 1331 | $memberlist = array(); |
| 1283 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1284 | - $memberlist[] = $row['id_member']; |
|
| 1332 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1333 | + $memberlist[] = $row['id_member']; |
|
| 1334 | + } |
|
| 1285 | 1335 | $userQuery = 'AND (pm.id_member_from IN ({array_int:member_list}) OR (pm.id_member_from = 0 AND ({raw:pm_from_name} LIKE {raw:guest_user_name_implode})))'; |
| 1286 | 1336 | $searchq_parameters['guest_user_name_implode'] = '\'' . implode('\' OR ' . ($smcFunc['db_case_sensitive'] ? 'LOWER(pm.from_name)' : 'pm.from_name') . ' LIKE \'', $possible_users) . '\''; |
| 1287 | 1337 | $searchq_parameters['member_list'] = $memberlist; |
| 1288 | 1338 | $searchq_parameters['pm_from_name'] = $smcFunc['db_case_sensitive'] ? 'LOWER(pm.from_name)' : 'pm.from_name'; |
| 1289 | 1339 | } |
| 1290 | 1340 | $smcFunc['db_free_result']($request); |
| 1341 | + } else { |
|
| 1342 | + $userQuery = ''; |
|
| 1291 | 1343 | } |
| 1292 | - else |
|
| 1293 | - $userQuery = ''; |
|
| 1294 | 1344 | } |
| 1295 | 1345 | |
| 1296 | 1346 | // Setup the sorting variables... |
@@ -1298,8 +1348,9 @@ discard block |
||
| 1298 | 1348 | $sort_columns = array( |
| 1299 | 1349 | 'pm.id_pm', |
| 1300 | 1350 | ); |
| 1301 | - if (empty($search_params['sort']) && !empty($_REQUEST['sort'])) |
|
| 1302 | - list ($search_params['sort'], $search_params['sort_dir']) = array_pad(explode('|', $_REQUEST['sort']), 2, ''); |
|
| 1351 | + if (empty($search_params['sort']) && !empty($_REQUEST['sort'])) { |
|
| 1352 | + list ($search_params['sort'], $search_params['sort_dir']) = array_pad(explode('|', $_REQUEST['sort']), 2, ''); |
|
| 1353 | + } |
|
| 1303 | 1354 | $search_params['sort'] = !empty($search_params['sort']) && in_array($search_params['sort'], $sort_columns) ? $search_params['sort'] : 'pm.id_pm'; |
| 1304 | 1355 | $search_params['sort_dir'] = !empty($search_params['sort_dir']) && $search_params['sort_dir'] == 'asc' ? 'asc' : 'desc'; |
| 1305 | 1356 | |
@@ -1309,24 +1360,27 @@ discard block |
||
| 1309 | 1360 | if ($context['folder'] == 'inbox' && !empty($search_params['advanced']) && $context['currently_using_labels']) |
| 1310 | 1361 | { |
| 1311 | 1362 | // Came here from pagination? Put them back into $_REQUEST for sanitization. |
| 1312 | - if (isset($search_params['labels'])) |
|
| 1313 | - $_REQUEST['searchlabel'] = explode(',', $search_params['labels']); |
|
| 1363 | + if (isset($search_params['labels'])) { |
|
| 1364 | + $_REQUEST['searchlabel'] = explode(',', $search_params['labels']); |
|
| 1365 | + } |
|
| 1314 | 1366 | |
| 1315 | 1367 | // Assuming we have some labels - make them all integers. |
| 1316 | 1368 | if (!empty($_REQUEST['searchlabel']) && is_array($_REQUEST['searchlabel'])) |
| 1317 | 1369 | { |
| 1318 | - foreach ($_REQUEST['searchlabel'] as $key => $id) |
|
| 1319 | - $_REQUEST['searchlabel'][$key] = (int) $id; |
|
| 1370 | + foreach ($_REQUEST['searchlabel'] as $key => $id) { |
|
| 1371 | + $_REQUEST['searchlabel'][$key] = (int) $id; |
|
| 1372 | + } |
|
| 1373 | + } else { |
|
| 1374 | + $_REQUEST['searchlabel'] = array(); |
|
| 1320 | 1375 | } |
| 1321 | - else |
|
| 1322 | - $_REQUEST['searchlabel'] = array(); |
|
| 1323 | 1376 | |
| 1324 | 1377 | // Now that everything is cleaned up a bit, make the labels a param. |
| 1325 | 1378 | $search_params['labels'] = implode(',', $_REQUEST['searchlabel']); |
| 1326 | 1379 | |
| 1327 | 1380 | // No labels selected? That must be an error! |
| 1328 | - if (empty($_REQUEST['searchlabel'])) |
|
| 1329 | - $context['search_errors']['no_labels_selected'] = true; |
|
| 1381 | + if (empty($_REQUEST['searchlabel'])) { |
|
| 1382 | + $context['search_errors']['no_labels_selected'] = true; |
|
| 1383 | + } |
|
| 1330 | 1384 | // Otherwise prepare the query! |
| 1331 | 1385 | elseif (count($_REQUEST['searchlabel']) != count($context['labels'])) |
| 1332 | 1386 | { |
@@ -1349,8 +1403,7 @@ discard block |
||
| 1349 | 1403 | // Not searching the inbox - PM must be labeled |
| 1350 | 1404 | $labelQuery = ' AND pml.id_label IN ({array_int:labels})'; |
| 1351 | 1405 | $labelJoin = ' INNER JOIN {db_prefix}pm_labeled_messages AS pml ON (pml.id_pm = pmr.id_pm)'; |
| 1352 | - } |
|
| 1353 | - else |
|
| 1406 | + } else |
|
| 1354 | 1407 | { |
| 1355 | 1408 | // Searching the inbox - PM doesn't have to be labeled |
| 1356 | 1409 | $labelQuery = ' AND (' . substr($labelQuery, 5) . ' OR pml.id_label IN ({array_int:labels}))'; |
@@ -1365,8 +1418,9 @@ discard block |
||
| 1365 | 1418 | // What are we actually searching for? |
| 1366 | 1419 | $search_params['search'] = !empty($search_params['search']) ? $search_params['search'] : (isset($_REQUEST['search']) ? $_REQUEST['search'] : ''); |
| 1367 | 1420 | // If we ain't got nothing - we should error! |
| 1368 | - if (!isset($search_params['search']) || $search_params['search'] == '') |
|
| 1369 | - $context['search_errors']['invalid_search_string'] = true; |
|
| 1421 | + if (!isset($search_params['search']) || $search_params['search'] == '') { |
|
| 1422 | + $context['search_errors']['invalid_search_string'] = true; |
|
| 1423 | + } |
|
| 1370 | 1424 | |
| 1371 | 1425 | // Extract phrase parts first (e.g. some words "this is a phrase" some more words.) |
| 1372 | 1426 | preg_match_all('~(?:^|\s)([-]?)"([^"]+)"(?:$|\s)~' . ($context['utf8'] ? 'u' : ''), $search_params['search'], $matches, PREG_PATTERN_ORDER); |
@@ -1379,12 +1433,14 @@ discard block |
||
| 1379 | 1433 | $excludedWords = array(); |
| 1380 | 1434 | |
| 1381 | 1435 | // .. first, we check for things like -"some words", but not "-some words". |
| 1382 | - foreach ($matches[1] as $index => $word) |
|
| 1383 | - if ($word == '-') |
|
| 1436 | + foreach ($matches[1] as $index => $word) { |
|
| 1437 | + if ($word == '-') |
|
| 1384 | 1438 | { |
| 1385 | 1439 | $word = $smcFunc['strtolower'](trim($searchArray[$index])); |
| 1386 | - if (strlen($word) > 0) |
|
| 1387 | - $excludedWords[] = $word; |
|
| 1440 | + } |
|
| 1441 | + if (strlen($word) > 0) { |
|
| 1442 | + $excludedWords[] = $word; |
|
| 1443 | + } |
|
| 1388 | 1444 | unset($searchArray[$index]); |
| 1389 | 1445 | } |
| 1390 | 1446 | |
@@ -1394,8 +1450,9 @@ discard block |
||
| 1394 | 1450 | if (strpos(trim($word), '-') === 0) |
| 1395 | 1451 | { |
| 1396 | 1452 | $word = substr($smcFunc['strtolower']($word), 1); |
| 1397 | - if (strlen($word) > 0) |
|
| 1398 | - $excludedWords[] = $word; |
|
| 1453 | + if (strlen($word) > 0) { |
|
| 1454 | + $excludedWords[] = $word; |
|
| 1455 | + } |
|
| 1399 | 1456 | unset($tempSearch[$index]); |
| 1400 | 1457 | } |
| 1401 | 1458 | } |
@@ -1406,9 +1463,9 @@ discard block |
||
| 1406 | 1463 | foreach ($searchArray as $index => $value) |
| 1407 | 1464 | { |
| 1408 | 1465 | $searchArray[$index] = $smcFunc['strtolower'](trim($value)); |
| 1409 | - if ($searchArray[$index] == '') |
|
| 1410 | - unset($searchArray[$index]); |
|
| 1411 | - else |
|
| 1466 | + if ($searchArray[$index] == '') { |
|
| 1467 | + unset($searchArray[$index]); |
|
| 1468 | + } else |
|
| 1412 | 1469 | { |
| 1413 | 1470 | // Sort out entities first. |
| 1414 | 1471 | $searchArray[$index] = $smcFunc['htmlspecialchars']($searchArray[$index]); |
@@ -1418,27 +1475,32 @@ discard block |
||
| 1418 | 1475 | |
| 1419 | 1476 | // Create an array of replacements for highlighting. |
| 1420 | 1477 | $context['mark'] = array(); |
| 1421 | - foreach ($searchArray as $word) |
|
| 1422 | - $context['mark'][$word] = '<strong class="highlight">' . $word . '</strong>'; |
|
| 1478 | + foreach ($searchArray as $word) { |
|
| 1479 | + $context['mark'][$word] = '<strong class="highlight">' . $word . '</strong>'; |
|
| 1480 | + } |
|
| 1423 | 1481 | |
| 1424 | 1482 | // This contains *everything* |
| 1425 | 1483 | $searchWords = array_merge($searchArray, $excludedWords); |
| 1426 | 1484 | |
| 1427 | 1485 | // Make sure at least one word is being searched for. |
| 1428 | - if (empty($searchArray)) |
|
| 1429 | - $context['search_errors']['invalid_search_string'] = true; |
|
| 1486 | + if (empty($searchArray)) { |
|
| 1487 | + $context['search_errors']['invalid_search_string'] = true; |
|
| 1488 | + } |
|
| 1430 | 1489 | |
| 1431 | 1490 | // Sort out the search query so the user can edit it - if they want. |
| 1432 | 1491 | $context['search_params'] = $search_params; |
| 1433 | - if (isset($context['search_params']['search'])) |
|
| 1434 | - $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']); |
|
| 1435 | - if (isset($context['search_params']['userspec'])) |
|
| 1436 | - $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']); |
|
| 1492 | + if (isset($context['search_params']['search'])) { |
|
| 1493 | + $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']); |
|
| 1494 | + } |
|
| 1495 | + if (isset($context['search_params']['userspec'])) { |
|
| 1496 | + $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']); |
|
| 1497 | + } |
|
| 1437 | 1498 | |
| 1438 | 1499 | // Now we have all the parameters, combine them together for pagination and the like... |
| 1439 | 1500 | $context['params'] = array(); |
| 1440 | - foreach ($search_params as $k => $v) |
|
| 1441 | - $context['params'][] = $k . '|\'|' . $v; |
|
| 1501 | + foreach ($search_params as $k => $v) { |
|
| 1502 | + $context['params'][] = $k . '|\'|' . $v; |
|
| 1503 | + } |
|
| 1442 | 1504 | $context['params'] = base64_encode(implode('|"|', $context['params'])); |
| 1443 | 1505 | |
| 1444 | 1506 | // Compile the subject query part. |
@@ -1446,26 +1508,31 @@ discard block |
||
| 1446 | 1508 | |
| 1447 | 1509 | foreach ($searchWords as $index => $word) |
| 1448 | 1510 | { |
| 1449 | - if ($word == '') |
|
| 1450 | - continue; |
|
| 1511 | + if ($word == '') { |
|
| 1512 | + continue; |
|
| 1513 | + } |
|
| 1451 | 1514 | |
| 1452 | - if ($search_params['subject_only']) |
|
| 1453 | - $andQueryParts[] = 'pm.subject' . (in_array($word, $excludedWords) ? ' NOT' : '') . ' LIKE {string:search_' . $index . '}'; |
|
| 1454 | - else |
|
| 1455 | - $andQueryParts[] = '(pm.subject' . (in_array($word, $excludedWords) ? ' NOT' : '') . ' LIKE {string:search_' . $index . '} ' . (in_array($word, $excludedWords) ? 'AND pm.body NOT' : 'OR pm.body') . ' LIKE {string:search_' . $index . '})'; |
|
| 1515 | + if ($search_params['subject_only']) { |
|
| 1516 | + $andQueryParts[] = 'pm.subject' . (in_array($word, $excludedWords) ? ' NOT' : '') . ' LIKE {string:search_' . $index . '}'; |
|
| 1517 | + } else { |
|
| 1518 | + $andQueryParts[] = '(pm.subject' . (in_array($word, $excludedWords) ? ' NOT' : '') . ' LIKE {string:search_' . $index . '} ' . (in_array($word, $excludedWords) ? 'AND pm.body NOT' : 'OR pm.body') . ' LIKE {string:search_' . $index . '})'; |
|
| 1519 | + } |
|
| 1456 | 1520 | $searchq_parameters['search_' . $index] = '%' . strtr($word, array('_' => '\\_', '%' => '\\%')) . '%'; |
| 1457 | 1521 | } |
| 1458 | 1522 | |
| 1459 | 1523 | $searchQuery = ' 1=1'; |
| 1460 | - if (!empty($andQueryParts)) |
|
| 1461 | - $searchQuery = implode(!empty($search_params['searchtype']) && $search_params['searchtype'] == 2 ? ' OR ' : ' AND ', $andQueryParts); |
|
| 1524 | + if (!empty($andQueryParts)) { |
|
| 1525 | + $searchQuery = implode(!empty($search_params['searchtype']) && $search_params['searchtype'] == 2 ? ' OR ' : ' AND ', $andQueryParts); |
|
| 1526 | + } |
|
| 1462 | 1527 | |
| 1463 | 1528 | // Age limits? |
| 1464 | 1529 | $timeQuery = ''; |
| 1465 | - if (!empty($search_params['minage'])) |
|
| 1466 | - $timeQuery .= ' AND pm.msgtime < ' . (time() - $search_params['minage'] * 86400); |
|
| 1467 | - if (!empty($search_params['maxage'])) |
|
| 1468 | - $timeQuery .= ' AND pm.msgtime > ' . (time() - $search_params['maxage'] * 86400); |
|
| 1530 | + if (!empty($search_params['minage'])) { |
|
| 1531 | + $timeQuery .= ' AND pm.msgtime < ' . (time() - $search_params['minage'] * 86400); |
|
| 1532 | + } |
|
| 1533 | + if (!empty($search_params['maxage'])) { |
|
| 1534 | + $timeQuery .= ' AND pm.msgtime > ' . (time() - $search_params['maxage'] * 86400); |
|
| 1535 | + } |
|
| 1469 | 1536 | |
| 1470 | 1537 | // If we have errors - return back to the first screen... |
| 1471 | 1538 | if (!empty($context['search_errors'])) |
@@ -1551,8 +1618,9 @@ discard block |
||
| 1551 | 1618 | ) |
| 1552 | 1619 | ); |
| 1553 | 1620 | $real_pm_ids = array(); |
| 1554 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1555 | - $real_pm_ids[$row['id_pm_head']] = $row['id_pm']; |
|
| 1621 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1622 | + $real_pm_ids[$row['id_pm_head']] = $row['id_pm']; |
|
| 1623 | + } |
|
| 1556 | 1624 | $smcFunc['db_free_result']($request); |
| 1557 | 1625 | } |
| 1558 | 1626 | |
@@ -1582,8 +1650,9 @@ discard block |
||
| 1582 | 1650 | ); |
| 1583 | 1651 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1584 | 1652 | { |
| 1585 | - if ($context['folder'] == 'sent' || empty($row['bcc'])) |
|
| 1586 | - $recipients[$row['id_pm']][empty($row['bcc']) ? 'to' : 'bcc'][] = empty($row['id_member_to']) ? $txt['guest_title'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member_to'] . '">' . $row['to_name'] . '</a>'; |
|
| 1653 | + if ($context['folder'] == 'sent' || empty($row['bcc'])) { |
|
| 1654 | + $recipients[$row['id_pm']][empty($row['bcc']) ? 'to' : 'bcc'][] = empty($row['id_member_to']) ? $txt['guest_title'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member_to'] . '">' . $row['to_name'] . '</a>'; |
|
| 1655 | + } |
|
| 1587 | 1656 | |
| 1588 | 1657 | if ($row['id_member_to'] == $user_info['id'] && $context['folder'] != 'sent') |
| 1589 | 1658 | { |
@@ -1604,12 +1673,14 @@ discard block |
||
| 1604 | 1673 | while ($row2 = $smcFunc['db_fetch_assoc']($request2)) |
| 1605 | 1674 | { |
| 1606 | 1675 | $l_id = $row2['id_label']; |
| 1607 | - if (isset($context['labels'][$l_id])) |
|
| 1608 | - $context['message_labels'][$row['id_pm']][$l_id] = array('id' => $l_id, 'name' => $context['labels'][$l_id]['name']); |
|
| 1676 | + if (isset($context['labels'][$l_id])) { |
|
| 1677 | + $context['message_labels'][$row['id_pm']][$l_id] = array('id' => $l_id, 'name' => $context['labels'][$l_id]['name']); |
|
| 1678 | + } |
|
| 1609 | 1679 | |
| 1610 | 1680 | // Here we find the first label on a message - for linking to posts in results |
| 1611 | - if (!isset($context['first_label'][$row['id_pm']]) && $row['in_inbox'] != 1) |
|
| 1612 | - $context['first_label'][$row['id_pm']] = $l_id; |
|
| 1681 | + if (!isset($context['first_label'][$row['id_pm']]) && $row['in_inbox'] != 1) { |
|
| 1682 | + $context['first_label'][$row['id_pm']] = $l_id; |
|
| 1683 | + } |
|
| 1613 | 1684 | } |
| 1614 | 1685 | |
| 1615 | 1686 | $smcFunc['db_free_result']($request2); |
@@ -1736,8 +1807,9 @@ discard block |
||
| 1736 | 1807 | list ($postCount) = $smcFunc['db_fetch_row']($request); |
| 1737 | 1808 | $smcFunc['db_free_result']($request); |
| 1738 | 1809 | |
| 1739 | - if (!empty($postCount) && $postCount >= $modSettings['pm_posts_per_hour']) |
|
| 1740 | - fatal_lang_error('pm_too_many_per_hour', true, array($modSettings['pm_posts_per_hour'])); |
|
| 1810 | + if (!empty($postCount) && $postCount >= $modSettings['pm_posts_per_hour']) { |
|
| 1811 | + fatal_lang_error('pm_too_many_per_hour', true, array($modSettings['pm_posts_per_hour'])); |
|
| 1812 | + } |
|
| 1741 | 1813 | } |
| 1742 | 1814 | |
| 1743 | 1815 | // Quoting/Replying to a message? |
@@ -1746,8 +1818,9 @@ discard block |
||
| 1746 | 1818 | $pmsg = (int) $_REQUEST['pmsg']; |
| 1747 | 1819 | |
| 1748 | 1820 | // Make sure this is yours. |
| 1749 | - if (!isAccessiblePM($pmsg)) |
|
| 1750 | - fatal_lang_error('no_access', false); |
|
| 1821 | + if (!isAccessiblePM($pmsg)) { |
|
| 1822 | + fatal_lang_error('no_access', false); |
|
| 1823 | + } |
|
| 1751 | 1824 | |
| 1752 | 1825 | // Work out whether this is one you've received? |
| 1753 | 1826 | $request = $smcFunc['db_query']('', ' |
@@ -1784,8 +1857,9 @@ discard block |
||
| 1784 | 1857 | 'id_pm' => $pmsg, |
| 1785 | 1858 | ) |
| 1786 | 1859 | ); |
| 1787 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1788 | - fatal_lang_error('pm_not_yours', false); |
|
| 1860 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1861 | + fatal_lang_error('pm_not_yours', false); |
|
| 1862 | + } |
|
| 1789 | 1863 | $row_quoted = $smcFunc['db_fetch_assoc']($request); |
| 1790 | 1864 | $smcFunc['db_free_result']($request); |
| 1791 | 1865 | |
@@ -1796,9 +1870,9 @@ discard block |
||
| 1796 | 1870 | // Add 'Re: ' to it.... |
| 1797 | 1871 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
| 1798 | 1872 | { |
| 1799 | - if ($language === $user_info['language']) |
|
| 1800 | - $context['response_prefix'] = $txt['response_prefix']; |
|
| 1801 | - else |
|
| 1873 | + if ($language === $user_info['language']) { |
|
| 1874 | + $context['response_prefix'] = $txt['response_prefix']; |
|
| 1875 | + } else |
|
| 1802 | 1876 | { |
| 1803 | 1877 | loadLanguage('index', $language, false); |
| 1804 | 1878 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -1807,22 +1881,25 @@ discard block |
||
| 1807 | 1881 | cache_put_data('response_prefix', $context['response_prefix'], 600); |
| 1808 | 1882 | } |
| 1809 | 1883 | $form_subject = $row_quoted['subject']; |
| 1810 | - if ($context['reply'] && trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) |
|
| 1811 | - $form_subject = $context['response_prefix'] . $form_subject; |
|
| 1884 | + if ($context['reply'] && trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) { |
|
| 1885 | + $form_subject = $context['response_prefix'] . $form_subject; |
|
| 1886 | + } |
|
| 1812 | 1887 | |
| 1813 | 1888 | if (isset($_REQUEST['quote'])) |
| 1814 | 1889 | { |
| 1815 | 1890 | // Remove any nested quotes and <br>... |
| 1816 | 1891 | $form_message = preg_replace('~<br ?/?' . '>~i', "\n", $row_quoted['body']); |
| 1817 | - if (!empty($modSettings['removeNestedQuotes'])) |
|
| 1818 | - $form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message); |
|
| 1819 | - if (empty($row_quoted['id_member'])) |
|
| 1820 | - $form_message = '[quote author="' . $row_quoted['real_name'] . '"]' . "\n" . $form_message . "\n" . '[/quote]'; |
|
| 1821 | - else |
|
| 1822 | - $form_message = '[quote author=' . $row_quoted['real_name'] . ' link=action=profile;u=' . $row_quoted['id_member'] . ' date=' . $row_quoted['msgtime'] . ']' . "\n" . $form_message . "\n" . '[/quote]'; |
|
| 1892 | + if (!empty($modSettings['removeNestedQuotes'])) { |
|
| 1893 | + $form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message); |
|
| 1894 | + } |
|
| 1895 | + if (empty($row_quoted['id_member'])) { |
|
| 1896 | + $form_message = '[quote author="' . $row_quoted['real_name'] . '"]' . "\n" . $form_message . "\n" . '[/quote]'; |
|
| 1897 | + } else { |
|
| 1898 | + $form_message = '[quote author=' . $row_quoted['real_name'] . ' link=action=profile;u=' . $row_quoted['id_member'] . ' date=' . $row_quoted['msgtime'] . ']' . "\n" . $form_message . "\n" . '[/quote]'; |
|
| 1899 | + } |
|
| 1900 | + } else { |
|
| 1901 | + $form_message = ''; |
|
| 1823 | 1902 | } |
| 1824 | - else |
|
| 1825 | - $form_message = ''; |
|
| 1826 | 1903 | |
| 1827 | 1904 | // Do the BBC thang on the message. |
| 1828 | 1905 | $row_quoted['body'] = parse_bbc($row_quoted['body'], true, 'pm' . $row_quoted['id_pm']); |
@@ -1843,8 +1920,7 @@ discard block |
||
| 1843 | 1920 | 'timestamp' => forum_time(true, $row_quoted['msgtime']), |
| 1844 | 1921 | 'body' => $row_quoted['body'] |
| 1845 | 1922 | ); |
| 1846 | - } |
|
| 1847 | - else |
|
| 1923 | + } else |
|
| 1848 | 1924 | { |
| 1849 | 1925 | $context['quoted_message'] = false; |
| 1850 | 1926 | $form_subject = ''; |
@@ -1863,11 +1939,12 @@ discard block |
||
| 1863 | 1939 | if ($_REQUEST['u'] == 'all' && isset($row_quoted)) |
| 1864 | 1940 | { |
| 1865 | 1941 | // Firstly, to reply to all we clearly already have $row_quoted - so have the original member from. |
| 1866 | - if ($row_quoted['id_member'] != $user_info['id']) |
|
| 1867 | - $context['recipients']['to'][] = array( |
|
| 1942 | + if ($row_quoted['id_member'] != $user_info['id']) { |
|
| 1943 | + $context['recipients']['to'][] = array( |
|
| 1868 | 1944 | 'id' => $row_quoted['id_member'], |
| 1869 | 1945 | 'name' => $smcFunc['htmlspecialchars']($row_quoted['real_name']), |
| 1870 | 1946 | ); |
| 1947 | + } |
|
| 1871 | 1948 | |
| 1872 | 1949 | // Now to get the others. |
| 1873 | 1950 | $request = $smcFunc['db_query']('', ' |
@@ -1883,18 +1960,19 @@ discard block |
||
| 1883 | 1960 | 'not_bcc' => 0, |
| 1884 | 1961 | ) |
| 1885 | 1962 | ); |
| 1886 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1887 | - $context['recipients']['to'][] = array( |
|
| 1963 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1964 | + $context['recipients']['to'][] = array( |
|
| 1888 | 1965 | 'id' => $row['id_member'], |
| 1889 | 1966 | 'name' => $row['real_name'], |
| 1890 | 1967 | ); |
| 1968 | + } |
|
| 1891 | 1969 | $smcFunc['db_free_result']($request); |
| 1892 | - } |
|
| 1893 | - else |
|
| 1970 | + } else |
|
| 1894 | 1971 | { |
| 1895 | 1972 | $_REQUEST['u'] = explode(',', $_REQUEST['u']); |
| 1896 | - foreach ($_REQUEST['u'] as $key => $uID) |
|
| 1897 | - $_REQUEST['u'][$key] = (int) $uID; |
|
| 1973 | + foreach ($_REQUEST['u'] as $key => $uID) { |
|
| 1974 | + $_REQUEST['u'][$key] = (int) $uID; |
|
| 1975 | + } |
|
| 1898 | 1976 | |
| 1899 | 1977 | $_REQUEST['u'] = array_unique($_REQUEST['u']); |
| 1900 | 1978 | |
@@ -1908,22 +1986,24 @@ discard block |
||
| 1908 | 1986 | 'limit' => count($_REQUEST['u']), |
| 1909 | 1987 | ) |
| 1910 | 1988 | ); |
| 1911 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1912 | - $context['recipients']['to'][] = array( |
|
| 1989 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1990 | + $context['recipients']['to'][] = array( |
|
| 1913 | 1991 | 'id' => $row['id_member'], |
| 1914 | 1992 | 'name' => $row['real_name'], |
| 1915 | 1993 | ); |
| 1994 | + } |
|
| 1916 | 1995 | $smcFunc['db_free_result']($request); |
| 1917 | 1996 | } |
| 1918 | 1997 | |
| 1919 | 1998 | // Get a literal name list in case the user has JavaScript disabled. |
| 1920 | 1999 | $names = array(); |
| 1921 | - foreach ($context['recipients']['to'] as $to) |
|
| 1922 | - $names[] = $to['name']; |
|
| 2000 | + foreach ($context['recipients']['to'] as $to) { |
|
| 2001 | + $names[] = $to['name']; |
|
| 2002 | + } |
|
| 1923 | 2003 | $context['to_value'] = empty($names) ? '' : '"' . implode('", "', $names) . '"'; |
| 2004 | + } else { |
|
| 2005 | + $context['to_value'] = ''; |
|
| 1924 | 2006 | } |
| 1925 | - else |
|
| 1926 | - $context['to_value'] = ''; |
|
| 1927 | 2007 | |
| 1928 | 2008 | // Set the defaults... |
| 1929 | 2009 | $context['subject'] = $form_subject; |
@@ -1993,8 +2073,9 @@ discard block |
||
| 1993 | 2073 | |
| 1994 | 2074 | // validate with loadMemberData() |
| 1995 | 2075 | $memberResult = loadMemberData($user_info['id'], false); |
| 1996 | - if (!$memberResult) |
|
| 1997 | - fatal_lang_error('not_a_user', false); |
|
| 2076 | + if (!$memberResult) { |
|
| 2077 | + fatal_lang_error('not_a_user', false); |
|
| 2078 | + } |
|
| 1998 | 2079 | list ($memID) = $memberResult; |
| 1999 | 2080 | |
| 2000 | 2081 | // drafts is where the functions reside |
@@ -2020,9 +2101,9 @@ discard block |
||
| 2020 | 2101 | $context['sub_template'] = 'send'; |
| 2021 | 2102 | loadJavaScriptFile('PersonalMessage.js', array('defer' => false), 'smf_pms'); |
| 2022 | 2103 | loadJavaScriptFile('suggest.js', array('defer' => false), 'smf_suggest'); |
| 2104 | + } else { |
|
| 2105 | + $context['sub_template'] = 'pm'; |
|
| 2023 | 2106 | } |
| 2024 | - else |
|
| 2025 | - $context['sub_template'] = 'pm'; |
|
| 2026 | 2107 | |
| 2027 | 2108 | $context['page_title'] = $txt['send_message']; |
| 2028 | 2109 | |
@@ -2083,10 +2164,11 @@ discard block |
||
| 2083 | 2164 | ); |
| 2084 | 2165 | if ($smcFunc['db_num_rows']($request) == 0) |
| 2085 | 2166 | { |
| 2086 | - if (!isset($_REQUEST['xml'])) |
|
| 2087 | - fatal_lang_error('pm_not_yours', false); |
|
| 2088 | - else |
|
| 2089 | - $error_types[] = 'pm_not_yours'; |
|
| 2167 | + if (!isset($_REQUEST['xml'])) { |
|
| 2168 | + fatal_lang_error('pm_not_yours', false); |
|
| 2169 | + } else { |
|
| 2170 | + $error_types[] = 'pm_not_yours'; |
|
| 2171 | + } |
|
| 2090 | 2172 | } |
| 2091 | 2173 | $row_quoted = $smcFunc['db_fetch_assoc']($request); |
| 2092 | 2174 | $smcFunc['db_free_result']($request); |
@@ -2133,14 +2215,16 @@ discard block |
||
| 2133 | 2215 | $context['post_error'][$error_type] = true; |
| 2134 | 2216 | if (isset($txt['error_' . $error_type])) |
| 2135 | 2217 | { |
| 2136 | - if ($error_type == 'long_message') |
|
| 2137 | - $txt['error_' . $error_type] = sprintf($txt['error_' . $error_type], $modSettings['max_messageLength']); |
|
| 2218 | + if ($error_type == 'long_message') { |
|
| 2219 | + $txt['error_' . $error_type] = sprintf($txt['error_' . $error_type], $modSettings['max_messageLength']); |
|
| 2220 | + } |
|
| 2138 | 2221 | $context['post_error']['messages'][] = $txt['error_' . $error_type]; |
| 2139 | 2222 | } |
| 2140 | 2223 | |
| 2141 | 2224 | // If it's not a minor error flag it as such. |
| 2142 | - if (!in_array($error_type, array('new_reply', 'not_approved', 'new_replies', 'old_topic', 'need_qr_verification', 'no_subject'))) |
|
| 2143 | - $context['error_type'] = 'serious'; |
|
| 2225 | + if (!in_array($error_type, array('new_reply', 'not_approved', 'new_replies', 'old_topic', 'need_qr_verification', 'no_subject'))) { |
|
| 2226 | + $context['error_type'] = 'serious'; |
|
| 2227 | + } |
|
| 2144 | 2228 | } |
| 2145 | 2229 | |
| 2146 | 2230 | // We need to load the editor once more. |
@@ -2198,8 +2282,9 @@ discard block |
||
| 2198 | 2282 | require_once($sourcedir . '/Subs-Auth.php'); |
| 2199 | 2283 | |
| 2200 | 2284 | // PM Drafts enabled and needed? |
| 2201 | - if ($context['drafts_pm_save'] && (isset($_POST['save_draft']) || isset($_POST['id_pm_draft']))) |
|
| 2202 | - require_once($sourcedir . '/Drafts.php'); |
|
| 2285 | + if ($context['drafts_pm_save'] && (isset($_POST['save_draft']) || isset($_POST['id_pm_draft']))) { |
|
| 2286 | + require_once($sourcedir . '/Drafts.php'); |
|
| 2287 | + } |
|
| 2203 | 2288 | |
| 2204 | 2289 | loadLanguage('PersonalMessage', '', false); |
| 2205 | 2290 | |
@@ -2229,24 +2314,27 @@ discard block |
||
| 2229 | 2314 | |
| 2230 | 2315 | if (!empty($postCount) && $postCount >= $modSettings['pm_posts_per_hour']) |
| 2231 | 2316 | { |
| 2232 | - if (!isset($_REQUEST['xml'])) |
|
| 2233 | - fatal_lang_error('pm_too_many_per_hour', true, array($modSettings['pm_posts_per_hour'])); |
|
| 2234 | - else |
|
| 2235 | - $post_errors[] = 'pm_too_many_per_hour'; |
|
| 2317 | + if (!isset($_REQUEST['xml'])) { |
|
| 2318 | + fatal_lang_error('pm_too_many_per_hour', true, array($modSettings['pm_posts_per_hour'])); |
|
| 2319 | + } else { |
|
| 2320 | + $post_errors[] = 'pm_too_many_per_hour'; |
|
| 2321 | + } |
|
| 2236 | 2322 | } |
| 2237 | 2323 | } |
| 2238 | 2324 | |
| 2239 | 2325 | // If your session timed out, show an error, but do allow to re-submit. |
| 2240 | - if (!isset($_REQUEST['xml']) && checkSession('post', '', false) != '') |
|
| 2241 | - $post_errors[] = 'session_timeout'; |
|
| 2326 | + if (!isset($_REQUEST['xml']) && checkSession('post', '', false) != '') { |
|
| 2327 | + $post_errors[] = 'session_timeout'; |
|
| 2328 | + } |
|
| 2242 | 2329 | |
| 2243 | 2330 | $_REQUEST['subject'] = isset($_REQUEST['subject']) ? trim($_REQUEST['subject']) : ''; |
| 2244 | 2331 | $_REQUEST['to'] = empty($_POST['to']) ? (empty($_GET['to']) ? '' : $_GET['to']) : $_POST['to']; |
| 2245 | 2332 | $_REQUEST['bcc'] = empty($_POST['bcc']) ? (empty($_GET['bcc']) ? '' : $_GET['bcc']) : $_POST['bcc']; |
| 2246 | 2333 | |
| 2247 | 2334 | // Route the input from the 'u' parameter to the 'to'-list. |
| 2248 | - if (!empty($_POST['u'])) |
|
| 2249 | - $_POST['recipient_to'] = explode(',', $_POST['u']); |
|
| 2335 | + if (!empty($_POST['u'])) { |
|
| 2336 | + $_POST['recipient_to'] = explode(',', $_POST['u']); |
|
| 2337 | + } |
|
| 2250 | 2338 | |
| 2251 | 2339 | // Construct the list of recipients. |
| 2252 | 2340 | $recipientList = array(); |
@@ -2258,8 +2346,9 @@ discard block |
||
| 2258 | 2346 | $recipientList[$recipientType] = array(); |
| 2259 | 2347 | if (!empty($_POST['recipient_' . $recipientType]) && is_array($_POST['recipient_' . $recipientType])) |
| 2260 | 2348 | { |
| 2261 | - foreach ($_POST['recipient_' . $recipientType] as $recipient) |
|
| 2262 | - $recipientList[$recipientType][] = (int) $recipient; |
|
| 2349 | + foreach ($_POST['recipient_' . $recipientType] as $recipient) { |
|
| 2350 | + $recipientList[$recipientType][] = (int) $recipient; |
|
| 2351 | + } |
|
| 2263 | 2352 | } |
| 2264 | 2353 | |
| 2265 | 2354 | // Are there also literal names set? |
@@ -2273,10 +2362,11 @@ discard block |
||
| 2273 | 2362 | |
| 2274 | 2363 | foreach ($namedRecipientList[$recipientType] as $index => $recipient) |
| 2275 | 2364 | { |
| 2276 | - if (strlen(trim($recipient)) > 0) |
|
| 2277 | - $namedRecipientList[$recipientType][$index] = $smcFunc['htmlspecialchars']($smcFunc['strtolower'](trim($recipient))); |
|
| 2278 | - else |
|
| 2279 | - unset($namedRecipientList[$recipientType][$index]); |
|
| 2365 | + if (strlen(trim($recipient)) > 0) { |
|
| 2366 | + $namedRecipientList[$recipientType][$index] = $smcFunc['htmlspecialchars']($smcFunc['strtolower'](trim($recipient))); |
|
| 2367 | + } else { |
|
| 2368 | + unset($namedRecipientList[$recipientType][$index]); |
|
| 2369 | + } |
|
| 2280 | 2370 | } |
| 2281 | 2371 | |
| 2282 | 2372 | if (!empty($namedRecipientList[$recipientType])) |
@@ -2306,8 +2396,9 @@ discard block |
||
| 2306 | 2396 | } |
| 2307 | 2397 | |
| 2308 | 2398 | // Selected a recipient to be deleted? Remove them now. |
| 2309 | - if (!empty($_POST['delete_recipient'])) |
|
| 2310 | - $recipientList[$recipientType] = array_diff($recipientList[$recipientType], array((int) $_POST['delete_recipient'])); |
|
| 2399 | + if (!empty($_POST['delete_recipient'])) { |
|
| 2400 | + $recipientList[$recipientType] = array_diff($recipientList[$recipientType], array((int) $_POST['delete_recipient'])); |
|
| 2401 | + } |
|
| 2311 | 2402 | |
| 2312 | 2403 | // Make sure we don't include the same name twice |
| 2313 | 2404 | $recipientList[$recipientType] = array_unique($recipientList[$recipientType]); |
@@ -2317,8 +2408,9 @@ discard block |
||
| 2317 | 2408 | $is_recipient_change = !empty($_POST['delete_recipient']) || !empty($_POST['to_submit']) || !empty($_POST['bcc_submit']); |
| 2318 | 2409 | |
| 2319 | 2410 | // Check if there's at least one recipient. |
| 2320 | - if (empty($recipientList['to']) && empty($recipientList['bcc'])) |
|
| 2321 | - $post_errors[] = 'no_to'; |
|
| 2411 | + if (empty($recipientList['to']) && empty($recipientList['bcc'])) { |
|
| 2412 | + $post_errors[] = 'no_to'; |
|
| 2413 | + } |
|
| 2322 | 2414 | |
| 2323 | 2415 | // Make sure that we remove the members who did get it from the screen. |
| 2324 | 2416 | if (!$is_recipient_change) |
@@ -2332,28 +2424,31 @@ discard block |
||
| 2332 | 2424 | // Since we already have a post error, remove the previous one. |
| 2333 | 2425 | $post_errors = array_diff($post_errors, array('no_to')); |
| 2334 | 2426 | |
| 2335 | - foreach ($namesNotFound[$recipientType] as $name) |
|
| 2336 | - $context['send_log']['failed'][] = sprintf($txt['pm_error_user_not_found'], $name); |
|
| 2427 | + foreach ($namesNotFound[$recipientType] as $name) { |
|
| 2428 | + $context['send_log']['failed'][] = sprintf($txt['pm_error_user_not_found'], $name); |
|
| 2429 | + } |
|
| 2337 | 2430 | } |
| 2338 | 2431 | } |
| 2339 | 2432 | } |
| 2340 | 2433 | |
| 2341 | 2434 | // Did they make any mistakes? |
| 2342 | - if ($_REQUEST['subject'] == '') |
|
| 2343 | - $post_errors[] = 'no_subject'; |
|
| 2344 | - if (!isset($_REQUEST['message']) || $_REQUEST['message'] == '') |
|
| 2345 | - $post_errors[] = 'no_message'; |
|
| 2346 | - elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_REQUEST['message']) > $modSettings['max_messageLength']) |
|
| 2347 | - $post_errors[] = 'long_message'; |
|
| 2348 | - else |
|
| 2435 | + if ($_REQUEST['subject'] == '') { |
|
| 2436 | + $post_errors[] = 'no_subject'; |
|
| 2437 | + } |
|
| 2438 | + if (!isset($_REQUEST['message']) || $_REQUEST['message'] == '') { |
|
| 2439 | + $post_errors[] = 'no_message'; |
|
| 2440 | + } elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_REQUEST['message']) > $modSettings['max_messageLength']) { |
|
| 2441 | + $post_errors[] = 'long_message'; |
|
| 2442 | + } else |
|
| 2349 | 2443 | { |
| 2350 | 2444 | // Preparse the message. |
| 2351 | 2445 | $message = $_REQUEST['message']; |
| 2352 | 2446 | preparsecode($message); |
| 2353 | 2447 | |
| 2354 | 2448 | // Make sure there's still some content left without the tags. |
| 2355 | - if ($smcFunc['htmltrim'](strip_tags(parse_bbc($smcFunc['htmlspecialchars']($message, ENT_QUOTES), false), '<img>')) === '' && (!allowedTo('admin_forum') || strpos($message, '[html]') === false)) |
|
| 2356 | - $post_errors[] = 'no_message'; |
|
| 2449 | + if ($smcFunc['htmltrim'](strip_tags(parse_bbc($smcFunc['htmlspecialchars']($message, ENT_QUOTES), false), '<img>')) === '' && (!allowedTo('admin_forum') || strpos($message, '[html]') === false)) { |
|
| 2450 | + $post_errors[] = 'no_message'; |
|
| 2451 | + } |
|
| 2357 | 2452 | } |
| 2358 | 2453 | |
| 2359 | 2454 | // Wrong verification code? |
@@ -2365,13 +2460,15 @@ discard block |
||
| 2365 | 2460 | ); |
| 2366 | 2461 | $context['require_verification'] = create_control_verification($verificationOptions, true); |
| 2367 | 2462 | |
| 2368 | - if (is_array($context['require_verification'])) |
|
| 2369 | - $post_errors = array_merge($post_errors, $context['require_verification']); |
|
| 2463 | + if (is_array($context['require_verification'])) { |
|
| 2464 | + $post_errors = array_merge($post_errors, $context['require_verification']); |
|
| 2465 | + } |
|
| 2370 | 2466 | } |
| 2371 | 2467 | |
| 2372 | 2468 | // If they did, give a chance to make ammends. |
| 2373 | - if (!empty($post_errors) && !$is_recipient_change && !isset($_REQUEST['preview']) && !isset($_REQUEST['xml'])) |
|
| 2374 | - return messagePostError($post_errors, $namedRecipientList, $recipientList); |
|
| 2469 | + if (!empty($post_errors) && !$is_recipient_change && !isset($_REQUEST['preview']) && !isset($_REQUEST['xml'])) { |
|
| 2470 | + return messagePostError($post_errors, $namedRecipientList, $recipientList); |
|
| 2471 | + } |
|
| 2375 | 2472 | |
| 2376 | 2473 | // Want to take a second glance before you send? |
| 2377 | 2474 | if (isset($_REQUEST['preview'])) |
@@ -2402,8 +2499,9 @@ discard block |
||
| 2402 | 2499 | foreach ($namesNotFound as $recipientType => $names) |
| 2403 | 2500 | { |
| 2404 | 2501 | $post_errors[] = 'bad_' . $recipientType; |
| 2405 | - foreach ($names as $name) |
|
| 2406 | - $context['send_log']['failed'][] = sprintf($txt['pm_error_user_not_found'], $name); |
|
| 2502 | + foreach ($names as $name) { |
|
| 2503 | + $context['send_log']['failed'][] = sprintf($txt['pm_error_user_not_found'], $name); |
|
| 2504 | + } |
|
| 2407 | 2505 | } |
| 2408 | 2506 | |
| 2409 | 2507 | return messagePostError(array(), $namedRecipientList, $recipientList); |
@@ -2433,13 +2531,14 @@ discard block |
||
| 2433 | 2531 | checkSubmitOnce('check'); |
| 2434 | 2532 | |
| 2435 | 2533 | // Do the actual sending of the PM. |
| 2436 | - if (!empty($recipientList['to']) || !empty($recipientList['bcc'])) |
|
| 2437 | - $context['send_log'] = sendpm($recipientList, $_REQUEST['subject'], $_REQUEST['message'], true, null, !empty($_REQUEST['pm_head']) ? (int) $_REQUEST['pm_head'] : 0); |
|
| 2438 | - else |
|
| 2439 | - $context['send_log'] = array( |
|
| 2534 | + if (!empty($recipientList['to']) || !empty($recipientList['bcc'])) { |
|
| 2535 | + $context['send_log'] = sendpm($recipientList, $_REQUEST['subject'], $_REQUEST['message'], true, null, !empty($_REQUEST['pm_head']) ? (int) $_REQUEST['pm_head'] : 0); |
|
| 2536 | + } else { |
|
| 2537 | + $context['send_log'] = array( |
|
| 2440 | 2538 | 'sent' => array(), |
| 2441 | 2539 | 'failed' => array() |
| 2442 | 2540 | ); |
| 2541 | + } |
|
| 2443 | 2542 | |
| 2444 | 2543 | // Mark the message as "replied to". |
| 2445 | 2544 | if (!empty($context['send_log']['sent']) && !empty($_REQUEST['replied_to']) && isset($_REQUEST['f']) && $_REQUEST['f'] == 'inbox') |
@@ -2457,11 +2556,12 @@ discard block |
||
| 2457 | 2556 | } |
| 2458 | 2557 | |
| 2459 | 2558 | // If one or more of the recipient were invalid, go back to the post screen with the failed usernames. |
| 2460 | - if (!empty($context['send_log']['failed'])) |
|
| 2461 | - return messagePostError($post_errors, $namesNotFound, array( |
|
| 2559 | + if (!empty($context['send_log']['failed'])) { |
|
| 2560 | + return messagePostError($post_errors, $namesNotFound, array( |
|
| 2462 | 2561 | 'to' => array_intersect($recipientList['to'], $context['send_log']['failed']), |
| 2463 | 2562 | 'bcc' => array_intersect($recipientList['bcc'], $context['send_log']['failed']) |
| 2464 | 2563 | )); |
| 2564 | + } |
|
| 2465 | 2565 | |
| 2466 | 2566 | // Message sent successfully? |
| 2467 | 2567 | if (!empty($context['send_log']) && empty($context['send_log']['failed'])) |
@@ -2469,8 +2569,9 @@ discard block |
||
| 2469 | 2569 | $context['current_label_redirect'] = $context['current_label_redirect'] . ';done=sent'; |
| 2470 | 2570 | |
| 2471 | 2571 | // If we had a PM draft for this one, then its time to remove it since it was just sent |
| 2472 | - if ($context['drafts_pm_save'] && !empty($_POST['id_pm_draft'])) |
|
| 2473 | - DeleteDraft($_POST['id_pm_draft']); |
|
| 2572 | + if ($context['drafts_pm_save'] && !empty($_POST['id_pm_draft'])) { |
|
| 2573 | + DeleteDraft($_POST['id_pm_draft']); |
|
| 2574 | + } |
|
| 2474 | 2575 | } |
| 2475 | 2576 | |
| 2476 | 2577 | // Go back to the where they sent from, if possible... |
@@ -2485,24 +2586,28 @@ discard block |
||
| 2485 | 2586 | |
| 2486 | 2587 | checkSession('request'); |
| 2487 | 2588 | |
| 2488 | - if (isset($_REQUEST['del_selected'])) |
|
| 2489 | - $_REQUEST['pm_action'] = 'delete'; |
|
| 2589 | + if (isset($_REQUEST['del_selected'])) { |
|
| 2590 | + $_REQUEST['pm_action'] = 'delete'; |
|
| 2591 | + } |
|
| 2490 | 2592 | |
| 2491 | 2593 | if (isset($_REQUEST['pm_action']) && $_REQUEST['pm_action'] != '' && !empty($_REQUEST['pms']) && is_array($_REQUEST['pms'])) |
| 2492 | 2594 | { |
| 2493 | - foreach ($_REQUEST['pms'] as $pm) |
|
| 2494 | - $_REQUEST['pm_actions'][(int) $pm] = $_REQUEST['pm_action']; |
|
| 2595 | + foreach ($_REQUEST['pms'] as $pm) { |
|
| 2596 | + $_REQUEST['pm_actions'][(int) $pm] = $_REQUEST['pm_action']; |
|
| 2597 | + } |
|
| 2495 | 2598 | } |
| 2496 | 2599 | |
| 2497 | - if (empty($_REQUEST['pm_actions'])) |
|
| 2498 | - redirectexit($context['current_label_redirect']); |
|
| 2600 | + if (empty($_REQUEST['pm_actions'])) { |
|
| 2601 | + redirectexit($context['current_label_redirect']); |
|
| 2602 | + } |
|
| 2499 | 2603 | |
| 2500 | 2604 | // If we are in conversation, we may need to apply this to every message in the conversation. |
| 2501 | 2605 | if ($context['display_mode'] == 2 && isset($_REQUEST['conversation'])) |
| 2502 | 2606 | { |
| 2503 | 2607 | $id_pms = array(); |
| 2504 | - foreach ($_REQUEST['pm_actions'] as $pm => $dummy) |
|
| 2505 | - $id_pms[] = (int) $pm; |
|
| 2608 | + foreach ($_REQUEST['pm_actions'] as $pm => $dummy) { |
|
| 2609 | + $id_pms[] = (int) $pm; |
|
| 2610 | + } |
|
| 2506 | 2611 | |
| 2507 | 2612 | $request = $smcFunc['db_query']('', ' |
| 2508 | 2613 | SELECT id_pm_head, id_pm |
@@ -2513,8 +2618,9 @@ discard block |
||
| 2513 | 2618 | ) |
| 2514 | 2619 | ); |
| 2515 | 2620 | $pm_heads = array(); |
| 2516 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2517 | - $pm_heads[$row['id_pm_head']] = $row['id_pm']; |
|
| 2621 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2622 | + $pm_heads[$row['id_pm_head']] = $row['id_pm']; |
|
| 2623 | + } |
|
| 2518 | 2624 | $smcFunc['db_free_result']($request); |
| 2519 | 2625 | |
| 2520 | 2626 | $request = $smcFunc['db_query']('', ' |
@@ -2528,8 +2634,9 @@ discard block |
||
| 2528 | 2634 | // Copy the action from the single to PM to the others. |
| 2529 | 2635 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2530 | 2636 | { |
| 2531 | - if (isset($pm_heads[$row['id_pm_head']]) && isset($_REQUEST['pm_actions'][$pm_heads[$row['id_pm_head']]])) |
|
| 2532 | - $_REQUEST['pm_actions'][$row['id_pm']] = $_REQUEST['pm_actions'][$pm_heads[$row['id_pm_head']]]; |
|
| 2637 | + if (isset($pm_heads[$row['id_pm_head']]) && isset($_REQUEST['pm_actions'][$pm_heads[$row['id_pm_head']]])) { |
|
| 2638 | + $_REQUEST['pm_actions'][$row['id_pm']] = $_REQUEST['pm_actions'][$pm_heads[$row['id_pm_head']]]; |
|
| 2639 | + } |
|
| 2533 | 2640 | } |
| 2534 | 2641 | $smcFunc['db_free_result']($request); |
| 2535 | 2642 | } |
@@ -2540,22 +2647,21 @@ discard block |
||
| 2540 | 2647 | $labels = array(); |
| 2541 | 2648 | foreach ($_REQUEST['pm_actions'] as $pm => $action) |
| 2542 | 2649 | { |
| 2543 | - if ($action === 'delete') |
|
| 2544 | - $to_delete[] = (int) $pm; |
|
| 2545 | - else |
|
| 2650 | + if ($action === 'delete') { |
|
| 2651 | + $to_delete[] = (int) $pm; |
|
| 2652 | + } else |
|
| 2546 | 2653 | { |
| 2547 | 2654 | if (substr($action, 0, 4) == 'add_') |
| 2548 | 2655 | { |
| 2549 | 2656 | $type = 'add'; |
| 2550 | 2657 | $action = substr($action, 4); |
| 2551 | - } |
|
| 2552 | - elseif (substr($action, 0, 4) == 'rem_') |
|
| 2658 | + } elseif (substr($action, 0, 4) == 'rem_') |
|
| 2553 | 2659 | { |
| 2554 | 2660 | $type = 'rem'; |
| 2555 | 2661 | $action = substr($action, 4); |
| 2662 | + } else { |
|
| 2663 | + $type = 'unk'; |
|
| 2556 | 2664 | } |
| 2557 | - else |
|
| 2558 | - $type = 'unk'; |
|
| 2559 | 2665 | |
| 2560 | 2666 | if ($action == '-1' || (int) $action > 0) |
| 2561 | 2667 | { |
@@ -2566,8 +2672,9 @@ discard block |
||
| 2566 | 2672 | } |
| 2567 | 2673 | |
| 2568 | 2674 | // Deleting, it looks like? |
| 2569 | - if (!empty($to_delete)) |
|
| 2570 | - deleteMessages($to_delete, $context['display_mode'] == 2 ? null : $context['folder']); |
|
| 2675 | + if (!empty($to_delete)) { |
|
| 2676 | + deleteMessages($to_delete, $context['display_mode'] == 2 ? null : $context['folder']); |
|
| 2677 | + } |
|
| 2571 | 2678 | |
| 2572 | 2679 | // Are we labeling anything? |
| 2573 | 2680 | if (!empty($to_label) && $context['folder'] == 'inbox') |
@@ -2633,8 +2740,7 @@ discard block |
||
| 2633 | 2740 | } |
| 2634 | 2741 | |
| 2635 | 2742 | $smcFunc['db_free_result']($request2); |
| 2636 | - } |
|
| 2637 | - elseif ($type == 'rem') |
|
| 2743 | + } elseif ($type == 'rem') |
|
| 2638 | 2744 | { |
| 2639 | 2745 | // If we're removing from the inbox, see if we have at least one other label. |
| 2640 | 2746 | // This query is faster than the one above |
@@ -2666,21 +2772,25 @@ discard block |
||
| 2666 | 2772 | if ($to_label[$row['id_pm']] != '-1') |
| 2667 | 2773 | { |
| 2668 | 2774 | // If this label is in the list and we're not adding it, remove it |
| 2669 | - if (array_key_exists($to_label[$row['id_pm']], $labels) && $type !== 'add') |
|
| 2670 | - unset($labels[$to_label[$row['id_pm']]]); |
|
| 2671 | - else if ($type !== 'rem') |
|
| 2672 | - $labels[$to_label[$row['id_pm']]] = $to_label[$row['id_pm']]; |
|
| 2775 | + if (array_key_exists($to_label[$row['id_pm']], $labels) && $type !== 'add') { |
|
| 2776 | + unset($labels[$to_label[$row['id_pm']]]); |
|
| 2777 | + } else if ($type !== 'rem') { |
|
| 2778 | + $labels[$to_label[$row['id_pm']]] = $to_label[$row['id_pm']]; |
|
| 2779 | + } |
|
| 2673 | 2780 | } |
| 2674 | 2781 | |
| 2675 | 2782 | // Removing all labels or just removing the inbox label |
| 2676 | - if ($type == 'rem' && empty($labels)) |
|
| 2677 | - $in_inbox = (empty($context['can_remove_inbox']) ? 1 : 0); |
|
| 2783 | + if ($type == 'rem' && empty($labels)) { |
|
| 2784 | + $in_inbox = (empty($context['can_remove_inbox']) ? 1 : 0); |
|
| 2785 | + } |
|
| 2678 | 2786 | // Adding new labels, but removing inbox and applying new ones |
| 2679 | - elseif ($type == 'add' && !empty($options['pm_remove_inbox_label']) && !empty($labels)) |
|
| 2680 | - $in_inbox = 0; |
|
| 2787 | + elseif ($type == 'add' && !empty($options['pm_remove_inbox_label']) && !empty($labels)) { |
|
| 2788 | + $in_inbox = 0; |
|
| 2789 | + } |
|
| 2681 | 2790 | // Just adding it to the inbox |
| 2682 | - else |
|
| 2683 | - $in_inbox = 1; |
|
| 2791 | + else { |
|
| 2792 | + $in_inbox = 1; |
|
| 2793 | + } |
|
| 2684 | 2794 | |
| 2685 | 2795 | // Are we adding it to or removing it from the inbox? |
| 2686 | 2796 | if ($in_inbox != $row['in_inbox']) |
@@ -2722,8 +2832,9 @@ discard block |
||
| 2722 | 2832 | if (!empty($labels_to_apply)) |
| 2723 | 2833 | { |
| 2724 | 2834 | $inserts = array(); |
| 2725 | - foreach ($labels_to_apply as $label) |
|
| 2726 | - $inserts[] = array($row['id_pm'], $label); |
|
| 2835 | + foreach ($labels_to_apply as $label) { |
|
| 2836 | + $inserts[] = array($row['id_pm'], $label); |
|
| 2837 | + } |
|
| 2727 | 2838 | |
| 2728 | 2839 | $smcFunc['db_insert']('', |
| 2729 | 2840 | '{db_prefix}pm_labeled_messages', |
@@ -2767,11 +2878,13 @@ discard block |
||
| 2767 | 2878 | checkSession('get'); |
| 2768 | 2879 | |
| 2769 | 2880 | // If all then delete all messages the user has. |
| 2770 | - if ($_REQUEST['f'] == 'all') |
|
| 2771 | - deleteMessages(null, null); |
|
| 2881 | + if ($_REQUEST['f'] == 'all') { |
|
| 2882 | + deleteMessages(null, null); |
|
| 2883 | + } |
|
| 2772 | 2884 | // Otherwise just the selected folder. |
| 2773 | - else |
|
| 2774 | - deleteMessages(null, $_REQUEST['f'] != 'sent' ? 'inbox' : 'sent'); |
|
| 2885 | + else { |
|
| 2886 | + deleteMessages(null, $_REQUEST['f'] != 'sent' ? 'inbox' : 'sent'); |
|
| 2887 | + } |
|
| 2775 | 2888 | |
| 2776 | 2889 | // Done... all gone. |
| 2777 | 2890 | redirectexit($context['current_label_redirect']); |
@@ -2808,8 +2921,9 @@ discard block |
||
| 2808 | 2921 | 'msgtime' => $deleteTime, |
| 2809 | 2922 | ) |
| 2810 | 2923 | ); |
| 2811 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 2812 | - $toDelete[] = $row[0]; |
|
| 2924 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 2925 | + $toDelete[] = $row[0]; |
|
| 2926 | + } |
|
| 2813 | 2927 | $smcFunc['db_free_result']($request); |
| 2814 | 2928 | |
| 2815 | 2929 | // Select all messages in their inbox older than $deleteTime. |
@@ -2826,8 +2940,9 @@ discard block |
||
| 2826 | 2940 | 'msgtime' => $deleteTime, |
| 2827 | 2941 | ) |
| 2828 | 2942 | ); |
| 2829 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2830 | - $toDelete[] = $row['id_pm']; |
|
| 2943 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2944 | + $toDelete[] = $row['id_pm']; |
|
| 2945 | + } |
|
| 2831 | 2946 | $smcFunc['db_free_result']($request); |
| 2832 | 2947 | |
| 2833 | 2948 | // Delete the actual messages. |
@@ -2858,26 +2973,29 @@ discard block |
||
| 2858 | 2973 | { |
| 2859 | 2974 | global $user_info, $smcFunc; |
| 2860 | 2975 | |
| 2861 | - if ($owner === null) |
|
| 2862 | - $owner = array($user_info['id']); |
|
| 2863 | - elseif (empty($owner)) |
|
| 2864 | - return; |
|
| 2865 | - elseif (!is_array($owner)) |
|
| 2866 | - $owner = array($owner); |
|
| 2976 | + if ($owner === null) { |
|
| 2977 | + $owner = array($user_info['id']); |
|
| 2978 | + } elseif (empty($owner)) { |
|
| 2979 | + return; |
|
| 2980 | + } elseif (!is_array($owner)) { |
|
| 2981 | + $owner = array($owner); |
|
| 2982 | + } |
|
| 2867 | 2983 | |
| 2868 | 2984 | if ($personal_messages !== null) |
| 2869 | 2985 | { |
| 2870 | - if (empty($personal_messages) || !is_array($personal_messages)) |
|
| 2871 | - return; |
|
| 2986 | + if (empty($personal_messages) || !is_array($personal_messages)) { |
|
| 2987 | + return; |
|
| 2988 | + } |
|
| 2872 | 2989 | |
| 2873 | - foreach ($personal_messages as $index => $delete_id) |
|
| 2874 | - $personal_messages[$index] = (int) $delete_id; |
|
| 2990 | + foreach ($personal_messages as $index => $delete_id) { |
|
| 2991 | + $personal_messages[$index] = (int) $delete_id; |
|
| 2992 | + } |
|
| 2875 | 2993 | |
| 2876 | 2994 | $where = ' |
| 2877 | 2995 | AND id_pm IN ({array_int:pm_list})'; |
| 2996 | + } else { |
|
| 2997 | + $where = ''; |
|
| 2878 | 2998 | } |
| 2879 | - else |
|
| 2880 | - $where = ''; |
|
| 2881 | 2999 | |
| 2882 | 3000 | if ($folder == 'sent' || $folder === null) |
| 2883 | 3001 | { |
@@ -2912,17 +3030,19 @@ discard block |
||
| 2912 | 3030 | // ...And update the statistics accordingly - now including unread messages!. |
| 2913 | 3031 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2914 | 3032 | { |
| 2915 | - if ($row['is_read']) |
|
| 2916 | - updateMemberData($row['id_member'], array('instant_messages' => $where == '' ? 0 : 'instant_messages - ' . $row['num_deleted_messages'])); |
|
| 2917 | - else |
|
| 2918 | - updateMemberData($row['id_member'], array('instant_messages' => $where == '' ? 0 : 'instant_messages - ' . $row['num_deleted_messages'], 'unread_messages' => $where == '' ? 0 : 'unread_messages - ' . $row['num_deleted_messages'])); |
|
| 3033 | + if ($row['is_read']) { |
|
| 3034 | + updateMemberData($row['id_member'], array('instant_messages' => $where == '' ? 0 : 'instant_messages - ' . $row['num_deleted_messages'])); |
|
| 3035 | + } else { |
|
| 3036 | + updateMemberData($row['id_member'], array('instant_messages' => $where == '' ? 0 : 'instant_messages - ' . $row['num_deleted_messages'], 'unread_messages' => $where == '' ? 0 : 'unread_messages - ' . $row['num_deleted_messages'])); |
|
| 3037 | + } |
|
| 2919 | 3038 | |
| 2920 | 3039 | // If this is the current member we need to make their message count correct. |
| 2921 | 3040 | if ($user_info['id'] == $row['id_member']) |
| 2922 | 3041 | { |
| 2923 | 3042 | $user_info['messages'] -= $row['num_deleted_messages']; |
| 2924 | - if (!($row['is_read'])) |
|
| 2925 | - $user_info['unread_messages'] -= $row['num_deleted_messages']; |
|
| 3043 | + if (!($row['is_read'])) { |
|
| 3044 | + $user_info['unread_messages'] -= $row['num_deleted_messages']; |
|
| 3045 | + } |
|
| 2926 | 3046 | } |
| 2927 | 3047 | } |
| 2928 | 3048 | $smcFunc['db_free_result']($request); |
@@ -2990,8 +3110,9 @@ discard block |
||
| 2990 | 3110 | ) |
| 2991 | 3111 | ); |
| 2992 | 3112 | $remove_pms = array(); |
| 2993 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2994 | - $remove_pms[] = $row['sender']; |
|
| 3113 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 3114 | + $remove_pms[] = $row['sender']; |
|
| 3115 | + } |
|
| 2995 | 3116 | $smcFunc['db_free_result']($request); |
| 2996 | 3117 | |
| 2997 | 3118 | if (!empty($remove_pms)) |
@@ -3036,8 +3157,9 @@ discard block |
||
| 3036 | 3157 | { |
| 3037 | 3158 | global $user_info, $context, $smcFunc; |
| 3038 | 3159 | |
| 3039 | - if ($owner === null) |
|
| 3040 | - $owner = $user_info['id']; |
|
| 3160 | + if ($owner === null) { |
|
| 3161 | + $owner = $user_info['id']; |
|
| 3162 | + } |
|
| 3041 | 3163 | |
| 3042 | 3164 | $in_inbox = ''; |
| 3043 | 3165 | |
@@ -3061,8 +3183,7 @@ discard block |
||
| 3061 | 3183 | } |
| 3062 | 3184 | |
| 3063 | 3185 | $smcFunc['db_free_result']($get_messages); |
| 3064 | - } |
|
| 3065 | - elseif ($label = '-1') |
|
| 3186 | + } elseif ($label = '-1') |
|
| 3066 | 3187 | { |
| 3067 | 3188 | // Marking all PMs in your inbox read |
| 3068 | 3189 | $in_inbox = ' |
@@ -3087,8 +3208,9 @@ discard block |
||
| 3087 | 3208 | { |
| 3088 | 3209 | if ($owner == $user_info['id']) |
| 3089 | 3210 | { |
| 3090 | - foreach ($context['labels'] as $label) |
|
| 3091 | - $context['labels'][(int) $label['id']]['unread_messages'] = 0; |
|
| 3211 | + foreach ($context['labels'] as $label) { |
|
| 3212 | + $context['labels'][(int) $label['id']]['unread_messages'] = 0; |
|
| 3213 | + } |
|
| 3092 | 3214 | } |
| 3093 | 3215 | |
| 3094 | 3216 | $result = $smcFunc['db_query']('', ' |
@@ -3108,8 +3230,9 @@ discard block |
||
| 3108 | 3230 | { |
| 3109 | 3231 | $total_unread += $row['num']; |
| 3110 | 3232 | |
| 3111 | - if ($owner != $user_info['id'] || empty($row['id_pm'])) |
|
| 3112 | - continue; |
|
| 3233 | + if ($owner != $user_info['id'] || empty($row['id_pm'])) { |
|
| 3234 | + continue; |
|
| 3235 | + } |
|
| 3113 | 3236 | |
| 3114 | 3237 | $this_labels = array(); |
| 3115 | 3238 | |
@@ -3133,11 +3256,13 @@ discard block |
||
| 3133 | 3256 | |
| 3134 | 3257 | $smcFunc['db_free_result']($result2); |
| 3135 | 3258 | |
| 3136 | - foreach ($this_labels as $this_label) |
|
| 3137 | - $context['labels'][$this_label]['unread_messages'] += $row['num']; |
|
| 3259 | + foreach ($this_labels as $this_label) { |
|
| 3260 | + $context['labels'][$this_label]['unread_messages'] += $row['num']; |
|
| 3261 | + } |
|
| 3138 | 3262 | |
| 3139 | - if ($row['in_inbox'] == 1) |
|
| 3140 | - $context['labels'][-1]['unread_messages'] += $row['num']; |
|
| 3263 | + if ($row['in_inbox'] == 1) { |
|
| 3264 | + $context['labels'][-1]['unread_messages'] += $row['num']; |
|
| 3265 | + } |
|
| 3141 | 3266 | } |
| 3142 | 3267 | $smcFunc['db_free_result']($result); |
| 3143 | 3268 | |
@@ -3146,8 +3271,9 @@ discard block |
||
| 3146 | 3271 | updateMemberData($owner, array('unread_messages' => $total_unread)); |
| 3147 | 3272 | |
| 3148 | 3273 | // If it was for the current member, reflect this in the $user_info array too. |
| 3149 | - if ($owner == $user_info['id']) |
|
| 3150 | - $user_info['unread_messages'] = $total_unread; |
|
| 3274 | + if ($owner == $user_info['id']) { |
|
| 3275 | + $user_info['unread_messages'] = $total_unread; |
|
| 3276 | + } |
|
| 3151 | 3277 | } |
| 3152 | 3278 | } |
| 3153 | 3279 | |
@@ -3175,8 +3301,9 @@ discard block |
||
| 3175 | 3301 | // Add all existing labels to the array to save, slashing them as necessary... |
| 3176 | 3302 | foreach ($context['labels'] as $label) |
| 3177 | 3303 | { |
| 3178 | - if ($label['id'] != -1) |
|
| 3179 | - $the_labels[$label['id']] = $label['name']; |
|
| 3304 | + if ($label['id'] != -1) { |
|
| 3305 | + $the_labels[$label['id']] = $label['name']; |
|
| 3306 | + } |
|
| 3180 | 3307 | } |
| 3181 | 3308 | |
| 3182 | 3309 | if (isset($_POST[$context['session_var']])) |
@@ -3195,8 +3322,9 @@ discard block |
||
| 3195 | 3322 | { |
| 3196 | 3323 | $_POST['label'] = strtr($smcFunc['htmlspecialchars'](trim($_POST['label'])), array(',' => ',')); |
| 3197 | 3324 | |
| 3198 | - if ($smcFunc['strlen']($_POST['label']) > 30) |
|
| 3199 | - $_POST['label'] = $smcFunc['substr']($_POST['label'], 0, 30); |
|
| 3325 | + if ($smcFunc['strlen']($_POST['label']) > 30) { |
|
| 3326 | + $_POST['label'] = $smcFunc['substr']($_POST['label'], 0, 30); |
|
| 3327 | + } |
|
| 3200 | 3328 | if ($_POST['label'] != '') |
| 3201 | 3329 | { |
| 3202 | 3330 | $the_labels[] = $_POST['label']; |
@@ -3217,24 +3345,25 @@ discard block |
||
| 3217 | 3345 | { |
| 3218 | 3346 | foreach ($the_labels as $id => $name) |
| 3219 | 3347 | { |
| 3220 | - if ($id == -1) |
|
| 3221 | - continue; |
|
| 3222 | - elseif (isset($_POST['label_name'][$id])) |
|
| 3348 | + if ($id == -1) { |
|
| 3349 | + continue; |
|
| 3350 | + } elseif (isset($_POST['label_name'][$id])) |
|
| 3223 | 3351 | { |
| 3224 | 3352 | $_POST['label_name'][$id] = trim(strtr($smcFunc['htmlspecialchars']($_POST['label_name'][$id]), array(',' => ','))); |
| 3225 | 3353 | |
| 3226 | - if ($smcFunc['strlen']($_POST['label_name'][$id]) > 30) |
|
| 3227 | - $_POST['label_name'][$id] = $smcFunc['substr']($_POST['label_name'][$id], 0, 30); |
|
| 3354 | + if ($smcFunc['strlen']($_POST['label_name'][$id]) > 30) { |
|
| 3355 | + $_POST['label_name'][$id] = $smcFunc['substr']($_POST['label_name'][$id], 0, 30); |
|
| 3356 | + } |
|
| 3228 | 3357 | if ($_POST['label_name'][$id] != '') |
| 3229 | 3358 | { |
| 3230 | 3359 | // Changing the name of this label? |
| 3231 | - if ($the_labels[$id] != $_POST['label_name'][$id]) |
|
| 3232 | - $label_updates[$id] = $_POST['label_name'][$id]; |
|
| 3360 | + if ($the_labels[$id] != $_POST['label_name'][$id]) { |
|
| 3361 | + $label_updates[$id] = $_POST['label_name'][$id]; |
|
| 3362 | + } |
|
| 3233 | 3363 | |
| 3234 | 3364 | $the_labels[(int) $id] = $_POST['label_name'][$id]; |
| 3235 | 3365 | |
| 3236 | - } |
|
| 3237 | - else |
|
| 3366 | + } else |
|
| 3238 | 3367 | { |
| 3239 | 3368 | unset($the_labels[(int) $id]); |
| 3240 | 3369 | $labels_to_remove[] = $id; |
@@ -3248,8 +3377,9 @@ discard block |
||
| 3248 | 3377 | if (!empty($labels_to_add)) |
| 3249 | 3378 | { |
| 3250 | 3379 | $inserts = array(); |
| 3251 | - foreach ($labels_to_add AS $label) |
|
| 3252 | - $inserts[] = array($user_info['id'], $label); |
|
| 3380 | + foreach ($labels_to_add AS $label) { |
|
| 3381 | + $inserts[] = array($user_info['id'], $label); |
|
| 3382 | + } |
|
| 3253 | 3383 | |
| 3254 | 3384 | $smcFunc['db_insert']('', '{db_prefix}pm_labels', array('id_member' => 'int', 'name' => 'string-30'), $inserts, array()); |
| 3255 | 3385 | } |
@@ -3339,8 +3469,9 @@ discard block |
||
| 3339 | 3469 | // Each action... |
| 3340 | 3470 | foreach ($rule['actions'] as $k2 => $action) |
| 3341 | 3471 | { |
| 3342 | - if ($action['t'] != 'lab' || !in_array($action['v'], $labels_to_remove)) |
|
| 3343 | - continue; |
|
| 3472 | + if ($action['t'] != 'lab' || !in_array($action['v'], $labels_to_remove)) { |
|
| 3473 | + continue; |
|
| 3474 | + } |
|
| 3344 | 3475 | |
| 3345 | 3476 | $rule_changes[] = $rule['id']; |
| 3346 | 3477 | |
@@ -3355,8 +3486,8 @@ discard block |
||
| 3355 | 3486 | { |
| 3356 | 3487 | $rule_changes = array_unique($rule_changes); |
| 3357 | 3488 | // Update/delete as appropriate. |
| 3358 | - foreach ($rule_changes as $k => $id) |
|
| 3359 | - if (!empty($context['rules'][$id]['actions'])) |
|
| 3489 | + foreach ($rule_changes as $k => $id) { |
|
| 3490 | + if (!empty($context['rules'][$id]['actions'])) |
|
| 3360 | 3491 | { |
| 3361 | 3492 | $smcFunc['db_query']('', ' |
| 3362 | 3493 | UPDATE {db_prefix}pm_rules |
@@ -3369,12 +3500,13 @@ discard block |
||
| 3369 | 3500 | 'actions' => $smcFunc['json_encode']($context['rules'][$id]['actions']), |
| 3370 | 3501 | ) |
| 3371 | 3502 | ); |
| 3503 | + } |
|
| 3372 | 3504 | unset($rule_changes[$k]); |
| 3373 | 3505 | } |
| 3374 | 3506 | |
| 3375 | 3507 | // Anything left here means it's lost all actions... |
| 3376 | - if (!empty($rule_changes)) |
|
| 3377 | - $smcFunc['db_query']('', ' |
|
| 3508 | + if (!empty($rule_changes)) { |
|
| 3509 | + $smcFunc['db_query']('', ' |
|
| 3378 | 3510 | DELETE FROM {db_prefix}pm_rules |
| 3379 | 3511 | WHERE id_rule IN ({array_int:rule_list}) |
| 3380 | 3512 | AND id_member = {int:current_member}', |
@@ -3383,6 +3515,7 @@ discard block |
||
| 3383 | 3515 | 'rule_list' => $rule_changes, |
| 3384 | 3516 | ) |
| 3385 | 3517 | ); |
| 3518 | + } |
|
| 3386 | 3519 | } |
| 3387 | 3520 | |
| 3388 | 3521 | // Make sure we're not caching this! |
@@ -3452,8 +3585,9 @@ discard block |
||
| 3452 | 3585 | // Save the fields. |
| 3453 | 3586 | saveProfileFields(); |
| 3454 | 3587 | |
| 3455 | - if (!empty($profile_vars)) |
|
| 3456 | - updateMemberData($user_info['id'], $profile_vars); |
|
| 3588 | + if (!empty($profile_vars)) { |
|
| 3589 | + updateMemberData($user_info['id'], $profile_vars); |
|
| 3590 | + } |
|
| 3457 | 3591 | } |
| 3458 | 3592 | |
| 3459 | 3593 | setupProfileContext( |
@@ -3478,13 +3612,15 @@ discard block |
||
| 3478 | 3612 | global $user_info, $language, $modSettings, $smcFunc; |
| 3479 | 3613 | |
| 3480 | 3614 | // Check that this feature is even enabled! |
| 3481 | - if (empty($modSettings['enableReportPM']) || empty($_REQUEST['pmsg'])) |
|
| 3482 | - fatal_lang_error('no_access', false); |
|
| 3615 | + if (empty($modSettings['enableReportPM']) || empty($_REQUEST['pmsg'])) { |
|
| 3616 | + fatal_lang_error('no_access', false); |
|
| 3617 | + } |
|
| 3483 | 3618 | |
| 3484 | 3619 | $pmsg = (int) $_REQUEST['pmsg']; |
| 3485 | 3620 | |
| 3486 | - if (!isAccessiblePM($pmsg, 'inbox')) |
|
| 3487 | - fatal_lang_error('no_access', false); |
|
| 3621 | + if (!isAccessiblePM($pmsg, 'inbox')) { |
|
| 3622 | + fatal_lang_error('no_access', false); |
|
| 3623 | + } |
|
| 3488 | 3624 | |
| 3489 | 3625 | $context['pm_id'] = $pmsg; |
| 3490 | 3626 | $context['page_title'] = $txt['pm_report_title']; |
@@ -3506,8 +3642,9 @@ discard block |
||
| 3506 | 3642 | ) |
| 3507 | 3643 | ); |
| 3508 | 3644 | $context['admins'] = array(); |
| 3509 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 3510 | - $context['admins'][$row['id_member']] = $row['real_name']; |
|
| 3645 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 3646 | + $context['admins'][$row['id_member']] = $row['real_name']; |
|
| 3647 | + } |
|
| 3511 | 3648 | $smcFunc['db_free_result']($request); |
| 3512 | 3649 | |
| 3513 | 3650 | // How many admins in total? |
@@ -3536,8 +3673,9 @@ discard block |
||
| 3536 | 3673 | ) |
| 3537 | 3674 | ); |
| 3538 | 3675 | // Can only be a hacker here! |
| 3539 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 3540 | - fatal_lang_error('no_access', false); |
|
| 3676 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 3677 | + fatal_lang_error('no_access', false); |
|
| 3678 | + } |
|
| 3541 | 3679 | list ($subject, $body, $time, $memberFromID, $memberFromName) = $smcFunc['db_fetch_row']($request); |
| 3542 | 3680 | $smcFunc['db_free_result']($request); |
| 3543 | 3681 | |
@@ -3561,15 +3699,17 @@ discard block |
||
| 3561 | 3699 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 3562 | 3700 | { |
| 3563 | 3701 | // If it's hidden still don't reveal their names - privacy after all ;) |
| 3564 | - if ($row['bcc']) |
|
| 3565 | - $hidden_recipients++; |
|
| 3566 | - else |
|
| 3567 | - $recipients[] = '[url=' . $scripturl . '?action=profile;u=' . $row['id_member_to'] . ']' . $row['to_name'] . '[/url]'; |
|
| 3702 | + if ($row['bcc']) { |
|
| 3703 | + $hidden_recipients++; |
|
| 3704 | + } else { |
|
| 3705 | + $recipients[] = '[url=' . $scripturl . '?action=profile;u=' . $row['id_member_to'] . ']' . $row['to_name'] . '[/url]'; |
|
| 3706 | + } |
|
| 3568 | 3707 | } |
| 3569 | 3708 | $smcFunc['db_free_result']($request); |
| 3570 | 3709 | |
| 3571 | - if ($hidden_recipients) |
|
| 3572 | - $recipients[] = sprintf($txt['pm_report_pm_hidden'], $hidden_recipients); |
|
| 3710 | + if ($hidden_recipients) { |
|
| 3711 | + $recipients[] = sprintf($txt['pm_report_pm_hidden'], $hidden_recipients); |
|
| 3712 | + } |
|
| 3573 | 3713 | |
| 3574 | 3714 | // Now let's get out and loop through the admins. |
| 3575 | 3715 | $request = $smcFunc['db_query']('', ' |
@@ -3585,8 +3725,9 @@ discard block |
||
| 3585 | 3725 | ); |
| 3586 | 3726 | |
| 3587 | 3727 | // Maybe we shouldn't advertise this? |
| 3588 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 3589 | - fatal_lang_error('no_access', false); |
|
| 3728 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 3729 | + fatal_lang_error('no_access', false); |
|
| 3730 | + } |
|
| 3590 | 3731 | |
| 3591 | 3732 | $memberFromName = un_htmlspecialchars($memberFromName); |
| 3592 | 3733 | |
@@ -3605,8 +3746,9 @@ discard block |
||
| 3605 | 3746 | // Make the body. |
| 3606 | 3747 | $report_body = str_replace(array('{REPORTER}', '{SENDER}'), array(un_htmlspecialchars($user_info['name']), $memberFromName), $txt['pm_report_pm_user_sent']); |
| 3607 | 3748 | $report_body .= "\n" . '[b]' . $_POST['reason'] . '[/b]' . "\n\n"; |
| 3608 | - if (!empty($recipients)) |
|
| 3609 | - $report_body .= $txt['pm_report_pm_other_recipients'] . ' ' . implode(', ', $recipients) . "\n\n"; |
|
| 3749 | + if (!empty($recipients)) { |
|
| 3750 | + $report_body .= $txt['pm_report_pm_other_recipients'] . ' ' . implode(', ', $recipients) . "\n\n"; |
|
| 3751 | + } |
|
| 3610 | 3752 | $report_body .= $txt['pm_report_pm_unedited_below'] . "\n" . '[quote author=' . (empty($memberFromID) ? '"' . $memberFromName . '"' : $memberFromName . ' link=action=profile;u=' . $memberFromID . ' date=' . $time) . ']' . "\n" . un_htmlspecialchars($body) . '[/quote]'; |
| 3611 | 3753 | |
| 3612 | 3754 | // Plonk it in the array ;) |
@@ -3626,12 +3768,14 @@ discard block |
||
| 3626 | 3768 | $smcFunc['db_free_result']($request); |
| 3627 | 3769 | |
| 3628 | 3770 | // Send a different email for each language. |
| 3629 | - foreach ($messagesToSend as $lang => $message) |
|
| 3630 | - sendpm($message['recipients'], $message['subject'], $message['body']); |
|
| 3771 | + foreach ($messagesToSend as $lang => $message) { |
|
| 3772 | + sendpm($message['recipients'], $message['subject'], $message['body']); |
|
| 3773 | + } |
|
| 3631 | 3774 | |
| 3632 | 3775 | // Give the user their own language back! |
| 3633 | - if (!empty($modSettings['userLanguage'])) |
|
| 3634 | - loadLanguage('PersonalMessage', '', false); |
|
| 3776 | + if (!empty($modSettings['userLanguage'])) { |
|
| 3777 | + loadLanguage('PersonalMessage', '', false); |
|
| 3778 | + } |
|
| 3635 | 3779 | |
| 3636 | 3780 | // Leave them with a template. |
| 3637 | 3781 | $context['sub_template'] = 'report_message_complete'; |
@@ -3677,8 +3821,9 @@ discard block |
||
| 3677 | 3821 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 3678 | 3822 | { |
| 3679 | 3823 | // Hide hidden groups! |
| 3680 | - if ($row['hidden'] && !$row['can_moderate'] && !allowedTo('manage_membergroups')) |
|
| 3681 | - continue; |
|
| 3824 | + if ($row['hidden'] && !$row['can_moderate'] && !allowedTo('manage_membergroups')) { |
|
| 3825 | + continue; |
|
| 3826 | + } |
|
| 3682 | 3827 | |
| 3683 | 3828 | $context['groups'][$row['id_group']] = $row['group_name']; |
| 3684 | 3829 | } |
@@ -3704,9 +3849,10 @@ discard block |
||
| 3704 | 3849 | $context['rule'] = $context['rules'][$context['rid']]; |
| 3705 | 3850 | $members = array(); |
| 3706 | 3851 | // Need to get member names! |
| 3707 | - foreach ($context['rule']['criteria'] as $k => $criteria) |
|
| 3708 | - if ($criteria['t'] == 'mid' && !empty($criteria['v'])) |
|
| 3852 | + foreach ($context['rule']['criteria'] as $k => $criteria) { |
|
| 3853 | + if ($criteria['t'] == 'mid' && !empty($criteria['v'])) |
|
| 3709 | 3854 | $members[(int) $criteria['v']] = $k; |
| 3855 | + } |
|
| 3710 | 3856 | |
| 3711 | 3857 | if (!empty($members)) |
| 3712 | 3858 | { |
@@ -3718,19 +3864,20 @@ discard block |
||
| 3718 | 3864 | 'member_list' => array_keys($members), |
| 3719 | 3865 | ) |
| 3720 | 3866 | ); |
| 3721 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 3722 | - $context['rule']['criteria'][$members[$row['id_member']]]['v'] = $row['member_name']; |
|
| 3867 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 3868 | + $context['rule']['criteria'][$members[$row['id_member']]]['v'] = $row['member_name']; |
|
| 3869 | + } |
|
| 3723 | 3870 | $smcFunc['db_free_result']($request); |
| 3724 | 3871 | } |
| 3725 | - } |
|
| 3726 | - else |
|
| 3727 | - $context['rule'] = array( |
|
| 3872 | + } else { |
|
| 3873 | + $context['rule'] = array( |
|
| 3728 | 3874 | 'id' => '', |
| 3729 | 3875 | 'name' => '', |
| 3730 | 3876 | 'criteria' => array(), |
| 3731 | 3877 | 'actions' => array(), |
| 3732 | 3878 | 'logic' => 'and', |
| 3733 | 3879 | ); |
| 3880 | + } |
|
| 3734 | 3881 | } |
| 3735 | 3882 | // Saving? |
| 3736 | 3883 | elseif (isset($_GET['save'])) |
@@ -3740,22 +3887,25 @@ discard block |
||
| 3740 | 3887 | |
| 3741 | 3888 | // Name is easy! |
| 3742 | 3889 | $ruleName = $smcFunc['htmlspecialchars'](trim($_POST['rule_name'])); |
| 3743 | - if (empty($ruleName)) |
|
| 3744 | - fatal_lang_error('pm_rule_no_name', false); |
|
| 3890 | + if (empty($ruleName)) { |
|
| 3891 | + fatal_lang_error('pm_rule_no_name', false); |
|
| 3892 | + } |
|
| 3745 | 3893 | |
| 3746 | 3894 | // Sanity check... |
| 3747 | - if (empty($_POST['ruletype']) || empty($_POST['acttype'])) |
|
| 3748 | - fatal_lang_error('pm_rule_no_criteria', false); |
|
| 3895 | + if (empty($_POST['ruletype']) || empty($_POST['acttype'])) { |
|
| 3896 | + fatal_lang_error('pm_rule_no_criteria', false); |
|
| 3897 | + } |
|
| 3749 | 3898 | |
| 3750 | 3899 | // Let's do the criteria first - it's also hardest! |
| 3751 | 3900 | $criteria = array(); |
| 3752 | 3901 | foreach ($_POST['ruletype'] as $ind => $type) |
| 3753 | 3902 | { |
| 3754 | 3903 | // Check everything is here... |
| 3755 | - if ($type == 'gid' && (!isset($_POST['ruledefgroup'][$ind]) || !isset($context['groups'][$_POST['ruledefgroup'][$ind]]))) |
|
| 3756 | - continue; |
|
| 3757 | - elseif ($type != 'bud' && !isset($_POST['ruledef'][$ind])) |
|
| 3758 | - continue; |
|
| 3904 | + if ($type == 'gid' && (!isset($_POST['ruledefgroup'][$ind]) || !isset($context['groups'][$_POST['ruledefgroup'][$ind]]))) { |
|
| 3905 | + continue; |
|
| 3906 | + } elseif ($type != 'bud' && !isset($_POST['ruledef'][$ind])) { |
|
| 3907 | + continue; |
|
| 3908 | + } |
|
| 3759 | 3909 | |
| 3760 | 3910 | // Members need to be found. |
| 3761 | 3911 | if ($type == 'mid') |
@@ -3779,13 +3929,13 @@ discard block |
||
| 3779 | 3929 | $smcFunc['db_free_result']($request); |
| 3780 | 3930 | |
| 3781 | 3931 | $criteria[] = array('t' => 'mid', 'v' => $memID); |
| 3932 | + } elseif ($type == 'bud') { |
|
| 3933 | + $criteria[] = array('t' => 'bud', 'v' => 1); |
|
| 3934 | + } elseif ($type == 'gid') { |
|
| 3935 | + $criteria[] = array('t' => 'gid', 'v' => (int) $_POST['ruledefgroup'][$ind]); |
|
| 3936 | + } elseif (in_array($type, array('sub', 'msg')) && trim($_POST['ruledef'][$ind]) != '') { |
|
| 3937 | + $criteria[] = array('t' => $type, 'v' => $smcFunc['htmlspecialchars'](trim($_POST['ruledef'][$ind]))); |
|
| 3782 | 3938 | } |
| 3783 | - elseif ($type == 'bud') |
|
| 3784 | - $criteria[] = array('t' => 'bud', 'v' => 1); |
|
| 3785 | - elseif ($type == 'gid') |
|
| 3786 | - $criteria[] = array('t' => 'gid', 'v' => (int) $_POST['ruledefgroup'][$ind]); |
|
| 3787 | - elseif (in_array($type, array('sub', 'msg')) && trim($_POST['ruledef'][$ind]) != '') |
|
| 3788 | - $criteria[] = array('t' => $type, 'v' => $smcFunc['htmlspecialchars'](trim($_POST['ruledef'][$ind]))); |
|
| 3789 | 3939 | } |
| 3790 | 3940 | |
| 3791 | 3941 | // Also do the actions! |
@@ -3795,26 +3945,29 @@ discard block |
||
| 3795 | 3945 | foreach ($_POST['acttype'] as $ind => $type) |
| 3796 | 3946 | { |
| 3797 | 3947 | // Picking a valid label? |
| 3798 | - if ($type == 'lab' && (!isset($_POST['labdef'][$ind]) || !isset($context['labels'][$_POST['labdef'][$ind]]))) |
|
| 3799 | - continue; |
|
| 3948 | + if ($type == 'lab' && (!isset($_POST['labdef'][$ind]) || !isset($context['labels'][$_POST['labdef'][$ind]]))) { |
|
| 3949 | + continue; |
|
| 3950 | + } |
|
| 3800 | 3951 | |
| 3801 | 3952 | // Record what we're doing. |
| 3802 | - if ($type == 'del') |
|
| 3803 | - $doDelete = 1; |
|
| 3804 | - elseif ($type == 'lab') |
|
| 3805 | - $actions[] = array('t' => 'lab', 'v' => (int) $_POST['labdef'][$ind]); |
|
| 3953 | + if ($type == 'del') { |
|
| 3954 | + $doDelete = 1; |
|
| 3955 | + } elseif ($type == 'lab') { |
|
| 3956 | + $actions[] = array('t' => 'lab', 'v' => (int) $_POST['labdef'][$ind]); |
|
| 3957 | + } |
|
| 3806 | 3958 | } |
| 3807 | 3959 | |
| 3808 | - if (empty($criteria) || (empty($actions) && !$doDelete)) |
|
| 3809 | - fatal_lang_error('pm_rule_no_criteria', false); |
|
| 3960 | + if (empty($criteria) || (empty($actions) && !$doDelete)) { |
|
| 3961 | + fatal_lang_error('pm_rule_no_criteria', false); |
|
| 3962 | + } |
|
| 3810 | 3963 | |
| 3811 | 3964 | // What are we storing? |
| 3812 | 3965 | $criteria = $smcFunc['json_encode']($criteria); |
| 3813 | 3966 | $actions = $smcFunc['json_encode']($actions); |
| 3814 | 3967 | |
| 3815 | 3968 | // Create the rule? |
| 3816 | - if (empty($context['rid'])) |
|
| 3817 | - $smcFunc['db_insert']('', |
|
| 3969 | + if (empty($context['rid'])) { |
|
| 3970 | + $smcFunc['db_insert']('', |
|
| 3818 | 3971 | '{db_prefix}pm_rules', |
| 3819 | 3972 | array( |
| 3820 | 3973 | 'id_member' => 'int', 'rule_name' => 'string', 'criteria' => 'string', 'actions' => 'string', |
@@ -3825,8 +3978,8 @@ discard block |
||
| 3825 | 3978 | ), |
| 3826 | 3979 | array('id_rule') |
| 3827 | 3980 | ); |
| 3828 | - else |
|
| 3829 | - $smcFunc['db_query']('', ' |
|
| 3981 | + } else { |
|
| 3982 | + $smcFunc['db_query']('', ' |
|
| 3830 | 3983 | UPDATE {db_prefix}pm_rules |
| 3831 | 3984 | SET rule_name = {string:rule_name}, criteria = {string:criteria}, actions = {string:actions}, |
| 3832 | 3985 | delete_pm = {int:delete_pm}, is_or = {int:is_or} |
@@ -3842,6 +3995,7 @@ discard block |
||
| 3842 | 3995 | 'actions' => $actions, |
| 3843 | 3996 | ) |
| 3844 | 3997 | ); |
| 3998 | + } |
|
| 3845 | 3999 | |
| 3846 | 4000 | redirectexit('action=pm;sa=manrules'); |
| 3847 | 4001 | } |
@@ -3850,11 +4004,12 @@ discard block |
||
| 3850 | 4004 | { |
| 3851 | 4005 | checkSession(); |
| 3852 | 4006 | $toDelete = array(); |
| 3853 | - foreach ($_POST['delrule'] as $k => $v) |
|
| 3854 | - $toDelete[] = (int) $k; |
|
| 4007 | + foreach ($_POST['delrule'] as $k => $v) { |
|
| 4008 | + $toDelete[] = (int) $k; |
|
| 4009 | + } |
|
| 3855 | 4010 | |
| 3856 | - if (!empty($toDelete)) |
|
| 3857 | - $smcFunc['db_query']('', ' |
|
| 4011 | + if (!empty($toDelete)) { |
|
| 4012 | + $smcFunc['db_query']('', ' |
|
| 3858 | 4013 | DELETE FROM {db_prefix}pm_rules |
| 3859 | 4014 | WHERE id_rule IN ({array_int:delete_list}) |
| 3860 | 4015 | AND id_member = {int:current_member}', |
@@ -3863,6 +4018,7 @@ discard block |
||
| 3863 | 4018 | 'delete_list' => $toDelete, |
| 3864 | 4019 | ) |
| 3865 | 4020 | ); |
| 4021 | + } |
|
| 3866 | 4022 | |
| 3867 | 4023 | redirectexit('action=pm;sa=manrules'); |
| 3868 | 4024 | } |
@@ -3881,8 +4037,9 @@ discard block |
||
| 3881 | 4037 | loadRules(); |
| 3882 | 4038 | |
| 3883 | 4039 | // No rules? |
| 3884 | - if (empty($context['rules'])) |
|
| 3885 | - return; |
|
| 4040 | + if (empty($context['rules'])) { |
|
| 4041 | + return; |
|
| 4042 | + } |
|
| 3886 | 4043 | |
| 3887 | 4044 | // Just unread ones? |
| 3888 | 4045 | $ruleQuery = $all_messages ? '' : ' AND pmr.is_new = 1'; |
@@ -3912,8 +4069,9 @@ discard block |
||
| 3912 | 4069 | // Loop through all the criteria hoping to make a match. |
| 3913 | 4070 | foreach ($rule['criteria'] as $criterium) |
| 3914 | 4071 | { |
| 3915 | - if (($criterium['t'] == 'mid' && $criterium['v'] == $row['id_member_from']) || ($criterium['t'] == 'gid' && $criterium['v'] == $row['id_group']) || ($criterium['t'] == 'sub' && strpos($row['subject'], $criterium['v']) !== false) || ($criterium['t'] == 'msg' && strpos($row['body'], $criterium['v']) !== false)) |
|
| 3916 | - $match = true; |
|
| 4072 | + if (($criterium['t'] == 'mid' && $criterium['v'] == $row['id_member_from']) || ($criterium['t'] == 'gid' && $criterium['v'] == $row['id_group']) || ($criterium['t'] == 'sub' && strpos($row['subject'], $criterium['v']) !== false) || ($criterium['t'] == 'msg' && strpos($row['body'], $criterium['v']) !== false)) { |
|
| 4073 | + $match = true; |
|
| 4074 | + } |
|
| 3917 | 4075 | // If we're adding and one criteria don't match then we stop! |
| 3918 | 4076 | elseif ($rule['logic'] == 'and') |
| 3919 | 4077 | { |
@@ -3925,17 +4083,18 @@ discard block |
||
| 3925 | 4083 | // If we have a match the rule must be true - act! |
| 3926 | 4084 | if ($match) |
| 3927 | 4085 | { |
| 3928 | - if ($rule['delete']) |
|
| 3929 | - $actions['deletes'][] = $row['id_pm']; |
|
| 3930 | - else |
|
| 4086 | + if ($rule['delete']) { |
|
| 4087 | + $actions['deletes'][] = $row['id_pm']; |
|
| 4088 | + } else |
|
| 3931 | 4089 | { |
| 3932 | 4090 | foreach ($rule['actions'] as $ruleAction) |
| 3933 | 4091 | { |
| 3934 | 4092 | if ($ruleAction['t'] == 'lab') |
| 3935 | 4093 | { |
| 3936 | 4094 | // Get a basic pot started! |
| 3937 | - if (!isset($actions['labels'][$row['id_pm']])) |
|
| 3938 | - $actions['labels'][$row['id_pm']] = array(); |
|
| 4095 | + if (!isset($actions['labels'][$row['id_pm']])) { |
|
| 4096 | + $actions['labels'][$row['id_pm']] = array(); |
|
| 4097 | + } |
|
| 3939 | 4098 | $actions['labels'][$row['id_pm']][] = $ruleAction['v']; |
| 3940 | 4099 | } |
| 3941 | 4100 | } |
@@ -3946,8 +4105,9 @@ discard block |
||
| 3946 | 4105 | $smcFunc['db_free_result']($request); |
| 3947 | 4106 | |
| 3948 | 4107 | // Deletes are easy! |
| 3949 | - if (!empty($actions['deletes'])) |
|
| 3950 | - deleteMessages($actions['deletes']); |
|
| 4108 | + if (!empty($actions['deletes'])) { |
|
| 4109 | + deleteMessages($actions['deletes']); |
|
| 4110 | + } |
|
| 3951 | 4111 | |
| 3952 | 4112 | // Relabel? |
| 3953 | 4113 | if (!empty($actions['labels'])) |
@@ -3974,8 +4134,7 @@ discard block |
||
| 3974 | 4134 | 'current_member' => $user_info['id'], |
| 3975 | 4135 | ) |
| 3976 | 4136 | ); |
| 3977 | - } |
|
| 3978 | - else |
|
| 4137 | + } else |
|
| 3979 | 4138 | { |
| 3980 | 4139 | $realLabels[] = $label['id']; |
| 3981 | 4140 | } |
@@ -3984,8 +4143,9 @@ discard block |
||
| 3984 | 4143 | |
| 3985 | 4144 | $inserts = array(); |
| 3986 | 4145 | // Now we insert the label info |
| 3987 | - foreach ($realLabels as $a_label) |
|
| 3988 | - $inserts[] = array($pm, $a_label); |
|
| 4146 | + foreach ($realLabels as $a_label) { |
|
| 4147 | + $inserts[] = array($pm, $a_label); |
|
| 4148 | + } |
|
| 3989 | 4149 | |
| 3990 | 4150 | $smcFunc['db_insert']('ignore', |
| 3991 | 4151 | '{db_prefix}pm_labeled_messages', |
@@ -4006,8 +4166,9 @@ discard block |
||
| 4006 | 4166 | { |
| 4007 | 4167 | global $user_info, $context, $smcFunc; |
| 4008 | 4168 | |
| 4009 | - if (isset($context['rules']) && !$reload) |
|
| 4010 | - return; |
|
| 4169 | + if (isset($context['rules']) && !$reload) { |
|
| 4170 | + return; |
|
| 4171 | + } |
|
| 4011 | 4172 | |
| 4012 | 4173 | $request = $smcFunc['db_query']('', ' |
| 4013 | 4174 | SELECT |
@@ -4031,8 +4192,9 @@ discard block |
||
| 4031 | 4192 | 'logic' => $row['is_or'] ? 'or' : 'and', |
| 4032 | 4193 | ); |
| 4033 | 4194 | |
| 4034 | - if ($row['delete_pm']) |
|
| 4035 | - $context['rules'][$row['id_rule']]['actions'][] = array('t' => 'del', 'v' => 1); |
|
| 4195 | + if ($row['delete_pm']) { |
|
| 4196 | + $context['rules'][$row['id_rule']]['actions'][] = array('t' => 'del', 'v' => 1); |
|
| 4197 | + } |
|
| 4036 | 4198 | } |
| 4037 | 4199 | $smcFunc['db_free_result']($request); |
| 4038 | 4200 | } |
@@ -15,8 +15,9 @@ discard block |
||
| 15 | 15 | * @version 2.1 Beta 4 |
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | -if (!defined('SMF')) |
|
| 18 | +if (!defined('SMF')) { |
|
| 19 | 19 | die('No direct access...'); |
| 20 | +} |
|
| 20 | 21 | |
| 21 | 22 | /** |
| 22 | 23 | * This defines every profile field known to man. |
@@ -29,8 +30,9 @@ discard block |
||
| 29 | 30 | global $sourcedir, $profile_vars; |
| 30 | 31 | |
| 31 | 32 | // Don't load this twice! |
| 32 | - if (!empty($profile_fields) && !$force_reload) |
|
| 33 | - return; |
|
| 33 | + if (!empty($profile_fields) && !$force_reload) { |
|
| 34 | + return; |
|
| 35 | + } |
|
| 34 | 36 | |
| 35 | 37 | /* This horrific array defines all the profile fields in the whole world! |
| 36 | 38 | In general each "field" has one array - the key of which is the database column name associated with said field. Each item |
@@ -103,13 +105,14 @@ discard block |
||
| 103 | 105 | if (isset($_POST['bday2'], $_POST['bday3']) && $value > 0 && $_POST['bday2'] > 0) |
| 104 | 106 | { |
| 105 | 107 | // Set to blank? |
| 106 | - if ((int) $_POST['bday3'] == 1 && (int) $_POST['bday2'] == 1 && (int) $value == 1) |
|
| 107 | - $value = '1004-01-01'; |
|
| 108 | - else |
|
| 109 | - $value = checkdate($value, $_POST['bday2'], $_POST['bday3'] < 1004 ? 1004 : $_POST['bday3']) ? sprintf('%04d-%02d-%02d', $_POST['bday3'] < 1004 ? 1004 : $_POST['bday3'], $_POST['bday1'], $_POST['bday2']) : '1004-01-01'; |
|
| 108 | + if ((int) $_POST['bday3'] == 1 && (int) $_POST['bday2'] == 1 && (int) $value == 1) { |
|
| 109 | + $value = '1004-01-01'; |
|
| 110 | + } else { |
|
| 111 | + $value = checkdate($value, $_POST['bday2'], $_POST['bday3'] < 1004 ? 1004 : $_POST['bday3']) ? sprintf('%04d-%02d-%02d', $_POST['bday3'] < 1004 ? 1004 : $_POST['bday3'], $_POST['bday1'], $_POST['bday2']) : '1004-01-01'; |
|
| 112 | + } |
|
| 113 | + } else { |
|
| 114 | + $value = '1004-01-01'; |
|
| 110 | 115 | } |
| 111 | - else |
|
| 112 | - $value = '1004-01-01'; |
|
| 113 | 116 | |
| 114 | 117 | $profile_vars['birthdate'] = $value; |
| 115 | 118 | $cur_profile['birthdate'] = $value; |
@@ -127,8 +130,7 @@ discard block |
||
| 127 | 130 | { |
| 128 | 131 | $value = checkdate($dates[2], $dates[3], $dates[1] < 4 ? 4 : $dates[1]) ? sprintf('%04d-%02d-%02d', $dates[1] < 4 ? 4 : $dates[1], $dates[2], $dates[3]) : '1004-01-01'; |
| 129 | 132 | return true; |
| 130 | - } |
|
| 131 | - else |
|
| 133 | + } else |
|
| 132 | 134 | { |
| 133 | 135 | $value = empty($cur_profile['birthdate']) ? '1004-01-01' : $cur_profile['birthdate']; |
| 134 | 136 | return false; |
@@ -150,10 +152,11 @@ discard block |
||
| 150 | 152 | return $txt['invalid_registration'] . ' ' . strftime('%d %b %Y ' . (strpos($user_info['time_format'], '%H') !== false ? '%I:%M:%S %p' : '%H:%M:%S'), forum_time(false)); |
| 151 | 153 | } |
| 152 | 154 | // As long as it doesn't equal "N/A"... |
| 153 | - elseif ($value != $txt['not_applicable'] && $value != strtotime(strftime('%Y-%m-%d', $cur_profile['date_registered'] + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600))) |
|
| 154 | - $value = $value - ($user_info['time_offset'] + $modSettings['time_offset']) * 3600; |
|
| 155 | - else |
|
| 156 | - $value = $cur_profile['date_registered']; |
|
| 155 | + elseif ($value != $txt['not_applicable'] && $value != strtotime(strftime('%Y-%m-%d', $cur_profile['date_registered'] + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600))) { |
|
| 156 | + $value = $value - ($user_info['time_offset'] + $modSettings['time_offset']) * 3600; |
|
| 157 | + } else { |
|
| 158 | + $value = $cur_profile['date_registered']; |
|
| 159 | + } |
|
| 157 | 160 | |
| 158 | 161 | return true; |
| 159 | 162 | }, |
@@ -177,8 +180,9 @@ discard block |
||
| 177 | 180 | { |
| 178 | 181 | global $context, $old_profile, $profile_vars, $sourcedir, $modSettings; |
| 179 | 182 | |
| 180 | - if (strtolower($value) == strtolower($old_profile['email_address'])) |
|
| 181 | - return false; |
|
| 183 | + if (strtolower($value) == strtolower($old_profile['email_address'])) { |
|
| 184 | + return false; |
|
| 185 | + } |
|
| 182 | 186 | |
| 183 | 187 | $isValid = profileValidateEmail($value, $context['id_member']); |
| 184 | 188 | |
@@ -254,11 +258,11 @@ discard block |
||
| 254 | 258 | |
| 255 | 259 | if (isset($context['profile_languages'][$value])) |
| 256 | 260 | { |
| 257 | - if ($context['user']['is_owner'] && empty($context['password_auth_failed'])) |
|
| 258 | - $_SESSION['language'] = $value; |
|
| 261 | + if ($context['user']['is_owner'] && empty($context['password_auth_failed'])) { |
|
| 262 | + $_SESSION['language'] = $value; |
|
| 263 | + } |
|
| 259 | 264 | return true; |
| 260 | - } |
|
| 261 | - else |
|
| 265 | + } else |
|
| 262 | 266 | { |
| 263 | 267 | $value = $cur_profile['lngfile']; |
| 264 | 268 | return false; |
@@ -282,13 +286,14 @@ discard block |
||
| 282 | 286 | |
| 283 | 287 | // Maybe they are trying to change their password as well? |
| 284 | 288 | $resetPassword = true; |
| 285 | - if (isset($_POST['passwrd1']) && $_POST['passwrd1'] != '' && isset($_POST['passwrd2']) && $_POST['passwrd1'] == $_POST['passwrd2'] && validatePassword($_POST['passwrd1'], $value, array($cur_profile['real_name'], $user_info['username'], $user_info['name'], $user_info['email'])) == null) |
|
| 286 | - $resetPassword = false; |
|
| 289 | + if (isset($_POST['passwrd1']) && $_POST['passwrd1'] != '' && isset($_POST['passwrd2']) && $_POST['passwrd1'] == $_POST['passwrd2'] && validatePassword($_POST['passwrd1'], $value, array($cur_profile['real_name'], $user_info['username'], $user_info['name'], $user_info['email'])) == null) { |
|
| 290 | + $resetPassword = false; |
|
| 291 | + } |
|
| 287 | 292 | |
| 288 | 293 | // Do the reset... this will send them an email too. |
| 289 | - if ($resetPassword) |
|
| 290 | - resetPassword($context['id_member'], $value); |
|
| 291 | - elseif ($value !== null) |
|
| 294 | + if ($resetPassword) { |
|
| 295 | + resetPassword($context['id_member'], $value); |
|
| 296 | + } elseif ($value !== null) |
|
| 292 | 297 | { |
| 293 | 298 | validateUsername($context['id_member'], trim(preg_replace('~[\t\n\r \x0B\0' . ($context['utf8'] ? '\x{A0}\x{AD}\x{2000}-\x{200F}\x{201F}\x{202F}\x{3000}\x{FEFF}' : '\x00-\x08\x0B\x0C\x0E-\x19\xA0') . ']+~' . ($context['utf8'] ? 'u' : ''), ' ', $value))); |
| 294 | 299 | updateMemberData($context['id_member'], array('member_name' => $value)); |
@@ -312,20 +317,23 @@ discard block |
||
| 312 | 317 | 'input_validate' => function(&$value) use ($sourcedir, $user_info, $smcFunc, $cur_profile) |
| 313 | 318 | { |
| 314 | 319 | // If we didn't try it then ignore it! |
| 315 | - if ($value == '') |
|
| 316 | - return false; |
|
| 320 | + if ($value == '') { |
|
| 321 | + return false; |
|
| 322 | + } |
|
| 317 | 323 | |
| 318 | 324 | // Do the two entries for the password even match? |
| 319 | - if (!isset($_POST['passwrd2']) || $value != $_POST['passwrd2']) |
|
| 320 | - return 'bad_new_password'; |
|
| 325 | + if (!isset($_POST['passwrd2']) || $value != $_POST['passwrd2']) { |
|
| 326 | + return 'bad_new_password'; |
|
| 327 | + } |
|
| 321 | 328 | |
| 322 | 329 | // Let's get the validation function into play... |
| 323 | 330 | require_once($sourcedir . '/Subs-Auth.php'); |
| 324 | 331 | $passwordErrors = validatePassword($value, $cur_profile['member_name'], array($cur_profile['real_name'], $user_info['username'], $user_info['name'], $user_info['email'])); |
| 325 | 332 | |
| 326 | 333 | // Were there errors? |
| 327 | - if ($passwordErrors != null) |
|
| 328 | - return 'password_' . $passwordErrors; |
|
| 334 | + if ($passwordErrors != null) { |
|
| 335 | + return 'password_' . $passwordErrors; |
|
| 336 | + } |
|
| 329 | 337 | |
| 330 | 338 | // Set up the new password variable... ready for storage. |
| 331 | 339 | $value = hash_password($cur_profile['member_name'], un_htmlspecialchars($value)); |
@@ -350,8 +358,9 @@ discard block |
||
| 350 | 358 | 'permission' => 'profile_blurb', |
| 351 | 359 | 'input_validate' => function(&$value) use ($smcFunc) |
| 352 | 360 | { |
| 353 | - if ($smcFunc['strlen']($value) > 50) |
|
| 354 | - return 'personal_text_too_long'; |
|
| 361 | + if ($smcFunc['strlen']($value) > 50) { |
|
| 362 | + return 'personal_text_too_long'; |
|
| 363 | + } |
|
| 355 | 364 | |
| 356 | 365 | return true; |
| 357 | 366 | }, |
@@ -386,10 +395,11 @@ discard block |
||
| 386 | 395 | 'permission' => 'moderate_forum', |
| 387 | 396 | 'input_validate' => function(&$value) |
| 388 | 397 | { |
| 389 | - if (!is_numeric($value)) |
|
| 390 | - return 'digits_only'; |
|
| 391 | - else |
|
| 392 | - $value = $value != '' ? strtr($value, array(',' => '', '.' => '', ' ' => '')) : 0; |
|
| 398 | + if (!is_numeric($value)) { |
|
| 399 | + return 'digits_only'; |
|
| 400 | + } else { |
|
| 401 | + $value = $value != '' ? strtr($value, array(',' => '', '.' => '', ' ' => '')) : 0; |
|
| 402 | + } |
|
| 393 | 403 | return true; |
| 394 | 404 | }, |
| 395 | 405 | ), |
@@ -405,15 +415,16 @@ discard block |
||
| 405 | 415 | { |
| 406 | 416 | $value = trim(preg_replace('~[\t\n\r \x0B\0' . ($context['utf8'] ? '\x{A0}\x{AD}\x{2000}-\x{200F}\x{201F}\x{202F}\x{3000}\x{FEFF}' : '\x00-\x08\x0B\x0C\x0E-\x19\xA0') . ']+~' . ($context['utf8'] ? 'u' : ''), ' ', $value)); |
| 407 | 417 | |
| 408 | - if (trim($value) == '') |
|
| 409 | - return 'no_name'; |
|
| 410 | - elseif ($smcFunc['strlen']($value) > 60) |
|
| 411 | - return 'name_too_long'; |
|
| 412 | - elseif ($cur_profile['real_name'] != $value) |
|
| 418 | + if (trim($value) == '') { |
|
| 419 | + return 'no_name'; |
|
| 420 | + } elseif ($smcFunc['strlen']($value) > 60) { |
|
| 421 | + return 'name_too_long'; |
|
| 422 | + } elseif ($cur_profile['real_name'] != $value) |
|
| 413 | 423 | { |
| 414 | 424 | require_once($sourcedir . '/Subs-Members.php'); |
| 415 | - if (isReservedName($value, $context['id_member'])) |
|
| 416 | - return 'name_taken'; |
|
| 425 | + if (isReservedName($value, $context['id_member'])) { |
|
| 426 | + return 'name_taken'; |
|
| 427 | + } |
|
| 417 | 428 | } |
| 418 | 429 | return true; |
| 419 | 430 | }, |
@@ -471,8 +482,9 @@ discard block |
||
| 471 | 482 | 'selected' => $set == $context['member']['smiley_set']['id'] |
| 472 | 483 | ); |
| 473 | 484 | |
| 474 | - if ($context['smiley_sets'][$i]['selected']) |
|
| 475 | - $context['member']['smiley_set']['name'] = $set_names[$i]; |
|
| 485 | + if ($context['smiley_sets'][$i]['selected']) { |
|
| 486 | + $context['member']['smiley_set']['name'] = $set_names[$i]; |
|
| 487 | + } |
|
| 476 | 488 | } |
| 477 | 489 | return true; |
| 478 | 490 | }, |
@@ -481,8 +493,9 @@ discard block |
||
| 481 | 493 | global $modSettings; |
| 482 | 494 | |
| 483 | 495 | $smiley_sets = explode(',', $modSettings['smiley_sets_known']); |
| 484 | - if (!in_array($value, $smiley_sets) && $value != 'none') |
|
| 485 | - $value = ''; |
|
| 496 | + if (!in_array($value, $smiley_sets) && $value != 'none') { |
|
| 497 | + $value = ''; |
|
| 498 | + } |
|
| 486 | 499 | return true; |
| 487 | 500 | }, |
| 488 | 501 | ), |
@@ -497,8 +510,9 @@ discard block |
||
| 497 | 510 | loadLanguage('Settings'); |
| 498 | 511 | |
| 499 | 512 | $context['allow_no_censored'] = false; |
| 500 | - if ($user_info['is_admin'] || $context['user']['is_owner']) |
|
| 501 | - $context['allow_no_censored'] = !empty($modSettings['allow_no_censored']); |
|
| 513 | + if ($user_info['is_admin'] || $context['user']['is_owner']) { |
|
| 514 | + $context['allow_no_censored'] = !empty($modSettings['allow_no_censored']); |
|
| 515 | + } |
|
| 502 | 516 | |
| 503 | 517 | return true; |
| 504 | 518 | }, |
@@ -545,8 +559,9 @@ discard block |
||
| 545 | 559 | 'input_validate' => function($value) |
| 546 | 560 | { |
| 547 | 561 | $tz = smf_list_timezones(); |
| 548 | - if (!isset($tz[$value])) |
|
| 549 | - return 'bad_timezone'; |
|
| 562 | + if (!isset($tz[$value])) { |
|
| 563 | + return 'bad_timezone'; |
|
| 564 | + } |
|
| 550 | 565 | |
| 551 | 566 | return true; |
| 552 | 567 | }, |
@@ -561,8 +576,9 @@ discard block |
||
| 561 | 576 | 'enabled' => !empty($modSettings['titlesEnable']), |
| 562 | 577 | 'input_validate' => function(&$value) use ($smcFunc) |
| 563 | 578 | { |
| 564 | - if ($smcFunc['strlen']($value) > 50) |
|
| 565 | - return 'user_title_too_long'; |
|
| 579 | + if ($smcFunc['strlen']($value) > 50) { |
|
| 580 | + return 'user_title_too_long'; |
|
| 581 | + } |
|
| 566 | 582 | |
| 567 | 583 | return true; |
| 568 | 584 | }, |
@@ -584,10 +600,12 @@ discard block |
||
| 584 | 600 | // Fix the URL... |
| 585 | 601 | 'input_validate' => function(&$value) |
| 586 | 602 | { |
| 587 | - if (strlen(trim($value)) > 0 && strpos($value, '://') === false) |
|
| 588 | - $value = 'http://' . $value; |
|
| 589 | - if (strlen($value) < 8 || (substr($value, 0, 7) !== 'http://' && substr($value, 0, 8) !== 'https://')) |
|
| 590 | - $value = ''; |
|
| 603 | + if (strlen(trim($value)) > 0 && strpos($value, '://') === false) { |
|
| 604 | + $value = 'http://' . $value; |
|
| 605 | + } |
|
| 606 | + if (strlen($value) < 8 || (substr($value, 0, 7) !== 'http://' && substr($value, 0, 8) !== 'https://')) { |
|
| 607 | + $value = ''; |
|
| 608 | + } |
|
| 591 | 609 | return true; |
| 592 | 610 | }, |
| 593 | 611 | 'link_with' => 'website', |
@@ -601,16 +619,19 @@ discard block |
||
| 601 | 619 | foreach ($profile_fields as $key => $field) |
| 602 | 620 | { |
| 603 | 621 | // Do we have permission to do this? |
| 604 | - if (isset($field['permission']) && !allowedTo(($context['user']['is_owner'] ? array($field['permission'] . '_own', $field['permission'] . '_any') : $field['permission'] . '_any')) && !allowedTo($field['permission'])) |
|
| 605 | - unset($profile_fields[$key]); |
|
| 622 | + if (isset($field['permission']) && !allowedTo(($context['user']['is_owner'] ? array($field['permission'] . '_own', $field['permission'] . '_any') : $field['permission'] . '_any')) && !allowedTo($field['permission'])) { |
|
| 623 | + unset($profile_fields[$key]); |
|
| 624 | + } |
|
| 606 | 625 | |
| 607 | 626 | // Is it enabled? |
| 608 | - if (isset($field['enabled']) && !$field['enabled']) |
|
| 609 | - unset($profile_fields[$key]); |
|
| 627 | + if (isset($field['enabled']) && !$field['enabled']) { |
|
| 628 | + unset($profile_fields[$key]); |
|
| 629 | + } |
|
| 610 | 630 | |
| 611 | 631 | // Is it specifically disabled? |
| 612 | - if (in_array($key, $disabled_fields) || (isset($field['link_with']) && in_array($field['link_with'], $disabled_fields))) |
|
| 613 | - unset($profile_fields[$key]); |
|
| 632 | + if (in_array($key, $disabled_fields) || (isset($field['link_with']) && in_array($field['link_with'], $disabled_fields))) { |
|
| 633 | + unset($profile_fields[$key]); |
|
| 634 | + } |
|
| 614 | 635 | } |
| 615 | 636 | } |
| 616 | 637 | |
@@ -635,9 +656,10 @@ discard block |
||
| 635 | 656 | loadProfileFields(true); |
| 636 | 657 | |
| 637 | 658 | // First check for any linked sets. |
| 638 | - foreach ($profile_fields as $key => $field) |
|
| 639 | - if (isset($field['link_with']) && in_array($field['link_with'], $fields)) |
|
| 659 | + foreach ($profile_fields as $key => $field) { |
|
| 660 | + if (isset($field['link_with']) && in_array($field['link_with'], $fields)) |
|
| 640 | 661 | $fields[] = $key; |
| 662 | + } |
|
| 641 | 663 | |
| 642 | 664 | $i = 0; |
| 643 | 665 | $last_type = ''; |
@@ -649,38 +671,46 @@ discard block |
||
| 649 | 671 | $cur_field = &$profile_fields[$field]; |
| 650 | 672 | |
| 651 | 673 | // Does it have a preload and does that preload succeed? |
| 652 | - if (isset($cur_field['preload']) && !$cur_field['preload']()) |
|
| 653 | - continue; |
|
| 674 | + if (isset($cur_field['preload']) && !$cur_field['preload']()) { |
|
| 675 | + continue; |
|
| 676 | + } |
|
| 654 | 677 | |
| 655 | 678 | // If this is anything but complex we need to do more cleaning! |
| 656 | 679 | if ($cur_field['type'] != 'callback' && $cur_field['type'] != 'hidden') |
| 657 | 680 | { |
| 658 | - if (!isset($cur_field['label'])) |
|
| 659 | - $cur_field['label'] = isset($txt[$field]) ? $txt[$field] : $field; |
|
| 681 | + if (!isset($cur_field['label'])) { |
|
| 682 | + $cur_field['label'] = isset($txt[$field]) ? $txt[$field] : $field; |
|
| 683 | + } |
|
| 660 | 684 | |
| 661 | 685 | // Everything has a value! |
| 662 | - if (!isset($cur_field['value'])) |
|
| 663 | - $cur_field['value'] = isset($cur_profile[$field]) ? $cur_profile[$field] : ''; |
|
| 686 | + if (!isset($cur_field['value'])) { |
|
| 687 | + $cur_field['value'] = isset($cur_profile[$field]) ? $cur_profile[$field] : ''; |
|
| 688 | + } |
|
| 664 | 689 | |
| 665 | 690 | // Any input attributes? |
| 666 | 691 | $cur_field['input_attr'] = !empty($cur_field['input_attr']) ? implode(',', $cur_field['input_attr']) : ''; |
| 667 | 692 | } |
| 668 | 693 | |
| 669 | 694 | // Was there an error with this field on posting? |
| 670 | - if (isset($context['profile_errors'][$field])) |
|
| 671 | - $cur_field['is_error'] = true; |
|
| 695 | + if (isset($context['profile_errors'][$field])) { |
|
| 696 | + $cur_field['is_error'] = true; |
|
| 697 | + } |
|
| 672 | 698 | |
| 673 | 699 | // Any javascript stuff? |
| 674 | - if (!empty($cur_field['js_submit'])) |
|
| 675 | - $context['profile_onsubmit_javascript'] .= $cur_field['js_submit']; |
|
| 676 | - if (!empty($cur_field['js'])) |
|
| 677 | - $context['profile_javascript'] .= $cur_field['js']; |
|
| 700 | + if (!empty($cur_field['js_submit'])) { |
|
| 701 | + $context['profile_onsubmit_javascript'] .= $cur_field['js_submit']; |
|
| 702 | + } |
|
| 703 | + if (!empty($cur_field['js'])) { |
|
| 704 | + $context['profile_javascript'] .= $cur_field['js']; |
|
| 705 | + } |
|
| 678 | 706 | |
| 679 | 707 | // Any template stuff? |
| 680 | - if (!empty($cur_field['prehtml'])) |
|
| 681 | - $context['profile_prehtml'] .= $cur_field['prehtml']; |
|
| 682 | - if (!empty($cur_field['posthtml'])) |
|
| 683 | - $context['profile_posthtml'] .= $cur_field['posthtml']; |
|
| 708 | + if (!empty($cur_field['prehtml'])) { |
|
| 709 | + $context['profile_prehtml'] .= $cur_field['prehtml']; |
|
| 710 | + } |
|
| 711 | + if (!empty($cur_field['posthtml'])) { |
|
| 712 | + $context['profile_posthtml'] .= $cur_field['posthtml']; |
|
| 713 | + } |
|
| 684 | 714 | |
| 685 | 715 | // Finally put it into context? |
| 686 | 716 | if ($cur_field['type'] != 'hidden') |
@@ -713,12 +743,14 @@ discard block |
||
| 713 | 743 | }, false);' : ''), true); |
| 714 | 744 | |
| 715 | 745 | // Any onsubmit javascript? |
| 716 | - if (!empty($context['profile_onsubmit_javascript'])) |
|
| 717 | - addInlineJavaScript($context['profile_onsubmit_javascript'], true); |
|
| 746 | + if (!empty($context['profile_onsubmit_javascript'])) { |
|
| 747 | + addInlineJavaScript($context['profile_onsubmit_javascript'], true); |
|
| 748 | + } |
|
| 718 | 749 | |
| 719 | 750 | // Any totally custom stuff? |
| 720 | - if (!empty($context['profile_javascript'])) |
|
| 721 | - addInlineJavaScript($context['profile_javascript'], true); |
|
| 751 | + if (!empty($context['profile_javascript'])) { |
|
| 752 | + addInlineJavaScript($context['profile_javascript'], true); |
|
| 753 | + } |
|
| 722 | 754 | |
| 723 | 755 | // Free up some memory. |
| 724 | 756 | unset($profile_fields); |
@@ -739,8 +771,9 @@ discard block |
||
| 739 | 771 | |
| 740 | 772 | // This allows variables to call activities when they save - by default just to reload their settings |
| 741 | 773 | $context['profile_execute_on_save'] = array(); |
| 742 | - if ($context['user']['is_owner']) |
|
| 743 | - $context['profile_execute_on_save']['reload_user'] = 'profileReloadUser'; |
|
| 774 | + if ($context['user']['is_owner']) { |
|
| 775 | + $context['profile_execute_on_save']['reload_user'] = 'profileReloadUser'; |
|
| 776 | + } |
|
| 744 | 777 | |
| 745 | 778 | // Assume we log nothing. |
| 746 | 779 | $context['log_changes'] = array(); |
@@ -748,8 +781,9 @@ discard block |
||
| 748 | 781 | // Cycle through the profile fields working out what to do! |
| 749 | 782 | foreach ($profile_fields as $key => $field) |
| 750 | 783 | { |
| 751 | - if (!isset($_POST[$key]) || !empty($field['is_dummy']) || (isset($_POST['preview_signature']) && $key == 'signature')) |
|
| 752 | - continue; |
|
| 784 | + if (!isset($_POST[$key]) || !empty($field['is_dummy']) || (isset($_POST['preview_signature']) && $key == 'signature')) { |
|
| 785 | + continue; |
|
| 786 | + } |
|
| 753 | 787 | |
| 754 | 788 | // What gets updated? |
| 755 | 789 | $db_key = isset($field['save_key']) ? $field['save_key'] : $key; |
@@ -777,12 +811,13 @@ discard block |
||
| 777 | 811 | $field['cast_type'] = empty($field['cast_type']) ? $field['type'] : $field['cast_type']; |
| 778 | 812 | |
| 779 | 813 | // Finally, clean up certain types. |
| 780 | - if ($field['cast_type'] == 'int') |
|
| 781 | - $_POST[$key] = (int) $_POST[$key]; |
|
| 782 | - elseif ($field['cast_type'] == 'float') |
|
| 783 | - $_POST[$key] = (float) $_POST[$key]; |
|
| 784 | - elseif ($field['cast_type'] == 'check') |
|
| 785 | - $_POST[$key] = !empty($_POST[$key]) ? 1 : 0; |
|
| 814 | + if ($field['cast_type'] == 'int') { |
|
| 815 | + $_POST[$key] = (int) $_POST[$key]; |
|
| 816 | + } elseif ($field['cast_type'] == 'float') { |
|
| 817 | + $_POST[$key] = (float) $_POST[$key]; |
|
| 818 | + } elseif ($field['cast_type'] == 'check') { |
|
| 819 | + $_POST[$key] = !empty($_POST[$key]) ? 1 : 0; |
|
| 820 | + } |
|
| 786 | 821 | |
| 787 | 822 | // If we got here we're doing OK. |
| 788 | 823 | if ($field['type'] != 'hidden' && (!isset($old_profile[$key]) || $_POST[$key] != $old_profile[$key])) |
@@ -793,11 +828,12 @@ discard block |
||
| 793 | 828 | $cur_profile[$key] = $_POST[$key]; |
| 794 | 829 | |
| 795 | 830 | // Are we logging it? |
| 796 | - if (!empty($field['log_change']) && isset($old_profile[$key])) |
|
| 797 | - $context['log_changes'][$key] = array( |
|
| 831 | + if (!empty($field['log_change']) && isset($old_profile[$key])) { |
|
| 832 | + $context['log_changes'][$key] = array( |
|
| 798 | 833 | 'previous' => $old_profile[$key], |
| 799 | 834 | 'new' => $_POST[$key], |
| 800 | 835 | ); |
| 836 | + } |
|
| 801 | 837 | } |
| 802 | 838 | |
| 803 | 839 | // Logging group changes are a bit different... |
@@ -830,10 +866,11 @@ discard block |
||
| 830 | 866 | { |
| 831 | 867 | foreach ($groups as $id => $group) |
| 832 | 868 | { |
| 833 | - if (isset($context['member_groups'][$group])) |
|
| 834 | - $additional_groups[$type][$id] = $context['member_groups'][$group]['name']; |
|
| 835 | - else |
|
| 836 | - unset($additional_groups[$type][$id]); |
|
| 869 | + if (isset($context['member_groups'][$group])) { |
|
| 870 | + $additional_groups[$type][$id] = $context['member_groups'][$group]['name']; |
|
| 871 | + } else { |
|
| 872 | + unset($additional_groups[$type][$id]); |
|
| 873 | + } |
|
| 837 | 874 | } |
| 838 | 875 | $additional_groups[$type] = implode(', ', $additional_groups[$type]); |
| 839 | 876 | } |
@@ -844,10 +881,11 @@ discard block |
||
| 844 | 881 | } |
| 845 | 882 | |
| 846 | 883 | // @todo Temporary |
| 847 | - if ($context['user']['is_owner']) |
|
| 848 | - $changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own')); |
|
| 849 | - else |
|
| 850 | - $changeOther = allowedTo('profile_extra_any'); |
|
| 884 | + if ($context['user']['is_owner']) { |
|
| 885 | + $changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own')); |
|
| 886 | + } else { |
|
| 887 | + $changeOther = allowedTo('profile_extra_any'); |
|
| 888 | + } |
|
| 851 | 889 | if ($changeOther && empty($post_errors)) |
| 852 | 890 | { |
| 853 | 891 | makeThemeChanges($context['id_member'], isset($_POST['id_theme']) ? (int) $_POST['id_theme'] : $old_profile['id_theme']); |
@@ -855,8 +893,9 @@ discard block |
||
| 855 | 893 | { |
| 856 | 894 | $custom_fields_errors = makeCustomFieldChanges($context['id_member'], $_REQUEST['sa'], false, true); |
| 857 | 895 | |
| 858 | - if (!empty($custom_fields_errors)) |
|
| 859 | - $post_errors = array_merge($post_errors, $custom_fields_errors); |
|
| 896 | + if (!empty($custom_fields_errors)) { |
|
| 897 | + $post_errors = array_merge($post_errors, $custom_fields_errors); |
|
| 898 | + } |
|
| 860 | 899 | } |
| 861 | 900 | } |
| 862 | 901 | |
@@ -882,9 +921,9 @@ discard block |
||
| 882 | 921 | if ($context['user']['is_owner']) |
| 883 | 922 | { |
| 884 | 923 | $changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own', 'profile_website_any', 'profile_website_own', 'profile_signature_any', 'profile_signature_own')); |
| 924 | + } else { |
|
| 925 | + $changeOther = allowedTo(array('profile_extra_any', 'profile_website_any', 'profile_signature_any')); |
|
| 885 | 926 | } |
| 886 | - else |
|
| 887 | - $changeOther = allowedTo(array('profile_extra_any', 'profile_website_any', 'profile_signature_any')); |
|
| 888 | 927 | |
| 889 | 928 | // Arrays of all the changes - makes things easier. |
| 890 | 929 | $profile_bools = array(); |
@@ -895,22 +934,25 @@ discard block |
||
| 895 | 934 | 'ignore_boards', |
| 896 | 935 | ); |
| 897 | 936 | |
| 898 | - if (isset($_POST['sa']) && $_POST['sa'] == 'ignoreboards' && empty($_POST['ignore_brd'])) |
|
| 899 | - $_POST['ignore_brd'] = array(); |
|
| 937 | + if (isset($_POST['sa']) && $_POST['sa'] == 'ignoreboards' && empty($_POST['ignore_brd'])) { |
|
| 938 | + $_POST['ignore_brd'] = array(); |
|
| 939 | + } |
|
| 900 | 940 | |
| 901 | 941 | unset($_POST['ignore_boards']); // Whatever it is set to is a dirty filthy thing. Kinda like our minds. |
| 902 | 942 | if (isset($_POST['ignore_brd'])) |
| 903 | 943 | { |
| 904 | - if (!is_array($_POST['ignore_brd'])) |
|
| 905 | - $_POST['ignore_brd'] = array($_POST['ignore_brd']); |
|
| 944 | + if (!is_array($_POST['ignore_brd'])) { |
|
| 945 | + $_POST['ignore_brd'] = array($_POST['ignore_brd']); |
|
| 946 | + } |
|
| 906 | 947 | |
| 907 | 948 | foreach ($_POST['ignore_brd'] as $k => $d) |
| 908 | 949 | { |
| 909 | 950 | $d = (int) $d; |
| 910 | - if ($d != 0) |
|
| 911 | - $_POST['ignore_brd'][$k] = $d; |
|
| 912 | - else |
|
| 913 | - unset($_POST['ignore_brd'][$k]); |
|
| 951 | + if ($d != 0) { |
|
| 952 | + $_POST['ignore_brd'][$k] = $d; |
|
| 953 | + } else { |
|
| 954 | + unset($_POST['ignore_brd'][$k]); |
|
| 955 | + } |
|
| 914 | 956 | } |
| 915 | 957 | $_POST['ignore_boards'] = implode(',', $_POST['ignore_brd']); |
| 916 | 958 | unset($_POST['ignore_brd']); |
@@ -923,21 +965,26 @@ discard block |
||
| 923 | 965 | makeThemeChanges($memID, isset($_POST['id_theme']) ? (int) $_POST['id_theme'] : $old_profile['id_theme']); |
| 924 | 966 | //makeAvatarChanges($memID, $post_errors); |
| 925 | 967 | |
| 926 | - if (!empty($_REQUEST['sa'])) |
|
| 927 | - makeCustomFieldChanges($memID, $_REQUEST['sa'], false); |
|
| 968 | + if (!empty($_REQUEST['sa'])) { |
|
| 969 | + makeCustomFieldChanges($memID, $_REQUEST['sa'], false); |
|
| 970 | + } |
|
| 928 | 971 | |
| 929 | - foreach ($profile_bools as $var) |
|
| 930 | - if (isset($_POST[$var])) |
|
| 972 | + foreach ($profile_bools as $var) { |
|
| 973 | + if (isset($_POST[$var])) |
|
| 931 | 974 | $profile_vars[$var] = empty($_POST[$var]) ? '0' : '1'; |
| 932 | - foreach ($profile_ints as $var) |
|
| 933 | - if (isset($_POST[$var])) |
|
| 975 | + } |
|
| 976 | + foreach ($profile_ints as $var) { |
|
| 977 | + if (isset($_POST[$var])) |
|
| 934 | 978 | $profile_vars[$var] = $_POST[$var] != '' ? (int) $_POST[$var] : ''; |
| 935 | - foreach ($profile_floats as $var) |
|
| 936 | - if (isset($_POST[$var])) |
|
| 979 | + } |
|
| 980 | + foreach ($profile_floats as $var) { |
|
| 981 | + if (isset($_POST[$var])) |
|
| 937 | 982 | $profile_vars[$var] = (float) $_POST[$var]; |
| 938 | - foreach ($profile_strings as $var) |
|
| 939 | - if (isset($_POST[$var])) |
|
| 983 | + } |
|
| 984 | + foreach ($profile_strings as $var) { |
|
| 985 | + if (isset($_POST[$var])) |
|
| 940 | 986 | $profile_vars[$var] = $_POST[$var]; |
| 987 | + } |
|
| 941 | 988 | } |
| 942 | 989 | } |
| 943 | 990 | |
@@ -971,8 +1018,9 @@ discard block |
||
| 971 | 1018 | ); |
| 972 | 1019 | |
| 973 | 1020 | // Can't change reserved vars. |
| 974 | - if ((isset($_POST['options']) && count(array_intersect(array_keys($_POST['options']), $reservedVars)) != 0) || (isset($_POST['default_options']) && count(array_intersect(array_keys($_POST['default_options']), $reservedVars)) != 0)) |
|
| 975 | - fatal_lang_error('no_access', false); |
|
| 1021 | + if ((isset($_POST['options']) && count(array_intersect(array_keys($_POST['options']), $reservedVars)) != 0) || (isset($_POST['default_options']) && count(array_intersect(array_keys($_POST['default_options']), $reservedVars)) != 0)) { |
|
| 1022 | + fatal_lang_error('no_access', false); |
|
| 1023 | + } |
|
| 976 | 1024 | |
| 977 | 1025 | // Don't allow any overriding of custom fields with default or non-default options. |
| 978 | 1026 | $request = $smcFunc['db_query']('', ' |
@@ -984,8 +1032,9 @@ discard block |
||
| 984 | 1032 | ) |
| 985 | 1033 | ); |
| 986 | 1034 | $custom_fields = array(); |
| 987 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 988 | - $custom_fields[] = $row['col_name']; |
|
| 1035 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1036 | + $custom_fields[] = $row['col_name']; |
|
| 1037 | + } |
|
| 989 | 1038 | $smcFunc['db_free_result']($request); |
| 990 | 1039 | |
| 991 | 1040 | // These are the theme changes... |
@@ -994,33 +1043,39 @@ discard block |
||
| 994 | 1043 | { |
| 995 | 1044 | foreach ($_POST['options'] as $opt => $val) |
| 996 | 1045 | { |
| 997 | - if (in_array($opt, $custom_fields)) |
|
| 998 | - continue; |
|
| 1046 | + if (in_array($opt, $custom_fields)) { |
|
| 1047 | + continue; |
|
| 1048 | + } |
|
| 999 | 1049 | |
| 1000 | 1050 | // These need to be controlled. |
| 1001 | - if ($opt == 'topics_per_page' || $opt == 'messages_per_page') |
|
| 1002 | - $val = max(0, min($val, 50)); |
|
| 1051 | + if ($opt == 'topics_per_page' || $opt == 'messages_per_page') { |
|
| 1052 | + $val = max(0, min($val, 50)); |
|
| 1053 | + } |
|
| 1003 | 1054 | // We don't set this per theme anymore. |
| 1004 | - elseif ($opt == 'allow_no_censored') |
|
| 1005 | - continue; |
|
| 1055 | + elseif ($opt == 'allow_no_censored') { |
|
| 1056 | + continue; |
|
| 1057 | + } |
|
| 1006 | 1058 | |
| 1007 | 1059 | $themeSetArray[] = array($memID, $id_theme, $opt, is_array($val) ? implode(',', $val) : $val); |
| 1008 | 1060 | } |
| 1009 | 1061 | } |
| 1010 | 1062 | |
| 1011 | 1063 | $erase_options = array(); |
| 1012 | - if (isset($_POST['default_options']) && is_array($_POST['default_options'])) |
|
| 1013 | - foreach ($_POST['default_options'] as $opt => $val) |
|
| 1064 | + if (isset($_POST['default_options']) && is_array($_POST['default_options'])) { |
|
| 1065 | + foreach ($_POST['default_options'] as $opt => $val) |
|
| 1014 | 1066 | { |
| 1015 | 1067 | if (in_array($opt, $custom_fields)) |
| 1016 | 1068 | continue; |
| 1069 | + } |
|
| 1017 | 1070 | |
| 1018 | 1071 | // These need to be controlled. |
| 1019 | - if ($opt == 'topics_per_page' || $opt == 'messages_per_page') |
|
| 1020 | - $val = max(0, min($val, 50)); |
|
| 1072 | + if ($opt == 'topics_per_page' || $opt == 'messages_per_page') { |
|
| 1073 | + $val = max(0, min($val, 50)); |
|
| 1074 | + } |
|
| 1021 | 1075 | // Only let admins and owners change the censor. |
| 1022 | - elseif ($opt == 'allow_no_censored' && !$user_info['is_admin'] && !$context['user']['is_owner']) |
|
| 1023 | - continue; |
|
| 1076 | + elseif ($opt == 'allow_no_censored' && !$user_info['is_admin'] && !$context['user']['is_owner']) { |
|
| 1077 | + continue; |
|
| 1078 | + } |
|
| 1024 | 1079 | |
| 1025 | 1080 | $themeSetArray[] = array($memID, 1, $opt, is_array($val) ? implode(',', $val) : $val); |
| 1026 | 1081 | $erase_options[] = $opt; |
@@ -1056,8 +1111,9 @@ discard block |
||
| 1056 | 1111 | |
| 1057 | 1112 | // Admins can choose any theme, even if it's not enabled... |
| 1058 | 1113 | $themes = allowedTo('admin_forum') ? explode(',', $modSettings['knownThemes']) : explode(',', $modSettings['enableThemes']); |
| 1059 | - foreach ($themes as $t) |
|
| 1060 | - cache_put_data('theme_settings-' . $t . ':' . $memID, null, 60); |
|
| 1114 | + foreach ($themes as $t) { |
|
| 1115 | + cache_put_data('theme_settings-' . $t . ':' . $memID, null, 60); |
|
| 1116 | + } |
|
| 1061 | 1117 | } |
| 1062 | 1118 | } |
| 1063 | 1119 | |
@@ -1076,8 +1132,9 @@ discard block |
||
| 1076 | 1132 | if (isset($_POST['edit_notify_boards']) && !empty($_POST['notify_boards'])) |
| 1077 | 1133 | { |
| 1078 | 1134 | // Make sure only integers are deleted. |
| 1079 | - foreach ($_POST['notify_boards'] as $index => $id) |
|
| 1080 | - $_POST['notify_boards'][$index] = (int) $id; |
|
| 1135 | + foreach ($_POST['notify_boards'] as $index => $id) { |
|
| 1136 | + $_POST['notify_boards'][$index] = (int) $id; |
|
| 1137 | + } |
|
| 1081 | 1138 | |
| 1082 | 1139 | // id_board = 0 is reserved for topic notifications. |
| 1083 | 1140 | $_POST['notify_boards'] = array_diff($_POST['notify_boards'], array(0)); |
@@ -1096,8 +1153,9 @@ discard block |
||
| 1096 | 1153 | // We are editing topic notifications...... |
| 1097 | 1154 | elseif (isset($_POST['edit_notify_topics']) && !empty($_POST['notify_topics'])) |
| 1098 | 1155 | { |
| 1099 | - foreach ($_POST['notify_topics'] as $index => $id) |
|
| 1100 | - $_POST['notify_topics'][$index] = (int) $id; |
|
| 1156 | + foreach ($_POST['notify_topics'] as $index => $id) { |
|
| 1157 | + $_POST['notify_topics'][$index] = (int) $id; |
|
| 1158 | + } |
|
| 1101 | 1159 | |
| 1102 | 1160 | // Make sure there are no zeros left. |
| 1103 | 1161 | $_POST['notify_topics'] = array_diff($_POST['notify_topics'], array(0)); |
@@ -1111,16 +1169,18 @@ discard block |
||
| 1111 | 1169 | 'selected_member' => $memID, |
| 1112 | 1170 | ) |
| 1113 | 1171 | ); |
| 1114 | - foreach ($_POST['notify_topics'] as $topic) |
|
| 1115 | - setNotifyPrefs($memID, array('topic_notify_' . $topic => 0)); |
|
| 1172 | + foreach ($_POST['notify_topics'] as $topic) { |
|
| 1173 | + setNotifyPrefs($memID, array('topic_notify_' . $topic => 0)); |
|
| 1174 | + } |
|
| 1116 | 1175 | } |
| 1117 | 1176 | |
| 1118 | 1177 | // We are removing topic preferences |
| 1119 | 1178 | elseif (isset($_POST['remove_notify_topics']) && !empty($_POST['notify_topics'])) |
| 1120 | 1179 | { |
| 1121 | 1180 | $prefs = array(); |
| 1122 | - foreach ($_POST['notify_topics'] as $topic) |
|
| 1123 | - $prefs[] = 'topic_notify_' . $topic; |
|
| 1181 | + foreach ($_POST['notify_topics'] as $topic) { |
|
| 1182 | + $prefs[] = 'topic_notify_' . $topic; |
|
| 1183 | + } |
|
| 1124 | 1184 | deleteNotifyPrefs($memID, $prefs); |
| 1125 | 1185 | } |
| 1126 | 1186 | |
@@ -1128,8 +1188,9 @@ discard block |
||
| 1128 | 1188 | elseif (isset($_POST['remove_notify_board']) && !empty($_POST['notify_boards'])) |
| 1129 | 1189 | { |
| 1130 | 1190 | $prefs = array(); |
| 1131 | - foreach ($_POST['notify_boards'] as $board) |
|
| 1132 | - $prefs[] = 'board_notify_' . $board; |
|
| 1191 | + foreach ($_POST['notify_boards'] as $board) { |
|
| 1192 | + $prefs[] = 'board_notify_' . $board; |
|
| 1193 | + } |
|
| 1133 | 1194 | deleteNotifyPrefs($memID, $prefs); |
| 1134 | 1195 | } |
| 1135 | 1196 | } |
@@ -1150,8 +1211,9 @@ discard block |
||
| 1150 | 1211 | |
| 1151 | 1212 | $errors = array(); |
| 1152 | 1213 | |
| 1153 | - if ($sanitize && isset($_POST['customfield'])) |
|
| 1154 | - $_POST['customfield'] = htmlspecialchars__recursive($_POST['customfield']); |
|
| 1214 | + if ($sanitize && isset($_POST['customfield'])) { |
|
| 1215 | + $_POST['customfield'] = htmlspecialchars__recursive($_POST['customfield']); |
|
| 1216 | + } |
|
| 1155 | 1217 | |
| 1156 | 1218 | $where = $area == 'register' ? 'show_reg != 0' : 'show_profile = {string:area}'; |
| 1157 | 1219 | |
@@ -1176,26 +1238,29 @@ discard block |
||
| 1176 | 1238 | - The data is not invisible to users but editable by the owner (or if it is the user is not the owner) |
| 1177 | 1239 | - The area isn't registration, and if it is that the field is not supposed to be shown there. |
| 1178 | 1240 | */ |
| 1179 | - if ($row['private'] != 0 && !allowedTo('admin_forum') && ($memID != $user_info['id'] || $row['private'] != 2) && ($area != 'register' || $row['show_reg'] == 0)) |
|
| 1180 | - continue; |
|
| 1241 | + if ($row['private'] != 0 && !allowedTo('admin_forum') && ($memID != $user_info['id'] || $row['private'] != 2) && ($area != 'register' || $row['show_reg'] == 0)) { |
|
| 1242 | + continue; |
|
| 1243 | + } |
|
| 1181 | 1244 | |
| 1182 | 1245 | // Validate the user data. |
| 1183 | - if ($row['field_type'] == 'check') |
|
| 1184 | - $value = isset($_POST['customfield'][$row['col_name']]) ? 1 : 0; |
|
| 1185 | - elseif ($row['field_type'] == 'select' || $row['field_type'] == 'radio') |
|
| 1246 | + if ($row['field_type'] == 'check') { |
|
| 1247 | + $value = isset($_POST['customfield'][$row['col_name']]) ? 1 : 0; |
|
| 1248 | + } elseif ($row['field_type'] == 'select' || $row['field_type'] == 'radio') |
|
| 1186 | 1249 | { |
| 1187 | 1250 | $value = $row['default_value']; |
| 1188 | - foreach (explode(',', $row['field_options']) as $k => $v) |
|
| 1189 | - if (isset($_POST['customfield'][$row['col_name']]) && $_POST['customfield'][$row['col_name']] == $k) |
|
| 1251 | + foreach (explode(',', $row['field_options']) as $k => $v) { |
|
| 1252 | + if (isset($_POST['customfield'][$row['col_name']]) && $_POST['customfield'][$row['col_name']] == $k) |
|
| 1190 | 1253 | $value = $v; |
| 1254 | + } |
|
| 1191 | 1255 | } |
| 1192 | 1256 | // Otherwise some form of text! |
| 1193 | 1257 | else |
| 1194 | 1258 | { |
| 1195 | 1259 | $value = isset($_POST['customfield'][$row['col_name']]) ? $_POST['customfield'][$row['col_name']] : ''; |
| 1196 | 1260 | |
| 1197 | - if ($row['field_length']) |
|
| 1198 | - $value = $smcFunc['substr']($value, 0, $row['field_length']); |
|
| 1261 | + if ($row['field_length']) { |
|
| 1262 | + $value = $smcFunc['substr']($value, 0, $row['field_length']); |
|
| 1263 | + } |
|
| 1199 | 1264 | |
| 1200 | 1265 | // Any masks? |
| 1201 | 1266 | if ($row['field_type'] == 'text' && !empty($row['mask']) && $row['mask'] != 'none') |
@@ -1204,36 +1269,34 @@ discard block |
||
| 1204 | 1269 | $valueReference = un_htmlspecialchars($value); |
| 1205 | 1270 | |
| 1206 | 1271 | // Try and avoid some checks. '0' could be a valid non-empty value. |
| 1207 | - if (empty($value) && !is_numeric($value)) |
|
| 1208 | - $value = ''; |
|
| 1272 | + if (empty($value) && !is_numeric($value)) { |
|
| 1273 | + $value = ''; |
|
| 1274 | + } |
|
| 1209 | 1275 | |
| 1210 | 1276 | if ($row['mask'] == 'nohtml' && ($valueReference != strip_tags($valueReference) || $value != filter_var($value, FILTER_SANITIZE_STRING) || preg_match('/<(.+?)[\s]*\/?[\s]*>/si', $valueReference))) |
| 1211 | 1277 | { |
| 1212 | - if ($returnErrors) |
|
| 1213 | - $errors[] = 'custom_field_nohtml_fail'; |
|
| 1214 | - |
|
| 1215 | - else |
|
| 1216 | - $value = ''; |
|
| 1217 | - } |
|
| 1218 | - elseif ($row['mask'] == 'email' && (!filter_var($value, FILTER_VALIDATE_EMAIL) || strlen($value) > 255)) |
|
| 1278 | + if ($returnErrors) { |
|
| 1279 | + $errors[] = 'custom_field_nohtml_fail'; |
|
| 1280 | + } else { |
|
| 1281 | + $value = ''; |
|
| 1282 | + } |
|
| 1283 | + } elseif ($row['mask'] == 'email' && (!filter_var($value, FILTER_VALIDATE_EMAIL) || strlen($value) > 255)) |
|
| 1219 | 1284 | { |
| 1220 | - if ($returnErrors) |
|
| 1221 | - $errors[] = 'custom_field_mail_fail'; |
|
| 1222 | - |
|
| 1223 | - else |
|
| 1224 | - $value = ''; |
|
| 1225 | - } |
|
| 1226 | - elseif ($row['mask'] == 'number') |
|
| 1285 | + if ($returnErrors) { |
|
| 1286 | + $errors[] = 'custom_field_mail_fail'; |
|
| 1287 | + } else { |
|
| 1288 | + $value = ''; |
|
| 1289 | + } |
|
| 1290 | + } elseif ($row['mask'] == 'number') |
|
| 1227 | 1291 | { |
| 1228 | 1292 | $value = (int) $value; |
| 1229 | - } |
|
| 1230 | - elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0) |
|
| 1293 | + } elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0) |
|
| 1231 | 1294 | { |
| 1232 | - if ($returnErrors) |
|
| 1233 | - $errors[] = 'custom_field_regex_fail'; |
|
| 1234 | - |
|
| 1235 | - else |
|
| 1236 | - $value = ''; |
|
| 1295 | + if ($returnErrors) { |
|
| 1296 | + $errors[] = 'custom_field_regex_fail'; |
|
| 1297 | + } else { |
|
| 1298 | + $value = ''; |
|
| 1299 | + } |
|
| 1237 | 1300 | } |
| 1238 | 1301 | |
| 1239 | 1302 | unset($valueReference); |
@@ -1261,8 +1324,9 @@ discard block |
||
| 1261 | 1324 | |
| 1262 | 1325 | $hook_errors = call_integration_hook('integrate_save_custom_profile_fields', array(&$changes, &$log_changes, &$errors, $returnErrors, $memID, $area, $sanitize)); |
| 1263 | 1326 | |
| 1264 | - if (!empty($hook_errors) && is_array($hook_errors)) |
|
| 1265 | - $errors = array_merge($errors, $hook_errors); |
|
| 1327 | + if (!empty($hook_errors) && is_array($hook_errors)) { |
|
| 1328 | + $errors = array_merge($errors, $hook_errors); |
|
| 1329 | + } |
|
| 1266 | 1330 | |
| 1267 | 1331 | // Make those changes! |
| 1268 | 1332 | if (!empty($changes) && empty($context['password_auth_failed']) && empty($errors)) |
@@ -1280,9 +1344,10 @@ discard block |
||
| 1280 | 1344 | } |
| 1281 | 1345 | } |
| 1282 | 1346 | |
| 1283 | - if ($returnErrors) |
|
| 1284 | - return $errors; |
|
| 1285 | -} |
|
| 1347 | + if ($returnErrors) { |
|
| 1348 | + return $errors; |
|
| 1349 | + } |
|
| 1350 | + } |
|
| 1286 | 1351 | |
| 1287 | 1352 | /** |
| 1288 | 1353 | * Show all the users buddies, as well as a add/delete interface. |
@@ -1294,8 +1359,9 @@ discard block |
||
| 1294 | 1359 | global $context, $txt, $modSettings; |
| 1295 | 1360 | |
| 1296 | 1361 | // Do a quick check to ensure people aren't getting here illegally! |
| 1297 | - if (!$context['user']['is_owner'] || empty($modSettings['enable_buddylist'])) |
|
| 1298 | - fatal_lang_error('no_access', false); |
|
| 1362 | + if (!$context['user']['is_owner'] || empty($modSettings['enable_buddylist'])) { |
|
| 1363 | + fatal_lang_error('no_access', false); |
|
| 1364 | + } |
|
| 1299 | 1365 | |
| 1300 | 1366 | // Can we email the user direct? |
| 1301 | 1367 | $context['can_moderate_forum'] = allowedTo('moderate_forum'); |
@@ -1325,9 +1391,10 @@ discard block |
||
| 1325 | 1391 | $context['sub_template'] = $subActions[$context['list_area']][0]; |
| 1326 | 1392 | $call = call_helper($subActions[$context['list_area']][0], true); |
| 1327 | 1393 | |
| 1328 | - if (!empty($call)) |
|
| 1329 | - call_user_func($call, $memID); |
|
| 1330 | -} |
|
| 1394 | + if (!empty($call)) { |
|
| 1395 | + call_user_func($call, $memID); |
|
| 1396 | + } |
|
| 1397 | + } |
|
| 1331 | 1398 | |
| 1332 | 1399 | /** |
| 1333 | 1400 | * Show all the users buddies, as well as a add/delete interface. |
@@ -1341,9 +1408,10 @@ discard block |
||
| 1341 | 1408 | |
| 1342 | 1409 | // For making changes! |
| 1343 | 1410 | $buddiesArray = explode(',', $user_profile[$memID]['buddy_list']); |
| 1344 | - foreach ($buddiesArray as $k => $dummy) |
|
| 1345 | - if ($dummy == '') |
|
| 1411 | + foreach ($buddiesArray as $k => $dummy) { |
|
| 1412 | + if ($dummy == '') |
|
| 1346 | 1413 | unset($buddiesArray[$k]); |
| 1414 | + } |
|
| 1347 | 1415 | |
| 1348 | 1416 | // Removing a buddy? |
| 1349 | 1417 | if (isset($_GET['remove'])) |
@@ -1355,10 +1423,11 @@ discard block |
||
| 1355 | 1423 | $_SESSION['prf-save'] = $txt['could_not_remove_person']; |
| 1356 | 1424 | |
| 1357 | 1425 | // Heh, I'm lazy, do it the easy way... |
| 1358 | - foreach ($buddiesArray as $key => $buddy) |
|
| 1359 | - if ($buddy == (int) $_GET['remove']) |
|
| 1426 | + foreach ($buddiesArray as $key => $buddy) { |
|
| 1427 | + if ($buddy == (int) $_GET['remove']) |
|
| 1360 | 1428 | { |
| 1361 | 1429 | unset($buddiesArray[$key]); |
| 1430 | + } |
|
| 1362 | 1431 | $_SESSION['prf-save'] = true; |
| 1363 | 1432 | } |
| 1364 | 1433 | |
@@ -1368,8 +1437,7 @@ discard block |
||
| 1368 | 1437 | |
| 1369 | 1438 | // Redirect off the page because we don't like all this ugly query stuff to stick in the history. |
| 1370 | 1439 | redirectexit('action=profile;area=lists;sa=buddies;u=' . $memID); |
| 1371 | - } |
|
| 1372 | - elseif (isset($_POST['new_buddy'])) |
|
| 1440 | + } elseif (isset($_POST['new_buddy'])) |
|
| 1373 | 1441 | { |
| 1374 | 1442 | checkSession(); |
| 1375 | 1443 | |
@@ -1382,8 +1450,9 @@ discard block |
||
| 1382 | 1450 | { |
| 1383 | 1451 | $new_buddies[$k] = strtr(trim($new_buddies[$k]), array('\'' => ''')); |
| 1384 | 1452 | |
| 1385 | - if (strlen($new_buddies[$k]) == 0 || in_array($new_buddies[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) |
|
| 1386 | - unset($new_buddies[$k]); |
|
| 1453 | + if (strlen($new_buddies[$k]) == 0 || in_array($new_buddies[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) { |
|
| 1454 | + unset($new_buddies[$k]); |
|
| 1455 | + } |
|
| 1387 | 1456 | } |
| 1388 | 1457 | |
| 1389 | 1458 | call_integration_hook('integrate_add_buddies', array($memID, &$new_buddies)); |
@@ -1403,16 +1472,18 @@ discard block |
||
| 1403 | 1472 | ) |
| 1404 | 1473 | ); |
| 1405 | 1474 | |
| 1406 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 1407 | - $_SESSION['prf-save'] = true; |
|
| 1475 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 1476 | + $_SESSION['prf-save'] = true; |
|
| 1477 | + } |
|
| 1408 | 1478 | |
| 1409 | 1479 | // Add the new member to the buddies array. |
| 1410 | 1480 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1411 | 1481 | { |
| 1412 | - if (in_array($row['id_member'], $buddiesArray)) |
|
| 1413 | - continue; |
|
| 1414 | - else |
|
| 1415 | - $buddiesArray[] = (int) $row['id_member']; |
|
| 1482 | + if (in_array($row['id_member'], $buddiesArray)) { |
|
| 1483 | + continue; |
|
| 1484 | + } else { |
|
| 1485 | + $buddiesArray[] = (int) $row['id_member']; |
|
| 1486 | + } |
|
| 1416 | 1487 | } |
| 1417 | 1488 | $smcFunc['db_free_result']($request); |
| 1418 | 1489 | |
@@ -1442,18 +1513,20 @@ discard block |
||
| 1442 | 1513 | |
| 1443 | 1514 | $context['custom_pf'] = array(); |
| 1444 | 1515 | $disabled_fields = isset($modSettings['disabled_profile_fields']) ? array_flip(explode(',', $modSettings['disabled_profile_fields'])) : array(); |
| 1445 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1446 | - if (!isset($disabled_fields[$row['col_name']])) |
|
| 1516 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1517 | + if (!isset($disabled_fields[$row['col_name']])) |
|
| 1447 | 1518 | $context['custom_pf'][$row['col_name']] = array( |
| 1448 | 1519 | 'label' => $row['field_name'], |
| 1449 | 1520 | 'type' => $row['field_type'], |
| 1450 | 1521 | 'bbc' => !empty($row['bbc']), |
| 1451 | 1522 | 'enclose' => $row['enclose'], |
| 1452 | 1523 | ); |
| 1524 | + } |
|
| 1453 | 1525 | |
| 1454 | 1526 | // Gotta disable the gender option. |
| 1455 | - if (isset($context['custom_pf']['cust_gender']) && $context['custom_pf']['cust_gender'] == 'Disabled') |
|
| 1456 | - unset($context['custom_pf']['cust_gender']); |
|
| 1527 | + if (isset($context['custom_pf']['cust_gender']) && $context['custom_pf']['cust_gender'] == 'Disabled') { |
|
| 1528 | + unset($context['custom_pf']['cust_gender']); |
|
| 1529 | + } |
|
| 1457 | 1530 | |
| 1458 | 1531 | $smcFunc['db_free_result']($request); |
| 1459 | 1532 | |
@@ -1470,8 +1543,9 @@ discard block |
||
| 1470 | 1543 | 'buddy_list_count' => substr_count($user_profile[$memID]['buddy_list'], ',') + 1, |
| 1471 | 1544 | ) |
| 1472 | 1545 | ); |
| 1473 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
| 1474 | - $buddies[] = $row['id_member']; |
|
| 1546 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
| 1547 | + $buddies[] = $row['id_member']; |
|
| 1548 | + } |
|
| 1475 | 1549 | $smcFunc['db_free_result']($result); |
| 1476 | 1550 | } |
| 1477 | 1551 | |
@@ -1499,30 +1573,32 @@ discard block |
||
| 1499 | 1573 | continue; |
| 1500 | 1574 | } |
| 1501 | 1575 | |
| 1502 | - if ($column['bbc'] && !empty($context['buddies'][$buddy]['options'][$key])) |
|
| 1503 | - $context['buddies'][$buddy]['options'][$key] = strip_tags(parse_bbc($context['buddies'][$buddy]['options'][$key])); |
|
| 1504 | - |
|
| 1505 | - elseif ($column['type'] == 'check') |
|
| 1506 | - $context['buddies'][$buddy]['options'][$key] = $context['buddies'][$buddy]['options'][$key] == 0 ? $txt['no'] : $txt['yes']; |
|
| 1576 | + if ($column['bbc'] && !empty($context['buddies'][$buddy]['options'][$key])) { |
|
| 1577 | + $context['buddies'][$buddy]['options'][$key] = strip_tags(parse_bbc($context['buddies'][$buddy]['options'][$key])); |
|
| 1578 | + } elseif ($column['type'] == 'check') { |
|
| 1579 | + $context['buddies'][$buddy]['options'][$key] = $context['buddies'][$buddy]['options'][$key] == 0 ? $txt['no'] : $txt['yes']; |
|
| 1580 | + } |
|
| 1507 | 1581 | |
| 1508 | 1582 | // Enclosing the user input within some other text? |
| 1509 | - if (!empty($column['enclose']) && !empty($context['buddies'][$buddy]['options'][$key])) |
|
| 1510 | - $context['buddies'][$buddy]['options'][$key] = strtr($column['enclose'], array( |
|
| 1583 | + if (!empty($column['enclose']) && !empty($context['buddies'][$buddy]['options'][$key])) { |
|
| 1584 | + $context['buddies'][$buddy]['options'][$key] = strtr($column['enclose'], array( |
|
| 1511 | 1585 | '{SCRIPTURL}' => $scripturl, |
| 1512 | 1586 | '{IMAGES_URL}' => $settings['images_url'], |
| 1513 | 1587 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
| 1514 | 1588 | '{INPUT}' => $context['buddies'][$buddy]['options'][$key], |
| 1515 | 1589 | )); |
| 1590 | + } |
|
| 1516 | 1591 | } |
| 1517 | 1592 | } |
| 1518 | 1593 | } |
| 1519 | 1594 | |
| 1520 | 1595 | if (isset($_SESSION['prf-save'])) |
| 1521 | 1596 | { |
| 1522 | - if ($_SESSION['prf-save'] === true) |
|
| 1523 | - $context['saved_successful'] = true; |
|
| 1524 | - else |
|
| 1525 | - $context['saved_failed'] = $_SESSION['prf-save']; |
|
| 1597 | + if ($_SESSION['prf-save'] === true) { |
|
| 1598 | + $context['saved_successful'] = true; |
|
| 1599 | + } else { |
|
| 1600 | + $context['saved_failed'] = $_SESSION['prf-save']; |
|
| 1601 | + } |
|
| 1526 | 1602 | |
| 1527 | 1603 | unset($_SESSION['prf-save']); |
| 1528 | 1604 | } |
@@ -1542,9 +1618,10 @@ discard block |
||
| 1542 | 1618 | |
| 1543 | 1619 | // For making changes! |
| 1544 | 1620 | $ignoreArray = explode(',', $user_profile[$memID]['pm_ignore_list']); |
| 1545 | - foreach ($ignoreArray as $k => $dummy) |
|
| 1546 | - if ($dummy == '') |
|
| 1621 | + foreach ($ignoreArray as $k => $dummy) { |
|
| 1622 | + if ($dummy == '') |
|
| 1547 | 1623 | unset($ignoreArray[$k]); |
| 1624 | + } |
|
| 1548 | 1625 | |
| 1549 | 1626 | // Removing a member from the ignore list? |
| 1550 | 1627 | if (isset($_GET['remove'])) |
@@ -1554,10 +1631,11 @@ discard block |
||
| 1554 | 1631 | $_SESSION['prf-save'] = $txt['could_not_remove_person']; |
| 1555 | 1632 | |
| 1556 | 1633 | // Heh, I'm lazy, do it the easy way... |
| 1557 | - foreach ($ignoreArray as $key => $id_remove) |
|
| 1558 | - if ($id_remove == (int) $_GET['remove']) |
|
| 1634 | + foreach ($ignoreArray as $key => $id_remove) { |
|
| 1635 | + if ($id_remove == (int) $_GET['remove']) |
|
| 1559 | 1636 | { |
| 1560 | 1637 | unset($ignoreArray[$key]); |
| 1638 | + } |
|
| 1561 | 1639 | $_SESSION['prf-save'] = true; |
| 1562 | 1640 | } |
| 1563 | 1641 | |
@@ -1567,8 +1645,7 @@ discard block |
||
| 1567 | 1645 | |
| 1568 | 1646 | // Redirect off the page because we don't like all this ugly query stuff to stick in the history. |
| 1569 | 1647 | redirectexit('action=profile;area=lists;sa=ignore;u=' . $memID); |
| 1570 | - } |
|
| 1571 | - elseif (isset($_POST['new_ignore'])) |
|
| 1648 | + } elseif (isset($_POST['new_ignore'])) |
|
| 1572 | 1649 | { |
| 1573 | 1650 | checkSession(); |
| 1574 | 1651 | // Prepare the string for extraction... |
@@ -1580,8 +1657,9 @@ discard block |
||
| 1580 | 1657 | { |
| 1581 | 1658 | $new_entries[$k] = strtr(trim($new_entries[$k]), array('\'' => ''')); |
| 1582 | 1659 | |
| 1583 | - if (strlen($new_entries[$k]) == 0 || in_array($new_entries[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) |
|
| 1584 | - unset($new_entries[$k]); |
|
| 1660 | + if (strlen($new_entries[$k]) == 0 || in_array($new_entries[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) { |
|
| 1661 | + unset($new_entries[$k]); |
|
| 1662 | + } |
|
| 1585 | 1663 | } |
| 1586 | 1664 | |
| 1587 | 1665 | $_SESSION['prf-save'] = $txt['could_not_add_person']; |
@@ -1599,16 +1677,18 @@ discard block |
||
| 1599 | 1677 | ) |
| 1600 | 1678 | ); |
| 1601 | 1679 | |
| 1602 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 1603 | - $_SESSION['prf-save'] = true; |
|
| 1680 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 1681 | + $_SESSION['prf-save'] = true; |
|
| 1682 | + } |
|
| 1604 | 1683 | |
| 1605 | 1684 | // Add the new member to the buddies array. |
| 1606 | 1685 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1607 | 1686 | { |
| 1608 | - if (in_array($row['id_member'], $ignoreArray)) |
|
| 1609 | - continue; |
|
| 1610 | - else |
|
| 1611 | - $ignoreArray[] = (int) $row['id_member']; |
|
| 1687 | + if (in_array($row['id_member'], $ignoreArray)) { |
|
| 1688 | + continue; |
|
| 1689 | + } else { |
|
| 1690 | + $ignoreArray[] = (int) $row['id_member']; |
|
| 1691 | + } |
|
| 1612 | 1692 | } |
| 1613 | 1693 | $smcFunc['db_free_result']($request); |
| 1614 | 1694 | |
@@ -1637,8 +1717,9 @@ discard block |
||
| 1637 | 1717 | 'ignore_list_count' => substr_count($user_profile[$memID]['pm_ignore_list'], ',') + 1, |
| 1638 | 1718 | ) |
| 1639 | 1719 | ); |
| 1640 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
| 1641 | - $ignored[] = $row['id_member']; |
|
| 1720 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
| 1721 | + $ignored[] = $row['id_member']; |
|
| 1722 | + } |
|
| 1642 | 1723 | $smcFunc['db_free_result']($result); |
| 1643 | 1724 | } |
| 1644 | 1725 | |
@@ -1657,10 +1738,11 @@ discard block |
||
| 1657 | 1738 | |
| 1658 | 1739 | if (isset($_SESSION['prf-save'])) |
| 1659 | 1740 | { |
| 1660 | - if ($_SESSION['prf-save'] === true) |
|
| 1661 | - $context['saved_successful'] = true; |
|
| 1662 | - else |
|
| 1663 | - $context['saved_failed'] = $_SESSION['prf-save']; |
|
| 1741 | + if ($_SESSION['prf-save'] === true) { |
|
| 1742 | + $context['saved_successful'] = true; |
|
| 1743 | + } else { |
|
| 1744 | + $context['saved_failed'] = $_SESSION['prf-save']; |
|
| 1745 | + } |
|
| 1664 | 1746 | |
| 1665 | 1747 | unset($_SESSION['prf-save']); |
| 1666 | 1748 | } |
@@ -1676,8 +1758,9 @@ discard block |
||
| 1676 | 1758 | global $context, $txt; |
| 1677 | 1759 | |
| 1678 | 1760 | loadThemeOptions($memID); |
| 1679 | - if (allowedTo(array('profile_identity_own', 'profile_identity_any', 'profile_password_own', 'profile_password_any'))) |
|
| 1680 | - loadCustomFields($memID, 'account'); |
|
| 1761 | + if (allowedTo(array('profile_identity_own', 'profile_identity_any', 'profile_password_own', 'profile_password_any'))) { |
|
| 1762 | + loadCustomFields($memID, 'account'); |
|
| 1763 | + } |
|
| 1681 | 1764 | |
| 1682 | 1765 | $context['sub_template'] = 'edit_options'; |
| 1683 | 1766 | $context['page_desc'] = $txt['account_info']; |
@@ -1704,8 +1787,9 @@ discard block |
||
| 1704 | 1787 | global $context, $txt; |
| 1705 | 1788 | |
| 1706 | 1789 | loadThemeOptions($memID); |
| 1707 | - if (allowedTo(array('profile_forum_own', 'profile_forum_any'))) |
|
| 1708 | - loadCustomFields($memID, 'forumprofile'); |
|
| 1790 | + if (allowedTo(array('profile_forum_own', 'profile_forum_any'))) { |
|
| 1791 | + loadCustomFields($memID, 'forumprofile'); |
|
| 1792 | + } |
|
| 1709 | 1793 | |
| 1710 | 1794 | $context['sub_template'] = 'edit_options'; |
| 1711 | 1795 | $context['page_desc'] = $txt['forumProfile_info']; |
@@ -1738,18 +1822,21 @@ discard block |
||
| 1738 | 1822 | $dirs = array(); |
| 1739 | 1823 | $files = array(); |
| 1740 | 1824 | |
| 1741 | - if (!$dir) |
|
| 1742 | - return array(); |
|
| 1825 | + if (!$dir) { |
|
| 1826 | + return array(); |
|
| 1827 | + } |
|
| 1743 | 1828 | |
| 1744 | 1829 | while ($line = $dir->read()) |
| 1745 | 1830 | { |
| 1746 | - if (in_array($line, array('.', '..', 'blank.png', 'index.php'))) |
|
| 1747 | - continue; |
|
| 1831 | + if (in_array($line, array('.', '..', 'blank.png', 'index.php'))) { |
|
| 1832 | + continue; |
|
| 1833 | + } |
|
| 1748 | 1834 | |
| 1749 | - if (is_dir($modSettings['avatar_directory'] . '/' . $directory . (!empty($directory) ? '/' : '') . $line)) |
|
| 1750 | - $dirs[] = $line; |
|
| 1751 | - else |
|
| 1752 | - $files[] = $line; |
|
| 1835 | + if (is_dir($modSettings['avatar_directory'] . '/' . $directory . (!empty($directory) ? '/' : '') . $line)) { |
|
| 1836 | + $dirs[] = $line; |
|
| 1837 | + } else { |
|
| 1838 | + $files[] = $line; |
|
| 1839 | + } |
|
| 1753 | 1840 | } |
| 1754 | 1841 | $dir->close(); |
| 1755 | 1842 | |
@@ -1770,14 +1857,15 @@ discard block |
||
| 1770 | 1857 | foreach ($dirs as $line) |
| 1771 | 1858 | { |
| 1772 | 1859 | $tmp = getAvatars($directory . (!empty($directory) ? '/' : '') . $line, $level + 1); |
| 1773 | - if (!empty($tmp)) |
|
| 1774 | - $result[] = array( |
|
| 1860 | + if (!empty($tmp)) { |
|
| 1861 | + $result[] = array( |
|
| 1775 | 1862 | 'filename' => $smcFunc['htmlspecialchars']($line), |
| 1776 | 1863 | 'checked' => strpos($context['member']['avatar']['server_pic'], $line . '/') !== false, |
| 1777 | 1864 | 'name' => '[' . $smcFunc['htmlspecialchars'](str_replace('_', ' ', $line)) . ']', |
| 1778 | 1865 | 'is_dir' => true, |
| 1779 | 1866 | 'files' => $tmp |
| 1780 | 1867 | ); |
| 1868 | + } |
|
| 1781 | 1869 | unset($tmp); |
| 1782 | 1870 | } |
| 1783 | 1871 | |
@@ -1787,8 +1875,9 @@ discard block |
||
| 1787 | 1875 | $extension = substr(strrchr($line, '.'), 1); |
| 1788 | 1876 | |
| 1789 | 1877 | // Make sure it is an image. |
| 1790 | - if (strcasecmp($extension, 'gif') != 0 && strcasecmp($extension, 'jpg') != 0 && strcasecmp($extension, 'jpeg') != 0 && strcasecmp($extension, 'png') != 0 && strcasecmp($extension, 'bmp') != 0) |
|
| 1791 | - continue; |
|
| 1878 | + if (strcasecmp($extension, 'gif') != 0 && strcasecmp($extension, 'jpg') != 0 && strcasecmp($extension, 'jpeg') != 0 && strcasecmp($extension, 'png') != 0 && strcasecmp($extension, 'bmp') != 0) { |
|
| 1879 | + continue; |
|
| 1880 | + } |
|
| 1792 | 1881 | |
| 1793 | 1882 | $result[] = array( |
| 1794 | 1883 | 'filename' => $smcFunc['htmlspecialchars']($line), |
@@ -1796,8 +1885,9 @@ discard block |
||
| 1796 | 1885 | 'name' => $smcFunc['htmlspecialchars'](str_replace('_', ' ', $filename)), |
| 1797 | 1886 | 'is_dir' => false |
| 1798 | 1887 | ); |
| 1799 | - if ($level == 1) |
|
| 1800 | - $context['avatar_list'][] = $directory . '/' . $line; |
|
| 1888 | + if ($level == 1) { |
|
| 1889 | + $context['avatar_list'][] = $directory . '/' . $line; |
|
| 1890 | + } |
|
| 1801 | 1891 | } |
| 1802 | 1892 | |
| 1803 | 1893 | return $result; |
@@ -1816,8 +1906,9 @@ discard block |
||
| 1816 | 1906 | loadSubTemplate('options'); |
| 1817 | 1907 | |
| 1818 | 1908 | loadThemeOptions($memID); |
| 1819 | - if (allowedTo(array('profile_extra_own', 'profile_extra_any'))) |
|
| 1820 | - loadCustomFields($memID, 'theme'); |
|
| 1909 | + if (allowedTo(array('profile_extra_own', 'profile_extra_any'))) { |
|
| 1910 | + loadCustomFields($memID, 'theme'); |
|
| 1911 | + } |
|
| 1821 | 1912 | |
| 1822 | 1913 | $context['sub_template'] = 'edit_options'; |
| 1823 | 1914 | $context['page_desc'] = $txt['theme_info']; |
@@ -1871,16 +1962,19 @@ discard block |
||
| 1871 | 1962 | { |
| 1872 | 1963 | global $txt, $context, $modSettings, $smcFunc, $sourcedir; |
| 1873 | 1964 | |
| 1874 | - if (!isset($context['token_check'])) |
|
| 1875 | - $context['token_check'] = 'profile-nt' . $memID; |
|
| 1965 | + if (!isset($context['token_check'])) { |
|
| 1966 | + $context['token_check'] = 'profile-nt' . $memID; |
|
| 1967 | + } |
|
| 1876 | 1968 | |
| 1877 | 1969 | is_not_guest(); |
| 1878 | - if (!$context['user']['is_owner']) |
|
| 1879 | - isAllowedTo('profile_extra_any'); |
|
| 1970 | + if (!$context['user']['is_owner']) { |
|
| 1971 | + isAllowedTo('profile_extra_any'); |
|
| 1972 | + } |
|
| 1880 | 1973 | |
| 1881 | 1974 | // Set the post action if we're coming from the profile... |
| 1882 | - if (!isset($context['action'])) |
|
| 1883 | - $context['action'] = 'action=profile;area=notification;sa=alerts;u=' . $memID; |
|
| 1975 | + if (!isset($context['action'])) { |
|
| 1976 | + $context['action'] = 'action=profile;area=notification;sa=alerts;u=' . $memID; |
|
| 1977 | + } |
|
| 1884 | 1978 | |
| 1885 | 1979 | // What options are set |
| 1886 | 1980 | loadThemeOptions($memID); |
@@ -1967,28 +2061,34 @@ discard block |
||
| 1967 | 2061 | ); |
| 1968 | 2062 | |
| 1969 | 2063 | // There are certain things that are disabled at the group level. |
| 1970 | - if (empty($modSettings['cal_enabled'])) |
|
| 1971 | - unset($alert_types['calendar']); |
|
| 2064 | + if (empty($modSettings['cal_enabled'])) { |
|
| 2065 | + unset($alert_types['calendar']); |
|
| 2066 | + } |
|
| 1972 | 2067 | |
| 1973 | 2068 | // Disable paid subscriptions at group level if they're disabled |
| 1974 | - if (empty($modSettings['paid_enabled'])) |
|
| 1975 | - unset($alert_types['paidsubs']); |
|
| 2069 | + if (empty($modSettings['paid_enabled'])) { |
|
| 2070 | + unset($alert_types['paidsubs']); |
|
| 2071 | + } |
|
| 1976 | 2072 | |
| 1977 | 2073 | // Disable membergroup requests at group level if they're disabled |
| 1978 | - if (empty($modSettings['show_group_membership'])) |
|
| 1979 | - unset($alert_types['groupr'], $alert_types['members']['request_group']); |
|
| 2074 | + if (empty($modSettings['show_group_membership'])) { |
|
| 2075 | + unset($alert_types['groupr'], $alert_types['members']['request_group']); |
|
| 2076 | + } |
|
| 1980 | 2077 | |
| 1981 | 2078 | // Disable mentions if they're disabled |
| 1982 | - if (empty($modSettings['enable_mentions'])) |
|
| 1983 | - unset($alert_types['msg']['msg_mention']); |
|
| 2079 | + if (empty($modSettings['enable_mentions'])) { |
|
| 2080 | + unset($alert_types['msg']['msg_mention']); |
|
| 2081 | + } |
|
| 1984 | 2082 | |
| 1985 | 2083 | // Disable likes if they're disabled |
| 1986 | - if (empty($modSettings['enable_likes'])) |
|
| 1987 | - unset($alert_types['msg']['msg_like']); |
|
| 2084 | + if (empty($modSettings['enable_likes'])) { |
|
| 2085 | + unset($alert_types['msg']['msg_like']); |
|
| 2086 | + } |
|
| 1988 | 2087 | |
| 1989 | 2088 | // Disable buddy requests if they're disabled |
| 1990 | - if (empty($modSettings['enable_buddylist'])) |
|
| 1991 | - unset($alert_types['members']['buddy_request']); |
|
| 2089 | + if (empty($modSettings['enable_buddylist'])) { |
|
| 2090 | + unset($alert_types['members']['buddy_request']); |
|
| 2091 | + } |
|
| 1992 | 2092 | |
| 1993 | 2093 | // Now, now, we could pass this through global but we should really get into the habit of |
| 1994 | 2094 | // passing content to hooks, not expecting hooks to splatter everything everywhere. |
@@ -2016,15 +2116,17 @@ discard block |
||
| 2016 | 2116 | $perms_cache['manage_membergroups'] = in_array($memID, $members); |
| 2017 | 2117 | } |
| 2018 | 2118 | |
| 2019 | - if (!($perms_cache['manage_membergroups'] || $can_mod != 0)) |
|
| 2020 | - unset($alert_types['members']['request_group']); |
|
| 2119 | + if (!($perms_cache['manage_membergroups'] || $can_mod != 0)) { |
|
| 2120 | + unset($alert_types['members']['request_group']); |
|
| 2121 | + } |
|
| 2021 | 2122 | |
| 2022 | 2123 | foreach ($alert_types as $group => $items) |
| 2023 | 2124 | { |
| 2024 | 2125 | foreach ($items as $alert_key => $alert_value) |
| 2025 | 2126 | { |
| 2026 | - if (!isset($alert_value['permission'])) |
|
| 2027 | - continue; |
|
| 2127 | + if (!isset($alert_value['permission'])) { |
|
| 2128 | + continue; |
|
| 2129 | + } |
|
| 2028 | 2130 | if (!isset($perms_cache[$alert_value['permission']['name']])) |
| 2029 | 2131 | { |
| 2030 | 2132 | $in_board = !empty($alert_value['permission']['is_board']) ? 0 : null; |
@@ -2032,12 +2134,14 @@ discard block |
||
| 2032 | 2134 | $perms_cache[$alert_value['permission']['name']] = in_array($memID, $members); |
| 2033 | 2135 | } |
| 2034 | 2136 | |
| 2035 | - if (!$perms_cache[$alert_value['permission']['name']]) |
|
| 2036 | - unset ($alert_types[$group][$alert_key]); |
|
| 2137 | + if (!$perms_cache[$alert_value['permission']['name']]) { |
|
| 2138 | + unset ($alert_types[$group][$alert_key]); |
|
| 2139 | + } |
|
| 2037 | 2140 | } |
| 2038 | 2141 | |
| 2039 | - if (empty($alert_types[$group])) |
|
| 2040 | - unset ($alert_types[$group]); |
|
| 2142 | + if (empty($alert_types[$group])) { |
|
| 2143 | + unset ($alert_types[$group]); |
|
| 2144 | + } |
|
| 2041 | 2145 | } |
| 2042 | 2146 | } |
| 2043 | 2147 | |
@@ -2069,9 +2173,9 @@ discard block |
||
| 2069 | 2173 | $update_prefs[$this_option[1]] = !empty($_POST['opt_' . $this_option[1]]) ? 1 : 0; |
| 2070 | 2174 | break; |
| 2071 | 2175 | case 'select': |
| 2072 | - if (isset($_POST['opt_' . $this_option[1]], $this_option['opts'][$_POST['opt_' . $this_option[1]]])) |
|
| 2073 | - $update_prefs[$this_option[1]] = $_POST['opt_' . $this_option[1]]; |
|
| 2074 | - else |
|
| 2176 | + if (isset($_POST['opt_' . $this_option[1]], $this_option['opts'][$_POST['opt_' . $this_option[1]]])) { |
|
| 2177 | + $update_prefs[$this_option[1]] = $_POST['opt_' . $this_option[1]]; |
|
| 2178 | + } else |
|
| 2075 | 2179 | { |
| 2076 | 2180 | // We didn't have a sane value. Let's grab the first item from the possibles. |
| 2077 | 2181 | $keys = array_keys($this_option['opts']); |
@@ -2091,23 +2195,28 @@ discard block |
||
| 2091 | 2195 | $this_value = 0; |
| 2092 | 2196 | foreach ($context['alert_bits'] as $type => $bitvalue) |
| 2093 | 2197 | { |
| 2094 | - if ($this_options[$type] == 'yes' && !empty($_POST[$type . '_' . $item_key]) || $this_options[$type] == 'always') |
|
| 2095 | - $this_value |= $bitvalue; |
|
| 2198 | + if ($this_options[$type] == 'yes' && !empty($_POST[$type . '_' . $item_key]) || $this_options[$type] == 'always') { |
|
| 2199 | + $this_value |= $bitvalue; |
|
| 2200 | + } |
|
| 2201 | + } |
|
| 2202 | + if (!isset($context['alert_prefs'][$item_key]) || $context['alert_prefs'][$item_key] != $this_value) { |
|
| 2203 | + $update_prefs[$item_key] = $this_value; |
|
| 2096 | 2204 | } |
| 2097 | - if (!isset($context['alert_prefs'][$item_key]) || $context['alert_prefs'][$item_key] != $this_value) |
|
| 2098 | - $update_prefs[$item_key] = $this_value; |
|
| 2099 | 2205 | } |
| 2100 | 2206 | } |
| 2101 | 2207 | |
| 2102 | - if (!empty($_POST['opt_alert_timeout'])) |
|
| 2103 | - $update_prefs['alert_timeout'] = $context['member']['alert_timeout'] = (int) $_POST['opt_alert_timeout']; |
|
| 2208 | + if (!empty($_POST['opt_alert_timeout'])) { |
|
| 2209 | + $update_prefs['alert_timeout'] = $context['member']['alert_timeout'] = (int) $_POST['opt_alert_timeout']; |
|
| 2210 | + } |
|
| 2104 | 2211 | |
| 2105 | - if (!empty($_POST['notify_announcements'])) |
|
| 2106 | - $update_prefs['announcements'] = $context['member']['notify_announcements'] = (int) $_POST['notify_announcements']; |
|
| 2212 | + if (!empty($_POST['notify_announcements'])) { |
|
| 2213 | + $update_prefs['announcements'] = $context['member']['notify_announcements'] = (int) $_POST['notify_announcements']; |
|
| 2214 | + } |
|
| 2107 | 2215 | |
| 2108 | 2216 | setNotifyPrefs((int) $memID, $update_prefs); |
| 2109 | - foreach ($update_prefs as $pref => $value) |
|
| 2110 | - $context['alert_prefs'][$pref] = $value; |
|
| 2217 | + foreach ($update_prefs as $pref => $value) { |
|
| 2218 | + $context['alert_prefs'][$pref] = $value; |
|
| 2219 | + } |
|
| 2111 | 2220 | |
| 2112 | 2221 | makeNotificationChanges($memID); |
| 2113 | 2222 | |
@@ -2137,8 +2246,9 @@ discard block |
||
| 2137 | 2246 | |
| 2138 | 2247 | // Now we're all set up. |
| 2139 | 2248 | is_not_guest(); |
| 2140 | - if (!$context['user']['is_owner']) |
|
| 2141 | - fatal_error('no_access'); |
|
| 2249 | + if (!$context['user']['is_owner']) { |
|
| 2250 | + fatal_error('no_access'); |
|
| 2251 | + } |
|
| 2142 | 2252 | |
| 2143 | 2253 | checkSession('get'); |
| 2144 | 2254 | |
@@ -2170,8 +2280,9 @@ discard block |
||
| 2170 | 2280 | { |
| 2171 | 2281 | global $smcFunc; |
| 2172 | 2282 | |
| 2173 | - if (empty($toMark) || empty($memID)) |
|
| 2174 | - return false; |
|
| 2283 | + if (empty($toMark) || empty($memID)) { |
|
| 2284 | + return false; |
|
| 2285 | + } |
|
| 2175 | 2286 | |
| 2176 | 2287 | $toMark = (array) $toMark; |
| 2177 | 2288 | |
@@ -2205,8 +2316,9 @@ discard block |
||
| 2205 | 2316 | { |
| 2206 | 2317 | global $smcFunc; |
| 2207 | 2318 | |
| 2208 | - if (empty($toDelete)) |
|
| 2209 | - return false; |
|
| 2319 | + if (empty($toDelete)) { |
|
| 2320 | + return false; |
|
| 2321 | + } |
|
| 2210 | 2322 | |
| 2211 | 2323 | $toDelete = (array) $toDelete; |
| 2212 | 2324 | |
@@ -2241,8 +2353,9 @@ discard block |
||
| 2241 | 2353 | { |
| 2242 | 2354 | global $smcFunc; |
| 2243 | 2355 | |
| 2244 | - if (empty($memID)) |
|
| 2245 | - return false; |
|
| 2356 | + if (empty($memID)) { |
|
| 2357 | + return false; |
|
| 2358 | + } |
|
| 2246 | 2359 | |
| 2247 | 2360 | $request = $smcFunc['db_query']('', ' |
| 2248 | 2361 | SELECT id_alert |
@@ -2319,8 +2432,9 @@ discard block |
||
| 2319 | 2432 | { |
| 2320 | 2433 | $link = $topic['link']; |
| 2321 | 2434 | |
| 2322 | - if ($topic['new']) |
|
| 2323 | - $link .= ' <a href="' . $topic['new_href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>'; |
|
| 2435 | + if ($topic['new']) { |
|
| 2436 | + $link .= ' <a href="' . $topic['new_href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>'; |
|
| 2437 | + } |
|
| 2324 | 2438 | |
| 2325 | 2439 | $link .= '<br><span class="smalltext"><em>' . $txt['in'] . ' ' . $topic['board_link'] . '</em></span>'; |
| 2326 | 2440 | |
@@ -2471,8 +2585,9 @@ discard block |
||
| 2471 | 2585 | { |
| 2472 | 2586 | $link = $board['link']; |
| 2473 | 2587 | |
| 2474 | - if ($board['new']) |
|
| 2475 | - $link .= ' <a href="' . $board['href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>'; |
|
| 2588 | + if ($board['new']) { |
|
| 2589 | + $link .= ' <a href="' . $board['href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>'; |
|
| 2590 | + } |
|
| 2476 | 2591 | |
| 2477 | 2592 | return $link; |
| 2478 | 2593 | }, |
@@ -2672,8 +2787,8 @@ discard block |
||
| 2672 | 2787 | ) |
| 2673 | 2788 | ); |
| 2674 | 2789 | $notification_boards = array(); |
| 2675 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2676 | - $notification_boards[] = array( |
|
| 2790 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2791 | + $notification_boards[] = array( |
|
| 2677 | 2792 | 'id' => $row['id_board'], |
| 2678 | 2793 | 'name' => $row['name'], |
| 2679 | 2794 | 'href' => $scripturl . '?board=' . $row['id_board'] . '.0', |
@@ -2681,6 +2796,7 @@ discard block |
||
| 2681 | 2796 | 'new' => $row['board_read'] < $row['id_msg_updated'], |
| 2682 | 2797 | 'notify_pref' => isset($prefs['board_notify_' . $row['id_board']]) ? $prefs['board_notify_' . $row['id_board']] : (!empty($prefs['board_notify']) ? $prefs['board_notify'] : 0), |
| 2683 | 2798 | ); |
| 2799 | + } |
|
| 2684 | 2800 | $smcFunc['db_free_result']($request); |
| 2685 | 2801 | |
| 2686 | 2802 | return $notification_boards; |
@@ -2695,17 +2811,18 @@ discard block |
||
| 2695 | 2811 | { |
| 2696 | 2812 | global $context, $options, $cur_profile, $smcFunc; |
| 2697 | 2813 | |
| 2698 | - if (isset($_POST['default_options'])) |
|
| 2699 | - $_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options']; |
|
| 2814 | + if (isset($_POST['default_options'])) { |
|
| 2815 | + $_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options']; |
|
| 2816 | + } |
|
| 2700 | 2817 | |
| 2701 | 2818 | if ($context['user']['is_owner']) |
| 2702 | 2819 | { |
| 2703 | 2820 | $context['member']['options'] = $options; |
| 2704 | - if (isset($_POST['options']) && is_array($_POST['options'])) |
|
| 2705 | - foreach ($_POST['options'] as $k => $v) |
|
| 2821 | + if (isset($_POST['options']) && is_array($_POST['options'])) { |
|
| 2822 | + foreach ($_POST['options'] as $k => $v) |
|
| 2706 | 2823 | $context['member']['options'][$k] = $v; |
| 2707 | - } |
|
| 2708 | - else |
|
| 2824 | + } |
|
| 2825 | + } else |
|
| 2709 | 2826 | { |
| 2710 | 2827 | $request = $smcFunc['db_query']('', ' |
| 2711 | 2828 | SELECT id_member, variable, value |
@@ -2726,8 +2843,9 @@ discard block |
||
| 2726 | 2843 | continue; |
| 2727 | 2844 | } |
| 2728 | 2845 | |
| 2729 | - if (isset($_POST['options'][$row['variable']])) |
|
| 2730 | - $row['value'] = $_POST['options'][$row['variable']]; |
|
| 2846 | + if (isset($_POST['options'][$row['variable']])) { |
|
| 2847 | + $row['value'] = $_POST['options'][$row['variable']]; |
|
| 2848 | + } |
|
| 2731 | 2849 | $context['member']['options'][$row['variable']] = $row['value']; |
| 2732 | 2850 | } |
| 2733 | 2851 | $smcFunc['db_free_result']($request); |
@@ -2735,8 +2853,9 @@ discard block |
||
| 2735 | 2853 | // Load up the default theme options for any missing. |
| 2736 | 2854 | foreach ($temp as $k => $v) |
| 2737 | 2855 | { |
| 2738 | - if (!isset($context['member']['options'][$k])) |
|
| 2739 | - $context['member']['options'][$k] = $v; |
|
| 2856 | + if (!isset($context['member']['options'][$k])) { |
|
| 2857 | + $context['member']['options'][$k] = $v; |
|
| 2858 | + } |
|
| 2740 | 2859 | } |
| 2741 | 2860 | } |
| 2742 | 2861 | } |
@@ -2751,8 +2870,9 @@ discard block |
||
| 2751 | 2870 | global $context, $modSettings, $smcFunc, $cur_profile, $sourcedir; |
| 2752 | 2871 | |
| 2753 | 2872 | // Have the admins enabled this option? |
| 2754 | - if (empty($modSettings['allow_ignore_boards'])) |
|
| 2755 | - fatal_lang_error('ignoreboards_disallowed', 'user'); |
|
| 2873 | + if (empty($modSettings['allow_ignore_boards'])) { |
|
| 2874 | + fatal_lang_error('ignoreboards_disallowed', 'user'); |
|
| 2875 | + } |
|
| 2756 | 2876 | |
| 2757 | 2877 | // Find all the boards this user is allowed to see. |
| 2758 | 2878 | $request = $smcFunc['db_query']('order_by_board_order', ' |
@@ -2772,12 +2892,13 @@ discard block |
||
| 2772 | 2892 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2773 | 2893 | { |
| 2774 | 2894 | // This category hasn't been set up yet.. |
| 2775 | - if (!isset($context['categories'][$row['id_cat']])) |
|
| 2776 | - $context['categories'][$row['id_cat']] = array( |
|
| 2895 | + if (!isset($context['categories'][$row['id_cat']])) { |
|
| 2896 | + $context['categories'][$row['id_cat']] = array( |
|
| 2777 | 2897 | 'id' => $row['id_cat'], |
| 2778 | 2898 | 'name' => $row['cat_name'], |
| 2779 | 2899 | 'boards' => array() |
| 2780 | 2900 | ); |
| 2901 | + } |
|
| 2781 | 2902 | |
| 2782 | 2903 | // Set this board up, and let the template know when it's a child. (indent them..) |
| 2783 | 2904 | $context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array( |
@@ -2807,18 +2928,20 @@ discard block |
||
| 2807 | 2928 | } |
| 2808 | 2929 | |
| 2809 | 2930 | $max_boards = ceil(count($temp_boards) / 2); |
| 2810 | - if ($max_boards == 1) |
|
| 2811 | - $max_boards = 2; |
|
| 2931 | + if ($max_boards == 1) { |
|
| 2932 | + $max_boards = 2; |
|
| 2933 | + } |
|
| 2812 | 2934 | |
| 2813 | 2935 | // Now, alternate them so they can be shown left and right ;). |
| 2814 | 2936 | $context['board_columns'] = array(); |
| 2815 | 2937 | for ($i = 0; $i < $max_boards; $i++) |
| 2816 | 2938 | { |
| 2817 | 2939 | $context['board_columns'][] = $temp_boards[$i]; |
| 2818 | - if (isset($temp_boards[$i + $max_boards])) |
|
| 2819 | - $context['board_columns'][] = $temp_boards[$i + $max_boards]; |
|
| 2820 | - else |
|
| 2821 | - $context['board_columns'][] = array(); |
|
| 2940 | + if (isset($temp_boards[$i + $max_boards])) { |
|
| 2941 | + $context['board_columns'][] = $temp_boards[$i + $max_boards]; |
|
| 2942 | + } else { |
|
| 2943 | + $context['board_columns'][] = array(); |
|
| 2944 | + } |
|
| 2822 | 2945 | } |
| 2823 | 2946 | |
| 2824 | 2947 | loadThemeOptions($memID); |
@@ -2887,8 +3010,9 @@ discard block |
||
| 2887 | 3010 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2888 | 3011 | { |
| 2889 | 3012 | // We should skip the administrator group if they don't have the admin_forum permission! |
| 2890 | - if ($row['id_group'] == 1 && !allowedTo('admin_forum')) |
|
| 2891 | - continue; |
|
| 3013 | + if ($row['id_group'] == 1 && !allowedTo('admin_forum')) { |
|
| 3014 | + continue; |
|
| 3015 | + } |
|
| 2892 | 3016 | |
| 2893 | 3017 | $context['member_groups'][$row['id_group']] = array( |
| 2894 | 3018 | 'id' => $row['id_group'], |
@@ -2934,16 +3058,17 @@ discard block |
||
| 2934 | 3058 | $context['max_signature_length'] = $context['signature_limits']['max_length']; |
| 2935 | 3059 | // Warning message for signature image limits? |
| 2936 | 3060 | $context['signature_warning'] = ''; |
| 2937 | - if ($context['signature_limits']['max_image_width'] && $context['signature_limits']['max_image_height']) |
|
| 2938 | - $context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_size'], $context['signature_limits']['max_image_width'], $context['signature_limits']['max_image_height']); |
|
| 2939 | - elseif ($context['signature_limits']['max_image_width'] || $context['signature_limits']['max_image_height']) |
|
| 2940 | - $context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_' . ($context['signature_limits']['max_image_width'] ? 'width' : 'height')], $context['signature_limits'][$context['signature_limits']['max_image_width'] ? 'max_image_width' : 'max_image_height']); |
|
| 3061 | + if ($context['signature_limits']['max_image_width'] && $context['signature_limits']['max_image_height']) { |
|
| 3062 | + $context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_size'], $context['signature_limits']['max_image_width'], $context['signature_limits']['max_image_height']); |
|
| 3063 | + } elseif ($context['signature_limits']['max_image_width'] || $context['signature_limits']['max_image_height']) { |
|
| 3064 | + $context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_' . ($context['signature_limits']['max_image_width'] ? 'width' : 'height')], $context['signature_limits'][$context['signature_limits']['max_image_width'] ? 'max_image_width' : 'max_image_height']); |
|
| 3065 | + } |
|
| 2941 | 3066 | |
| 2942 | 3067 | $context['show_spellchecking'] = !empty($modSettings['enableSpellChecking']) && (function_exists('pspell_new') || (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv')))); |
| 2943 | 3068 | |
| 2944 | - if (empty($context['do_preview'])) |
|
| 2945 | - $context['member']['signature'] = empty($cur_profile['signature']) ? '' : str_replace(array('<br>', '<', '>', '"', '\''), array("\n", '<', '>', '"', '''), $cur_profile['signature']); |
|
| 2946 | - else |
|
| 3069 | + if (empty($context['do_preview'])) { |
|
| 3070 | + $context['member']['signature'] = empty($cur_profile['signature']) ? '' : str_replace(array('<br>', '<', '>', '"', '\''), array("\n", '<', '>', '"', '''), $cur_profile['signature']); |
|
| 3071 | + } else |
|
| 2947 | 3072 | { |
| 2948 | 3073 | $signature = !empty($_POST['signature']) ? $_POST['signature'] : ''; |
| 2949 | 3074 | $validation = profileValidateSignature($signature); |
@@ -2953,8 +3078,9 @@ discard block |
||
| 2953 | 3078 | $context['post_errors'] = array(); |
| 2954 | 3079 | } |
| 2955 | 3080 | $context['post_errors'][] = 'signature_not_yet_saved'; |
| 2956 | - if ($validation !== true && $validation !== false) |
|
| 2957 | - $context['post_errors'][] = $validation; |
|
| 3081 | + if ($validation !== true && $validation !== false) { |
|
| 3082 | + $context['post_errors'][] = $validation; |
|
| 3083 | + } |
|
| 2958 | 3084 | |
| 2959 | 3085 | censorText($context['member']['signature']); |
| 2960 | 3086 | $context['member']['current_signature'] = $context['member']['signature']; |
@@ -2964,8 +3090,9 @@ discard block |
||
| 2964 | 3090 | } |
| 2965 | 3091 | |
| 2966 | 3092 | // Load the spell checker? |
| 2967 | - if ($context['show_spellchecking']) |
|
| 2968 | - loadJavaScriptFile('spellcheck.js', array('defer' => false), 'smf_spellcheck'); |
|
| 3093 | + if ($context['show_spellchecking']) { |
|
| 3094 | + loadJavaScriptFile('spellcheck.js', array('defer' => false), 'smf_spellcheck'); |
|
| 3095 | + } |
|
| 2969 | 3096 | |
| 2970 | 3097 | return true; |
| 2971 | 3098 | } |
@@ -2999,8 +3126,7 @@ discard block |
||
| 2999 | 3126 | 'external' => $cur_profile['avatar'] == 'gravatar://' || empty($modSettings['gravatarAllowExtraEmail']) || !empty($modSettings['gravatarOverride']) ? $cur_profile['email_address'] : substr($cur_profile['avatar'], 11) |
| 3000 | 3127 | ); |
| 3001 | 3128 | $context['member']['avatar']['href'] = get_gravatar_url($context['member']['avatar']['external']); |
| 3002 | - } |
|
| 3003 | - elseif ($cur_profile['avatar'] == '' && $cur_profile['id_attach'] > 0 && $context['member']['avatar']['allow_upload']) |
|
| 3129 | + } elseif ($cur_profile['avatar'] == '' && $cur_profile['id_attach'] > 0 && $context['member']['avatar']['allow_upload']) |
|
| 3004 | 3130 | { |
| 3005 | 3131 | $context['member']['avatar'] += array( |
| 3006 | 3132 | 'choice' => 'upload', |
@@ -3010,33 +3136,34 @@ discard block |
||
| 3010 | 3136 | $context['member']['avatar']['href'] = empty($cur_profile['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $cur_profile['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $cur_profile['filename']; |
| 3011 | 3137 | } |
| 3012 | 3138 | // Use "avatar_original" here so we show what the user entered even if the image proxy is enabled |
| 3013 | - elseif ((stristr($cur_profile['avatar'], 'http://') || stristr($cur_profile['avatar'], 'https://')) && $context['member']['avatar']['allow_external']) |
|
| 3014 | - $context['member']['avatar'] += array( |
|
| 3139 | + elseif ((stristr($cur_profile['avatar'], 'http://') || stristr($cur_profile['avatar'], 'https://')) && $context['member']['avatar']['allow_external']) { |
|
| 3140 | + $context['member']['avatar'] += array( |
|
| 3015 | 3141 | 'choice' => 'external', |
| 3016 | 3142 | 'server_pic' => 'blank.png', |
| 3017 | 3143 | 'external' => $cur_profile['avatar_original'] |
| 3018 | 3144 | ); |
| 3019 | - elseif ($cur_profile['avatar'] != '' && file_exists($modSettings['avatar_directory'] . '/' . $cur_profile['avatar']) && $context['member']['avatar']['allow_server_stored']) |
|
| 3020 | - $context['member']['avatar'] += array( |
|
| 3145 | + } elseif ($cur_profile['avatar'] != '' && file_exists($modSettings['avatar_directory'] . '/' . $cur_profile['avatar']) && $context['member']['avatar']['allow_server_stored']) { |
|
| 3146 | + $context['member']['avatar'] += array( |
|
| 3021 | 3147 | 'choice' => 'server_stored', |
| 3022 | 3148 | 'server_pic' => $cur_profile['avatar'] == '' ? 'blank.png' : $cur_profile['avatar'], |
| 3023 | 3149 | 'external' => 'http://' |
| 3024 | 3150 | ); |
| 3025 | - else |
|
| 3026 | - $context['member']['avatar'] += array( |
|
| 3151 | + } else { |
|
| 3152 | + $context['member']['avatar'] += array( |
|
| 3027 | 3153 | 'choice' => 'none', |
| 3028 | 3154 | 'server_pic' => 'blank.png', |
| 3029 | 3155 | 'external' => 'http://' |
| 3030 | 3156 | ); |
| 3157 | + } |
|
| 3031 | 3158 | |
| 3032 | 3159 | // Get a list of all the avatars. |
| 3033 | 3160 | if ($context['member']['avatar']['allow_server_stored']) |
| 3034 | 3161 | { |
| 3035 | 3162 | $context['avatar_list'] = array(); |
| 3036 | 3163 | $context['avatars'] = is_dir($modSettings['avatar_directory']) ? getAvatars('', 0) : array(); |
| 3164 | + } else { |
|
| 3165 | + $context['avatars'] = array(); |
|
| 3037 | 3166 | } |
| 3038 | - else |
|
| 3039 | - $context['avatars'] = array(); |
|
| 3040 | 3167 | |
| 3041 | 3168 | // Second level selected avatar... |
| 3042 | 3169 | $context['avatar_selected'] = substr(strrchr($context['member']['avatar']['server_pic'], '/'), 1); |
@@ -3065,19 +3192,22 @@ discard block |
||
| 3065 | 3192 | ) |
| 3066 | 3193 | ); |
| 3067 | 3194 | $protected_groups = array(1); |
| 3068 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 3069 | - $protected_groups[] = $row['id_group']; |
|
| 3195 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 3196 | + $protected_groups[] = $row['id_group']; |
|
| 3197 | + } |
|
| 3070 | 3198 | $smcFunc['db_free_result']($request); |
| 3071 | 3199 | |
| 3072 | 3200 | $protected_groups = array_unique($protected_groups); |
| 3073 | 3201 | } |
| 3074 | 3202 | |
| 3075 | 3203 | // The account page allows the change of your id_group - but not to a protected group! |
| 3076 | - if (empty($protected_groups) || count(array_intersect(array((int) $value, $old_profile['id_group']), $protected_groups)) == 0) |
|
| 3077 | - $value = (int) $value; |
|
| 3204 | + if (empty($protected_groups) || count(array_intersect(array((int) $value, $old_profile['id_group']), $protected_groups)) == 0) { |
|
| 3205 | + $value = (int) $value; |
|
| 3206 | + } |
|
| 3078 | 3207 | // ... otherwise it's the old group sir. |
| 3079 | - else |
|
| 3080 | - $value = $old_profile['id_group']; |
|
| 3208 | + else { |
|
| 3209 | + $value = $old_profile['id_group']; |
|
| 3210 | + } |
|
| 3081 | 3211 | |
| 3082 | 3212 | // Find the additional membergroups (if any) |
| 3083 | 3213 | if (isset($_POST['additional_groups']) && is_array($_POST['additional_groups'])) |
@@ -3086,16 +3216,18 @@ discard block |
||
| 3086 | 3216 | foreach ($_POST['additional_groups'] as $group_id) |
| 3087 | 3217 | { |
| 3088 | 3218 | $group_id = (int) $group_id; |
| 3089 | - if (!empty($group_id) && (empty($protected_groups) || !in_array($group_id, $protected_groups))) |
|
| 3090 | - $additional_groups[] = $group_id; |
|
| 3219 | + if (!empty($group_id) && (empty($protected_groups) || !in_array($group_id, $protected_groups))) { |
|
| 3220 | + $additional_groups[] = $group_id; |
|
| 3221 | + } |
|
| 3091 | 3222 | } |
| 3092 | 3223 | |
| 3093 | 3224 | // Put the protected groups back in there if you don't have permission to take them away. |
| 3094 | 3225 | $old_additional_groups = explode(',', $old_profile['additional_groups']); |
| 3095 | 3226 | foreach ($old_additional_groups as $group_id) |
| 3096 | 3227 | { |
| 3097 | - if (!empty($protected_groups) && in_array($group_id, $protected_groups)) |
|
| 3098 | - $additional_groups[] = $group_id; |
|
| 3228 | + if (!empty($protected_groups) && in_array($group_id, $protected_groups)) { |
|
| 3229 | + $additional_groups[] = $group_id; |
|
| 3230 | + } |
|
| 3099 | 3231 | } |
| 3100 | 3232 | |
| 3101 | 3233 | if (implode(',', $additional_groups) !== $old_profile['additional_groups']) |
@@ -3127,18 +3259,20 @@ discard block |
||
| 3127 | 3259 | list ($another) = $smcFunc['db_fetch_row']($request); |
| 3128 | 3260 | $smcFunc['db_free_result']($request); |
| 3129 | 3261 | |
| 3130 | - if (empty($another)) |
|
| 3131 | - fatal_lang_error('at_least_one_admin', 'critical'); |
|
| 3262 | + if (empty($another)) { |
|
| 3263 | + fatal_lang_error('at_least_one_admin', 'critical'); |
|
| 3264 | + } |
|
| 3132 | 3265 | } |
| 3133 | 3266 | } |
| 3134 | 3267 | |
| 3135 | 3268 | // If we are changing group status, update permission cache as necessary. |
| 3136 | 3269 | if ($value != $old_profile['id_group'] || isset($profile_vars['additional_groups'])) |
| 3137 | 3270 | { |
| 3138 | - if ($context['user']['is_owner']) |
|
| 3139 | - $_SESSION['mc']['time'] = 0; |
|
| 3140 | - else |
|
| 3141 | - updateSettings(array('settings_updated' => time())); |
|
| 3271 | + if ($context['user']['is_owner']) { |
|
| 3272 | + $_SESSION['mc']['time'] = 0; |
|
| 3273 | + } else { |
|
| 3274 | + updateSettings(array('settings_updated' => time())); |
|
| 3275 | + } |
|
| 3142 | 3276 | } |
| 3143 | 3277 | |
| 3144 | 3278 | // Announce to any hooks that we have changed groups, but don't allow them to change it. |
@@ -3159,8 +3293,9 @@ discard block |
||
| 3159 | 3293 | global $modSettings, $sourcedir, $smcFunc, $profile_vars, $cur_profile, $context; |
| 3160 | 3294 | |
| 3161 | 3295 | $memID = $context['id_member']; |
| 3162 | - if (empty($memID) && !empty($context['password_auth_failed'])) |
|
| 3163 | - return false; |
|
| 3296 | + if (empty($memID) && !empty($context['password_auth_failed'])) { |
|
| 3297 | + return false; |
|
| 3298 | + } |
|
| 3164 | 3299 | |
| 3165 | 3300 | require_once($sourcedir . '/ManageAttachments.php'); |
| 3166 | 3301 | |
@@ -3171,8 +3306,9 @@ discard block |
||
| 3171 | 3306 | $downloadedExternalAvatar = false; |
| 3172 | 3307 | if ($value == 'external' && allowedTo('profile_remote_avatar') && (stripos($_POST['userpicpersonal'], 'http://') === 0 || stripos($_POST['userpicpersonal'], 'https://') === 0) && strlen($_POST['userpicpersonal']) > 7 && !empty($modSettings['avatar_download_external'])) |
| 3173 | 3308 | { |
| 3174 | - if (!is_writable($uploadDir)) |
|
| 3175 | - fatal_lang_error('attachments_no_write', 'critical'); |
|
| 3309 | + if (!is_writable($uploadDir)) { |
|
| 3310 | + fatal_lang_error('attachments_no_write', 'critical'); |
|
| 3311 | + } |
|
| 3176 | 3312 | |
| 3177 | 3313 | require_once($sourcedir . '/Subs-Package.php'); |
| 3178 | 3314 | |
@@ -3216,19 +3352,18 @@ discard block |
||
| 3216 | 3352 | |
| 3217 | 3353 | // Get rid of their old avatar. (if uploaded.) |
| 3218 | 3354 | removeAttachments(array('id_member' => $memID)); |
| 3219 | - } |
|
| 3220 | - elseif ($value == 'gravatar' && !empty($modSettings['gravatarEnabled'])) |
|
| 3355 | + } elseif ($value == 'gravatar' && !empty($modSettings['gravatarEnabled'])) |
|
| 3221 | 3356 | { |
| 3222 | 3357 | // One wasn't specified, or it's not allowed to use extra email addresses, or it's not a valid one, reset to default Gravatar. |
| 3223 | - if (empty($_POST['gravatarEmail']) || empty($modSettings['gravatarAllowExtraEmail']) || !filter_var($_POST['gravatarEmail'], FILTER_VALIDATE_EMAIL)) |
|
| 3224 | - $profile_vars['avatar'] = 'gravatar://'; |
|
| 3225 | - else |
|
| 3226 | - $profile_vars['avatar'] = 'gravatar://' . ($_POST['gravatarEmail'] != $cur_profile['email_address'] ? $_POST['gravatarEmail'] : ''); |
|
| 3358 | + if (empty($_POST['gravatarEmail']) || empty($modSettings['gravatarAllowExtraEmail']) || !filter_var($_POST['gravatarEmail'], FILTER_VALIDATE_EMAIL)) { |
|
| 3359 | + $profile_vars['avatar'] = 'gravatar://'; |
|
| 3360 | + } else { |
|
| 3361 | + $profile_vars['avatar'] = 'gravatar://' . ($_POST['gravatarEmail'] != $cur_profile['email_address'] ? $_POST['gravatarEmail'] : ''); |
|
| 3362 | + } |
|
| 3227 | 3363 | |
| 3228 | 3364 | // Get rid of their old avatar. (if uploaded.) |
| 3229 | 3365 | removeAttachments(array('id_member' => $memID)); |
| 3230 | - } |
|
| 3231 | - elseif ($value == 'external' && allowedTo('profile_remote_avatar') && (stripos($_POST['userpicpersonal'], 'http://') === 0 || stripos($_POST['userpicpersonal'], 'https://') === 0) && empty($modSettings['avatar_download_external'])) |
|
| 3366 | + } elseif ($value == 'external' && allowedTo('profile_remote_avatar') && (stripos($_POST['userpicpersonal'], 'http://') === 0 || stripos($_POST['userpicpersonal'], 'https://') === 0) && empty($modSettings['avatar_download_external'])) |
|
| 3232 | 3367 | { |
| 3233 | 3368 | // We need these clean... |
| 3234 | 3369 | $cur_profile['id_attach'] = 0; |
@@ -3240,11 +3375,13 @@ discard block |
||
| 3240 | 3375 | |
| 3241 | 3376 | $profile_vars['avatar'] = str_replace(' ', '%20', preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $_POST['userpicpersonal'])); |
| 3242 | 3377 | |
| 3243 | - if ($profile_vars['avatar'] == 'http://' || $profile_vars['avatar'] == 'http:///') |
|
| 3244 | - $profile_vars['avatar'] = ''; |
|
| 3378 | + if ($profile_vars['avatar'] == 'http://' || $profile_vars['avatar'] == 'http:///') { |
|
| 3379 | + $profile_vars['avatar'] = ''; |
|
| 3380 | + } |
|
| 3245 | 3381 | // Trying to make us do something we'll regret? |
| 3246 | - elseif (substr($profile_vars['avatar'], 0, 7) != 'http://' && substr($profile_vars['avatar'], 0, 8) != 'https://') |
|
| 3247 | - return 'bad_avatar_invalid_url'; |
|
| 3382 | + elseif (substr($profile_vars['avatar'], 0, 7) != 'http://' && substr($profile_vars['avatar'], 0, 8) != 'https://') { |
|
| 3383 | + return 'bad_avatar_invalid_url'; |
|
| 3384 | + } |
|
| 3248 | 3385 | // Should we check dimensions? |
| 3249 | 3386 | elseif (!empty($modSettings['avatar_max_height_external']) || !empty($modSettings['avatar_max_width_external'])) |
| 3250 | 3387 | { |
@@ -3254,9 +3391,9 @@ discard block |
||
| 3254 | 3391 | if (is_array($sizes) && (($sizes[0] > $modSettings['avatar_max_width_external'] && !empty($modSettings['avatar_max_width_external'])) || ($sizes[1] > $modSettings['avatar_max_height_external'] && !empty($modSettings['avatar_max_height_external'])))) |
| 3255 | 3392 | { |
| 3256 | 3393 | // Houston, we have a problem. The avatar is too large!! |
| 3257 | - if ($modSettings['avatar_action_too_large'] == 'option_refuse') |
|
| 3258 | - return 'bad_avatar_too_large'; |
|
| 3259 | - elseif ($modSettings['avatar_action_too_large'] == 'option_download_and_resize') |
|
| 3394 | + if ($modSettings['avatar_action_too_large'] == 'option_refuse') { |
|
| 3395 | + return 'bad_avatar_too_large'; |
|
| 3396 | + } elseif ($modSettings['avatar_action_too_large'] == 'option_download_and_resize') |
|
| 3260 | 3397 | { |
| 3261 | 3398 | // @todo remove this if appropriate |
| 3262 | 3399 | require_once($sourcedir . '/Subs-Graphics.php'); |
@@ -3266,26 +3403,27 @@ discard block |
||
| 3266 | 3403 | $cur_profile['id_attach'] = $modSettings['new_avatar_data']['id']; |
| 3267 | 3404 | $cur_profile['filename'] = $modSettings['new_avatar_data']['filename']; |
| 3268 | 3405 | $cur_profile['attachment_type'] = $modSettings['new_avatar_data']['type']; |
| 3406 | + } else { |
|
| 3407 | + return 'bad_avatar'; |
|
| 3269 | 3408 | } |
| 3270 | - else |
|
| 3271 | - return 'bad_avatar'; |
|
| 3272 | 3409 | } |
| 3273 | 3410 | } |
| 3274 | 3411 | } |
| 3275 | - } |
|
| 3276 | - elseif (($value == 'upload' && allowedTo('profile_upload_avatar')) || $downloadedExternalAvatar) |
|
| 3412 | + } elseif (($value == 'upload' && allowedTo('profile_upload_avatar')) || $downloadedExternalAvatar) |
|
| 3277 | 3413 | { |
| 3278 | 3414 | if ((isset($_FILES['attachment']['name']) && $_FILES['attachment']['name'] != '') || $downloadedExternalAvatar) |
| 3279 | 3415 | { |
| 3280 | 3416 | // Get the dimensions of the image. |
| 3281 | 3417 | if (!$downloadedExternalAvatar) |
| 3282 | 3418 | { |
| 3283 | - if (!is_writable($uploadDir)) |
|
| 3284 | - fatal_lang_error('attachments_no_write', 'critical'); |
|
| 3419 | + if (!is_writable($uploadDir)) { |
|
| 3420 | + fatal_lang_error('attachments_no_write', 'critical'); |
|
| 3421 | + } |
|
| 3285 | 3422 | |
| 3286 | 3423 | $new_filename = $uploadDir . '/' . getAttachmentFilename('avatar_tmp_' . $memID, false, null, true); |
| 3287 | - if (!move_uploaded_file($_FILES['attachment']['tmp_name'], $new_filename)) |
|
| 3288 | - fatal_lang_error('attach_timeout', 'critical'); |
|
| 3424 | + if (!move_uploaded_file($_FILES['attachment']['tmp_name'], $new_filename)) { |
|
| 3425 | + fatal_lang_error('attach_timeout', 'critical'); |
|
| 3426 | + } |
|
| 3289 | 3427 | |
| 3290 | 3428 | $_FILES['attachment']['tmp_name'] = $new_filename; |
| 3291 | 3429 | } |
@@ -3398,17 +3536,19 @@ discard block |
||
| 3398 | 3536 | $profile_vars['avatar'] = ''; |
| 3399 | 3537 | |
| 3400 | 3538 | // Delete any temporary file. |
| 3401 | - if (file_exists($_FILES['attachment']['tmp_name'])) |
|
| 3402 | - @unlink($_FILES['attachment']['tmp_name']); |
|
| 3539 | + if (file_exists($_FILES['attachment']['tmp_name'])) { |
|
| 3540 | + @unlink($_FILES['attachment']['tmp_name']); |
|
| 3541 | + } |
|
| 3403 | 3542 | } |
| 3404 | 3543 | // Selected the upload avatar option and had one already uploaded before or didn't upload one. |
| 3405 | - else |
|
| 3544 | + else { |
|
| 3545 | + $profile_vars['avatar'] = ''; |
|
| 3546 | + } |
|
| 3547 | + } elseif ($value == 'gravatar' && allowedTo('profile_gravatar_avatar')) { |
|
| 3548 | + $profile_vars['avatar'] = 'gravatar://www.gravatar.com/avatar/' . md5(strtolower(trim($cur_profile['email_address']))); |
|
| 3549 | + } else { |
|
| 3406 | 3550 | $profile_vars['avatar'] = ''; |
| 3407 | 3551 | } |
| 3408 | - elseif ($value == 'gravatar' && allowedTo('profile_gravatar_avatar')) |
|
| 3409 | - $profile_vars['avatar'] = 'gravatar://www.gravatar.com/avatar/' . md5(strtolower(trim($cur_profile['email_address']))); |
|
| 3410 | - else |
|
| 3411 | - $profile_vars['avatar'] = ''; |
|
| 3412 | 3552 | |
| 3413 | 3553 | // Setup the profile variables so it shows things right on display! |
| 3414 | 3554 | $cur_profile['avatar'] = $profile_vars['avatar']; |
@@ -3456,9 +3596,9 @@ discard block |
||
| 3456 | 3596 | $smiley_parsed = $unparsed_signature; |
| 3457 | 3597 | parsesmileys($smiley_parsed); |
| 3458 | 3598 | $smiley_count = substr_count(strtolower($smiley_parsed), '<img') - substr_count(strtolower($unparsed_signature), '<img'); |
| 3459 | - if (!empty($sig_limits[4]) && $sig_limits[4] == -1 && $smiley_count > 0) |
|
| 3460 | - return 'signature_allow_smileys'; |
|
| 3461 | - elseif (!empty($sig_limits[4]) && $sig_limits[4] > 0 && $smiley_count > $sig_limits[4]) |
|
| 3599 | + if (!empty($sig_limits[4]) && $sig_limits[4] == -1 && $smiley_count > 0) { |
|
| 3600 | + return 'signature_allow_smileys'; |
|
| 3601 | + } elseif (!empty($sig_limits[4]) && $sig_limits[4] > 0 && $smiley_count > $sig_limits[4]) |
|
| 3462 | 3602 | { |
| 3463 | 3603 | $txt['profile_error_signature_max_smileys'] = sprintf($txt['profile_error_signature_max_smileys'], $sig_limits[4]); |
| 3464 | 3604 | return 'signature_max_smileys'; |
@@ -3471,14 +3611,15 @@ discard block |
||
| 3471 | 3611 | { |
| 3472 | 3612 | $limit_broke = 0; |
| 3473 | 3613 | // Attempt to allow all sizes of abuse, so to speak. |
| 3474 | - if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) |
|
| 3475 | - $limit_broke = $sig_limits[7] . 'px'; |
|
| 3476 | - elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) |
|
| 3477 | - $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt'; |
|
| 3478 | - elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) |
|
| 3479 | - $limit_broke = ((float) $sig_limits[7] / 16) . 'em'; |
|
| 3480 | - elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) |
|
| 3481 | - $limit_broke = 'large'; |
|
| 3614 | + if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) { |
|
| 3615 | + $limit_broke = $sig_limits[7] . 'px'; |
|
| 3616 | + } elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) { |
|
| 3617 | + $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt'; |
|
| 3618 | + } elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) { |
|
| 3619 | + $limit_broke = ((float) $sig_limits[7] / 16) . 'em'; |
|
| 3620 | + } elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) { |
|
| 3621 | + $limit_broke = 'large'; |
|
| 3622 | + } |
|
| 3482 | 3623 | |
| 3483 | 3624 | if ($limit_broke) |
| 3484 | 3625 | { |
@@ -3520,24 +3661,26 @@ discard block |
||
| 3520 | 3661 | $width = -1; $height = -1; |
| 3521 | 3662 | |
| 3522 | 3663 | // Does it have predefined restraints? Width first. |
| 3523 | - if ($matches[6][$key]) |
|
| 3524 | - $matches[2][$key] = $matches[6][$key]; |
|
| 3664 | + if ($matches[6][$key]) { |
|
| 3665 | + $matches[2][$key] = $matches[6][$key]; |
|
| 3666 | + } |
|
| 3525 | 3667 | if ($matches[2][$key] && $sig_limits[5] && $matches[2][$key] > $sig_limits[5]) |
| 3526 | 3668 | { |
| 3527 | 3669 | $width = $sig_limits[5]; |
| 3528 | 3670 | $matches[4][$key] = $matches[4][$key] * ($width / $matches[2][$key]); |
| 3671 | + } elseif ($matches[2][$key]) { |
|
| 3672 | + $width = $matches[2][$key]; |
|
| 3529 | 3673 | } |
| 3530 | - elseif ($matches[2][$key]) |
|
| 3531 | - $width = $matches[2][$key]; |
|
| 3532 | 3674 | // ... and height. |
| 3533 | 3675 | if ($matches[4][$key] && $sig_limits[6] && $matches[4][$key] > $sig_limits[6]) |
| 3534 | 3676 | { |
| 3535 | 3677 | $height = $sig_limits[6]; |
| 3536 | - if ($width != -1) |
|
| 3537 | - $width = $width * ($height / $matches[4][$key]); |
|
| 3678 | + if ($width != -1) { |
|
| 3679 | + $width = $width * ($height / $matches[4][$key]); |
|
| 3680 | + } |
|
| 3681 | + } elseif ($matches[4][$key]) { |
|
| 3682 | + $height = $matches[4][$key]; |
|
| 3538 | 3683 | } |
| 3539 | - elseif ($matches[4][$key]) |
|
| 3540 | - $height = $matches[4][$key]; |
|
| 3541 | 3684 | |
| 3542 | 3685 | // If the dimensions are still not fixed - we need to check the actual image. |
| 3543 | 3686 | if (($width == -1 && $sig_limits[5]) || ($height == -1 && $sig_limits[6])) |
@@ -3555,21 +3698,24 @@ discard block |
||
| 3555 | 3698 | if ($sizes[1] > $sig_limits[6] && $sig_limits[6]) |
| 3556 | 3699 | { |
| 3557 | 3700 | $height = $sig_limits[6]; |
| 3558 | - if ($width == -1) |
|
| 3559 | - $width = $sizes[0]; |
|
| 3701 | + if ($width == -1) { |
|
| 3702 | + $width = $sizes[0]; |
|
| 3703 | + } |
|
| 3560 | 3704 | $width = $width * ($height / $sizes[1]); |
| 3705 | + } elseif ($width != -1) { |
|
| 3706 | + $height = $sizes[1]; |
|
| 3561 | 3707 | } |
| 3562 | - elseif ($width != -1) |
|
| 3563 | - $height = $sizes[1]; |
|
| 3564 | 3708 | } |
| 3565 | 3709 | } |
| 3566 | 3710 | |
| 3567 | 3711 | // Did we come up with some changes? If so remake the string. |
| 3568 | - if ($width != -1 || $height != -1) |
|
| 3569 | - $replaces[$image] = '[img' . ($width != -1 ? ' width=' . round($width) : '') . ($height != -1 ? ' height=' . round($height) : '') . ']' . $matches[7][$key] . '[/img]'; |
|
| 3712 | + if ($width != -1 || $height != -1) { |
|
| 3713 | + $replaces[$image] = '[img' . ($width != -1 ? ' width=' . round($width) : '') . ($height != -1 ? ' height=' . round($height) : '') . ']' . $matches[7][$key] . '[/img]'; |
|
| 3714 | + } |
|
| 3715 | + } |
|
| 3716 | + if (!empty($replaces)) { |
|
| 3717 | + $value = str_replace(array_keys($replaces), array_values($replaces), $value); |
|
| 3570 | 3718 | } |
| 3571 | - if (!empty($replaces)) |
|
| 3572 | - $value = str_replace(array_keys($replaces), array_values($replaces), $value); |
|
| 3573 | 3719 | } |
| 3574 | 3720 | } |
| 3575 | 3721 | |
@@ -3613,10 +3759,12 @@ discard block |
||
| 3613 | 3759 | $email = strtr($email, array(''' => '\'')); |
| 3614 | 3760 | |
| 3615 | 3761 | // Check the name and email for validity. |
| 3616 | - if (trim($email) == '') |
|
| 3617 | - return 'no_email'; |
|
| 3618 | - if (!filter_var($email, FILTER_VALIDATE_EMAIL)) |
|
| 3619 | - return 'bad_email'; |
|
| 3762 | + if (trim($email) == '') { |
|
| 3763 | + return 'no_email'; |
|
| 3764 | + } |
|
| 3765 | + if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { |
|
| 3766 | + return 'bad_email'; |
|
| 3767 | + } |
|
| 3620 | 3768 | |
| 3621 | 3769 | // Email addresses should be and stay unique. |
| 3622 | 3770 | $request = $smcFunc['db_query']('', ' |
@@ -3631,8 +3779,9 @@ discard block |
||
| 3631 | 3779 | ) |
| 3632 | 3780 | ); |
| 3633 | 3781 | |
| 3634 | - if ($smcFunc['db_num_rows']($request) > 0) |
|
| 3635 | - return 'email_taken'; |
|
| 3782 | + if ($smcFunc['db_num_rows']($request) > 0) { |
|
| 3783 | + return 'email_taken'; |
|
| 3784 | + } |
|
| 3636 | 3785 | $smcFunc['db_free_result']($request); |
| 3637 | 3786 | |
| 3638 | 3787 | return true; |
@@ -3645,8 +3794,9 @@ discard block |
||
| 3645 | 3794 | { |
| 3646 | 3795 | global $modSettings, $context, $cur_profile; |
| 3647 | 3796 | |
| 3648 | - if (isset($_POST['passwrd2']) && $_POST['passwrd2'] != '') |
|
| 3649 | - setLoginCookie(60 * $modSettings['cookieTime'], $context['id_member'], hash_salt($_POST['passwrd1'], $cur_profile['password_salt'])); |
|
| 3797 | + if (isset($_POST['passwrd2']) && $_POST['passwrd2'] != '') { |
|
| 3798 | + setLoginCookie(60 * $modSettings['cookieTime'], $context['id_member'], hash_salt($_POST['passwrd1'], $cur_profile['password_salt'])); |
|
| 3799 | + } |
|
| 3650 | 3800 | |
| 3651 | 3801 | loadUserSettings(); |
| 3652 | 3802 | writeLog(); |
@@ -3662,8 +3812,9 @@ discard block |
||
| 3662 | 3812 | require_once($sourcedir . '/Subs-Post.php'); |
| 3663 | 3813 | |
| 3664 | 3814 | // Shouldn't happen but just in case. |
| 3665 | - if (empty($profile_vars['email_address'])) |
|
| 3666 | - return; |
|
| 3815 | + if (empty($profile_vars['email_address'])) { |
|
| 3816 | + return; |
|
| 3817 | + } |
|
| 3667 | 3818 | |
| 3668 | 3819 | $replacements = array( |
| 3669 | 3820 | 'ACTIVATIONLINK' => $scripturl . '?action=activate;u=' . $context['id_member'] . ';code=' . $profile_vars['validation_code'], |
@@ -3686,8 +3837,9 @@ discard block |
||
| 3686 | 3837 | $_SESSION['log_time'] = 0; |
| 3687 | 3838 | $_SESSION['login_' . $cookiename] = $smcFunc['json_encode'](array(0, '', 0)); |
| 3688 | 3839 | |
| 3689 | - if (isset($_COOKIE[$cookiename])) |
|
| 3690 | - $_COOKIE[$cookiename] = ''; |
|
| 3840 | + if (isset($_COOKIE[$cookiename])) { |
|
| 3841 | + $_COOKIE[$cookiename] = ''; |
|
| 3842 | + } |
|
| 3691 | 3843 | |
| 3692 | 3844 | loadUserSettings(); |
| 3693 | 3845 | |
@@ -3720,11 +3872,13 @@ discard block |
||
| 3720 | 3872 | $groups[] = $curMember['id_group']; |
| 3721 | 3873 | |
| 3722 | 3874 | // Ensure the query doesn't croak! |
| 3723 | - if (empty($groups)) |
|
| 3724 | - $groups = array(0); |
|
| 3875 | + if (empty($groups)) { |
|
| 3876 | + $groups = array(0); |
|
| 3877 | + } |
|
| 3725 | 3878 | // Just to be sure... |
| 3726 | - foreach ($groups as $k => $v) |
|
| 3727 | - $groups[$k] = (int) $v; |
|
| 3879 | + foreach ($groups as $k => $v) { |
|
| 3880 | + $groups[$k] = (int) $v; |
|
| 3881 | + } |
|
| 3728 | 3882 | |
| 3729 | 3883 | // Get all the membergroups they can join. |
| 3730 | 3884 | $request = $smcFunc['db_query']('', ' |
@@ -3754,12 +3908,14 @@ discard block |
||
| 3754 | 3908 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 3755 | 3909 | { |
| 3756 | 3910 | // Can they edit their primary group? |
| 3757 | - if (($row['id_group'] == $context['primary_group'] && $row['group_type'] > 1) || ($row['hidden'] != 2 && $context['primary_group'] == 0 && in_array($row['id_group'], $groups))) |
|
| 3758 | - $context['can_edit_primary'] = true; |
|
| 3911 | + if (($row['id_group'] == $context['primary_group'] && $row['group_type'] > 1) || ($row['hidden'] != 2 && $context['primary_group'] == 0 && in_array($row['id_group'], $groups))) { |
|
| 3912 | + $context['can_edit_primary'] = true; |
|
| 3913 | + } |
|
| 3759 | 3914 | |
| 3760 | 3915 | // If they can't manage (protected) groups, and it's not publically joinable or already assigned, they can't see it. |
| 3761 | - if (((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) && $row['id_group'] != $context['primary_group']) |
|
| 3762 | - continue; |
|
| 3916 | + if (((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) && $row['id_group'] != $context['primary_group']) { |
|
| 3917 | + continue; |
|
| 3918 | + } |
|
| 3763 | 3919 | |
| 3764 | 3920 | $context['groups'][in_array($row['id_group'], $groups) ? 'member' : 'available'][$row['id_group']] = array( |
| 3765 | 3921 | 'id' => $row['id_group'], |
@@ -3788,13 +3944,15 @@ discard block |
||
| 3788 | 3944 | ); |
| 3789 | 3945 | |
| 3790 | 3946 | // No changing primary one unless you have enough groups! |
| 3791 | - if (count($context['groups']['member']) < 2) |
|
| 3792 | - $context['can_edit_primary'] = false; |
|
| 3947 | + if (count($context['groups']['member']) < 2) { |
|
| 3948 | + $context['can_edit_primary'] = false; |
|
| 3949 | + } |
|
| 3793 | 3950 | |
| 3794 | 3951 | // In the special case that someone is requesting membership of a group, setup some special context vars. |
| 3795 | - if (isset($_REQUEST['request']) && isset($context['groups']['available'][(int) $_REQUEST['request']]) && $context['groups']['available'][(int) $_REQUEST['request']]['type'] == 2) |
|
| 3796 | - $context['group_request'] = $context['groups']['available'][(int) $_REQUEST['request']]; |
|
| 3797 | -} |
|
| 3952 | + if (isset($_REQUEST['request']) && isset($context['groups']['available'][(int) $_REQUEST['request']]) && $context['groups']['available'][(int) $_REQUEST['request']]['type'] == 2) { |
|
| 3953 | + $context['group_request'] = $context['groups']['available'][(int) $_REQUEST['request']]; |
|
| 3954 | + } |
|
| 3955 | + } |
|
| 3798 | 3956 | |
| 3799 | 3957 | /** |
| 3800 | 3958 | * This function actually makes all the group changes |
@@ -3809,10 +3967,12 @@ discard block |
||
| 3809 | 3967 | global $user_info, $context, $user_profile, $modSettings, $smcFunc; |
| 3810 | 3968 | |
| 3811 | 3969 | // Let's be extra cautious... |
| 3812 | - if (!$context['user']['is_owner'] || empty($modSettings['show_group_membership'])) |
|
| 3813 | - isAllowedTo('manage_membergroups'); |
|
| 3814 | - if (!isset($_REQUEST['gid']) && !isset($_POST['primary'])) |
|
| 3815 | - fatal_lang_error('no_access', false); |
|
| 3970 | + if (!$context['user']['is_owner'] || empty($modSettings['show_group_membership'])) { |
|
| 3971 | + isAllowedTo('manage_membergroups'); |
|
| 3972 | + } |
|
| 3973 | + if (!isset($_REQUEST['gid']) && !isset($_POST['primary'])) { |
|
| 3974 | + fatal_lang_error('no_access', false); |
|
| 3975 | + } |
|
| 3816 | 3976 | |
| 3817 | 3977 | checkSession(isset($_GET['gid']) ? 'get' : 'post'); |
| 3818 | 3978 | |
@@ -3831,8 +3991,9 @@ discard block |
||
| 3831 | 3991 | $foundTarget = $changeType == 'primary' && $group_id == 0 ? true : false; |
| 3832 | 3992 | |
| 3833 | 3993 | // Sanity check!! |
| 3834 | - if ($group_id == 1) |
|
| 3835 | - isAllowedTo('admin_forum'); |
|
| 3994 | + if ($group_id == 1) { |
|
| 3995 | + isAllowedTo('admin_forum'); |
|
| 3996 | + } |
|
| 3836 | 3997 | // Protected groups too! |
| 3837 | 3998 | else |
| 3838 | 3999 | { |
@@ -3849,8 +4010,9 @@ discard block |
||
| 3849 | 4010 | list ($is_protected) = $smcFunc['db_fetch_row']($request); |
| 3850 | 4011 | $smcFunc['db_free_result']($request); |
| 3851 | 4012 | |
| 3852 | - if ($is_protected == 1) |
|
| 3853 | - isAllowedTo('admin_forum'); |
|
| 4013 | + if ($is_protected == 1) { |
|
| 4014 | + isAllowedTo('admin_forum'); |
|
| 4015 | + } |
|
| 3854 | 4016 | } |
| 3855 | 4017 | |
| 3856 | 4018 | // What ever we are doing, we need to determine if changing primary is possible! |
@@ -3872,36 +4034,43 @@ discard block |
||
| 3872 | 4034 | $group_name = $row['group_name']; |
| 3873 | 4035 | |
| 3874 | 4036 | // Does the group type match what we're doing - are we trying to request a non-requestable group? |
| 3875 | - if ($changeType == 'request' && $row['group_type'] != 2) |
|
| 3876 | - fatal_lang_error('no_access', false); |
|
| 4037 | + if ($changeType == 'request' && $row['group_type'] != 2) { |
|
| 4038 | + fatal_lang_error('no_access', false); |
|
| 4039 | + } |
|
| 3877 | 4040 | // What about leaving a requestable group we are not a member of? |
| 3878 | - elseif ($changeType == 'free' && $row['group_type'] == 2 && $old_profile['id_group'] != $row['id_group'] && !isset($addGroups[$row['id_group']])) |
|
| 3879 | - fatal_lang_error('no_access', false); |
|
| 3880 | - elseif ($changeType == 'free' && $row['group_type'] != 3 && $row['group_type'] != 2) |
|
| 3881 | - fatal_lang_error('no_access', false); |
|
| 4041 | + elseif ($changeType == 'free' && $row['group_type'] == 2 && $old_profile['id_group'] != $row['id_group'] && !isset($addGroups[$row['id_group']])) { |
|
| 4042 | + fatal_lang_error('no_access', false); |
|
| 4043 | + } elseif ($changeType == 'free' && $row['group_type'] != 3 && $row['group_type'] != 2) { |
|
| 4044 | + fatal_lang_error('no_access', false); |
|
| 4045 | + } |
|
| 3882 | 4046 | |
| 3883 | 4047 | // We can't change the primary group if this is hidden! |
| 3884 | - if ($row['hidden'] == 2) |
|
| 3885 | - $canChangePrimary = false; |
|
| 4048 | + if ($row['hidden'] == 2) { |
|
| 4049 | + $canChangePrimary = false; |
|
| 4050 | + } |
|
| 3886 | 4051 | } |
| 3887 | 4052 | |
| 3888 | 4053 | // If this is their old primary, can we change it? |
| 3889 | - if ($row['id_group'] == $old_profile['id_group'] && ($row['group_type'] > 1 || $context['can_manage_membergroups']) && $canChangePrimary !== false) |
|
| 3890 | - $canChangePrimary = 1; |
|
| 4054 | + if ($row['id_group'] == $old_profile['id_group'] && ($row['group_type'] > 1 || $context['can_manage_membergroups']) && $canChangePrimary !== false) { |
|
| 4055 | + $canChangePrimary = 1; |
|
| 4056 | + } |
|
| 3891 | 4057 | |
| 3892 | 4058 | // If we are not doing a force primary move, don't do it automatically if current primary is not 0. |
| 3893 | - if ($changeType != 'primary' && $old_profile['id_group'] != 0) |
|
| 3894 | - $canChangePrimary = false; |
|
| 4059 | + if ($changeType != 'primary' && $old_profile['id_group'] != 0) { |
|
| 4060 | + $canChangePrimary = false; |
|
| 4061 | + } |
|
| 3895 | 4062 | |
| 3896 | 4063 | // If this is the one we are acting on, can we even act? |
| 3897 | - if ((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) |
|
| 3898 | - $canChangePrimary = false; |
|
| 4064 | + if ((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) { |
|
| 4065 | + $canChangePrimary = false; |
|
| 4066 | + } |
|
| 3899 | 4067 | } |
| 3900 | 4068 | $smcFunc['db_free_result']($request); |
| 3901 | 4069 | |
| 3902 | 4070 | // Didn't find the target? |
| 3903 | - if (!$foundTarget) |
|
| 3904 | - fatal_lang_error('no_access', false); |
|
| 4071 | + if (!$foundTarget) { |
|
| 4072 | + fatal_lang_error('no_access', false); |
|
| 4073 | + } |
|
| 3905 | 4074 | |
| 3906 | 4075 | // Final security check, don't allow users to promote themselves to admin. |
| 3907 | 4076 | if ($context['can_manage_membergroups'] && !allowedTo('admin_forum')) |
@@ -3921,8 +4090,9 @@ discard block |
||
| 3921 | 4090 | list ($disallow) = $smcFunc['db_fetch_row']($request); |
| 3922 | 4091 | $smcFunc['db_free_result']($request); |
| 3923 | 4092 | |
| 3924 | - if ($disallow) |
|
| 3925 | - isAllowedTo('admin_forum'); |
|
| 4093 | + if ($disallow) { |
|
| 4094 | + isAllowedTo('admin_forum'); |
|
| 4095 | + } |
|
| 3926 | 4096 | } |
| 3927 | 4097 | |
| 3928 | 4098 | // If we're requesting, add the note then return. |
@@ -3940,8 +4110,9 @@ discard block |
||
| 3940 | 4110 | 'status_open' => 0, |
| 3941 | 4111 | ) |
| 3942 | 4112 | ); |
| 3943 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 3944 | - fatal_lang_error('profile_error_already_requested_group'); |
|
| 4113 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 4114 | + fatal_lang_error('profile_error_already_requested_group'); |
|
| 4115 | + } |
|
| 3945 | 4116 | $smcFunc['db_free_result']($request); |
| 3946 | 4117 | |
| 3947 | 4118 | // Log the request. |
@@ -3975,10 +4146,11 @@ discard block |
||
| 3975 | 4146 | // Are we leaving? |
| 3976 | 4147 | if ($old_profile['id_group'] == $group_id || isset($addGroups[$group_id])) |
| 3977 | 4148 | { |
| 3978 | - if ($old_profile['id_group'] == $group_id) |
|
| 3979 | - $newPrimary = 0; |
|
| 3980 | - else |
|
| 3981 | - unset($addGroups[$group_id]); |
|
| 4149 | + if ($old_profile['id_group'] == $group_id) { |
|
| 4150 | + $newPrimary = 0; |
|
| 4151 | + } else { |
|
| 4152 | + unset($addGroups[$group_id]); |
|
| 4153 | + } |
|
| 3982 | 4154 | } |
| 3983 | 4155 | // ... if not, must be joining. |
| 3984 | 4156 | else |
@@ -3986,36 +4158,42 @@ discard block |
||
| 3986 | 4158 | // Can we change the primary, and do we want to? |
| 3987 | 4159 | if ($canChangePrimary) |
| 3988 | 4160 | { |
| 3989 | - if ($old_profile['id_group'] != 0) |
|
| 3990 | - $addGroups[$old_profile['id_group']] = -1; |
|
| 4161 | + if ($old_profile['id_group'] != 0) { |
|
| 4162 | + $addGroups[$old_profile['id_group']] = -1; |
|
| 4163 | + } |
|
| 3991 | 4164 | $newPrimary = $group_id; |
| 3992 | 4165 | } |
| 3993 | 4166 | // Otherwise it's an additional group... |
| 3994 | - else |
|
| 3995 | - $addGroups[$group_id] = -1; |
|
| 4167 | + else { |
|
| 4168 | + $addGroups[$group_id] = -1; |
|
| 4169 | + } |
|
| 3996 | 4170 | } |
| 3997 | 4171 | } |
| 3998 | 4172 | // Finally, we must be setting the primary. |
| 3999 | 4173 | elseif ($canChangePrimary) |
| 4000 | 4174 | { |
| 4001 | - if ($old_profile['id_group'] != 0) |
|
| 4002 | - $addGroups[$old_profile['id_group']] = -1; |
|
| 4003 | - if (isset($addGroups[$group_id])) |
|
| 4004 | - unset($addGroups[$group_id]); |
|
| 4175 | + if ($old_profile['id_group'] != 0) { |
|
| 4176 | + $addGroups[$old_profile['id_group']] = -1; |
|
| 4177 | + } |
|
| 4178 | + if (isset($addGroups[$group_id])) { |
|
| 4179 | + unset($addGroups[$group_id]); |
|
| 4180 | + } |
|
| 4005 | 4181 | $newPrimary = $group_id; |
| 4006 | 4182 | } |
| 4007 | 4183 | |
| 4008 | 4184 | // Finally, we can make the changes! |
| 4009 | - foreach ($addGroups as $id => $dummy) |
|
| 4010 | - if (empty($id)) |
|
| 4185 | + foreach ($addGroups as $id => $dummy) { |
|
| 4186 | + if (empty($id)) |
|
| 4011 | 4187 | unset($addGroups[$id]); |
| 4188 | + } |
|
| 4012 | 4189 | $addGroups = implode(',', array_flip($addGroups)); |
| 4013 | 4190 | |
| 4014 | 4191 | // Ensure that we don't cache permissions if the group is changing. |
| 4015 | - if ($context['user']['is_owner']) |
|
| 4016 | - $_SESSION['mc']['time'] = 0; |
|
| 4017 | - else |
|
| 4018 | - updateSettings(array('settings_updated' => time())); |
|
| 4192 | + if ($context['user']['is_owner']) { |
|
| 4193 | + $_SESSION['mc']['time'] = 0; |
|
| 4194 | + } else { |
|
| 4195 | + updateSettings(array('settings_updated' => time())); |
|
| 4196 | + } |
|
| 4019 | 4197 | |
| 4020 | 4198 | updateMemberData($memID, array('id_group' => $newPrimary, 'additional_groups' => $addGroups)); |
| 4021 | 4199 | |
@@ -4038,8 +4216,9 @@ discard block |
||
| 4038 | 4216 | if (empty($user_settings['tfa_secret']) && $context['user']['is_owner']) |
| 4039 | 4217 | { |
| 4040 | 4218 | // Check to ensure we're forcing SSL for authentication |
| 4041 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) |
|
| 4042 | - fatal_lang_error('login_ssl_required'); |
|
| 4219 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) { |
|
| 4220 | + fatal_lang_error('login_ssl_required'); |
|
| 4221 | + } |
|
| 4043 | 4222 | |
| 4044 | 4223 | // In some cases (forced 2FA or backup code) they would be forced to be redirected here, |
| 4045 | 4224 | // we do not want too much AJAX to confuse them. |
@@ -4076,8 +4255,7 @@ discard block |
||
| 4076 | 4255 | $context['sub_template'] = 'tfasetup_backup'; |
| 4077 | 4256 | |
| 4078 | 4257 | return; |
| 4079 | - } |
|
| 4080 | - else |
|
| 4258 | + } else |
|
| 4081 | 4259 | { |
| 4082 | 4260 | $context['tfa_secret'] = $_SESSION['tfa_secret']; |
| 4083 | 4261 | $context['tfa_error'] = !$valid_code; |
@@ -4085,8 +4263,7 @@ discard block |
||
| 4085 | 4263 | $context['tfa_pass_value'] = $_POST['passwd']; |
| 4086 | 4264 | $context['tfa_value'] = $_POST['tfa_code']; |
| 4087 | 4265 | } |
| 4088 | - } |
|
| 4089 | - else |
|
| 4266 | + } else |
|
| 4090 | 4267 | { |
| 4091 | 4268 | $totp = new \TOTP\Auth(); |
| 4092 | 4269 | $secret = $totp->generateCode(); |
@@ -4096,17 +4273,16 @@ discard block |
||
| 4096 | 4273 | } |
| 4097 | 4274 | |
| 4098 | 4275 | $context['tfa_qr_url'] = $totp->getQrCodeUrl($context['forum_name'] . ':' . $user_info['name'], $context['tfa_secret']); |
| 4099 | - } |
|
| 4100 | - elseif (isset($_REQUEST['disable'])) |
|
| 4276 | + } elseif (isset($_REQUEST['disable'])) |
|
| 4101 | 4277 | { |
| 4102 | 4278 | updateMemberData($memID, array( |
| 4103 | 4279 | 'tfa_secret' => '', |
| 4104 | 4280 | 'tfa_backup' => '', |
| 4105 | 4281 | )); |
| 4106 | 4282 | redirectexit('action=profile;area=account;u=' . $memID); |
| 4283 | + } else { |
|
| 4284 | + redirectexit('action=profile;area=account;u=' . $memID); |
|
| 4285 | + } |
|
| 4107 | 4286 | } |
| 4108 | - else |
|
| 4109 | - redirectexit('action=profile;area=account;u=' . $memID); |
|
| 4110 | -} |
|
| 4111 | 4287 | |
| 4112 | 4288 | ?> |
| 4113 | 4289 | \ No newline at end of file |