Skip to:
Content

BuddyPress.org

Changeset 2810


Ignore:
Timestamp:
03/05/2010 04:01:27 AM (16 years ago)
Author:
johnjamesjacoby
Message:

Sweep through xprofile and format code to WP standards

Location:
trunk/bp-xprofile
Files:
4 edited

Legend:

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

    r2805 r2810  
    2121
    2222        else if ( isset( $_GET['mode'] ) && isset( $_GET['group_id'] ) && isset( $_GET['field_id'] ) && 'edit_field' == $_GET['mode'] )
    23                 xprofile_admin_manage_field($_GET['group_id'], $_GET['field_id'] );
     23                xprofile_admin_manage_field( $_GET['group_id'], $_GET['field_id'] );
    2424
    2525        else if ( isset( $_GET['mode'] ) && isset( $_GET['field_id'] ) && 'delete_field' == $_GET['mode'] )
    26                 xprofile_admin_delete_field($_GET['field_id'], 'field');
     26                xprofile_admin_delete_field( $_GET['field_id'], 'field');
    2727
    2828        else if ( isset( $_GET['mode'] ) && isset( $_GET['option_id'] ) && 'delete_option' == $_GET['mode'] )
     
    4141?>
    4242        <div class="wrap">
    43                 <h2><?php _e( 'Profile Field Setup', 'buddypress') ?></h2>
    44                 <p><?php _e( 'Your users will distinguish themselves through their profile page. You must give them profile fields that allow them to describe themselves in a way that is relevant to the theme of your social network.', 'buddypress') ?></p>
     43                <h2><?php _e( 'Profile Field Setup', 'buddypress'); ?></h2>
     44                <p><?php _e( 'Your users will distinguish themselves through their profile page. You must give them profile fields that allow them to describe themselves in a way that is relevant to the theme of your social network.', 'buddypress'); ?></p>
    4545                <p><?php _e('NOTE: Any fields in the first group will appear on the signup page.', 'buddypress'); ?></p>
    4646
     
    6464                                foreach ( $groups as $group ) { ?>
    6565
    66                                                 <table id="group_<?php echo $group->id;?>" class="widefat field-group sortable">
     66                                                <table id="group_<?php echo $group->id; ?>" class="widefat field-group sortable">
    6767                                                        <thead>
    6868                                                                <tr class="grabber">
    69                                                                         <th scope="col" width="10"><img src="<?php echo BP_PLUGIN_URL ?>/bp-xprofile/admin/images/move.gif" alt="<?php _e( 'Drag', 'buddypress' ) ?>" /></th>
     69                                                                        <th scope="col" width="10"><img src="<?php echo BP_PLUGIN_URL; ?>/bp-xprofile/admin/images/move.gif" alt="<?php _e( 'Drag', 'buddypress' ); ?>" /></th>
    7070                                                                        <th scope="col" colspan="3"><?php echo attribute_escape( $group->name ); ?></th>
    7171<?php
    7272                                                                        if ( $group->can_delete ) :
    7373?>
    74                                                                                 <th scope="col" class="center"><a class="edit" href="admin.php?page=bp-profile-setup&amp;mode=edit_group&amp;group_id=<?php echo attribute_escape( $group->id ); ?>"><?php _e( 'Edit', 'buddypress' ) ?></a></th>
    75                                                                         <th scope="col" class="center"><a class="delete" href="admin.php?page=bp-profile-setup&amp;mode=delete_group&amp;group_id=<?php echo attribute_escape( $group->id ); ?>"><?php _e( 'Delete', 'buddypress' ) ?></a></th>
     74                                                                                <th scope="col" class="center"><a class="edit" href="admin.php?page=bp-profile-setup&amp;mode=edit_group&amp;group_id=<?php echo attribute_escape( $group->id ); ?>"><?php _e( 'Edit', 'buddypress' ); ?></a></th>
     75                                                                        <th scope="col" class="center"><a class="delete" href="admin.php?page=bp-profile-setup&amp;mode=delete_group&amp;group_id=<?php echo attribute_escape( $group->id ); ?>"><?php _e( 'Delete', 'buddypress' ); ?></a></th>
    7676<?php
    7777                                                                        else :
    7878?>
    79                                                                                 <th scope="col" class="center"><a class="edit" href="admin.php?page=bp-general-settings"><?php _e( 'Edit', 'buddypress' ) ?></a></th>
     79                                                                                <th scope="col" class="center"><a class="edit" href="admin.php?page=bp-general-settings"><?php _e( 'Edit', 'buddypress' ); ?></a></th>
    8080                                                                                <th scope="col" class="center">&nbsp;</th>
    8181<?php
     
    8686                                                                <tr class="header">
    8787                                                                        <td>&nbsp;</td>
    88                                                                         <td><?php _e( 'Field Name', 'buddypress' ) ?></td>
    89                                                                         <td width="14%"><?php _e( 'Field Type', 'buddypress' ) ?></td>
    90                                                                         <td width="6%" class="center"><?php _e( 'Required?', 'buddypress' ) ?></td>
    91                                                                         <td colspan="2" width="10%" class="center"><?php _e( 'Actions', 'buddypress' ) ?></td>
     88                                                                        <td><?php _e( 'Field Name', 'buddypress' ); ?></td>
     89                                                                        <td width="14%"><?php _e( 'Field Type', 'buddypress' ); ?></td>
     90                                                                        <td width="6%" class="center"><?php _e( 'Required?', 'buddypress' ); ?></td>
     91                                                                        <td colspan="2" width="10%" class="center"><?php _e( 'Actions', 'buddypress' ); ?></td>
    9292                                                                </tr>
    9393                                                        </thead>
     
    9595                                                        <tfoot>
    9696                                                                <tr class="nodrag">
    97                                                                         <td colspan="6"><a href="admin.php?page=bp-profile-setup&amp;group_id=<?php echo attribute_escape( $group->id ); ?>&amp;mode=add_field"><?php _e( 'Add New Field', 'buddypress' ) ?></a></td>
     97                                                                        <td colspan="6"><a href="admin.php?page=bp-profile-setup&amp;group_id=<?php echo attribute_escape( $group->id ); ?>&amp;mode=add_field"><?php _e( 'Add New Field', 'buddypress' ); ?></a></td>
    9898                                                                </tr>
    9999                                                        </tfoot>
    100100
    101                                                         <tbody id="<?php echo $group->id;?>">
     101                                                        <tbody id="<?php echo $group->id ?>">
    102102 <?php
    103103                                                                if ( $group->fields ) :
     
    114114
    115115                                                                                <tr id="field_<?php echo attribute_escape( $field->id ); ?>" class="sortable<?php if ( $class ) { echo ' ' . $class; } ?>">
    116                                                                                         <td width="10"><img src="<?php echo BP_PLUGIN_URL ?>/bp-xprofile/admin/images/move.gif" alt="<?php _e( 'Drag', 'buddypress' ) ?>" /></td>
    117                                                                                         <td><span title="<?php echo $field->description; ?>"><?php echo attribute_escape( $field->name ); ?> <?php if(!$field->can_delete) { ?> <?php _e( '(Core Field)', 'buddypress' ) ?><?php } ?></span></td>
     116                                                                                        <td width="10"><img src="<?php echo BP_PLUGIN_URL; ?>/bp-xprofile/admin/images/move.gif" alt="<?php _e( 'Drag', 'buddypress' ); ?>" /></td>
     117                                                                                        <td><span title="<?php echo $field->description; ?>"><?php echo attribute_escape( $field->name ); ?> <?php if(!$field->can_delete) { ?> <?php _e( '(Core Field)', 'buddypress' ); } ?></span></td>
    118118                                                                                        <td><?php echo attribute_escape( $field->type ); ?></td>
    119119                                                                                        <td class="center"><?php if ( $field->is_required ) { echo '<img src="' . BP_PLUGIN_URL . '/bp-xprofile/admin/images/tick.gif" alt="' . __( 'Yes', 'buddypress' ) . '" />'; } else { ?>-<?php } ?></td>
    120                                                                                         <td class="center"><a class="edit" href="<?php if ( !$field->can_delete ) { ?>admin.php?page=bp-general-settings<?php } else { ?>admin.php?page=bp-profile-setup&amp;group_id=<?php echo attribute_escape( $group->id ); ?>&amp;field_id=<?php echo attribute_escape( $field->id ); ?>&amp;mode=edit_field<?php } ?>"><?php _e( 'Edit', 'buddypress' ) ?></a></td>
    121                                                                                         <td class="center"><?php if ( !$field->can_delete ) { ?>&nbsp;<?php } else { ?><a class="delete" href="admin.php?page=bp-profile-setup&amp;field_id=<?php echo attribute_escape( $field->id ); ?>&amp;mode=delete_field"><?php _e( 'Delete', 'buddypress' ) ?></a><?php } ?></td>
     120                                                                                        <td class="center"><a class="edit" href="<?php if ( !$field->can_delete ) { ?>admin.php?page=bp-general-settings<?php } else { ?>admin.php?page=bp-profile-setup&amp;group_id=<?php echo attribute_escape( $group->id ); ?>&amp;field_id=<?php echo attribute_escape( $field->id ); ?>&amp;mode=edit_field<?php } ?>"><?php _e( 'Edit', 'buddypress' ); ?></a></td>
     121                                                                                        <td class="center"><?php if ( !$field->can_delete ) { ?>&nbsp;<?php } else { ?><a class="delete" href="admin.php?page=bp-profile-setup&amp;field_id=<?php echo attribute_escape( $field->id ); ?>&amp;mode=delete_field"><?php _e( 'Delete', 'buddypress' ); ?></a><?php } ?></td>
    122122                                                                                </tr>
    123123<?php
     
    128128
    129129                                                                        <tr class="nodrag">
    130                                                                                 <td colspan="6"><?php _e( 'There are no fields in this group.', 'buddypress' ) ?></td>
     130                                                                                <td colspan="6"><?php _e( 'There are no fields in this group.', 'buddypress' ); ?></td>
    131131                                                                        </tr>
    132132<?php
     
    140140                                        </div>
    141141                                        <p>
    142                                                 <a class="button" href="admin.php?page=bp-profile-setup&amp;mode=add_group"><?php _e( 'Add New Field Group', 'buddypress' ) ?></a>
     142                                                <a class="button" href="admin.php?page=bp-profile-setup&amp;mode=add_group"><?php _e( 'Add New Field Group', 'buddypress' ); ?></a>
    143143                                        </p>
    144144<?php
     
    147147
    148148                                <div id="message" class="error"><p><?php _e('You have no groups.', 'buddypress' ); ?></p></div>
    149                                 <p><a href="admin.php?page=bp-profile-setup&amp;mode=add_group"><?php _e( 'Add New Group', 'buddypress' ) ?></a></p>
     149                                <p><a href="admin.php?page=bp-profile-setup&amp;mode=add_group"><?php _e( 'Add New Group', 'buddypress' ); ?></a></p>
    150150<?php
    151151                                endif;
     
    167167        global $message, $type;
    168168
    169         $group = new BP_XProfile_Group($group_id);
    170 
    171         if ( isset($_POST['saveGroup']) ) {
    172                 if ( BP_XProfile_Group::admin_validate($_POST) ) {
     169        $group = new BP_XProfile_Group( $group_id );
     170
     171        if ( isset( $_POST['saveGroup'] ) ) {
     172                if ( BP_XProfile_Group::admin_validate( $_POST ) ) {
    173173                        $group->name = wp_filter_kses( $_POST['group_name'] );
    174174                        $group->description = wp_filter_kses( $_POST['group_desc'] );
    175175
    176176                        if ( !$group->save() ) {
    177                                 $message = __('There was an error saving the group. Please try again', 'buddypress');
     177                                $message = __( 'There was an error saving the group. Please try again', 'buddypress' );
    178178                                $type = 'error';
    179179                        } else {
    180                                 $message = __('The group was saved successfully.', 'buddypress');
     180                                $message = __( 'The group was saved successfully.', 'buddypress' );
    181181                                $type = 'success';
    182182
     
    184184                        }
    185185
    186                         unset($_GET['mode']);
     186                        unset( $_GET['mode'] );
    187187                        xprofile_admin( $message, $type );
    188188
    189189                } else {
    190                         $group->render_admin_form($message);
     190                        $group->render_admin_form( $message );
    191191                }
    192192        } else {
     
    230230        global $bp, $wpdb, $message, $groups;
    231231
    232         $field = new BP_XProfile_Field($field_id);
     232        $field = new BP_XProfile_Field( $field_id );
    233233        $field->group_id = $group_id;
    234234
    235         if ( isset($_POST['saveField']) ) {
     235        if ( isset( $_POST['saveField'] ) ) {
    236236                if ( BP_XProfile_Field::admin_validate() ) {
    237237                        $field->name = wp_filter_kses( $_POST['title'] );
     
    249249
    250250                        if ( !$field->save() ) {
    251                                 $message = __('There was an error saving the field. Please try again', 'buddypress');
     251                                $message = __( 'There was an error saving the field. Please try again', 'buddypress' );
    252252                                $type = 'error';
    253253
    254                                 unset($_GET['mode']);
    255                                 xprofile_admin($message, $type);
     254                                unset( $_GET['mode'] );
     255                                xprofile_admin( $message, $type );
    256256                        } else {
    257                                 $message = __('The field was saved successfully.', 'buddypress');
     257                                $message = __( 'The field was saved successfully.', 'buddypress' );
    258258                                $type = 'success';
    259259
    260                                 unset($_GET['mode']);
     260                                unset( $_GET['mode'] );
    261261
    262262                                do_action( 'xprofile_fields_saved_field', $field );
     
    266266                        }
    267267                } else {
    268                         $field->render_admin_form($message);
     268                        $field->render_admin_form( $message );
    269269                }
    270270        } else {
     
    282282        global $message, $type;
    283283
    284         if ( 'field' == $type ) {
     284        if ( 'field' == $type )
    285285                $type = __('field', 'buddypress');
    286         } else {
     286        else
    287287                $type = __('option', 'buddypress');
    288         }
    289 
    290         $field = new BP_XProfile_Field($field_id);
     288
     289        $field = new BP_XProfile_Field( $field_id );
    291290
    292291        if ( !$field->delete() ) {
    293                 $message = sprintf( __('There was an error deleting the %s. Please try again', 'buddypress'), $type);
     292                $message = sprintf( __('There was an error deleting the %s. Please try again', 'buddypress' ), $type );
    294293                $type = 'error';
    295294        } else {
    296                 $message = sprintf( __('The %s was deleted successfully!', 'buddypress'), $type);
     295                $message = sprintf( __('The %s was deleted successfully!', 'buddypress' ), $type );
    297296                $type = 'success';
    298297
     
    300299        }
    301300
    302         unset($_GET['mode']);
    303         xprofile_admin($message, $type);
     301        unset( $_GET['mode'] );
     302        xprofile_admin( $message, $type );
    304303}
    305304
  • trunk/bp-xprofile/bp-xprofile-classes.php

    r2809 r2810  
    2121                $sql = $wpdb->prepare( "SELECT * FROM {$bp->profile->table_name_groups} WHERE id = %d", $id );
    2222
    23                 if ( !$group = $wpdb->get_row($sql) )
     23                if ( !$group = $wpdb->get_row( $sql ) )
    2424                        return false;
    2525
     
    3838                do_action( 'xprofile_group_before_save', $this );
    3939
    40                 if ( $this->id ) {
     40                if ( $this->id )
    4141                        $sql = $wpdb->prepare( "UPDATE {$bp->profile->table_name_groups} SET name = %s, description = %s WHERE id = %d", $this->name, $this->description, $this->id );
    42                 } else {
     42                else
    4343                        $sql = $wpdb->prepare( "INSERT INTO {$bp->profile->table_name_groups} (name, description, can_delete) VALUES (%s, %s, 1)", $this->name, $this->description );
    44                 }
    4544
    4645                if ( !$wpdb->query($sql) )
     
    6867                        if ( BP_XProfile_Field::delete_for_group( $this->id ) ) {
    6968                                /* Remove profile data for the groups fields */
    70                                 for ( $i = 0; $i < count( $this->fields ); $i++ )
     69                                for ( $i = 0; $i < count( $this->fields ); $i++ ) {
    7170                                        BP_XProfile_ProfileData::delete_for_field( $this->fields[$i]->id );
    72 
     71                                }
    7372                        }
    7473
     
    105104
    106105                /* Get the group ids */
    107                 foreach( (array)$groups as $group )
     106                foreach( (array)$groups as $group ) {
    108107                        $group_ids[] = $group->id;
     108                }
    109109
    110110                $group_ids = implode( ',', (array) $group_ids );
     
    121121                if ( $fetch_field_data ) {
    122122                        /* Fetch the field data for the user. */
    123                         foreach( (array)$fields as $field )
     123                        foreach( (array)$fields as $field ) {
    124124                                $field_ids[] = $field->id;
     125                        }
    125126
    126127                        $field_ids = implode( ',', (array) $field_ids );
     
    155156                /* Validate Form */
    156157                if ( empty( $_POST['group_name'] ) ) {
    157                         $message = __('Please make sure you give the group a name.', 'buddypress');
     158                        $message = __( 'Please make sure you give the group a name.', 'buddypress' );
    158159                        return false;
    159160                } else {
     
    187188
    188189                        <h2><?php echo $title; ?></h2>
    189                         <br />
    190 
    191                         <?php
     190<?php
    192191                                if ( $message != '' ) {
    193192                                        $type = ( 'error' == $type ) ? 'error' : 'updated';
    194                         ?>
     193?>
     194
    195195                                <div id="message" class="<?php echo $type; ?> fade">
    196196                                        <p><?php echo $message; ?></p>
    197197                                </div>
    198                         <?php } ?>
     198<?php } ?>
    199199
    200200                        <form action="<?php echo attribute_escape( $action ); ?>" method="post">
    201 
    202201                                <div id="titlediv">
    203202                                        <label for="group_name"><?php _e( "Field Group Name", 'buddypress') ?></label>
    204203                                        <div>
    205                                                 <input type="text" name="group_name" id="group_name" value="<?php echo attribute_escape( $this->name ) ?>" style="width:50%" />
     204                                                <input type="text" name="group_name" id="group_name" value="<?php echo attribute_escape( $this->name ); ?>" style="width:50%" />
    206205                                        </div>
    207206                                </div>
     
    210209                                        <input type="submit" name="saveGroup" value="<?php echo attribute_escape( $title ); ?> &rarr;" />
    211210                                </p>
    212 
    213211                        </form>
    214212                </div>
    215 
    216213<?php
    217214        }
     
    265262
    266263                        if ( $get_data )
    267                                 $this->data = $this->get_field_data($user_id);
     264                                $this->data = $this->get_field_data( $user_id );
    268265
    269266                }
     
    306303
    307304                if ( $this->id != null )
    308                         $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->description, $this->is_required, $this->order_by, $this->field_order, $this->id);
     305                        $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->description, $this->is_required, $this->order_by, $this->field_order, $this->id );
    309306                else
    310307                        $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->description, $this->is_required, $this->order_by, $this->field_order );
     
    417414                $sql = $wpdb->prepare( "SELECT * FROM {$bp->profile->table_name_fields} WHERE parent_id = %d AND group_id = %d $sort_sql", $parent_id, $this->group_id );
    418415
    419                 if ( !$children = $wpdb->get_results($sql) )
     416                if ( !$children = $wpdb->get_results( $sql ) )
    420417                        return false;
    421418
     
    426423                global $wpdb, $bp;
    427424
    428                 $sql = $wpdb->prepare("DELETE FROM {$bp->profile->table_name_fields} WHERE parent_id = %d", $this->id);
    429 
    430                 $wpdb->query($sql);
     425                $sql = $wpdb->prepare( "DELETE FROM {$bp->profile->table_name_fields} WHERE parent_id = %d", $this->id );
     426
     427                $wpdb->query( $sql );
    431428        }
    432429
     
    454451                        $sql = $wpdb->prepare( "DELETE FROM {$bp->profile->table_name_fields} WHERE group_id = %d", $group_id );
    455452
    456                         if ( $wpdb->get_var($sql) === false )
     453                        if ( $wpdb->get_var( $sql ) === false )
    457454                                return false;
    458455
     
    503500                                $default_input = 'radio';
    504501?>
    505                         <div id="<?php echo $type ?>" class="options-box" style="<?php if ( $this->type != $type ) { ?>display: none;<?php } ?> margin-left: 15px;">
    506                                 <h4><?php _e('Please enter options for this Field:', 'buddypress') ?></h4>
    507                                 <p><?php _e( 'Order By:', 'buddypress' ) ?>
    508                                         <select name="sort_order_<?php echo $type ?>" id="sort_order_<?php echo $type ?>" >
    509                                                 <option value="default" <?php if ( 'default' == $this->order_by ) {?> selected="selected"<?php } ?> ><?php _e( 'Order Entered', 'buddypress' ) ?></option>
    510                                                 <option value="asc" <?php if ( 'asc' == $this->order_by ) {?> selected="selected"<?php } ?>><?php _e( 'Name - Ascending', 'buddypress' ) ?></option>
    511                                                 <option value="desc" <?php if ( 'desc' == $this->order_by ) {?> selected="selected"<?php } ?>><?php _e( 'Name - Descending', 'buddypress' ) ?></option>
     502                        <div id="<?php echo $type; ?>" class="options-box" style="<?php if ( $this->type != $type ) { ?>display: none;<?php } ?> margin-left: 15px;">
     503                                <h4><?php _e('Please enter options for this Field:', 'buddypress'); ?></h4>
     504                                <p><?php _e( 'Order By:', 'buddypress' ); ?>
     505                                        <select name="sort_order_<?php echo $type; ?>" id="sort_order_<?php echo $type; ?>" >
     506                                                <option value="default" <?php if ( 'default' == $this->order_by ) {?> selected="selected"<?php } ?> ><?php _e( 'Order Entered', 'buddypress' ); ?></option>
     507                                                <option value="asc" <?php if ( 'asc' == $this->order_by ) {?> selected="selected"<?php } ?>><?php _e( 'Name - Ascending', 'buddypress' ); ?></option>
     508                                                <option value="desc" <?php if ( 'desc' == $this->order_by ) {?> selected="selected"<?php } ?>><?php _e( 'Name - Descending', 'buddypress' ); ?></option>
    512509                                        </select>
    513510<?php
    514                                 if ( !$options = $this->get_children(true) ) {
     511                                if ( !$options = $this->get_children( true ) ) {
    515512                                        $i = 1;
    516513                                        while ( isset( $_POST[$type . '_option'][$i] ) ) {
     
    530527
    531528                                if ( !empty( $options ) ) {
    532                                         for ( $i = 0; $i < count($options); $i++ ) {
     529                                        for ( $i = 0; $i < count( $options ); $i++ ) {
    533530                                                $j = $i + 1;
    534531
    535532                                                if ( 'multiselectbox' == $type || 'checkbox' == $type )
    536533                                                        $default_name = '[' . $j . ']';
    537                                                 ?>
    538                                                 <p><?php _e('Option', 'buddypress') ?> <?php echo $j ?>:
    539                                                    <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 ) ?>" />
    540                                                    <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' ) ?>
     534?>
     535                                                <p><?php _e('Option', 'buddypress'); ?> <?php echo $j; ?>:
     536                                                   <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 ); ?>" />
     537                                                   <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' ); ?>
    541538                                                        <?php if ( $j != 1 &&
    542                                                                 $options[$i]->id != -1 ) : ?><a href="admin.php?page=bp-profile-setup&amp;mode=delete_option&amp;option_id=<?php echo $options[$i]->id ?>" class="ajax-option-delete" id="delete-<?php echo $options[$i]->id ?>">[x]</a><?php endif ?></p>
     539                                                                $options[$i]->id != -1 ) : ?><a href="admin.php?page=bp-profile-setup&amp;mode=delete_option&amp;option_id=<?php echo $options[$i]->id ?>" class="ajax-option-delete" id="delete-<?php echo $options[$i]->id; ?>">[x]</a><?php endif; ?></p>
    543540                                                </p>
    544                                         <?php } /* end for */ ?>
    545                                         <input type="hidden" name="<?php echo $type ?>_option_number" id="<?php echo $type ?>_option_number" value="<?php echo $j + 1 ?>" />
    546 
    547                                 <?php
     541<?php                           } /* end for */ ?>
     542
     543                                        <input type="hidden" name="<?php echo $type; ?>_option_number" id="<?php echo $type; ?>_option_number" value="<?php echo $j + 1; ?>" />
     544<?php
    548545                                } else {
    549546                                        if ( 'multiselectbox' == $type || 'checkbox' == $type )
    550547                                                $default_name = '[1]';
    551                                 ?>
    552 
    553                                         <p><?php _e('Option', 'buddypress') ?> 1: <input type="text" name="<?php echo $type ?>_option[1]" id="<?php echo $type ?>_option1" />
    554                                         <input type="<?php echo $default_input ?>" name="isDefault_<?php echo $type ?>_option<?php echo $default_name; ?>" id="isDefault_<?php echo $type ?>_option" value="1" /> <?php _e( 'Default Value', 'buddypress' ) ?>
    555                                         <input type="hidden" name="<?php echo $type ?>_option_number" id="<?php echo $type ?>_option_number" value="2" />
    556 
    557                                 <?php } /* end if */ ?>
    558                                 <div id="<?php echo $type ?>_more"></div>
    559                                 <p><a href="javascript:add_option('<?php echo $type ?>')"><?php _e('Add Another Option', 'buddypress') ?></a></p>
     548?>
     549
     550                                        <p><?php _e( 'Option', 'buddypress' ); ?> 1: <input type="text" name="<?php echo $type; ?>_option[1]" id="<?php echo $type; ?>_option1" />
     551                                        <input type="<?php echo $default_input; ?>" name="isDefault_<?php echo $type; ?>_option<?php echo $default_name; ?>" id="isDefault_<?php echo $type; ?>_option" value="1" /> <?php _e( 'Default Value', 'buddypress' ); ?>
     552                                        <input type="hidden" name="<?php echo $type; ?>_option_number" id="<?php echo $type; ?>_option_number" value="2" />
     553
     554<?php                   } /* end if */ ?>
     555
     556                                <div id="<?php echo $type; ?>_more"></div>
     557                                <p><a href="javascript:add_option('<?php echo $type; ?>')"><?php _e('Add Another Option', 'buddypress'); ?></a></p>
    560558                        </div>
    561559
     
    565563        function render_admin_form( $message = '' ) {
    566564                if ( !$this->id ) {
    567                         $title                          = __('Add Field', 'buddypress');
     565                        $title                          = __( 'Add Field', 'buddypress' );
    568566                        $action                         = "admin.php?page=bp-profile-setup&amp;group_id=" . $this->group_id . "&amp;mode=add_field";
    569567
     
    574572                        $this->order_by         = $_POST["sort_order_{$this->type}"];
    575573                } else {
    576                         $title                          = __('Edit Field', 'buddypress');
     574                        $title                          = __( 'Edit Field', 'buddypress' );
    577575                        $action                         = "admin.php?page=bp-profile-setup&amp;mode=edit_field&amp;group_id=" . $this->group_id . "&amp;field_id=" . $this->id;
    578576                }
     
    580578
    581579        <div class="wrap">
    582 
    583580                <h2><?php echo $title; ?></h2>
    584                 <br />
    585 
    586                 <?php
     581<?php
    587582                        if ( $message != '' ) {
    588                 ?>
     583?>
     584
    589585                        <div id="message" class="error fade">
    590586                                <p><?php echo $message; ?></p>
    591587                        </div>
    592                 <?php } ?>
    593 
    594                 <form action="<?php echo $action ?>" method="post">
     588<?php } ?>
     589
     590                <form action="<?php echo $action; ?>" method="post">
    595591                        <div id="poststuff">
    596592                                <div id="titlediv">
    597                                         <h3><label for="title"><?php _e("Field Title", 'buddypress') ?> *</label></h3>
     593                                        <h3><label for="title"><?php _e( 'Field Title', 'buddypress' ); ?> *</label></h3>
    598594                                        <div id="titlewrap">
    599                                                 <input type="text" name="title" id="title" value="<?php echo attribute_escape( $this->name ) ?>" style="width:50%" />
     595                                                <input type="text" name="title" id="title" value="<?php echo attribute_escape( $this->name ); ?>" style="width:50%" />
    600596                                        </div>
    601597                                </div>
    602598
    603599                                <div id="titlediv" class="inside">
    604                                         <h3><label for="description"><?php _e("Field Description", 'buddypress') ?></label></h3>
     600                                        <h3><label for="description"><?php _e("Field Description", 'buddypress'); ?></label></h3>
    605601                                        <div id="titlewrap">
    606602                                                <textarea name="description" id="description" rows="8" cols="60"><?php echo htmlspecialchars( $this->description ); ?></textarea>
     
    609605
    610606                                <div id="titlediv">
    611                                         <h3><label for="required"><?php _e("Is This Field Required?", 'buddypress') ?> *</label></h3>
     607                                        <h3><label for="required"><?php _e( "Is This Field Required?", 'buddypress' ); ?> *</label></h3>
    612608                                        <select name="required" id="required" style="width: 30%">
    613                                                 <option value="0"<?php if ( $this->is_required == '0' ) { ?> selected="selected"<?php } ?>><?php _e( 'Not Required', 'buddypress' ) ?></option>
    614                                                 <option value="1"<?php if ( $this->is_required == '1' ) { ?> selected="selected"<?php } ?>><?php _e( 'Required', 'buddypress' ) ?></option>
     609                                                <option value="0"<?php if ( $this->is_required == '0' ) { ?> selected="selected"<?php } ?>><?php _e( 'Not Required', 'buddypress' ); ?></option>
     610                                                <option value="1"<?php if ( $this->is_required == '1' ) { ?> selected="selected"<?php } ?>><?php _e( 'Required', 'buddypress' ); ?></option>
    615611                                        </select>
    616612                                </div>
    617613
    618614                                <div id="titlediv">
    619                                         <h3><label for="fieldtype"><?php _e("Field Type", 'buddypress') ?> *</label></h3>
     615                                        <h3><label for="fieldtype"><?php _e("Field Type", 'buddypress'); ?> *</label></h3>
    620616                                        <select name="fieldtype" id="fieldtype" onchange="show_options(this.value)" style="width: 30%">
    621                                                 <option value="textbox"<?php if ( $this->type == 'textbox' ) {?> selected="selected"<?php } ?>><?php _e( 'Text Box', 'buddypress' ) ?></option>
    622                                                 <option value="textarea"<?php if ( $this->type == 'textarea' ) {?> selected="selected"<?php } ?>><?php _e( 'Multi-line Text Box', 'buddypress' ) ?></option>
    623                                                 <option value="datebox"<?php if ( $this->type == 'datebox' ) {?> selected="selected"<?php } ?>><?php _e( 'Date Selector', 'buddypress' ) ?></option>
    624                                                 <option value="radio"<?php if ( $this->type == 'radio' ) {?> selected="selected"<?php } ?>><?php _e( 'Radio Buttons', 'buddypress' ) ?></option>
    625                                                 <option value="selectbox"<?php if ( $this->type == 'selectbox' ) {?> selected="selected"<?php } ?>><?php _e( 'Drop Down Select Box', 'buddypress' ) ?></option>
    626                                                 <option value="multiselectbox"<?php if ( $this->type == 'multiselectbox' ) {?> selected="selected"<?php } ?>><?php _e( 'Multi Select Box', 'buddypress' ) ?></option>
    627                                                 <option value="checkbox"<?php if ( $this->type == 'checkbox' ) {?> selected="selected"<?php } ?>><?php _e( 'Checkboxes', 'buddypress' ) ?></option>
     617                                                <option value="textbox"<?php if ( $this->type == 'textbox' ) {?> selected="selected"<?php } ?>><?php _e( 'Text Box', 'buddypress' ); ?></option>
     618                                                <option value="textarea"<?php if ( $this->type == 'textarea' ) {?> selected="selected"<?php } ?>><?php _e( 'Multi-line Text Box', 'buddypress' ); ?></option>
     619                                                <option value="datebox"<?php if ( $this->type == 'datebox' ) {?> selected="selected"<?php } ?>><?php _e( 'Date Selector', 'buddypress' ); ?></option>
     620                                                <option value="radio"<?php if ( $this->type == 'radio' ) {?> selected="selected"<?php } ?>><?php _e( 'Radio Buttons', 'buddypress' ); ?></option>
     621                                                <option value="selectbox"<?php if ( $this->type == 'selectbox' ) {?> selected="selected"<?php } ?>><?php _e( 'Drop Down Select Box', 'buddypress' ); ?></option>
     622                                                <option value="multiselectbox"<?php if ( $this->type == 'multiselectbox' ) {?> selected="selected"<?php } ?>><?php _e( 'Multi Select Box', 'buddypress' ); ?></option>
     623                                                <option value="checkbox"<?php if ( $this->type == 'checkbox' ) {?> selected="selected"<?php } ?>><?php _e( 'Checkboxes', 'buddypress' ); ?></option>
    628624                                        </select>
    629625                                </div>
    630626
    631                                 <?php $this->render_admin_form_children() ?>
     627                                <?php $this->render_admin_form_children(); ?>
    632628
    633629                                <p class="submit">
    634                                         &nbsp;<input type="submit" value="<?php _e("Save", 'buddypress') ?> &rarr;" name="saveField" id="saveField" style="font-weight: bold" />
    635                                          <?php _e('or', 'buddypress') ?> <a href="admin.php?page=bp-profile-setup" style="color: red"><?php _e( 'Cancel', 'buddypress' ) ?></a>
     630                                        &nbsp;<input type="submit" value="<?php _e( 'Save', 'buddypress' ); ?> &rarr;" name="saveField" id="saveField" style="font-weight: bold" />
     631                                         <?php _e( 'or', 'buddypress' ); ?> <a href="admin.php?page=bp-profile-setup" style="color: red"><?php _e( 'Cancel', 'buddypress' ); ?></a>
    636632                                </p>
    637633
     
    655651                        $message = __( 'Please make sure you fill out all required fields.', 'buddypress' );
    656652                        return false;
    657                 } else if ( empty($_POST['field_file']) && $_POST['fieldtype'] == 'radio' && empty($_POST['radio_option'][1]) ) {
     653                } else if ( empty( $_POST['field_file'] ) && $_POST['fieldtype'] == 'radio' && empty( $_POST['radio_option'][1] ) ) {
    658654                        $message = __( 'Radio button field types require at least one option. Please add options below.', 'buddypress' );
    659655                        return false;
    660                 } else if ( empty($_POST['field_file']) && $_POST['fieldtype'] == 'selectbox' && empty($_POST['selectbox_option'][1]) ) {
     656                } else if ( empty( $_POST['field_file'] ) && $_POST['fieldtype'] == 'selectbox' && empty( $_POST['selectbox_option'][1] ) ) {
    661657                        $message = __( 'Select box field types require at least one option. Please add options below.', 'buddypress' );
    662658                        return false;
    663                 } else if ( empty($_POST['field_file']) && $_POST['fieldtype'] == 'multiselectbox' && empty($_POST['multiselectbox_option'][1]) ) {
     659                } else if ( empty( $_POST['field_file'] ) && $_POST['fieldtype'] == 'multiselectbox' && empty( $_POST['multiselectbox_option'][1] ) ) {
    664660                        $message = __( 'Select box field types require at least one option. Please add options below.', 'buddypress' );
    665661                        return false;
    666                 } else if ( empty($_POST['field_file']) && $_POST['fieldtype'] == 'checkbox' && empty($_POST['checkbox_option'][1]) ) {
     662                } else if ( empty( $_POST['field_file'] ) && $_POST['fieldtype'] == 'checkbox' && empty( $_POST['checkbox_option'][1] ) ) {
    667663                        $message = __( 'Checkbox field types require at least one option. Please add options below.', 'buddypress' );
    668664                        return false;
     
    692688
    693689                if ( $profiledata = $wpdb->get_row( $sql ) ) {
    694                         $this->id = $profiledata->id;
    695                         $this->user_id = $profiledata->user_id;
    696                         $this->field_id = $profiledata->field_id;
    697                         $this->value = stripslashes($profiledata->value);
    698                         $this->last_updated = $profiledata->last_updated;
     690                        $this->id                       = $profiledata->id;
     691                        $this->user_id          = $profiledata->user_id;
     692                        $this->field_id         = $profiledata->field_id;
     693                        $this->value            = stripslashes( $profiledata->value );
     694                        $this->last_updated     = $profiledata->last_updated;
    699695                }
    700696        }
     
    727723                global $wpdb, $bp;
    728724
    729                 $this->user_id = apply_filters( 'xprofile_data_user_id_before_save', $this->user_id, $this->id );
    730                 $this->field_id = apply_filters( 'xprofile_data_field_id_before_save', $this->field_id, $this->id );
    731                 $this->value = apply_filters( 'xprofile_data_value_before_save', $this->value, $this->id );
    732                 $this->last_updated = apply_filters( 'xprofile_data_last_updated_before_save', date( 'Y-m-d H:i:s' ), $this->id );
     725                $this->user_id          = apply_filters( 'xprofile_data_user_id_before_save', $this->user_id, $this->id );
     726                $this->field_id         = apply_filters( 'xprofile_data_field_id_before_save', $this->field_id, $this->id );
     727                $this->value            = apply_filters( 'xprofile_data_value_before_save', $this->value, $this->id );
     728                $this->last_updated     = apply_filters( 'xprofile_data_last_updated_before_save', date( 'Y-m-d H:i:s' ), $this->id );
    733729
    734730                do_action( 'xprofile_data_before_save', $this );
     
    778774
    779775                if ( $results ) {
    780                         $profile_data['user_login'] = $results[0]->user_login;
    781                         $profile_data['user_nicename'] = $results[0]->user_nicename;
    782                         $profile_data['user_email'] = $results[0]->user_email;
     776                        $profile_data['user_login']             = $results[0]->user_login;
     777                        $profile_data['user_nicename']  = $results[0]->user_nicename;
     778                        $profile_data['user_email']             = $results[0]->user_email;
    783779
    784780                        foreach( (array) $results as $field ) {
    785781                                $profile_data[$field->field_name] = array(
    786                                         'field_group_id' => $field->field_group_id,
    787                                         'field_group_name' => $field->field_group_name,
    788                                         'field_id' => $field->field_id,
    789                                         'field_type' => $field->field_type,
    790                                         'field_data' => $field->field_data
     782                                        'field_group_id'        => $field->field_group_id,
     783                                        'field_group_name'      => $field->field_group_name,
     784                                        'field_id'                      => $field->field_id,
     785                                        'field_type'            => $field->field_type,
     786                                        'field_data'            => $field->field_data
    791787                                );
    792788                        }
     
    806802
    807803                if ( is_array( $user_ids ) ) {
    808                         $user_ids = implode( ',', (array)$user_ids );
     804                        $user_ids = implode( ',', (array) $user_ids );
    809805                        $data = $wpdb->get_results( $wpdb->prepare( "SELECT user_id, value FROM {$bp->profile->table_name_data} WHERE field_id = %d AND user_id IN ({$user_ids})", $field_id ) );
    810806                } else {
     
    829825                $field_sql = '';
    830826
    831                 if ( is_array($fields) ) {
    832                         for ( $i = 0; $i < count($fields); $i++ ) {
     827                if ( is_array( $fields ) ) {
     828                        for ( $i = 0; $i < count( $fields ); $i++ ) {
    833829                                if ( $i == 0 )
    834830                                        $field_sql .= $wpdb->prepare( "AND ( f.name = %s ", $fields[$i] );
     
    852848                        for ( $i = 0; $i < count( $values ); $i++ ) {
    853849                                for ( $j = 0; $j < count( $fields ); $j++ ) {
    854                                         if ( $values[$i]->name == $fields[$j] ) {
     850                                        if ( $values[$i]->name == $fields[$j] )
    855851                                                $new_values[$fields[$j]] = $values[$i]->value;
    856                                         } else if ( !array_key_exists( $fields[$j], $new_values ) ) {
     852                                        else if ( !array_key_exists( $fields[$j], $new_values ) )
    857853                                                $new_values[$fields[$j]] = NULL;
    858                                         }
    859854                                }
    860855                        }
  • trunk/bp-xprofile/bp-xprofile-filters.php

    r2576 r2810  
    4343
    4444function xprofile_filter_format_field_value( $field_value, $field_type = '' ) {
    45         if ( !isset($field_value) || empty( $field_value ) )
     45        if ( !isset( $field_value ) || empty( $field_value ) )
    4646                return false;
    4747
    48         if ( 'datebox' == $field_type ) {
     48        if ( 'datebox' == $field_type )
    4949                $field_value = bp_format_time( $field_value, true );
    50         } else {
     50        else
    5151                $field_value = str_replace(']]>', ']]&gt;', $field_value );
    52         }
    5352
    5453        return stripslashes( stripslashes( $field_value ) );
     
    6564
    6665        if ( $values ) {
    67                 foreach ( (array)$values as $value ) {
     66                foreach ( (array) $values as $value ) {
    6867                        $value = trim( $value );
    6968
     
    9695        if ( $fullnames = BP_XProfile_ProfileData::get_value_byid( 1, $user_ids ) ) {
    9796                foreach( (array)$fullnames as $user ) {
    98                         $users[$user->user_id] = trim($user->value);
     97                        $users[$user->user_id] = trim( $user->value );
    9998                }
    10099        }
  • trunk/bp-xprofile/bp-xprofile-templatetags.php

    r2798 r2810  
    2121        function bp_xprofile_data_template( $user_id, $profile_group_id ) {
    2222                $this->groups = BP_XProfile_Group::get( array(
    23                         'profile_group_id' => $profile_group_id,
    24                         'user_id' => $user_id,
    25                         'hide_empty_groups' => true,
    26                         'fetch_fields' => true,
    27                         'fetch_field_data' => true
     23                        'profile_group_id'      => $profile_group_id,
     24                        'user_id'                       => $user_id,
     25                        'hide_empty_groups'     => true,
     26                        'fetch_fields'          => true,
     27                        'fetch_field_data'      => true
    2828                ) );
    2929
    30                 $this->group_count = count($this->groups);
     30                $this->group_count = count( $this->groups );
    3131                $this->user_id = $user_id;
    3232        }
     
    5151        function rewind_groups() {
    5252                $this->current_group = -1;
    53                 if ( $this->group_count > 0 ) {
     53
     54                if ( $this->group_count > 0 )
    5455                        $this->group = $this->groups[0];
    55                 }
    5656        }
    5757
     
    6060                        return true;
    6161                } elseif ( $this->current_group + 1 == $this->group_count ) {
    62                         do_action('xprofile_template_loop_end');
     62                        do_action( 'xprofile_template_loop_end' );
    6363                        /* Do some cleaning up after the loop */
    6464                        $this->rewind_groups();
     
    7676
    7777                if ( 0 == $this->current_group ) /* loop has just started */
    78                         do_action('xprofile_template_loop_start');
     78                        do_action( 'xprofile_template_loop_start' );
    7979        }
    8080
     
    9090        function rewind_fields() {
    9191                $this->current_field = -1;
    92                 if ( $this->field_count > 0 ) {
     92
     93                if ( $this->field_count > 0 )
    9394                        $this->field = $this->group->fields[0];
    94                 }
    9595        }
    9696
     
    101101                        $field = &$this->group->fields[$i];
    102102
    103                         if ( $field->data->value != null ) {
     103                        if ( $field->data->value != null )
    104104                                $has_data = true;
    105                         }
    106105                }
    107106
     
    113112
    114113        function profile_fields() {
    115                 if ( $this->current_field + 1 < $this->field_count ) {
     114                if ( $this->current_field + 1 < $this->field_count )
    116115                        return true;
    117                 } elseif ( $this->current_field + 1 == $this->field_count ) {
    118                         /* Do some cleaning up after the loop */
     116
     117                /* Do some cleaning up after the loop */
     118                elseif ( $this->current_field + 1 == $this->field_count )
    119119                        $this->rewind_fields();
    120                 }
    121120
    122121                return false;
     
    128127                $field = $this->next_field();
    129128
    130                 if ( !empty( $field->data->value ) ) {
     129                if ( !empty( $field->data->value ) )
    131130                        $this->field_has_data = true;
    132                 }
    133                 else {
     131                else
    134132                        $this->field_has_data = false;
    135                 }
    136133        }
    137134}
     
    257254                global $group;
    258255
    259                 foreach ( (array) $group->fields as $field )
     256                foreach ( (array) $group->fields as $field ) {
    260257                        $field_ids .= $field->id . ',';
     258                }
    261259
    262260                return substr( $field_ids, 0, -1 );
     
    372370                                        $html .= '<option value="">--------</option>';
    373371
    374                                 for ( $k = 0; $k < count($options); $k++ ) {
    375                                         $option_value = BP_XProfile_ProfileData::get_value_byid($options[$k]->parent_id);
     372                                for ( $k = 0; $k < count( $options ); $k++ ) {
     373                                        $option_value = BP_XProfile_ProfileData::get_value_byid( $options[$k]->parent_id );
    376374
    377375                                        /* Check for updated posted values, but errors preventing them from being saved first time */
     
    381379                                        }
    382380
    383                                         if ( $option_value == $options[$k]->name || $options[$k]->is_default_option ) {
     381                                        if ( $option_value == $options[$k]->name || $options[$k]->is_default_option )
    384382                                                $selected = ' selected="selected"';
    385                                         } else {
     383                                        else
    386384                                                $selected = '';
    387                                         }
    388385
    389386                                        $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] );
     
    394391                                $html = '<div id="field_' . $field->id . '">';
    395392
    396                                 for ( $k = 0; $k < count($options); $k++ ) {
    397                                         $option_value = BP_XProfile_ProfileData::get_value_byid($options[$k]->parent_id);
     393                                for ( $k = 0; $k < count( $options ); $k++ ) {
     394                                        $option_value = BP_XProfile_ProfileData::get_value_byid( $options[$k]->parent_id );
    398395
    399396                                        /* Check for updated posted values, but errors preventing them from being saved first time */
     
    403400                                        }
    404401
    405                                         if ( $option_value == $options[$k]->name || $value == $options[$k]->name || $options[$k]->is_default_option ) {
     402                                        if ( $option_value == $options[$k]->name || $value == $options[$k]->name || $options[$k]->is_default_option )
    406403                                                $selected = ' checked="checked"';
    407                                         } else {
     404                                        else
    408405                                                $selected = '';
    409                                         }
    410406
    411407                                        $html .= apply_filters( 'bp_get_the_profile_field_options_radio', '<label><input' . $selected . ' type="radio" name="field_' . $field->id . '" id="option_' . $options[$k]->id . '" value="' . attribute_escape( $options[$k]->name ) . '"> ' . attribute_escape( $options[$k]->name ) . '</label>', $options[$k] );
     
    416412
    417413                        case 'checkbox':
    418                                 $option_values = BP_XProfile_ProfileData::get_value_byid($options[0]->parent_id);
     414                                $option_values = BP_XProfile_ProfileData::get_value_byid( $options[0]->parent_id );
    419415
    420416                                /* Check for updated posted values, but errors preventing them from being saved first time */
     
    424420                                }
    425421
    426                                 $option_values = maybe_unserialize($option_values);
    427 
    428                                 for ( $k = 0; $k < count($options); $k++ ) {
    429                                         for ( $j = 0; $j < count($option_values); $j++ ) {
     422                                $option_values = maybe_unserialize( $option_values );
     423
     424                                for ( $k = 0; $k < count( $options ); $k++ ) {
     425                                        for ( $j = 0; $j < count( $option_values ); $j++ ) {
    430426                                                if ( $option_values[$j] == $options[$k]->name || @in_array( $options[$k]->name, $value ) || $options[$k]->is_default_option ) {
    431427                                                        $selected = ' checked="checked"';
     
    442438
    443439                                if ( !empty( $field->data->value ) ) {
    444                                         $day = date("j", $field->data->value);
    445                                         $month = date("F", $field->data->value);
    446                                         $year = date("Y", $field->data->value);
    447                                         $default_select = ' selected="selected"';
     440                                        $day                    = date("j", $field->data->value);
     441                                        $month                  = date("F", $field->data->value);
     442                                        $year                   = date("Y", $field->data->value);
     443                                        $default_select = ' selected="selected"';
    448444                                }
    449445
     
    469465
    470466                                                for ( $i = 1; $i < 32; $i++ ) {
    471                                                         if ( $day == $i ) {
     467                                                        if ( $day == $i )
    472468                                                                $selected = ' selected = "selected"';
    473                                                         } else {
     469                                                        else
    474470                                                                $selected = '';
    475                                                         }
     471
    476472                                                        $html .= '<option value="' . $i .'"' . $selected . '>' . $i . '</option>';
    477473                                                }
     
    490486
    491487                                                for ( $i = 0; $i < 12; $i++ ) {
    492                                                         if ( $month == $eng_months[$i] ) {
     488                                                        if ( $month == $eng_months[$i] )
    493489                                                                $selected = ' selected = "selected"';
    494                                                         } else {
     490                                                        else
    495491                                                                $selected = '';
    496                                                         }
    497492
    498493                                                        $html .= '<option value="' . $eng_months[$i] . '"' . $selected . '>' . $months[$i] . '</option>';
     
    504499
    505500                                                for ( $i = date( 'Y', time() ); $i > 1899; $i-- ) {
    506                                                         if ( $year == $i ) {
     501                                                        if ( $year == $i )
    507502                                                                $selected = ' selected = "selected"';
    508                                                         } else {
     503                                                        else
    509504                                                                $selected = '';
    510                                                         }
    511505
    512506                                                        $html .= '<option value="' . $i .'"' . $selected . '>' . $i . '</option>';
     
    529523                global $field;
    530524
    531                 return apply_filters( 'bp_get_the_profile_field_is_required', (int)$field->is_required );
     525                return apply_filters( 'bp_get_the_profile_field_is_required', (int) $field->is_required );
    532526        }
    533527
    534528function bp_unserialize_profile_field( $value ) {
    535         if ( is_serialized($value) ) {
    536                 $field_value = maybe_unserialize($value);
     529        if ( is_serialized( $value ) ) {
     530                $field_value = maybe_unserialize( $value );
    537531                $field_value = implode( ', ', $field_value );
    538532                return $field_value;
     
    547541        function bp_get_profile_field_data( $args = '' ) {
    548542                $defaults = array(
    549                         'field' => false, /* Field name or ID. */
    550                         'user_id' => $bp->displayed_user->id
     543                        'field'         => false, /* Field name or ID. */
     544                        'user_id'       => $bp->displayed_user->id
    551545                );
    552546
     
    568562                $group_name = bp_profile_group_name(false);
    569563
    570         for ( $i = 0; $i < count($groups); $i++ ) {
    571                 if ( $group_name == $groups[$i]->name ) {
     564        for ( $i = 0; $i < count( $groups ); $i++ ) {
     565                if ( $group_name == $groups[$i]->name )
    572566                        $selected = ' class="current"';
    573                 } else {
     567                else
    574568                        $selected = '';
    575                 }
    576569
    577570                if ( $groups[$i]->fields )
     
    591584
    592585        if ( !$group = wp_cache_get( 'xprofile_group_' . $group_id, 'bp' ) ) {
    593                 $group = new BP_XProfile_Group($group_id);
     586                $group = new BP_XProfile_Group( $group_id );
    594587                wp_cache_set( 'xprofile_group_' . $group_id, $group, 'bp' );
    595588        }
    596589
    597         if ( !$deprecated ) {
     590        if ( !$deprecated )
    598591                return bp_get_profile_group_name();
    599         } else {
     592        else
    600593                echo bp_get_profile_group_name();
    601         }
    602594}
    603595        function bp_get_profile_group_name() {
     
    610602
    611603                if ( !$group = wp_cache_get( 'xprofile_group_' . $group_id, 'bp' ) ) {
    612                         $group = new BP_XProfile_Group($group_id);
     604                        $group = new BP_XProfile_Group( $group_id );
    613605                        wp_cache_set( 'xprofile_group_' . $group_id, $group, 'bp' );
    614606                }
     
    631623        $last_updated = bp_get_profile_last_updated();
    632624
    633         if ( !$last_updated ) {
     625        if ( !$last_updated )
    634626                _e( 'Profile not recently updated', 'buddypress' ) . '.';
    635         } else {
     627        else
    636628                echo $last_updated;
    637         }
    638629}
    639630        function bp_get_profile_last_updated() {
     
    680671        global $bp;
    681672
    682         ?>
     673?>
     674
    683675        <div class="generic-button">
    684                 <a class="edit" title="<?php _e( 'Edit Profile', 'buddypress' ) ?>" href="<?php echo $bp->displayed_user->domain . $bp->profile->slug ?>/edit"><?php _e( 'Edit Profile', 'buddypress' ) ?></a>
     676                <a class="edit" title="<?php _e( 'Edit Profile', 'buddypress' ); ?>" href="<?php echo $bp->displayed_user->domain . $bp->profile->slug ?>/edit"><?php _e( 'Edit Profile', 'buddypress' ); ?></a>
    685677        </div>
    686         <?php
    687 }
    688 
     678<?php
     679}
    689680
    690681?>
Note: See TracChangeset for help on using the changeset viewer.