Changeset 2077 for trunk/bp-xprofile/bp-xprofile-admin.php
- Timestamp:
- 11/02/2009 07:54:21 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/bp-xprofile/bp-xprofile-admin.php (modified) (23 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-xprofile/bp-xprofile-admin.php
r2066 r2077 4 4 /************************************************************************** 5 5 xprofile_admin() 6 6 7 7 Handles all actions for the admin area for creating, editing and deleting 8 8 profile groups and fields. … … 31 31 xprofile_admin_manage_group($_GET['group_id']); 32 32 } else { 33 ?> 33 ?> 34 34 <div class="wrap"> 35 35 36 36 <h2><?php _e( 'Profile Field Setup', 'buddypress') ?></h2> 37 37 <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 40 40 in a way that is relevant to the theme of your social network.', 'buddypress') ?></p> 41 41 42 42 <p><?php _e('NOTE: Any fields in the first group will appear on the signup page.', 'buddypress'); ?></p> 43 43 44 44 <form action="" id="profile-field-form" method="post"> 45 45 46 46 <?php wp_nonce_field( 'bp_reorder_fields', '_wpnonce_reorder_fields' ); ?> 47 47 48 48 <?php 49 49 if ( $message != '' ) { … … 54 54 </div> 55 55 <?php } 56 56 57 57 if ( $groups ) { ?> 58 <?php 58 <?php 59 59 for ( $i = 0; $i < count($groups); $i++ ) { // TODO: foreach 60 60 ?> … … 65 65 <th scope="col"> </th> 66 66 <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 ) { ?> 68 68 <th scope="col"><a class="edit" href="admin.php?page=bp-profile-setup&mode=edit_group&group_id=<?php echo attribute_escape( $groups[$i]->id ); ?>"><?php _e( 'Edit', 'buddypress' ) ?></a></th> 69 69 <th scope="col"><a class="delete" href="admin.php?page=bp-profile-setup&mode=delete_group&group_id=<?php echo attribute_escape( $groups[$i]->id ); ?>"><?php _e( 'Delete', 'buddypress' ) ?></a></th> … … 79 79 </thead> 80 80 <tbody id="the-list"> 81 81 82 82 <?php if ( $groups[$i]->fields ) { ?> 83 83 84 84 <?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"; } ?> 87 87 <?php $field = new BP_XProfile_Field($groups[$i]->fields[$j]->id); ?> 88 88 <?php if ( !$field->can_delete ) { $class .= ' core'; } ?> 89 89 90 90 <tr id="field_<?php echo attribute_escape( $field->id ); ?>" class="sortable<?php if ( $class ) { echo ' ' . $class; } ?>"> 91 91 <td width="10"><img src="<?php echo BP_PLUGIN_URL ?>/bp-xprofile/admin/images/move.gif" alt="<?php _e( 'Drag', 'buddypress' ) ?>" /></td> … … 96 96 <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&field_id=<?php echo attribute_escape( $field->id ); ?>&mode=delete_field"><?php _e( 'Delete', 'buddypress' ) ?></a><?php } ?></td> 97 97 </tr> 98 98 99 99 <?php } ?> 100 100 101 101 <?php } else { ?> 102 102 103 103 <tr class="nodrag"> 104 104 <td colspan="6"><?php _e( 'There are no fields in this group.', 'buddypress' ) ?></td> 105 105 </tr> 106 106 107 107 <?php } ?> 108 108 109 109 </tbody> 110 110 111 111 <tfoot> 112 112 113 113 <tr class="nodrag"> 114 114 <td colspan="6"><a href="admin.php?page=bp-profile-setup&group_id=<?php echo attribute_escape( $groups[$i]->id ); ?>&mode=add_field"><?php _e( 'Add New Field', 'buddypress' ) ?></a></td> 115 115 </tr> 116 116 117 117 </tfoot> 118 118 119 119 </table> 120 120 </p> 121 121 122 122 <?php } /* End For */ ?> 123 123 124 124 <p> 125 125 <a class="button" href="admin.php?page=bp-profile-setup&mode=add_group"><?php _e( 'Add New Field Group', 'buddypress' ) ?></a> 126 126 </p> 127 127 128 128 <?php } else { ?> 129 129 <div id="message" class="error"><p><?php _e('You have no groups.', 'buddypress' ); ?></p></div> 130 130 <p><a href="admin.php?page=bp-profile-setup&mode=add_group"><?php _e( 'Add New Group', 'buddypress' ) ?></a></p> 131 131 <?php } ?> 132 132 133 133 </form> 134 134 135 135 </div> 136 136 <?php … … 141 141 /************************************************************************** 142 142 xprofile_admin_manage_group() 143 143 144 144 Handles the adding or editing of groups. 145 145 **************************************************************************/ … … 154 154 $group->name = wp_filter_kses( $_POST['group_name'] ); 155 155 $group->description = wp_filter_kses( $_POST['group_desc'] ); 156 156 157 157 if ( !$group->save() ) { 158 158 $message = __('There was an error saving the group. Please try again', 'buddypress'); … … 161 161 $message = __('The group was saved successfully.', 'buddypress'); 162 162 $type = 'success'; 163 163 164 164 do_action( 'xprofile_groups_saved_group', $group ); 165 165 } 166 166 167 167 unset($_GET['mode']); 168 168 xprofile_admin( $message, $type ); … … 172 172 } 173 173 } else { 174 $group->render_admin_form(); 174 $group->render_admin_form(); 175 175 } 176 176 } … … 178 178 /************************************************************************** 179 179 xprofile_admin_delete_group() 180 180 181 181 Handles the deletion of profile data groups. 182 182 **************************************************************************/ … … 184 184 function xprofile_admin_delete_group( $group_id ) { 185 185 global $message, $type; 186 186 187 187 $group = new BP_XProfile_Group($group_id); 188 188 189 189 if ( !$group->delete() ) { 190 190 $message = __('There was an error deleting the group. Please try again', 'buddypress'); … … 193 193 $message = __('The group was deleted successfully.', 'buddypress'); 194 194 $type = 'success'; 195 195 196 196 do_action( 'xprofile_groups_deleted_group', $group ); 197 197 } 198 198 199 199 unset($_GET['mode']); // TODO: wtf? 200 200 xprofile_admin( $message, $type ); … … 204 204 /************************************************************************** 205 205 xprofile_admin_manage_field() 206 206 207 207 Handles the adding or editing of profile field data for a user. 208 208 **************************************************************************/ … … 210 210 function xprofile_admin_manage_field( $group_id, $field_id = null ) { 211 211 global $bp, $wpdb, $message, $groups; 212 212 213 213 $field = new BP_XProfile_Field($field_id); 214 214 $field->group_id = $group_id; … … 228 228 $field->field_order++; 229 229 } 230 230 231 231 if ( !$field->save() ) { 232 232 $message = __('There was an error saving the field. Please try again', 'buddypress'); 233 233 $type = 'error'; 234 234 235 235 unset($_GET['mode']); 236 236 xprofile_admin($message, $type); … … 238 238 $message = __('The field was saved successfully.', 'buddypress'); 239 239 $type = 'success'; 240 240 241 241 unset($_GET['mode']); 242 242 243 243 do_action( 'xprofile_fields_saved_field', $field ); 244 244 245 245 $groups = BP_XProfile_Group::get_all(); 246 246 xprofile_admin( $message, $type ); … … 250 250 } 251 251 } else { 252 $field->render_admin_form(); 252 $field->render_admin_form(); 253 253 } 254 254 } … … 256 256 /************************************************************************** 257 257 xprofile_admin_delete_field() 258 258 259 259 Handles the deletion of a profile field [or option]. 260 260 **************************************************************************/ … … 262 262 function xprofile_admin_delete_field( $field_id, $type = 'field' ) { 263 263 global $message, $type; 264 264 265 265 if ( 'field' == $type ) { 266 266 $type = __('field', 'buddypress'); … … 268 268 $type = __('option', 'buddypress'); 269 269 } 270 270 271 271 $field = new BP_XProfile_Field($field_id); 272 272 … … 277 277 $message = sprintf( __('The %s was deleted successfully!', 'buddypress'), $type); 278 278 $type = 'success'; 279 279 280 280 do_action( 'xprofile_fields_deleted_field', $field ); 281 281 } 282 282 283 283 unset($_GET['mode']); 284 284 xprofile_admin($message, $type); … … 287 287 function xprofile_ajax_reorder_fields() { 288 288 global $bp; 289 289 290 290 /* Check the nonce */ 291 291 check_admin_referer( 'bp_reorder_fields', '_wpnonce_reorder_fields' ); 292 292 293 293 if ( empty( $_POST['field_order'] ) ) 294 294 return false; 295 295 296 296 parse_str($_POST['field_order'], $order ); 297 297
Note: See TracChangeset
for help on using the changeset viewer.