Skip to:
Content

BuddyPress.org

Changeset 1868


Ignore:
Timestamp:
09/14/2009 06:27:34 PM (15 years ago)
Author:
apeatling
Message:

Added field_order support for new profile fields created.

Location:
trunk/bp-xprofile
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-xprofile/bp-xprofile-admin.php

    r1798 r1868  
    209209
    210210function xprofile_admin_manage_field( $group_id, $field_id = null ) {
    211     global $message, $groups;
     211    global $bp, $wpdb, $message, $groups;
    212212   
    213213    $field = new BP_XProfile_Field($field_id);
     
    215215
    216216    if ( isset($_POST['saveField']) ) {
    217         if ( BP_XProfile_Field::admin_validate($_POST) ) {
     217        if ( BP_XProfile_Field::admin_validate() ) {
    218218            $field->name = wp_filter_kses( $_POST['title'] );
    219219            $field->desc = wp_filter_kses( $_POST['description'] );
     
    221221            $field->type = wp_filter_kses( $_POST['fieldtype'] );
    222222            $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++;
    223225           
    224226            if ( !$field->save() ) {
  • trunk/bp-xprofile/bp-xprofile-classes.php

    r1830 r1868  
    250250        $this->is_required = apply_filters( 'xprofile_field_is_required_before_save', $this->is_required, $this->id );
    251251        $this->order_by = apply_filters( 'xprofile_field_order_by_before_save', $this->order_by, $this->id );
     252        $this->field_order = apply_filters( 'xprofile_field_field_order_before_save', $this->field_order, $this->id );
    252253
    253254        do_action( 'xprofile_field_before_save', $this );
    254255       
    255256        if ( $this->id != null )
    256             $sql = $wpdb->prepare("UPDATE {$bp->profile->table_name_fields} SET group_id = %d, parent_id = 0, type = %s, name = %s, description = %s, is_required = %d, order_by = %s WHERE id = %d", $this->group_id, $this->type, $this->name, $this->desc, $this->is_required, $this->order_by, $this->id);
     257            $sql = $wpdb->prepare("UPDATE {$bp->profile->table_name_fields} SET group_id = %d, parent_id = 0, type = %s, name = %s, description = %s, is_required = %d, order_by = %s, field_order = %d WHERE id = %d", $this->group_id, $this->type, $this->name, $this->desc, $this->is_required, $this->order_by, $this->field_order, $this->id);
    257258        else
    258             $sql = $wpdb->prepare("INSERT INTO {$bp->profile->table_name_fields} (group_id, parent_id, type, name, description, is_required, order_by) VALUES (%d, 0, %s, %s, %s, %d, %d)", $this->group_id, $this->type, $this->name, $this->desc, $this->is_required, $this->order_by);
     259            $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 );
    259260
    260261        if ( $wpdb->query($sql) ) {
     
    566567    }
    567568   
    568     /* Deprecated - Signup fields are now in the template */
    569     function get_signup_fields() {
    570         global $wpdb, $bp;
    571        
    572         $sql = $wpdb->prepare( "SELECT f.id FROM {$bp->profile->table_name_fields} AS f, {$bp->profile->table_name_groups} AS g WHERE g.name = %s AND f.parent_id = 0   AND g.id = f.group_id ORDER BY f.id", get_site_option('bp-xprofile-base-group-name') );
    573 
    574         if ( !$temp_fields = $wpdb->get_results($sql) )
    575             return false;
    576        
    577         for ( $i = 0; $i < count($temp_fields); $i++ ) {
    578             $fields[] = new BP_XProfile_Field( $temp_fields[$i]->id, null, false );
    579         }
    580        
    581         return $fields;
    582     }
    583    
    584     /* Deprecated, Validation is now done in the screen function */
    585569    function admin_validate() {
    586570        global $message;
     
    606590        }
    607591    }
     592
     593    /* Deprecated - Signup fields are now in the template */
     594    function get_signup_fields() {
     595        global $wpdb, $bp;
     596       
     597        $sql = $wpdb->prepare( "SELECT f.id FROM {$bp->profile->table_name_fields} AS f, {$bp->profile->table_name_groups} AS g WHERE g.name = %s AND f.parent_id = 0   AND g.id = f.group_id ORDER BY f.id", get_site_option('bp-xprofile-base-group-name') );
     598
     599        if ( !$temp_fields = $wpdb->get_results($sql) )
     600            return false;
     601       
     602        for ( $i = 0; $i < count($temp_fields); $i++ ) {
     603            $fields[] = new BP_XProfile_Field( $temp_fields[$i]->id, null, false );
     604        }
     605       
     606        return $fields;
     607    }
     608
    608609}
    609610
  • trunk/bp-xprofile/bp-xprofile-templatetags.php

    r1847 r1868  
    396396                        $selected = '';
    397397                    }
    398                    
    399                      
    400                    
     398
    401399                    $html .= apply_filters( 'bp_get_the_profile_field_options_select', '<option' . $selected . ' value="' . attribute_escape( $options[$k]->name ) . '">' . attribute_escape( $options[$k]->name ) . '</option>', $options[$k] );
    402400                }
Note: See TracChangeset for help on using the changeset viewer.