Changeset 1907
- Timestamp:
- 09/21/2009 06:02:36 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-xprofile.php
r1905 r1907 203 203 204 204 /* Add 'Profile' to the main navigation */ 205 bp_core_new_nav_item( array( 'name' => __( 'Profile', 'buddypress'), 'slug' => $bp->profile->slug, 'position' => 20, 'screen_function' => 'xprofile_screen_display_profile', 'default_subnav_slug' => 'public', 'item_css_id' => $bp->profile->id ) );205 bp_core_new_nav_item( array( 'name' => __( 'Profile', 'buddypress' ), 'slug' => $bp->profile->slug, 'position' => 20, 'screen_function' => 'xprofile_screen_display_profile', 'default_subnav_slug' => 'public', 'item_css_id' => $bp->profile->id ) ); 206 206 207 207 $profile_link = $bp->loggedin_user->domain . $bp->profile->slug . '/'; … … 214 214 if ( $bp->current_component == $bp->profile->slug ) { 215 215 if ( bp_is_home() ) { 216 $bp->bp_options_title = __( 'My Profile', 'buddypress');216 $bp->bp_options_title = __( 'My Profile', 'buddypress' ); 217 217 } else { 218 218 $bp->bp_options_avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb' ) ); -
trunk/bp-xprofile/bp-xprofile-admin.php
r1905 r1907 220 220 $field->is_required = wp_filter_kses( $_POST['required'] ); 221 221 $field->type = wp_filter_kses( $_POST['fieldtype'] ); 222 $field->order_by = wp_filter_kses( $_POST["sort_order_$field->type"] ); 223 $field->field_order = (int) $wpdb->get_var( $wpdb->prepare( "SELECT max(field_order) FROM {$bp->profile->table_name_fields} WHERE group_id = %d", $group_id ) ); 224 $field->field_order++; 222 $field->order_by = wp_filter_kses( $_POST["sort_order_{$field->type}"] ); 223 224 $field->field_order = $wpdb->get_var( $wpdb->prepare( "SELECT field_order FROM {$bp->profile->table_name_fields} WHERE id = %d", $field_id ) ); 225 226 if ( !$field->field_order ) { 227 $field->field_order = (int) $wpdb->get_var( $wpdb->prepare( "SELECT max(field_order) FROM {$bp->profile->table_name_fields} WHERE group_id = %d", $group_id ) ); 228 $field->field_order++; 229 } 225 230 226 231 if ( !$field->save() ) { -
trunk/bp-xprofile/bp-xprofile-classes.php
r1905 r1907 232 232 global $wpdb, $bp; 233 233 234 if ( !$this->id ) 235 return false; 236 234 if ( !$this->id || 235 // Prevent deletion by url when can_delete is false. 236 !$this->can_delete || 237 // Prevent deletion of option 1 since this invalidates fields with options. 238 ( $this->parent_id && $this->option_order == 1 ) ) 239 return false; 240 237 241 if ( !$wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->profile->table_name_fields} WHERE id = %d OR parent_id = %d", $this->id, $this->id ) ) ) 238 242 return false; … … 265 269 $sql = $wpdb->prepare("INSERT INTO {$bp->profile->table_name_fields} (group_id, parent_id, type, name, description, is_required, order_by, field_order ) VALUES (%d, 0, %s, %s, %s, %d, %s, %d )", $this->group_id, $this->type, $this->name, $this->desc, $this->is_required, $this->order_by, $this->field_order ); 266 270 267 if ( $wpdb->query($sql) ) { 271 // Check for null so field options can be changed without changing any other part of the field. 272 // The described situation will return 0 here. 273 if ( $wpdb->query($sql) !== null ) { 268 274 269 275 // Only do this if we are editing an existing field … … 457 463 458 464 <?php 459 $options = $this->get_children(true); 460 465 if ( !$options = $this->get_children(true) ) { 466 $i = 1; 467 while ( isset( $_POST[$type . '_option'][$i] ) ) { 468 (array) $options[] = (object) array( 469 'id' => -1, 470 'name' => $_POST[$type . '_option'][$i], 471 'is_default_option' => ( 'multiselectbox' != $type && 472 'checkbox' != $type && 473 $_POST["isDefault_{$type}_option"] == $i ) ? 474 1 : 475 $_POST["isDefault_{$type}_option"][$i] 476 ); 477 478 $i++; 479 } 480 } 481 461 482 if ( !empty($options) ) { 462 483 for ( $i = 0; $i < count($options); $i++ ) { 463 //var_dump($options[$i]);464 484 $j = $i + 1; 465 485 … … 469 489 <p><?php _e('Option', 'buddypress') ?> <?php echo $j ?>: 470 490 <input type="text" name="<?php echo $type ?>_option[<?php echo $j ?>]" id="<?php echo $type ?>_option<?php echo $j ?>" value="<?php echo attribute_escape( $options[$i]->name ) ?>" /> 471 <input type="<?php echo $default_input ?>" name="isDefault_<?php echo $type ?>_option<?php echo $default_name; ?>" <?php if ( (int) $options[$i]->is_default_option ) {?> checked="checked"<?php } ?> " value="<?php echo $j ?>" /> <?php _e( 'Default Value', 'buddypress' ) ?> 472 <a href="admin.php?page=<?php echo BP_PLUGIN_DIR ?>/bp-xprofile.php&mode=delete_option&option_id=<?php echo $options[$i]->id ?>" class="ajax-option-delete" id="delete-<?php echo $options[$i]->id ?>">[x]</a></p> 491 <input type="<?php echo $default_input ?>" name="isDefault_<?php echo $type ?>_option<?php echo $default_name ?>" <?php if ( (int) $options[$i]->is_default_option ) {?> checked="checked"<?php } ?> " value="<?php echo $j ?>" /> <?php _e( 'Default Value', 'buddypress' ) ?> 492 <?php if ( $j != 1 && 493 $options[$i]->id != -1 ) : ?><a href="admin.php?page=<?php echo BP_PLUGIN_DIR ?>/bp-xprofile.php&mode=delete_option&option_id=<?php echo $options[$i]->id ?>" class="ajax-option-delete" id="delete-<?php echo $options[$i]->id ?>">[x]</a><?php endif ?></p> 473 494 </p> 474 495 <?php } // end for ?> … … 477 498 <?php 478 499 } else { 479 if ( 'multiselectbox' == $type || 'check xbox' == $type )500 if ( 'multiselectbox' == $type || 'checkbox' == $type ) 480 501 $default_name = '[1]'; 481 502 ?> 482 503 483 504 <p><?php _e('Option', 'buddypress') ?> 1: <input type="text" name="<?php echo $type ?>_option[1]" id="<?php echo $type ?>_option1" /> 484 <input type="<?php echo $default_input ?>" name="isDefault_<?php echo $type ?>_option<?php echo $default_name; ?>" id="isDefault_<?php echo $type ?>_option" <?php if ( (int) $options[$i]->is_default_option) {?> checked="checked"<?php } ?>" value="1" /> <?php _e( 'Default Value', 'buddypress' ) ?>505 <input type="<?php echo $default_input ?>" name="isDefault_<?php echo $type ?>_option<?php echo $default_name; ?>" id="isDefault_<?php echo $type ?>_option" <?php if ( $default_input == 'radio' ) {?> checked="checked"<?php } ?>" value="1" /> <?php _e( 'Default Value', 'buddypress' ) ?> 485 506 <input type="hidden" name="<?php echo $type ?>_option_number" id="<?php echo $type ?>_option_number" value="2" /> 486 507 … … 497 518 $title = __('Add Field', 'buddypress'); 498 519 $action = "admin.php?page=" . BP_PLUGIN_DIR . "/bp-xprofile.php&group_id=" . $this->group_id . "&mode=add_field"; 520 521 $this->name = $_POST['title']; 522 $this->desc = $_POST['description']; 523 $this->is_required = $_POST['required']; 524 $this->type = $_POST['fieldtype']; 525 $this->order_by = $_POST["sort_order_{$this->type}"]; 499 526 } else { 500 527 $title = __('Edit Field', 'buddypress'); 501 528 $action = "admin.php?page=" . BP_PLUGIN_DIR . "/bp-xprofile.php&mode=edit_field&group_id=" . $this->group_id . "&field_id=" . $this->id; 502 $options = $this->get_children();503 529 } 504 530 ?> … … 529 555 <h3><label for="description"><?php _e("Field Description", 'buddypress') ?></label></h3> 530 556 <div id="titlewrap"> 531 <textarea name="description" id="description" rows="8" cols="60"> 557 <textarea name="description" id="description" rows="8" cols="60"><?php echo htmlspecialchars( $this->desc ); ?></textarea> 532 558 </div> 533 559 </div>
Note: See TracChangeset
for help on using the changeset viewer.