Changeset 2883 for trunk/bp-xprofile/bp-xprofile-admin.php
- Timestamp:
- 03/29/2010 12:08:14 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/bp-xprofile/bp-xprofile-admin.php (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-xprofile/bp-xprofile-admin.php
r2813 r2883 40 40 else { 41 41 ?> 42 42 43 <div class="wrap"> 43 <h2><?php _e( 'Profile Field Setup', 'buddypress'); ?></h2> 44 <div class="icon32" id="icon-tools"><br></div> 45 <h2> 46 <?php _e( 'Profile Field Setup', 'buddypress'); ?> 47 <a id="add_group" class="button add-new-h2" href="admin.php?page=bp-profile-setup&mode=add_group"><?php _e( 'Add New Group', 'buddypress' ); ?></a> 48 </h2> 44 49 <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> 45 <p><?php _e('NOTE: Any fields in the first group will appear on the signup page.', 'buddypress'); ?></p>50 <p><?php echo sprintf( __( 'NOTE: Any fields in the "%s" group will appear on the signup page.', 'buddypress' ), get_site_option( 'bp-xprofile-base-group-name' ) ); ?></p> 46 51 47 52 <form action="" id="profile-field-form" method="post"> … … 51 56 52 57 if ( $message != '' ) : 53 $type = ( $type == 'error' ) ? 'error' : 'updated'; 54 ?> 58 $type = ( $type == 'error' ) ? 'error' : 'updated'; ?> 55 59 56 60 <div id="message" class="<?php echo $type; ?> fade"> … … 59 63 <?php endif; ?> 60 64 61 <div id="field-groups"> 65 <div id="tabs"> 66 <ul id="field-group-tabs"> 62 67 <?php 63 68 if ( $groups ) : 64 69 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"><img src="<?php echo BP_PLUGIN_URL; ?>/bp-xprofile/admin/images/move.gif" alt="<?php _e( 'Drag', 'buddypress' ); ?>" /></th> 70 <th scope="col" colspan="3"><?php echo attribute_escape( $group->name ); ?></th> 71 <?php 72 if ( $group->can_delete ) : 73 ?> 74 <th scope="col" class="center"><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" class="center"><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 else : 78 ?> 79 <th scope="col" class="center"><a class="edit" href="admin.php?page=bp-general-settings"><?php _e( 'Edit', 'buddypress' ); ?></a></th> 80 <th scope="col" class="center"> </th> 81 <?php 82 endif; 83 ?> 84 85 </tr> 86 <tr class="header"> 87 <td> </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> 92 </tr> 93 </thead> 94 95 <tfoot> 96 <tr class="nodrag"> 97 <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> 98 </tr> 99 </tfoot> 100 101 <tbody id="<?php echo $group->id ?>"> 102 <?php 103 if ( $group->fields ) : 104 foreach ( $group->fields as $field ) { 105 if ( 0 == $j % 2 ) 106 $class = ''; 107 else 108 $class = 'alternate'; 109 110 $field = new BP_XProfile_Field( $field->id ); 111 if ( !$field->can_delete ) 112 $class .= ' core nodrag'; 113 ?> 114 115 <tr id="field_<?php echo attribute_escape( $field->id ); ?>" class="sortable<?php if ( $class ) echo ' ' . $class; ?>"> 116 <td width="10"><?php if ( $field->can_delete ) : ?><img src="<?php echo BP_PLUGIN_URL; ?>/bp-xprofile/admin/images/move.gif" alt="<?php _e( 'Drag', 'buddypress' ); ?>" /><?php endif; ?></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' ); endif; ?></span></td> 118 <td><?php echo attribute_escape( $field->type ); ?></td> 119 <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 endif; ?></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&group_id=<?php echo attribute_escape( $group->id ); ?>&field_id=<?php echo attribute_escape( $field->id ); ?>&mode=edit_field<?php } ?>"><?php _e( 'Edit', 'buddypress' ); ?></a></td> 121 <td class="center"><?php if ( !$field->can_delete ) : ?> <?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 endif; ?></td> 122 </tr> 123 <?php 124 } /* end for */ 125 126 else : /* !$group->fields */ 127 ?> 128 129 <tr class="nodrag"> 130 <td colspan="6"><?php _e( 'There are no fields in this group.', 'buddypress' ); ?></td> 131 </tr> 70 <li id="group_<?php echo $group->id; ?>"><a href="#tabs-<?php echo $group->id; ?>" class="ui-tab"><?php echo attribute_escape( $group->name ); ?><?php if ( !$group->can_delete ) : ?> <?php _e( '(Core)', 'buddypress'); endif; ?></a></li> 71 <?php } 72 endif; ?> 73 </ul> 74 75 <?php if ( $groups ) : 76 foreach ( $groups as $group ) { ?> 77 78 <div id="tabs-<?php echo $group->id; ?>" class="tab-wrapper"> 79 <div class="tab-toolbar"> 80 <div class="tab-toolbar-left"> 81 <a class="button" 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> 82 <a class="button edit" href="admin.php?page=bp-profile-setup&mode=edit_group&group_id=<?php echo attribute_escape( $group->id ); ?>"><?php _e( 'Edit Group', 'buddypress' ); ?></a> 83 <?php if ( $group->can_delete ) : ?> 84 <a class="button delete" href="admin.php?page=bp-profile-setup&mode=delete_group&group_id=<?php echo attribute_escape( $group->id ); ?>"><?php _e( 'Delete Group', 'buddypress' ); ?></a> 85 <?php endif; ?> 86 </div> 87 </div> 88 89 <fieldset id="<?php echo $group->id; ?>" class="connectedSortable field-group"> 90 <?php if( $group->description ) : ?> 91 <legend><?php echo attribute_escape( $group->description ) ?></legend> 92 <?php endif; 93 94 if ( $group->fields ) : 95 foreach ( $group->fields as $field ) { 96 97 /* Load the field */ 98 $field = new BP_XProfile_Field( $field->id ); 99 if ( !$field->can_delete ) 100 $class .= ' core nodrag'; 101 102 /* This function handles the WYSIWYG profile field 103 * display for the xprofile admin setup screen 104 */ 105 xprofile_admin_field( $field, $group ); 106 107 } /* end for */ 108 109 else : /* !$group->fields */ 110 ?> 111 112 <p class="nodrag nofields"><?php _e( 'There are no fields in this group.', 'buddypress' ); ?></p> 132 113 <?php 133 114 endif; /* end $group->fields */ 134 115 ?> 135 136 </tbody> 137 </table> 138 <?php 139 } /* End For */ ?> 116 </fieldset> 140 117 </div> 141 <p> 142 <a class="button" href="admin.php?page=bp-profile-setup&mode=add_group"><?php _e( 'Add New Field Group', 'buddypress' ); ?></a>143 </p>118 <?php 119 } /* End For */ ?> 120 </div> 144 121 <?php 145 122 else : 146 123 ?> 147 148 <div id="message" class="error"><p><?php _e('You have no groups.', 'buddypress' ); ?></p></div> 124 <div id="message" class="error"><p><?php _e( 'You have no groups.', 'buddypress' ); ?></p></div> 149 125 <p><a href="admin.php?page=bp-profile-setup&mode=add_group"><?php _e( 'Add New Group', 'buddypress' ); ?></a></p> 150 126 <?php 151 127 endif; 152 128 ?> 153 154 </form> 155 </div> 129 </form> 130 </div> 156 131 <?php 157 132 } … … 169 144 $group = new BP_XProfile_Group( $group_id ); 170 145 171 if ( isset( $_POST['save Group'] ) ) {146 if ( isset( $_POST['save_group'] ) ) { 172 147 if ( BP_XProfile_Group::admin_validate( $_POST ) ) { 173 $group->name = wp_filter_kses( $_POST['group_name'] );174 $group->description = wp_filter_kses( $_POST['group_desc'] );148 $group->name = wp_filter_kses( $_POST['group_name'] ); 149 $group->description = wp_filter_kses( $_POST['group_description'] ); 175 150 176 151 if ( !$group->save() ) { … … 216 191 } 217 192 218 unset( $_GET['mode'] ); /* TODO: wtf? */193 unset( $_GET['mode'] ); 219 194 xprofile_admin( $message, $type ); 220 195 } … … 242 217 243 218 $field->field_order = $wpdb->get_var( $wpdb->prepare( "SELECT field_order FROM {$bp->profile->table_name_fields} WHERE id = %d", $field_id ) ); 244 245 219 if ( !$field->field_order ) { 246 220 $field->field_order = (int) $wpdb->get_var( $wpdb->prepare( "SELECT max(field_order) FROM {$bp->profile->table_name_fields} WHERE group_id = %d", $group_id ) ); … … 278 252 Handles the deletion of a profile field [or option]. 279 253 **************************************************************************/ 280 281 254 function xprofile_admin_delete_field( $field_id, $type = 'field' ) { 282 255 global $message, $type; … … 303 276 } 304 277 278 /************************************************************************** 279 xprofile_ajax_reorder_fields() 280 281 Handles the ajax reordering of fields within a group 282 **************************************************************************/ 305 283 function xprofile_ajax_reorder_fields() { 306 284 global $bp; … … 321 299 add_action( 'wp_ajax_xprofile_reorder_fields', 'xprofile_ajax_reorder_fields' ); 322 300 301 /************************************************************************** 302 xprofile_ajax_reorder_field_groups() 303 304 Handles the reordering of field groups 305 **************************************************************************/ 323 306 function xprofile_ajax_reorder_field_groups() { 324 307 global $bp; … … 337 320 } 338 321 add_action( 'wp_ajax_xprofile_reorder_groups', 'xprofile_ajax_reorder_field_groups' ); 322 323 /************************************************************************** 324 xprofile_admin_field() 325 326 Handles the WYSIWYG display of each profile field on the edit screen 327 **************************************************************************/ 328 function xprofile_admin_field( $admin_field, $admin_group ) { 329 global $field; 330 331 $field = $admin_field; 332 ?> 333 <fieldset id="field_<?php echo attribute_escape( $field->id ); ?>" class="sortable<?php echo ' ' . $field->type; if ( $class ) echo ' ' . $class; ?>"> 334 <legend><?php bp_the_profile_field_name(); ?> <?php if( !$field->can_delete ) : ?> <?php _e( '(Core)', 'buddypress' ); endif; ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ) ?><?php endif; ?></legend> 335 <div class="field-wrapper"> 336 <?php 337 switch ( $field->type ) { 338 case 'textbox' : ?> 339 340 <input type="text" name="<?php bp_the_profile_field_input_name() ?>" id="<?php bp_the_profile_field_input_name() ?>" value="" /> 341 <?php break; case 'textarea' : ?> 342 343 <textarea rows="5" cols="40" name="<?php bp_the_profile_field_input_name() ?>" id="<?php bp_the_profile_field_input_name() ?>"></textarea> 344 <?php break; case 'selectbox' : ?> 345 346 <select name="<?php bp_the_profile_field_input_name() ?>" id="<?php bp_the_profile_field_input_name() ?>"> 347 <?php bp_the_profile_field_options() ?> 348 349 </select> 350 351 <?php break; case 'multiselectbox' : ?> 352 353 <select name="<?php bp_the_profile_field_input_name() ?>" id="<?php bp_the_profile_field_input_name() ?>" multiple="multiple"> 354 <?php bp_the_profile_field_options() ?> 355 356 </select> 357 358 <?php break; case 'radio' : ?> 359 360 <?php bp_the_profile_field_options() ?> 361 362 <?php if ( !bp_get_the_profile_field_is_required() ) : ?> 363 364 <a class="clear-value" href="javascript:clear( '<?php bp_the_profile_field_input_name() ?>' );"><?php _e( 'Clear', 'buddypress' ) ?></a> 365 <?php endif; ?> 366 367 <?php break; case 'checkbox' : ?> 368 369 <?php bp_the_profile_field_options(); ?> 370 371 <?php break; case 'datebox' : ?> 372 373 <select name="<?php bp_the_profile_field_input_name(); ?>_day" id="<?php bp_the_profile_field_input_name(); ?>_day"> 374 <?php bp_the_profile_field_options( 'type=day' ); ?> 375 376 </select> 377 378 <select name="<?php bp_the_profile_field_input_name(); ?>_month" id="<?php bp_the_profile_field_input_name(); ?>_month"> 379 <?php bp_the_profile_field_options( 'type=month' ); ?> 380 381 </select> 382 383 <select name="<?php bp_the_profile_field_input_name(); ?>_year" id="<?php bp_the_profile_field_input_name(); ?>_year"> 384 <?php bp_the_profile_field_options( 'type=year' ); ?> 385 386 </select> 387 388 <?php break; default : ?> 389 390 <?php do_action( 'xprofile_admin_field', $field, 1 ); ?> 391 392 <?php } ?> 393 <div class="actions"> 394 <a class="button edit" href="admin.php?page=bp-profile-setup&group_id=<?php echo attribute_escape( $admin_group->id ); ?>&field_id=<?php echo attribute_escape( $field->id ); ?>&mode=edit_field"><?php _e( 'Edit', 'buddypress' ); ?></a> 395 <?php if ( !$field->can_delete ) : ?> <?php else : ?><a class="button 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 endif; ?> 396 397 </div> 398 <?php if ( $field->description ) : ?> 399 <p class="description"><?php echo attribute_escape( $field->description ); ?></p> 400 <?php endif; ?> 401 </div> 402 </fieldset> 403 <?php 404 }
Note: See TracChangeset
for help on using the changeset viewer.