Skip to:
Content

BuddyPress.org

Changeset 10498


Ignore:
Timestamp:
02/03/2016 05:33:13 AM (11 years ago)
Author:
tw2113
Message:

Adds missed periods and some @since tags to the Settings component.

See #6405.

Location:
trunk/src/bp-settings
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-settings/bp-settings-actions.php

    r10479 r10498  
    2323 * users accounts already, without knowing their existing password.
    2424 *
     25 * @since 1.6.0
     26 *
    2527 * @global BuddyPress $bp
    2628 */
    2729function bp_settings_action_general() {
    2830
    29         // Bail if not a POST action
     31        // Bail if not a POST action.
    3032        if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) )
    3133                return;
    3234
    33         // Bail if no submit action
     35        // Bail if no submit action.
    3436        if ( ! isset( $_POST['submit'] ) )
    3537                return;
    3638
    37         // Bail if not in settings
     39        // Bail if not in settings.
    3840        if ( ! bp_is_settings_component() || ! bp_is_current_action( 'general' ) )
    3941                return;
    … …  
    5254        $email_changed = false;        // true if the user changes their email
    5355        $feedback_type = 'error';      // success|error
    54         $feedback      = array();      // array of strings for feedback
    55 
    56         // Nonce check
     56        $feedback      = array();      // array of strings for feedback.
     57
     58        // Nonce check.
    5759        check_admin_referer('bp_settings_general');
    5860
    59         // Validate the user again for the current password when making a big change
     61        // Validate the user again for the current password when making a big change.
    6062        if ( ( is_super_admin() ) || ( !empty( $_POST['pwd'] ) && wp_check_password( $_POST['pwd'], $bp->displayed_user->userdata->user_pass, bp_displayed_user_id() ) ) ) {
    6163
    6264                $update_user = get_userdata( bp_displayed_user_id() );
    6365
    64                 /** Email Change Attempt ******************************************/
     66                /* Email Change Attempt ******************************************/
    6567
    6668                if ( !empty( $_POST['email'] ) ) {
    6769
    6870                        // What is missing from the profile page vs signup -
    69                         // let's double check the goodies
     71                        // let's double check the goodies.
    7072                        $user_email     = sanitize_email( esc_html( trim( $_POST['email'] ) ) );
    7173                        $old_user_email = $bp->displayed_user->userdata->user_email;
    7274
    73                         // User is changing email address
     75                        // User is changing email address.
    7476                        if ( $old_user_email != $user_email ) {
    7577
    76                                 // Run some tests on the email address
     78                                // Run some tests on the email address.
    7779                                $email_checks = bp_core_validate_email_address( $user_email );
    7880
    … …  
    9193                                }
    9294
    93                                 // Store a hash to enable email validation
     95                                // Store a hash to enable email validation.
    9496                                if ( false === $email_error ) {
    9597                                        $hash = wp_hash( $_POST['email'] );
    … …  
    103105                                        $verify_link = bp_displayed_user_domain() . bp_get_settings_slug() . '/?verify_email_change=' . $hash;
    104106
    105                                         // Send the verification email
     107                                        // Send the verification email.
    106108                                        $args = array(
    107109                                                'tokens' => array(
    … …  
    115117
    116118                                        // We mark that the change has taken place so as to ensure a
    117                                         // success message, even though verification is still required
     119                                        // success message, even though verification is still required.
    118120                                        $_POST['email'] = $update_user->user_email;
    119121                                        $email_changed = true;
    120122                                }
    121123
    122                         // No change
     124                        // No change.
    123125                        } else {
    124126                                $email_error = false;
    125127                        }
    126128
    127                 // Email address cannot be empty
     129                // Email address cannot be empty.
    128130                } else {
    129131                        $email_error = 'empty';
    130132                }
    131133
    132                 /** Password Change Attempt ***************************************/
     134                /* Password Change Attempt ***************************************/
    133135
    134136                if ( !empty( $_POST['pass1'] ) && !empty( $_POST['pass2'] ) ) {
    … …  
    136138                        if ( ( $_POST['pass1'] == $_POST['pass2'] ) && !strpos( " " . $_POST['pass1'], "\\" ) ) {
    137139
    138                                 // Password change attempt is successful
     140                                // Password change attempt is successful.
    139141                                if ( ( ! empty( $_POST['pwd'] ) && $_POST['pwd'] != $_POST['pass1'] ) || is_super_admin() )  {
    140142                                        $update_user->user_pass = $_POST['pass1'];
    141143                                        $pass_changed = true;
    142144
    143                                 // The new password is the same as the current password
     145                                // The new password is the same as the current password.
    144146                                } else {
    145147                                        $pass_error = 'same';
    146148                                }
    147149
    148                         // Password change attempt was unsuccessful
     150                        // Password change attempt was unsuccessful.
    149151                        } else {
    150152                                $pass_error = 'mismatch';
    151153                        }
    152154
    153                 // Both password fields were empty
     155                // Both password fields were empty.
    154156                } elseif ( empty( $_POST['pass1'] ) && empty( $_POST['pass2'] ) ) {
    155157                        $pass_error = false;
    156158
    157                 // One of the password boxes was left empty
     159                // One of the password boxes was left empty.
    158160                } elseif ( ( empty( $_POST['pass1'] ) && !empty( $_POST['pass2'] ) ) || ( !empty( $_POST['pass1'] ) && empty( $_POST['pass2'] ) ) ) {
    159161                        $pass_error = 'empty';
    … …  
    161163
    162164                // The structure of the $update_user object changed in WP 3.3, but
    163                 // wp_update_user() still expects the old format
     165                // wp_update_user() still expects the old format.
    164166                if ( isset( $update_user->data ) && is_object( $update_user->data ) ) {
    165167                        $update_user = $update_user->data;
    … …  
    168170                        // Unset the password field to prevent it from emptying out the
    169171                        // user's user_pass field in the database.
    170                         // @see wp_update_user()
     172                        // @see wp_update_user().
    171173                        if ( false === $pass_changed ) {
    172174                                unset( $update_user['user_pass'] );
    … …  
    175177
    176178                // Clear cached data, so that the changed settings take effect
    177                 // on the current page load
     179                // on the current page load.
    178180                if ( ( false === $email_error ) && ( false === $pass_error ) && ( wp_update_user( $update_user ) ) ) {
    179181                        wp_cache_delete( 'bp_core_userdata_' . bp_displayed_user_id(), 'bp' );
    … …  
    181183                }
    182184
    183         // Password Error
     185        // Password Error.
    184186        } else {
    185187                $pass_error = 'invalid';
    186188        }
    187189
    188         // Email feedback
     190        // Email feedback.
    189191        switch ( $email_error ) {
    190192                case 'invalid' :
    … …  
    201203                        break;
    202204                case false :
    203                         // No change
    204                         break;
    205         }
    206 
    207         // Password feedback
     205                        // No change.
     206                        break;
     207        }
     208
     209        // Password feedback.
    208210        switch ( $pass_error ) {
    209211                case 'invalid' :
    … …  
    220222                        break;
    221223                case false :
    222                         // No change
    223                         break;
    224         }
    225 
    226         // No errors so show a simple success message
     224                        // No change.
     225                        break;
     226        }
     227
     228        // No errors so show a simple success message.
    227229        if ( ( ( false === $email_error ) || ( false == $pass_error ) ) && ( ( true === $pass_changed ) || ( true === $email_changed ) ) ) {
    228230                $feedback[]    = __( 'Your settings have been saved.', 'buddypress' );
    229231                $feedback_type = 'success';
    230232
    231         // Some kind of errors occurred
     233        // Some kind of errors occurred.
    232234        } elseif ( ( ( false === $email_error ) || ( false === $pass_error ) ) && ( ( false === $pass_changed ) || ( false === $email_changed ) ) ) {
    233235                if ( bp_is_my_profile() ) {
    … …  
    238240        }
    239241
    240         // Set the feedback
     242        // Set the feedback.
    241243        bp_core_add_message( implode( "\n", $feedback ), $feedback_type );
    242244
    … …  
    248250        do_action( 'bp_core_general_settings_after_save' );
    249251
    250         // Redirect to prevent issues with browser back button
     252        // Redirect to prevent issues with browser back button.
    251253        bp_core_redirect( trailingslashit( bp_displayed_user_domain() . bp_get_settings_slug() . '/general' ) );
    252254}
    … …  
    255257/**
    256258 * Handles the changing and saving of user notification settings.
     259 *
     260 * @since 1.6.0
    257261 */
    258262function bp_settings_action_notifications() {
    259263
    260         // Bail if not a POST action
     264        // Bail if not a POST action.
    261265        if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) )
    262266                return;
    263267
    264         // Bail if no submit action
     268        // Bail if no submit action.
    265269        if ( ! isset( $_POST['submit'] ) )
    266270                return;
    267271
    268         // Bail if not in settings
     272        // Bail if not in settings.
    269273        if ( ! bp_is_settings_component() || ! bp_is_current_action( 'notifications' ) )
    270274                return false;
    … …  
    280284        bp_settings_update_notification_settings( bp_displayed_user_id(), (array) $_POST['notifications'] );
    281285
    282         // Switch feedback for super admins
     286        // Switch feedback for super admins.
    283287        if ( bp_is_my_profile() ) {
    284288                bp_core_add_message( __( 'Your notification settings have been saved.',        'buddypress' ), 'success' );
    … …  
    300304/**
    301305 * Handles the setting of user capabilities, spamming, hamming, role, etc...
     306 *
     307 * @since 1.6.0
    302308 */
    303309function bp_settings_action_capabilities() {
    304310
    305         // Bail if not a POST action
     311        // Bail if not a POST action.
    306312        if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) )
    307313                return;
    308314
    309         // Bail if no submit action
     315        // Bail if no submit action.
    310316        if ( ! isset( $_POST['capabilities-submit'] ) )
    311317                return;
    312318
    313         // Bail if not in settings
     319        // Bail if not in settings.
    314320        if ( ! bp_is_settings_component() || ! bp_is_current_action( 'capabilities' ) )
    315321                return false;
    … …  
    322328
    323329        // Only super admins can currently spam users (but they can't spam
    324         // themselves)
     330        // themselves).
    325331        if ( ! is_super_admin() || bp_is_my_profile() ) {
    326332                return;
    327333        }
    328334
    329         // Nonce check
     335        // Nonce check.
    330336        check_admin_referer( 'capabilities' );
    331337
    … …  
    337343        do_action( 'bp_settings_capabilities_before_save' );
    338344
    339         /** Spam **************************************************************/
     345        /* Spam **************************************************************/
    340346
    341347        $is_spammer = !empty( $_POST['user-spammer'] ) ? true : false;
    … …  
    356362        }
    357363
    358         /** Other *************************************************************/
     364        /* Other *************************************************************/
    359365
    360366        /**
    … …  
    365371        do_action( 'bp_settings_capabilities_after_save' );
    366372
    367         // Redirect to the root domain
     373        // Redirect to the root domain.
    368374        bp_core_redirect( bp_displayed_user_domain() . bp_get_settings_slug() . '/capabilities/' );
    369375}
    … …  
    372378/**
    373379 * Handles the deleting of a user.
     380 *
     381 * @since 1.6.0
    374382 */
    375383function bp_settings_action_delete_account() {
    376384
    377         // Bail if not a POST action
     385        // Bail if not a POST action.
    378386        if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) )
    379387                return;
    380388
    381         // Bail if no submit action
     389        // Bail if no submit action.
    382390        if ( ! isset( $_POST['delete-account-understand'] ) )
    383391                return;
    384392
    385         // Bail if not in settings
     393        // Bail if not in settings.
    386394        if ( ! bp_is_settings_component() || ! bp_is_current_action( 'delete-account' ) )
    387395                return false;
    … …  
    393401        }
    394402
    395         // Bail if account deletion is disabled
     403        // Bail if account deletion is disabled.
    396404        if ( bp_disable_account_deletion() && ! bp_current_user_can( 'delete_users' ) ) {
    397405                return false;
    398406        }
    399407
    400         // Nonce check
     408        // Nonce check.
    401409        check_admin_referer( 'delete-account' );
    402410
    … …  
    404412        $username = bp_get_displayed_user_fullname();
    405413
    406         // delete the users account
     414        // Delete the users account.
    407415        if ( bp_core_delete_account( bp_displayed_user_id() ) ) {
    408416
    409                 // Add feedback after deleting a user
     417                // Add feedback after deleting a user.
    410418                bp_core_add_message( sprintf( __( '%s was successfully deleted.', 'buddypress' ), $username ), 'success' );
    411419
    412                 // Redirect to the root domain
     420                // Redirect to the root domain.
    413421                bp_core_redirect( bp_get_root_domain() );
    414422        }
    … …  
    432440        $redirect_to = trailingslashit( bp_displayed_user_domain() . bp_get_settings_slug() );
    433441
    434         // Email change is being verified
     442        // Email change is being verified.
    435443        if ( isset( $_GET['verify_email_change'] ) ) {
    436444                $pending_email = bp_get_user_meta( bp_displayed_user_id(), 'pending_email_change', true );
    437445
    438                 // Bail if the hash provided doesn't match the one saved in the database
     446                // Bail if the hash provided doesn't match the one saved in the database.
    439447                if ( urldecode( $_GET['verify_email_change'] ) !== $pending_email['hash'] ) {
    440448                        return;
    … …  
    447455
    448456                if ( $email_changed ) {
    449                         // Delete object cache for displayed user
     457                        // Delete object cache for displayed user.
    450458                        wp_cache_delete( 'bp_core_userdata_' . bp_displayed_user_id(), 'bp' );
    451459
    452                         // Delete the pending email change key
     460                        // Delete the pending email change key.
    453461                        bp_delete_user_meta( bp_displayed_user_id(), 'pending_email_change' );
    454462
    455                         // Post a success message and redirect
     463                        // Post a success message and redirect.
    456464                        bp_core_add_message( __( 'You have successfully verified your new email address.', 'buddypress' ) );
    457465                } else {
    458                         // Unknown error
     466                        // Unknown error.
    459467                        bp_core_add_message( __( 'There was a problem verifying your new email address. Please try again.', 'buddypress' ), 'error' );
    460468                }
    … …  
    463471                die();
    464472
    465         // Email change is being dismissed
     473        // Email change is being dismissed.
    466474        } elseif ( ! empty( $_GET['dismiss_email_change'] ) ) {
    467475                bp_delete_user_meta( bp_displayed_user_id(), 'pending_email_change' );
  • trunk/src/bp-settings/bp-settings-loader.php

    r10417 r10498  
    1111defined( 'ABSPATH' ) || exit;
    1212
     13/**
     14 * Creates our Settings component.
     15 *
     16 * @since 1.5.0
     17 */
    1318class BP_Settings_Component extends BP_Component {
    1419
    … …  
    3237         * Include files.
    3338         *
     39         * @since 1.5.0
     40         *
    3441         * @param array $includes Array of values to include. Not used.
    3542         */
    … …  
    4956         * backwards compatibility.
    5057         *
     58         * @since 1.5.0
     59         *
    5160         * @param array $args Array of arguments.
    52          *
    53          * @since 1.5.0
    5461         */
    5562        public function setup_globals( $args = array() ) {
    5663
    57                 // Define a slug, if necessary
     64                // Define a slug, if necessary.
    5865                if ( ! defined( 'BP_SETTINGS_SLUG' ) ) {
    5966                        define( 'BP_SETTINGS_SLUG', $this->id );
    … …  
    7077         * Set up navigation.
    7178         *
     79         * @since 1.5.0
     80         *
    7281         * @param array $main_nav Array of main nav items.
    7382         * @param array $sub_nav  Array of sub nav items.
    … …  
    7584        public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
    7685
    77                 // Determine user to use
     86                // Determine user to use.
    7887                if ( bp_displayed_user_domain() ) {
    7988                        $user_domain = bp_displayed_user_domain();
    … …  
    8897                $settings_link = trailingslashit( $user_domain . $slug );
    8998
    90                 // Add the settings navigation item
     99                // Add the settings navigation item.
    91100                $main_nav = array(
    92101                        'name'                    => __( 'Settings', 'buddypress' ),
    … …  
    98107                );
    99108
    100                 // Add General Settings nav item
     109                // Add General Settings nav item.
    101110                $sub_nav[] = array(
    102111                        'name'            => __( 'General', 'buddypress' ),
    … …  
    110119
    111120                // Add Email nav item. Formerly called 'Notifications', we
    112                 // retain the old slug and function names for backward compat
     121                // retain the old slug and function names for backward compat.
    113122                $sub_nav[] = array(
    114123                        'name'            => __( 'Email', 'buddypress' ),
    … …  
    121130                );
    122131
    123                 // Add Spam Account nav item
     132                // Add Spam Account nav item.
    124133                if ( bp_current_user_can( 'bp_moderate' ) ) {
    125134                        $sub_nav[] = array(
    … …  
    134143                }
    135144
    136                 // Add Delete Account nav item
     145                // Add Delete Account nav item.
    137146                if ( ( ! bp_disable_account_deletion() && bp_is_my_profile() ) || bp_current_user_can( 'delete_users' ) ) {
    138147                        $sub_nav[] = array(
    … …  
    153162         * Set up the Toolbar.
    154163         *
     164         * @since 1.5.0
     165         *
    155166         * @param array $wp_admin_nav Array of Admin Bar items.
    156167         */
    157168        public function setup_admin_bar( $wp_admin_nav = array() ) {
    158169
    159                 // Menus for logged in user
     170                // Menus for logged in user.
    160171                if ( is_user_logged_in() ) {
    161172
    162                         // Setup the logged in user variables
     173                        // Setup the logged in user variables.
    163174                        $settings_link = trailingslashit( bp_loggedin_user_domain() . bp_get_settings_slug() );
    164175
    165                         // Add main Settings menu
     176                        // Add main Settings menu.
    166177                        $wp_admin_nav[] = array(
    167178                                'parent' => buddypress()->my_account_menu_id,
    … …  
    171182                        );
    172183
    173                         // General Account
     184                        // General Account.
    174185                        $wp_admin_nav[] = array(
    175186                                'parent' => 'my-account-' . $this->id,
    … …  
    189200                        }
    190201
    191                         // Delete Account
     202                        // Delete Account.
    192203                        if ( !bp_current_user_can( 'bp_moderate' ) && ! bp_core_get_root_option( 'bp-disable-account-deletion' ) ) {
    193204                                $wp_admin_nav[] = array(
    … …  
    204215}
    205216
     217/**
     218 * Instantiates the settings component.
     219 *
     220 * @since 1.6.0
     221 */
    206222function bp_setup_settings() {
    207223        buddypress()->settings = new BP_Settings_Component();
Note: See TracChangeset for help on using the changeset viewer.