Changeset 2798 for trunk/bp-xprofile/bp-xprofile-admin.php
- Timestamp:
- 03/03/2010 06:53:59 AM (16 years ago)
- File:
-
- 1 edited
-
trunk/bp-xprofile/bp-xprofile-admin.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-xprofile/bp-xprofile-admin.php
r2625 r2798 1 1 <?php 2 3 2 4 3 /************************************************************************** … … 16 15 $groups = BP_XProfile_Group::get( array( 17 16 'fetch_fields' => true 18 ) ); 19 20 if ( isset($_GET['mode']) && isset($_GET['group_id']) && 'add_field' == $_GET['mode'] ) { 21 xprofile_admin_manage_field($_GET['group_id']); 22 } 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']); 24 } else if ( isset($_GET['mode']) && isset($_GET['field_id']) && 'delete_field' == $_GET['mode'] ) { 17 )); 18 19 if ( isset( $_GET['mode'] ) && isset( $_GET['group_id'] ) && 'add_field' == $_GET['mode'] ) 20 xprofile_admin_manage_field( $_GET['group_id'] ); 21 22 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'] ); 24 25 else if ( isset( $_GET['mode'] ) && isset( $_GET['field_id'] ) && 'delete_field' == $_GET['mode'] ) 25 26 xprofile_admin_delete_field($_GET['field_id'], 'field'); 26 } else if ( isset($_GET['mode']) && isset($_GET['option_id']) && 'delete_option' == $_GET['mode'] ) { 27 xprofile_admin_delete_field($_GET['option_id'], 'option'); 28 } else if ( isset($_GET['mode']) && 'add_group' == $_GET['mode'] ) { 27 28 else if ( isset( $_GET['mode'] ) && isset( $_GET['option_id'] ) && 'delete_option' == $_GET['mode'] ) 29 xprofile_admin_delete_field( $_GET['option_id'], 'option' ); 30 31 else if ( isset( $_GET['mode'] ) && 'add_group' == $_GET['mode'] ) 29 32 xprofile_admin_manage_group(); 30 } else if ( isset($_GET['mode']) && isset($_GET['group_id']) && 'delete_group' == $_GET['mode'] ) { 31 xprofile_admin_delete_group($_GET['group_id']); 32 } else if ( isset($_GET['mode']) && isset($_GET['group_id']) && 'edit_group' == $_GET['mode'] ) { 33 xprofile_admin_manage_group($_GET['group_id']); 34 } else { 33 34 else if ( isset( $_GET['mode'] ) && isset( $_GET['group_id'] ) && 'delete_group' == $_GET['mode'] ) 35 xprofile_admin_delete_group( $_GET['group_id'] ); 36 37 else if ( isset( $_GET['mode'] ) && isset( $_GET['group_id'] ) && 'edit_group' == $_GET['mode'] ) 38 xprofile_admin_manage_group( $_GET['group_id'] ); 39 40 else { 35 41 ?> 36 42 <div class="wrap"> 37 38 43 <h2><?php _e( 'Profile Field Setup', 'buddypress') ?></h2> 39 <br />40 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> 41 45 <p><?php _e('NOTE: Any fields in the first group will appear on the signup page.', 'buddypress'); ?></p> 42 46 43 47 <form action="" id="profile-field-form" method="post"> 44 45 48 <?php wp_nonce_field( 'bp_reorder_fields', '_wpnonce_reorder_fields' ); ?> 46 49 47 <?php 48 if ( $message != '' ) { 49 $type = ( $type == 'error' ) ? 'error' : 'updated'; 50 ?> 50 <?php wp_nonce_field( 'bp_reorder_groups', '_wpnonce_reorder_groups', false ); 51 52 if ( $message != '' ) : 53 $type = ( $type == 'error' ) ? 'error' : 'updated'; 54 ?> 55 51 56 <div id="message" class="<?php echo $type; ?> fade"> 52 57 <p><?php echo wp_specialchars( attribute_escape( $message ) ); ?></p> 53 58 </div> 54 <?php } 55 56 if ( $groups ) { ?> 57 <?php 58 for ( $i = 0; $i < count($groups); $i++ ) { // TODO: foreach 59 ?> 60 <p> 61 <table id="group_<?php echo $groups[$i]->id;?>" class="widefat field-group"> 62 <thead> 63 <tr> 64 <th scope="col" width="10"> </th> 65 <th scope="col" colspan="<?php if ( $groups[$i]->can_delete ) { ?>3<?php } else { ?>5<?php } ?>"><?php echo attribute_escape( $groups[$i]->name ); ?></th> 66 <?php if ( $groups[$i]->can_delete ) { ?> 67 <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> 68 <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> 69 <?php } ?> 70 </tr> 71 <tr class="header"> 72 <td> </td> 73 <td><?php _e( 'Field Name', 'buddypress' ) ?></td> 74 <td width="14%"><?php _e( 'Field Type', 'buddypress' ) ?></td> 75 <td width="6%"><?php _e( 'Required?', 'buddypress' ) ?></td> 76 <td colspan="2" width="10%" style="text-align:center;"><?php _e( 'Action', 'buddypress' ) ?></td> 77 </tr> 78 </thead> 79 <tbody id="the-list"> 80 81 <?php if ( $groups[$i]->fields ) { ?> 82 83 <?php for ( $j = 0; $j < count($groups[$i]->fields); $j++ ) { ?> 84 85 <?php if ( 0 == $j % 2 ) { $class = ""; } else { $class = "alternate"; } ?> 86 <?php $field = new BP_XProfile_Field($groups[$i]->fields[$j]->id); ?> 87 <?php if ( !$field->can_delete ) { $class .= ' core'; } ?> 88 89 <tr id="field_<?php echo attribute_escape( $field->id ); ?>" class="sortable<?php if ( $class ) { echo ' ' . $class; } ?>"> 90 <td width="10"><img src="<?php echo BP_PLUGIN_URL ?>/bp-xprofile/admin/images/move.gif" alt="<?php _e( 'Drag', 'buddypress' ) ?>" /></td> 91 <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> 92 <td><?php echo attribute_escape( $field->type ); ?></td> 93 <td style="text-align:center;"><?php if ( $field->is_required ) { echo '<img src="' . BP_PLUGIN_URL . '/bp-xprofile/admin/images/tick.gif" alt="' . __( 'Yes', 'buddypress' ) . '" />'; } else { ?>--<?php } ?></td> 94 <td style="text-align:center;"><?php if ( !$field->can_delete ) { ?><strike><?php _e( 'Edit', 'buddypress' ) ?></strike><?php } else { ?><a class="edit" href="admin.php?page=bp-profile-setup&group_id=<?php echo attribute_escape( $groups[$i]->id ); ?>&field_id=<?php echo attribute_escape( $field->id ); ?>&mode=edit_field"><?php _e( 'Edit', 'buddypress' ) ?></a><?php } ?></td> 95 <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> 96 </tr> 97 98 <?php } ?> 99 100 <?php } else { ?> 101 59 <?php endif; ?> 60 61 <div id="field-groups"> 62 <?php 63 if ( $groups ) : 64 foreach ( $groups as $group ) { ?> 65 66 <table id="group_<?php echo $group->id;?>" class="widefat field-group sortable"> 67 <thead> 68 <tr class="grabber"> 69 <th scope="col" width="10"> </th> 70 <th scope="col" colspan="<?php if ( $group->can_delete ) { ?>3<?php } else { ?>5<?php } ?>"><?php echo attribute_escape( $group->name ); ?></th> 71 <?php 72 if ( $group->can_delete ) : 73 ?> 74 <th scope="col"><a class="edit" href="admin.php?page=bp-profile-setup&mode=edit_group&group_id=<?php echo attribute_escape( $group->id ); ?>"><?php _e( 'Edit', 'buddypress' ) ?></a></th> 75 <th scope="col"><a class="delete" href="admin.php?page=bp-profile-setup&mode=delete_group&group_id=<?php echo attribute_escape( $group->id ); ?>"><?php _e( 'Delete', 'buddypress' ) ?></a></th> 76 <?php 77 endif; 78 ?> 79 80 </tr> 81 <tr class="header"> 82 <td> </td> 83 <td><?php _e( 'Field Name', 'buddypress' ) ?></td> 84 <td width="14%"><?php _e( 'Field Type', 'buddypress' ) ?></td> 85 <td width="6%"><?php _e( 'Required?', 'buddypress' ) ?></td> 86 <td colspan="2" width="10%" style="text-align:center;"><?php _e( 'Action', 'buddypress' ) ?></td> 87 </tr> 88 </thead> 89 90 <tfoot> 102 91 <tr class="nodrag"> 103 <td colspan="6">< ?php _e( 'There are no fields in this group.', 'buddypress' ) ?></td>92 <td colspan="6"><a href="admin.php?page=bp-profile-setup&group_id=<?php echo attribute_escape( $group->id ); ?>&mode=add_field"><?php _e( 'Add New Field', 'buddypress' ) ?></a></td> 104 93 </tr> 105 106 <?php } ?> 107 108 </tbody> 109 110 <tfoot> 111 112 <tr class="nodrag"> 113 <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> 114 </tr> 115 116 </tfoot> 117 118 </table> 119 </p> 120 121 <?php } /* End For */ ?> 122 94 </tfoot> 95 96 <tbody id="the-list"> 97 <?php 98 if ( $group->fields ) : 99 foreach ( $group->fields as $field ) { 100 if ( 0 == $j % 2 ) 101 $class = ''; 102 else 103 $class = 'alternate'; 104 105 $field = new BP_XProfile_Field( $field->id ); 106 if ( !$field->can_delete ) 107 $class .= ' core'; 108 ?> 109 110 <tr id="field_<?php echo attribute_escape( $field->id ); ?>" class="sortable<?php if ( $class ) { echo ' ' . $class; } ?>"> 111 <td width="10"><img src="<?php echo BP_PLUGIN_URL ?>/bp-xprofile/admin/images/move.gif" alt="<?php _e( 'Drag', 'buddypress' ) ?>" /></td> 112 <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> 113 <td><?php echo attribute_escape( $field->type ); ?></td> 114 <td style="text-align:center;"><?php if ( $field->is_required ) { echo '<img src="' . BP_PLUGIN_URL . '/bp-xprofile/admin/images/tick.gif" alt="' . __( 'Yes', 'buddypress' ) . '" />'; } else { ?>--<?php } ?></td> 115 <td style="text-align:center;"><?php if ( !$field->can_delete ) { ?><strike><?php _e( 'Edit', 'buddypress' ) ?></strike><?php } else { ?><a class="edit" href="admin.php?page=bp-profile-setup&group_id=<?php echo attribute_escape( $group->id ); ?>&field_id=<?php echo attribute_escape( $field->id ); ?>&mode=edit_field"><?php _e( 'Edit', 'buddypress' ) ?></a><?php } ?></td> 116 <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> 117 </tr> 118 <?php 119 } /* end for */ 120 121 else : /* !$group->fields */ 122 ?> 123 124 <tr class="nodrag"> 125 <td colspan="6"><?php _e( 'There are no fields in this group.', 'buddypress' ) ?></td> 126 </tr> 127 <?php 128 endif; /* end $group->fields */ 129 ?> 130 131 </tbody> 132 </table> 133 <?php 134 } /* End For */ ?> 135 </div> 123 136 <p> 124 137 <a class="button" href="admin.php?page=bp-profile-setup&mode=add_group"><?php _e( 'Add New Field Group', 'buddypress' ) ?></a> 125 138 </p> 126 127 <?php } else { ?> 139 <?php 140 else : 141 ?> 142 128 143 <div id="message" class="error"><p><?php _e('You have no groups.', 'buddypress' ); ?></p></div> 129 144 <p><a href="admin.php?page=bp-profile-setup&mode=add_group"><?php _e( 'Add New Group', 'buddypress' ) ?></a></p> 130 <?php } ?> 145 <?php 146 endif; 147 ?> 131 148 132 149 </form> 133 134 150 </div> 135 151 <?php 136 152 } 137 153 } 138 139 154 140 155 /************************************************************************** … … 184 199 global $message, $type; 185 200 186 $group = new BP_XProfile_Group( $group_id);201 $group = new BP_XProfile_Group( $group_id ); 187 202 188 203 if ( !$group->delete() ) { 189 $message = __( 'There was an error deleting the group. Please try again', 'buddypress');204 $message = __( 'There was an error deleting the group. Please try again', 'buddypress' ); 190 205 $type = 'error'; 191 206 } else { 192 $message = __( 'The group was deleted successfully.', 'buddypress');207 $message = __( 'The group was deleted successfully.', 'buddypress' ); 193 208 $type = 'success'; 194 209 … … 196 211 } 197 212 198 unset( $_GET['mode']); // TODO: wtf?213 unset( $_GET['mode'] ); /* TODO: wtf? */ 199 214 xprofile_admin( $message, $type ); 200 215 } … … 293 308 return false; 294 309 295 parse_str( $_POST['field_order'], $order );296 297 foreach ( (array) $order['field'] as $position => $field_id ) {310 parse_str( $_POST['field_order'], $order ); 311 312 foreach ( (array) $order['field'] as $position => $field_id ) 298 313 xprofile_update_field_position( (int) $field_id, (int) $position ); 299 } 314 300 315 } 301 316 add_action( 'wp_ajax_xprofile_reorder_fields', 'xprofile_ajax_reorder_fields' ); 317 318 function xprofile_ajax_reorder_field_groups() { 319 global $bp; 320 321 /* Check the nonce */ 322 check_admin_referer( 'bp_reorder_groups', '_wpnonce_reorder_groups' ); 323 324 if ( empty( $_POST['group_order'] ) ) 325 return false; 326 327 parse_str( $_POST['group_order'], $order ); 328 329 foreach ( (array) $order['group'] as $position => $field_group_id ) 330 xprofile_update_field_group_position( (int) $field_group_id, (int) $position ); 331 332 } 333 add_action( 'wp_ajax_xprofile_reorder_groups', 'xprofile_ajax_reorder_field_groups' );
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)