Ticket #2240: 2240.003.diff
File 2240.003.diff, 5.3 KB (added by , 13 years ago) |
---|
-
bp-xprofile/bp-xprofile-filters.php
100 100 if ( !isset( $field_value ) || empty( $field_value ) ) 101 101 return false; 102 102 103 if ( 'datebox' == $field_type ) 104 $field_value = bp_format_time( $field_value, true ); 105 else 103 if ( 'datebox' == $field_type ) { 104 if ( is_numeric( $field_value ) ) 105 $field_value = bp_format_time( $field_value, true ); 106 else 107 $field_value = bp_format_time( strtotime( $field_value ), true ); 108 } else { 106 109 $field_value = str_replace(']]>', ']]>', $field_value ); 110 } 107 111 108 112 return stripslashes( $field_value ); 109 113 } -
bp-xprofile/bp-xprofile-templatetags.php
457 457 458 458 case 'datebox': 459 459 460 if ( !empty( $field->data->value ) ) { 461 $day = date("j", $field->data->value); 462 $month = date("F", $field->data->value); 463 $year = date("Y", $field->data->value); 464 $default_select = ' selected="selected"'; 460 if ( !empty( $date ) ) { 461 if ( is_numeric( $date ) ) { 462 $day = date( 'j', $date ); 463 $month = date( 'F', $date ); 464 $year = date( 'Y', $date ); 465 } else { 466 $day = mysql2date( 'j', $date ); 467 $month = mysql2date( 'F', $date ); 468 $year = mysql2date( 'Y', $date ); 465 469 } 470 } 466 471 467 472 /* Check for updated posted values, but errors preventing them from being saved first time */ 468 473 if ( !empty( $_POST['field_' . $field->id . '_day'] ) ) { -
bp-xprofile.php
198 198 if ( !bp_is_my_profile() && !is_super_admin() ) 199 199 return false; 200 200 201 / * Make sure a group is set. */201 // Make sure a group is set. 202 202 if ( empty( $bp->action_variables[1] ) ) 203 203 bp_core_redirect( $bp->displayed_user->domain . BP_XPROFILE_SLUG . '/edit/group/1' ); 204 204 205 / * Check the field group exists */205 // Check the field group exists 206 206 if ( !xprofile_get_field_group( $bp->action_variables[1] ) ) 207 207 bp_core_redirect( $bp->root_domain ); 208 208 209 / * Check to see if any new information has been submitted */209 // Check to see if any new information has been submitted 210 210 if ( isset( $_POST['field_ids'] ) ) { 211 211 212 / * Check the nonce */212 // Check the nonce 213 213 check_admin_referer( 'bp_xprofile_edit' ); 214 214 215 / * Check we have field ID's */215 // Check we have field ID's 216 216 if ( empty( $_POST['field_ids'] ) ) 217 217 bp_core_redirect( $bp->displayed_user->domain . BP_XPROFILE_SLUG . '/edit/group/' . $bp->action_variables[1] . '/' ); 218 218 219 / * Explode the posted field IDs into an array so we know which fields have been submitted */219 // Explode the posted field IDs into an array so we know which fields have been submitted 220 220 $posted_field_ids = explode( ',', $_POST['field_ids'] ); 221 221 222 222 $is_required = array(); 223 223 224 / * Loop through the posted fields formatting any datebox values then validate the field */224 // Loop through the posted fields formatting any datebox values then validate the field 225 225 foreach ( (array)$posted_field_ids as $field_id ) { 226 226 if ( !isset( $_POST['field_' . $field_id] ) ) { 227 227 228 228 if ( is_numeric( $_POST['field_' . $field_id . '_day'] ) ) { 229 / * Concatenate the values. */229 // Concatenate the values. 230 230 $date_value = $_POST['field_' . $field_id . '_day'] . ' ' . 231 231 $_POST['field_' . $field_id . '_month'] . ' ' . 232 232 $_POST['field_' . $field_id . '_year']; 233 233 234 / * Turn the concatenated value into a timestamp */235 $_POST['field_' . $field_id] = strtotime( $date_value);234 // Turn the concatenated value into a timestamp 235 $_POST['field_' . $field_id] = date( 'Y-m-d H:i:s', strtotime( $date_value ) ); 236 236 } 237 237 238 238 } … … 245 245 if ( !empty( $errors ) ) 246 246 bp_core_add_message( __( 'Please make sure you fill in all required fields in this profile field group before saving.', 'buddypress' ), 'error' ); 247 247 else { 248 / * Reset the errors var */248 // Reset the errors var 249 249 $errors = false; 250 250 251 / * Now we've checked for required fields, lets save the values. */251 // Now we've checked for required fields, lets save the values. 252 252 foreach ( (array)$posted_field_ids as $field_id ) { 253 253 if ( !xprofile_set_field_data( $field_id, $bp->displayed_user->id, $_POST['field_' . $field_id], $is_required[$field_id] ) ) 254 254 $errors = true; … … 258 258 259 259 do_action( 'xprofile_updated_profile', $bp->displayed_user->id, $posted_field_ids, $errors ); 260 260 261 / * Set the feedback messages */261 // Set the feedback messages 262 262 if ( $errors ) 263 263 bp_core_add_message( __( 'There was a problem updating some of your profile information, please try again.', 'buddypress' ), 'error' ); 264 264 else 265 265 bp_core_add_message( __( 'Changes saved.', 'buddypress' ) ); 266 266 267 / * Redirect back to the edit screen to display the updates and message */267 // Redirect back to the edit screen to display the updates and message 268 268 bp_core_redirect( $bp->displayed_user->domain . BP_XPROFILE_SLUG . '/edit/group/' . $bp->action_variables[1] . '/' ); 269 269 } 270 270 }