Changeset 10163 for trunk/src/bp-xprofile/bp-xprofile-screens.php
- Timestamp:
- 10/01/2015 04:18:13 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-xprofile/bp-xprofile-screens.php
r10157 r10163 17 17 * Handles the display of the profile page by loading the correct template file. 18 18 * 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). 21 20 */ 22 21 function xprofile_screen_display_profile() { … … 46 45 * Also checks to make sure this can only be accessed for the logged in users profile. 47 46 * 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). 51 49 */ 52 50 function xprofile_screen_edit_profile() { … … 61 59 } 62 60 63 // Check the field group exists 61 // Check the field group exists. 64 62 if ( ! bp_is_action_variable( 'group' ) || ! xprofile_get_field_group( bp_action_variable( 1 ) ) ) { 65 63 bp_do_404(); … … 67 65 } 68 66 69 // No errors 67 // No errors. 70 68 $errors = false; 71 69 72 // Check to see if any new information has been submitted 70 // Check to see if any new information has been submitted. 73 71 if ( isset( $_POST['field_ids'] ) ) { 74 72 75 // Check the nonce 73 // Check the nonce. 76 74 check_admin_referer( 'bp_xprofile_edit' ); 77 75 78 // Check we have field ID's 76 // Check we have field ID's. 79 77 if ( empty( $_POST['field_ids'] ) ) { 80 78 bp_core_redirect( trailingslashit( bp_displayed_user_domain() . bp_get_profile_slug() . '/edit/group/' . bp_action_variable( 1 ) ) ); … … 82 80 83 81 // Explode the posted field IDs into an array so we know which 84 // fields have been submitted 82 // fields have been submitted. 85 83 $posted_field_ids = wp_parse_id_list( $_POST['field_ids'] ); 86 84 $is_required = array(); 87 85 88 86 // Loop through the posted fields formatting any datebox values 89 // then validate the field 87 // then validate the field. 90 88 foreach ( (array) $posted_field_ids as $field_id ) { 91 89 if ( !isset( $_POST['field_' . $field_id] ) ) { 92 90 93 91 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. 95 93 $date_value = $_POST['field_' . $field_id . '_day'] . ' ' . $_POST['field_' . $field_id . '_month'] . ' ' . $_POST['field_' . $field_id . '_year']; 96 94 97 // Turn the concatenated value into a timestamp 95 // Turn the concatenated value into a timestamp. 98 96 $_POST['field_' . $field_id] = date( 'Y-m-d H:i:s', strtotime( $date_value ) ); 99 97 } … … 107 105 } 108 106 109 // There are errors 107 // There are errors. 110 108 if ( !empty( $errors ) ) { 111 109 bp_core_add_message( __( 'Please make sure you fill in all required fields in this profile field group before saving.', 'buddypress' ), 'error' ); 112 110 113 // No errors 111 // No errors. 114 112 } else { 115 113 116 // Reset the errors var 114 // Reset the errors var. 117 115 $errors = false; 118 116 … … 128 126 // Save the old and new values. They will be 129 127 // passed to the filter and used to determine 130 // whether an activity item should be posted 128 // whether an activity item should be posted. 131 129 $old_values[ $field_id ] = array( 132 130 'value' => xprofile_get_field_data( $field_id, bp_displayed_user_id() ), … … 134 132 ); 135 133 136 // Update the field data and visibility level 134 // Update the field data and visibility level. 137 135 xprofile_set_field_visibility_level( $field_id, bp_displayed_user_id(), $visibility_level ); 138 136 $field_updated = xprofile_set_field_data( $field_id, bp_displayed_user_id(), $value, $is_required[ $field_id ] ); … … 173 171 do_action( 'xprofile_updated_profile', bp_displayed_user_id(), $posted_field_ids, $errors, $old_values, $new_values ); 174 172 175 // Set the feedback messages 173 // Set the feedback messages. 176 174 if ( !empty( $errors ) ) { 177 175 bp_core_add_message( __( 'There was a problem updating some of your profile information. Please try again.', 'buddypress' ), 'error' ); … … 180 178 } 181 179 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. 183 181 bp_core_redirect( trailingslashit( bp_displayed_user_domain() . bp_get_profile_slug() . '/edit/group/' . bp_action_variable( 1 ) ) ); 184 182 } … … 205 203 * Handles the uploading and cropping of a user avatar. Displays the change avatar page. 206 204 * 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). 210 207 */ 211 208 function xprofile_screen_change_avatar() { 212 209 213 // Bail if not the correct screen 210 // Bail if not the correct screen. 214 211 if ( ! bp_is_my_profile() && ! bp_current_user_can( 'bp_moderate' ) ) { 215 212 return false; 216 213 } 217 214 218 // Bail if there are action variables 215 // Bail if there are action variables. 219 216 if ( bp_action_variables() ) { 220 217 bp_do_404(); … … 232 229 if ( !empty( $_FILES ) ) { 233 230 234 // Check the nonce 231 // Check the nonce. 235 232 check_admin_referer( 'bp_avatar_upload' ); 236 233 237 // Pass the file to the avatar upload handler 234 // Pass the file to the avatar upload handler. 238 235 if ( bp_core_avatar_handle_upload( $_FILES, 'xprofile_avatar_upload_dir' ) ) { 239 236 $bp->avatar_admin->step = 'crop-image'; 240 237 241 // Make sure we include the jQuery jCrop file for image cropping 238 // Make sure we include the jQuery jCrop file for image cropping. 242 239 add_action( 'wp_print_scripts', 'bp_core_add_jquery_cropper' ); 243 240 } 244 241 } 245 242 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. 247 244 if ( isset( $_POST['avatar-crop-submit'] ) ) { 248 245 249 // Check the nonce 246 // Check the nonce. 250 247 check_admin_referer( 'bp_avatar_cropstore' ); 251 248 … … 268 265 * @since 1.1.0 269 266 * @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'). 271 268 * 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'). 274 271 */ 275 272 do_action( 'xprofile_avatar_uploaded', (int) $args['item_id'], 'crop' ); … … 328 325 329 326 /** 330 * Show the xprofile settings template 327 * Show the xprofile settings template. 331 328 * 332 329 * @since 2.0.0 … … 334 331 function bp_xprofile_screen_settings() { 335 332 336 // Redirect if no privacy settings page is accessible 333 // Redirect if no privacy settings page is accessible. 337 334 if ( bp_action_variables() || ! bp_is_active( 'xprofile' ) ) { 338 335 bp_do_404();
Note: See TracChangeset
for help on using the changeset viewer.