Changeset 1798
- Timestamp:
- 09/06/2009 01:07:21 AM (16 years ago)
- Location:
- trunk/bp-xprofile
- Files:
-
- 5 added
- 1 deleted
- 4 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-xprofile/admin/css/admin.css
r1366 r1798 1 table.field-group tbody { 2 cursor: move; 3 } 4 table.field-group tbody tr.nodrag { 5 cursor: default !important; 6 } 7 8 table.field-group tbody tr:hover { 9 background-color: #fffee9; 10 } 11 1 12 tr.header td { 2 13 border-bottom: 2px solid #eee; -
trunk/bp-xprofile/bp-xprofile-admin.php
r1643 r1798 42 42 <p><?php _e('NOTE: Any fields in the first group will appear on the signup page.', 'buddypress'); ?></p> 43 43 44 <?php 45 if ( $message != '' ) { 46 $type = ( $type == 'error' ) ? 'error' : 'updated'; 47 ?> 48 <div id="message" class="<?php echo $type; ?> fade"> 49 <p><?php echo wp_specialchars( $message ); ?></p> 50 </div> 51 <?php } 52 53 if ( $groups ) { ?> 54 <?php 55 for ( $i = 0; $i < count($groups); $i++ ) { // TODO: foreach 44 <form action="" id="profile-field-form" method="post"> 45 46 <?php wp_nonce_field( 'bp_reorder_fields', '_wpnonce_reorder_fields' ); ?> 47 48 <?php 49 if ( $message != '' ) { 50 $type = ( $type == 'error' ) ? 'error' : 'updated'; 56 51 ?> 57 <p> 58 <table id="group_<?php echo $groups[$i]->id;?>" class="widefat"> 59 <thead> 60 <tr class="nodrag"> 61 <th scope="col" colspan="<?php if ( $groups[$i]->can_delete ) { ?>3<?php } else { ?>5<?php } ?>"><?php echo $groups[$i]->name; ?></th> 62 <?php if ( $groups[$i]->can_delete ) { ?> 63 <th scope="col"><a class="edit" href="admin.php?page=<?php echo BP_PLUGIN_DIR ?>/bp-xprofile.php&mode=edit_group&group_id=<?php echo $groups[$i]->id; ?>"><?php _e( 'Edit', 'buddypress' ) ?></a></th> 64 <th scope="col"><a class="delete" href="admin.php?page=<?php echo BP_PLUGIN_DIR ?>/bp-xprofile.php&mode=delete_group&group_id=<?php echo $groups[$i]->id; ?>"><?php _e( 'Delete', 'buddypress' ) ?></a></th> 52 <div id="message" class="<?php echo $type; ?> fade"> 53 <p><?php echo wp_specialchars( attribute_escape( $message ) ); ?></p> 54 </div> 55 <?php } 56 57 if ( $groups ) { ?> 58 <?php 59 for ( $i = 0; $i < count($groups); $i++ ) { // TODO: foreach 60 ?> 61 <p> 62 <table id="group_<?php echo $groups[$i]->id;?>" class="widefat field-group"> 63 <thead> 64 <tr> 65 <th scope="col"> </th> 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 ) { ?> 68 <th scope="col"><a class="edit" href="admin.php?page=<?php echo BP_PLUGIN_DIR ?>/bp-xprofile.php&mode=edit_group&group_id=<?php echo attribute_escape( $groups[$i]->id ); ?>"><?php _e( 'Edit', 'buddypress' ) ?></a></th> 69 <th scope="col"><a class="delete" href="admin.php?page=<?php echo BP_PLUGIN_DIR ?>/bp-xprofile.php&mode=delete_group&group_id=<?php echo attribute_escape( $groups[$i]->id ); ?>"><?php _e( 'Delete', 'buddypress' ) ?></a></th> 70 <?php } ?> 71 </tr> 72 <tr class="header"> 73 <td> </td> 74 <td><?php _e( 'Field Name', 'buddypress' ) ?></td> 75 <td width="14%"><?php _e( 'Field Type', 'buddypress' ) ?></td> 76 <td width="6%"><?php _e( 'Required?', 'buddypress' ) ?></td> 77 <td colspan="2" width="10%" style="text-align:center;"><?php _e( 'Action', 'buddypress' ) ?></td> 78 </tr> 79 </thead> 80 <tbody id="the-list"> 81 82 <?php if ( $groups[$i]->fields ) { ?> 83 84 <?php for ( $j = 0; $j < count($groups[$i]->fields); $j++ ) { ?> 85 86 <?php if ( 0 == $j % 2 ) { $class = ""; } else { $class = "alternate"; } ?> 87 <?php $field = new BP_XProfile_Field($groups[$i]->fields[$j]->id); ?> 88 <?php if ( !$field->can_delete ) { $class .= ' core'; } ?> 89 90 <tr id="field_<?php echo attribute_escape( $field->id ); ?>" class="sortable<?php if ( $class ) { echo ' ' . $class; } ?>"> 91 <td width="10"><img src="<?php echo BP_PLUGIN_URL ?>/bp-xprofile/admin/images/move.gif" alt="<?php _e( 'Drag', 'buddypress' ) ?>" /></td> 92 <td><span title="<?php echo $field->desc; ?>"><?php echo attribute_escape( $field->name ); ?> <?php if(!$field->can_delete) { ?>(Core)<?php } ?></span></td> 93 <td><?php echo attribute_escape( $field->type ); ?></td> 94 <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> 95 <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=<?php echo BP_PLUGIN_DIR ?>/bp-xprofile.php&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> 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=<?php echo BP_PLUGIN_DIR ?>/bp-xprofile.php&field_id=<?php echo attribute_escape( $field->id ); ?>&mode=delete_field"><?php _e( 'Delete', 'buddypress' ) ?></a><?php } ?></td> 97 </tr> 98 99 <?php } ?> 100 101 <?php } else { ?> 102 103 <tr class="nodrag"> 104 <td colspan="6"><?php _e( 'There are no fields in this group.', 'buddypress' ) ?></td> 105 </tr> 106 65 107 <?php } ?> 66 </tr> 67 </thead> 68 <tbody id="the-list"> 69 <tr class="header nodrag"> 70 <td><?php _e( 'Field Name', 'buddypress' ) ?></td> 71 <td width="14%"><?php _e( 'Field Type', 'buddypress' ) ?></td> 72 <td width="6%"><?php _e( 'Required?', 'buddypress' ) ?></td> 73 <td colspan="2" width="10%" style="text-align:center;"><?php _e( 'Action', 'buddypress' ) ?></td> 74 </tr> 75 76 <?php if ( $groups[$i]->fields ) { ?> 77 <?php for ( $j = 0; $j < count($groups[$i]->fields); $j++ ) { ?> 78 <?php if ( 0 == $j % 2 ) { $class = ""; } else { $class = "alternate"; } ?> 79 <?php $field = new BP_XProfile_Field($groups[$i]->fields[$j]->id); ?> 80 <?php if ( !$field->can_delete ) { $class .= ' core'; } ?> 81 82 <tr id="field_<?php echo $field->id; ?>" <?php if ( $class ) { echo 'class="' . $class . '"'; } ?>> 83 <td><span title="<?php echo $field->desc; ?>"><?php echo $field->name; ?> <?php if(!$field->can_delete) { ?>(Core)<?php } ?></span></td> 84 <td><?php echo $field->type; ?></td> 85 <td style="text-align:center;"><?php if ( $field->is_required ) { echo '<img src="' . $bp->profile->image_base . '/tick.gif" alt="' . _e( 'Yes', 'buddypress' ) . '" />'; } else { ?>--<?php } ?></td> 86 <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=<?php echo BP_PLUGIN_DIR ?>/bp-xprofile.php&group_id=<?php echo $groups[$i]->id; ?>&field_id=<?php echo $field->id; ?>&mode=edit_field"><?php _e( 'Edit', 'buddypress' ) ?></a><?php } ?></td> 87 <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=<?php echo BP_PLUGIN_DIR ?>/bp-xprofile.php&field_id=<?php echo $field->id; ?>&mode=delete_field"><?php _e( 'Delete', 'buddypress' ) ?></a><?php } ?></td> 88 </tr> 89 90 <?php } ?> 91 <?php } else { ?> 92 <tr class="nodrag"> 93 <td colspan="6"><?php _e( 'There are no fields in this group.', 'buddypress' ) ?></td> 94 </tr> 95 <?php } ?> 96 <tr class="nodrag"> 97 <td colspan="6"><a href="admin.php?page=<?php echo BP_PLUGIN_DIR ?>/bp-xprofile.php&group_id=<?php echo $groups[$i]->id; ?>&mode=add_field"><?php _e( 'Add New Field', 'buddypress' ) ?></a></td> 98 </tr> 99 </tbody> 100 </table> 101 </p> 102 103 <?php } /* End For */ ?> 104 105 <p> 106 <a href="admin.php?page=<?php echo BP_PLUGIN_DIR ?>/bp-xprofile.php&mode=add_group"><?php _e( 'Add New Group', 'buddypress' ) ?></a> 107 </p> 108 109 <?php } else { ?> 110 <div id="message" class="error"><p><?php _e('You have no groups.', 'buddypress' ); ?></p></div> 111 <p><a href="admin.php?page=<?php echo BP_PLUGIN_DIR ?>/bp-xprofile.php&mode=add_group"><?php _e( 'Add New Group', 'buddypress' ) ?></a></p> 112 <?php } ?> 108 109 </tbody> 110 111 <tfoot> 112 113 <tr class="nodrag"> 114 <td colspan="6"><a href="admin.php?page=<?php echo BP_PLUGIN_DIR ?>/bp-xprofile.php&group_id=<?php echo attribute_escape( $groups[$i]->id ); ?>&mode=add_field"><?php _e( 'Add New Field', 'buddypress' ) ?></a></td> 115 </tr> 116 117 </tfoot> 118 119 </table> 120 </p> 121 122 <?php } /* End For */ ?> 123 124 <p> 125 <a class="button" href="admin.php?page=<?php echo BP_PLUGIN_DIR ?>/bp-xprofile.php&mode=add_group"><?php _e( 'Add New Field Group', 'buddypress' ) ?></a> 126 </p> 127 128 <?php } else { ?> 129 <div id="message" class="error"><p><?php _e('You have no groups.', 'buddypress' ); ?></p></div> 130 <p><a href="admin.php?page=<?php echo BP_PLUGIN_DIR ?>/bp-xprofile.php&mode=add_group"><?php _e( 'Add New Group', 'buddypress' ) ?></a></p> 131 <?php } ?> 132 133 </form> 134 113 135 </div> 114 136 <?php … … 255 277 xprofile_admin($message, $type); 256 278 } 279 280 function xprofile_ajax_reorder_fields() { 281 global $bp; 282 283 /* Check the nonce */ 284 check_admin_referer( 'bp_reorder_fields', '_wpnonce_reorder_fields' ); 285 286 if ( empty( $_POST['field_order'] ) ) 287 return false; 288 289 parse_str($_POST['field_order'], $order ); 290 291 foreach ( (array) $order['field'] as $position => $field_id ) { 292 xprofile_update_field_position( (int) $field_id, (int) $position ); 293 } 294 } 295 add_action( 'wp_ajax_xprofile_reorder_fields', 'xprofile_ajax_reorder_fields' ); -
trunk/bp-xprofile/bp-xprofile-classes.php
r1728 r1798 82 82 83 83 // Get field ids for the current group. 84 if ( !$fields = $wpdb->get_results( $wpdb->prepare("SELECT id, type FROM {$bp->profile->table_name_fields} WHERE group_id = %d AND parent_id = 0 ORDER BY id", $this->id ) ) )84 if ( !$fields = $wpdb->get_results( $wpdb->prepare("SELECT id, type FROM {$bp->profile->table_name_fields} WHERE group_id = %d AND parent_id = 0 ORDER BY field_order", $this->id ) ) ) 85 85 return false; 86 86 … … 128 128 129 129 if ( !$this->id ) { 130 $title = __('Add Group', 'buddypress');130 $title = __('Add New Field Group', 'buddypress'); 131 131 $action = "admin.php?page=" . BP_PLUGIN_DIR . "/bp-xprofile.php&mode=add_group"; 132 132 } else { 133 $title = __('Edit Group', 'buddypress');133 $title = __('Edit Field Group', 'buddypress'); 134 134 $action = "admin.php?page=" . BP_PLUGIN_DIR . "/bp-xprofile.php&mode=edit_group&group_id=" . $this->id; 135 135 } … … 152 152 153 153 <div id="titlediv"> 154 <label for="group_name"><?php _e( "ProfileGroup Name", 'buddypress') ?></label>154 <label for="group_name"><?php _e( "Field Group Name", 'buddypress') ?></label> 155 155 <div> 156 156 <input type="text" name="group_name" id="group_name" value="<?php echo attribute_escape( $this->name ) ?>" style="width:50%" /> … … 372 372 $wpdb->query($sql); 373 373 } 374 375 // Static Functions 374 376 375 377 function get_type( $field_id ) { … … 411 413 412 414 return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->profile->table_name_fields} WHERE name = %s", $field_name ) ); 415 } 416 417 function update_position( $field_id, $position ) { 418 global $wpdb, $bp; 419 420 if ( !is_numeric( $position ) ) 421 return false; 422 423 return $wpdb->query( $wpdb->prepare( "UPDATE {$bp->profile->table_name_fields} SET field_order = %d WHERE id = %d", $position, $field_id ) ); 413 424 } 414 425 -
trunk/bp-xprofile/bp-xprofile-cssjs.php
r1636 r1798 2 2 3 3 function xprofile_add_admin_css() { 4 wp_enqueue_style( 'xprofile-admin-css', BP_PLUGIN_URL . '/bp-xprofile/admin/css/admin.css' ); 5 } 6 add_action( 'admin_menu', 'xprofile_add_admin_css' ); 7 8 function xprofile_add_admin_js() { 4 9 if ( strpos( $_GET['page'], 'xprofile' ) !== false ) { 5 echo '<link rel="stylesheet" href="' . BP_PLUGIN_URL . '/bp-xprofile/css/admin.css' . '" type="text/css" />'; 10 wp_enqueue_script( array( "jquery-ui-sortable" ) ); 11 wp_enqueue_script( 'xprofile-admin-js', BP_PLUGIN_URL . '/bp-xprofile/admin/js/admin.js', array( 'jquery' ) ); 6 12 } 7 13 } 8 add_action( 'admin_head', 'xprofile_add_admin_css' ); 9 10 function xprofile_add_admin_js() { 11 if ( strpos( $_GET['page'], 'xprofile' ) !== false ) 12 echo '<script type="text/javascript" src="' . BP_PLUGIN_URL . '/bp-xprofile/js/admin.js' . '"></script>'; 13 } 14 add_action( 'admin_head', 'xprofile_add_admin_js' ); 14 add_action( 'admin_menu', 'xprofile_add_admin_js', 1 ); 15 15 16 16 ?>
Note: See TracChangeset
for help on using the changeset viewer.