Ticket #3378: 3378.01.patch
File 3378.01.patch, 6.2 KB (added by , 13 years ago) |
---|
-
bp-xprofile/bp-xprofile-template.php
function bp_the_profile_field_edit_value() { 325 325 * Check to see if the posted value is different, if it is re-display this 326 326 * value as long as it's not empty and a required field. 327 327 */ 328 if ( isset( $_POST['field_' . $field->id] ) && isset( $field->data->value ) && $field->data->value != $_POST['field_' . $field->id] ) { 328 if ( !isset( $field->data->value ) ) 329 $field->data->value = ''; 330 331 if ( isset( $_POST['field_' . $field->id] ) && ( $field->data->value != $_POST['field_' . $field->id] ) ) { 329 332 if ( !empty( $_POST['field_' . $field->id] ) ) 330 333 $field->data->value = $_POST['field_' . $field->id]; 331 334 } … … function bp_the_profile_field_options( $args = '' ) { 417 420 418 421 switch ( $field->type ) { 419 422 420 case 'selectbox': case 'multiselectbox': 421 if ( 'multiselectbox' != $field->type ) 422 $html .= '<option value="">--------</option>'; 423 case 'selectbox': 424 $html .= '<option value="">--------</option>'; 425 426 if ( !$original_option_values = maybe_unserialize( BP_XProfile_ProfileData::get_value_byid( $field->id ) ) ) 427 $original_option_values = $_POST['field_' . $field->id]; 423 428 424 $original_option_values = maybe_unserialize( BP_XProfile_ProfileData::get_value_byid( $field->id ) );425 429 $option_values = (array) $original_option_values; 426 430 427 for ( $k = 0 ; $k < count( $options ); $k++) {431 for ( $k = 0, $count = count( $options ); $k < $count; ++$k ) { 428 432 // Check for updated posted values, but errors preventing them from being saved first time 429 433 foreach( $option_values as $i => $option_value ) { 430 434 if ( isset( $_POST['field_' . $field->id] ) && $_POST['field_' . $field->id] != $option_value ) { … … function bp_the_profile_field_options( $args = '' ) { 432 436 $option_values[$i] = $_POST['field_' . $field->id]; 433 437 } 434 438 } 435 436 439 $selected = ''; 437 440 438 441 // Run the allowed option name through the before_save 439 442 // filter, so we'll be sure to get a match 440 443 $allowed_options = xprofile_sanitize_data_value_before_save( $options[$k]->name, false, false ); 441 444 442 // First, check to see whether the user-entered value 443 // matches 445 // First, check to see whether the user-entered value matches 444 446 if ( in_array( $allowed_options, (array) $option_values ) ) 445 447 $selected = ' selected="selected"'; 446 448 447 // Then, if the user has not provided a value, check for 448 // defaults 449 if ( !is_array( $original_option_values ) && empty( $option_values ) & $options[$k]->is_default_option ) 449 // Then, if the user has not provided a value, check for defaults 450 if ( !is_array( $original_option_values ) && empty( $option_values ) && $options[$k]->is_default_option ) 450 451 $selected = ' selected="selected"'; 451 452 452 453 $html .= apply_filters( 'bp_get_the_profile_field_options_select', '<option' . $selected . ' value="' . esc_attr( stripslashes( $options[$k]->name ) ) . '">' . esc_attr( stripslashes( $options[$k]->name ) ) . '</option>', $options[$k] ); 453 454 } 454 455 break; 455 456 457 case 'multiselectbox': 458 459 $original_option_values = ''; 460 if ( !$original_option_values = maybe_unserialize( BP_XProfile_ProfileData::get_value_byid( $field->id ) ) ) 461 $original_option_values = $_POST['field_' . $field->id]; 462 463 $option_values = (array) $original_option_values; 464 465 for ( $k = 0, $count = count( $options ); $k < $count; ++$k ) { 466 // Check for updated posted values, but errors preventing them from being saved first time 467 foreach( $option_values as $i => $option_value ) { 468 if ( isset( $_POST['field_' . $field->id] ) && $_POST['field_' . $field->id][$i] != $option_value ) { 469 if ( !empty( $_POST['field_' . $field->id][$i] ) ) 470 $option_values[] = $_POST['field_' . $field->id][$i]; 471 } 472 } 473 $selected = ''; 474 475 // Run the allowed option name through the before_save 476 // filter, so we'll be sure to get a match 477 $allowed_options = xprofile_sanitize_data_value_before_save( $options[$k]->name, false, false ); 478 479 // First, check to see whether the user-entered value matches 480 if ( in_array( $allowed_options, (array) $option_values ) ) 481 $selected = ' selected="selected"'; 482 483 // Then, if the user has not provided a value, check for defaults 484 if ( !is_array( $original_option_values ) && empty( $option_values ) && $options[$k]->is_default_option ) 485 $selected = ' selected="selected"'; 486 487 $html .= apply_filters( 'bp_get_the_profile_field_options_multiselect', '<option' . $selected . ' value="' . esc_attr( stripslashes( $options[$k]->name ) ) . '">' . esc_attr( stripslashes( $options[$k]->name ) ) . '</option>', $options[$k] ); 488 } 489 break; 490 456 491 case 'radio': 457 492 $html .= '<div id="field_' . $field->id . '">'; 458 493 $option_value = BP_XProfile_ProfileData::get_value_byid( $field->id ); 459 494 460 for ( $k = 0 ; $k < count( $options ); $k++) {495 for ( $k = 0, $count = count( $options ); $k < $count; ++$k ) { 461 496 // Check for updated posted values, but errors preventing them from being saved first time 462 497 if ( isset( $_POST['field_' . $field->id] ) && $option_value != $_POST['field_' . $field->id] ) { 463 498 if ( !empty( $_POST['field_' . $field->id] ) ) … … function bp_the_profile_field_options( $args = '' ) { 488 523 $option_values = $_POST['field_' . $field->id]; 489 524 } 490 525 491 for ( $k = 0 ; $k < count( $options ); $k++) {526 for ( $k = 0, $count = count( $options ); $k < $count; ++$k ) { 492 527 $selected = ''; 493 528 494 529 // First, check to see whether the user's saved values 495 530 // match the option 496 for ( $j = 0 ; $j < count( $option_values ); $j++) {531 for ( $j = 0, $count = count( $option_values ); $j < $count; ++$j ) { 497 532 498 533 // Run the allowed option name through the 499 // before_save filter, so we'll be sure to get a 500 // match 534 // before_save filter, so we'll be sure to get a match 501 535 $allowed_options = xprofile_sanitize_data_value_before_save( $options[$k]->name, false, false ); 502 536 503 537 if ( $option_values[$j] == $allowed_options || @in_array( $allowed_options, $value ) ) {