Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
10/01/2015 04:18:13 AM (10 years ago)
Author:
tw2113
Message:

First pass of documentation cleanup for the XProfile Component.

See #6406.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-xprofile/bp-xprofile-screens.php

    r10157 r10163  
    1717 * Handles the display of the profile page by loading the correct template file.
    1818 *
    19  * @package BuddyPress XProfile
    20  * @uses bp_core_load_template() Looks for and loads a template file within the current member theme (folder/filename)
     19 * @uses bp_core_load_template() Looks for and loads a template file within the current member theme (folder/filename).
    2120 */
    2221function xprofile_screen_display_profile() {
     
    4645 * Also checks to make sure this can only be accessed for the logged in users profile.
    4746 *
    48  * @package BuddyPress XProfile
    49  * @uses bp_is_my_profile() Checks to make sure the current user being viewed equals the logged in user
    50  * @uses bp_core_load_template() Looks for and loads a template file within the current member theme (folder/filename)
     47 * @uses bp_is_my_profile() Checks to make sure the current user being viewed equals the logged in user.
     48 * @uses bp_core_load_template() Looks for and loads a template file within the current member theme (folder/filename).
    5149 */
    5250function xprofile_screen_edit_profile() {
     
    6159    }
    6260
    63     // Check the field group exists
     61    // Check the field group exists.
    6462    if ( ! bp_is_action_variable( 'group' ) || ! xprofile_get_field_group( bp_action_variable( 1 ) ) ) {
    6563        bp_do_404();
     
    6765    }
    6866
    69     // No errors
     67    // No errors.
    7068    $errors = false;
    7169
    72     // Check to see if any new information has been submitted
     70    // Check to see if any new information has been submitted.
    7371    if ( isset( $_POST['field_ids'] ) ) {
    7472
    75         // Check the nonce
     73        // Check the nonce.
    7674        check_admin_referer( 'bp_xprofile_edit' );
    7775
    78         // Check we have field ID's
     76        // Check we have field ID's.
    7977        if ( empty( $_POST['field_ids'] ) ) {
    8078            bp_core_redirect( trailingslashit( bp_displayed_user_domain() . bp_get_profile_slug() . '/edit/group/' . bp_action_variable( 1 ) ) );
     
    8280
    8381        // Explode the posted field IDs into an array so we know which
    84         // fields have been submitted
     82        // fields have been submitted.
    8583        $posted_field_ids = wp_parse_id_list( $_POST['field_ids'] );
    8684        $is_required      = array();
    8785
    8886        // Loop through the posted fields formatting any datebox values
    89         // then validate the field
     87        // then validate the field.
    9088        foreach ( (array) $posted_field_ids as $field_id ) {
    9189            if ( !isset( $_POST['field_' . $field_id] ) ) {
    9290
    9391                if ( !empty( $_POST['field_' . $field_id . '_day'] ) && !empty( $_POST['field_' . $field_id . '_month'] ) && !empty( $_POST['field_' . $field_id . '_year'] ) ) {
    94                     // Concatenate the values
     92                    // Concatenate the values.
    9593                    $date_value =   $_POST['field_' . $field_id . '_day'] . ' ' . $_POST['field_' . $field_id . '_month'] . ' ' . $_POST['field_' . $field_id . '_year'];
    9694
    97                     // Turn the concatenated value into a timestamp
     95                    // Turn the concatenated value into a timestamp.
    9896                    $_POST['field_' . $field_id] = date( 'Y-m-d H:i:s', strtotime( $date_value ) );
    9997                }
     
    107105        }
    108106
    109         // There are errors
     107        // There are errors.
    110108        if ( !empty( $errors ) ) {
    111109            bp_core_add_message( __( 'Please make sure you fill in all required fields in this profile field group before saving.', 'buddypress' ), 'error' );
    112110
    113         // No errors
     111        // No errors.
    114112        } else {
    115113
    116             // Reset the errors var
     114            // Reset the errors var.
    117115            $errors = false;
    118116
     
    128126                // Save the old and new values. They will be
    129127                // passed to the filter and used to determine
    130                 // whether an activity item should be posted
     128                // whether an activity item should be posted.
    131129                $old_values[ $field_id ] = array(
    132130                    'value'      => xprofile_get_field_data( $field_id, bp_displayed_user_id() ),
     
    134132                );
    135133
    136                 // Update the field data and visibility level
     134                // Update the field data and visibility level.
    137135                xprofile_set_field_visibility_level( $field_id, bp_displayed_user_id(), $visibility_level );
    138136                $field_updated = xprofile_set_field_data( $field_id, bp_displayed_user_id(), $value, $is_required[ $field_id ] );
     
    173171            do_action( 'xprofile_updated_profile', bp_displayed_user_id(), $posted_field_ids, $errors, $old_values, $new_values );
    174172
    175             // Set the feedback messages
     173            // Set the feedback messages.
    176174            if ( !empty( $errors ) ) {
    177175                bp_core_add_message( __( 'There was a problem updating some of your profile information. Please try again.', 'buddypress' ), 'error' );
     
    180178            }
    181179
    182             // Redirect back to the edit screen to display the updates and message
     180            // Redirect back to the edit screen to display the updates and message.
    183181            bp_core_redirect( trailingslashit( bp_displayed_user_domain() . bp_get_profile_slug() . '/edit/group/' . bp_action_variable( 1 ) ) );
    184182        }
     
    205203 * Handles the uploading and cropping of a user avatar. Displays the change avatar page.
    206204 *
    207  * @package BuddyPress XProfile
    208  * @uses bp_is_my_profile() Checks to make sure the current user being viewed equals the logged in user
    209  * @uses bp_core_load_template() Looks for and loads a template file within the current member theme (folder/filename)
     205 * @uses bp_is_my_profile() Checks to make sure the current user being viewed equals the logged in user.
     206 * @uses bp_core_load_template() Looks for and loads a template file within the current member theme (folder/filename).
    210207 */
    211208function xprofile_screen_change_avatar() {
    212209
    213     // Bail if not the correct screen
     210    // Bail if not the correct screen.
    214211    if ( ! bp_is_my_profile() && ! bp_current_user_can( 'bp_moderate' ) ) {
    215212        return false;
    216213    }
    217214
    218     // Bail if there are action variables
     215    // Bail if there are action variables.
    219216    if ( bp_action_variables() ) {
    220217        bp_do_404();
     
    232229    if ( !empty( $_FILES ) ) {
    233230
    234         // Check the nonce
     231        // Check the nonce.
    235232        check_admin_referer( 'bp_avatar_upload' );
    236233
    237         // Pass the file to the avatar upload handler
     234        // Pass the file to the avatar upload handler.
    238235        if ( bp_core_avatar_handle_upload( $_FILES, 'xprofile_avatar_upload_dir' ) ) {
    239236            $bp->avatar_admin->step = 'crop-image';
    240237
    241             // Make sure we include the jQuery jCrop file for image cropping
     238            // Make sure we include the jQuery jCrop file for image cropping.
    242239            add_action( 'wp_print_scripts', 'bp_core_add_jquery_cropper' );
    243240        }
    244241    }
    245242
    246     // If the image cropping is done, crop the image and save a full/thumb version
     243    // If the image cropping is done, crop the image and save a full/thumb version.
    247244    if ( isset( $_POST['avatar-crop-submit'] ) ) {
    248245
    249         // Check the nonce
     246        // Check the nonce.
    250247        check_admin_referer( 'bp_avatar_cropstore' );
    251248
     
    268265             * @since 1.1.0
    269266             * @since 2.3.4 Add two new parameters to inform about the user id and
    270              *              about the way the avatar was set (eg: 'crop' or 'camera')
     267             *              about the way the avatar was set (eg: 'crop' or 'camera').
    271268             *
    272              * @param string $item_id Inform about the user id the avatar was set for
    273              * @param string $value Inform about the way the avatar was set ('crop')
     269             * @param string $item_id Inform about the user id the avatar was set for.
     270             * @param string $value   Inform about the way the avatar was set ('crop').
    274271             */
    275272            do_action( 'xprofile_avatar_uploaded', (int) $args['item_id'], 'crop' );
     
    328325
    329326/**
    330  * Show the xprofile settings template
     327 * Show the xprofile settings template.
    331328 *
    332329 * @since 2.0.0
     
    334331function bp_xprofile_screen_settings() {
    335332
    336     // Redirect if no privacy settings page is accessible
     333    // Redirect if no privacy settings page is accessible.
    337334    if ( bp_action_variables() || ! bp_is_active( 'xprofile' ) ) {
    338335        bp_do_404();
Note: See TracChangeset for help on using the changeset viewer.