@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 3 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Shows a listing of registered members. |
@@ -110,8 +111,9 @@ discard block |
||
| 110 | 111 | |
| 111 | 112 | $context['custom_profile_fields'] = getCustFieldsMList(); |
| 112 | 113 | |
| 113 | - if (!empty($context['custom_profile_fields']['columns'])) |
|
| 114 | - $context['columns'] += $context['custom_profile_fields']['columns']; |
|
| 114 | + if (!empty($context['custom_profile_fields']['columns'])) { |
|
| 115 | + $context['columns'] += $context['custom_profile_fields']['columns']; |
|
| 116 | + } |
|
| 115 | 117 | |
| 116 | 118 | $context['colspan'] = 0; |
| 117 | 119 | $context['disabled_fields'] = isset($modSettings['disabled_profile_fields']) ? array_flip(explode(',', $modSettings['disabled_profile_fields'])) : array(); |
@@ -147,12 +149,12 @@ discard block |
||
| 147 | 149 | call_integration_hook('integrate_memberlist_buttons'); |
| 148 | 150 | |
| 149 | 151 | // Jump to the sub action. |
| 150 | - if (isset($subActions[$context['listing_by']])) |
|
| 151 | - call_helper($subActions[$context['listing_by']][1]); |
|
| 152 | - |
|
| 153 | - else |
|
| 154 | - call_helper($subActions['all'][1]); |
|
| 155 | -} |
|
| 152 | + if (isset($subActions[$context['listing_by']])) { |
|
| 153 | + call_helper($subActions[$context['listing_by']][1]); |
|
| 154 | + } else { |
|
| 155 | + call_helper($subActions['all'][1]); |
|
| 156 | + } |
|
| 157 | + } |
|
| 156 | 158 | |
| 157 | 159 | /** |
| 158 | 160 | * List all members, page by page, with sorting. |
@@ -177,8 +179,9 @@ discard block |
||
| 177 | 179 | if ($use_cache) |
| 178 | 180 | { |
| 179 | 181 | // Maybe there's something cached already. |
| 180 | - if (!empty($modSettings['memberlist_cache'])) |
|
| 181 | - $memberlist_cache = smf_json_decode($modSettings['memberlist_cache'], true); |
|
| 182 | + if (!empty($modSettings['memberlist_cache'])) { |
|
| 183 | + $memberlist_cache = smf_json_decode($modSettings['memberlist_cache'], true); |
|
| 184 | + } |
|
| 182 | 185 | |
| 183 | 186 | // The chunk size for the cached index. |
| 184 | 187 | $cache_step_size = 500; |
@@ -234,13 +237,15 @@ discard block |
||
| 234 | 237 | } |
| 235 | 238 | |
| 236 | 239 | // Set defaults for sort (real_name) and start. (0) |
| 237 | - if (!isset($_REQUEST['sort']) || !isset($context['columns'][$_REQUEST['sort']])) |
|
| 238 | - $_REQUEST['sort'] = 'real_name'; |
|
| 240 | + if (!isset($_REQUEST['sort']) || !isset($context['columns'][$_REQUEST['sort']])) { |
|
| 241 | + $_REQUEST['sort'] = 'real_name'; |
|
| 242 | + } |
|
| 239 | 243 | |
| 240 | 244 | if (!is_numeric($_REQUEST['start'])) |
| 241 | 245 | { |
| 242 | - if (preg_match('~^[^\'\\\\/]~' . ($context['utf8'] ? 'u' : ''), $smcFunc['strtolower']($_REQUEST['start']), $match) === 0) |
|
| 243 | - fatal_error('Hacker?', false); |
|
| 246 | + if (preg_match('~^[^\'\\\\/]~' . ($context['utf8'] ? 'u' : ''), $smcFunc['strtolower']($_REQUEST['start']), $match) === 0) { |
|
| 247 | + fatal_error('Hacker?', false); |
|
| 248 | + } |
|
| 244 | 249 | |
| 245 | 250 | $_REQUEST['start'] = $match[0]; |
| 246 | 251 | |
@@ -259,16 +264,18 @@ discard block |
||
| 259 | 264 | } |
| 260 | 265 | |
| 261 | 266 | $context['letter_links'] = ''; |
| 262 | - for ($i = 97; $i < 123; $i++) |
|
| 263 | - $context['letter_links'] .= '<a href="' . $scripturl . '?action=mlist;sa=all;start=' . chr($i) . '#letter' . chr($i) . '">' . strtoupper(chr($i)) . '</a> '; |
|
| 267 | + for ($i = 97; $i < 123; $i++) { |
|
| 268 | + $context['letter_links'] .= '<a href="' . $scripturl . '?action=mlist;sa=all;start=' . chr($i) . '#letter' . chr($i) . '">' . strtoupper(chr($i)) . '</a> '; |
|
| 269 | + } |
|
| 264 | 270 | |
| 265 | 271 | // Sort out the column information. |
| 266 | 272 | foreach ($context['columns'] as $col => $column_details) |
| 267 | 273 | { |
| 268 | 274 | $context['columns'][$col]['href'] = $scripturl . '?action=mlist;sort=' . $col . ';start=0'; |
| 269 | 275 | |
| 270 | - if ((!isset($_REQUEST['desc']) && $col == $_REQUEST['sort']) || ($col != $_REQUEST['sort'] && !empty($column_details['default_sort_rev']))) |
|
| 271 | - $context['columns'][$col]['href'] .= ';desc'; |
|
| 276 | + if ((!isset($_REQUEST['desc']) && $col == $_REQUEST['sort']) || ($col != $_REQUEST['sort'] && !empty($column_details['default_sort_rev']))) { |
|
| 277 | + $context['columns'][$col]['href'] .= ';desc'; |
|
| 278 | + } |
|
| 272 | 279 | |
| 273 | 280 | $context['columns'][$col]['link'] = '<a href="' . $context['columns'][$col]['href'] . '" rel="nofollow">' . $context['columns'][$col]['label'] . '</a>'; |
| 274 | 281 | $context['columns'][$col]['selected'] = $_REQUEST['sort'] == $col; |
@@ -317,8 +324,9 @@ discard block |
||
| 317 | 324 | elseif ($use_cache && $_REQUEST['sort'] === 'real_name') |
| 318 | 325 | { |
| 319 | 326 | $first_offset = floor(($memberlist_cache['num_members'] - $modSettings['defaultMaxMembers'] - $_REQUEST['start']) / $cache_step_size) * $cache_step_size; |
| 320 | - if ($first_offset < 0) |
|
| 321 | - $first_offset = 0; |
|
| 327 | + if ($first_offset < 0) { |
|
| 328 | + $first_offset = 0; |
|
| 329 | + } |
|
| 322 | 330 | $second_offset = ceil(($memberlist_cache['num_members'] - $_REQUEST['start']) / $cache_step_size) * $cache_step_size; |
| 323 | 331 | |
| 324 | 332 | $where = 'mem.real_name BETWEEN {string:real_name_low} AND {string:real_name_high}'; |
@@ -328,8 +336,9 @@ discard block |
||
| 328 | 336 | } |
| 329 | 337 | |
| 330 | 338 | $custom_fields_qry = ''; |
| 331 | - if (!empty($context['custom_profile_fields']['join'][$_REQUEST['sort']])) |
|
| 332 | - $custom_fields_qry = $context['custom_profile_fields']['join'][$_REQUEST['sort']]; |
|
| 339 | + if (!empty($context['custom_profile_fields']['join'][$_REQUEST['sort']])) { |
|
| 340 | + $custom_fields_qry = $context['custom_profile_fields']['join'][$_REQUEST['sort']]; |
|
| 341 | + } |
|
| 333 | 342 | |
| 334 | 343 | // Select the members from the database. |
| 335 | 344 | $request = $smcFunc['db_query']('', ' |
@@ -399,12 +408,13 @@ discard block |
||
| 399 | 408 | ) |
| 400 | 409 | ); |
| 401 | 410 | $context['custom_search_fields'] = array(); |
| 402 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 403 | - $context['custom_search_fields'][$row['col_name']] = array( |
|
| 411 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 412 | + $context['custom_search_fields'][$row['col_name']] = array( |
|
| 404 | 413 | 'colname' => $row['col_name'], |
| 405 | 414 | 'name' => $row['field_name'], |
| 406 | 415 | 'desc' => $row['field_desc'], |
| 407 | 416 | ); |
| 417 | + } |
|
| 408 | 418 | $smcFunc['db_free_result']($request); |
| 409 | 419 | |
| 410 | 420 | // They're searching.. |
@@ -417,23 +427,27 @@ discard block |
||
| 417 | 427 | $context['old_search_value'] = urlencode($_REQUEST['search']); |
| 418 | 428 | |
| 419 | 429 | // No fields? Use default... |
| 420 | - if (empty($_POST['fields'])) |
|
| 421 | - $_POST['fields'] = array('name'); |
|
| 430 | + if (empty($_POST['fields'])) { |
|
| 431 | + $_POST['fields'] = array('name'); |
|
| 432 | + } |
|
| 422 | 433 | |
| 423 | 434 | // Set defaults for how the results are sorted |
| 424 | - if (!isset($_REQUEST['sort']) || !isset($context['columns'][$_REQUEST['sort']])) |
|
| 425 | - $_REQUEST['sort'] = 'real_name'; |
|
| 435 | + if (!isset($_REQUEST['sort']) || !isset($context['columns'][$_REQUEST['sort']])) { |
|
| 436 | + $_REQUEST['sort'] = 'real_name'; |
|
| 437 | + } |
|
| 426 | 438 | |
| 427 | 439 | // Build the column link / sort information. |
| 428 | 440 | foreach ($context['columns'] as $col => $column_details) |
| 429 | 441 | { |
| 430 | 442 | $context['columns'][$col]['href'] = $scripturl . '?action=mlist;sa=search;start=0;sort=' . $col; |
| 431 | 443 | |
| 432 | - if ((!isset($_REQUEST['desc']) && $col == $_REQUEST['sort']) || ($col != $_REQUEST['sort'] && !empty($column_details['default_sort_rev']))) |
|
| 433 | - $context['columns'][$col]['href'] .= ';desc'; |
|
| 444 | + if ((!isset($_REQUEST['desc']) && $col == $_REQUEST['sort']) || ($col != $_REQUEST['sort'] && !empty($column_details['default_sort_rev']))) { |
|
| 445 | + $context['columns'][$col]['href'] .= ';desc'; |
|
| 446 | + } |
|
| 434 | 447 | |
| 435 | - if (isset($_POST['search']) && isset($_POST['fields'])) |
|
| 436 | - $context['columns'][$col]['href'] .= ';search=' . $_POST['search'] . ';fields=' . implode(',', $_POST['fields']); |
|
| 448 | + if (isset($_POST['search']) && isset($_POST['fields'])) { |
|
| 449 | + $context['columns'][$col]['href'] .= ';search=' . $_POST['search'] . ';fields=' . implode(',', $_POST['fields']); |
|
| 450 | + } |
|
| 437 | 451 | |
| 438 | 452 | $context['columns'][$col]['link'] = '<a href="' . $context['columns'][$col]['href'] . '" rel="nofollow">' . $context['columns'][$col]['label'] . '</a>'; |
| 439 | 453 | $context['columns'][$col]['selected'] = $_REQUEST['sort'] == $col; |
@@ -456,8 +470,7 @@ discard block |
||
| 456 | 470 | { |
| 457 | 471 | $fields = allowedTo('moderate_forum') ? array('member_name', 'real_name') : array('real_name'); |
| 458 | 472 | $search_fields[] = 'name'; |
| 459 | - } |
|
| 460 | - else |
|
| 473 | + } else |
|
| 461 | 474 | { |
| 462 | 475 | $fields = array(); |
| 463 | 476 | $search_fields = array(); |
@@ -482,9 +495,10 @@ discard block |
||
| 482 | 495 | $search_fields[] = 'email'; |
| 483 | 496 | } |
| 484 | 497 | |
| 485 | - if ($smcFunc['db_case_sensitive']) |
|
| 486 | - foreach ($fields as $key => $field) |
|
| 498 | + if ($smcFunc['db_case_sensitive']) { |
|
| 499 | + foreach ($fields as $key => $field) |
|
| 487 | 500 | $fields[$key] = 'LOWER(' . $field . ')'; |
| 501 | + } |
|
| 488 | 502 | |
| 489 | 503 | $customJoin = array(); |
| 490 | 504 | $customCount = 10; |
@@ -503,8 +517,9 @@ discard block |
||
| 503 | 517 | } |
| 504 | 518 | |
| 505 | 519 | // No search fields? That means you're trying to hack things |
| 506 | - if (empty($search_fields)) |
|
| 507 | - fatal_lang_error('invalid_search_string', false); |
|
| 520 | + if (empty($search_fields)) { |
|
| 521 | + fatal_lang_error('invalid_search_string', false); |
|
| 522 | + } |
|
| 508 | 523 | |
| 509 | 524 | $query = $_POST['search'] == '' ? '= {string:blank_string}' : ($smcFunc['db_case_sensitive'] ? 'LIKE LOWER({string:search})' : 'LIKE {string:search}'); |
| 510 | 525 | |
@@ -542,8 +557,7 @@ discard block |
||
| 542 | 557 | ); |
| 543 | 558 | printMemberListRows($request); |
| 544 | 559 | $smcFunc['db_free_result']($request); |
| 545 | - } |
|
| 546 | - else |
|
| 560 | + } else |
|
| 547 | 561 | { |
| 548 | 562 | // These are all the possible fields. |
| 549 | 563 | $context['search_fields'] = array( |
@@ -558,14 +572,14 @@ discard block |
||
| 558 | 572 | { |
| 559 | 573 | unset($context['search_fields']['email']); |
| 560 | 574 | $context['search_defaults'] = array('name'); |
| 561 | - } |
|
| 562 | - else |
|
| 575 | + } else |
|
| 563 | 576 | { |
| 564 | 577 | $context['search_defaults'] = array('name', 'email'); |
| 565 | 578 | } |
| 566 | 579 | |
| 567 | - foreach ($context['custom_search_fields'] as $field) |
|
| 568 | - $context['search_fields']['cust_' . $field['colname']] = sprintf($txt['mlist_search_by'], $field['name']); |
|
| 580 | + foreach ($context['custom_search_fields'] as $field) { |
|
| 581 | + $context['search_fields']['cust_' . $field['colname']] = sprintf($txt['mlist_search_by'], $field['name']); |
|
| 582 | + } |
|
| 569 | 583 | |
| 570 | 584 | $context['sub_template'] = 'search'; |
| 571 | 585 | $context['old_search'] = isset($_GET['search']) ? $_GET['search'] : (isset($_POST['search']) ? $smcFunc['htmlspecialchars']($_POST['search']) : ''); |
@@ -607,12 +621,14 @@ discard block |
||
| 607 | 621 | $smcFunc['db_free_result']($result); |
| 608 | 622 | |
| 609 | 623 | // Avoid division by zero... |
| 610 | - if ($most_posts == 0) |
|
| 611 | - $most_posts = 1; |
|
| 624 | + if ($most_posts == 0) { |
|
| 625 | + $most_posts = 1; |
|
| 626 | + } |
|
| 612 | 627 | |
| 613 | 628 | $members = array(); |
| 614 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 615 | - $members[] = $row['id_member']; |
|
| 629 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 630 | + $members[] = $row['id_member']; |
|
| 631 | + } |
|
| 616 | 632 | |
| 617 | 633 | // Load all the members for display. |
| 618 | 634 | loadMemberData($members); |
@@ -620,8 +636,9 @@ discard block |
||
| 620 | 636 | $context['members'] = array(); |
| 621 | 637 | foreach ($members as $member) |
| 622 | 638 | { |
| 623 | - if (!loadMemberContext($member)) |
|
| 624 | - continue; |
|
| 639 | + if (!loadMemberContext($member)) { |
|
| 640 | + continue; |
|
| 641 | + } |
|
| 625 | 642 | |
| 626 | 643 | $context['members'][$member] = $memberContext[$member]; |
| 627 | 644 | $context['members'][$member]['post_percent'] = round(($context['members'][$member]['real_posts'] * 100) / $most_posts); |
@@ -638,20 +655,21 @@ discard block |
||
| 638 | 655 | continue; |
| 639 | 656 | } |
| 640 | 657 | |
| 641 | - if ($column['bbc'] && !empty($context['members'][$member]['options'][$key])) |
|
| 642 | - $context['members'][$member]['options'][$key] = strip_tags(parse_bbc($context['members'][$member]['options'][$key])); |
|
| 643 | - |
|
| 644 | - elseif ($column['type'] == 'check') |
|
| 645 | - $context['members'][$member]['options'][$key] = $context['members'][$member]['options'][$key] == 0 ? $txt['no'] : $txt['yes']; |
|
| 658 | + if ($column['bbc'] && !empty($context['members'][$member]['options'][$key])) { |
|
| 659 | + $context['members'][$member]['options'][$key] = strip_tags(parse_bbc($context['members'][$member]['options'][$key])); |
|
| 660 | + } elseif ($column['type'] == 'check') { |
|
| 661 | + $context['members'][$member]['options'][$key] = $context['members'][$member]['options'][$key] == 0 ? $txt['no'] : $txt['yes']; |
|
| 662 | + } |
|
| 646 | 663 | |
| 647 | 664 | // Enclosing the user input within some other text? |
| 648 | - if (!empty($column['enclose'])) |
|
| 649 | - $context['members'][$member]['options'][$key] = strtr($column['enclose'], array( |
|
| 665 | + if (!empty($column['enclose'])) { |
|
| 666 | + $context['members'][$member]['options'][$key] = strtr($column['enclose'], array( |
|
| 650 | 667 | '{SCRIPTURL}' => $scripturl, |
| 651 | 668 | '{IMAGES_URL}' => $settings['images_url'], |
| 652 | 669 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
| 653 | 670 | '{INPUT}' => $context['members'][$member]['options'][$key], |
| 654 | 671 | )); |
| 672 | + } |
|
| 655 | 673 | } |
| 656 | 674 | } |
| 657 | 675 | } |
@@ -692,17 +710,17 @@ discard block |
||
| 692 | 710 | ); |
| 693 | 711 | |
| 694 | 712 | // Get the right sort method depending on the cust field type. |
| 695 | - if ($row['field_type'] != 'check') |
|
| 696 | - $cpf['columns'][$row['col_name']]['sort'] = array( |
|
| 713 | + if ($row['field_type'] != 'check') { |
|
| 714 | + $cpf['columns'][$row['col_name']]['sort'] = array( |
|
| 697 | 715 | 'down' => 'LENGTH(t' . $row['col_name'] . '.value) > 0 ASC, COALESCE(t' . $row['col_name'] . '.value, \'\') DESC', |
| 698 | 716 | 'up' => 'LENGTH(t' . $row['col_name'] . '.value) > 0 DESC, COALESCE(t' . $row['col_name'] . '.value, \'\') ASC' |
| 699 | 717 | ); |
| 700 | - |
|
| 701 | - else |
|
| 702 | - $cpf['columns'][$row['col_name']]['sort'] = array( |
|
| 718 | + } else { |
|
| 719 | + $cpf['columns'][$row['col_name']]['sort'] = array( |
|
| 703 | 720 | 'down' => 't' . $row['col_name'] . '.value DESC', |
| 704 | 721 | 'up' => 't' . $row['col_name'] . '.value ASC' |
| 705 | 722 | ); |
| 723 | + } |
|
| 706 | 724 | |
| 707 | 725 | $cpf['join'][$row['col_name']] = 'LEFT JOIN {db_prefix}themes AS t' . $row['col_name'] . ' ON (t' . $row['col_name'] . '.variable = {literal:' . $row['col_name'] . '} AND t' . $row['col_name'] . '.id_theme = 1 AND t' . $row['col_name'] . '.id_member = mem.id_member)'; |
| 708 | 726 | } |