Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/02/2009 07:54:21 PM (16 years ago)
Author:
apeatling
Message:

Merging 1.1 branch changes and syncing.

File:
1 edited

Legend:

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

    r2066 r2077  
    44/**************************************************************************
    55 xprofile_admin()
    6  
     6
    77 Handles all actions for the admin area for creating, editing and deleting
    88 profile groups and fields.
     
    3131        xprofile_admin_manage_group($_GET['group_id']);
    3232    } else {
    33 ?> 
     33?>
    3434    <div class="wrap">
    35        
     35
    3636        <h2><?php _e( 'Profile Field Setup', 'buddypress') ?></h2>
    3737        <br />
    38         <p><?php _e( 'Your users will distinguish themselves through their profile page. 
    39            You must give them profile fields that allow them to describe themselves 
     38        <p><?php _e( 'Your users will distinguish themselves through their profile page.
     39           You must give them profile fields that allow them to describe themselves
    4040            in a way that is relevant to the theme of your social network.', 'buddypress') ?></p>
    41            
     41
    4242        <p><?php _e('NOTE: Any fields in the first group will appear on the signup page.', 'buddypress'); ?></p>
    43        
     43
    4444        <form action="" id="profile-field-form" method="post">
    45            
     45
    4646            <?php wp_nonce_field( 'bp_reorder_fields', '_wpnonce_reorder_fields' ); ?>
    47                    
     47
    4848            <?php
    4949                if ( $message != '' ) {
     
    5454                </div>
    5555            <?php }
    56        
     56
    5757            if ( $groups ) { ?>
    58                 <?php 
     58                <?php
    5959                for ( $i = 0; $i < count($groups); $i++ ) { // TODO: foreach
    6060                ?>
     
    6565                                <th scope="col">&nbsp;</th>
    6666                                <th scope="col" colspan="<?php if ( $groups[$i]->can_delete ) { ?>3<?php } else { ?>5<?php } ?>"><?php echo attribute_escape( $groups[$i]->name ); ?></th>
    67                                 <?php if ( $groups[$i]->can_delete ) { ?>       
     67                                <?php if ( $groups[$i]->can_delete ) { ?>
    6868                                    <th scope="col"><a class="edit" href="admin.php?page=bp-profile-setup&amp;mode=edit_group&amp;group_id=<?php echo attribute_escape( $groups[$i]->id ); ?>"><?php _e( 'Edit', 'buddypress' ) ?></a></th>
    6969                                    <th scope="col"><a class="delete" href="admin.php?page=bp-profile-setup&amp;mode=delete_group&amp;group_id=<?php echo attribute_escape( $groups[$i]->id ); ?>"><?php _e( 'Delete', 'buddypress' ) ?></a></th>
     
    7979                        </thead>
    8080                        <tbody id="the-list">
    81                        
     81
    8282                          <?php if ( $groups[$i]->fields ) { ?>
    83                            
     83
    8484                                <?php for ( $j = 0; $j < count($groups[$i]->fields); $j++ ) { ?>
    85                        
    86                                     <?php if ( 0 == $j % 2 ) { $class = ""; } else { $class = "alternate"; } ?>     
     85
     86                                    <?php if ( 0 == $j % 2 ) { $class = ""; } else { $class = "alternate"; } ?>
    8787                                    <?php $field = new BP_XProfile_Field($groups[$i]->fields[$j]->id); ?>
    8888                                    <?php if ( !$field->can_delete ) { $class .= ' core'; } ?>
    89                            
     89
    9090                                    <tr id="field_<?php echo attribute_escape( $field->id ); ?>" class="sortable<?php if ( $class ) { echo ' ' . $class; } ?>">
    9191                                        <td width="10"><img src="<?php echo BP_PLUGIN_URL ?>/bp-xprofile/admin/images/move.gif" alt="<?php _e( 'Drag', 'buddypress' ) ?>" /></td>
     
    9696                                        <td style="text-align:center;"><?php if ( !$field->can_delete ) { ?><strike><?php _e( 'Delete', 'buddypress' ) ?></strike><?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>
    9797                                    </tr>
    98                            
     98
    9999                                <?php } ?>
    100                            
     100
    101101                            <?php } else { ?>
    102                            
     102
    103103                                <tr class="nodrag">
    104104                                    <td colspan="6"><?php _e( 'There are no fields in this group.', 'buddypress' ) ?></td>
    105105                                </tr>
    106                            
     106
    107107                            <?php } ?>
    108                    
     108
    109109                        </tbody>
    110                    
     110
    111111                        <tfoot>
    112                        
     112
    113113                                <tr class="nodrag">
    114114                                    <td colspan="6"><a href="admin.php?page=bp-profile-setup&amp;group_id=<?php echo attribute_escape( $groups[$i]->id ); ?>&amp;mode=add_field"><?php _e( 'Add New Field', 'buddypress' ) ?></a></td>
    115115                                </tr>
    116                        
     116
    117117                        </tfoot>
    118                    
     118
    119119                    </table>
    120120                    </p>
    121                
     121
    122122                <?php } /* End For */ ?>
    123            
     123
    124124                    <p>
    125125                        <a class="button" href="admin.php?page=bp-profile-setup&amp;mode=add_group"><?php _e( 'Add New Field Group', 'buddypress' ) ?></a>
    126126                    </p>
    127                
     127
    128128            <?php } else { ?>
    129129                <div id="message" class="error"><p><?php _e('You have no groups.', 'buddypress' ); ?></p></div>
    130130                <p><a href="admin.php?page=bp-profile-setup&amp;mode=add_group"><?php _e( 'Add New Group', 'buddypress' ) ?></a></p>
    131131            <?php } ?>
    132        
     132
    133133        </form>
    134        
     134
    135135    </div>
    136136<?php
     
    141141/**************************************************************************
    142142 xprofile_admin_manage_group()
    143  
     143
    144144 Handles the adding or editing of groups.
    145145 **************************************************************************/
     
    154154            $group->name = wp_filter_kses( $_POST['group_name'] );
    155155            $group->description = wp_filter_kses( $_POST['group_desc'] );
    156            
     156
    157157            if ( !$group->save() ) {
    158158                $message = __('There was an error saving the group. Please try again', 'buddypress');
     
    161161                $message = __('The group was saved successfully.', 'buddypress');
    162162                $type = 'success';
    163                
     163
    164164                do_action( 'xprofile_groups_saved_group', $group );
    165165            }
    166            
     166
    167167            unset($_GET['mode']);
    168168            xprofile_admin( $message, $type );
     
    172172        }
    173173    } else {
    174         $group->render_admin_form();               
     174        $group->render_admin_form();
    175175    }
    176176}
     
    178178/**************************************************************************
    179179 xprofile_admin_delete_group()
    180  
     180
    181181 Handles the deletion of profile data groups.
    182182 **************************************************************************/
     
    184184function xprofile_admin_delete_group( $group_id ) {
    185185    global $message, $type;
    186    
     186
    187187    $group = new BP_XProfile_Group($group_id);
    188    
     188
    189189    if ( !$group->delete() ) {
    190190        $message = __('There was an error deleting the group. Please try again', 'buddypress');
     
    193193        $message = __('The group was deleted successfully.', 'buddypress');
    194194        $type = 'success';
    195        
     195
    196196        do_action( 'xprofile_groups_deleted_group', $group );
    197197    }
    198    
     198
    199199    unset($_GET['mode']); // TODO: wtf?
    200200    xprofile_admin( $message, $type );
     
    204204/**************************************************************************
    205205 xprofile_admin_manage_field()
    206  
     206
    207207 Handles the adding or editing of profile field data for a user.
    208208 **************************************************************************/
     
    210210function xprofile_admin_manage_field( $group_id, $field_id = null ) {
    211211    global $bp, $wpdb, $message, $groups;
    212    
     212
    213213    $field = new BP_XProfile_Field($field_id);
    214214    $field->group_id = $group_id;
     
    228228                $field->field_order++;
    229229            }
    230            
     230
    231231            if ( !$field->save() ) {
    232232                $message = __('There was an error saving the field. Please try again', 'buddypress');
    233233                $type = 'error';
    234                
     234
    235235                unset($_GET['mode']);
    236236                xprofile_admin($message, $type);
     
    238238                $message = __('The field was saved successfully.', 'buddypress');
    239239                $type = 'success';
    240                
     240
    241241                unset($_GET['mode']);
    242                
     242
    243243                do_action( 'xprofile_fields_saved_field', $field );
    244                
     244
    245245                $groups = BP_XProfile_Group::get_all();
    246246                xprofile_admin( $message, $type );
     
    250250        }
    251251    } else {
    252         $field->render_admin_form();               
     252        $field->render_admin_form();
    253253    }
    254254}
     
    256256/**************************************************************************
    257257 xprofile_admin_delete_field()
    258  
     258
    259259 Handles the deletion of a profile field [or option].
    260260**************************************************************************/
     
    262262function xprofile_admin_delete_field( $field_id, $type = 'field' ) {
    263263    global $message, $type;
    264    
     264
    265265    if ( 'field' == $type ) {
    266266        $type = __('field', 'buddypress');
     
    268268        $type = __('option', 'buddypress');
    269269    }
    270    
     270
    271271    $field = new BP_XProfile_Field($field_id);
    272272
     
    277277        $message = sprintf( __('The %s was deleted successfully!', 'buddypress'), $type);
    278278        $type = 'success';
    279        
     279
    280280        do_action( 'xprofile_fields_deleted_field', $field );
    281281    }
    282    
     282
    283283    unset($_GET['mode']);
    284284    xprofile_admin($message, $type);
     
    287287function xprofile_ajax_reorder_fields() {
    288288    global $bp;
    289    
     289
    290290    /* Check the nonce */
    291291    check_admin_referer( 'bp_reorder_fields', '_wpnonce_reorder_fields' );
    292    
     292
    293293    if ( empty( $_POST['field_order'] ) )
    294294        return false;
    295    
     295
    296296    parse_str($_POST['field_order'], $order );
    297297
Note: See TracChangeset for help on using the changeset viewer.