Changeset 2798
- Timestamp:
- 03/03/2010 06:53:59 AM (16 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
-
bp-xprofile.php (modified) (10 diffs)
-
bp-xprofile/admin/css/admin.css (modified) (1 diff)
-
bp-xprofile/admin/js/admin.js (modified) (7 diffs)
-
bp-xprofile/bp-xprofile-admin.php (modified) (5 diffs)
-
bp-xprofile/bp-xprofile-classes.php (modified) (38 diffs)
-
bp-xprofile/bp-xprofile-cssjs.php (modified) (1 diff)
-
bp-xprofile/bp-xprofile-templatetags.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-xprofile.php
r2797 r2798 1 1 <?php 2 define ( 'BP_XPROFILE_DB_VERSION', '1 850' );2 define ( 'BP_XPROFILE_DB_VERSION', '1950' ); 3 3 4 4 /* Define the slug for the component */ … … 38 38 name varchar(150) NOT NULL, 39 39 description mediumtext NOT NULL, 40 group_order bigint(20) NOT NULL DEFAULT '0', 40 41 can_delete tinyint(1) NOT NULL, 41 42 KEY can_delete (can_delete) … … 86 87 87 88 require_once( ABSPATH . 'wp-admin/upgrade-functions.php' ); 88 dbDelta( $sql);89 dbDelta( $sql ); 89 90 90 91 do_action( 'xprofile_install' ); … … 153 154 154 155 /* Add the administration tab under the "Site Admin" tab for site administrators */ 155 add_submenu_page( 'bp-general-settings', __( "Profile Field Setup", 'buddypress'), __("Profile Field Setup", 'buddypress'), 'manage_options', 'bp-profile-setup', "xprofile_admin");156 add_submenu_page( 'bp-general-settings', __( 'Profile Field Setup', 'buddypress' ), __( 'Profile Field Setup', 'buddypress' ), 'manage_options', 'bp-profile-setup', 'xprofile_admin' ); 156 157 157 158 /* Need to check db tables exist, activate hook no-worky in mu-plugins folder. */ … … 215 216 /* Don't show this menu to non site admins or if you're viewing your own profile */ 216 217 if ( !is_site_admin() || bp_is_my_profile() ) 217 return false; 218 ?> 218 return false; ?> 219 219 220 <li id="bp-adminbar-adminoptions-menu"> 220 221 <a href=""><?php _e( 'Admin Options', 'buddypress' ) ?></a> … … 223 224 <li><a href="<?php echo $bp->displayed_user->domain . $bp->profile->slug ?>/edit/"><?php printf( __( "Edit %s's Profile", 'buddypress' ), attribute_escape( $bp->displayed_user->fullname ) ) ?></a></li> 224 225 <li><a href="<?php echo $bp->displayed_user->domain . $bp->profile->slug ?>/change-avatar/"><?php printf( __( "Edit %s's Avatar", 'buddypress' ), attribute_escape( $bp->displayed_user->fullname ) ) ?></a></li> 225 226 <?php if ( !bp_core_is_user_spammer( $bp->displayed_user->id ) ) : ?> 227 <li><a href="<?php echo wp_nonce_url( $bp->displayed_user->domain . 'admin/mark-spammer/', 'mark-unmark-spammer' ) ?>" class="confirm"><?php _e( "Mark as Spammer", 'buddypress' ) ?></a></li> 228 <?php else : ?> 229 <li><a href="<?php echo wp_nonce_url( $bp->displayed_user->domain . 'admin/unmark-spammer/', 'mark-unmark-spammer' ) ?>" class="confirm"><?php _e( "Not a Spammer", 'buddypress' ) ?></a></li> 230 <?php endif; ?> 226 <?php if ( !bp_core_is_user_spammer( $bp->displayed_user->id ) ) : ?> 227 228 <li><a href="<?php echo wp_nonce_url( $bp->displayed_user->domain . 'admin/mark-spammer/', 'mark-unmark-spammer' ) ?>" class="confirm"><?php _e( "Mark as Spammer", 'buddypress' ) ?></a></li> 229 <?php else : ?> 230 231 <li><a href="<?php echo wp_nonce_url( $bp->displayed_user->domain . 'admin/unmark-spammer/', 'mark-unmark-spammer' ) ?>" class="confirm"><?php _e( "Not a Spammer", 'buddypress' ) ?></a></li> 232 <?php endif; ?> 231 233 232 234 <li><a href="<?php echo wp_nonce_url( $bp->displayed_user->domain . 'admin/delete-user/', 'delete-user' ) ?>" class="confirm"><?php printf( __( "Delete %s", 'buddypress' ), attribute_escape( $bp->displayed_user->fullname ) ) ?></a></li> 233 234 <?php do_action( 'xprofile_adminbar_menu_items' ) ?> 235 <?php do_action( 'xprofile_adminbar_menu_items' ) ?> 236 235 237 </ul> 236 238 </li> 237 <?php239 <?php 238 240 } 239 241 add_action( 'bp_adminbar_menus', 'xprofile_setup_adminbar_menu', 20 ); … … 578 580 $field_group = new BP_XProfile_Group( $field_group_id ); 579 581 return $field_group->delete(); 582 } 583 584 function xprofile_update_field_group_position( $field_group_id, $position ) { 585 return BP_XProfile_Group::update_position( $field_group_id, $position ); 580 586 } 581 587 … … 851 857 852 858 function xprofile_update_field_position( $field_id, $position ) { 853 return BP_XProfile_Field::update_position( $field_id, $position );859 return BP_XProfile_Field::update_position( $field_id, $position ); 854 860 } 855 861 … … 953 959 BP_XProfile_ProfileData::delete_data_for_user( $user_id ); 954 960 955 / / delete any avatar files.961 /* delete any avatar files. */ 956 962 @unlink( get_usermeta( $user_id, 'bp_core_avatar_v1_path' ) ); 957 963 @unlink( get_usermeta( $user_id, 'bp_core_avatar_v2_path' ) ); 958 964 959 / / unset the usermeta for avatars from the usermeta table.965 /* unset the usermeta for avatars from the usermeta table. */ 960 966 delete_usermeta( $user_id, 'bp_core_avatar_v1' ); 961 967 delete_usermeta( $user_id, 'bp_core_avatar_v1_path' ); … … 995 1001 } 996 1002 997 / / List actions to clear object caches on1003 /* List actions to clear object caches on */ 998 1004 add_action( 'xprofile_groups_deleted_group', 'xprofile_clear_profile_groups_object_cache' ); 999 1005 add_action( 'xprofile_groups_saved_group', 'xprofile_clear_profile_groups_object_cache' ); 1000 1006 add_action( 'xprofile_updated_profile', 'xprofile_clear_profile_data_object_cache' ); 1001 1007 1002 / / List actions to clear super cached pages on, if super cache is installed1008 /* List actions to clear super cached pages on, if super cache is installed */ 1003 1009 add_action( 'xprofile_updated_profile', 'bp_core_clear_cache' ); 1004 1010 -
trunk/bp-xprofile/admin/css/admin.css
r1798 r2798 1 2 div.sortable { 3 margin-bottom: 20px; 4 } 5 6 table.field-group { 7 margin-bottom: 20px; 8 } 9 table.field-group.ui-sortable-helper { 10 filter: alpha(opacity=50); 11 opacity: 0.5; 12 } 13 table.field-group.ui-sortable-placeholder { 14 border: 2px dashed #ddd; 15 visibility: visible !important; 16 margin-bottom: 22px; 17 background-color: transparent; 18 } 19 20 table.field-group thead tr.grabber { 21 cursor: move; 22 } 23 1 24 table.field-group tbody { 2 25 cursor: move; -
trunk/bp-xprofile/admin/js/admin.js
r1977 r2798 37 37 38 38 toDeleteText = document.createTextNode('[x]'); 39 39 40 toDelete.setAttribute('href',"javascript:hide('" + forWhat + '_div' + theId + "')"); 40 41 41 toDelete.setAttribute('class','delete'); 42 43 42 toDelete.appendChild(toDeleteText); 44 43 … … 50 49 newDiv.appendChild(toDelete); 51 50 holder.appendChild(newDiv); 52 53 51 54 52 theId++ … … 62 60 document.getElementById("checkbox").style.display = "none"; 63 61 64 if(forWhat == "radio") {62 if(forWhat == "radio") 65 63 document.getElementById("radio").style.display = ""; 66 }67 64 68 if(forWhat == "selectbox") {65 if(forWhat == "selectbox") 69 66 document.getElementById("selectbox").style.display = ""; 70 }71 67 72 if(forWhat == "multiselectbox") {68 if(forWhat == "multiselectbox") 73 69 document.getElementById("multiselectbox").style.display = ""; 74 }75 70 76 if(forWhat == "checkbox") {71 if(forWhat == "checkbox") 77 72 document.getElementById("checkbox").style.display = ""; 78 }79 73 } 80 74 81 75 function hide(id) { 82 if ( !document.getElementById(id) ) return false;76 if ( !document.getElementById(id) ) return; 83 77 84 78 document.getElementById(id).style.display = "none"; … … 86 80 } 87 81 88 / / Set up deleting options ajax82 /* Set up deleting options ajax */ 89 83 jQuery(document).ready( function() { 90 91 84 jQuery("a.ajax-option-delete").click( 92 85 function() { … … 98 91 'cookie': encodeURIComponent(document.cookie), 99 92 '_wpnonce': jQuery("input#_wpnonce").val(), 100 101 93 'option_id': theId 102 94 }, 103 function(response) 104 {}); 95 function(response){}); 105 96 } 106 ); 97 ); 107 98 }); 108 99 … … 115 106 116 107 jQuery(document).ready( function() { 108 jQuery("form#profile-field-form div#field-groups").sortable( { 109 cursor: 'move', 110 axis: 'y', 111 helper: fixHelper, 112 distance: 1, 113 cancel: 'table.nodrag', 114 update: function() { 115 jQuery.post( ajaxurl, { 116 action: 'xprofile_reorder_groups', 117 'cookie': encodeURIComponent(document.cookie), 118 '_wpnonce_reorder_groups': jQuery("input#_wpnonce_reorder_groups").val(), 119 'group_order': jQuery(this).sortable('serialize') 120 }, 121 function(response){}); 122 } 123 }); 124 117 125 jQuery("table.field-group tbody").sortable( { 118 126 cursor: 'move', … … 126 134 'cookie': encodeURIComponent(document.cookie), 127 135 '_wpnonce_reorder_fields': jQuery("input#_wpnonce_reorder_fields").val(), 128 129 136 'field_order': jQuery(this).sortable('serialize') 130 137 }, 131 function(response) 132 {}); 133 138 function(response){}); 134 139 } 135 140 }); -
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' ); -
trunk/bp-xprofile/bp-xprofile-classes.php
r2654 r2798 61 61 return false; 62 62 63 $sql = $wpdb->prepare( "DELETE FROM {$bp->profile->table_name_groups} WHERE id = %d", $this->id ); 64 65 if ( !$wpdb->query($sql) ) { 66 return false; 67 } else { 68 // Now the group is deleted, remove the group's fields. 69 if ( BP_XProfile_Field::delete_for_group($this->id) ) { 70 // Now delete all the profile data for the groups fields 71 for ( $i = 0; $i < count($this->fields); $i++ ) { 72 BP_XProfile_ProfileData::delete_for_field($this->fields[$i]->id); 73 } 63 /* Delete field group */ 64 if ( !$wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->profile->table_name_groups} WHERE id = %d", $this->id ) ) ) { 65 return false; 66 } else { 67 /* Remove the group's fields. */ 68 if ( BP_XProfile_Field::delete_for_group( $this->id ) ) { 69 /* Remove profile data for the groups fields */ 70 foreach ( $this->fields as $field ) 71 BP_XProfile_ProfileData::delete_for_field( $field->id ); 72 74 73 } 75 74 … … 98 97 99 98 if ( $hide_empty_groups ) 100 $groups = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT g.* FROM {$bp->profile->table_name_groups} g INNER JOIN {$bp->profile->table_name_fields} f ON g.id = f.group_id {$group_id_sql} ORDER BY g. idASC" ) );99 $groups = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT g.* FROM {$bp->profile->table_name_groups} g INNER JOIN {$bp->profile->table_name_fields} f ON g.id = f.group_id {$group_id_sql} ORDER BY g.group_order ASC" ) ); 101 100 else 102 $groups = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT g.* FROM {$bp->profile->table_name_groups} g {$group_id_sql} ORDER BY g. idASC" ) );101 $groups = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT g.* FROM {$bp->profile->table_name_groups} g {$group_id_sql} ORDER BY g.group_order ASC" ) ); 103 102 104 103 if ( !$fetch_fields ) … … 154 153 global $message; 155 154 156 / / Validate Form155 /* Validate Form */ 157 156 if ( empty( $_POST['group_name'] ) ) { 158 157 $message = __('Please make sure you give the group a name.', 'buddypress'); … … 163 162 } 164 163 165 // ADMIN AREA HTML. TODO: Get this out of here. 164 function update_position( $field_group_id, $position ) { 165 global $wpdb, $bp; 166 167 if ( !is_numeric( $position ) ) 168 return false; 169 170 return $wpdb->query( $wpdb->prepare( "UPDATE {$bp->profile->table_name_groups} SET group_order = %d WHERE id = %d", $position, $field_group_id ) ); 171 } 172 173 /* ADMIN AREA HTML. TODO: Get this out of here. */ 166 174 167 175 function render_admin_form() { … … 175 183 $action = "admin.php?page=bp-profile-setup&mode=edit_group&group_id=" . $this->id; 176 184 } 177 ?>185 ?> 178 186 <div class="wrap"> 179 187 … … 206 214 </div> 207 215 208 <?php216 <?php 209 217 } 210 218 } … … 230 238 231 239 function bp_xprofile_field( $id = null, $user_id = null, $get_data = true ) { 232 if ( $id ) {240 if ( $id ) 233 241 $this->populate( $id, $user_id, $get_data ); 234 }235 242 } 236 243 … … 238 245 global $wpdb, $userdata, $bp; 239 246 240 if ( is_null( $user_id) ) {247 if ( is_null( $user_id ) ) 241 248 $user_id = $userdata->ID; 242 }243 249 244 250 $sql = $wpdb->prepare( "SELECT * FROM {$bp->profile->table_name_fields} WHERE id = %d", $id ); 245 251 246 if ( $field = $wpdb->get_row( $sql) ) {252 if ( $field = $wpdb->get_row( $sql ) ) { 247 253 $this->id = $field->id; 248 254 $this->group_id = $field->group_id; … … 258 264 $this->is_default_option = $field->is_default_option; 259 265 260 if ( $get_data ) {266 if ( $get_data ) 261 267 $this->data = $this->get_field_data($user_id); 262 } 268 263 269 } 264 270 } … … 268 274 269 275 if ( !$this->id || 270 / / Prevent deletion by url when can_delete is false.276 /* Prevent deletion by url when can_delete is false. */ 271 277 !$this->can_delete || 272 / / Prevent deletion of option 1 since this invalidates fields with options.278 /* Prevent deletion of option 1 since this invalidates fields with options. */ 273 279 ( $this->parent_id && $this->option_order == 1 ) ) 274 280 return false; … … 277 283 return false; 278 284 279 / / delete the data in the DB for this field280 BP_XProfile_ProfileData::delete_for_field( $this->id);285 /* delete the data in the DB for this field */ 286 BP_XProfile_ProfileData::delete_for_field( $this->id ); 281 287 282 288 return true; … … 300 306 301 307 if ( $this->id != null ) 302 $sql = $wpdb->prepare( "UPDATE {$bp->profile->table_name_fields} SET group_id = %d, parent_id = 0, type = %s, name = %s, description = %s, is_required = %d, order_by = %s, field_order = %d WHERE id = %d", $this->group_id, $this->type, $this->name, $this->description, $this->is_required, $this->order_by, $this->field_order, $this->id);308 $sql = $wpdb->prepare( "UPDATE {$bp->profile->table_name_fields} SET group_id = %d, parent_id = 0, type = %s, name = %s, description = %s, is_required = %d, order_by = %s, field_order = %d WHERE id = %d", $this->group_id, $this->type, $this->name, $this->description, $this->is_required, $this->order_by, $this->field_order, $this->id); 303 309 else 304 $sql = $wpdb->prepare("INSERT INTO {$bp->profile->table_name_fields} (group_id, parent_id, type, name, description, is_required, order_by, field_order ) VALUES (%d, 0, %s, %s, %s, %d, %s, %d )", $this->group_id, $this->type, $this->name, $this->description, $this->is_required, $this->order_by, $this->field_order ); 305 306 // Check for null so field options can be changed without changing any other part of the field. 307 // The described situation will return 0 here. 308 if ( $wpdb->query($sql) !== null ) { 310 $sql = $wpdb->prepare( "INSERT INTO {$bp->profile->table_name_fields} (group_id, parent_id, type, name, description, is_required, order_by, field_order ) VALUES (%d, 0, %s, %s, %s, %d, %s, %d )", $this->group_id, $this->type, $this->name, $this->description, $this->is_required, $this->order_by, $this->field_order ); 311 312 /* 313 * Check for null so field options can be changed without changing any other part of the field. 314 * The described situation will return 0 here. 315 */ 316 if ( $wpdb->query( $sql ) !== null ) { 309 317 310 318 if ( $this->id ) … … 313 321 $field_id = $wpdb->insert_id; 314 322 315 / / Only do this if we are editing an existing field323 /* Only do this if we are editing an existing field */ 316 324 if ( $this->id != null ) { 317 // Remove any radio or dropdown options for this 318 // field. They will be re-added if needed. 319 // This stops orphan options if the user changes a 320 // field from a radio button field to a text box. 325 /* 326 * Remove any radio or dropdown options for this 327 * field. They will be re-added if needed. 328 * This stops orphan options if the user changes a 329 * field from a radio button field to a text box. 330 */ 321 331 $this->delete_children(); 322 332 } 323 333 324 // Check to see if this is a field with child options. 325 // We need to add the options to the db, if it is. 334 /* 335 * Check to see if this is a field with child options. 336 * We need to add the options to the db, if it is. 337 */ 326 338 if ( 'radio' == $this->type || 'selectbox' == $this->type || 'checkbox' == $this->type || 'multiselectbox' == $this->type ) { 327 if ( $this->id ) {339 if ( $this->id ) 328 340 $parent_id = $this->id; 329 } else {341 else 330 342 $parent_id = $wpdb->insert_id; 331 }332 343 333 344 if ( 'radio' == $this->type ) { 334 335 345 $options = $_POST['radio_option']; 336 346 $defaults = $_POST['isDefault_radio_option']; 337 347 338 348 } else if ( 'selectbox' == $this->type ) { 339 340 349 $options = $_POST['selectbox_option']; 341 350 $defaults = $_POST['isDefault_selectbox_option']; 342 351 343 352 } else if ( 'multiselectbox' == $this->type ) { 344 345 353 $options = $_POST['multiselectbox_option']; 346 354 $defaults = $_POST['isDefault_multiselectbox_option']; 347 355 348 356 } else if ( 'checkbox' == $this->type ) { 349 350 357 $options = $_POST['checkbox_option']; 351 358 $defaults = $_POST['isDefault_checkbox_option']; … … 358 365 $is_default = 0; 359 366 360 if ( is_array( $defaults) ) {361 if ( isset( $defaults[$option_key]) )367 if ( is_array( $defaults ) ) { 368 if ( isset( $defaults[$option_key] ) ) 362 369 $is_default = 1; 363 370 } else { … … 367 374 368 375 if ( '' != $option_value ) { 369 if ( !$wpdb->query( $wpdb->prepare( "INSERT INTO {$bp->profile->table_name_fields} (group_id, parent_id, type, name, description, is_required, option_order, is_default_option) VALUES (%d, %d, 'option', %s, '', 0, %d, %d)", $this->group_id, $parent_id, $option_value, $counter, $is_default ) ) )376 if ( !$wpdb->query( $wpdb->prepare( "INSERT INTO {$bp->profile->table_name_fields} (group_id, parent_id, type, name, description, is_required, option_order, is_default_option) VALUES (%d, %d, 'option', %s, '', 0, %d, %d)", $this->group_id, $parent_id, $option_value, $counter, $is_default ) ) ) 370 377 return false; 371 378 } … … 387 394 } 388 395 389 function get_field_data( $user_id) {390 return new BP_XProfile_ProfileData( $this->id, $user_id);391 } 392 393 function get_children($for_editing = false) {394 global $wpdb, $bp; 395 396 / / This is done here so we don't have problems with sql injection397 if ( 'asc' == $this->order_by && !$for_editing ) {396 function get_field_data( $user_id ) { 397 return new BP_XProfile_ProfileData( $this->id, $user_id ); 398 } 399 400 function get_children( $for_editing = false ) { 401 global $wpdb, $bp; 402 403 /* This is done here so we don't have problems with sql injection */ 404 if ( 'asc' == $this->order_by && !$for_editing ) 398 405 $sort_sql = 'ORDER BY name ASC'; 399 } else if ( 'desc' == $this->order_by && !$for_editing ) {406 else if ( 'desc' == $this->order_by && !$for_editing ) 400 407 $sort_sql = 'ORDER BY name DESC'; 401 } else {408 else 402 409 $sort_sql = 'ORDER BY option_order ASC'; 403 } 404 405 //This eliminates a problem with getting all fields when there is no id for the object 406 if ( !$this->id ) { 410 411 /* This eliminates a problem with getting all fields when there is no id for the object */ 412 if ( !$this->id ) 407 413 $parent_id = -1; 408 } else {414 else 409 415 $parent_id = $this->id; 410 }411 416 412 417 $sql = $wpdb->prepare( "SELECT * FROM {$bp->profile->table_name_fields} WHERE parent_id = %d AND group_id = %d $sort_sql", $parent_id, $this->group_id ); … … 426 431 } 427 432 428 / / Static Functions433 /* Static Functions */ 429 434 430 435 function get_type( $field_id ) { … … 434 439 $sql = $wpdb->prepare( "SELECT type FROM {$bp->profile->table_name_fields} WHERE id = %d", $field_id ); 435 440 436 if ( !$field_type = $wpdb->get_var( $sql) )441 if ( !$field_type = $wpdb->get_var( $sql ) ) 437 442 return false; 438 443 … … 449 454 $sql = $wpdb->prepare( "DELETE FROM {$bp->profile->table_name_fields} WHERE group_id = %d", $group_id ); 450 455 451 if ( $wpdb->get_var($sql) === false ) {456 if ( $wpdb->get_var($sql) === false ) 452 457 return false; 453 }454 458 455 459 return true; … … 477 481 } 478 482 479 // ADMIN AREA HTML. TODO: Get this out of here. 480 483 /* ADMIN AREA HTML. TODO: Get this out of here. */ 484 485 /* This function populates the items for radio buttons checkboxes and drop down boxes */ 481 486 function render_admin_form_children() { 482 //This function populates the items for radio buttons checkboxes and drop down boxes483 487 $input_types = array( 'checkbox', 'selectbox', 'multiselectbox', 'radio' ); 484 488 … … 486 490 $default_name = ''; 487 491 488 if ( 'multiselectbox' == $type || 'checkbox' == $type ) {492 if ( 'multiselectbox' == $type || 'checkbox' == $type ) 489 493 $default_input = 'checkbox'; 490 } else {494 else 491 495 $default_input = 'radio'; 492 } 493 ?> 496 ?> 494 497 <div id="<?php echo $type ?>" class="options-box" style="<?php if ( $this->type != $type ) { ?>display: none;<?php } ?> margin-left: 15px;"> 495 498 <h4><?php _e('Please enter options for this Field:', 'buddypress') ?></h4> 496 499 <p><?php _e( 'Order By:', 'buddypress' ) ?> 497 498 500 <select name="sort_order_<?php echo $type ?>" id="sort_order_<?php echo $type ?>" > 499 501 <option value="default" <?php if ( 'default' == $this->order_by ) {?> selected="selected"<?php } ?> ><?php _e( 'Order Entered', 'buddypress' ) ?></option> … … 501 503 <option value="desc" <?php if ( 'desc' == $this->order_by ) {?> selected="selected"<?php } ?>><?php _e( 'Name - Descending', 'buddypress' ) ?></option> 502 504 </select> 503 504 <?php 505 <?php 505 506 if ( !$options = $this->get_children(true) ) { 506 507 $i = 1; … … 520 521 } 521 522 522 if ( !empty( $options) ) {523 if ( !empty( $options ) ) { 523 524 for ( $i = 0; $i < count($options); $i++ ) { 524 525 $j = $i + 1; … … 526 527 if ( 'multiselectbox' == $type || 'checkbox' == $type ) 527 528 $default_name = '[' . $j . ']'; 528 ?>529 ?> 529 530 <p><?php _e('Option', 'buddypress') ?> <?php echo $j ?>: 530 531 <input type="text" name="<?php echo $type ?>_option[<?php echo $j ?>]" id="<?php echo $type ?>_option<?php echo $j ?>" value="<?php echo attribute_escape( $options[$i]->name ) ?>" /> … … 533 534 $options[$i]->id != -1 ) : ?><a href="admin.php?page=bp-profile-setup&mode=delete_option&option_id=<?php echo $options[$i]->id ?>" class="ajax-option-delete" id="delete-<?php echo $options[$i]->id ?>">[x]</a><?php endif ?></p> 534 535 </p> 535 <?php } / / end for?>536 <?php } /* end for */ ?> 536 537 <input type="hidden" name="<?php echo $type ?>_option_number" id="<?php echo $type ?>_option_number" value="<?php echo $j + 1 ?>" /> 537 538 … … 546 547 <input type="hidden" name="<?php echo $type ?>_option_number" id="<?php echo $type ?>_option_number" value="2" /> 547 548 548 <?php } / / end if?>549 <?php } /* end if */ ?> 549 550 <div id="<?php echo $type ?>_more"></div> 550 551 <p><a href="javascript:add_option('<?php echo $type ?>')"><?php _e('Add Another Option', 'buddypress') ?></a></p> … … 556 557 function render_admin_form( $message = '' ) { 557 558 if ( !$this->id ) { 558 $title = __('Add Field', 'buddypress');559 $action = "admin.php?page=bp-profile-setup&group_id=" . $this->group_id . "&mode=add_field";559 $title = __('Add Field', 'buddypress'); 560 $action = "admin.php?page=bp-profile-setup&group_id=" . $this->group_id . "&mode=add_field"; 560 561 561 562 $this->name = $_POST['title']; … … 565 566 $this->order_by = $_POST["sort_order_{$this->type}"]; 566 567 } else { 567 $title = __('Edit Field', 'buddypress');568 $action = "admin.php?page=bp-profile-setup&mode=edit_field&group_id=" . $this->group_id . "&field_id=" . $this->id;568 $title = __('Edit Field', 'buddypress'); 569 $action = "admin.php?page=bp-profile-setup&mode=edit_field&group_id=" . $this->group_id . "&field_id=" . $this->id; 569 570 } 570 571 ?> … … 623 624 624 625 <p class="submit"> 625 <input type="submit" value="<?php _e("Save", 'buddypress') ?> →" name="saveField" id="saveField" style="font-weight: bold" />626 <?php _e('or', 'buddypress') ?> <a href="admin.php?page=bp-profile-setup" style="color: red"><?php _e( 'Cancel', 'buddypress' ) ?></a>626 <input type="submit" value="<?php _e("Save", 'buddypress') ?> →" name="saveField" id="saveField" style="font-weight: bold" /> 627 <?php _e('or', 'buddypress') ?> <a href="admin.php?page=bp-profile-setup" style="color: red"><?php _e( 'Cancel', 'buddypress' ) ?></a> 627 628 </p> 628 629 630 </div> 631 629 632 <div class="clear"></div> 630 633 631 <?php if ( function_exists('wp_nonce_field') ) 632 wp_nonce_field('xprofile_delete_option'); 633 ?> 634 <?php if ( function_exists( 'wp_nonce_field' ) ) wp_nonce_field( 'xprofile_delete_option' ); ?> 634 635 635 636 </form> 636 637 </div> 637 638 638 <?php639 <?php 639 640 } 640 641 … … 642 643 global $message; 643 644 644 / / Validate Form645 /* Validate Form */ 645 646 if ( '' == $_POST['title'] || '' == $_POST['required'] || '' == $_POST['fieldtype'] ) { 646 $message = __( 'Please make sure you fill out all required fields.', 'buddypress');647 $message = __( 'Please make sure you fill out all required fields.', 'buddypress' ); 647 648 return false; 648 649 } else if ( empty($_POST['field_file']) && $_POST['fieldtype'] == 'radio' && empty($_POST['radio_option'][1]) ) { 649 $message = __( 'Radio button field types require at least one option. Please add options below.', 'buddypress');650 $message = __( 'Radio button field types require at least one option. Please add options below.', 'buddypress' ); 650 651 return false; 651 652 } else if ( empty($_POST['field_file']) && $_POST['fieldtype'] == 'selectbox' && empty($_POST['selectbox_option'][1]) ) { 652 $message = __( 'Select box field types require at least one option. Please add options below.', 'buddypress');653 $message = __( 'Select box field types require at least one option. Please add options below.', 'buddypress' ); 653 654 return false; 654 655 } else if ( empty($_POST['field_file']) && $_POST['fieldtype'] == 'multiselectbox' && empty($_POST['multiselectbox_option'][1]) ) { 655 $message = __( 'Select box field types require at least one option. Please add options below.', 'buddypress');656 $message = __( 'Select box field types require at least one option. Please add options below.', 'buddypress' ); 656 657 return false; 657 658 } else if ( empty($_POST['field_file']) && $_POST['fieldtype'] == 'checkbox' && empty($_POST['checkbox_option'][1]) ) { 658 $message = __( 'Checkbox field types require at least one option. Please add options below.', 'buddypress');659 $message = __( 'Checkbox field types require at least one option. Please add options below.', 'buddypress' ); 659 660 return false; 660 661 } else { … … 673 674 674 675 function bp_xprofile_profiledata( $field_id = null, $user_id = null ) { 675 if ( $field_id ) {676 if ( $field_id ) 676 677 $this->populate( $field_id, $user_id ); 677 }678 678 } 679 679 … … 683 683 $sql = $wpdb->prepare( "SELECT * FROM {$bp->profile->table_name_data} WHERE field_id = %d AND user_id = %d", $field_id, $user_id ); 684 684 685 if ( $profiledata = $wpdb->get_row($sql) ) { 686 685 if ( $profiledata = $wpdb->get_row( $sql ) ) { 687 686 $this->id = $profiledata->id; 688 687 $this->user_id = $profiledata->user_id; … … 696 695 global $wpdb, $bp; 697 696 698 / / check to see if there is data already for the user.697 /* Check to see if there is data already for the user. */ 699 698 $sql = $wpdb->prepare( "SELECT id FROM {$bp->profile->table_name_data} WHERE user_id = %d AND field_id = %d", $this->user_id, $this->field_id ); 700 699 701 if ( !$wpdb->get_row( $sql) )700 if ( !$wpdb->get_row( $sql ) ) 702 701 return false; 703 702 … … 708 707 global $wpdb, $bp; 709 708 710 / / check to see if this data is actually for a valid field.711 $sql = $wpdb->prepare( "SELECT id FROM {$bp->profile->table_name_fields} WHERE id = %d", $this->field_id );712 713 if ( !$wpdb->get_row( $sql) )709 /* check to see if this data is actually for a valid field. */ 710 $sql = $wpdb->prepare( "SELECT id FROM {$bp->profile->table_name_fields} WHERE id = %d", $this->field_id ); 711 712 if ( !$wpdb->get_row( $sql ) ) 714 713 return false; 715 714 … … 728 727 729 728 if ( $this->is_valid_field() ) { 730 if ( $this->exists() && !empty( $this->value ) && strlen( trim( $this->value ) ) ) {729 if ( $this->exists() && !empty( $this->value ) && strlen( trim( $this->value ) ) ) 731 730 $result = $wpdb->query( $wpdb->prepare( "UPDATE {$bp->profile->table_name_data} SET value = %s, last_updated = %s WHERE user_id = %d AND field_id = %d", $this->value, $this->last_updated, $this->user_id, $this->field_id ) ); 732 } else if ( $this->exists() && empty( $this->value ) ) { 733 // Data removed, delete the entry. 731 732 /* Data removed, delete the entry. */ 733 else if ( $this->exists() && empty( $this->value ) ) 734 734 $result = $this->delete(); 735 } else { 735 736 else 736 737 $result = $wpdb->query( $wpdb->prepare("INSERT INTO {$bp->profile->table_name_data} (user_id, field_id, value, last_updated) VALUES (%d, %d, %s, %s)", $this->user_id, $this->field_id, $this->value, $this->last_updated ) ); 737 }738 738 739 739 if ( !$result ) … … 800 800 $user_ids = implode( ',', (array)$user_ids ); 801 801 $data = $wpdb->get_results( $wpdb->prepare( "SELECT user_id, value FROM {$bp->profile->table_name_data} WHERE field_id = %d AND user_id IN ({$user_ids})", $field_id ) ); 802 } else 802 } else { 803 803 $data = $wpdb->get_var( $wpdb->prepare( "SELECT value FROM {$bp->profile->table_name_data} WHERE field_id = %d AND user_id = %d", $field_id, $user_ids ) ); 804 } 804 805 805 806 return $data; … … 835 836 $sql = $wpdb->prepare( "SELECT d.value, f.name FROM {$bp->profile->table_name_data} d, {$bp->profile->table_name_fields} f WHERE d.field_id = f.id AND d.user_id = %d AND f.parent_id = 0 $field_sql", $user_id ); 836 837 837 if ( !$values = $wpdb->get_results( $sql) )838 if ( !$values = $wpdb->get_results( $sql ) ) 838 839 return false; 839 840 840 841 $new_values = array(); 841 842 842 if ( is_array( $fields) ) {843 for ( $i = 0; $i < count( $values); $i++ ) {844 for ( $j = 0; $j < count( $fields); $j++ ) {843 if ( is_array( $fields ) ) { 844 for ( $i = 0; $i < count( $values ); $i++ ) { 845 for ( $j = 0; $j < count( $fields ); $j++ ) { 845 846 if ( $values[$i]->name == $fields[$j] ) { 846 847 $new_values[$fields[$j]] = $values[$i]->value; … … 900 901 } 901 902 } 903 902 904 ?> -
trunk/bp-xprofile/bp-xprofile-cssjs.php
r1963 r2798 8 8 function xprofile_add_admin_js() { 9 9 if ( strpos( $_GET['page'], 'bp-profile-setup' ) !== false ) { 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' ) );10 wp_enqueue_script( 'jquery-ui-sortable' ); 11 wp_enqueue_script( 'xprofile-admin-js', BP_PLUGIN_URL . '/bp-xprofile/admin/js/admin.js', array( 'jquery', 'jquery-ui-sortable' ) ); 12 12 } 13 13 } -
trunk/bp-xprofile/bp-xprofile-templatetags.php
r2695 r2798 61 61 } elseif ( $this->current_group + 1 == $this->group_count ) { 62 62 do_action('xprofile_template_loop_end'); 63 / / Do some cleaning up after the loop63 /* Do some cleaning up after the loop */ 64 64 $this->rewind_groups(); 65 65 } … … 75 75 $group = $this->next_group(); 76 76 77 if ( 0 == $this->current_group ) / / loop has just started77 if ( 0 == $this->current_group ) /* loop has just started */ 78 78 do_action('xprofile_template_loop_start'); 79 79 } … … 116 116 return true; 117 117 } elseif ( $this->current_field + 1 == $this->field_count ) { 118 / / Do some cleaning up after the loop118 /* Do some cleaning up after the loop */ 119 119 $this->rewind_fields(); 120 120 } … … 547 547 function bp_get_profile_field_data( $args = '' ) { 548 548 $defaults = array( 549 'field' => false, / / Field name or ID.549 'field' => false, /* Field name or ID. */ 550 550 'user_id' => $bp->displayed_user->id 551 );551 ); 552 552 553 553 $r = wp_parse_args( $args, $defaults ); … … 657 657 $profile_group_id = 1; 658 658 659 return apply_filters( 'bp_get_current_profile_group_id', $profile_group_id ); // admin/profile/edit/[group-id] 659 /* admin/profile/edit/[group-id] */ 660 return apply_filters( 'bp_get_current_profile_group_id', $profile_group_id ); 660 661 } 661 662
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)