Changeset 102
- Timestamp:
- 05/13/2008 04:15:35 PM (18 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 3 edited
-
bp-friends.php (modified) (6 diffs)
-
bp-xprofile/bp-xprofile-admin.php (modified) (3 diffs)
-
bp-xprofile/bp-xprofile-ajax.php (added)
-
bp-xprofile/bp-xprofile-cssjs.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-friends.php
r57 r102 1 1 <?php 2 3 add_site_option('bp-friends-version', '0.1');4 2 $bp_friends_table_name = $wpdb->base_prefix . 'bp_friends'; 3 define('BP_FRIENDS_VERSION', '0.2'); 4 5 5 /************************************************************************** 6 6 friends_install() … … 9 9 **************************************************************************/ 10 10 11 function friends_install() { 12 global $wpdb, $table_name; 13 14 $sql = "CREATE TABLE ". $table_name ." ( 15 id mediumint(9) NOT NULL AUTO_INCREMENT, 16 initiator_user_id mediumint(9) NOT NULL, 17 friend_user_id mediumint(9) NOT NULL, 18 is_confirmed bool DEFAULT 0, 19 date_created int(11) NOT NULL, 20 UNIQUE KEY id (id) 11 function friends_install( $version ) { 12 global $wpdb, $bp_friends_table_name; 13 14 $sql = array(); 15 16 $sql[] = "CREATE TABLE `". $bp_friends_table_name ."` ( 17 `id` mediumint(9) NOT NULL AUTO_INCREMENT, 18 `initiator_user_id` mediumint(9) NOT NULL, 19 `friend_user_id` mediumint(9) NOT NULL, 20 `is_confirmed` bool DEFAULT 0, 21 `date_created` int(11) NOT NULL, 22 UNIQUE KEY id (`id`) 21 23 );"; 22 24 23 25 require_once(ABSPATH . 'wp-admin/upgrade-functions.php'); 24 26 dbDelta($sql); 27 28 add_site_option('bp-friends-version', $version); 25 29 } 26 30 … … 34 38 35 39 function friends_add_menu() { 36 global $wpdb, $table_name, $bp_friends, $userdata; 37 $table_name = $wpdb->base_prefix . "bp_friends"; 40 global $wpdb, $bp_friends_table_name, $bp_friends, $userdata; 38 41 39 42 if ( $wpdb->blogid == $userdata->primary_blog ) { 43 add_menu_page( __("Friends"), __("Friends"), 1, basename(__FILE__), "friends_list" ); 44 add_submenu_page( basename(__FILE__), __("My Friends"), __("My Friends"), 1, basename(__FILE__), "friends_list" ); 45 add_submenu_page( basename(__FILE__), __("Friend Finder"), __("Friend Finder"), 1, "friend_finder", "friends_find" ); 46 40 47 /* Instantiate bp_Friends class to do the real work. */ 41 48 $bp_friends = new BP_Friends; 42 49 $bp_friends->bp_friends(); 43 44 add_menu_page( __("Friends"), __("Friends"), 1, basename(__FILE__), "friends_list" ); 45 add_submenu_page( basename(__FILE__), __("My Friends"), __("My Friends"), 1, basename(__FILE__), "friends_list" ); 46 add_submenu_page( basename(__FILE__), __("Friend Finder"), __("Friend Finder"), 1, "friend_finder", "friends_find" ); 47 50 48 51 /* Add the administration tab under the "Site Admin" tab for site administrators */ 49 52 add_submenu_page( 'wpmu-admin.php', __("Friends"), __("Friends"), 1, basename(__FILE__), "friends_settings" ); 50 53 } 51 54 52 55 /* Need to check db tables exist, activate hook no-worky in mu-plugins folder. */ 53 if ( $wpdb->get_var("show tables like '%" . $table_name . "%'") == false ) 54 friends_install(); 56 if ( ( $wpdb->get_var("show tables like '%" . $bp_friends_table_name . "%'") == false ) || ( get_site_option('bp-friends-version') < BP_FRIENDS_VERSION ) ) 57 friends_install(BP_FRIENDS_VERSION); 58 55 59 } 56 60 add_action( 'admin_menu','friends_add_menu' ); … … 93 97 function bp_friends() 94 98 { 95 global $wpdb, $userdata, $ table_name;99 global $wpdb, $userdata, $bp_friends_table_name; 96 100 97 101 $this->wpdb = &$wpdb; 98 102 $this->userdata = &$userdata; 99 103 $this->basePrefix = $wpdb->base_prefix; 100 $this->tableName = $table_name; // need a root prefix, not a wp_X_ prefix.101 104 $this->imageBase = get_option('siteurl') . '/wp-content/mu-plugins/bp_friends/images/'; 102 105 … … 220 223 get_friends() 221 224 225 Get a list of friends for the current user using the current, internal 226 user id. 227 **************************************************************************/ 228 229 function get_friend_list() 230 { 231 return $this->get_friends($this->userdata->ID); 232 } 233 234 235 /************************************************************************** 236 get_friends() 237 222 238 Get a list of friends for the current user. 223 239 **************************************************************************/ … … 225 241 function get_friends($id) 226 242 { 243 global $bp_friends_table_name; 244 227 245 if(bp_core_validate($id)) 228 246 { 229 247 $sql = "SELECT initiator_user_id, friend_user_id 230 FROM " . $ this->tableName . "248 FROM " . $bp_friends_table_name . " 231 249 WHERE initiator_user_id = " . $id . " 232 250 OR friend_user_id = " . $id . " -
trunk/bp-xprofile/bp-xprofile-admin.php
r101 r102 49 49 <?php } 50 50 51 if ( $groups ) { 51 if ( $groups ) { ?> 52 <script type="text/javascript" charset="utf-8"> 53 jQuery(document).ready(function(){ <?php 54 for ( $i = 0; $i < count($groups); $i++ ) { ?> 55 jQuery('#group_<?php echo $groups[$i]->id;?>').tableDnD( { 56 onDrop: function(table, row) { 57 var field_ids = jQuery.tableDnD.serialize(); 58 reorderFields(table, row, field_ids); 59 } 60 }); 61 <?php } ?> 62 }); 63 </script> 64 65 <?php if ( function_exists('wp_nonce_field') ) 66 wp_nonce_field('xprofile_reorder_fields'); 67 52 68 for ( $i = 0; $i < count($groups); $i++ ) { 53 69 ?> 54 <script type="text/javascript" charset="utf-8"> 55 jQuery(document).ready(function(){ 56 jQuery('#<?php echo $groups[$i]->name;?>').tableDnD({ 57 onDrop: function(table, row) { 58 var order = jQuery.tableDnD.serialize(); 59 } 60 }); 61 }); 62 </script> 63 <p> 64 <table id="<?php echo $groups[$i]->name; ?>" class="widefat"> 70 <p> 71 <table id="group_<?php echo $groups[$i]->id;?>" class="widefat"> 65 72 <thead> 66 73 <tr class="nodrag"> … … 86 93 <?php if ( !$field->can_delete ) { $class .= ' core'; } ?> 87 94 88 <tr <?php echo ' class="' . $class . '"';?>>95 <tr id="field_<?php echo $field->id; ?>" <?php if ( $class ) { echo 'class="' . $class . '"'; } ?>> 89 96 <td><span title="<?php echo $field->desc; ?>"><?php echo $field->name; ?> <?php if(!$field->can_delete) { ?>(Core)<?php } ?></span></td> 90 97 <td><?php echo $field->type; ?></td> … … 100 107 </tr> 101 108 <?php } ?> 102 <tr >109 <tr class="nodrag"> 103 110 <td colspan="6"><a href="admin.php?page=xprofile_settings&group_id=<?php echo $groups[$i]->id; ?>&mode=add_field">Add New Field</a></td> 104 111 </tr> -
trunk/bp-xprofile/bp-xprofile-cssjs.php
r101 r102 366 366 jQuery('#v2_h').val(dimensions.height); 367 367 } 368 369 function reorderFields(table, row, field_ids) { 370 var ajaxurl = '<?php echo get_option('siteurl') . "/wp-admin/admin-ajax.php"; ?>'; 371 jQuery.post( ajaxurl, { 372 action: 'xprofile_reorder_fields', 373 'cookie': encodeURIComponent(document.cookie), 374 '_wpnonce': jQuery("input#_wpnonce").val(), 375 'group': table.id.split('_')[1], 376 'row': row, 377 'field_ids': field_ids 378 }, 379 function(response) { 380 alert(response); 381 }, 382 1250 383 ); 384 } 385 368 386 <?php } ?> 369 387 </script>
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)