Changeset 10322
- Timestamp:
- 11/02/2015 01:58:52 AM (9 years ago)
- Location:
- trunk/src/bp-members
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-members/admin/bp-members-admin-classes.php
r10248 r10322 1 1 <?php 2 2 /** 3 * BuddyPress Members List Classes 3 * BuddyPress Members List Classes. 4 4 * 5 5 * @package BuddyPress … … 89 89 * @since 2.0.0 90 90 * 91 * @uses WP_Users_List_Table::get_views() to get the users views 91 * @uses WP_Users_List_Table::get_views() to get the users views. 92 92 */ 93 93 public function get_views() { 94 94 $views = parent::get_views(); 95 95 96 // Remove the 'current' class from the 'All' link 96 // Remove the 'current' class from the 'All' link. 97 97 $views['all'] = str_replace( 'class="current"', '', $views['all'] ); 98 98 $views['registered'] = sprintf( '<a href="%1$s" class="current">%2$s</a>', esc_url( add_query_arg( 'page', 'bp-signups', bp_get_admin_url( 'users.php' ) ) ), sprintf( _x( 'Pending %s', 'signup users', 'buddypress' ), '<span class="count">(' . number_format_i18n( $this->signup_counts ) . ')</span>' ) ); … … 109 109 * @since 2.0.0 110 110 * 111 * @param array $which 111 * @param array $which Current table nav item. 112 112 */ 113 113 public function extra_tablenav( $which ) { … … 172 172 $link = false; 173 173 174 // Specific case when BuddyPress is not network activated 174 // Specific case when BuddyPress is not network activated. 175 175 if ( is_multisite() && current_user_can( 'manage_network_users') ) { 176 176 $link = sprintf( '<a href="%1$s">%2$s</a>', esc_url( network_admin_url( 'settings.php' ) ), esc_html__( 'Edit settings', 'buddypress' ) ); … … 206 206 foreach ( $this->items as $userid => $signup_object ) { 207 207 208 // Avoid a notice error appearing since 4.3.0 208 // Avoid a notice error appearing since 4.3.0. 209 209 if ( isset( $signup_object->id ) ) { 210 210 $signup_object->ID = $signup_object->id; … … 227 227 * @param string $role Role to be assigned to user. 228 228 * @param int $numposts Numper of posts. 229 * 230 * @return string 229 * @return void 231 230 */ 232 231 public function single_row( $signup_object = null, $style = '', $role = '', $numposts = 0 ) { … … 260 259 $avatar = get_avatar( $signup_object->user_email, 32 ); 261 260 262 // Activation email link 261 // Activation email link. 263 262 $email_link = add_query_arg( 264 263 array( … … 270 269 ); 271 270 272 // Activate link 271 // Activate link. 273 272 $activate_link = add_query_arg( 274 273 array( … … 280 279 ); 281 280 282 // Delete link 281 // Delete link. 283 282 $delete_link = add_query_arg( 284 283 array( … … 364 363 * 365 364 * @param object $signup_object Signup object instance. 366 *367 * @return int368 365 */ 369 366 public function column_count_sent( $signup_object = null ) { … … 378 375 * @param object|null $signup_object The signup data object. 379 376 * @param string $column_name The column name. 380 *381 377 * @return string 382 378 */ … … 398 394 399 395 if ( class_exists( 'WP_MS_Users_List_Table' ) ) : 396 400 397 /** 401 398 * List table class for signups network admin page. … … 415 412 416 413 /** 417 * Constructor 414 * Constructor. 418 415 * 419 416 * @since 2.0.0 … … 481 478 $views = parent::get_views(); 482 479 483 // Remove the 'current' class from the 'All' link 480 // Remove the 'current' class from the 'All' link. 484 481 $views['all'] = str_replace( 'class="current"', '', $views['all'] ); 485 482 $views['registered'] = sprintf( '<a href="%1$s" class="current">%2$s</a>', esc_url( add_query_arg( 'page', 'bp-signups', bp_get_admin_url( 'users.php' ) ) ), sprintf( _x( 'Pending %s', 'signup users', 'buddypress' ), '<span class="count">(' . number_format_i18n( $this->signup_counts ) . ')</span>' ) ); … … 574 571 foreach ( $this->items as $userid => $signup_object ) { 575 572 576 // Avoid a notice error appearing since 4.3.0 573 // Avoid a notice error appearing since 4.3.0. 577 574 if ( isset( $signup_object->id ) ) { 578 575 $signup_object->ID = $signup_object->id; … … 608 605 * @param string $column_name Current column name. 609 606 * @param string $primary Primary column name. 610 *611 607 * @return string 612 608 */ … … 639 635 $avatar = get_avatar( $signup_object->user_email, 32 ); 640 636 641 // Activation email link 637 // Activation email link. 642 638 $email_link = add_query_arg( 643 639 array( … … 649 645 ); 650 646 651 // Activate link 647 // Activate link. 652 648 $activate_link = add_query_arg( 653 649 array( … … 659 655 ); 660 656 661 // Delete link 657 // Delete link. 662 658 $delete_link = add_query_arg( 663 659 array( … … 764 760 * @param object|null $signup_object The signup data object. 765 761 * @param string $column_name The column name. 766 *767 762 * @return string 768 763 */ -
trunk/src/bp-members/bp-members-actions.php
r10149 r10322 1 1 <?php 2 2 /** 3 * BuddyPress Members Actions 3 * BuddyPress Members Actions. 4 4 * 5 5 * Action functions are exactly the same as screen functions, however they do not … … 28 28 29 29 // Only super admins can currently spam users (but they can't spam 30 // themselves) 30 // themselves). 31 31 if ( ! is_super_admin() || bp_is_my_profile() ) { 32 32 return; 33 33 } 34 34 35 // Use displayed user if it's not yourself 35 // Use displayed user if it's not yourself. 36 36 if ( empty( $user_id ) ) 37 37 $user_id = bp_displayed_user_id(); … … 39 39 if ( bp_is_current_component( 'admin' ) && ( in_array( bp_current_action(), array( 'mark-spammer', 'unmark-spammer' ) ) ) ) { 40 40 41 // Check the nonce 41 // Check the nonce. 42 42 check_admin_referer( 'mark-unmark-spammer' ); 43 43 44 // To spam or not to spam 44 // To spam or not to spam. 45 45 $status = bp_is_current_action( 'mark-spammer' ) ? 'spam' : 'ham'; 46 46 47 // The heavy lifting 47 // The heavy lifting. 48 48 bp_core_process_spammer_status( $user_id, $status ); 49 49 50 // Add feedback message. @todo - Error reporting 50 // Add feedback message. @todo - Error reporting. 51 51 if ( 'spam' == $status ) { 52 52 bp_core_add_message( __( 'User marked as spammer. Spam users are visible only to site admins.', 'buddypress' ) ); … … 59 59 do_action( 'bp_core_action_set_spammer_status', bp_displayed_user_id(), $is_spam ); 60 60 61 // Redirect back to where we came from 61 // Redirect back to where we came from. 62 62 bp_core_redirect( wp_get_referer() ); 63 63 } 64 64 } 65 // Unhooked in 1.6.0 - moved to settings 66 //add_action( 'bp_actions', 'bp_core_action_set_spammer_status' ); 65 66 /* 67 * Unhooked in 1.6.0 - moved to settings. 68 * add_action( 'bp_actions', 'bp_core_action_set_spammer_status' ); 69 */ 67 70 68 71 /** … … 78 81 if ( bp_is_current_component( 'admin' ) && bp_is_current_action( 'delete-user' ) ) { 79 82 80 // Check the nonce 83 // Check the nonce. 81 84 check_admin_referer( 'delete-user' ); 82 85 … … 99 102 } 100 103 } 101 // Unhooked in 1.6.0 - moved to settings 102 //add_action( 'bp_actions', 'bp_core_action_delete_user' ); 104 105 /* 106 * Unhooked in 1.6.0 - moved to settings 107 * add_action( 'bp_actions', 'bp_core_action_delete_user' ); 108 */ 103 109 104 110 /** -
trunk/src/bp-members/bp-members-activity.php
r10149 r10322 45 45 * @param string $action Static activity action. 46 46 * @param object $activity Activity object. 47 * 48 * @return string 47 * @return string $action 49 48 */ 50 49 function bp_members_format_activity_action_new_member( $action, $activity ) { … … 52 51 $action = sprintf( __( '%s became a registered member', 'buddypress' ), $userlink ); 53 52 54 // Legacy filter - pass $user_id instead of $activity 53 // Legacy filter - pass $user_id instead of $activity. 55 54 if ( has_filter( 'bp_core_activity_registered_member_action' ) ) { 56 55 $action = apply_filters( 'bp_core_activity_registered_member_action', $action, $activity->user_id ); … … 72 71 * 73 72 * @param array $user Array of userdata passed to bp_core_activated_user hook. 74 *75 73 * @return bool 76 74 */ -
trunk/src/bp-members/bp-members-admin.php
r10314 r10322 15 15 * Load Members admin area. 16 16 * 17 * @package BuddyPress18 * @subpackage membersAdministration19 *20 17 * @since 2.0.0 21 18 */ … … 103 100 104 101 // Paths and URLs 105 $this->admin_dir = trailingslashit( $bp->plugin_dir . 'bp-members/admin' ); // Admin path 106 $this->admin_url = trailingslashit( $bp->plugin_url . 'bp-members/admin' ); // Admin URL 107 $this->css_url = trailingslashit( $this->admin_url . 'css' ); // Admin CSS URL 108 $this->js_url = trailingslashit( $this->admin_url . 'js' ); // Admin CSS URL 109 110 // Capability depends on config 102 $this->admin_dir = trailingslashit( $bp->plugin_dir . 'bp-members/admin' ); // Admin path. 103 $this->admin_url = trailingslashit( $bp->plugin_url . 'bp-members/admin' ); // Admin URL. 104 $this->css_url = trailingslashit( $this->admin_url . 'css' ); // Admin CSS URL. 105 $this->js_url = trailingslashit( $this->admin_url . 'js' ); // Admin CSS URL. 106 107 // Capability depends on config. 111 108 $this->capability = bp_core_do_network_admin() ? 'manage_network_users' : 'edit_users'; 112 109 113 // The Edit Profile Screen id 110 // The Edit Profile Screen id. 114 111 $this->user_page = ''; 115 112 116 // The Show Profile Screen id 113 // The Show Profile Screen id. 117 114 $this->user_profile = is_network_admin() ? 'users' : 'profile'; 118 115 119 // The current user id 116 // The current user id. 120 117 $this->current_user_id = get_current_user_id(); 121 118 122 // The user id being edited 119 // The user id being edited. 123 120 $this->user_id = 0; 124 121 125 // Is a member editing their own profile 122 // Is a member editing their own profile. 126 123 $this->is_self_profile = false; 127 124 128 // The screen ids to load specific css for 125 // The screen ids to load specific css for. 129 126 $this->screen_id = array(); 130 127 131 // The stats metabox default position 128 // The stats metabox default position. 132 129 $this->stats_metabox = new StdClass(); 133 130 134 // BuddyPress edit user's profile args 131 // BuddyPress edit user's profile args. 135 132 $this->edit_profile_args = array( 'page' => 'bp-profile-edit' ); 136 133 $this->edit_profile_url = ''; 137 134 $this->edit_url = ''; 138 135 139 // Data specific to signups 136 // Data specific to signups. 140 137 $this->users_page = ''; 141 138 $this->signups_page = ''; … … 143 140 $this->users_screen = bp_core_do_network_admin() ? 'users-network' : 'users'; 144 141 145 // Specific config: BuddyPress is not network activated 142 // Specific config: BuddyPress is not network activated. 146 143 $this->subsite_activated = (bool) is_multisite() && ! bp_is_network_activated(); 147 144 148 // When BuddyPress is not network activated, only Super Admin can moderate signups 145 // When BuddyPress is not network activated, only Super Admin can moderate signups. 149 146 if ( ! empty( $this->subsite_activated ) ) { 150 147 $this->capability = 'manage_network_users'; … … 159 156 private function setup_actions() { 160 157 161 /** Extended Profile **************************************************/ 162 163 // Enqueue all admin JS and CSS 158 /** Extended Profile ************************************************* 159 */ 160 161 // Enqueue all admin JS and CSS. 164 162 add_action( 'bp_admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); 165 163 166 // Add some page specific output to the <head> 164 // Add some page specific output to the <head>. 167 165 add_action( 'bp_admin_head', array( $this, 'admin_head' ), 999 ); 168 166 169 // Add menu item to all users menu 167 // Add menu item to all users menu. 170 168 add_action( 'admin_menu', array( $this, 'admin_menus' ), 5 ); 171 169 add_action( 'network_admin_menu', array( $this, 'admin_menus' ), 5 ); 172 170 add_action( 'user_admin_menu', array( $this, 'user_profile_menu' ), 5 ); 173 171 174 // Create the Profile Navigation (Profile/Extended Profile) 172 // Create the Profile Navigation (Profile/Extended Profile). 175 173 add_action( 'edit_user_profile', array( $this, 'profile_nav' ), 99, 1 ); 176 174 add_action( 'show_user_profile', array( $this, 'profile_nav' ), 99, 1 ); 177 175 178 // Editing users of a specific site 176 // Editing users of a specific site. 179 177 add_action( "admin_head-site-users.php", array( $this, 'profile_admin_head' ) ); 180 178 181 // Add a row action to users listing 179 // Add a row action to users listing. 182 180 if ( bp_core_do_network_admin() ) { 183 181 add_filter( 'ms_user_row_actions', array( $this, 'row_actions' ), 10, 2 ); … … 186 184 } 187 185 188 // Add user row actions for single site 186 // Add user row actions for single site. 189 187 add_filter( 'user_row_actions', array( $this, 'row_actions' ), 10, 2 ); 190 188 … … 192 190 add_action( 'bp_members_admin_load', array( $this, 'process_member_type_update' ) ); 193 191 194 /** Signups ***********************************************************/ 192 /** Signups ********************************************************** 193 */ 195 194 196 195 if ( is_admin() ) { 197 196 198 // Filter non multisite user query to remove sign-up users 197 // Filter non multisite user query to remove sign-up users. 199 198 if ( ! is_multisite() ) { 200 199 add_action( 'pre_user_query', array( $this, 'remove_signups_from_user_query' ), 10, 1 ); 201 200 } 202 201 203 // Reorganise the views navigation in users.php and signups page 202 // Reorganise the views navigation in users.php and signups page. 204 203 if ( current_user_can( $this->capability ) ) { 205 204 add_filter( "views_{$this->users_screen}", array( $this, 'signup_filter_view' ), 10, 1 ); … … 226 225 $this->user_id = (int) get_current_user_id(); 227 226 228 // We'll need a user ID when not on self profile 227 // We'll need a user ID when not on self profile. 229 228 if ( ! empty( $_GET['user_id'] ) ) { 230 229 $this->user_id = (int) $_GET['user_id']; … … 237 236 * Can the current user edit the one displayed. 238 237 * 239 * self profile editing / or bp_moderate check.238 * Self profile editing / or bp_moderate check. 240 239 * This might be replaced by more granular capabilities 241 240 * in the future. … … 250 249 $retval = false; 251 250 252 // Bail if no user ID was passed 251 // Bail if no user ID was passed. 253 252 if ( empty( $user_id ) ) { 254 253 return $retval; 255 254 } 256 255 257 // Member can edit if they are viewing their own profile 256 // Member can edit if they are viewing their own profile. 258 257 if ( $this->current_user_id === $user_id ) { 259 258 $retval = true; 260 259 261 // Trust the 'bp_moderate' capability 260 // Trust the 'bp_moderate' capability. 262 261 } else { 263 262 $retval = bp_current_user_can( 'bp_moderate' ); … … 276 275 private function get_user_notice() { 277 276 278 // Setup empty notice for return value 277 // Setup empty notice for return value. 279 278 $notice = array(); 280 279 281 // Updates 280 // Updates. 282 281 if ( ! empty( $_REQUEST['updated'] ) ) { 283 282 switch ( $_REQUEST['updated'] ) { … … 309 308 } 310 309 311 // Errors 310 // Errors. 312 311 if ( ! empty( $_REQUEST['error'] ) ) { 313 312 switch ( $_REQUEST['error'] ) { … … 363 362 public function user_profile_menu() { 364 363 365 // Setup the hooks array 364 // Setup the hooks array. 366 365 $hooks = array(); 367 366 368 // Add the faux "Edit Profile" submenu page 367 // Add the faux "Edit Profile" submenu page. 369 368 $hooks['user'] = $this->user_page = add_submenu_page( 370 369 'profile.php', … … 376 375 ); 377 376 378 // Setup the screen ID's 377 // Setup the screen ID's. 379 378 $this->screen_id = array( 380 379 $this->user_page . '-user', … … 382 381 ); 383 382 384 // Loop through new hooks and add method actions 383 // Loop through new hooks and add method actions. 385 384 foreach ( $hooks as $key => $hook ) { 386 385 add_action( "load-{$hook}", array( $this, $key . '_admin_load' ) ); 387 386 } 388 387 389 // Add the profile_admin_head method to proper admin_head actions 388 // Add the profile_admin_head method to proper admin_head actions. 390 389 add_action( "admin_head-{$this->user_page}", array( $this, 'profile_admin_head' ) ); 391 390 add_action( "admin_head-profile.php", array( $this, 'profile_admin_head' ) ); … … 401 400 public function admin_menus() { 402 401 403 // Setup the hooks array 402 // Setup the hooks array. 404 403 $hooks = array(); 405 404 406 // Manage user's profile 405 // Manage user's profile. 407 406 $hooks['user'] = $this->user_page = add_submenu_page( 408 407 $this->user_profile . '.php', … … 414 413 ); 415 414 416 // Only show sign-ups where they belong 415 // Only show sign-ups where they belong. 417 416 if ( ! is_multisite() || is_network_admin() ) { 418 417 419 // Manage signups 418 // Manage signups. 420 419 $hooks['signups'] = $this->signups_page = add_users_page( 421 420 __( 'Manage Signups', 'buddypress' ), … … 431 430 $this->users_page = 'users'; 432 431 433 // Self profile check is needed for this pages 432 // Self profile check is needed for this pages. 434 433 $page_head = array( 435 434 $edit_page . '.php', … … 439 438 ); 440 439 441 // Append '-network' to each array item if in network admin 440 // Append '-network' to each array item if in network admin. 442 441 if ( is_network_admin() ) { 443 442 $edit_page .= '-network'; … … 448 447 } 449 448 450 // Setup the screen ID's 449 // Setup the screen ID's. 451 450 $this->screen_id = array( 452 451 $edit_page, … … 455 454 ); 456 455 457 // Loop through new hooks and add method actions 456 // Loop through new hooks and add method actions. 458 457 foreach ( $hooks as $key => $hook ) { 459 458 add_action( "load-{$hook}", array( $this, $key . '_admin_load' ) ); 460 459 } 461 460 462 // Add the profile_admin_head method to proper admin_head actions 461 // Add the profile_admin_head method to proper admin_head actions. 463 462 foreach ( $page_head as $head ) { 464 463 add_action( "admin_head-{$head}", array( $this, 'profile_admin_head' ) ); … … 478 477 $this->is_self_profile = true; 479 478 480 // Is the user attempting to edit their own profile 479 // Is the user attempting to edit their own profile. 481 480 } elseif ( isset( $_GET['user_id' ] ) || ( isset( $_GET['page'] ) && ( 'bp-profile-edit' === $_GET['page'] ) ) ) { 482 481 $this->is_self_profile = (bool) ( $this->get_user_id() === $this->current_user_id ); … … 490 489 } 491 490 492 // Editing your own profile, so recheck some vars 491 // Editing your own profile, so recheck some vars. 493 492 if ( true === $this->is_self_profile ) { 494 493 495 // Use profile.php as the edit page 494 // Use profile.php as the edit page. 496 495 $edit_page = 'profile.php'; 497 496 498 // Set profile.php as the parent & sub files to correct the menu nav 497 // Set profile.php as the parent & sub files to correct the menu nav. 499 498 if ( is_blog_admin() || is_user_admin() ) { 500 499 $parent_file = 'profile.php'; … … 502 501 } 503 502 504 // Not editing yourself, so use user-edit.php 503 // Not editing yourself, so use user-edit.php. 505 504 } else { 506 505 $edit_page = 'user-edit.php'; … … 566 565 } 567 566 568 // Only load JavaScript for BuddyPress profile 567 // Only load JavaScript for BuddyPress profile. 569 568 if ( get_current_screen()->id == $this->user_page ) { 570 569 $js = $this->js_url . "admin{$min}.js"; … … 599 598 * @param object|null $user User to create profile navigation for. 600 599 * @param string $active Which profile to highlight. 601 *602 600 * @return string 603 601 */ 604 602 public function profile_nav( $user = null, $active = 'WordPress' ) { 605 603 606 // Bail if no user ID exists here 604 // Bail if no user ID exists here. 607 605 if ( empty( $user->ID ) ) { 608 606 return; 609 607 } 610 608 611 // Add the user ID to query arguments when not editing yourself 609 // Add the user ID to query arguments when not editing yourself. 612 610 if ( false === $this->is_self_profile ) { 613 611 $query_args = array( 'user_id' => $user->ID ); … … 616 614 } 617 615 618 // Conditionally add a referer if it exists in the existing request 616 // Conditionally add a referer if it exists in the existing request. 619 617 if ( ! empty( $_REQUEST['wp_http_referer'] ) ) { 620 618 $query_args['wp_http_referer'] = urlencode( stripslashes_deep( $_REQUEST['wp_http_referer'] ) ); 621 619 } 622 620 623 // Setup the two distinct "edit" URL's 621 // Setup the two distinct "edit" URL's. 624 622 $community_url = add_query_arg( $query_args, $this->edit_profile_url ); 625 623 $wordpress_url = add_query_arg( $query_args, $this->edit_url ); … … 662 660 public function user_admin_load() { 663 661 664 // Get the user ID 662 // Get the user ID. 665 663 $user_id = $this->get_user_id(); 666 664 667 // can current user edit this profile?665 // Can current user edit this profile? 668 666 if ( ! $this->member_can_edit( $user_id ) ) { 669 667 wp_die( __( 'You cannot edit the requested user.', 'buddypress' ) ); 670 668 } 671 669 672 // Build redirection URL 670 // Build redirection URL. 673 671 $redirect_to = remove_query_arg( array( 'action', 'error', 'updated', 'spam', 'ham', 'delete_avatar' ), $_SERVER['REQUEST_URI'] ); 674 672 $doaction = ! empty( $_REQUEST['action'] ) ? $_REQUEST['action'] : false; … … 701 699 $allowed_actions = apply_filters( 'bp_members_admin_allowed_actions', array( 'update', 'delete_avatar', 'spam', 'ham' ) ); 702 700 703 // Prepare the display of the Community Profile screen 701 // Prepare the display of the Community Profile screen. 704 702 if ( ! in_array( $doaction, $allowed_actions ) ) { 705 703 add_screen_option( 'layout_columns', array( 'default' => 2, 'max' => 2, ) ); … … 714 712 ) ); 715 713 716 // Help panel - sidebar links 714 // Help panel - sidebar links. 717 715 get_current_screen()->set_help_sidebar( 718 716 '<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' . … … 731 729 ); 732 730 733 // In case xprofile is not active 731 // In case xprofile is not active. 734 732 $this->stats_metabox->context = 'normal'; 735 733 $this->stats_metabox->priority = 'core'; … … 748 746 do_action_ref_array( 'bp_members_admin_xprofile_metabox', array( $user_id, get_current_screen()->id, $this->stats_metabox ) ); 749 747 750 // If xProfile is inactive, difficult to know what's profile we're on 748 // If xProfile is inactive, difficult to know what's profile we're on. 751 749 if ( 'normal' === $this->stats_metabox->context ) { 752 750 $display_name = bp_core_get_user_displayname( $user_id ); … … 755 753 } 756 754 757 // User Stat metabox 755 // User Stat metabox. 758 756 add_meta_box( 759 757 'bp_members_admin_user_stats', … … 793 791 do_action( 'bp_members_admin_user_metaboxes', $this->is_self_profile, $user_id ); 794 792 795 // Enqueue JavaScript files 793 // Enqueue JavaScript files. 796 794 wp_enqueue_script( 'postbox' ); 797 795 wp_enqueue_script( 'dashboard' ); 798 796 799 // Spam or Ham user 797 // Spam or Ham user. 800 798 } elseif ( in_array( $doaction, array( 'spam', 'ham' ) ) && empty( $this->is_self_profile ) ) { 801 799 … … 810 808 bp_core_redirect( $redirect_to ); 811 809 812 // Update other stuff once above ones are done 810 // Update other stuff once above ones are done. 813 811 } else { 814 812 $this->redirect = $redirect_to; … … 841 839 } 842 840 843 // Get the user ID 841 // Get the user ID. 844 842 $user_id = $this->get_user_id(); 845 843 $user = get_user_to_edit( $user_id ); 846 844 847 // Construct title 845 // Construct title. 848 846 if ( true === $this->is_self_profile ) { 849 847 $title = __( 'Profile', 'buddypress' ); … … 852 850 } 853 851 854 // Construct URL for form 852 // Construct URL for form. 855 853 $request_url = remove_query_arg( array( 'action', 'error', 'updated', 'spam', 'ham' ), $_SERVER['REQUEST_URI'] ); 856 854 $form_action_url = add_query_arg( 'action', 'update', $request_url ); … … 860 858 } 861 859 862 // Prepare notice for admin 860 // Prepare notice for admin. 863 861 $notice = $this->get_user_notice(); 864 862 … … 947 945 public function user_admin_status_metabox( $user = null ) { 948 946 949 // Bail if no user id or if the user has not activated their account yet 947 // Bail if no user id or if the user has not activated their account yet. 950 948 if ( empty( $user->ID ) ) { 951 949 return; 952 950 } 953 951 954 // Bail if user has not been activated yet (how did you get here?) 952 // Bail if user has not been activated yet (how did you get here?). 955 953 if ( isset( $user->user_status ) && ( 2 == $user->user_status ) ) : ?> 956 954 … … 966 964 <?php 967 965 968 // Get the spam status once here to compare against below 966 // Get the spam status once here to compare against below. 969 967 $is_spammer = bp_is_user_spammer( $user->ID ); 970 968 … … 989 987 <?php 990 988 991 // translators: Publish box date format, see http://php.net/date989 // Translators: Publish box date format, see http://php.net/date. 992 990 $datef = __( 'M j, Y @ G:i', 'buddypress' ); 993 991 $date = date_i18n( $datef, strtotime( $user->user_registered ) ); … … 1036 1034 public function user_admin_stats_metabox( $user = null ) { 1037 1035 1038 // Bail if no user ID 1036 // Bail if no user ID. 1039 1037 if ( empty( $user->ID ) ) { 1040 1038 return; 1041 1039 } 1042 1040 1043 // If account is not activated last activity is the time user registered 1041 // If account is not activated last activity is the time user registered. 1044 1042 if ( isset( $user->user_status ) && 2 == $user->user_status ) { 1045 1043 $last_active = $user->user_registered; 1046 1044 1047 // Account is activated, getting user's last activity 1045 // Account is activated, getting user's last activity. 1048 1046 } else { 1049 1047 $last_active = bp_get_user_last_activity( $user->ID ); … … 1057 1055 1058 1056 <?php 1059 // Loading other stats only if user has activated their account 1057 // Loading other stats only if user has activated their account. 1060 1058 if ( empty( $user->user_status ) ) { 1061 1059 … … 1148 1146 * @param array|string $actions WordPress row actions (edit, delete). 1149 1147 * @param object $user The object for the user row. 1150 *1151 1148 * @return array Merged actions. 1152 1149 */ 1153 1150 public function row_actions( $actions = '', $user = null ) { 1154 1151 1155 // Bail if no user ID 1152 // Bail if no user ID. 1156 1153 if ( empty( $user->ID ) ) { 1157 1154 return; 1158 1155 } 1159 1156 1160 // Setup args array 1157 // Setup args array. 1161 1158 $args = array(); 1162 1159 1163 // Add the user ID if it's not for the current user 1160 // Add the user ID if it's not for the current user. 1164 1161 if ( $user->ID !== $this->current_user_id ) { 1165 1162 $args['user_id'] = $user->ID; 1166 1163 } 1167 1164 1168 // Add the referer 1165 // Add the referer. 1169 1166 $args['wp_http_referer'] = urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ); 1170 1167 1171 // Add the "Extended" link if the current user can edit this user 1168 // Add the "Extended" link if the current user can edit this user. 1172 1169 if ( current_user_can( 'edit_user', $user->ID ) || bp_current_user_can( 'bp_moderate' ) ) { 1173 1170 1174 // Add query args and setup the Extended link 1171 // Add query args and setup the Extended link. 1175 1172 $edit_profile = add_query_arg( $args, $this->edit_profile_url ); 1176 1173 $edit_profile_link = sprintf( '<a href="%1$s">%2$s</a>', esc_url( $edit_profile ), esc_html__( 'Extended', 'buddypress' ) ); … … 1178 1175 /** 1179 1176 * Check the edit action is available 1180 * and preserve the order edit | profile | remove/delete 1177 * and preserve the order edit | profile | remove/delete. 1181 1178 */ 1182 1179 if ( ! empty( $actions['edit'] ) ) { … … 1189 1186 ); 1190 1187 1191 // If not available simply add the edit profile action 1188 // If not available simply add the edit profile action. 1192 1189 } else { 1193 1190 $new_edit_actions = array( 'edit-profile' => $edit_profile_link ); … … 1219 1216 * @param string $url Profile URL. 1220 1217 * @param int $user_id User ID. 1221 *1222 1218 * @return string 1223 1219 */ … … 1245 1241 * @since 2.0.0 1246 1242 * 1247 * @param int $value 1248 * @param string $option 1249 * @param int $new_value 1250 * 1243 * @param int $value Value for signup option. 1244 * @param string $option Value for the option key. 1245 * @param int $new_value Value for the saved option. 1251 1246 * @return int The pagination preferences. 1252 1247 */ … … 1256 1251 } 1257 1252 1258 // Per page 1253 // Per page. 1259 1254 $new_value = (int) $new_value; 1260 1255 if ( $new_value < 1 || $new_value > 999 ) { … … 1274 1269 * 1275 1270 * @param WP_User_Query $query The users query. 1276 *1277 1271 * @return WP_User_Query The users query without the signups. 1278 1272 */ … … 1280 1274 global $wpdb; 1281 1275 1282 // Bail if this is an ajax request 1276 // Bail if this is an ajax request. 1283 1277 if ( defined( 'DOING_AJAX' ) ) { 1284 1278 return; 1285 1279 } 1286 1280 1287 // Bail if updating BuddyPress 1281 // Bail if updating BuddyPress. 1288 1282 if ( bp_is_update() ) { 1289 1283 return; 1290 1284 } 1291 1285 1292 // Bail if there is no current admin screen 1286 // Bail if there is no current admin screen. 1293 1287 if ( ! function_exists( 'get_current_screen' ) || ! get_current_screen() ) { 1294 1288 return; 1295 1289 } 1296 1290 1297 // Get current screen 1291 // Get current screen. 1298 1292 $current_screen = get_current_screen(); 1299 1293 1300 // Bail if not on a users page 1294 // Bail if not on a users page. 1301 1295 if ( ! isset( $current_screen->id ) || $this->users_page !== $current_screen->id ) { 1302 1296 return; 1303 1297 } 1304 1298 1305 // Bail if already querying by an existing role 1299 // Bail if already querying by an existing role. 1306 1300 if ( ! empty( $query->query_vars['role'] ) ) { 1307 1301 return; … … 1317 1311 * 1318 1312 * @param array $views WP List Table views. 1319 *1320 1313 * @return array The views with the signup view added. 1321 1314 */ 1322 1315 public function signup_filter_view( $views = array() ) { 1323 1316 1324 // Remove the 'current' class from All if we're on the signups view 1317 // Remove the 'current' class from All if we're on the signups view. 1325 1318 if ( $this->signups_page == get_current_screen()->id ) { 1326 1319 $views['all'] = str_replace( 'class="current"', '', $views['all'] ); … … 1346 1339 * @param string $class The name of the class to use. 1347 1340 * @param string $required The parent class. 1348 * 1349 * @return WP_List_Table The List table. 1341 * @return WP_List_Table The List table. 1350 1342 */ 1351 1343 public static function get_list_table_class( $class = '', $required = '' ) { … … 1376 1368 global $bp_members_signup_list_table; 1377 1369 1378 // Build redirection URL 1370 // Build redirection URL. 1379 1371 $redirect_to = remove_query_arg( array( 'action', 'error', 'updated', 'activated', 'notactivated', 'deleted', 'notdeleted', 'resent', 'notresent', 'do_delete', 'do_resend', 'do_activate', '_wpnonce', 'signup_ids' ), $_SERVER['REQUEST_URI'] ); 1380 1372 $doaction = bp_admin_list_table_current_bulk_action(); … … 1399 1391 $allowed_actions = apply_filters( 'bp_signups_admin_allowed_actions', array( 'do_delete', 'do_activate', 'do_resend' ) ); 1400 1392 1401 // Prepare the display of the Community Profile screen 1393 // Prepare the display of the Community Profile screen. 1402 1394 if ( ! in_array( $doaction, $allowed_actions ) || ( -1 == $doaction ) ) { 1403 1395 … … 1408 1400 } 1409 1401 1410 // per_page screen option1402 // The per_page screen option. 1411 1403 add_screen_option( 'per_page', array( 'label' => _x( 'Pending Accounts', 'Pending Accounts per page (screen options)', 'buddypress' ) ) ); 1412 1404 … … 1432 1424 ) ); 1433 1425 1434 // Help panel - sidebar links 1426 // Help panel - sidebar links. 1435 1427 get_current_screen()->set_help_sidebar( 1436 1428 '<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' . … … 1442 1434 } 1443 1435 1444 // Handle resent activation links 1436 // Handle resent activation links. 1445 1437 if ( 'do_resend' == $doaction ) { 1446 1438 1447 // nonce check1439 // Nonce check. 1448 1440 check_admin_referer( 'signups_resend' ); 1449 1441 … … 1469 1461 bp_core_redirect( $redirect_to ); 1470 1462 1471 // Handle activated accounts 1463 // Handle activated accounts. 1472 1464 } elseif ( 'do_activate' == $doaction ) { 1473 1465 1474 // nonce check1466 // Nonce check. 1475 1467 check_admin_referer( 'signups_activate' ); 1476 1468 … … 1496 1488 bp_core_redirect( $redirect_to ); 1497 1489 1498 // Handle sign-ups delete 1490 // Handle sign-ups delete. 1499 1491 } elseif ( 'do_delete' == $doaction ) { 1500 1492 1501 // nonce check1493 // Nonce check. 1502 1494 check_admin_referer( 'signups_delete' ); 1503 1495 … … 1523 1515 bp_core_redirect( $redirect_to ); 1524 1516 1525 // Plugins can update other stuff from here 1517 // Plugins can update other stuff from here. 1526 1518 } else { 1527 1519 $this->redirect = $redirect_to; … … 1550 1542 public function signups_display_errors() { 1551 1543 1552 // Look for sign-up errors 1544 // Look for sign-up errors. 1553 1545 $errors = get_transient( '_bp_admin_signups_errors' ); 1554 1546 1555 // Bail if no activation errors 1547 // Bail if no activation errors. 1556 1548 if ( empty( $errors ) ) { 1557 1549 return; 1558 1550 } 1559 1551 1560 // Loop through errors and display them 1552 // Loop through errors and display them. 1561 1553 foreach ( $errors as $error ) : ?> 1562 1554 … … 1565 1557 <?php endforeach; 1566 1558 1567 // Delete the redirect transient 1559 // Delete the redirect transient. 1568 1560 delete_transient( '_bp_admin_signups_errors' ); 1569 1561 } … … 1578 1570 private function get_signup_notice() { 1579 1571 1580 // Setup empty notice for return value 1572 // Setup empty notice for return value. 1581 1573 $notice = array(); 1582 1574 1583 // Updates 1575 // Updates. 1584 1576 if ( ! empty( $_REQUEST['updated'] ) ) { 1585 1577 switch ( $_REQUEST['updated'] ) { … … 1688 1680 } 1689 1681 1690 // Errors 1682 // Errors. 1691 1683 if ( ! empty( $_REQUEST['error'] ) ) { 1692 1684 switch ( $_REQUEST['error'] ) { … … 1733 1725 $doaction = bp_admin_list_table_current_bulk_action(); 1734 1726 1735 // Prepare notices for admin 1727 // Prepare notices for admin. 1736 1728 $notice = $this->get_signup_notice(); 1737 1729 1738 // Display notices 1730 // Display notices. 1739 1731 if ( ! empty( $notice ) ) : 1740 1732 if ( 'updated' === $notice['class'] ) : ?> … … 1760 1752 <?php endif; 1761 1753 1762 // Show the proper screen 1754 // Show the proper screen. 1763 1755 switch ( $doaction ) { 1764 1756 case 'activate' : … … 1788 1780 $usersearch = ! empty( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : ''; 1789 1781 1790 // Prepare the group items for display 1782 // Prepare the group items for display. 1791 1783 $bp_members_signup_list_table->prepare_items(); 1792 1784 … … 1843 1835 </h2> 1844 1836 1845 <?php // Display each signups on its own row ?>1837 <?php // Display each signups on its own row. ?> 1846 1838 <?php $bp_members_signup_list_table->views(); ?> 1847 1839 … … 1864 1856 * 1865 1857 * @param string $action Delete, activate, or resend activation link. 1866 *1867 1858 * @return string 1868 1859 */ … … 1872 1863 } 1873 1864 1874 // Get the user IDs from the URL 1865 // Get the user IDs from the URL. 1875 1866 $ids = false; 1876 1867 if ( ! empty( $_POST['allsignups'] ) ) { … … 1885 1876 1886 1877 // Query for signups, and filter out those IDs that don't 1887 // correspond to an actual signup 1878 // correspond to an actual signup. 1888 1879 $signups_query = BP_Signup::get( array( 1889 1880 'include' => $ids, … … 1893 1884 $signup_ids = wp_list_pluck( $signups, 'signup_id' ); 1894 1885 1895 // Set up strings 1886 // Set up strings. 1896 1887 switch ( $action ) { 1897 1888 case 'delete' : … … 1923 1914 } 1924 1915 1925 // These arguments are added to all URLs 1916 // These arguments are added to all URLs. 1926 1917 $url_args = array( 'page' => 'bp-signups' ); 1927 1918 1928 // These arguments are only added when performing an action 1919 // These arguments are only added when performing an action. 1929 1920 $action_args = array( 1930 1921 'action' => 'do_' . $action, … … 1987 1978 } 1988 1979 } 1989 endif; // class_exists check1990 1991 // Load the BP Members admin 1980 endif; // End class_exists check. 1981 1982 // Load the BP Members admin. 1992 1983 add_action( 'bp_init', array( 'BP_Members_Admin', 'register_members_admin' ) ); -
trunk/src/bp-members/bp-members-adminbar.php
r10190 r10322 17 17 * @since 1.6.0 18 18 * 19 * @todo Deprecate WP 3.2 Toolbar compatibility when we drop 3.2 support 19 * @todo Deprecate WP 3.2 Toolbar compatibility when we drop 3.2 support. 20 20 */ 21 21 function bp_members_admin_bar_my_account_menu() { 22 22 global $wp_admin_bar; 23 23 24 // Bail if this is an ajax request 24 // Bail if this is an ajax request. 25 25 if ( defined( 'DOING_AJAX' ) ) 26 26 return; 27 27 28 // Logged in user 28 // Logged in user. 29 29 if ( is_user_logged_in() ) { 30 30 31 31 $bp = buddypress(); 32 32 33 // Stored in the global so we can add menus easily later on 33 // Stored in the global so we can add menus easily later on. 34 34 $bp->my_account_menu_id = 'my-account-buddypress'; 35 35 36 // Create the main 'My Account' menu 36 // Create the main 'My Account' menu. 37 37 $wp_admin_bar->add_menu( array( 38 38 'id' => $bp->my_account_menu_id, … … 44 44 ) ) ); 45 45 46 // Show login and sign-up links 46 // Show login and sign-up links. 47 47 } elseif ( !empty( $wp_admin_bar ) ) { 48 48 49 49 add_filter ( 'show_admin_bar', '__return_true' ); 50 50 51 // Create the main 'My Account' menu 51 // Create the main 'My Account' menu. 52 52 $wp_admin_bar->add_menu( array( 53 53 'id' => 'bp-login', … … 56 56 ) ); 57 57 58 // Sign up 58 // Sign up. 59 59 if ( bp_get_signup_allowed() ) { 60 60 $wp_admin_bar->add_menu( array( … … 76 76 global $wp_admin_bar; 77 77 78 // Only show if viewing a user 78 // Only show if viewing a user. 79 79 if ( !bp_is_user() ) 80 80 return false; 81 81 82 // Don't show this menu to non site admins or if you're viewing your own profile 82 // Don't show this menu to non site admins or if you're viewing your own profile. 83 83 if ( !current_user_can( 'edit_users' ) || bp_is_my_profile() ) 84 84 return false; … … 86 86 $bp = buddypress(); 87 87 88 // Unique ID for the 'My Account' menu 88 // Unique ID for the 'My Account' menu. 89 89 $bp->user_admin_menu_id = 'user-admin'; 90 90 91 // Add the top-level User Admin button 91 // Add the top-level User Admin button. 92 92 $wp_admin_bar->add_menu( array( 93 93 'id' => $bp->user_admin_menu_id, … … 97 97 98 98 if ( bp_is_active( 'xprofile' ) ) { 99 // User Admin > Edit this user's profile 99 // User Admin > Edit this user's profile. 100 100 $wp_admin_bar->add_menu( array( 101 101 'parent' => $bp->user_admin_menu_id, … … 105 105 ) ); 106 106 107 // User Admin > Edit this user's avatar 107 // User Admin > Edit this user's avatar. 108 108 if ( buddypress()->avatar->show_avatars ) { 109 109 $wp_admin_bar->add_menu( array( … … 115 115 } 116 116 117 // User Admin > Edit this user's cover image 117 // User Admin > Edit this user's cover image. 118 118 if ( bp_displayed_user_use_cover_image_header() ) { 119 119 $wp_admin_bar->add_menu( array( … … 128 128 129 129 if ( bp_is_active( 'settings' ) ) { 130 // User Admin > Spam/unspam 130 // User Admin > Spam/unspam. 131 131 $wp_admin_bar->add_menu( array( 132 132 'parent' => $bp->user_admin_menu_id, … … 136 136 ) ); 137 137 138 // User Admin > Delete Account 138 // User Admin > Delete Account. 139 139 $wp_admin_bar->add_menu( array( 140 140 'parent' => $bp->user_admin_menu_id, … … 153 153 * 154 154 * @since 1.5.0 155 * 156 * @return bool 155 157 */ 156 158 function bp_members_admin_bar_notifications_menu() { 157 159 158 // Bail if notifications is not active 160 // Bail if notifications is not active. 159 161 if ( ! bp_is_active( 'notifications' ) ) { 160 162 return false; -
trunk/src/bp-members/bp-members-filters.php
r10149 r10322 33 33 function bp_members_signup_sanitization() { 34 34 35 // Filters on sign-up fields 35 // Filters on sign-up fields. 36 36 $fields = array ( 37 37 'bp_get_signup_username_value', … … 44 44 ); 45 45 46 // Add the filters to each field 46 // Add the filters to each field. 47 47 foreach( $fields as $filter ) { 48 48 add_filter( $filter, 'esc_html', 1 ); … … 51 51 } 52 52 53 // Sanitize email 53 // Sanitize email. 54 54 add_filter( 'bp_get_signup_email_value', 'sanitize_email' ); 55 55 } … … 66 66 * @since 2.1.0 67 67 * 68 * @param array $illegal_names 69 * 68 * @param array $illegal_names Array of illiegal names. 70 69 * @return array $illegal_names 71 70 */ … … 102 101 * @param string $url WP profile edit URL. 103 102 * @param int $user_id ID of the user. 104 * @param string $scheme 105 * 103 * @param string $scheme Scheme to use. 106 104 * @return string 107 105 */ 108 106 function bp_members_edit_profile_url( $url, $user_id, $scheme = 'admin' ) { 109 107 110 // If xprofile is active, use profile domain link 108 // If xprofile is active, use profile domain link. 111 109 if ( ! is_admin() && bp_is_active( 'xprofile' ) ) { 112 110 $profile_link = trailingslashit( bp_core_get_user_domain( $user_id ) . bp_get_profile_slug() . '/edit' ); 113 111 114 // Default to $url 112 // Default to $url. 115 113 } else { 116 114 $profile_link = $url; -
trunk/src/bp-members/bp-members-functions.php
r10276 r10322 39 39 $bp = buddypress(); 40 40 41 // No custom members slug 41 // No custom members slug. 42 42 if ( !defined( 'BP_MEMBERS_SLUG' ) ) { 43 43 if ( !empty( $bp->pages->members ) ) { … … 48 48 } 49 49 50 // No custom registration slug 50 // No custom registration slug. 51 51 if ( !defined( 'BP_REGISTER_SLUG' ) ) { 52 52 if ( !empty( $bp->pages->register ) ) { … … 57 57 } 58 58 59 // No custom activation slug 59 // No custom activation slug. 60 60 if ( !defined( 'BP_ACTIVATION_SLUG' ) ) { 61 61 if ( !empty( $bp->pages->activate ) ) { … … 98 98 function bp_core_get_users( $args = '' ) { 99 99 100 // Parse the user query arguments 100 // Parse the user query arguments. 101 101 $r = bp_parse_args( $args, array( 102 'type' => 'active', // active, newest, alphabetical, random or popular103 'user_id' => false, // Pass a user_id to limit to only friend connections for this user 104 'exclude' => false, // Users to exclude from results 105 'search_terms' => false, // Limit to users that match these search terms 106 'meta_key' => false, // Limit to users who have this piece of usermeta 107 'meta_value' => false, // With meta_key, limit to users where usermeta matches this value 102 'type' => 'active', // Active, newest, alphabetical, random or popular. 103 'user_id' => false, // Pass a user_id to limit to only friend connections for this user. 104 'exclude' => false, // Users to exclude from results. 105 'search_terms' => false, // Limit to users that match these search terms. 106 'meta_key' => false, // Limit to users who have this piece of usermeta. 107 'meta_value' => false, // With meta_key, limit to users where usermeta matches this value. 108 108 'member_type' => '', 109 109 'member_type__in' => '', 110 110 'member_type__not_in' => '', 111 'include' => false, // Pass comma separated list of user_ids to limit to only these users 112 'per_page' => 20, // The number of results to return per page 113 'page' => 1, // The page to return if limiting per page 114 'populate_extras' => true, // Fetch the last active, where the user is a friend, total friend count, latest update 115 'count_total' => 'count_query' // What kind of total user count to do, if any. 'count_query', 'sql_calc_found_rows', or false 111 'include' => false, // Pass comma separated list of user_ids to limit to only these users. 112 'per_page' => 20, // The number of results to return per page. 113 'page' => 1, // The page to return if limiting per page. 114 'populate_extras' => true, // Fetch the last active, where the user is a friend, total friend count, latest update. 115 'count_total' => 'count_query' // What kind of total user count to do, if any. 'count_query', 'sql_calc_found_rows', or false. 116 116 ), 'core_get_users' ); 117 117 … … 131 131 ); 132 132 133 // Default behavior as of BuddyPress 1.7 133 // Default behavior as of BuddyPress 1.7.0. 134 134 } else { 135 135 … … 161 161 * @param string|bool $user_nicename Optional. user_nicename of the user. 162 162 * @param string|bool $user_login Optional. user_login of the user. 163 *164 163 * @return string 165 164 */ … … 200 199 * 201 200 * @param int $user_id The ID of the user. 202 *203 201 * @return array 204 202 */ … … 231 229 * 232 230 * @param string $user_login user_login of the user being queried. 233 *234 231 * @return int 235 232 */ … … 244 241 * 245 242 * @param string $username user_login to check. 246 *247 243 * @return int|null The ID of the matched user on success, null on failure. 248 244 */ … … 271 267 * 272 268 * @param string $user_nicename user_nicename to check. 273 *274 269 * @return int|null The ID of the matched user on success, null on failure. 275 270 */ … … 301 296 * @param string|bool $user_nicename Optional. user_nicename of user being checked. 302 297 * @param string|bool $user_login Optional. user_login of user being checked. 303 *304 298 * @return string|bool The username of the matched user, or false. 305 299 */ … … 307 301 $bp = buddypress(); 308 302 309 // Check cache for user nicename 303 // Check cache for user nicename. 310 304 $username = wp_cache_get( 'bp_user_username_' . $user_id, 'bp' ); 311 305 if ( false === $username ) { 312 306 313 // Cache not found so prepare to update it 307 // Cache not found so prepare to update it. 314 308 $update_cache = true; 315 309 316 // Nicename and login were not passed 310 // Nicename and login were not passed. 317 311 if ( empty( $user_nicename ) && empty( $user_login ) ) { 318 312 319 // User ID matches logged in user 313 // User ID matches logged in user. 320 314 if ( bp_loggedin_user_id() == $user_id ) { 321 315 $userdata = &$bp->loggedin_user->userdata; 322 316 323 // User ID matches displayed in user 317 // User ID matches displayed in user. 324 318 } elseif ( bp_displayed_user_id() == $user_id ) { 325 319 $userdata = &$bp->displayed_user->userdata; 326 320 327 // No user ID match 321 // No user ID match. 328 322 } else { 329 323 $userdata = false; 330 324 } 331 325 332 // No match so go dig 326 // No match so go dig. 333 327 if ( empty( $userdata ) ) { 334 328 335 // User not found so return false 329 // User not found so return false. 336 330 if ( !$userdata = bp_core_get_core_userdata( $user_id ) ) { 337 331 return false; … … 339 333 } 340 334 341 // Update the $user_id for later 335 // Update the $user_id for later. 342 336 $user_id = $userdata->ID; 343 337 344 // Two possible options 338 // Two possible options. 345 339 $user_nicename = $userdata->user_nicename; 346 340 $user_login = $userdata->user_login; 347 341 } 348 342 349 // Pull an audible and maybe use the login over the nicename 343 // Pull an audible and maybe use the login over the nicename. 350 344 $username = bp_is_username_compatibility_mode() ? $user_login : $user_nicename; 351 345 352 // Username found in cache so don't update it again 346 // Username found in cache so don't update it again. 353 347 } else { 354 348 $update_cache = false; 355 349 } 356 350 357 // Add this to cache 351 // Add this to cache. 358 352 if ( ( true === $update_cache ) && !empty( $username ) ) { 359 353 wp_cache_set( 'bp_user_username_' . $user_id, $username, 'bp' ); 360 354 361 355 // @todo bust this cache if no $username found? 362 // } else {363 // 356 // } else { 357 // wp_cache_delete( 'bp_user_username_' . $user_id ); 364 358 } 365 359 … … 385 379 * 386 380 * @param int $user_id User ID to check. 387 *388 381 * @return string|bool The username of the matched user, or false. 389 382 */ … … 394 387 $update_cache = true; 395 388 396 // User ID matches logged in user 389 // User ID matches logged in user. 397 390 if ( bp_loggedin_user_id() == $user_id ) { 398 391 $userdata = &$bp->loggedin_user->userdata; 399 392 400 // User ID matches displayed in user 393 // User ID matches displayed in user. 401 394 } elseif ( bp_displayed_user_id() == $user_id ) { 402 395 $userdata = &$bp->displayed_user->userdata; 403 396 404 // No user ID match 397 // No user ID match. 405 398 } else { 406 399 $userdata = false; 407 400 } 408 401 409 // No match so go dig 402 // No match so go dig. 410 403 if ( empty( $userdata ) ) { 411 404 412 // User not found so return false 405 // User not found so return false. 413 406 if ( !$userdata = bp_core_get_core_userdata( $user_id ) ) { 414 407 return false; … … 416 409 } 417 410 418 // User nicename found 411 // User nicename found. 419 412 $user_nicename = $userdata->user_nicename; 420 413 421 // Nicename found in cache so don't update it again 414 // Nicename found in cache so don't update it again. 422 415 } else { 423 416 $update_cache = false; 424 417 } 425 418 426 // Add this to cache 419 // Add this to cache. 427 420 if ( true == $update_cache && !empty( $user_nicename ) ) { 428 421 wp_cache_set( 'bp_members_user_nicename_' . $user_id, $user_nicename, 'bp' ); … … 443 436 * 444 437 * @param int $uid User ID to check. 445 *446 438 * @return string The email for the matched user. Empty string if no user 447 439 * matched the $uid. … … 451 443 if ( !$email = wp_cache_get( 'bp_user_email_' . $uid, 'bp' ) ) { 452 444 453 // User exists 445 // User exists. 454 446 $ud = bp_core_get_core_userdata( $uid ); 455 447 if ( ! empty( $ud ) ) { 456 448 $email = $ud->user_email; 457 449 458 // User was deleted 450 // User was deleted. 459 451 } else { 460 452 $email = ''; … … 477 469 * Return a HTML formatted link for a user with the user's full name as the link text. 478 470 * 479 * eg: <a href="http://andy.example.com/">Andy Peatling</a>471 * Eg: <a href="http://andy.example.com/">Andy Peatling</a> 480 472 * 481 473 * Optional parameters will return just the name or just the URL. … … 486 478 * @param bool $just_link Disable full name and HTML and just return the URL 487 479 * text. Default false. 488 *489 480 * @return string|bool The link text based on passed parameters, or false on 490 481 * no match. … … 528 519 * @since 2.0.0 529 520 * 530 * @param array $user_ids 531 * 521 * @param array $user_ids Array of user IDs to get display names for. 532 522 * @return array 533 523 */ 534 524 function bp_core_get_user_displaynames( $user_ids ) { 535 525 536 // Sanitize 526 // Sanitize. 537 527 $user_ids = wp_parse_id_list( $user_ids ); 538 528 539 // Remove dupes and empties 529 // Remove dupes and empties. 540 530 $user_ids = array_unique( array_filter( $user_ids ) ); 541 531 … … 551 541 } 552 542 553 // Prime caches 543 // Prime caches. 554 544 if ( ! empty( $uncached_ids ) ) { 555 545 if ( bp_is_active( 'xprofile' ) ) { 556 546 $fullname_data = BP_XProfile_ProfileData::get_value_byid( 1, $uncached_ids ); 557 547 558 // Key by user_id 548 // Key by user_id. 559 549 $fullnames = array(); 560 550 foreach ( $fullname_data as $fd ) { … … 565 555 566 556 // If xprofiledata is not found for any users, we'll look 567 // them up separately 557 // them up separately. 568 558 $no_xprofile_ids = array_diff( $uncached_ids, array_keys( $fullnames ) ); 569 559 } else { … … 573 563 574 564 if ( ! empty( $no_xprofile_ids ) ) { 575 // Use WP_User_Query because we don't need BP information 565 // Use WP_User_Query because we don't need BP information. 576 566 $query = new WP_User_Query( array( 577 567 'include' => $no_xprofile_ids, … … 585 575 586 576 // If xprofile is active, set this value as the 587 // xprofile display name as well 577 // xprofile display name as well. 588 578 if ( bp_is_active( 'xprofile' ) ) { 589 579 xprofile_set_field_data( 1, $qr->ID, $fullnames[ $qr->ID ] ); … … 609 599 * 610 600 * @param int|string|bool $user_id_or_username User ID or username. 611 *612 601 * @return string|bool The display name for the user in question, or false if 613 602 * user not found. … … 655 644 * 656 645 * @param string $email The email address for the user. 657 *658 646 * @return string The link to the users home base. False on no match. 659 647 */ … … 677 665 * this should be user_login, otherwise it should 678 666 * be user_nicename. 679 *680 667 * @return string|bool The link to the user's domain, false on no match. 681 668 */ … … 739 726 $bp = buddypress(); 740 727 741 // Avoid a costly join by splitting the lookup 728 // Avoid a costly join by splitting the lookup. 742 729 if ( is_multisite() ) { 743 730 $sql = "SELECT ID FROM {$wpdb->users} WHERE (user_status != 0 OR deleted != 0 OR user_status != 0)"; … … 781 768 * performed this cleanup independently, as when hooked 782 769 * to 'make_spam_user'. 783 *784 770 * @return bool True on success, false on failure. 785 771 */ … … 787 773 global $wpdb; 788 774 789 // Bail if no user ID 775 // Bail if no user ID. 790 776 if ( empty( $user_id ) ) { 791 777 return; 792 778 } 793 779 794 // Bail if user ID is super admin 780 // Bail if user ID is super admin. 795 781 if ( is_super_admin( $user_id ) ) { 796 782 return; 797 783 } 798 784 799 // Get the functions file 785 // Get the functions file. 800 786 if ( is_multisite() ) { 801 787 require_once( ABSPATH . 'wp-admin/includes/ms.php' ); … … 804 790 $is_spam = ( 'spam' == $status ); 805 791 806 // Only you can prevent infinite loops 792 // Only you can prevent infinite loops. 807 793 remove_action( 'make_spam_user', 'bp_core_mark_user_spam_admin' ); 808 794 remove_action( 'make_ham_user', 'bp_core_mark_user_ham_admin' ); 809 795 810 // force the cleanup of WordPress content and status for multisite configs796 // Force the cleanup of WordPress content and status for multisite configs. 811 797 if ( $do_wp_cleanup ) { 812 798 813 // Get the blogs for the user 799 // Get the blogs for the user. 814 800 $blogs = get_blogs_of_user( $user_id, true ); 815 801 816 802 foreach ( (array) array_values( $blogs ) as $details ) { 817 803 818 // Do not mark the main or current root blog as spam 804 // Do not mark the main or current root blog as spam. 819 805 if ( 1 == $details->userblog_id || bp_get_root_blog_id() == $details->userblog_id ) { 820 806 continue; 821 807 } 822 808 823 // Update the blog status 809 // Update the blog status. 824 810 update_blog_status( $details->userblog_id, 'spam', $is_spam ); 825 811 } 826 812 827 // Finally, mark this user as a spammer 813 // Finally, mark this user as a spammer. 828 814 if ( is_multisite() ) { 829 815 update_user_status( $user_id, 'spam', $is_spam ); … … 831 817 } 832 818 833 // Update the user status 819 // Update the user status. 834 820 $wpdb->update( $wpdb->users, array( 'user_status' => $is_spam ), array( 'ID' => $user_id ) ); 835 821 836 // Clean user cache 822 // Clean user cache. 837 823 clean_user_cache( $user_id ); 838 824 839 825 if ( ! is_multisite() ) { 840 // Call multisite actions in single site mode for good measure 826 // Call multisite actions in single site mode for good measure. 841 827 if ( true === $is_spam ) { 842 828 … … 862 848 } 863 849 864 // Hide this user's activity 850 // Hide this user's activity. 865 851 if ( ( true === $is_spam ) && bp_is_active( 'activity' ) ) { 866 852 bp_activity_hide_user_activity( $user_id ); 867 853 } 868 854 869 // We need a special hook for is_spam so that components can delete data at spam time 855 // We need a special hook for is_spam so that components can delete data at spam time. 870 856 if ( true === $is_spam ) { 871 857 … … 900 886 do_action( 'bp_core_process_spammer_status', $user_id, $is_spam ); 901 887 902 // Put things back how we found them 888 // Put things back how we found them. 903 889 add_action( 'make_spam_user', 'bp_core_mark_user_spam_admin' ); 904 890 add_action( 'make_ham_user', 'bp_core_mark_user_ham_admin' ); … … 934 920 * 935 921 * @param int $user_id The ID for the user. 936 *937 922 * @return bool True if spammer, otherwise false. 938 923 */ 939 924 function bp_is_user_spammer( $user_id = 0 ) { 940 925 941 // No user to check 926 // No user to check. 942 927 if ( empty( $user_id ) ) { 943 928 return false; … … 946 931 $bp = buddypress(); 947 932 948 // Assume user is not spam 933 // Assume user is not spam. 949 934 $is_spammer = false; 950 935 951 // Setup our user 936 // Setup our user. 952 937 $user = false; 953 938 954 // Get locally-cached data if available 939 // Get locally-cached data if available. 955 940 switch ( $user_id ) { 956 941 case bp_loggedin_user_id() : … … 963 948 } 964 949 965 // Manually get userdata if still empty 950 // Manually get userdata if still empty. 966 951 if ( empty( $user ) ) { 967 952 $user = get_userdata( $user_id ); 968 953 } 969 954 970 // No user found 955 // No user found. 971 956 if ( empty( $user ) ) { 972 957 $is_spammer = false; 973 958 974 // User found 959 // User found. 975 960 } else { 976 961 977 // Check if spam 962 // Check if spam. 978 963 if ( !empty( $user->spam ) ) { 979 964 $is_spammer = true; … … 999 984 * 1000 985 * @param int $user_id The ID for the user. 1001 *1002 986 * @return bool True if deleted, otherwise false. 1003 987 */ 1004 988 function bp_is_user_deleted( $user_id = 0 ) { 1005 989 1006 // No user to check 990 // No user to check. 1007 991 if ( empty( $user_id ) ) { 1008 992 return false; … … 1011 995 $bp = buddypress(); 1012 996 1013 // Assume user is not deleted 997 // Assume user is not deleted. 1014 998 $is_deleted = false; 1015 999 1016 // Setup our user 1000 // Setup our user. 1017 1001 $user = false; 1018 1002 1019 // Get locally-cached data if available 1003 // Get locally-cached data if available. 1020 1004 switch ( $user_id ) { 1021 1005 case bp_loggedin_user_id() : … … 1028 1012 } 1029 1013 1030 // Manually get userdata if still empty 1014 // Manually get userdata if still empty. 1031 1015 if ( empty( $user ) ) { 1032 1016 $user = get_userdata( $user_id ); 1033 1017 } 1034 1018 1035 // No user found 1019 // No user found. 1036 1020 if ( empty( $user ) ) { 1037 1021 $is_deleted = true; 1038 1022 1039 // User found 1023 // User found. 1040 1024 } else { 1041 1025 1042 // Check if deleted 1026 // Check if deleted. 1043 1027 if ( !empty( $user->deleted ) ) { 1044 1028 $is_deleted = true; … … 1071 1055 * 1072 1056 * @param int $user_id The user ID to check. 1073 *1074 1057 * @return bool True if active, otherwise false. 1075 1058 */ 1076 1059 function bp_is_user_active( $user_id = 0 ) { 1077 1060 1078 // Default to current user 1061 // Default to current user. 1079 1062 if ( empty( $user_id ) && is_user_logged_in() ) { 1080 1063 $user_id = bp_loggedin_user_id(); 1081 1064 } 1082 1065 1083 // No user to check 1066 // No user to check. 1084 1067 if ( empty( $user_id ) ) { 1085 1068 return false; 1086 1069 } 1087 1070 1088 // Check spam 1071 // Check spam. 1089 1072 if ( bp_is_user_spammer( $user_id ) ) { 1090 1073 return false; 1091 1074 } 1092 1075 1093 // Check deleted 1076 // Check deleted. 1094 1077 if ( bp_is_user_deleted( $user_id ) ) { 1095 1078 return false; 1096 1079 } 1097 1080 1098 // Assume true if not spam or deleted 1081 // Assume true if not spam or deleted. 1099 1082 return true; 1100 1083 } … … 1113 1096 * 1114 1097 * @param int $user_id The user ID to check. 1115 *1116 1098 * @return bool True if inactive, otherwise false. 1117 1099 */ 1118 1100 function bp_is_user_inactive( $user_id = 0 ) { 1119 1101 1120 // Default to current user 1102 // Default to current user. 1121 1103 if ( empty( $user_id ) && is_user_logged_in() ) { 1122 1104 $user_id = bp_loggedin_user_id(); 1123 1105 } 1124 1106 1125 // No user to check 1107 // No user to check. 1126 1108 if ( empty( $user_id ) ) { 1127 1109 return false; 1128 1110 } 1129 1111 1130 // Return the inverse of active 1112 // Return the inverse of active. 1131 1113 return !bp_is_user_active( $user_id ); 1132 1114 } … … 1139 1121 * @param int $user_id ID of the user being updated. 1140 1122 * @param string $time Time of last activity, in 'Y-m-d H:i:s' format. 1141 *1142 1123 * @return bool True on success, false on failure. 1143 1124 */ 1144 1125 function bp_update_user_last_activity( $user_id = 0, $time = '' ) { 1145 1126 1146 // Fall back on current user 1127 // Fall back on current user. 1147 1128 if ( empty( $user_id ) ) { 1148 1129 $user_id = bp_loggedin_user_id(); 1149 1130 } 1150 1131 1151 // Bail if the user id is 0, as there's nothing to update 1132 // Bail if the user id is 0, as there's nothing to update. 1152 1133 if ( empty( $user_id ) ) { 1153 1134 return false; 1154 1135 } 1155 1136 1156 // Fall back on current time 1137 // Fall back on current time. 1157 1138 if ( empty( $time ) ) { 1158 1139 $time = bp_core_current_time(); … … 1183 1164 * @access private For internal use only. 1184 1165 * 1185 * @param null $retval 1166 * @param null $retval Null retval value. 1186 1167 * @param int $object_id ID of the user. 1187 1168 * @param string $meta_key Meta key being fetched. 1188 *1189 1169 * @return mixed 1190 1170 */ … … 1193 1173 1194 1174 if ( 'last_activity' === $meta_key ) { 1195 // Don't send the warning more than once per pageload 1175 // Don't send the warning more than once per pageload. 1196 1176 if ( false === $warned ) { 1197 1177 _doing_it_wrong( 'get_user_meta( $user_id, \'last_activity\' )', __( 'User last_activity data is no longer stored in usermeta. Use bp_get_user_last_activity() instead.', 'buddypress' ), '2.0.0' ); … … 1235 1215 * 1236 1216 * @param int $user_id The ID of the user. 1237 *1238 1217 * @return string Time of last activity, in 'Y-m-d H:i:s' format, or an empty 1239 1218 * string if none is found. … … 1274 1253 // Wipe out existing last_activity data in the activity table - 1275 1254 // this helps to prevent duplicates when pulling from the usermeta 1276 // table 1255 // table. 1277 1256 $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->members->table_name_last_activity} WHERE component = %s AND type = 'last_activity'", $bp->members->id ) ); 1278 1257 … … 1295 1274 * 1296 1275 * @param int $user_id ID of the user being queried. 1297 *1298 1276 * @return array Post IDs. 1299 1277 */ … … 1319 1297 function bp_core_delete_account( $user_id = 0 ) { 1320 1298 1321 // Use logged in user ID if none is passed 1299 // Use logged in user ID if none is passed. 1322 1300 if ( empty( $user_id ) ) { 1323 1301 $user_id = bp_loggedin_user_id(); 1324 1302 } 1325 1303 1326 // Site admins cannot be deleted 1304 // Site admins cannot be deleted. 1327 1305 if ( is_super_admin( $user_id ) ) { 1328 1306 return false; 1329 1307 } 1330 1308 1331 // Extra checks if user is not deleting themselves 1309 // Extra checks if user is not deleting themselves. 1332 1310 if ( bp_loggedin_user_id() !== absint( $user_id ) ) { 1333 1311 1334 // Bail if current user cannot delete any users 1312 // Bail if current user cannot delete any users. 1335 1313 if ( ! bp_current_user_can( 'delete_users' ) ) { 1336 1314 return false; 1337 1315 } 1338 1316 1339 // Bail if current user cannot delete this user 1317 // Bail if current user cannot delete this user. 1340 1318 if ( ! current_user_can_for_blog( bp_get_root_blog_id(), 'delete_user', $user_id ) ) { 1341 1319 return false; … … 1352 1330 do_action( 'bp_core_pre_delete_account', $user_id ); 1353 1331 1354 // Specifically handle multi-site environment 1332 // Specifically handle multi-site environment. 1355 1333 if ( is_multisite() ) { 1356 1334 require_once( ABSPATH . '/wp-admin/includes/ms.php' ); … … 1359 1337 $retval = wpmu_delete_user( $user_id ); 1360 1338 1361 // Single site user deletion 1339 // Single site user deletion. 1362 1340 } else { 1363 1341 require_once( ABSPATH . '/wp-admin/includes/user.php' ); … … 1383 1361 * 1384 1362 * @param int $user_id ID of the user who is about to be deleted. 1385 *1386 1363 * @return bool True on success, false on failure. 1387 1364 */ … … 1401 1378 * 1402 1379 * @param string $str String to be upper-cased. 1403 *1404 1380 * @return string 1405 1381 */ … … 1423 1399 * @param WP_User|WP_Error $user Either the WP_User object or the WP_Error 1424 1400 * object, as passed to the 'authenticate' filter. 1425 *1426 1401 * @return WP_User|WP_Error If the user is not a spammer, return the WP_User 1427 1402 * object. Otherwise a new WP_Error object. … … 1429 1404 function bp_core_boot_spammer( $user ) { 1430 1405 1431 // check to see if the $user has already failed logging in, if so return $user as-is1406 // Check to see if the $user has already failed logging in, if so return $user as-is. 1432 1407 if ( is_wp_error( $user ) || empty( $user ) ) { 1433 1408 return $user; 1434 1409 } 1435 1410 1436 // the user exists; now do a check to see if the user is a spammer1411 // The user exists; now do a check to see if the user is a spammer 1437 1412 // if the user is a spammer, stop them in their tracks! 1438 1413 if ( is_a( $user, 'WP_User' ) && ( ( is_multisite() && (int) $user->spam ) || 1 == $user->user_status ) ) { … … 1440 1415 } 1441 1416 1442 // user is good to go!1417 // User is good to go! 1443 1418 return $user; 1444 1419 } … … 1452 1427 function bp_core_remove_data( $user_id ) { 1453 1428 1454 // Remove last_activity data 1429 // Remove last_activity data. 1455 1430 BP_Core_User::delete_last_activity( $user_id ); 1456 1431 1457 // Flush the cache to remove the user from all cached objects 1432 // Flush the cache to remove the user from all cached objects. 1458 1433 wp_cache_flush(); 1459 1434 } … … 1499 1474 * Multisite settings. 1500 1475 * @param array|string $oldvalue The old value of the option. 1501 *1502 1476 * @return array Merged and unique array of illegal names. 1503 1477 */ 1504 1478 function bp_core_get_illegal_names( $value = '', $oldvalue = '' ) { 1505 1479 1506 // Make sure $value is array 1480 // Make sure $value is array. 1507 1481 if ( empty( $value ) ) { 1508 1482 $db_illegal_names = array(); … … 1531 1505 ); 1532 1506 1533 // Core constants 1507 // Core constants. 1534 1508 $slug_constants = array( 1535 1509 'BP_GROUPS_SLUG', … … 1561 1535 $filtered_illegal_names = apply_filters( 'bp_core_illegal_usernames', array_merge( array( 'www', 'web', 'root', 'admin', 'main', 'invite', 'administrator' ), $bp_component_slugs ) ); 1562 1536 1563 // Merge the arrays together 1537 // Merge the arrays together. 1564 1538 $merged_names = array_merge( (array) $filtered_illegal_names, (array) $db_illegal_names ); 1565 1539 1566 // Remove duplicates 1540 // Remove duplicates. 1567 1541 $illegal_names = array_unique( (array) $merged_names ); 1568 1542 … … 1590 1564 * 1591 1565 * @param string $user_email The email being checked. 1592 *1593 1566 * @return bool|array True if the address passes all checks; otherwise an array 1594 1567 * of error codes. … … 1605 1578 1606 1579 // Is the email on the Banned Email Domains list? 1607 // Note: This check only works on Multisite 1580 // Note: This check only works on Multisite. 1608 1581 if ( function_exists( 'is_email_address_unsafe' ) && is_email_address_unsafe( $user_email ) ) { 1609 1582 $errors['domain_banned'] = 1; … … 1611 1584 1612 1585 // Is the email on the Limited Email Domains list? 1613 // Note: This check only works on Multisite 1586 // Note: This check only works on Multisite. 1614 1587 $limited_email_domains = get_site_option( 'limited_email_domains' ); 1615 1588 if ( is_array( $limited_email_domains ) && empty( $limited_email_domains ) == false ) { … … 1668 1641 * @param string $user_name Username to validate. 1669 1642 * @param string $user_email Email address to validate. 1670 *1671 1643 * @return array Results of user validation including errors, if any. 1672 1644 */ 1673 1645 function bp_core_validate_user_signup( $user_name, $user_email ) { 1674 1646 1675 // Make sure illegal names include BuddyPress slugs and values 1647 // Make sure illegal names include BuddyPress slugs and values. 1676 1648 bp_core_flush_illegal_names(); 1677 1649 … … 1683 1655 // When not running Multisite, we perform our own validation. What 1684 1656 // follows reproduces much of the logic of wpmu_validate_user_signup(), 1685 // minus the multisite-specific restrictions on user_login 1657 // minus the multisite-specific restrictions on user_login. 1686 1658 } else { 1687 1659 $errors = new WP_Error(); … … 1696 1668 $user_name = apply_filters( 'pre_user_login', $user_name ); 1697 1669 1698 // User name can't be empty 1670 // User name can't be empty. 1699 1671 if ( empty( $user_name ) ) { 1700 1672 $errors->add( 'user_name', __( 'Please enter a username', 'buddypress' ) ); 1701 1673 } 1702 1674 1703 // user name can't be on the blacklist1675 // User name can't be on the blacklist. 1704 1676 $illegal_names = get_site_option( 'illegal_names' ); 1705 1677 if ( in_array( $user_name, (array) $illegal_names ) ) { … … 1707 1679 } 1708 1680 1709 // User name must pass WP's validity check 1681 // User name must pass WP's validity check. 1710 1682 if ( ! validate_username( $user_name ) ) { 1711 1683 $errors->add( 'user_name', __( 'Usernames can contain only letters, numbers, ., -, and @', 'buddypress' ) ); 1712 1684 } 1713 1685 1714 // Minimum of 4 characters 1686 // Minimum of 4 characters. 1715 1687 if ( strlen( $user_name ) < 4 ) { 1716 1688 $errors->add( 'user_name', __( 'Username must be at least 4 characters', 'buddypress' ) ); … … 1729 1701 } 1730 1702 1731 // Check into signups 1703 // Check into signups. 1732 1704 $signups = BP_Signup::get( array( 1733 1705 'user_login' => $user_name, … … 1742 1714 1743 1715 // Validate the email address and process the validation results into 1744 // error messages 1716 // error messages. 1745 1717 $validate_email = bp_core_validate_email_address( $user_email ); 1746 1718 bp_core_add_validation_error_messages( $errors, $validate_email ); 1747 1719 1748 // Assemble the return array 1720 // Assemble the return array. 1749 1721 $result = array( 1750 1722 'user_name' => $user_name, … … 1753 1725 ); 1754 1726 1755 // Apply WPMU legacy filter 1727 // Apply WPMU legacy filter. 1756 1728 $result = apply_filters( 'wpmu_validate_user_signup', $result ); 1757 1729 } … … 1774 1746 * @param string $blog_url Blog URL requested during registration. 1775 1747 * @param string $blog_title Blog title requested during registration. 1776 *1777 1748 * @return array 1778 1749 */ … … 1802 1773 * @param array $usermeta Miscellaneous metadata about the user (blog-specific 1803 1774 * signup data, xprofile data, etc). 1804 *1805 1775 * @return bool|WP_Error True on success, WP_Error on failure. 1806 1776 */ … … 1808 1778 $bp = buddypress(); 1809 1779 1810 // We need to cast $user_id to pass to the filters 1780 // We need to cast $user_id to pass to the filters. 1811 1781 $user_id = false; 1812 1782 1813 // Multisite installs have their own install procedure 1783 // Multisite installs have their own install procedure. 1814 1784 if ( is_multisite() ) { 1815 1785 wpmu_signup_user( $user_login, $user_email, $usermeta ); 1816 1786 1817 1787 } else { 1818 // Format data 1788 // Format data. 1819 1789 $user_login = preg_replace( '/\s+/', '', sanitize_user( $user_login, true ) ); 1820 1790 $user_email = sanitize_email( $user_email ); … … 1899 1869 * @param string $user_email Email address of requesting user. 1900 1870 * @param string $usermeta Miscellaneous metadata for the user. 1901 *1902 1871 * @return bool 1903 1872 */ … … 1908 1877 1909 1878 /** 1910 * Filters the result of wpmu_signup_blog() 1879 * Filters the result of wpmu_signup_blog(). 1911 1880 * 1912 1881 * This filter provides no value and is retained for … … 1924 1893 * 1925 1894 * @param string $key Activation key. 1926 *1927 1895 * @return int|bool User ID on success, false on failure. 1928 1896 */ … … 1932 1900 $user = false; 1933 1901 1934 // Multisite installs have their own activation routine 1902 // Multisite installs have their own activation routine. 1935 1903 if ( is_multisite() ) { 1936 1904 $user = wpmu_activate_signup( $key ); 1937 1905 1938 // If there were errors, add a message and redirect 1906 // If there were errors, add a message and redirect. 1939 1907 if ( ! empty( $user->errors ) ) { 1940 1908 return $user; … … 1962 1930 } 1963 1931 1964 // password is hashed again in wp_insert_user1932 // Password is hashed again in wp_insert_user. 1965 1933 $password = wp_generate_password( 12, false ); 1966 1934 1967 1935 $user_id = username_exists( $signup->user_login ); 1968 1936 1969 // Create the user 1937 // Create the user. 1970 1938 if ( ! $user_id ) { 1971 1939 $user_id = wp_create_user( $signup->user_login, $password, $signup->user_email ); … … 1974 1942 // created locally for backward compatibility. Process it. 1975 1943 } elseif ( $key == wp_hash( $user_id ) ) { 1976 // Change the user's status so they become active 1944 // Change the user's status so they become active. 1977 1945 if ( ! $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->users} SET user_status = 0 WHERE ID = %d", $user_id ) ) ) { 1978 1946 return new WP_Error( 'invalid_key', __( 'Invalid activation key.', 'buddypress' ) ); … … 1994 1962 } 1995 1963 1996 // Fetch the signup so we have the data later on 1964 // Fetch the signup so we have the data later on. 1997 1965 $signups = BP_Signup::get( array( 1998 1966 'activation_key' => $key, … … 2001 1969 $signup = isset( $signups['signups'] ) && ! empty( $signups['signups'][0] ) ? $signups['signups'][0] : false; 2002 1970 2003 // Activate the signup 1971 // Activate the signup. 2004 1972 BP_Signup::validate( $key ); 2005 1973 … … 2008 1976 } 2009 1977 2010 // Set up data to pass to the legacy filter 1978 // Set up data to pass to the legacy filter. 2011 1979 $user = array( 2012 1980 'user_id' => $user_id, … … 2015 1983 ); 2016 1984 2017 // Notify the site admin of a new user registration 1985 // Notify the site admin of a new user registration. 2018 1986 wp_new_user_notification( $user_id ); 2019 1987 … … 2034 2002 } 2035 2003 2036 // Set any profile data 2004 // Set any profile data. 2037 2005 if ( bp_is_active( 'xprofile' ) ) { 2038 2006 if ( ! empty( $user['meta']['profile_field_ids'] ) ) { … … 2046 2014 } 2047 2015 2048 // Save the visibility level 2016 // Save the visibility level. 2049 2017 $visibility_level = ! empty( $user['meta']['field_' . $field_id . '_visibility'] ) ? $user['meta']['field_' . $field_id . '_visibility'] : 'public'; 2050 2018 xprofile_set_field_visibility_level( $field_id, $user_id, $visibility_level ); … … 2053 2021 } 2054 2022 2055 // Update the display_name 2023 // Update the display_name. 2056 2024 wp_update_user( array( 2057 2025 'ID' => $user_id, … … 2059 2027 ) ); 2060 2028 2061 // Set the password on multisite installs 2029 // Set the password on multisite installs. 2062 2030 if ( ! empty( $user['meta']['password'] ) ) { 2063 2031 $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->users} SET user_pass = %s WHERE ID = %d", $user['meta']['password'], $user_id ) ); … … 2102 2070 2103 2071 // Fetch activation keys separately, to avoid the all_with_meta 2104 // overhead 2072 // overhead. 2105 2073 $status_2_ids_sql = implode( ',', $status_2_ids ); 2106 2074 $ak_data = $wpdb->get_results( "SELECT user_id, meta_value FROM {$wpdb->usermeta} WHERE meta_key = 'activation_key' AND user_id IN ({$status_2_ids_sql})" ); 2107 2075 2108 // Rekey 2076 // Rekey. 2109 2077 $activation_keys = array(); 2110 2078 foreach ( $ak_data as $ak_datum ) { … … 2114 2082 unset( $status_2_ids_sql, $status_2_ids, $ak_data ); 2115 2083 2116 // Merge 2084 // Merge. 2117 2085 foreach ( $signups as &$signup ) { 2118 2086 if ( isset( $activation_keys[ $signup->ID ] ) ) { … … 2121 2089 } 2122 2090 2123 // Reset the signup var as we're using it to process the migration 2091 // Reset the signup var as we're using it to process the migration. 2124 2092 unset( $signup ); 2125 2093 … … 2131 2099 $meta = array(); 2132 2100 2133 // Rebuild the activation key, if missing 2101 // Rebuild the activation key, if missing. 2134 2102 if ( empty( $signup->activation_key ) ) { 2135 2103 $signup->activation_key = wp_hash( $signup->ID ); … … 2153 2121 ) ); 2154 2122 2155 // Deleting these options will remove signups from users count 2123 // Deleting these options will remove signups from users count. 2156 2124 delete_user_option( $signup->ID, 'capabilities' ); 2157 2125 delete_user_option( $signup->ID, 'user_level' ); … … 2166 2134 * 2167 2135 * @param int $user_id ID of the user. 2168 *2169 2136 * @return bool 2170 2137 */ … … 2176 2143 } 2177 2144 2178 // Add the user's fullname to Xprofile 2145 // Add the user's fullname to Xprofile. 2179 2146 if ( bp_is_active( 'xprofile' ) ) { 2180 2147 $firstname = bp_get_user_meta( $user_id, 'first_name', true ); … … 2296 2263 * @param string $username The inputted, attempted username. 2297 2264 * @param string $password The inputted, attempted password. 2298 *2299 2265 * @return WP_User|WP_Error 2300 2266 */ 2301 2267 function bp_core_signup_disable_inactive( $user = null, $username = '', $password ='' ) { 2302 // login form not used2268 // Login form not used. 2303 2269 if ( empty( $username ) && empty( $password ) ) { 2304 2270 return $user; … … 2312 2278 2313 2279 // If no WP_User is found corresponding to the username, this 2314 // is a potential signup 2280 // is a potential signup. 2315 2281 } elseif ( is_wp_error( $user ) && 'invalid_username' == $user->get_error_code() ) { 2316 2282 $user_login = $username; 2317 2283 2318 // This is an activated user, so bail 2284 // This is an activated user, so bail. 2319 2285 } else { 2320 2286 return $user; 2321 2287 } 2322 2288 2323 // Look for the unactivated signup corresponding to the login name 2289 // Look for the unactivated signup corresponding to the login name. 2324 2290 $signup = BP_Signup::get( array( 'user_login' => sanitize_user( $user_login ) ) ); 2325 2291 … … 2330 2296 2331 2297 // Unactivated user account found! 2332 // Set up the feedback message 2298 // Set up the feedback message. 2333 2299 $signup_id = $signup['signups'][0]->signup_id; 2334 2300 … … 2363 2329 } 2364 2330 2365 // verify nonce2331 // Verify nonce. 2366 2332 if ( ! wp_verify_nonce( $_GET['_wpnonce'], 'bp-resend-activation' ) ) { 2367 2333 die( 'Security check' ); … … 2370 2336 $signup_id = (int) $_GET['id']; 2371 2337 2372 // resend the activation email2373 // also updates the 'last sent' and '# of emails sent' values 2338 // Resend the activation email. 2339 // also updates the 'last sent' and '# of emails sent' values. 2374 2340 $resend = BP_Signup::resend( array( $signup_id ) ); 2375 2341 2376 // add feedback message2342 // Add feedback message. 2377 2343 if ( ! empty( $resend['errors'] ) ) { 2378 2344 $error = __( '<strong>ERROR</strong>: Your account has already been activated.', 'buddypress' ); … … 2388 2354 function bp_core_wpsignup_redirect() { 2389 2355 2390 // Bail in admin or if custom signup page is broken 2356 // Bail in admin or if custom signup page is broken. 2391 2357 if ( is_admin() || ! bp_has_custom_signup_page() ) { 2392 2358 return; … … 2395 2361 $action = !empty( $_GET['action'] ) ? $_GET['action'] : ''; 2396 2362 2397 // Not at the WP core signup page and action is not register 2363 // Not at the WP core signup page and action is not register. 2398 2364 if ( ! empty( $_SERVER['SCRIPT_NAME'] ) && false === strpos( $_SERVER['SCRIPT_NAME'], 'wp-signup.php' ) && ( 'register' != $action ) ) { 2399 2365 return; … … 2426 2392 */ 2427 2393 function bp_stop_live_spammer() { 2428 // if we're on the login page, stop now to prevent redirect loop2394 // If we're on the login page, stop now to prevent redirect loop. 2429 2395 $is_login = false; 2430 2396 if ( isset( $GLOBALS['pagenow'] ) && ( false !== strpos( $GLOBALS['pagenow'], 'wp-login.php' ) ) ) { … … 2438 2404 } 2439 2405 2440 // user isn't logged in, so stop!2406 // User isn't logged in, so stop! 2441 2407 if ( ! is_user_logged_in() ) { 2442 2408 return; 2443 2409 } 2444 2410 2445 // if spammer, redirect to wp-login.php and reauthorize2411 // If spammer, redirect to wp-login.php and reauthorize. 2446 2412 if ( bp_is_user_spammer( bp_loggedin_user_id() ) ) { 2447 // setup login args2413 // Setup login args. 2448 2414 $args = array( 2449 // custom action used to throw an error message2415 // Custom action used to throw an error message. 2450 2416 'action' => 'bp-spam', 2451 2417 2452 // reauthorize user to login2418 // Reauthorize user to login. 2453 2419 'reauth' => 1 2454 2420 ); … … 2463 2429 $login_url = apply_filters( 'bp_live_spammer_redirect', add_query_arg( $args, wp_login_url() ) ); 2464 2430 2465 // redirect user to login page2431 // Redirect user to login page. 2466 2432 wp_redirect( $login_url ); 2467 2433 die(); … … 2480 2446 $error = __( '<strong>ERROR</strong>: Your account has been marked as a spammer.', 'buddypress' ); 2481 2447 2482 // shake shake shake!2448 // Shake shake shake! 2483 2449 add_action( 'login_head', 'wp_shake_js', 12 ); 2484 2450 } … … 2587 2553 * 2588 2554 * @param string $member_type The name of the member type. 2589 *2590 2555 * @return object A member type object. 2591 2556 */ … … 2614 2579 * element from the array needs to match; 'and' means all elements 2615 2580 * must match. Accepts 'or' or 'and'. Default 'and'. 2616 *2617 2581 * @return array A list of member type names or objects. 2618 2582 */ … … 2652 2616 * @param bool $append Optional. True to append this to existing types for user, 2653 2617 * false to replace. Default: false. 2654 * @return See {@see bp_set_object_terms()}.2618 * @return array $retval See {@see bp_set_object_terms()}. 2655 2619 */ 2656 2620 function bp_set_member_type( $user_id, $member_type, $append = false ) { … … 2688 2652 * @param int $user_id ID of the user. 2689 2653 * @param string $member_type Member Type. 2690 *2691 2654 * @return bool|WP_Error 2692 2655 */ … … 2722 2685 * @since 2.2.0 2723 2686 * 2724 * @param int $user_id ID of the user. 2725 * @param bool $single Optional. Whether to return a single type string. If multiple types are found 2726 * for the user, the oldest one will be returned. Default: true. 2727 * 2687 * @param int $user_id ID of the user. 2688 * @param bool $single Optional. Whether to return a single type string. If multiple types are found 2689 * for the user, the oldest one will be returned. Default: true. 2728 2690 * @return string|array|bool On success, returns a single member type (if $single is true) or an array of member 2729 2691 * types (if $single is false). Returns false on failure. … … 2769 2731 * @param int $user_id $user_id ID of the user. 2770 2732 * @param string $member_type Member Type. 2771 *2772 2733 * @return bool Whether the user has the given member type. 2773 2734 */ … … 2794 2755 * 2795 2756 * @param int $user_id ID of the user. 2796 * 2797 * @return See {@see bp_set_member_type()}. 2757 * @return array $value See {@see bp_set_member_type()}. 2798 2758 */ 2799 2759 function bp_remove_member_type_on_user_delete( $user_id ) { -
trunk/src/bp-members/bp-members-loader.php
r10248 r10322 10 10 defined( 'ABSPATH' ) || exit; 11 11 12 /** 13 * Defines the BuddyPress Members Component. 14 */ 12 15 class BP_Members_Component extends BP_Component { 13 16 … … 17 20 * @see bp_register_member_type() 18 21 * 19 * @since 20 * @var 22 * @since 2.2.0 23 * @var array 21 24 */ 22 25 public $types = array(); … … 48 51 public function includes( $includes = array() ) { 49 52 50 // Always include these files 53 // Always include these files. 51 54 $includes = array( 52 55 'actions', … … 65 68 } 66 69 67 // Include these only if in admin 70 // Include these only if in admin. 68 71 if ( is_admin() ) { 69 72 $includes[] = 'admin'; … … 88 91 $bp = buddypress(); 89 92 90 /** Component Globals *************************************************/ 91 92 // Define a slug, as a fallback for backpat 93 /** Component Globals ************************************************ 94 */ 95 96 // Define a slug, as a fallback for backpat. 93 97 if ( !defined( 'BP_MEMBERS_SLUG' ) ) { 94 98 define( 'BP_MEMBERS_SLUG', $this->id ); 95 99 } 96 100 97 // Override any passed args 101 // Override any passed args. 98 102 $args = array( 99 103 'slug' => BP_MEMBERS_SLUG, … … 110 114 parent::setup_globals( $args ); 111 115 112 /** Logged in user ****************************************************/ 116 /** Logged in user *************************************************** 117 */ 113 118 114 119 // The core userdata of the user who is currently logged in. 115 120 $bp->loggedin_user->userdata = bp_core_get_core_userdata( bp_loggedin_user_id() ); 116 121 117 // Fetch the full name for the logged in user 122 // Fetch the full name for the logged in user. 118 123 $bp->loggedin_user->fullname = isset( $bp->loggedin_user->userdata->display_name ) ? $bp->loggedin_user->userdata->display_name : ''; 119 124 120 // Hits the DB on single WP installs so get this separately 125 // Hits the DB on single WP installs so get this separately. 121 126 $bp->loggedin_user->is_super_admin = $bp->loggedin_user->is_site_admin = is_super_admin( bp_loggedin_user_id() ); 122 127 123 // The domain for the user currently logged in. eg: http://example.com/members/andy 128 // The domain for the user currently logged in. eg: http://example.com/members/andy. 124 129 $bp->loggedin_user->domain = bp_core_get_user_domain( bp_loggedin_user_id() ); 125 130 126 /** Displayed user ****************************************************/ 127 128 // The core userdata of the user who is currently being displayed 131 /** Displayed user *************************************************** 132 */ 133 134 // The core userdata of the user who is currently being displayed. 129 135 $bp->displayed_user->userdata = bp_core_get_core_userdata( bp_displayed_user_id() ); 130 136 131 // Fetch the full name displayed user 137 // Fetch the full name displayed user. 132 138 $bp->displayed_user->fullname = isset( $bp->displayed_user->userdata->display_name ) ? $bp->displayed_user->userdata->display_name : ''; 133 139 134 // The domain for the user currently being displayed 140 // The domain for the user currently being displayed. 135 141 $bp->displayed_user->domain = bp_core_get_user_domain( bp_displayed_user_id() ); 136 142 137 /** Signup ************************************************************/ 143 /** Signup *********************************************************** 144 */ 138 145 139 146 $bp->signup = new stdClass; 140 147 141 /** Profiles Fallback *************************************************/ 148 /** Profiles Fallback ************************************************ 149 */ 142 150 143 151 if ( ! bp_is_active( 'xprofile' ) ) { … … 156 164 $bp = buddypress(); 157 165 158 /** Default Profile Component *****************************************/ 166 /** Default Profile Component **************************************** 167 */ 159 168 160 169 if ( defined( 'BP_DEFAULT_COMPONENT' ) && BP_DEFAULT_COMPONENT ) { … … 168 177 } 169 178 170 /** Canonical Component Stack *****************************************/ 179 /** Canonical Component Stack **************************************** 180 */ 171 181 172 182 if ( bp_displayed_user_id() ) { … … 185 195 } 186 196 187 // Looking at the single member root/home, so assume the default 197 // Looking at the single member root/home, so assume the default. 188 198 if ( ! bp_current_component() ) { 189 199 $bp->current_component = $bp->default_component; 190 200 191 // The canonical URL will not contain the default component 201 // The canonical URL will not contain the default component. 192 202 } elseif ( bp_is_current_component( $bp->default_component ) && ! bp_current_action() ) { 193 203 unset( $bp->canonical_stack['component'] ); 194 204 } 195 205 196 // if we're on a spammer's profile page, only users with the 'bp_moderate' cap197 // can view subpages on the spammer's profile 206 // If we're on a spammer's profile page, only users with the 'bp_moderate' cap 207 // can view subpages on the spammer's profile. 198 208 // 199 209 // users without the cap trying to access a spammer's subnav page will get … … 220 230 public function setup_nav( $main_nav = array(), $sub_nav = array() ) { 221 231 222 // Bail if XProfile component is active 232 // Bail if XProfile component is active. 223 233 if ( bp_is_active( 'xprofile' ) ) { 224 234 return; 225 235 } 226 236 227 // Don't set up navigation if there's no member 237 // Don't set up navigation if there's no member. 228 238 if ( ! is_user_logged_in() && ! bp_is_user() ) { 229 239 return; 230 240 } 231 241 232 // Determine user to use 242 // Determine user to use. 233 243 if ( bp_displayed_user_domain() ) { 234 244 $user_domain = bp_displayed_user_domain(); … … 242 252 $profile_link = trailingslashit( $user_domain . $slug ); 243 253 244 // Setup the main navigation 254 // Setup the main navigation. 245 255 $main_nav = array( 246 256 'name' => _x( 'Profile', 'Member profile main navigation', 'buddypress' ), … … 252 262 ); 253 263 254 // Setup the subnav items for the member profile 264 // Setup the subnav items for the member profile. 255 265 $sub_nav[] = array( 256 266 'name' => _x( 'View', 'Member profile view', 'buddypress' ), … … 292 302 public function setup_cache_groups() { 293 303 294 // Global groups 304 // Global groups. 295 305 wp_cache_add_global_groups( array( 296 306 'bp_last_activity', -
trunk/src/bp-members/bp-members-screens.php
r10276 r10322 69 69 return; 70 70 71 // Not a directory 71 // Not a directory. 72 72 bp_update_is_directory( false, 'register' ); 73 73 74 // If the user is logged in, redirect away from here 74 // If the user is logged in, redirect away from here. 75 75 if ( is_user_logged_in() ) { 76 76 … … 96 96 $bp->signup->step = 'registration-disabled'; 97 97 98 // If the signup page is submitted, validate and save 98 // If the signup page is submitted, validate and save. 99 99 } elseif ( isset( $_POST['signup_submit'] ) && bp_verify_nonce_request( 'bp_new_signup' ) ) { 100 100 … … 106 106 do_action( 'bp_signup_pre_validate' ); 107 107 108 // Check the base account details for problems 108 // Check the base account details for problems. 109 109 $account_details = bp_core_validate_user_signup( $_POST['signup_username'], $_POST['signup_email'] ); 110 110 111 // If there are errors with account details, set them for display 111 // If there are errors with account details, set them for display. 112 112 if ( !empty( $account_details['errors']->errors['user_name'] ) ) 113 113 $bp->signup->errors['signup_username'] = $account_details['errors']->errors['user_name'][0]; … … 116 116 $bp->signup->errors['signup_email'] = $account_details['errors']->errors['user_email'][0]; 117 117 118 // Check that both password fields are filled in 118 // Check that both password fields are filled in. 119 119 if ( empty( $_POST['signup_password'] ) || empty( $_POST['signup_password_confirm'] ) ) 120 120 $bp->signup->errors['signup_password'] = __( 'Please make sure you enter your password twice', 'buddypress' ); 121 121 122 // Check that the passwords match 122 // Check that the passwords match. 123 123 if ( ( !empty( $_POST['signup_password'] ) && !empty( $_POST['signup_password_confirm'] ) ) && $_POST['signup_password'] != $_POST['signup_password_confirm'] ) 124 124 $bp->signup->errors['signup_password'] = __( 'The passwords you entered do not match.', 'buddypress' ); … … 127 127 $bp->signup->email = $_POST['signup_email']; 128 128 129 // Now we've checked account details, we can check profile information 129 // Now we've checked account details, we can check profile information. 130 130 if ( bp_is_active( 'xprofile' ) ) { 131 131 132 // Make sure hidden field is passed and populated 132 // Make sure hidden field is passed and populated. 133 133 if ( isset( $_POST['signup_profile_field_ids'] ) && !empty( $_POST['signup_profile_field_ids'] ) ) { 134 134 135 // Let's compact any profile field info into an array 135 // Let's compact any profile field info into an array. 136 136 $profile_field_ids = explode( ',', $_POST['signup_profile_field_ids'] ); 137 137 138 // Loop through the posted fields formatting any datebox values then validate the field 138 // Loop through the posted fields formatting any datebox values then validate the field. 139 139 foreach ( (array) $profile_field_ids as $field_id ) { 140 140 if ( !isset( $_POST['field_' . $field_id] ) ) { … … 143 143 } 144 144 145 // Create errors for required fields without values 145 // Create errors for required fields without values. 146 146 if ( xprofile_check_is_required_field( $field_id ) && empty( $_POST[ 'field_' . $field_id ] ) && ! bp_current_user_can( 'bp_moderate' ) ) 147 147 $bp->signup->errors['field_' . $field_id] = __( 'This is a required field', 'buddypress' ); 148 148 } 149 149 150 // This situation doesn't naturally occur so bounce to website root 150 // This situation doesn't naturally occur so bounce to website root. 151 151 } else { 152 152 bp_core_redirect( bp_get_root_domain() ); … … 154 154 } 155 155 156 // Finally, let's check the blog details, if the user wants a blog and blog creation is enabled 156 // Finally, let's check the blog details, if the user wants a blog and blog creation is enabled. 157 157 if ( isset( $_POST['signup_with_blog'] ) ) { 158 158 $active_signup = bp_core_get_root_option( 'registration' ); … … 161 161 $blog_details = bp_core_validate_blog_signup( $_POST['signup_blog_url'], $_POST['signup_blog_title'] ); 162 162 163 // If there are errors with blog details, set them for display 163 // If there are errors with blog details, set them for display. 164 164 if ( !empty( $blog_details['errors']->errors['blogname'] ) ) 165 165 $bp->signup->errors['signup_blog_url'] = $blog_details['errors']->errors['blogname'][0]; … … 180 180 if ( !empty( $bp->signup->errors ) ) { 181 181 foreach ( (array) $bp->signup->errors as $fieldname => $error_message ) { 182 // addslashes() and stripslashes() to avoid create_function() 183 // syntax errors when the $error_message contains quotes 182 /* 183 * The addslashes() and stripslashes() used to avoid create_function() 184 * syntax errors when the $error_message contains quotes. 185 */ 184 186 185 187 /** … … 200 202 if ( 'none' != $active_signup ) { 201 203 202 // Make sure the extended profiles module is enabled 204 // Make sure the extended profiles module is enabled. 203 205 if ( bp_is_active( 'xprofile' ) ) { 204 // Let's compact any profile field info into usermeta 206 // Let's compact any profile field info into usermeta. 205 207 $profile_field_ids = explode( ',', $_POST['signup_profile_field_ids'] ); 206 208 207 // Loop through the posted fields formatting any datebox values then add to usermeta - @todo This logic should be shared with the same in xprofile_screen_edit_profile() 209 // Loop through the posted fields formatting any datebox values then add to usermeta - @todo This logic should be shared with the same in xprofile_screen_edit_profile(). 208 210 foreach ( (array) $profile_field_ids as $field_id ) { 209 211 if ( ! isset( $_POST['field_' . $field_id] ) ) { 210 212 211 213 if ( ! empty( $_POST['field_' . $field_id . '_day'] ) && ! empty( $_POST['field_' . $field_id . '_month'] ) && ! empty( $_POST['field_' . $field_id . '_year'] ) ) { 212 // Concatenate the values 214 // Concatenate the values. 213 215 $date_value = $_POST['field_' . $field_id . '_day'] . ' ' . $_POST['field_' . $field_id . '_month'] . ' ' . $_POST['field_' . $field_id . '_year']; 214 216 215 // Turn the concatenated value into a timestamp 217 // Turn the concatenated value into a timestamp. 216 218 $_POST['field_' . $field_id] = date( 'Y-m-d H:i:s', strtotime( $date_value ) ); 217 219 } … … 225 227 } 226 228 227 // Store the profile field ID's in usermeta 229 // Store the profile field ID's in usermeta. 228 230 $usermeta['profile_field_ids'] = $_POST['signup_profile_field_ids']; 229 231 } 230 232 231 // Hash and store the password 233 // Hash and store the password. 232 234 $usermeta['password'] = wp_hash_password( $_POST['signup_password'] ); 233 235 234 // If the user decided to create a blog, save those details to usermeta 236 // If the user decided to create a blog, save those details to usermeta. 235 237 if ( 'blog' == $active_signup || 'all' == $active_signup ) 236 238 $usermeta['public'] = ( isset( $_POST['signup_blog_privacy'] ) && 'public' == $_POST['signup_blog_privacy'] ) ? true : false; … … 245 247 $usermeta = apply_filters( 'bp_signup_usermeta', $usermeta ); 246 248 247 // Finally, sign up the user and/or blog 249 // Finally, sign up the user and/or blog. 248 250 if ( isset( $_POST['signup_with_blog'] ) && is_multisite() ) 249 251 $wp_user_id = bp_core_signup_blog( $blog_details['domain'], $blog_details['path'], $blog_details['blog_title'], $_POST['signup_username'], $_POST['signup_email'], $usermeta ); … … 294 296 function bp_core_screen_activation() { 295 297 296 // Bail if not viewing the activation page 298 // Bail if not viewing the activation page. 297 299 if ( ! bp_is_current_component( 'activate' ) ) { 298 300 return false; 299 301 } 300 302 301 // If the user is already logged in, redirect away from here 303 // If the user is already logged in, redirect away from here. 302 304 if ( is_user_logged_in() ) { 303 305 … … 308 310 : bp_get_root_domain(); 309 311 310 // Trailing slash it, as we expect these URL's to be 312 // Trailing slash it, as we expect these URL's to be. 311 313 $redirect_to = trailingslashit( $redirect_to ); 312 314 … … 320 322 $redirect_to = apply_filters( 'bp_loggedin_activate_page_redirect_to', $redirect_to ); 321 323 322 // Redirect away from the activation page 324 // Redirect away from the activation page. 323 325 bp_core_redirect( $redirect_to ); 324 326 } 325 327 326 // grab the key (the old way)328 // Grab the key (the old way). 327 329 $key = isset( $_GET['key'] ) ? $_GET['key'] : ''; 328 330 329 // grab the key (the new way)331 // Grab the key (the new way). 330 332 if ( empty( $key ) ) { 331 333 $key = bp_current_action(); 332 334 } 333 335 334 // Get BuddyPress 336 // Get BuddyPress. 335 337 $bp = buddypress(); 336 338 337 // we've got a key; let's attempt to activate the signup339 // We've got a key; let's attempt to activate the signup. 338 340 if ( ! empty( $key ) ) { 339 341 … … 348 350 $user = apply_filters( 'bp_core_activate_account', bp_core_activate_signup( $key ) ); 349 351 350 // If there were errors, add a message and redirect 352 // If there were errors, add a message and redirect. 351 353 if ( ! empty( $user->errors ) ) { 352 354 bp_core_add_message( $user->get_error_message(), 'error' ); … … 357 359 358 360 // Check if the signup avatar folder exists. If it does, move the folder to 359 // the BP user avatars directory 361 // the BP user avatars directory. 360 362 if ( file_exists( bp_core_avatar_upload_path() . '/avatars/signups/' . $hashed_key ) ) { 361 363 @rename( bp_core_avatar_upload_path() . '/avatars/signups/' . $hashed_key, bp_core_avatar_upload_path() . '/avatars/' . $user ); … … 405 407 public function is_members() { 406 408 407 // Bail if not looking at the members component or a user's page 409 // Bail if not looking at the members component or a user's page. 408 410 if ( ! bp_is_members_component() && ! bp_is_user() ) { 409 411 return; 410 412 } 411 413 412 // Members Directory 414 // Members Directory. 413 415 if ( ! bp_current_action() && ! bp_current_item() ) { 414 416 bp_update_is_directory( true, 'members' ); … … 425 427 add_filter( 'bp_replace_the_content', array( $this, 'directory_content' ) ); 426 428 427 // User page 429 // User page. 428 430 } elseif ( bp_is_user() ) { 429 431 … … 459 461 * 460 462 * @param array $templates The templates from bp_get_theme_compat_templates(). 461 *462 463 * @return array $templates Array of custom templates to look for. 463 464 */ 464 465 public function directory_template_hierarchy( $templates = array() ) { 465 466 466 // Set up the template hierarchy 467 // Set up the template hierarchy. 467 468 $new_templates = array(); 468 469 if ( '' !== bp_get_current_member_type() ) { … … 481 482 482 483 // Merge new templates with existing stack 483 // @see bp_get_theme_compat_templates() 484 // @see bp_get_theme_compat_templates(). 484 485 $templates = array_merge( (array) $new_templates, $templates ); 485 486 … … 527 528 * @param string $templates The templates from 528 529 * bp_get_theme_compat_templates(). 529 *530 530 * @return array $templates Array of custom templates to look for. 531 531 */ 532 532 public function single_template_hierarchy( $templates ) { 533 // Setup some variables we're going to reference in our custom templates 533 // Setup some variables we're going to reference in our custom templates. 534 534 $user_nicename = buddypress()->displayed_user->userdata->user_nicename; 535 535 … … 550 550 551 551 // Merge new templates with existing stack 552 // @see bp_get_theme_compat_templates() 552 // @see bp_get_theme_compat_templates(). 553 553 $templates = array_merge( (array) $new_templates, $templates ); 554 554 … … 612 612 public function is_registration() { 613 613 614 // Bail if not looking at the registration or activation page 614 // Bail if not looking at the registration or activation page. 615 615 if ( ! bp_is_register_page() && ! bp_is_activation_page() ) { 616 616 return; 617 617 } 618 618 619 // Not a directory 619 // Not a directory. 620 620 bp_update_is_directory( false, 'register' ); 621 621 622 // Setup actions 622 // Setup actions. 623 623 add_filter( 'bp_get_buddypress_template', array( $this, 'template_hierarchy' ) ); 624 624 add_action( 'bp_template_include_reset_dummy_post_data', array( $this, 'dummy_post' ) ); … … 637 637 * 638 638 * @param string $templates The templates from bp_get_theme_compat_templates(). 639 *640 639 * @return array $templates Array of custom templates to look for. 641 640 */ … … 658 657 659 658 // Merge new templates with existing stack 660 // @see bp_get_theme_compat_templates() 659 // @see bp_get_theme_compat_templates(). 661 660 $templates = array_merge( (array) $new_templates, $templates ); 662 661 … … 670 669 */ 671 670 public function dummy_post() { 672 // Registration page 671 // Registration page. 673 672 if ( bp_is_register_page() ) { 674 673 $title = __( 'Create an Account', 'buddypress' ); … … 678 677 } 679 678 680 // Activation page 679 // Activation page. 681 680 } else { 682 681 $title = __( 'Activate Your Account', 'buddypress' ); -
trunk/src/bp-members/bp-members-template.php
r10248 r10322 433 433 */ 434 434 do_action('member_loop_end'); 435 // Do some cleaning up after the loop 435 // Do some cleaning up after the loop. 436 436 $this->rewind_members(); 437 437 } … … 455 455 $this->member = $this->next_member(); 456 456 457 // loop has just started457 // Loop has just started. 458 458 if ( 0 == $this->current_member ) { 459 459 … … 535 535 global $members_template; 536 536 537 // Default user ID 537 // Default user ID. 538 538 $user_id = 0; 539 539 540 // User filtering 540 // User filtering. 541 541 if ( bp_is_user_friends() && ! bp_is_user_friend_requests() ) { 542 542 $user_id = bp_displayed_user_id(); … … 559 559 } 560 560 561 // type: active ( default ) | random | newest | popular | online | alphabetical561 // Type: active ( default ) | random | newest | popular | online | alphabetical. 562 562 $r = bp_parse_args( $args, array( 563 563 'type' => 'active', … … 566 566 'max' => false, 567 567 568 'page_arg' => 'upage', // See https://buddypress.trac.wordpress.org/ticket/3679 569 570 'include' => false, // Pass a user_id or a list (comma-separated or array) of user_ids to only show these users 571 'exclude' => false, // Pass a user_id or a list (comma-separated or array) of user_ids to exclude these users 572 573 'user_id' => $user_id, // Pass a user_id to only show friends of this user 568 'page_arg' => 'upage', // See https://buddypress.trac.wordpress.org/ticket/3679. 569 570 'include' => false, // Pass a user_id or a list (comma-separated or array) of user_ids to only show these users. 571 'exclude' => false, // Pass a user_id or a list (comma-separated or array) of user_ids to exclude these users. 572 573 'user_id' => $user_id, // Pass a user_id to only show friends of this user. 574 574 'member_type' => $member_type, 575 575 'member_type__in' => '', … … 577 577 'search_terms' => $search_terms_default, 578 578 579 'meta_key' => false, // Only return users with this usermeta580 'meta_value' => false, // Only return users where the usermeta value matches. Requires meta_key579 'meta_key' => false, // Only return users with this usermeta. 580 'meta_value' => false, // Only return users where the usermeta value matches. Requires meta_key. 581 581 582 582 'populate_extras' => true // Fetch usermeta? Friend count, last active etc. … … 592 592 } 593 593 594 // Set per_page to max if max is larger than per_page 594 // Set per_page to max if max is larger than per_page. 595 595 if ( !empty( $r['max'] ) && ( $r['per_page'] > $r['max'] ) ) { 596 596 $r['per_page'] = $r['max']; 597 597 } 598 598 599 // Query for members and populate $members_template global 599 // Query for members and populate $members_template global. 600 600 $members_template = new BP_Core_Members_Template( 601 601 $r['type'], … … 761 761 * @since 1.7.0 762 762 * 763 * @param array $classes Array of custom classes 763 * @param array $classes Array of custom classes. 764 764 */ 765 765 function bp_member_class( $classes = array() ) { … … 771 771 * @since 1.7.0 772 772 * 773 * @param array $classes Array of custom classes 773 * @param array $classes Array of custom classes. 774 774 * 775 775 * @return string Row class of the member … … 778 778 global $members_template; 779 779 780 // Add even/odd classes, but only if there's more than 1 member 780 // Add even/odd classes, but only if there's more than 1 member. 781 781 if ( $members_template->member_count > 1 ) { 782 782 $pos_in_loop = (int) $members_template->current_member; 783 783 $classes[] = ( $pos_in_loop % 2 ) ? 'even' : 'odd'; 784 784 785 // If we've only one member in the loop, don't bother with odd and even 785 // If we've only one member in the loop, don't bother with odd and even. 786 786 } else { 787 787 $classes[] = 'bp-single-member'; 788 788 } 789 789 790 // Maybe add 'is-online' class 790 // Maybe add 'is-online' class. 791 791 if ( ! empty( $members_template->member->last_activity ) ) { 792 792 793 // Calculate some times 793 // Calculate some times. 794 794 $current_time = strtotime( bp_core_current_time() ); 795 795 $last_activity = strtotime( $members_template->member->last_activity ); … … 802 802 } 803 803 804 // Add current user class 804 // Add current user class. 805 805 if ( bp_loggedin_user_id() === (int) $members_template->member->id ) { 806 806 $classes[] = 'is-current-user'; … … 925 925 * @since 1.2.0 926 926 * 927 * @param string $value Formatted HTML <img> element, 928 * or raw avatar URL based on $html arg. 927 * @param string $value Formatted HTML <img> element, or raw avatar URL based on $html arg. 929 928 */ 930 929 echo apply_filters( 'bp_member_avatar', bp_get_member_avatar( $args ) ); … … 972 971 * @since 1.2.0 973 972 * 974 * @param string $value Formatted HTML <img> element, 975 * or raw avatar URL based on $html arg. 973 * @param string $value Formatted HTML <img> element, or raw avatar URL based on $html arg. 976 974 */ 977 975 return apply_filters( 'bp_get_member_avatar', bp_core_fetch_avatar( array( 'item_id' => $members_template->member->id, 'type' => $type, 'alt' => $alt, 'css_id' => $id, 'class' => $class, 'width' => $width, 'height' => $height, 'email' => $members_template->member->user_email ) ) ); … … 1039 1037 global $members_template; 1040 1038 1041 // Generally, this only fires when xprofile is disabled 1039 // Generally, this only fires when xprofile is disabled. 1042 1040 if ( empty( $members_template->member->fullname ) ) { 1043 // Our order of preference for alternative fullnames 1041 // Our order of preference for alternative fullnames. 1044 1042 $name_stack = array( 1045 1043 'display_name', … … 1050 1048 foreach ( $name_stack as $source ) { 1051 1049 if ( !empty( $members_template->member->{$source} ) ) { 1052 // When a value is found, set it as fullname and be done 1053 // with it 1050 // When a value is found, set it as fullname and be done with it. 1054 1051 $members_template->member->fullname = $members_template->member->{$source}; 1055 1052 break; … … 1095 1092 global $members_template; 1096 1093 1097 // Parse the activity format 1094 // Parse the activity format. 1098 1095 $r = bp_parse_args( $args, array( 1099 1096 'active_format' => true 1100 1097 ) ); 1101 1098 1102 // Backwards compatibility for anyone forcing a 'true' active_format 1099 // Backwards compatibility for anyone forcing a 'true' active_format. 1103 1100 if ( true === $r['active_format'] ) { 1104 1101 $r['active_format'] = __( 'active %s', 'buddypress' ); 1105 1102 } 1106 1103 1107 // Member has logged in at least one time 1104 // Member has logged in at least one time. 1108 1105 if ( isset( $members_template->member->last_activity ) ) { 1109 1106 1110 // Backwards compatibility for pre 1.5 'ago' strings 1107 // Backwards compatibility for pre 1.5 'ago' strings. 1111 1108 $last_activity = ! empty( $r['active_format'] ) 1112 1109 ? bp_core_get_last_activity( $members_template->member->last_activity, $r['active_format'] ) 1113 1110 : bp_core_time_since( $members_template->member->last_activity ); 1114 1111 1115 // Member has never logged in or been active 1112 // Member has never logged in or been active. 1116 1113 } else { 1117 1114 $last_activity = __( 'Never active', 'buddypress' ); … … 1132 1129 * Output the latest update of the current member in the loop. 1133 1130 * 1134 * @param array|string $args 1131 * @param array|string $args Array of arguments for latest update. 1135 1132 */ 1136 1133 function bp_member_latest_update( $args = '' ) { … … 1224 1221 } 1225 1222 1226 // Declare local variables 1223 // Declare local variables. 1227 1224 $data = false; 1228 1225 1229 // Guess at default $user_id 1226 // Guess at default $user_id. 1230 1227 $default_user_id = 0; 1231 1228 if ( ! empty( $members_template->member->id ) ) { … … 1242 1239 $r = wp_parse_args( $args, $defaults ); 1243 1240 1244 // If we're in a members loop, get the data from the global 1241 // If we're in a members loop, get the data from the global. 1245 1242 if ( ! empty( $members_template->member->profile_data ) ) { 1246 1243 $profile_data = $members_template->member->profile_data; 1247 1244 } 1248 1245 1249 // Otherwise query for the data 1246 // Otherwise query for the data. 1250 1247 if ( empty( $profile_data ) && method_exists( 'BP_XProfile_ProfileData', 'get_all_for_user' ) ) { 1251 1248 $profile_data = BP_XProfile_ProfileData::get_all_for_user( $r['user_id'] ); … … 1253 1250 1254 1251 // If we're in the members loop, but the profile data has not 1255 // been loaded into the global, cache it there for later use 1252 // been loaded into the global, cache it there for later use. 1256 1253 if ( ! empty( $members_template->member ) && empty( $members_template->member->profile_data ) ) { 1257 1254 $members_template->member->profile_data = $profile_data; 1258 1255 } 1259 1256 1260 // Get the data for the specific field requested 1257 // Get the data for the specific field requested. 1261 1258 if ( ! empty( $profile_data ) && ! empty( $profile_data[ $r['field'] ]['field_type'] ) && ! empty( $profile_data[ $r['field'] ]['field_data'] ) ) { 1262 1259 $data = xprofile_format_profile_field( $profile_data[ $r['field'] ]['field_type'], $profile_data[ $r['field'] ]['field_data'] ); … … 1397 1394 $bp = buddypress(); 1398 1395 1399 // Loop through each navigation item 1396 // Loop through each navigation item. 1400 1397 foreach( (array) $bp->bp_nav as $nav_item ) { 1401 1398 … … 1423 1420 } 1424 1421 1425 // echo out the final list item1422 // Echo out the final list item. 1426 1423 echo apply_filters_ref_array( 'bp_get_loggedin_user_nav_' . $nav_item['css_id'], array( '<li id="li-nav-' . $nav_item['css_id'] . '" ' . $selected . '><a id="my-' . $nav_item['css_id'] . '" href="' . $nav_item['link'] . '">' . $nav_item['name'] . '</a></li>', &$nav_item ) ); 1427 1424 } 1428 1425 1429 // Always add a log out list item to the end of the navigation 1426 // Always add a log out list item to the end of the navigation. 1430 1427 $logout_link = '<li><a id="wp-logout" href="' . wp_logout_url( bp_get_root_domain() ) . '">' . __( 'Log Out', 'buddypress' ) . '</a></li>'; 1431 1428 … … 1490 1487 * @see bp_get_loggedin_user_avatar() for a description of params. 1491 1488 * 1492 * @param array|string $args 1489 * @param array|string $args Array of arguments for logged in user avatar. 1493 1490 */ 1494 1491 function bp_loggedin_user_avatar( $args = '' ) { … … 1539 1536 * @see bp_get_displayed_user_avatar() for a description of params. 1540 1537 * 1541 * @param array|string $args 1538 * @param array|string $args Array of arguments for displayed user avatar. 1542 1539 */ 1543 1540 function bp_displayed_user_avatar( $args = '' ) { … … 1597 1594 $bp = buddypress(); 1598 1595 1599 // If displayed user exists, return email address 1596 // If displayed user exists, return email address. 1600 1597 if ( isset( $bp->displayed_user->userdata->user_email ) ) 1601 1598 $retval = $bp->displayed_user->userdata->user_email; … … 1635 1632 * 1636 1633 * @param int $user_id ID of the user. Default: displayed user ID. 1637 *1638 1634 * @return string 1639 1635 */ … … 1673 1669 function bp_get_user_firstname( $name = false ) { 1674 1670 1675 // Try to get displayed user 1671 // Try to get displayed user. 1676 1672 if ( empty( $name ) ) 1677 1673 $name = bp_get_displayed_user_fullname(); 1678 1674 1679 // Fall back on logged in user 1675 // Fall back on logged in user. 1680 1676 if ( empty( $name ) ) 1681 1677 $name = bp_get_loggedin_user_fullname(); … … 1933 1929 * @uses bp_get_signup_slug() To make sure there is a slug assigned to the page. 1934 1930 * @uses bp_locate_template() To make sure a template exists to provide output. 1931 * 1935 1932 * @return bool True if page and template exist, false if not. 1936 1933 */ … … 2148 2145 global $current_site; 2149 2146 2150 // In case plugins are still using this filter 2147 // In case plugins are still using this filter. 2151 2148 $subdomain_base = apply_filters( 'bp_blogs_subdomain_base', preg_replace( '|^www\.|', '', $current_site->domain ) . $current_site->path ); 2152 2149 … … 2232 2229 $bp = buddypress(); 2233 2230 2234 // Check if signup_avatar_dir is passed 2231 // Check if signup_avatar_dir is passed. 2235 2232 if ( !empty( $_POST['signup_avatar_dir'] ) ) 2236 2233 $signup_avatar_dir = $_POST['signup_avatar_dir']; 2237 2234 2238 // If not, check if global is set 2235 // If not, check if global is set. 2239 2236 elseif ( !empty( $bp->signup->avatar_dir ) ) 2240 2237 $signup_avatar_dir = $bp->signup->avatar_dir; 2241 2238 2242 // If not, set false 2239 // If not, set false. 2243 2240 else 2244 2241 $signup_avatar_dir = false; … … 2305 2302 extract( $r, EXTR_SKIP ); 2306 2303 2307 // Avatar DIR is found 2304 // Avatar DIR is found. 2308 2305 if ( $signup_avatar_dir = bp_get_signup_avatar_dir_value() ) { 2309 2306 $gravatar_img = bp_core_fetch_avatar( array( … … 2318 2315 ) ); 2319 2316 2320 // No avatar DIR was found 2317 // No avatar DIR was found. 2321 2318 } else { 2322 2319 2323 // Set default gravatar type 2320 // Set default gravatar type. 2324 2321 if ( empty( $bp->grav_default->user ) ) 2325 2322 $default_grav = 'wavatar'; … … 2435 2432 function bp_get_members_component_link( $component, $action = '', $query_args = '', $nonce = false ) { 2436 2433 2437 // Must be displayed user 2434 // Must be displayed user. 2438 2435 if ( !bp_displayed_user_id() ) 2439 2436 return; … … 2441 2438 $bp = buddypress(); 2442 2439 2443 // Append $action to $url if there is no $type 2440 // Append $action to $url if there is no $type. 2444 2441 if ( !empty( $action ) ) 2445 2442 $url = bp_displayed_user_domain() . $bp->{$component}->slug . '/' . $action; … … 2447 2444 $url = bp_displayed_user_domain() . $bp->{$component}->slug; 2448 2445 2449 // Add a slash at the end of our user url 2446 // Add a slash at the end of our user url. 2450 2447 $url = trailingslashit( $url ); 2451 2448 2452 // Add possible query arg 2449 // Add possible query arg. 2453 2450 if ( !empty( $query_args ) && is_array( $query_args ) ) 2454 2451 $url = add_query_arg( $query_args, $url ); … … 2460 2457 $url = wp_nonce_url( $url, $nonce ); 2461 2458 2462 // Return the url, if there is one 2459 // Return the url, if there is one. 2463 2460 if ( !empty( $url ) ) 2464 2461 return $url; -
trunk/src/bp-members/bp-members-widgets.php
r10276 r10322 35 35 public function __construct() { 36 36 37 // Setup widget name & description 37 // Setup widget name & description. 38 38 $name = _x( '(BuddyPress) Members', 'widget name', 'buddypress' ); 39 39 $description = __( 'A dynamic list of recently active, popular, and newest members', 'buddypress' ); 40 40 41 // Call WP_Widget constructor 41 // Call WP_Widget constructor. 42 42 parent::__construct( false, $name, array( 43 43 'description' => $description, … … 45 45 ) ); 46 46 47 // Maybe enqueue JS for widget 47 // Maybe enqueue JS for widget. 48 48 if ( is_active_widget( false, false, $this->id_base ) && ! is_admin() && ! is_network_admin() ) { 49 49 wp_enqueue_script( 'bp-widget-members' ); … … 61 61 public function widget( $args, $instance ) { 62 62 63 // Get widget settings 63 // Get widget settings. 64 64 $settings = $this->parse_settings( $instance ); 65 65 … … 86 86 $separator = apply_filters( 'bp_members_widget_separator', '|' ); 87 87 88 // Output before widget HTMl, title (and maybe content before & after it) 88 // Output before widget HTMl, title (and maybe content before & after it). 89 89 echo $args['before_widget'] 90 90 . $args['before_title'] … … 92 92 . $args['after_title']; 93 93 94 // Setup args for querying members 94 // Setup args for querying members. 95 95 $members_args = array( 96 96 'user_id' => 0, … … 165 165 * @param array $new_instance The new instance options. 166 166 * @param array $old_instance The old instance options. 167 * 168 * @return array $instance The parsed options to be saved. 167 * @return array $instance The parsed options to be saved. 169 168 */ 170 169 public function update( $new_instance, $old_instance ) { … … 184 183 * @param array $instance Widget instance settings. 185 184 * 186 * @return string185 * @return void 187 186 */ 188 187 public function form( $instance ) { 189 188 190 // Get widget settings 189 // Get widget settings. 191 190 $settings = $this->parse_settings( $instance ); 192 191 $title = strip_tags( $settings['title'] ); … … 233 232 * @since 2.3.0 234 233 * 234 * @uses bp_parse_args() To merge widget settings into defaults. 235 * 235 236 * @param array $instance Widget instance settings. 236 *237 * @uses bp_parse_args() To merge widget settings into defaults.238 *239 237 * @return array 240 238 */ … … 278 276 public function widget( $args, $instance ) { 279 277 280 // Get widget settings 278 // Get widget settings. 281 279 $settings = $this->parse_settings( $instance ); 282 280 … … 298 296 . $args['after_title']; 299 297 300 // Setup args for querying members 298 // Setup args for querying members. 301 299 $members_args = array( 302 300 'user_id' => 0, … … 338 336 * @param array $new_instance The new instance options. 339 337 * @param array $old_instance The old instance options. 340 * 341 * @return array $instance The parsed options to be saved. 338 * @return array $instance The parsed options to be saved. 342 339 */ 343 340 public function update( $new_instance, $old_instance ) { … … 353 350 * 354 351 * @param array $instance Widget instance settings. 355 * 356 * @return string 352 * @return void 357 353 */ 358 354 public function form( $instance ) { 359 355 360 // Get widget settings 356 // Get widget settings. 361 357 $settings = $this->parse_settings( $instance ); 362 358 $title = strip_tags( $settings['title'] ); … … 385 381 * @since 2.3.0 386 382 * 383 * @uses bp_parse_args() To merge widget settings into defaults. 384 * 387 385 * @param array $instance Widget instance settings. 388 *389 * @uses bp_parse_args() To merge widget settings into defaults.390 *391 386 * @return array 392 387 */ … … 428 423 public function widget( $args, $instance ) { 429 424 430 // Get widget settings 425 // Get widget settings. 431 426 $settings = $this->parse_settings( $instance ); 432 427 … … 448 443 . $args['after_title']; 449 444 450 // Setup args for querying members 445 // Setup args for querying members. 451 446 $members_args = array( 452 447 'user_id' => 0, … … 488 483 * @param array $new_instance The new instance options. 489 484 * @param array $old_instance The old instance options. 490 *491 485 * @return array $instance The parsed options to be saved. 492 486 */ … … 503 497 * 504 498 * @param array $instance Widget instance settings. 505 * 506 * @return string 499 * @return void 507 500 */ 508 501 public function form( $instance ) { 509 502 510 // Get widget settings 503 // Get widget settings. 511 504 $settings = $this->parse_settings( $instance ); 512 505 $title = strip_tags( $settings['title'] ); … … 535 528 * @since 2.3.0 536 529 * 530 * @uses bp_parse_args() To merge widget settings into defaults. 531 * 537 532 * @param array $instance Widget instance settings. 538 *539 * @uses bp_parse_args() To merge widget settings into defaults.540 *541 533 * @return array 542 534 */ … … 560 552 check_ajax_referer( 'bp_core_widget_members' ); 561 553 562 // Setup some variables to check 554 // Setup some variables to check. 563 555 $filter = ! empty( $_POST['filter'] ) ? $_POST['filter'] : 'recently-active-members'; 564 556 $max_members = ! empty( $_POST['max-members'] ) ? absint( $_POST['max-members'] ) : 5; 565 557 566 // Determine the type of members query to perform 558 // Determine the type of members query to perform. 567 559 switch ( $filter ) { 568 560 569 // Newest activated 561 // Newest activated. 570 562 case 'newest-members' : 571 563 $type = 'newest'; 572 564 break; 573 565 574 // Popular by friends 566 // Popular by friends. 575 567 case 'popular-members' : 576 568 if ( bp_is_active( 'friends' ) ) { … … 581 573 break; 582 574 583 // Default 575 // Default. 584 576 case 'recently-active-members' : 585 577 default : … … 588 580 } 589 581 590 // Setup args for querying members 582 // Setup args for querying members. 591 583 $members_args = array( 592 584 'user_id' => 0, … … 598 590 ); 599 591 600 // Query for members 592 // Query for members. 601 593 if ( bp_has_members( $members_args ) ) : ?> 602 <?php echo '0[[SPLIT]]'; // return valid result. TODO: remove this. ?>594 <?php echo '0[[SPLIT]]'; // Return valid result. TODO: remove this. ?> 603 595 <?php while ( bp_members() ) : bp_the_member(); ?> 604 596 <li class="vcard"> -
trunk/src/bp-members/classes/class-bp-signup.php
r10149 r10322 9 9 */ 10 10 11 /** 12 * Class used to handle Signups. 13 */ 11 14 class BP_Signup { 12 15 … … 112 115 * 113 116 * @param array $args the argument to retrieve desired signups. 114 *115 117 * @return array { 116 118 * @type array $signups Located signups. … … 150 152 if ( empty( $r['include'] ) ) { 151 153 152 // Search terms 154 // Search terms. 153 155 if ( ! empty( $r['usersearch'] ) ) { 154 156 $search_terms_like = '%' . bp_esc_like( $r['usersearch'] ) . '%'; … … 156 158 } 157 159 158 // Activation key 160 // Activation key. 159 161 if ( ! empty( $r['activation_key'] ) ) { 160 162 $sql['where'][] = $wpdb->prepare( "activation_key = %s", $r['activation_key'] ); 161 163 } 162 164 163 // User login 165 // User login. 164 166 if ( ! empty( $r['user_login'] ) ) { 165 167 $sql['where'][] = $wpdb->prepare( "user_login = %s", $r['user_login'] ); … … 174 176 } 175 177 176 // Implode WHERE clauses 178 // Implode WHERE clauses. 177 179 $sql['where'] = 'WHERE ' . implode( ' AND ', $sql['where'] ); 178 180 … … 194 196 195 197 // Used to calculate a diff between now & last 196 // time an activation link has been resent 198 // time an activation link has been resent. 197 199 $now = current_time( 'timestamp', true ); 198 200 … … 208 210 } 209 211 210 // Sent date defaults to date of registration 212 // Sent date defaults to date of registration. 211 213 if ( ! empty( $signup->meta['sent_date'] ) ) { 212 214 $signup->date_sent = $signup->meta['sent_date']; … … 219 221 220 222 /** 221 * add a boolean in case the last time an activation link222 * has been sent happened less than a day ago 223 * Add a boolean in case the last time an activation link 224 * has been sent happened less than a day ago. 223 225 */ 224 226 if ( $diff < 1 * DAY_IN_SECONDS ) { … … 258 260 * @since 2.0.0 259 261 * 260 * @param array $args 261 * 262 * @param array $args Array of arguments for signup addition. 262 263 * @return int|bool ID of newly created signup on success, false on 263 264 * failure. … … 320 321 * @param string $user_email User email address. 321 322 * @param array $usermeta Metadata associated with the signup. 322 *323 323 * @return int User id. 324 324 */ … … 338 338 339 339 // Update the user status to '2', ie "not activated" 340 // (0 = active, 1 = spam, 2 = not active) 340 // (0 = active, 1 = spam, 2 = not active). 341 341 $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->users} SET user_status = 2 WHERE ID = %d", $user_id ) ); 342 342 … … 347 347 delete_user_option( $user_id, 'user_level' ); 348 348 349 // Set any profile data 349 // Set any profile data. 350 350 if ( bp_is_active( 'xprofile' ) ) { 351 351 if ( ! empty( $usermeta['profile_field_ids'] ) ) { … … 360 360 xprofile_set_field_data( $field_id, $user_id, $current_field ); 361 361 362 // Save the visibility level 362 // Save the visibility level. 363 363 $visibility_level = ! empty( $usermeta['field_' . $field_id . '_visibility'] ) ? $usermeta['field_' . $field_id . '_visibility'] : 'public'; 364 364 xprofile_set_field_visibility_level( $field_id, $user_id, $visibility_level ); … … 383 383 * 384 384 * @param int $user_id ID of the user being checked. 385 *386 385 * @return int|bool The status if found, otherwise false. 387 386 */ … … 411 410 * 412 411 * @param string $key Activation key. 413 *414 412 * @return bool True on success, false on failure. 415 413 */ … … 422 420 423 421 $activated = $wpdb->update( 424 // Signups table 422 // Signups table. 425 423 buddypress()->members->table_name_signups, 426 424 array( … … 431 429 'activation_key' => $key, 432 430 ), 433 // Data sanitization format 431 // Data sanitization format. 434 432 array( 435 433 '%d', 436 434 '%s', 437 435 ), 438 // WHERE sanitization format 436 // WHERE sanitization format. 439 437 array( 440 438 '%s', … … 483 481 * @since 2.0.0 484 482 * 485 * @param array $args 486 * 487 * @return int The signup id 483 * @param array $args Array of arguments for the signup update. 484 * @return int The signup id. 488 485 */ 489 486 public static function update( $args = array() ) { … … 503 500 504 501 $wpdb->update( 505 // Signups table 502 // Signups table. 506 503 buddypress()->members->table_name_signups, 507 // Data to update 504 // Data to update. 508 505 array( 509 506 'meta' => serialize( $r['meta'] ), 510 507 ), 511 // WHERE 508 // WHERE. 512 509 array( 513 510 'signup_id' => $r['signup_id'], 514 511 ), 515 // Data sanitization format 512 // Data sanitization format. 516 513 array( 517 514 '%s', 518 515 ), 519 // WHERE sanitization format 516 // WHERE sanitization format. 520 517 array( 521 518 '%d', … … 539 536 * 540 537 * @param array $signup_ids Single ID or list of IDs to resend. 541 *542 538 * @return array 543 539 */ … … 572 568 $meta['count_sent'] = $signup->count_sent + 1; 573 569 574 // Send activation email 570 // Send activation email. 575 571 if ( is_multisite() ) { 576 572 wpmu_signup_user_notification( $signup->user_login, $signup->user_email, $signup->activation_key, serialize( $meta ) ); 577 573 } else { 578 574 579 // Check user status before sending email 575 // Check user status before sending email. 580 576 $user_id = email_exists( $signup->user_email ); 581 577 582 578 if ( ! empty( $user_id ) && 2 != self::check_user_status( $user_id ) ) { 583 579 584 // Status is not 2, so user's account has been activated 580 // Status is not 2, so user's account has been activated. 585 581 $result['errors'][ $signup->signup_id ] = array( $signup->user_login, esc_html__( 'the sign-up has already been activated.', 'buddypress' ) ); 586 582 587 // repair signups table583 // Repair signups table. 588 584 self::validate( $signup->activation_key ); 589 585 590 586 continue; 591 587 592 // Send the validation email 588 // Send the validation email. 593 589 } else { 594 590 bp_core_signup_send_validation_email( false, $signup->user_email, $signup->activation_key ); … … 596 592 } 597 593 598 // Update metas 594 // Update metas. 599 595 $result['resent'][] = self::update( array( 600 596 'signup_id' => $signup->signup_id, … … 629 625 * 630 626 * @param array $signup_ids Single ID or list of IDs to activate. 631 *632 627 * @return array 633 628 */ … … 670 665 if ( empty( $user_id ) ) { 671 666 672 // Status is not 2, so user's account has been activated 667 // Status is not 2, so user's account has been activated. 673 668 $result['errors'][ $signup->signup_id ] = array( $signup->user_login, esc_html__( 'the sign-up has already been activated.', 'buddypress' ) ); 674 669 675 // repair signups table670 // Repair signups table. 676 671 self::validate( $signup->activation_key ); 677 672 678 // we have a user id, account is not active, let's delete it673 // We have a user id, account is not active, let's delete it. 679 674 } else { 680 675 $result['errors'][ $signup->signup_id ] = array( $signup->user_login, $user->get_error_message() ); … … 712 707 * 713 708 * @param array $signup_ids Single ID or list of IDs to delete. 714 *715 709 * @return array 716 710 */ … … 748 742 if ( 2 != self::check_user_status( $user_id ) ) { 749 743 750 // Status is not 2, so user's account has been activated 744 // Status is not 2, so user's account has been activated. 751 745 $result['errors'][ $signup->signup_id ] = array( $signup->user_login, esc_html__( 'the sign-up has already been activated.', 'buddypress' ) ); 752 746 753 // repair signups table747 // Repair signups table. 754 748 self::validate( $signup->activation_key ); 755 749 756 // we have a user id, account is not active, let's delete it750 // We have a user id, account is not active, let's delete it. 757 751 } else { 758 752 bp_core_delete_account( $user_id ); … … 762 756 if ( empty( $result['errors'][ $signup->signup_id ] ) ) { 763 757 $wpdb->delete( 764 // Signups table 758 // Signups table. 765 759 buddypress()->members->table_name_signups, 766 // Where 760 // Where. 767 761 array( 'signup_id' => $signup->signup_id, ), 768 // WHERE sanitization format 762 // WHERE sanitization format. 769 763 array( '%d', ) 770 764 );
Note: See TracChangeset
for help on using the changeset viewer.