[ Index ] |
PHP Cross Reference of BuddyPress |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * BuddyPress Members List Table for Multisite. 4 * 5 * @package BuddyPress 6 * @subpackage MembersAdminClasses 7 * @since 2.3.0 8 */ 9 10 // Exit if accessed directly. 11 defined( 'ABSPATH' ) || exit; 12 13 /** 14 * List table class for signups network admin page. 15 * 16 * @since 2.0.0 17 */ 18 class BP_Members_MS_List_Table extends WP_MS_Users_List_Table { 19 20 /** 21 * Signup counts. 22 * 23 * @since 2.0.0 24 * 25 * @var int 26 */ 27 public $signup_counts = 0; 28 29 /** 30 * Signup profile fields. 31 * 32 * @since 10.0.0 33 * 34 * @var array 35 */ 36 public $signup_field_labels = array(); 37 38 /** 39 * Constructor. 40 * 41 * @since 2.0.0 42 */ 43 public function __construct() { 44 // Define singular and plural labels, as well as whether we support AJAX. 45 parent::__construct( array( 46 'ajax' => false, 47 'plural' => 'signups', 48 'singular' => 'signup', 49 'screen' => get_current_screen()->id, 50 ) ); 51 } 52 53 /** 54 * Set up items for display in the list table. 55 * 56 * Handles filtering of data, sorting, pagination, and any other data 57 * manipulation required prior to rendering. 58 * 59 * @since 2.0.0 60 */ 61 public function prepare_items() { 62 global $usersearch, $mode; 63 64 $usersearch = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : ''; 65 $signups_per_page = $this->get_items_per_page( str_replace( '-', '_', "{$this->screen->id}_per_page" ) ); 66 $paged = $this->get_pagenum(); 67 68 $args = array( 69 'offset' => ( $paged - 1 ) * $signups_per_page, 70 'number' => $signups_per_page, 71 'usersearch' => $usersearch, 72 'orderby' => 'signup_id', 73 'order' => 'DESC' 74 ); 75 76 if ( isset( $_REQUEST['orderby'] ) ) { 77 $args['orderby'] = $_REQUEST['orderby']; 78 } 79 80 if ( isset( $_REQUEST['order'] ) ) { 81 $args['order'] = $_REQUEST['order']; 82 } 83 84 $mode = empty( $_REQUEST['mode'] ) ? 'list' : $_REQUEST['mode']; 85 $signups = BP_Signup::get( $args ); 86 87 $this->items = $signups['signups']; 88 $this->signup_counts = $signups['total']; 89 90 $this->set_pagination_args( array( 91 'total_items' => $this->signup_counts, 92 'per_page' => $signups_per_page, 93 ) ); 94 } 95 96 /** 97 * Display the users screen views 98 * 99 * @since 2.5.0 100 * 101 * @global string $role The name of role the users screens is filtered by 102 */ 103 public function views() { 104 global $role; 105 106 // Used to reset the role. 107 $reset_role = $role; 108 109 // Temporarly set the role to registered. 110 $role = 'registered'; 111 112 // Used to reset the screen id once views are displayed. 113 $reset_screen_id = $this->screen->id; 114 115 // Temporarly set the screen id to the users one. 116 $this->screen->id = 'users-network'; 117 118 // Use the parent function so that other plugins can safely add views. 119 parent::views(); 120 121 // Reset the role. 122 $role = $reset_role; 123 124 // Reset the screen id. 125 $this->screen->id = $reset_screen_id; 126 127 // Use thickbox to display the extended profile information. 128 if ( bp_is_active( 'xprofile' ) || bp_members_site_requests_enabled() ) { 129 add_thickbox(); 130 } 131 } 132 133 /** 134 * Specific signups columns. 135 * 136 * @since 2.0.0 137 * 138 * @return array 139 */ 140 public function get_columns() { 141 142 $columns = array( 143 'cb' => '<input type="checkbox" />', 144 'username' => __( 'Username', 'buddypress' ), 145 'name' => __( 'Name', 'buddypress' ), 146 'email' => __( 'Email', 'buddypress' ), 147 'registered' => __( 'Registered', 'buddypress' ), 148 'date_sent' => __( 'Last Sent', 'buddypress' ), 149 'count_sent' => __( 'Emails Sent', 'buddypress' ) 150 ); 151 152 /** 153 * Filters the multisite Members signup columns. 154 * 155 * @since 2.0.0 156 * 157 * @param array $value Array of columns to display. 158 */ 159 return apply_filters( 'bp_members_ms_signup_columns', $columns ); 160 } 161 162 /** 163 * Specific bulk actions for signups. 164 * 165 * @since 2.0.0 166 */ 167 public function get_bulk_actions() { 168 $actions = array( 169 'activate' => _x( 'Activate', 'Pending signup action', 'buddypress' ), 170 'resend' => _x( 'Email', 'Pending signup action', 'buddypress' ), 171 ); 172 173 if ( current_user_can( 'delete_users' ) ) { 174 $actions['delete'] = __( 'Delete', 'buddypress' ); 175 } 176 177 /** 178 * Filters the bulk actions for signups. 179 * 180 * @since 10.0.0 181 * 182 * @param array $actions Array of actions and corresponding labels. 183 */ 184 return apply_filters( 'bp_members_ms_signup_bulk_actions', $actions ); 185 } 186 187 /** 188 * The text shown when no items are found. 189 * 190 * Nice job, clean sheet! 191 * 192 * @since 2.0.0 193 */ 194 public function no_items() { 195 if ( bp_get_signup_allowed() || bp_get_membership_requests_required() ) { 196 esc_html_e( 'No pending accounts found.', 'buddypress' ); 197 } else { 198 $link = false; 199 200 if ( current_user_can( 'manage_network_users' ) ) { 201 $link = sprintf( '<a href="%1$s">%2$s</a>', esc_url( network_admin_url( 'settings.php' ) ), esc_html__( 'Edit settings', 'buddypress' ) ); 202 } 203 204 /* translators: %s: url to site settings */ 205 printf( __( 'Registration is disabled. %s', 'buddypress' ), $link ); 206 } 207 } 208 209 /** 210 * The columns signups can be reordered with. 211 * 212 * @since 2.0.0 213 */ 214 public function get_sortable_columns() { 215 return array( 216 'username' => 'login', 217 'email' => 'email', 218 'registered' => 'signup_id', 219 ); 220 } 221 222 /** 223 * Display signups rows. 224 * 225 * @since 2.0.0 226 */ 227 public function display_rows() { 228 $style = ''; 229 foreach ( $this->items as $userid => $signup_object ) { 230 231 // Avoid a notice error appearing since 4.3.0. 232 if ( isset( $signup_object->id ) ) { 233 $signup_object->ID = $signup_object->id; 234 } 235 236 $style = ( ' class="alternate"' == $style ) ? '' : ' class="alternate"'; 237 echo "\n\t" . $this->single_row( $signup_object, $style ); 238 } 239 } 240 241 /** 242 * Display a signup row. 243 * 244 * @since 2.0.0 245 * 246 * @see WP_List_Table::single_row() for explanation of params. 247 * 248 * @param object|null $signup_object Signup user object. 249 * @param string $style Styles for the row. 250 */ 251 public function single_row( $signup_object = null, $style = '' ) { 252 echo '<tr' . $style . ' id="signup-' . esc_attr( $signup_object->id ) . '">'; 253 echo $this->single_row_columns( $signup_object ); 254 echo '</tr>'; 255 } 256 257 /** 258 * Prevents regular users row actions to be output. 259 * 260 * @since 2.4.0 261 * 262 * @param object|null $signup_object Signup being acted upon. 263 * @param string $column_name Current column name. 264 * @param string $primary Primary column name. 265 * @return string 266 */ 267 protected function handle_row_actions( $signup_object = null, $column_name = '', $primary = '' ) { 268 return ''; 269 } 270 271 /** 272 * Markup for the checkbox used to select items for bulk actions. 273 * 274 * @since 2.0.0 275 * 276 * @param object|null $signup_object The signup data object. 277 */ 278 public function column_cb( $signup_object = null ) { 279 ?> 280 <label class="screen-reader-text" for="signup_<?php echo intval( $signup_object->id ); ?>"><?php printf( 281 /* translators: accessibility text */ 282 esc_html__( 'Select user: %s', 'buddypress' ), $signup_object->user_login ); 283 ?></label> 284 <input type="checkbox" id="signup_<?php echo intval( $signup_object->id ) ?>" name="allsignups[]" value="<?php echo esc_attr( $signup_object->id ) ?>" /> 285 <?php 286 } 287 288 /** 289 * The row actions (delete/activate/email). 290 * 291 * @since 2.0.0 292 * 293 * @param object|null $signup_object The signup data object. 294 */ 295 public function column_username( $signup_object = null ) { 296 $avatar = get_avatar( $signup_object->user_email, 32 ); 297 298 // Activation email link. 299 $email_link = add_query_arg( 300 array( 301 'page' => 'bp-signups', 302 'signup_id' => $signup_object->id, 303 'action' => 'resend', 304 ), 305 network_admin_url( 'users.php' ) 306 ); 307 308 // Activate link. 309 $activate_link = add_query_arg( 310 array( 311 'page' => 'bp-signups', 312 'signup_id' => $signup_object->id, 313 'action' => 'activate', 314 ), 315 network_admin_url( 'users.php' ) 316 ); 317 318 // Delete link. 319 $delete_link = add_query_arg( 320 array( 321 'page' => 'bp-signups', 322 'signup_id' => $signup_object->id, 323 'action' => 'delete', 324 ), 325 network_admin_url( 'users.php' ) 326 ); 327 328 echo $avatar . sprintf( '<strong><a href="%1$s" class="edit">%2$s</a></strong><br/>', esc_url( $activate_link ), $signup_object->user_login ); 329 330 $actions = array(); 331 332 $actions['activate'] = sprintf( '<a href="%1$s">%2$s</a>', esc_url( $activate_link ), __( 'Activate', 'buddypress' ) ); 333 $actions['resend'] = sprintf( '<a href="%1$s">%2$s</a>', esc_url( $email_link ), __( 'Email', 'buddypress' ) ); 334 335 if ( current_user_can( 'delete_users' ) ) { 336 $actions['delete'] = sprintf( '<a href="%1$s" class="delete">%2$s</a>', esc_url( $delete_link ), __( 'Delete', 'buddypress' ) ); 337 } 338 339 /** This filter is documented in bp-members/admin/bp-members-classes.php */ 340 $actions = apply_filters( 'bp_members_ms_signup_row_actions', $actions, $signup_object ); 341 342 echo $this->row_actions( $actions ); 343 } 344 345 /** 346 * Display user name, if any. 347 * 348 * @since 2.0.0 349 * 350 * @param object|null $signup_object The signup data object. 351 */ 352 public function column_name( $signup_object = null ) { 353 echo esc_html( $signup_object->user_name ); 354 355 // Insert the extended profile modal content required by thickbox. 356 if ( ! bp_is_active( 'xprofile' ) && ! bp_members_site_requests_enabled() ) { 357 return; 358 } 359 360 if ( bp_is_active( 'xprofile' ) ) { 361 $profile_field_ids = array(); 362 363 // Fetch registration field data once only. 364 if ( ! $this->signup_field_labels ) { 365 $field_groups = bp_xprofile_get_groups( 366 array( 367 'fetch_fields' => true, 368 'signup_fields_only' => true, 369 ) 370 ); 371 372 foreach ( $field_groups as $field_group ) { 373 foreach ( $field_group->fields as $field ) { 374 $this->signup_field_labels[ $field->id ] = $field->name; 375 } 376 } 377 } 378 } 379 380 bp_members_admin_preview_signup_profile_info( $this->signup_field_labels, $signup_object ); 381 } 382 383 /** 384 * Display user email. 385 * 386 * @since 2.0.0 387 * 388 * @param object|null $signup_object The signup data object. 389 */ 390 public function column_email( $signup_object = null ) { 391 printf( '<a href="mailto:%1$s">%2$s</a>', esc_attr( $signup_object->user_email ), esc_html( $signup_object->user_email ) ); 392 } 393 394 /** 395 * Display registration date. 396 * 397 * @since 2.0.0 398 * 399 * @param object|null $signup_object The signup data object. 400 */ 401 public function column_registered( $signup_object = null ) { 402 global $mode; 403 404 if ( 'list' === $mode ) { 405 $date = 'Y/m/d'; 406 } else { 407 $date = 'Y/m/d \<\b\r \/\> g:i:s a'; 408 } 409 410 echo mysql2date( $date, $signup_object->registered ) . "</td>"; 411 } 412 413 /** 414 * Display the last time an activation email has been sent. 415 * 416 * @since 2.0.0 417 * 418 * @param object|null $signup_object Signup object instance. 419 */ 420 public function column_date_sent( $signup_object = null ) { 421 global $mode; 422 423 if ( 'list' === $mode ) { 424 $date = 'Y/m/d'; 425 } else { 426 $date = 'Y/m/d \<\b\r \/\> g:i:s a'; 427 } 428 429 if ( $signup_object->count_sent > 0 ) { 430 echo mysql2date( $date, $signup_object->date_sent ); 431 } else { 432 $message = __( 'Not yet notified', 'buddypress' ); 433 434 /** 435 * Filters the "not yet sent" message for "Last Sent" 436 * column in Manage Signups list table. 437 * 438 * @since 10.0.0 439 * 440 * @param string $message "Not yet sent" message. 441 * @param object|null $signup_object Signup object instance. 442 */ 443 $message = apply_filters( 'bp_members_ms_signup_date_sent_unsent_message', $message, $signup_object ); 444 445 echo esc_html( $message ); 446 } 447 } 448 449 /** 450 * Display number of time an activation email has been sent. 451 * 452 * @since 2.0.0 453 * 454 * @param object|null $signup_object Signup object instance. 455 */ 456 public function column_count_sent( $signup_object = null ) { 457 echo absint( $signup_object->count_sent ); 458 } 459 460 /** 461 * Allow plugins to add their custom column. 462 * 463 * @since 2.1.0 464 * 465 * @param object|null $signup_object The signup data object. 466 * @param string $column_name The column name. 467 * @return string 468 */ 469 function column_default( $signup_object = null, $column_name = '' ) { 470 471 /** 472 * Filters the multisite custom columns for plugins. 473 * 474 * @since 2.1.0 475 * 476 * @param string $column_name The column name. 477 * @param object $signup_object The signup data object. 478 */ 479 return apply_filters( 'bp_members_ms_signup_custom_column', '', $column_name, $signup_object ); 480 } 481 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Nov 21 01:00:57 2024 | Cross-referenced by PHPXref 0.7.1 |