Changeset 10322 for trunk/src/bp-members/classes/class-bp-signup.php
- Timestamp:
- 11/02/2015 01:58:52 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.