Changeset 439
- Timestamp:
- 10/28/2008 02:49:35 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 16 edited
-
bp-activity.php (modified) (1 diff)
-
bp-blogs.php (modified) (1 diff)
-
bp-core.php (modified) (5 diffs)
-
bp-core/bp-core-adminbar.php (modified) (4 diffs)
-
bp-core/bp-core-catchuri.php (modified) (2 diffs)
-
bp-core/bp-core-classes.php (modified) (1 diff)
-
bp-core/css/admin-bar.css (modified) (5 diffs)
-
bp-friends.php (modified) (8 diffs)
-
bp-friends/bp-friends-ajax.php (modified) (2 diffs)
-
bp-friends/bp-friends-classes.php (modified) (1 diff)
-
bp-groups.php (modified) (3 diffs)
-
bp-messages.php (modified) (7 diffs)
-
bp-messages/bp-messages-templatetags.php (modified) (1 diff)
-
bp-wire.php (modified) (3 diffs)
-
bp-wire/bp-wire-templatetags.php (modified) (1 diff)
-
bp-xprofile.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-activity.php
r398 r439 118 118 add_action( '_admin_menu', 'bp_activity_setup_globals', 1 ); 119 119 120 /**************************************************************************121 bp_activity_add_admin_menu()122 123 Creates the administration interface menus and checks to see if the DB124 tables are set up.125 **************************************************************************/126 127 function bp_activity_add_admin_menu() {128 global $wpdb, $bp, $userdata;129 130 if ( $wpdb->blogid == $bp['current_homebase_id'] ) {131 /* Add the administration tab under the "Site Admin" tab for site administrators */132 //add_submenu_page( 'wpmu-admin.php', __("Activity"), __("Activity"), 1, basename(__FILE__), "bp_activity_settings" );133 }134 }135 add_action( 'admin_menu', 'bp_activity_add_admin_menu' );136 120 137 121 /************************************************************************** -
trunk/bp-blogs.php
r429 r439 66 66 } 67 67 68 /************************************************************************** 69 bp_blogs_add_admin_menu() 70 71 Creates the administration interface menus and checks to see if the DB 72 tables are set up. 73 **************************************************************************/ 74 75 function bp_blogs_add_admin_menu() { 68 69 function bp_blogs_check_installed() { 76 70 global $wpdb, $bp, $userdata; 77 78 if ( $wpdb->blogid == $bp['current_homebase_id'] ) { 79 add_menu_page( __("Blogs", 'buddypress'), __("Blogs", 'buddypress'), 10, 'bp-blogs/admin-tabs/bp-blogs-tab.php' ); 80 add_submenu_page( 'bp-blogs/admin-tabs/bp-blogs-tab.php', __("My Blogs", 'buddypress'), __("My Blogs", 'buddypress'), 10, 'bp-blogs/admin-tabs/bp-blogs-tab.php' ); 81 add_submenu_page( 'bp-blogs/admin-tabs/bp-blogs-tab.php', __('Recent Posts', 'buddypress'), __('Recent Posts', 'buddypress'), 10, 'bp-blogs/admin-tabs/bp-blogs-posts-tab.php' ); 82 add_submenu_page( 'bp-blogs/admin-tabs/bp-blogs-tab.php', __('Recent Comments', 'buddypress'), __('Recent Comments', 'buddypress'), 10, 'bp-blogs/admin-tabs/bp-blogs-comments-tab.php' ); 83 } 84 85 /* Need to check db tables exist, activate hook no-worky in mu-plugins folder. */ 86 if ( ( $wpdb->get_var("show tables like '%" . $bp['blogs']['table_name'] . "%'") == false ) || ( get_site_option('bp-blogs-version') < BP_BLOGS_VERSION ) ) 87 bp_blogs_install(BP_BLOGS_VERSION); 88 } 89 add_action( 'admin_menu', 'bp_blogs_add_admin_menu' ); 71 72 if ( is_site_admin() ) { 73 /* Need to check db tables exist, activate hook no-worky in mu-plugins folder. */ 74 if ( ( $wpdb->get_var("show tables like '%" . $bp['blogs']['table_name'] . "%'") == false ) || ( get_site_option('bp-blogs-version') < BP_BLOGS_VERSION ) ) 75 bp_blogs_install(BP_BLOGS_VERSION); 76 } 77 } 78 add_action( 'admin_menu', 'bp_blogs_check_installed' ); 90 79 91 80 -
trunk/bp-core.php
r436 r439 2 2 3 3 /* Define the current version number for checking if DB tables are up to date. */ 4 define( 'BP_CORE_VERSION', '0.2. 6.1' );4 define( 'BP_CORE_VERSION', '0.2.7' ); 5 5 6 6 /* Define the slug for member pages and the members directory (e.g. domain.com/[members] ) */ … … 38 38 /* AJAX functionality */ 39 39 require_once( 'bp-core/bp-core-ajax.php' ); 40 41 /* Functions to handle the calculations and display of notifications for a user */ 42 require_once( 'bp-core/bp-core-notifications.php' ); 40 43 41 44 /* Functions to handle and display the member and blog directory pages */ … … 64 67 */ 65 68 function bp_core_setup_globals() { 66 global $bp ;69 global $bp, $wpdb; 67 70 global $current_user, $current_component, $current_action, $current_blog; 68 71 global $current_userid; … … 132 135 $bp['core'] = array( 133 136 'image_base' => site_url() . '/wp-content/mu-plugins/bp-core/images', 137 'table_name_notifications' => $wpdb->base_prefix . 'bp_notifications' 134 138 ); 135 139 … … 139 143 add_action( 'wp', 'bp_core_setup_globals', 1 ); 140 144 add_action( '_admin_menu', 'bp_core_setup_globals', 1 ); // must be _admin_menu hook. 145 146 147 function bp_core_install() { 148 global $wpdb, $bp; 149 150 $sql[] = "CREATE TABLE ". $bp['core']['table_name_notifications'] ." ( 151 id int(11) NOT NULL AUTO_INCREMENT, 152 user_id int(11) NOT NULL, 153 item_id int(11) NOT NULL, 154 component_name varchar(75) NOT NULL, 155 component_action varchar(75) NOT NULL, 156 date_notified datetime NOT NULL, 157 is_new tinyint(1) NOT NULL, 158 PRIMARY KEY id (id), 159 KEY item_id (item_id), 160 KEY user_id (user_id), 161 KEY is_new (is_new), 162 KEY component_name (component_name), 163 KEY component_action (component_action) 164 );"; 165 166 require_once(ABSPATH . 'wp-admin/upgrade-functions.php'); 167 dbDelta($sql); 168 169 add_site_option( 'bp-core-version', BP_CORE_VERSION ); 170 } 171 172 173 function bp_core_check_installed() { 174 global $wpdb, $bp; 175 176 if ( is_site_admin() ) { 177 /* Need to check db tables exist, activate hook no-worky in mu-plugins folder. */ 178 if ( ( $wpdb->get_var("show tables like '%" . $bp['core']['table_name_notifications'] . "%'") == false ) || ( get_site_option('bp-core-version') < BP_CORE_VERSION ) ) 179 bp_core_install(); 180 } 181 } 182 add_action( 'admin_menu', 'bp_core_check_installed' ); 183 141 184 142 185 function bp_core_setup_nav() { -
trunk/bp-core/bp-core-adminbar.php
r394 r439 18 18 19 19 /* Loop through each navigation item */ 20 $counter = 0; 20 21 foreach( $bp['bp_nav'] as $nav_item ) { 21 echo '<li>'; 22 echo '<a id="' . $nav_item['id'] . '" href="' . $nav_item['link'] . '">' . $nav_item['name'] . '</a>'; 22 $alt = ( $counter % 2 == 0 ) ? ' class="alt"' : ''; 23 echo '<li' . $alt . '>'; 24 echo '<a id="' . $nav_item['css_id'] . '" href="' . $nav_item['link'] . '">' . $nav_item['name'] . '</a>'; 23 25 24 if ( is_array( $bp['bp_options_nav'][$nav_item[' id']] ) ) {26 if ( is_array( $bp['bp_options_nav'][$nav_item['css_id']] ) ) { 25 27 echo '<ul>'; 26 foreach( $bp['bp_options_nav'][$nav_item['id']] as $subnav_item ) { 27 echo '<li><a id="' . $subnav_item['id'] . '" href="' . $subnav_item['link'] . '">' . $subnav_item['name'] . '</a></li>'; 28 $sub_counter = 0; 29 foreach( $bp['bp_options_nav'][$nav_item['css_id']] as $subnav_item ) { 30 $alt = ( $sub_counter % 2 == 0 ) ? ' class="alt"' : ''; 31 echo '<li' . $alt . '><a id="' . $subnav_item['css_id'] . '" href="' . $subnav_item['link'] . '">' . $subnav_item['name'] . '</a></li>'; 32 $sub_counter++; 28 33 } 29 34 echo '</ul>'; … … 31 36 32 37 echo '</li>'; 38 $counter++; 33 39 } 34 40 echo '<li><a id="logout" href="' . site_url() . '/wp-login.php?action=logout">' . __('Log Out', 'buddypress') . '</a></li>'; … … 44 50 _e('My Blogs', 'buddypress'); 45 51 echo '</a>'; 46 52 47 53 echo '<ul>'; 48 54 if ( is_array( $blogs['blogs'] ) ) { 49 55 56 $counter = 0; 50 57 foreach( $blogs['blogs'] as $blog ) { 51 echo '<li>'; 58 $alt = ( $counter % 2 == 0 ) ? ' class="alt"' : ''; 59 echo '<li' . $alt . '>'; 52 60 echo '<div class="admin-bar-clear"><a href="' . $blog['siteurl'] . '">' . $blog['title'] . '</a>'; 53 61 echo '</div>'; 54 62 55 63 echo '<ul>'; 56 echo '<li ><a href="' . $blog['siteurl'] . '/wp-admin/">' . __('Dashboard', 'buddypress') . '</a></li>';64 echo '<li class="alt"><a href="' . $blog['siteurl'] . '/wp-admin/">' . __('Dashboard', 'buddypress') . '</a></li>'; 57 65 echo '<li><a href="' . $blog['siteurl'] . '/wp-admin/post-new.php">' . __('New Post', 'buddypress') . '</a></li>'; 58 echo '<li ><a href="' . $blog['siteurl'] . '/wp-admin/post-new.php">' . __('Manage Posts', 'buddypress') . '</a></li>';66 echo '<li class="alt"><a href="' . $blog['siteurl'] . '/wp-admin/post-new.php">' . __('Manage Posts', 'buddypress') . '</a></li>'; 59 67 echo '<li><a href="' . $blog['siteurl'] . '/wp-admin/themes.php">' . __('Switch Theme', 'buddypress') . '</a></li>'; 60 echo '<li ><a href="' . $blog['siteurl'] . '/wp-admin/edit-comments.php">' . __('Manage Comments', 'buddypress') . '</a></li>';68 echo '<li class="alt"><a href="' . $blog['siteurl'] . '/wp-admin/edit-comments.php">' . __('Manage Comments', 'buddypress') . '</a></li>'; 61 69 echo '</ul>'; 62 70 63 71 echo '</li>'; 72 $counter++; 64 73 } 65 74 } else { … … 71 80 echo '</li>'; 72 81 } 82 83 /* Show notifications for this user */ 84 echo '<li id="notifications_menu"><a href="' . $bp['loggedin_domain'] . '">'; 85 _e('Notifications', 'buddypress'); 86 87 if ( $notifications = bp_core_get_notifications_for_user( $bp['loggedin_userid']) ) { ?> 88 <span><?php echo count($notifications) ?></span> 89 <?php 90 } 91 echo '</a>'; 92 echo '<ul>'; 93 if ( $notifications ) { ?> 94 <?php $counter = 0; ?> 95 <?php for ( $i = 0; $i < count($notifications); $i++ ) { ?> 96 <?php $alt = ( $counter % 2 == 0 ) ? ' class="alt"' : ''; ?> 97 <li<?php echo $alt ?>><?php echo $notifications[$i] ?></li> 98 <?php $counter++; ?> 99 <?php } ?> 100 <?php } else { ?> 101 <li><a href="<?php echo $bp['loggedin_domain'] ?>"><?php _e( 'No new notifications.', 'buddypress' ); ?></a></li> 102 <?php 103 } 104 echo '</ul>'; 105 echo '</li>'; 73 106 74 107 if ( $current_blog->blog_id > 1 ) { -
trunk/bp-core/bp-core-catchuri.php
r436 r439 154 154 155 155 if ( !file_exists( TEMPLATEPATH . "/header.php" ) || !file_exists( TEMPLATEPATH . "/footer.php" ) ) 156 wp_ die( 'Please make sure your BuddyPress enabled theme includes a header.php and footer.php file.');157 156 wp_redirect( $bp['root_domain'] ); 157 158 158 do_action( 'get_header' ); 159 159 load_template( TEMPLATEPATH . "/header.php" ); … … 196 196 } 197 197 198 // This function will remove home bases and redirect users to their new member page. 199 function bp_core_homebase_redirect() { 200 global $current_user, $current_blog; 201 202 if ( get_usermeta( $current_user->id, 'home_base' ) == $current_blog->blog_id ) { 203 if ( delete_blog( $current_blog->blog_id ) ) { 204 delete_usermeta( $current_user->id, 'home_base' ); 205 header('Location: ' . site_url() . MEMBERS_SLUG . '/' . $current_user->user_login . '/' ); 206 } 207 } 208 } 209 add_action( 'wp', 'bp_core_set_uri_globals', 0 ); 210 211 198 212 function bp_core_force_buddypress_theme() { 199 213 global $current_component, $current_action; -
trunk/bp-core/bp-core-classes.php
r436 r439 180 180 } 181 181 182 183 /** 184 * BP_Core_Notification class can be used by any component. 185 * It will handle the fetching, saving and deleting of a user notification. 186 * 187 * @package BuddyPress Core 188 */ 189 190 class BP_Core_Notification { 191 var $id; 192 var $user_id; 193 var $component_name; 194 var $component_action; 195 var $date_notified; 196 var $is_new; 197 198 function bp_core_notification( $id = false ) { 199 if ( $id ) { 200 $this->id = $id; 201 $this->populate(); 202 } 203 } 204 205 function populate() { 206 global $wpdb, $bp; 207 208 if ( $notification = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM " . $bp['core']['table_name_notifications'] . " WHERE id = %d", $this->id ) ) ) { 209 $this->user_id = $notification->user_id; 210 $this->component_name = $notification->component_name; 211 $this->component_action = $notification->component_action; 212 $this->date_notified = $notification->date_notified; 213 $this->is_new = $notification->is_new; 214 } 215 } 216 217 function save() { 218 global $wpdb, $bp; 219 220 if ( $this->id ) { 221 // Update 222 $sql = $wpdb->prepare( "UPDATE " . $bp['core']['table_name_notifications'] . " SET item_id = %d, user_id = %d, component_name = %s, component_action = %d, date_notified = FROM_UNIXTIME(%d), is_new = %d ) WHERE id = %d", $this->item_id, $this->user_id, $this->component_name, $this->component_action, $this->date_notified, $this->is_new, $this->id ); 223 } else { 224 // Save 225 $sql = $wpdb->prepare( "INSERT INTO " . $bp['core']['table_name_notifications'] . " ( item_id, user_id, component_name, component_action, date_notified, is_new ) VALUES ( %d, %d, %s, %s, FROM_UNIXTIME(%d), %d )", $this->item_id, $this->user_id, $this->component_name, $this->component_action, $this->date_notified, $this->is_new ); 226 } 227 228 return $wpdb->query( $sql ); 229 } 230 231 /* Static functions */ 232 233 function delete( $id ) { 234 global $wpdb, $bp; 235 236 237 } 238 239 function check_access( $user_id, $notification_id ) { 240 global $wpdb, $bp; 241 242 return $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM " . $bp['core']['table_name_notifications'] . " WHERE id = %d AND user_id = %d", $notification_id, $user_id ) ); 243 } 244 245 function total_notification_count( $user_id ) { 246 247 } 248 249 function get_all_for_user( $user_id ) { 250 global $wpdb, $bp; 251 252 return $wpdb->get_results( $wpdb->prepare( "SELECT * FROM " . $bp['core']['table_name_notifications'] . " WHERE user_id = %d AND is_new = 1", $user_id ) ); 253 } 254 255 function delete_for_user_by_type( $user_id, $component_name, $component_action ) { 256 global $wpdb, $bp; 257 258 return $wpdb->query( $wpdb->prepare( "DELETE FROM " . $bp['core']['table_name_notifications'] . " WHERE user_id = %d AND component_name = %s AND component_action = %s", $user_id, $component_name, $component_action ) ); 259 } 260 261 262 } 263 264 182 265 ?> -
trunk/bp-core/css/admin-bar.css
r309 r439 48 48 #wp-admin-bar ul li { /* all list items */ 49 49 padding: 0; 50 height: 30px;50 /*height: 30px;*/ 51 51 float: left; 52 52 } … … 76 76 margin: 0; 77 77 border: none; 78 background: #eee !important; 78 background: #f4f4f4 !important; 79 border-left: 1px solid #ccc; 80 border-right: 1px solid #ccc; 79 81 } 80 82 #wp-admin-bar ul li ul li.alt { 83 background: #fafafa !important; 84 } 85 86 #wp-admin-bar ul li ul li:last-child { 87 border-bottom: 1px solid #ccc; 88 -moz-border-radius-bottomleft: 4px; 89 -khtml-border-bottom-left-radius: 4px; 90 -webkit-border-bottom-left-radius: 4px; 91 border-bottom-left-radius: 4px; 92 -moz-border-radius-bottomright: 4px; 93 -khtml-border-bottom-right-radius: 4px; 94 -webkit-border-bottom-right-radius: 4px; 95 border-bottom-right-radius: 4px; 96 } 97 81 98 #wp-admin-bar ul li ul a { 82 99 color: #666 !important; … … 96 113 97 114 #wp-admin-bar ul li ul ul { 98 margin: -28px 0 0 18 5px;115 margin: -28px 0 0 183px; 99 116 } 100 117 … … 109 126 #wp-admin-bar ul.main-nav li ul li:hover { 110 127 background: #555; 128 } 129 130 #wp-admin-bar ul li ul li ul li:first-child { 131 border-top: 1px solid #ccc; 132 -moz-border-radius-topright: 4px; 133 -khtml-border-top-right-radius: 4px; 134 -webkit-border-top-right-radius: 4px; 135 border-top-right-radius: 4px; 111 136 } 112 137 … … 137 162 } 138 163 139 164 #wp-admin-bar ul li#notifications_menu a span { 165 background: #fff; 166 padding: 0 6px; 167 color: #555; 168 font-weight: bold !important; 169 font-size: 0.8em !important; 170 -moz-border-radius: 2px; 171 -khtml-border-radius: 2px; 172 -webkit-border-radius: 2px; 173 margin-left: 2px; 174 } -
trunk/bp-friends.php
r398 r439 19 19 **************************************************************************/ 20 20 21 function friends_install( $version) {21 function friends_install() { 22 22 global $wpdb, $bp; 23 23 … … 37 37 dbDelta($sql); 38 38 39 add_site_option( 'bp-friends-version', $version);39 add_site_option( 'bp-friends-version', BP_FRIENDS_VERSION ); 40 40 } 41 41 … … 61 61 add_action( '_admin_menu', 'friends_setup_globals', 1 ); 62 62 63 64 /************************************************************************** 65 friends_add_admin_menu() 66 67 Creates the administration interface menus and checks to see if the DB 68 tables are set up. 69 **************************************************************************/ 70 71 function friends_add_admin_menu() { 72 global $wpdb, $bp, $userdata; 73 74 if ( $wpdb->blogid == $bp['current_homebase_id'] ) { 75 /* Add the administration tab under the "Site Admin" tab for site administrators */ 76 //add_submenu_page( 'wpmu-admin.php', __("Friends"), __("Friends"), 1, basename(__FILE__), "friends_settings" ); 77 } 78 79 /* Need to check db tables exist, activate hook no-worky in mu-plugins folder. */ 80 if ( ( $wpdb->get_var("show tables like '%" . $bp['friends']['table_name'] . "%'") == false ) || ( get_site_option('bp-friends-version') < BP_FRIENDS_VERSION ) ) 81 friends_install(BP_FRIENDS_VERSION); 82 } 83 add_action( 'admin_menu', 'friends_add_admin_menu' ); 63 function friends_check_installed() { 64 global $wpdb, $bp; 65 66 if ( is_site_admin() ) { 67 /* Need to check db tables exist, activate hook no-worky in mu-plugins folder. */ 68 if ( ( $wpdb->get_var("show tables like '%" . $bp['friends']['table_name'] . "%'") == false ) || ( get_site_option('bp-friends-version') < BP_FRIENDS_VERSION ) ) 69 friends_install(); 70 } 71 } 72 add_action( 'admin_menu', 'friends_check_installed' ); 84 73 85 74 /************************************************************************** … … 102 91 bp_core_add_subnav_item( $bp['friends']['slug'], 'requests', __('Requests', 'buddypress'), $friends_link, 'friends_screen_requests' ); 103 92 bp_core_add_subnav_item( $bp['friends']['slug'], 'friend-finder', __('Friend Finder', 'buddypress'), $friends_link, 'friends_screen_friend_finder' ); 104 bp_core_add_subnav_item( $bp['friends']['slug'], 'invite-friend', __('Invite Friends', 'buddypress'), $friends_link, 'friends_screen_invite_friends' );93 //bp_core_add_subnav_item( $bp['friends']['slug'], 'invite-friend', __('Invite Friends', 'buddypress'), $friends_link, 'friends_screen_invite_friends' ); 105 94 106 95 if ( $bp['current_component'] == $bp['friends']['slug'] ) { … … 118 107 119 108 function friends_screen_my_friends() { 109 global $bp; 110 111 // Remove any notifications of new friend requests as we are viewing the 112 // friend request page 113 bp_core_delete_notifications_for_user_by_type( $bp['loggedin_userid'], 'friends', 'friendship_accepted' ); 114 120 115 bp_catch_uri( 'friends/index' ); 121 116 } … … 124 119 global $bp; 125 120 121 // Remove any notifications of new friend requests as we are viewing the 122 // friend request page 123 bp_core_delete_notifications_for_user_by_type( $bp['loggedin_userid'], 'friends', 'friendship_request' ); 124 126 125 if ( isset($bp['action_variables']) && in_array( 'accept', $bp['action_variables'] ) && is_numeric($bp['action_variables'][1]) ) { 127 126 … … 209 208 } 210 209 210 function friends_format_notifications( $action, $item_id, $total_items ) { 211 global $bp; 212 213 switch ( $action ) { 214 case 'friendship_accepted': 215 if ( (int)$total_items > 1 ) { 216 return '<a href="' . $bp['loggedin_domain'] . $bp['friends']['slug'] . '" title="' . __( 'My Friends', 'buddypress' ) . '">' . sprintf( __('%d friends accepted your friendship requests'), (int)$total_items ) . '</a>'; 217 } else { 218 $user_fullname = bp_core_global_user_fullname( $item_id ); 219 $user_url = bp_core_get_userurl( $item_id ); 220 return '<a href="' . $user_url . '" title="' . $user_fullname .'\'s profile">' . sprintf( __('%s accepted your friendship request'), $user_fullname ) . '</a>'; 221 } 222 break; 223 224 case 'friendship_request': 225 if ( (int)$total_items > 1 ) { 226 return '<a href="' . $bp['loggedin_domain'] . $bp['friends']['slug'] . '/requests" title="' . __( 'Friendship requests', 'buddypress' ) . '">' . sprintf( __('You have %d pending friendship requests'), (int)$total_items ) . '</a>'; 227 } else { 228 $user_fullname = bp_core_global_user_fullname( $item_id ); 229 $user_url = bp_core_get_userurl( $item_id ); 230 return '<a href="' . $bp['loggedin_domain'] . $bp['friends']['slug'] . '/requests" title="' . __( 'Friendship requests', 'buddypress' ) . '">' . sprintf( __('You have a friendship request from %s'), $user_fullname ) . '</a>'; 231 } 232 break; 233 } 234 if ( $action == 'friendship_accepted') { 235 if ( (int)$total_items > 1 ) { 236 return '<a href="' . $bp['loggedin_domain'] . $bp['friends']['slug'] . '" title="' . __( 'My Friends', 'buddypress' ) . '">' . sprintf( __('%d friends accepted your friendship requests'), (int)$total_items ) . '</a>'; 237 } else { 238 $user_fullname = bp_core_global_user_fullname( $item_id ); 239 $user_url = bp_core_get_userurl( $item_id ); 240 return '<a href="' . $user_url . '" title="' . $user_fullname .'\'s profile">' . sprintf( __('%s accepted your friendship request'), $user_fullname ) . '</a>'; 241 } 242 } 243 244 return false; 245 } 211 246 212 247 /************************************************************************** … … 373 408 if ( BP_Friends_Friendship::accept( $friendship_id ) ) { 374 409 friends_update_friend_totals( $friendship->initiator_user_id, $friendship->friend_user_id ); 410 bp_core_add_notification( $friendship->friend_user_id, $friendship->initiator_user_id, 'friends', 'friendship_accepted' ); 375 411 376 412 do_action( 'bp_friends_friendship_accepted', array( 'item_id' => $friendship_id, 'component_name' => 'friends', 'component_action' => 'friendship_accepted', 'is_private' => 0, 'dual_record' => true ) ); -
trunk/bp-friends/bp-friends-ajax.php
r436 r439 42 42 <span class="activity"><?php echo $friend->last_active ?></span> 43 43 <?php } ?> 44 <div class="action"> 45 <?php bp_add_friend_button( $friend->id ) ?> 46 </div> 44 47 </li> 45 48 <?php … … 95 98 <span class="activity"><?php echo $user->last_active ?></span> 96 99 <?php } ?> 97 <?php bp_add_friend_button( $user->id ) ?> 100 <div class="action"> 101 <?php bp_add_friend_button( $user->id ) ?> 102 </div> 98 103 </li> 99 104 <?php -
trunk/bp-friends/bp-friends-classes.php
r431 r439 27 27 global $wpdb, $bp, $creds; 28 28 29 $sql = $wpdb->prepare( "SELECT * FROM " . $bp['friends']['table_name'] . " WHERE id = %d", $this->id ); 30 $friendship = $wpdb->get_row($sql); 31 32 if ( $friendship ) { 33 if ( !$this->is_request ) { 34 $this->initiator_user_id = $friendship->initiator_user_id; 35 $this->friend_user_id = $friendship->friend_user_id; 36 } else { 37 $this->initiator_user_id = $friendship->friend_user_id; 38 $this->friend_user_id = $friendship->initiator_user_id; 39 } 40 29 if ( $friendship = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM " . $bp['friends']['table_name'] . " WHERE id = %d", $this->id ) ) ) { 30 $this->initiator_user_id = $friendship->initiator_user_id; 31 $this->friend_user_id = $friendship->friend_user_id; 41 32 $this->is_confirmed = $friendship->is_confirmed; 42 33 $this->is_limited = $friendship->is_limited; -
trunk/bp-groups.php
r414 r439 18 18 **************************************************************************/ 19 19 20 function groups_install( $version) {20 function groups_install() { 21 21 global $wpdb, $bp; 22 22 … … 85 85 dbDelta($sql); 86 86 87 add_site_option( 'bp-groups-version', $version);87 add_site_option( 'bp-groups-version', BP_GROUPS_VERSION ); 88 88 } 89 89 … … 122 122 123 123 124 /************************************************************************** 125 groups_add_admin_menu() 126 127 Creates the administration interface menus and checks to see if the DB 128 tables are set up. 129 **************************************************************************/ 130 131 function groups_add_admin_menu() { 132 global $wpdb, $bp, $userdata; 133 134 if ( $wpdb->blogid == $bp['current_homebase_id'] ) { 135 /* Add the administration tab under the "Site Admin" tab for site administrators */ 136 //add_submenu_page( 'wpmu-admin.php', __("Friends"), __("Friends"), 1, basename(__FILE__), "friends_settings" ); 137 } 138 139 /* Need to check db tables exist, activate hook no-worky in mu-plugins folder. */ 140 if ( ( $wpdb->get_var("show tables like '%" . $bp['groups']['table_name'] . "%'") == false ) || ( get_site_option('bp-groups-version') < BP_GROUPS_VERSION ) ) 141 groups_install(BP_GROUPS_VERSION); 142 143 } 144 add_action( 'admin_menu', 'groups_add_admin_menu' ); 124 function groups_check_installed() { 125 global $wpdb, $bp; 126 127 if ( is_site_admin() ) { 128 /* Need to check db tables exist, activate hook no-worky in mu-plugins folder. */ 129 if ( ( $wpdb->get_var("show tables like '%" . $bp['groups']['table_name'] . "%'") == false ) || ( get_site_option('bp-groups-version') < BP_GROUPS_VERSION ) ) 130 groups_install(); 131 } 132 } 133 add_action( 'admin_menu', 'groups_check_installed' ); 145 134 146 135 /************************************************************************** -
trunk/bp-messages.php
r398 r439 17 17 **************************************************************************/ 18 18 19 function messages_install( $version) {19 function messages_install() { 20 20 global $wpdb, $bp; 21 21 … … 79 79 dbDelta($sql); 80 80 81 add_site_option( 'bp-messages-version', $version);81 add_site_option( 'bp-messages-version', BP_MESSAGES_VERSION ); 82 82 } 83 83 … … 115 115 **************************************************************************/ 116 116 117 function messages_ add_admin_menu() {117 function messages_check_installed() { 118 118 global $wpdb, $bp, $userdata; 119 119 120 if ( $wpdb->blogid == $bp['current_homebase_id'] ) { 121 //Add the administration tab under the "Site Admin" tab for site administrators 122 //add_submenu_page ( 'wpmu-admin.php', __('Messages'), __('Messages'), 1, basename(__FILE__), "messages_settings" ); 123 } 124 125 /* Need to check db tables exist, activate hook no-worky in mu-plugins folder. */ 126 if ( ( $wpdb->get_var( "show tables like '%" . $bp['messages']['table_name'] . "%'" ) == false ) || ( get_site_option('bp-messages-version') < BP_MESSAGES_VERSION ) ) 127 messages_install(BP_MESSAGES_VERSION); 128 } 129 add_action( 'admin_menu', 'messages_add_admin_menu' ); 120 if ( is_site_admin() ) { 121 /* Need to check db tables exist, activate hook no-worky in mu-plugins folder. */ 122 if ( ( $wpdb->get_var( "show tables like '%" . $bp['messages']['table_name'] . "%'" ) == false ) || ( get_site_option('bp-messages-version') < BP_MESSAGES_VERSION ) ) 123 messages_install(); 124 } 125 } 126 add_action( 'admin_menu', 'messages_check_installed' ); 130 127 131 128 /************************************************************************** … … 340 337 } 341 338 339 function messages_format_notifications( $action, $item_id, $total_items ) { 340 global $bp; 341 342 if ( $action == 'new_message') { 343 if ( (int)$total_items > 1 ) 344 return '<a href="' . $bp['loggedin_domain'] . $bp['messages']['slug'] . '/inbox" title="Inbox">' . sprintf( __('You have %d new messages'), (int)$total_items ) . '</a>'; 345 else 346 return '<a href="' . $bp['loggedin_domain'] . $bp['messages']['slug'] . '/inbox" title="Inbox">' . sprintf( __('You have %d new message'), (int)$total_items ) . '</a>'; 347 } 348 } 349 350 342 351 /************************************************************************** 343 352 messages_write_new() … … 349 358 <?php 350 359 global $messages_write_new_action; 351 352 if ( $messages_write_new_action == '' )353 $messages_write_new_action = 'admin.php?page=bp-messages.php&mode=send';354 360 ?> 355 361 … … 409 415 } 410 416 411 function messages_inbox() {412 messages_box( 'inbox', __('Inbox', 'buddypress') );413 }414 415 function messages_sentbox() {416 messages_box( 'sentbox', __('Sent Messages', 'buddypress') );417 }418 419 420 /**************************************************************************421 messages_box()422 423 Handles and displays the messages in a particular box for the current user.424 **************************************************************************/425 426 function messages_box( $box = 'inbox', $display_name = 'Inbox', $message = '', $type = '' ) {427 global $bp, $userdata;428 429 if ( isset($_GET['mode']) && isset($_GET['thread_id']) && $_GET['mode'] == 'view' ) {430 messages_view_thread( $_GET['thread_id'], 'inbox' );431 } else if ( isset($_GET['mode']) && isset($_GET['thread_id']) && $_GET['mode'] == 'delete' ) {432 messages_delete_thread( $_GET['thread_id'], $box, $display_name );433 } else if ( isset($_GET['mode']) && isset($_POST['thread_ids']) && $_GET['mode'] == 'delete_bulk' ) {434 messages_delete_thread( $_POST['thread_ids'], $box, $display_name );435 } else if ( isset($_GET['mode']) && $_GET['mode'] == 'send' ) {436 messages_send_message( $_POST['send_to'], $_POST['subject'], $_POST['content'], $_POST['thread_id'] );437 } else {438 ?>439 440 <div class="wrap">441 <h2><?php echo $display_name ?></h2>442 <form action="admin.php?page=bp-messages.php&mode=delete_bulk" method="post">443 444 <?php445 if ( $message != '' ) {446 $type = ( $type == 'error' ) ? 'error' : 'updated';447 ?>448 <div id="message" class="<?php echo $type; ?> fade">449 <p><?php echo $message; ?></p>450 </div>451 <?php } ?>452 453 <?php if ( $box == 'inbox' ) { ?>454 <div class="messages-options">455 <?php bp_messages_options() ?>456 </div>457 458 <?php bp_message_get_notices(); ?>459 <?php } ?>460 461 <table class="widefat" id="message-threads" style="margin-top: 10px;">462 <tbody id="the-list">463 <?php464 $threads = BP_Messages_Thread::get_current_threads_for_user( $userdata->ID, $box );465 466 if ( $threads ) {467 $counter = 0;468 foreach ( $threads as $thread ) {469 if ( $thread->unread_count ) {470 $is_read = '<img src="' . $bp['messages']['image_base'] .'/email.gif" alt="New Message" /><a href="admin.php?page=bp-messages.php&mode=view&thread_id=' . $thread->thread_id . '"><span id="awaiting-mod" class="count-1"><span class="message-count">' . $thread->unread_count . '</span></span></a>';471 $new = " unread";472 } else {473 $is_read = '<img src="' . $bp['messages']['image_base'] .'/email_open.gif" alt="Older Message" />';474 $new = " read";475 }476 477 if ( $counter % 2 == 0 )478 $class = "alternate";479 ?>480 <tr class="<?php echo $class . $new ?>" id="m-<?php echo $message->id ?>">481 <td class="is-read" width="1%"><?php echo $is_read ?></td>482 <td class="avatar" width="1%">483 <?php if ( function_exists('bp_core_get_avatar') )484 echo bp_core_get_avatar($thread->last_sender_id, 1);485 ?>486 </td>487 <td class="sender-details" width="20%">488 <?php if ( $box == 'sentbox') { ?>489 <h3>To: <?php echo BP_Messages_Thread::get_recipient_links($thread->recipients); ?></h3>490 <?php } else { ?>491 <h3>From: <?php echo bp_core_get_userlink($thread->last_sender_id) ?></h3>492 <?php } ?>493 <?php echo bp_format_time(strtotime($thread->last_post_date)) ?>494 </td>495 <td class="message-details" width="40%">496 <h4><a href="admin.php?page=bp-messages.php&mode=view&thread_id=<?php echo $thread->thread_id ?>"><?php echo stripslashes($thread->last_message_subject) ?></a></h4>497 <?php echo bp_create_excerpt($thread->last_message_message, 20); ?>498 </td>499 <td width="10%"><a href="admin.php?page=bp-messages.php&mode=delete&thread_id=<?php echo $thread->thread_id ?>">Delete</a> <input type="checkbox" name="message_ids[]" value="<?php echo $thread->thread_id ?>" /></td>500 </tr>501 <?php502 503 $counter++;504 unset($class);505 unset($new);506 unset($is_read);507 }508 509 echo '510 </tbody>511 </table>512 <p class="submit">513 <input id="deletebookmarks" class="button" type="submit" onclick="return confirm(\'You are about to delete these messages permanently.\n[Cancel] to stop, [OK] to delete.\')" value="Delete Checked Messages »" name="deletebookmarks"/>514 </p>515 </form>516 </div>';517 518 } else {519 ?>520 <tr class="alternate">521 <td colspan="7" style="text-align: center; padding: 15px 0;">522 <?php _e('You have no messages in your', 'buddypress'); echo ' ' . $display_name . '.'; ?>523 </td>524 </tr>525 <?php526 }527 ?>528 </tbody>529 </table>530 </form>531 </div>532 <?php533 }534 }535 536 417 /************************************************************************** 537 418 messages_send_message() … … 603 484 $type = 'success'; 604 485 605 do_action( 'bp_messages_message_sent', array( 'item_id' => $pmessage->id, 'component_name' => 'messages', 'component_action' => 'message_sent', 'is_private' => 1 ) ); 486 // Send notices to the recipients 487 for ( $i = 0; $i < count($pmessage->recipients); $i++ ) { 488 if ( $pmessage->recipients[$i] != $bp['loggedin_userid'] ) 489 bp_core_add_notification( $pmessage->id, $pmessage->recipients[$i], 'messages', 'new_message' ); 490 } 491 492 do_action( 'bp_messages_message_sent', array( 'item_id' => $pmessage->id, 'recipient_ids' => $pmessage->recipients, 'component_name' => 'messages', 'component_action' => 'message_sent', 'is_private' => 1 ) ); 606 493 607 494 if ( $from_ajax ) { -
trunk/bp-messages/bp-messages-templatetags.php
r391 r439 102 102 wp_die('No Access'); 103 103 } else { 104 if ( $bp['current_action'] == 'inbox' ) 105 bp_core_delete_notifications_for_user_by_type( $bp['loggedin_userid'], 'messages', 'new_message' ); 106 104 107 $messages_template = new BP_Messages_Template( $bp['loggedin_userid'], $bp['current_action'] ); 105 108 } -
trunk/bp-wire.php
r398 r439 18 18 **************************************************************************/ 19 19 20 function bp_wire_install( $version) {20 function bp_wire_install() { 21 21 global $wpdb, $bp; 22 22 23 23 // No DB tables need to be installed, DB tables for each component wire 24 24 // are set up within that component *if* this component is installed. 25 26 add_site_option( 'bp-wire-version', $version ); 25 add_site_option( 'bp-wire-version', BP_WIRE_VERSION ); 27 26 } 28 27 … … 38 37 39 38 if ( get_site_option('bp-wire-version') < BP_WIRE_VERSION ) { 40 bp_wire_install( BP_WIRE_VERSION);39 bp_wire_install(); 41 40 } 42 41 … … 183 182 } 184 183 184 185 185 ?> -
trunk/bp-wire/bp-wire-templatetags.php
r436 r439 23 23 if ( $bp['current_component'] == $bp['wire']['slug'] ) { 24 24 $this->table_name = $bp['profile']['table_name_wire']; 25 26 // Seeing as we're viewing a users wire, lets remove any new wire 27 // post notifications 28 if ( $bp['current_action'] == 'all-posts' ) 29 bp_core_delete_notifications_for_user_by_type( $bp['loggedin_userid'], 'xprofile', 'new_wire_post' ); 30 25 31 } else { 26 32 $this->table_name = $bp[$bp['current_component']]['table_name_wire']; -
trunk/bp-xprofile.php
r438 r439 20 20 **************************************************************************/ 21 21 22 function xprofile_install( $version) {22 function xprofile_install() { 23 23 global $bp; 24 24 … … 97 97 98 98 dbDelta($sql); 99 add_site_option('bp-xprofile-version', $version);99 add_site_option('bp-xprofile-version', BP_XPROFILE_VERSION); 100 100 } 101 101 … … 142 142 global $wpdb, $bp, $groups, $userdata; 143 143 144 if ( $wpdb->blogid == $bp['current_homebase_id'] ) {145 add_menu_page( __('Profile', 'buddypress'), __('Profile', 'buddypress'), 1, basename(__FILE__), 'bp_core_avatar_admin' );146 add_submenu_page( basename(__FILE__), __('Profile › Avatar', 'buddypress'), __('Avatar', 'buddypress'), 1, basename(__FILE__), 'xprofile_avatar_admin' );147 148 $groups = BP_XProfile_Group::get_all();149 150 for ( $i=0; $i < count($groups); $i++ ) {151 if ( $groups[$i]->fields ) {152 add_submenu_page( basename(__FILE__), __('Profile', 'buddypress') . ' › ' . $groups[$i]->name, $groups[$i]->name, 1, "xprofile_" . $groups[$i]->name, "xprofile_edit" );153 }154 }155 }156 157 144 if ( is_site_admin() ) { 158 145 wp_enqueue_script( 'jquery.tablednd', '/wp-content/mu-plugins/bp-core/js/jquery/jquery.tablednd.js', array( 'jquery' ), '0.4' ); … … 160 147 /* Add the administration tab under the "Site Admin" tab for site administrators */ 161 148 add_submenu_page( 'wpmu-admin.php', __("Profiles", 'buddypress'), __("Profiles", 'buddypress'), 1, "xprofile_settings", "xprofile_admin" ); 162 } 163 164 /* Need to check db tables exist, activate hook no-worky in mu-plugins folder. */ 165 if ( ( $wpdb->get_var("show tables like '%" . $bp['profile']['table_name_groups'] . "%'") == false ) || ( get_site_option('bp-xprofile-version') < BP_XPROFILE_VERSION ) ) 166 xprofile_install(BP_XPROFILE_VERSION); 167 149 150 /* Need to check db tables exist, activate hook no-worky in mu-plugins folder. */ 151 if ( ( $wpdb->get_var("show tables like '%" . $bp['profile']['table_name_groups'] . "%'") == false ) || ( get_site_option('bp-xprofile-version') < BP_XPROFILE_VERSION ) ) 152 xprofile_install(); 153 } 168 154 } 169 155 add_action( 'admin_menu', 'xprofile_add_admin_menu' ); … … 282 268 return false; 283 269 284 return bp_core_get_userlink($bp['current_userid']) . ' ' . __('updated the', 'buddypress') . ' "<a href="' . $bp['current_domain'] . $bp['profile']['slug'] . '">' . $profile_group->name . '</a>" ' . __('information on your profile', 'buddypress') . '. <span class="time-since">%s</span>';270 return bp_core_get_userlink($bp['current_userid']) . ' ' . __('updated the', 'buddypress') . ' "<a href="' . $bp['current_domain'] . $bp['profile']['slug'] . '">' . $profile_group->name . '</a>" ' . __('information on their profile', 'buddypress') . '. <span class="time-since">%s</span>'; 285 271 break; 286 272 } … … 288 274 return false; 289 275 } 276 277 function xprofile_format_notifications( $action, $item_id, $total_items ) { 278 global $bp; 279 280 if ( $action == 'new_wire_post') { 281 if ( (int)$total_items > 1 ) { 282 return '<a href="' . $bp['loggedin_domain'] . $bp['wire']['slug'] . '" title="Wire">' . sprintf( __('You have %d new posts on your wire'), (int)$total_items ) . '</a>'; 283 } else { 284 $user_fullname = bp_core_global_user_fullname( $item_id ); 285 return '<a href="' . $bp['loggedin_domain'] . $bp['wire']['slug'] . '" title="Wire">' . sprintf( __('%s posted on your wire'), $user_fullname ) . '</a>'; 286 } 287 } 288 289 return false; 290 } 291 292 function xprofile_record_wire_post_notification( $wire_post_id, $user_id, $poster_id ) { 293 global $bp; 294 295 if ( $bp['current_component'] == $bp['wire']['slug'] && !bp_is_home() ) 296 bp_core_add_notification( $poster_id, $user_id, 'xprofile', 'new_wire_post' ); 297 } 298 add_action( 'bp_wire_post_posted', 'xprofile_record_wire_post_notification', 10, 3 ); 290 299 291 300 /**************************************************************************
Note: See TracChangeset
for help on using the changeset viewer.