Changeset 3917
- Timestamp:
- 01/25/2011 08:58:56 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 7 added
- 8 deleted
- 48 edited
- 8 copied
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-activity/bp-activity-actions.php
r3772 r3917 62 62 bp_core_redirect( $redirect ); 63 63 } 64 add_action( ' wp', 'bp_activity_action_permalink_router', 3);64 add_action( 'bp_actions', 'bp_activity_action_permalink_router' ); 65 65 66 66 function bp_activity_action_delete_activity() { … … 100 100 bp_core_redirect( wp_get_referer() ); 101 101 } 102 add_action( ' wp', 'bp_activity_action_delete_activity', 3);102 add_action( 'bp_actions', 'bp_activity_action_delete_activity' ); 103 103 104 104 function bp_activity_action_post_update() { … … 147 147 bp_core_redirect( wp_get_referer() ); 148 148 } 149 add_action( ' wp', 'bp_activity_action_post_update', 3);149 add_action( 'bp_actions', 'bp_activity_action_post_update' ); 150 150 151 151 function bp_activity_action_post_comment() { … … 179 179 bp_core_redirect( wp_get_referer() . '#ac-form-' . $activity_id ); 180 180 } 181 add_action( ' wp', 'bp_activity_action_post_comment', 3);181 add_action( 'bp_actions', 'bp_activity_action_post_comment' ); 182 182 183 183 function bp_activity_action_mark_favorite() { … … 197 197 bp_core_redirect( wp_get_referer() . '#activity-' . $bp->action_variables[0] ); 198 198 } 199 add_action( ' wp', 'bp_activity_action_mark_favorite', 3);199 add_action( 'bp_actions', 'bp_activity_action_mark_favorite' ); 200 200 201 201 function bp_activity_action_remove_favorite() { … … 215 215 bp_core_redirect( wp_get_referer() . '#activity-' . $bp->action_variables[0] ); 216 216 } 217 add_action( ' wp', 'bp_activity_action_remove_favorite', 3);217 add_action( 'bp_actions', 'bp_activity_action_remove_favorite' ); 218 218 219 219 function bp_activity_action_sitewide_feed() { … … 229 229 die; 230 230 } 231 add_action( ' wp', 'bp_activity_action_sitewide_feed', 3);231 add_action( 'bp_actions', 'bp_activity_action_sitewide_feed' ); 232 232 233 233 function bp_activity_action_personal_feed() { … … 243 243 die; 244 244 } 245 add_action( ' wp', 'bp_activity_action_personal_feed', 3);245 add_action( 'bp_actions', 'bp_activity_action_personal_feed' ); 246 246 247 247 function bp_activity_action_friends_feed() { … … 257 257 die; 258 258 } 259 add_action( ' wp', 'bp_activity_action_friends_feed', 3);259 add_action( 'bp_actions', 'bp_activity_action_friends_feed' ); 260 260 261 261 function bp_activity_action_my_groups_feed() { … … 271 271 die; 272 272 } 273 add_action( ' wp', 'bp_activity_action_my_groups_feed', 3);273 add_action( 'bp_actions', 'bp_activity_action_my_groups_feed' ); 274 274 275 275 function bp_activity_action_mentions_feed() { … … 285 285 die; 286 286 } 287 add_action( ' wp', 'bp_activity_action_mentions_feed', 3);287 add_action( 'bp_actions', 'bp_activity_action_mentions_feed' ); 288 288 289 289 function bp_activity_action_favorites_feed() { … … 299 299 die; 300 300 } 301 add_action( ' wp', 'bp_activity_action_favorites_feed', 3);301 add_action( 'bp_actions', 'bp_activity_action_favorites_feed' ); 302 302 303 303 ?> -
trunk/bp-activity/bp-activity-classes.php
r3903 r3917 151 151 152 152 // Get the fullnames of users so we don't have to query in the loop 153 if ( bp_is_active( ' profile' ) && $activities ) {153 if ( bp_is_active( 'xprofile' ) && $activities ) { 154 154 foreach ( (array)$activities as $activity ) { 155 155 if ( (int)$activity->user_id ) … … 365 365 // Select the user's fullname with the query so we don't have to 366 366 // fetch it for each comment 367 if ( bp_is_active( ' profile' ) ) {367 if ( bp_is_active( 'xprofile' ) ) { 368 368 $fullname_select = ", pd.value as user_fullname"; 369 369 $fullname_from = ", {$bp->profile->table_name_data} pd "; -
trunk/bp-activity/bp-activity-loader.php
r3800 r3917 18 18 */ 19 19 function BP_Activity_Component() { 20 parent::start( 'activity', __( 'Activity Streams', 'buddypress' ) ); 20 parent::start( 21 'activity', 22 __( 'Activity Streams', 'buddypress' ), 23 BP_PLUGIN_DIR 24 ); 25 } 26 27 /** 28 * Include files 29 */ 30 function _includes() { 31 // Files to include 32 $includes = array( 33 'actions', 34 'screens', 35 'filters', 36 'classes', 37 'template', 38 'functions', 39 'notifications', 40 ); 41 42 parent::_includes( $includes ); 21 43 } 22 44 … … 37 59 define( 'BP_ACTIVITY_SLUG', $this->id ); 38 60 39 // Do some slug checks 40 $this->slug = BP_ACTIVITY_SLUG; 41 $this->root_slug = isset( $bp->pages->activity->slug ) ? $bp->pages->activity->slug : $this->slug; 42 43 // Tables 44 $this->table_name = $bp->table_prefix . 'bp_activity'; 45 $this->table_name_meta = $bp->table_prefix . 'bp_activity_meta'; 46 47 // Register this in the active components array 48 $bp->active_components[$this->id] = $this->id; 49 50 // The default text for the blogs directory search box 51 $bp->default_search_strings[$this->id] = __( 'Search Activity...', 'buddypress' ); 52 } 53 54 /** 55 * Include files 56 */ 57 function _includes() { 58 require_once( BP_PLUGIN_DIR . '/bp-activity/bp-activity-actions.php' ); 59 require_once( BP_PLUGIN_DIR . '/bp-activity/bp-activity-filters.php' ); 60 require_once( BP_PLUGIN_DIR . '/bp-activity/bp-activity-screens.php' ); 61 require_once( BP_PLUGIN_DIR . '/bp-activity/bp-activity-classes.php' ); 62 require_once( BP_PLUGIN_DIR . '/bp-activity/bp-activity-template.php' ); 63 require_once( BP_PLUGIN_DIR . '/bp-activity/bp-activity-functions.php' ); 61 // Global tables for messaging component 62 $global_tables = array( 63 'table_name' => $bp->table_prefix . 'bp_activity', 64 'table_name_meta' => $bp->table_prefix . 'bp_activity_meta', 65 ); 66 67 // All globals for messaging component. 68 // Note that global_tables is included in this array. 69 $globals = array( 70 'path' => BP_PLUGIN_DIR, 71 'slug' => BP_ACTIVITY_SLUG, 72 'root_slug' => isset( $bp->pages->activity->slug ) ? $bp->pages->activity->slug : BP_ACTIVITY_SLUG, 73 'search_string' => __( 'Search Activity...', 'buddypress' ), 74 'global_tables' => $global_tables, 75 ); 76 77 parent::_setup_globals( $globals ); 64 78 } 65 79 … … 73 87 74 88 // Add 'Activity' to the main navigation 75 bp_core_new_nav_item(array(89 $main_nav = array( 76 90 'name' => __( 'Activity', 'buddypress' ), 77 91 'slug' => $this->slug, … … 79 93 'screen_function' => 'bp_activity_screen_my_activity', 80 94 'default_subnav_slug' => 'just-me', 81 'item_css_id' => $this->id )95 'item_css_id' => $this->id 82 96 ); 83 97 … … 101 115 102 116 // Add the subnav items to the activity nav item if we are using a theme that supports this 103 bp_core_new_subnav_item(array(117 $sub_nav[] = array( 104 118 'name' => __( 'Personal', 'buddypress' ), 105 119 'slug' => 'just-me', … … 108 122 'screen_function' => 'bp_activity_screen_my_activity', 109 123 'position' => 10 110 ) );124 ); 111 125 112 126 // Additional menu if friends is active 113 127 if ( bp_is_active( 'friends' ) ) { 114 bp_core_new_subnav_item(array(128 $sub_nav[] = array( 115 129 'name' => __( 'Friends', 'buddypress' ), 116 130 'slug' => $bp->friends->slug, … … 120 134 'position' => 20, 121 135 'item_css_id' => 'activity-friends' 122 ) );136 ) ; 123 137 } 124 138 125 139 // Additional menu if groups is active 126 140 if ( bp_is_active( 'groups' ) ) { 127 bp_core_new_subnav_item(array(141 $sub_nav[] = array( 128 142 'name' => __( 'Groups', 'buddypress' ), 129 143 'slug' => $bp->groups->slug, … … 133 147 'position' => 30, 134 148 'item_css_id' => 'activity-groups' 135 ) );149 ); 136 150 } 137 151 138 152 // Favorite activity items 139 bp_core_new_subnav_item(array(153 $sub_nav[] = array( 140 154 'name' => __( 'Favorites', 'buddypress' ), 141 155 'slug' => 'favorites', … … 145 159 'position' => 40, 146 160 'item_css_id' => 'activity-favs' 147 ) );161 ); 148 162 149 163 // @ mentions 150 bp_core_new_subnav_item(array(164 $sub_nav[] = array( 151 165 'name' => sprintf( __( '@%s Mentions', 'buddypress' ), $user_login ), 152 166 'slug' => 'mentions', … … 156 170 'position' => 50, 157 171 'item_css_id' => 'activity-mentions' 158 ) ); 172 ); 173 174 parent::_setup_nav( $main_nav, $sub_nav ); 175 } 176 177 /** 178 * Sets up the title for pages and <title> 179 * 180 * @global obj $bp 181 */ 182 function _setup_title() { 183 global $bp; 159 184 160 185 // Adjust title based on view … … 170 195 } 171 196 } 197 198 parent::_setup_title(); 172 199 } 173 200 } -
trunk/bp-activity/bp-activity-notifications.php
r3771 r3917 24 24 continue; 25 25 26 bp_ users_add_notification( $activity_id, $receiver_user_id, 'activity', 'new_at_mention', $poster_user_id );26 bp_members_add_notification( $activity_id, $receiver_user_id, 'activity', 'new_at_mention', $poster_user_id ); 27 27 28 28 $subject = ''; -
trunk/bp-activity/bp-activity-screens.php
r3844 r3917 25 25 } 26 26 } 27 add_action( ' wp', 'bp_activity_screen_index', 2);27 add_action( 'bp_screens', 'bp_activity_screen_index' ); 28 28 29 29 function bp_activity_screen_my_activity() { … … 89 89 global $bp; 90 90 91 bp_ users_delete_notifications_by_type( $bp->loggedin_user->id, $bp->activity->id, 'new_at_mention' );91 bp_members_delete_notifications_by_type( $bp->loggedin_user->id, $bp->activity->id, 'new_at_mention' ); 92 92 } 93 93 add_action( 'bp_activity_screen_my_activity', 'bp_activity_remove_screen_notifications' ); … … 161 161 bp_core_load_template( apply_filters( 'bp_activity_template_profile_activity_permalink', 'members/single/activity/permalink' ) ); 162 162 } 163 add_action( ' wp', 'bp_activity_screen_single_activity_permalink', 3);163 add_action( 'bp_screens', 'bp_activity_screen_single_activity_permalink' ); 164 164 165 165 function bp_activity_screen_notification_settings() { -
trunk/bp-activity/bp-activity-template.php
r3904 r3917 1049 1049 1050 1050 // Make sure all core internal component names are translatable 1051 $translatable_components = array( __( ' profile', 'buddypress'), __( 'friends', 'buddypress' ), __( 'groups', 'buddypress' ), __( 'status', 'buddypress' ), __( 'blogs', 'buddypress' ) );1051 $translatable_components = array( __( 'xprofile', 'buddypress'), __( 'friends', 'buddypress' ), __( 'groups', 'buddypress' ), __( 'status', 'buddypress' ), __( 'blogs', 'buddypress' ) ); 1052 1052 1053 1053 $component_links[] = $before . '<a href="' . esc_attr( $link ) . '">' . ucwords( __( $component, 'buddypress' ) ) . '</a>' . $after; -
trunk/bp-blogs/bp-blogs-actions.php
r3761 r3917 1 1 <?php 2 2 3 function bp_blogs_redirect_to_random_blog() { 4 global $bp, $wpdb; 5 6 if ( bp_is_blogs_component() && isset( $_GET['random-blog'] ) ) { 7 $blog = bp_blogs_get_random_blogs( 1, 1 ); 8 9 bp_core_redirect( get_site_url( $blog['blogs'][0]->blog_id ) ); 10 } 11 } 12 add_action( 'bp_actions', 'bp_blogs_redirect_to_random_blog' ); 13 3 14 ?> -
trunk/bp-blogs/bp-blogs-functions.php
r3903 r3917 412 412 } 413 413 414 function bp_blogs_redirect_to_random_blog() {415 global $bp, $wpdb;416 417 if ( $bp->current_component == $bp->blogs->slug && isset( $_GET['random-blog'] ) ) {418 $blog = bp_blogs_get_random_blogs( 1, 1 );419 420 bp_core_redirect( get_site_url( $blog['blogs'][0]->blog_id ) );421 }422 }423 add_action( 'wp', 'bp_blogs_redirect_to_random_blog', 6 );424 425 426 414 /******************************************************************************* 427 415 * Blog meta functions -
trunk/bp-blogs/bp-blogs-loader.php
r3855 r3917 18 18 */ 19 19 function BP_Blogs_Component() { 20 parent::start( 'blogs', __( 'Blogs Streams', 'buddypress' ) ); 20 parent::start( 21 'blogs', 22 __( 'Blogs Streams', 'buddypress' ), 23 BP_PLUGIN_DIR 24 ); 21 25 } 22 26 … … 36 40 define ( 'BP_BLOGS_SLUG', $this->id ); 37 41 38 // Do some slug checks 39 $this->slug = BP_BLOGS_SLUG; 40 $this->root_slug = isset( $bp->pages->blogs->slug ) ? $bp->pages->blogs->slug : $this->slug; 42 // Global tables for messaging component 43 $global_tables = array( 44 'table_name' => $bp->table_prefix . 'bp_user_blogs', 45 'table_name_blogmeta' => $bp->table_prefix . 'bp_user_blogs_blogmeta', 46 ); 41 47 42 // Tables 43 $this->table_name = $bp->table_prefix . 'bp_user_blogs'; 44 $this->table_name_blogmeta = $bp->table_prefix . 'bp_user_blogs_blogmeta'; 48 // All globals for messaging component. 49 // Note that global_tables is included in this array. 50 $globals = array( 51 'path' => BP_PLUGIN_DIR, 52 'slug' => BP_BLOGS_SLUG, 53 'root_slug' => isset( $bp->pages->blogs->slug ) ? $bp->pages->blogs->slug : BP_BLOGS_SLUG, 54 'notification_callback' => 'bp_blogs_format_notifications', 55 'search_string' => __( 'Search Blogs...', 'buddypress' ), 56 'autocomplete_all' => defined( 'BP_MESSAGES_AUTOCOMPLETE_ALL' ), 57 'global_tables' => $global_tables, 58 ); 45 59 46 // Notifications 47 $this->notification_callback = 'bp_blogs_format_notifications'; 48 49 // Register this in the active components array 50 $bp->active_components[$this->id] = $this->id; 51 52 // The default text for the blogs directory search box 53 $bp->default_search_strings[$this->id] = __( 'Search Blogs...', 'buddypress' ); 60 // Setup the globals 61 parent::_setup_globals( $globals ); 54 62 } 55 63 … … 58 66 */ 59 67 function _includes() { 60 require_once( BP_PLUGIN_DIR . '/bp-blogs/bp-blogs-cache.php' ); 61 require_once( BP_PLUGIN_DIR . '/bp-blogs/bp-blogs-classes.php' ); 62 require_once( BP_PLUGIN_DIR . '/bp-blogs/bp-blogs-screens.php' ); 63 require_once( BP_PLUGIN_DIR . '/bp-blogs/bp-blogs-actions.php' ); 64 require_once( BP_PLUGIN_DIR . '/bp-blogs/bp-blogs-activity.php' ); 65 require_once( BP_PLUGIN_DIR . '/bp-blogs/bp-blogs-template.php' ); 66 require_once( BP_PLUGIN_DIR . '/bp-blogs/bp-blogs-functions.php' ); 68 // Files to include 69 $includes = array( 70 'cache', 71 'actions', 72 'screens', 73 'classes', 74 'template', 75 'activity', 76 'functions', 77 ); 67 78 68 79 if ( is_multisite() ) 69 require_once( BP_PLUGIN_DIR . '/bp-blogs/bp-blogs-widgets.php' ); 80 $includes[] = 'widgets'; 81 82 // Include the files 83 parent::_includes( $includes ); 70 84 } 71 85 … … 87 101 88 102 // Add 'Blogs' to the main navigation 89 bp_core_new_nav_item(array(103 $main_nav = array( 90 104 'name' => sprintf( __( 'Blogs <span>(%d)</span>', 'buddypress' ), bp_blogs_total_blogs_for_user() ), 91 105 'slug' => $this->slug, … … 94 108 'default_subnav_slug' => 'my-blogs', 95 109 'item_css_id' => $this->id 96 ) ); 110 ); 111 112 // Setup navigation 113 parent::_setup_nav( $main_nav, $sub_nav ); 114 } 115 116 /** 117 * Sets up the title for pages and <title> 118 * 119 * @global obj $bp 120 */ 121 function _setup_title() { 122 global $bp; 97 123 98 124 // Set up the component options navigation for Blog 99 if ( $bp->blogs->slug == $bp->current_component) {125 if ( bp_is_blogs_component() ) { 100 126 if ( bp_is_my_profile() ) { 101 127 if ( function_exists('xprofile_setup_nav') ) { … … 113 139 } 114 140 } 141 142 parent::_setup_title(); 115 143 } 116 144 } -
trunk/bp-blogs/bp-blogs-screens.php
r3763 r3917 8 8 9 9 function bp_blogs_screen_my_blogs() { 10 global $bp;11 12 10 if ( !is_multisite() ) 13 11 return false; … … 19 17 20 18 function bp_blogs_screen_create_a_blog() { 21 global $bp; 22 23 if ( !is_multisite() || $bp->current_component != $bp->blogs->slug || 'create' != $bp->current_action ) 19 if ( !is_multisite() || !bp_is_blogs_component() || !bp_is_current_action( 'create' ) ) 24 20 return false; 25 21 … … 31 27 bp_core_load_template( apply_filters( 'bp_blogs_template_create_a_blog', 'blogs/create' ) ); 32 28 } 33 add_action( ' wp', 'bp_blogs_screen_create_a_blog', 3 );29 add_action( 'bp_screens', 'bp_blogs_screen_create_a_blog', 3 ); 34 30 35 31 function bp_blogs_screen_index() { 36 32 global $bp; 37 33 38 if ( is_multisite() && $bp->current_component == $bp->blogs->slug && empty( $bp->current_action) ) {34 if ( is_multisite() && bp_is_blogs_component() && !bp_current_action() ) { 39 35 $bp->is_directory = true; 40 36 … … 44 40 } 45 41 } 46 add_action( ' wp', 'bp_blogs_screen_index', 2 );42 add_action( 'bp_screens', 'bp_blogs_screen_index', 2 ); 47 43 48 44 ?> -
trunk/bp-core/admin/bp-core-admin.php
r3790 r3917 101 101 foreach ( (array)$_POST['bp-admin'] as $key => $value ) { 102 102 103 if ( bp_is_active( ' profile' ) ) {103 if ( bp_is_active( 'xprofile' ) ) { 104 104 if ( 'bp-xprofile-base-group-name' == $key ) 105 105 $wpdb->query( $wpdb->prepare( "UPDATE {$bp->profile->table_name_groups} SET name = %s WHERE id = 1", stripslashes( $value ) ) ); … … 130 130 <tbody> 131 131 132 <?php if ( bp_is_active( ' profile' ) ) : ?>132 <?php if ( bp_is_active( 'xprofile' ) ) : ?> 133 133 134 134 <tr> -
trunk/bp-core/bp-core-buddybar.php
r3861 r3917 63 63 if ( bp_is_current_component( $slug ) && !bp_current_action() ) { 64 64 if ( !is_object( $screen_function[0] ) ) 65 add_action( ' wp', $screen_function, 3);65 add_action( 'bp_screens', $screen_function ); 66 66 else 67 add_action( ' wp', array( &$screen_function[0], $screen_function[1] ), 3 );67 add_action( 'bp_screens', array( &$screen_function[0], $screen_function[1] ), 3 ); 68 68 69 69 if ( !empty( $default_subnav_slug ) ) … … 92 92 if ( $function = $bp->bp_nav[$parent_slug]['screen_function'] ) { 93 93 if ( !is_object( $function[0] ) ) 94 remove_action( ' wp', $function, 3 );94 remove_action( 'bp_screens', $function, 3 ); 95 95 else 96 remove_action( ' wp', array( &$function[0], $function[1] ), 3 );96 remove_action( 'bp_screens', array( &$function[0], $function[1] ), 3 ); 97 97 } 98 98 … … 101 101 if ( $bp->current_component == $parent_slug && !$bp->current_action ) { 102 102 if ( !is_object( $screen_function[0] ) ) 103 add_action( ' wp', $screen_function, 3);103 add_action( 'bp_screens', $screen_function ); 104 104 else 105 add_action( ' wp', array( &$screen_function[0], $screen_function[1] ), 3);105 add_action( 'bp_screens', array( &$screen_function[0], $screen_function[1] ) ); 106 106 107 107 if ( $subnav_slug ) … … 189 189 if ( ( $bp->current_action == $slug && $bp->current_component == $parent_slug ) && $user_has_access ) { 190 190 if ( !is_object( $screen_function[0] ) ) 191 add_action( ' wp', $screen_function, 3);191 add_action( 'bp_screens', $screen_function ); 192 192 else 193 add_action( ' wp', array( &$screen_function[0], $screen_function[1] ), 3);193 add_action( 'bp_screens', array( &$screen_function[0], $screen_function[1] ) ); 194 194 } 195 195 } … … 244 244 if ( $function = $bp->bp_nav[$parent_id]['screen_function'] ) { 245 245 if ( !is_object( $function[0] ) ) { 246 remove_action( ' wp', $function, 3);246 remove_action( 'bp_screens', $function ); 247 247 } else { 248 remove_action( ' wp', array( &$function[0], $function[1] ), 3);248 remove_action( 'bp_screens', array( &$function[0], $function[1] ) ); 249 249 } 250 250 } … … 267 267 if ( $screen_function ) { 268 268 if ( !is_object( $screen_function[0] ) ) 269 remove_action( ' wp', $screen_function, 3);269 remove_action( 'bp_screens', $screen_function ); 270 270 else 271 remove_action( ' wp', array( &$screen_function[0], $screen_function[1] ), 3);271 remove_action( 'bp_screens', array( &$screen_function[0], $screen_function[1] ) ); 272 272 } 273 273 … … 484 484 _e( 'Notifications', 'buddypress' ); 485 485 486 if ( $notifications = bp_ users_get_notifications_for_user( $bp->loggedin_user->id ) ) { ?>486 if ( $notifications = bp_members_get_notifications_for_user( $bp->loggedin_user->id ) ) { ?> 487 487 <span><?php echo count( $notifications ) ?></span> 488 488 <?php -
trunk/bp-core/bp-core-catchuri.php
r3884 r3917 21 21 * Example: 22 22 * - http://domain.com/members/andy/profile/edit/group/5/ 23 * - $bp->current_component: string ' profile'23 * - $bp->current_component: string 'xprofile' 24 24 * - $bp->current_action: string 'edit' 25 25 * - $bp->action_variables: array ['group', 5] … … 280 280 global $bp; 281 281 282 if ( !bp_is_active( ' profile' ) )282 if ( !bp_is_active( 'xprofile' ) ) 283 283 bp_core_load_template( apply_filters( 'bp_core_template_display_profile', 'members/single/home' ) ); 284 284 } -
trunk/bp-core/bp-core-classes.php
r3909 r3917 56 56 */ 57 57 function populate() { 58 if ( bp_is_active( ' profile' ) )58 if ( bp_is_active( 'xprofile' ) ) 59 59 $this->profile_data = $this->get_profile_data(); 60 60 … … 124 124 $sql['from'] = "FROM " . CUSTOM_USER_TABLE . " u LEFT JOIN " . CUSTOM_USER_META_TABLE . " um ON um.user_id = u.ID"; 125 125 126 if ( $search_terms && bp_is_active( ' profile' ) || 'alphabetical' == $type )126 if ( $search_terms && bp_is_active( 'xprofile' ) || 'alphabetical' == $type ) 127 127 $sql['join_profiledata'] = "LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id"; 128 128 … … 167 167 } 168 168 169 if ( $search_terms && bp_is_active( ' profile' ) ) {169 if ( $search_terms && bp_is_active( 'xprofile' ) ) { 170 170 $search_terms = like_escape( $wpdb->escape( $search_terms ) ); 171 171 $sql['where_searchterms'] = "AND pd.value LIKE '%%$search_terms%%'"; … … 349 349 350 350 // Fetch the user's full name 351 if ( bp_is_active( ' profile' ) && 'alphabetical' != $type ) {351 if ( bp_is_active( 'xprofile' ) && 'alphabetical' != $type ) { 352 352 // Ensure xprofile globals are set 353 353 if ( !defined( 'BP_XPROFILE_FULLNAME_FIELD_NAME' ) ) -
trunk/bp-core/bp-core-component.php
r3751 r3917 34 34 35 35 /** 36 * @var string The path to the plugins files 37 */ 38 var $path; 39 40 /** 36 41 * @var WP_Query The loop for this component 37 42 */ … … 63 68 * @uses bp_Component::_setup_actions() Setup the hooks and actions 64 69 */ 65 function start( $id, $name ) {70 function start( $id, $name, $path ) { 66 71 // Internal identifier of component 67 72 $this->id = $id; … … 70 75 $this->name = $name; 71 76 72 $this->_setup_actions (); 77 // Path for includes 78 $this->path = $path; 79 80 // Move on to the next step 81 $this->_setup_actions(); 73 82 } 74 83 … … 90 99 91 100 $defaults = array( 92 'slug' => '', 93 'root_slug' => '' 101 'slug' => '', 102 'root_slug' => '', 103 'notification_callback' => '', 104 'global_tables' => '' 94 105 ); 95 106 $r = wp_parse_args( $args, $defaults ); … … 101 112 $this->root_slug = apply_filters( 'bp_' . $this->id . '_root_slug', $r['root_slug'] ); 102 113 114 // Notifications callback 115 $this->notification_callback = 'bp_' . $this->id . '_notification_callback'; 116 117 // Setup global table names 118 if ( !empty( $r['global_tables'] ) ) 119 foreach ( $r['global_tables'] as $global_name => $table_name ) 120 $this->$global_name = $table_name; 121 103 122 /** BuddyPress ********************************************************/ 104 123 105 // Avoid syntactical errors106 $component_id = $this->id;107 108 124 // Register this component in the active components array 109 $bp->active_components[$ bp->$component_id->slug] = $this->id;110 111 // Notifications callback112 $bp->$component_id->notification_callback = apply_filters( 'bp_' . $this->id . '_format_notifications', 'bp_' . $this->id . '_format_notifications' );125 $bp->active_components[$this->slug] = $this->id; 126 127 // Call action 128 do_action( 'bp_' . $this->id . '_setup_globals' ); 113 129 } 114 130 … … 121 137 * @uses do_action() Calls 'bp_{@link bp_Component::name}_includes' 122 138 */ 123 function _includes() { 139 function _includes( $includes = '' ) { 140 if ( empty( $includes ) ) 141 return; 142 143 // Loop through files to be included 144 foreach ( $includes as $file ) { 145 146 // Check path + file 147 if ( file_exists( $this->path . '/' . $file ) ) 148 require_once( $this->path . '/' . $file ); 149 150 // Check path + /bp-component/ + file 151 elseif ( file_exists( $this->path . '/bp-' . $this->id . '/' . $file ) ) 152 require_once( $this->$path . '/bp-' . $this->id . '/' . $file ); 153 154 // Check buddypress/bp-component/bp-component-$file.php 155 elseif ( file_exists( $this->path . '/bp-' . $this->id . '/bp-' . $this->id . '-' . $file . '.php' ) ) 156 require_once( $this->path . '/bp-' . $this->id . '/bp-' . $this->id . '-' . $file . '.php' ); 157 158 } 159 160 // Call action 124 161 do_action( 'bp_' . $this->id . '_includes' ); 125 162 } … … 145 182 146 183 // Register post types 184 add_action( 'bp_setup_title', array ( $this, '_setup_title' ), 10 ); 185 186 // Register post types 147 187 add_action( 'bp_register_post_types', array ( $this, 'register_post_types' ), 10 ); 148 188 … … 161 201 162 202 /** 203 * Setup the navigation 204 * 205 * @param arr $main_nav 206 * @param arr $sub_nav 207 */ 208 function _setup_nav( $main_nav, $sub_nav ) { 209 bp_core_new_nav_item( $main_nav ); 210 211 foreach( $sub_nav as $nav ) 212 bp_core_new_subnav_item( $nav ); 213 214 // Call action 215 do_action( 'bp_' . $this->id . '_setup_nav' ); 216 } 217 218 219 function _setup_title( ) { 220 221 } 222 223 /** 163 224 * Setup the component post types 164 225 * … … 204 265 } 205 266 } 206 endif; // bp_Component 267 endif; // BP_Component 268 269 ?> -
trunk/bp-core/bp-core-functions.php
r3802 r3917 249 249 @setcookie( 'bp-message-type', false, time() - 1000, COOKIEPATH ); 250 250 } 251 add_action( ' wp', 'bp_core_setup_message', 2);251 add_action( 'bp_actions', 'bp_core_setup_message' ); 252 252 253 253 /** … … 317 317 ); 318 318 319 if ( ! is_numeric( $older_date ) ) {319 if ( !empty( $older_date ) && !is_numeric( $older_date ) ) { 320 320 $time_chunks = explode( ':', str_replace( ' ', ':', $older_date ) ); 321 321 $date_chunks = explode( '-', str_replace( ' ', '-', $older_date ) ); -
trunk/bp-core/bp-core-hooks.php
r3874 r3917 7 7 add_action( 'bp_loaded', 'bp_include', 2 ); 8 8 9 add_action( 'wp', 'bp_actions', 2 ); 10 11 add_action( 'wp', 'bp_screens', 2 ); 9 12 10 13 /** Init **********************************************************************/ 11 14 12 15 // Attach bp_init to WordPress init 13 add_action( 'init', 'bp_init');16 add_action( 'init', 'bp_init' ); 14 17 15 18 // Parse the URI and set globals 16 add_action( 'bp_init', 'bp_core_set_uri_globals',2 );19 add_action( 'bp_init', 'bp_core_set_uri_globals', 2 ); 17 20 18 21 // Setup component globals 19 add_action( 'bp_init', 'bp_setup_globals', 4 ); 20 21 // Setup root directories for components 22 add_action( 'bp_init', 'bp_setup_root_components', 6 ); 22 add_action( 'bp_init', 'bp_setup_globals', 4 ); 23 23 24 24 // Setup the navigation menu 25 add_action( 'bp_init', 'bp_setup_nav',8 );25 add_action( 'bp_init', 'bp_setup_nav', 8 ); 26 26 27 27 // Setup widgets 28 add_action( 'bp_init', 'bp_setup_widgets',8 );28 add_action( 'bp_init', 'bp_setup_widgets', 8 ); 29 29 30 30 // Setup admin bar 31 add_action( 'bp_loaded', 'bp_core_load_admin_bar');31 add_action( 'bp_loaded', 'bp_core_load_admin_bar' ); 32 32 33 /** The hooks *****************************************************************/ 34 35 /** 36 * Include files on this action 37 */ 38 function bp_include() { 39 do_action( 'bp_include' ); 40 } 41 42 /** 43 * Setup global variables and objects 44 */ 45 function bp_setup_globals() { 46 do_action( 'bp_setup_globals' ); 47 } 48 49 /** 50 * Set navigation elements 51 */ 52 function bp_setup_nav() { 53 do_action( 'bp_setup_nav' ); 54 } 55 56 /** 57 * Set the page title 58 */ 59 function bp_setup_title() { 60 do_action( 'bp_setup_title' ); 61 } 62 63 /** 64 * Register widgets 65 */ 66 function bp_setup_widgets() { 67 do_action( 'bp_register_widgets' ); 68 } 69 70 /** 71 * Initlialize code 72 */ 73 function bp_init() { 74 do_action( 'bp_init' ); 75 } 76 77 /** 78 * Attached to plugins_loaded 79 */ 80 function bp_loaded() { 81 do_action( 'bp_loaded' ); 82 } 83 84 /** 85 * Attach potential template actions 86 */ 87 function bp_actions() { 88 do_action( 'bp_actions' ); 89 } 90 91 /** 92 * Attach potential template screens 93 */ 94 function bp_screens() { 95 do_action( 'bp_screens' ); 96 } 33 97 34 98 ?> -
trunk/bp-core/bp-core-loader.php
r3829 r3917 1 1 <?php 2 2 3 // Load the files containing functions that we globally will need.4 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-hooks.php');5 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-cssjs.php');6 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-classes.php');7 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-filters.php');8 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-avatars.php');9 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-widgets.php');10 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-template.php');11 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-buddybar.php');12 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-catchuri.php');13 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-component.php' );14 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-functions.php' );3 // Require all of the BuddyPress core libraries 4 require_once( BP_PLUGIN_DIR . '/bp-core/bp-core-component.php' ); 5 require_once( BP_PLUGIN_DIR . '/bp-core/bp-core-functions.php' ); 6 require_once( BP_PLUGIN_DIR . '/bp-core/bp-core-hooks.php' ); 7 require_once( BP_PLUGIN_DIR . '/bp-core/bp-core-cssjs.php' ); 8 require_once( BP_PLUGIN_DIR . '/bp-core/bp-core-classes.php' ); 9 require_once( BP_PLUGIN_DIR . '/bp-core/bp-core-filters.php' ); 10 require_once( BP_PLUGIN_DIR . '/bp-core/bp-core-avatars.php' ); 11 require_once( BP_PLUGIN_DIR . '/bp-core/bp-core-widgets.php' ); 12 require_once( BP_PLUGIN_DIR . '/bp-core/bp-core-template.php' ); 13 require_once( BP_PLUGIN_DIR . '/bp-core/bp-core-buddybar.php' ); 14 require_once( BP_PLUGIN_DIR . '/bp-core/bp-core-catchuri.php' ); 15 15 16 // Do we load deprecated functions?16 // Load deprecated functions 17 17 if ( !defined( 'BP_SKIP_DEPRECATED' ) ) 18 require ( BP_PLUGIN_DIR . '/bp-core/deprecated/1.3.php');18 require_once( BP_PLUGIN_DIR . '/bp-core/deprecated/1.3.php' ); 19 19 20 // If BP_DISABLE_ADMIN_BAR is defined, do not load the globaladmin bar.20 // Load the WP admin bar. 21 21 if ( !defined( 'BP_DISABLE_ADMIN_BAR' ) ) 22 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-adminbar.php');22 require_once( BP_PLUGIN_DIR . '/bp-core/bp-core-adminbar.php' ); 23 23 24 24 /** "And now for something completely different" ******************************/ 25 25 26 /** 27 * Sets up default global BuddyPress configuration settings and stores 28 * them in a $bp variable. 29 * 30 * @package BuddyPress Core Core 31 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() 32 * @uses bp_core_get_user_domain() Returns the domain for a user 33 */ 34 function bp_core_setup_globals() { 35 global $bp; 36 //global $current_action, $current_blog; 37 global $bp_pages; 38 //global $action_variables; 26 class BP_Core extends BP_Component { 39 27 40 // Get the base database prefix 41 $bp->table_prefix = bp_core_get_table_prefix(); 42 43 // The domain for the root of the site where the main blog resides 44 $bp->root_domain = bp_core_get_root_domain(); 45 46 // The names of the core WordPress pages used to display BuddyPress content 47 $bp->pages = $bp_pages; 48 49 /** Component and Action **************************************************/ 50 51 // Used for overriding the 2nd level navigation menu so it can be used to 52 // display custom navigation for an item (for example a group) 53 $bp->is_single_item = false; 54 55 // The default component to use if none are set and someone 56 // visits: http://domain.com/members/andy 57 if ( !defined( 'BP_DEFAULT_COMPONENT' ) ) { 58 if ( isset( $bp->pages->activity ) ) 59 $bp->default_component = $bp->activity->id; 60 else 61 $bp->default_component = $bp->profile->id; 62 } else { 63 $bp->default_component = BP_DEFAULT_COMPONENT; 28 function BP_Core() { 29 parent::start( 30 '_core', 31 __( 'BuddyPress Core', 'buddypress' ) 32 , BP_PLUGIN_DIR 33 ); 64 34 } 65 35 66 // Fetches all of the core BuddyPress settings in one fell swoop67 $bp->site_options = bp_core_get_site_options();36 function _setup_globals() { 37 global $bp, $bp_pages; 68 38 69 // Sets up the array container for the component navigation rendered 70 // by bp_get_nav() 71 $bp->bp_nav = array(); 39 // Setup the BuddyPress theme directory 40 register_theme_directory( WP_PLUGIN_DIR . '/buddypress/bp-themes' ); 72 41 73 // Sets up the array container for the component options navigation 74 // rendered by bp_get_options_nav() 75 $bp->bp_options_nav = array(); 42 // Get the base database prefix 43 $bp->table_prefix = bp_core_get_table_prefix(); 76 44 77 // Contains an array of all the active components. The key is the slug, 78 // value the internal ID of the component. 79 $bp->active_components = array(); 45 // The domain for the root of the site where the main blog resides 46 $bp->root_domain = bp_core_get_root_domain(); 80 47 81 /** Avatars ***************************************************************/ 48 // The names of the core WordPress pages used to display BuddyPress content 49 $bp->pages = $bp_pages; 82 50 83 // Fetches the default Gravatar image to use if the user/group/blog has no avatar or gravatar 84 $bp->grav_default->user = apply_filters( 'bp_user_gravatar_default', $bp->site_options['avatar_default'] ); 85 $bp->grav_default->group = apply_filters( 'bp_group_gravatar_default', $bp->grav_default->user ); 86 $bp->grav_default->blog = apply_filters( 'bp_blog_gravatar_default', $bp->grav_default->user ); 51 /** Component and Action **************************************************/ 87 52 88 // Notifications Table 89 $bp->core->table_name_notifications = $bp->table_prefix . 'bp_notifications'; 53 // Used for overriding the 2nd level navigation menu so it can be used to 54 // display custom navigation for an item (for example a group) 55 $bp->is_single_item = false; 90 56 91 do_action( 'bp_core_setup_globals' ); 92 } 93 add_action( 'bp_setup_globals', 'bp_core_setup_globals', 1 ); 57 // The default component to use if none are set and someone 58 // visits: http://domain.com/members/andy 59 if ( !defined( 'BP_DEFAULT_COMPONENT' ) ) { 60 if ( isset( $bp->pages->activity ) ) 61 $bp->default_component = $bp->activity->id; 62 else 63 $bp->default_component = $bp->profile->id; 64 } else { 65 $bp->default_component = BP_DEFAULT_COMPONENT; 66 } 94 67 95 /** 96 * Sets up the profile navigation item if the Xprofile component is not installed. 97 * 98 * @package BuddyPress Core 99 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() 100 * @uses bp_core_new_nav_item() Adds a navigation item to the top level buddypress navigation 101 * @uses bp_core_new_subnav_item() Adds a sub navigation item to a nav item 102 * @uses bp_is_my_profile() Returns true if the current user being viewed is equal the logged in user 103 * @uses bp_core_fetch_avatar() Returns the either the thumb or full avatar URL for the user_id passed 104 */ 105 function bp_core_setup_nav() { 106 global $bp; 68 // Fetches all of the core BuddyPress settings in one fell swoop 69 $bp->site_options = bp_core_get_site_options(); 107 70 108 /*** 109 * If the extended profiles component is disabled, we need to revert to using the 110 * built in WordPress profile information 111 */ 112 if ( !bp_is_active( 'profile' ) ) { 71 // Sets up the array container for the component navigation rendered 72 // by bp_get_nav() 73 $bp->bp_nav = array(); 113 74 114 // Fallback values if xprofile is disabled115 $bp->core->profile->slug = 'profile';116 $bp-> active_components[$bp->core->profile->slug] = $bp->core->profile->slug;75 // Sets up the array container for the component options navigation 76 // rendered by bp_get_options_nav() 77 $bp->bp_options_nav = array(); 117 78 118 // Add 'Profile' to the main navigation 119 bp_core_new_nav_item( array( 120 'name' => __( 'Profile', 'buddypress' ), 121 'slug' => $bp->core->profile->slug, 122 'position' => 20, 123 'screen_function' => 'bp_core_catch_profile_uri', 124 'default_subnav_slug' => 'public' 125 ) ); 79 // Contains an array of all the active components. The key is the slug, 80 // value the internal ID of the component. 81 $bp->active_components = array(); 126 82 127 $profile_link = trailingslashit( $bp->loggedin_user->domain . '/' . $bp->core->profile->slug );83 /** Basic current user data ***********************************************/ 128 84 129 // Add the subnav items to the profile 130 bp_core_new_subnav_item( array( 131 'name' => __( 'Public', 'buddypress' ), 132 'slug' => 'public', 133 'parent_url' => $profile_link, 134 'parent_slug' => $bp->core->profile->slug, 135 'screen_function' => 'bp_core_catch_profile_uri' 136 ) ); 85 // Logged in user is the 'current_user' 86 $current_user = wp_get_current_user(); 137 87 138 // Looking at a profile 139 if ( 'profile' == $bp->current_component ) { 140 if ( bp_is_my_profile() ) { 141 $bp->bp_options_title = __( 'My Profile', 'buddypress' ); 142 } else { 143 $bp->bp_options_avatar = bp_core_fetch_avatar( array( 144 'item_id' => $bp->displayed_user->id, 145 'type' => 'thumb' 146 ) ); 147 $bp->bp_options_title = $bp->displayed_user->fullname; 148 } 88 // The user ID of the user who is currently logged in. 89 $bp->loggedin_user->id = $current_user->ID; 90 91 /** Avatars ***************************************************************/ 92 93 // Fetches the default Gravatar image to use if the user/group/blog has no avatar or gravatar 94 $bp->grav_default->user = apply_filters( 'bp_user_gravatar_default', $bp->site_options['avatar_default'] ); 95 $bp->grav_default->group = apply_filters( 'bp_group_gravatar_default', $bp->grav_default->user ); 96 $bp->grav_default->blog = apply_filters( 'bp_blog_gravatar_default', $bp->grav_default->user ); 97 98 // Notifications Table 99 $bp->core->table_name_notifications = $bp->table_prefix . 'bp_notifications'; 100 101 do_action( 'bp_core_setup_globals' ); 102 } 103 104 function _setup_nav() { 105 global $bp; 106 107 /*** 108 * If the extended profiles component is disabled, we need to revert to using the 109 * built in WordPress profile information 110 */ 111 if ( !bp_is_active( 'xprofile' ) ) { 112 113 // Fallback values if xprofile is disabled 114 $bp->core->profile->slug = 'profile'; 115 $bp->active_components[$bp->core->profile->slug] = $bp->core->profile->slug; 116 117 // Add 'Profile' to the main navigation 118 $main_nav = array( 119 'name' => __( 'Profile', 'buddypress' ), 120 'slug' => $bp->core->profile->slug, 121 'position' => 20, 122 'screen_function' => 'bp_core_catch_profile_uri', 123 'default_subnav_slug' => 'public' 124 ); 125 126 $profile_link = trailingslashit( $bp->loggedin_user->domain . '/' . $bp->core->profile->slug ); 127 128 // Add the subnav items to the profile 129 $sub_nav[] = array( 130 'name' => __( 'Public', 'buddypress' ), 131 'slug' => 'public', 132 'parent_url' => $profile_link, 133 'parent_slug' => $bp->core->profile->slug, 134 'screen_function' => 'bp_core_catch_profile_uri' 135 ); 149 136 } 150 137 } 151 138 } 152 add_action( 'bp_setup_nav', 'bp_core_setup_nav' ); 153 139 $bp->core = new BP_Core(); 154 140 155 141 ?> -
trunk/bp-core/bp-core-template.php
r3914 r3917 280 280 */ 281 281 function bp_search_form_enabled() { 282 if ( bp_is_active( ' profile' )282 if ( bp_is_active( 'xprofile' ) 283 283 || bp_is_active( 'groups' ) 284 284 || ( bp_is_active( 'blogs' ) && is_multisite() ) … … 311 311 $options = array(); 312 312 313 if ( bp_is_active( ' profile' ) )313 if ( bp_is_active( 'xprofile' ) ) 314 314 $options['members'] = __( 'Members', 'buddypress' ); 315 315 … … 824 824 825 825 function bp_is_profile_component() { 826 if ( bp_is_current_component( ' profile' ) )826 if ( bp_is_current_component( 'xprofile' ) ) 827 827 return true; 828 828 … … 934 934 global $bp; 935 935 936 if ( bp_is_current_component( ' profile' ) )936 if ( bp_is_current_component( 'xprofile' ) ) 937 937 return true; 938 938 … … 943 943 global $bp; 944 944 945 if ( bp_is_current_component( ' profile' ) && bp_is_current_action( 'edit' ) )945 if ( bp_is_current_component( 'xprofile' ) && bp_is_current_action( 'edit' ) ) 946 946 return true; 947 947 … … 952 952 global $bp; 953 953 954 if ( bp_is_current_component( ' profile' ) && bp_is_current_action( 'change-avatar' ) )954 if ( bp_is_current_component( 'xprofile' ) && bp_is_current_action( 'change-avatar' ) ) 955 955 return true; 956 956 … … 1240 1240 if ( !bp_is_blog_page() ) : 1241 1241 if ( bp_is_user_profile() ) 1242 $bp_classes[] = ' profile';1242 $bp_classes[] = 'xprofile'; 1243 1243 1244 1244 if ( bp_is_activity_component() ) -
trunk/bp-core/deprecated/1.3.php
r3853 r3917 9 9 */ 10 10 11 /** Loader ********************************************************************/ 12 13 function bp_setup_root_components() { 14 do_action( 'bp_setup_root_components' ); 15 } 16 add_action( 'bp_init', 'bp_setup_root_components', 6 ); 17 11 18 /** WP Abstraction ************************************************************/ 12 19 … … 35 42 36 43 function bp_core_screen_signup() { 37 _deprecated_function( __FUNCTION__, '1.3', 'bp_ users_screen_signup' );38 bp_ users_screen_signup();44 _deprecated_function( __FUNCTION__, '1.3', 'bp_members_screen_signup' ); 45 bp_members_screen_signup(); 39 46 } 40 47 41 48 function bp_core_screen_activation() { 42 _deprecated_function( __FUNCTION__, '1.3', 'bp_ users_screen_activation' );43 bp_ users_screen_activation();49 _deprecated_function( __FUNCTION__, '1.3', 'bp_members_screen_activation' ); 50 bp_members_screen_activation(); 44 51 } 45 52 46 53 function bp_core_flush_illegal_names() { 47 _deprecated_function( __FUNCTION__, '1.3', 'bp_ users_flush_illegal_names' );48 bp_ users_flush_illegal_names();54 _deprecated_function( __FUNCTION__, '1.3', 'bp_members_flush_illegal_names' ); 55 bp_members_flush_illegal_names(); 49 56 } 50 57 51 58 function bp_core_illegal_names( $value = '', $oldvalue = '' ) { 52 _deprecated_function( __FUNCTION__, '1.3', 'bp_ users_illegal_names' );53 bp_ users_illegal_names( $value, $oldvalue );59 _deprecated_function( __FUNCTION__, '1.3', 'bp_members_illegal_names' ); 60 bp_members_illegal_names( $value, $oldvalue ); 54 61 } 55 62 56 63 function bp_core_validate_user_signup( $user_name, $user_email ) { 57 _deprecated_function( __FUNCTION__, '1.3', 'bp_ users_validate_user_signup' );58 bp_ users_validate_user_signup( $user_name, $user_email );64 _deprecated_function( __FUNCTION__, '1.3', 'bp_members_validate_user_signup' ); 65 bp_members_validate_user_signup( $user_name, $user_email ); 59 66 } 60 67 61 68 function bp_core_validate_blog_signup( $blog_url, $blog_title ) { 62 _deprecated_function( __FUNCTION__, '1.3', 'bp_ users_validate_blog_signup' );63 bp_ users_validate_blog_signup( $blog_url, $blog_title );69 _deprecated_function( __FUNCTION__, '1.3', 'bp_members_validate_blog_signup' ); 70 bp_members_validate_blog_signup( $blog_url, $blog_title ); 64 71 } 65 72 66 73 function bp_core_signup_user( $user_login, $user_password, $user_email, $usermeta ) { 67 _deprecated_function( __FUNCTION__, '1.3', 'bp_ users_signup_user' );68 bp_ users_signup_user( $user_login, $user_password, $user_email, $usermeta );74 _deprecated_function( __FUNCTION__, '1.3', 'bp_members_signup_user' ); 75 bp_members_signup_user( $user_login, $user_password, $user_email, $usermeta ); 69 76 } 70 77 71 78 function bp_core_signup_blog( $blog_domain, $blog_path, $blog_title, $user_name, $user_email, $usermeta ) { 72 _deprecated_function( __FUNCTION__, '1.3', 'bp_ users_signup_blog' );73 bp_ users_signup_blog( $blog_domain, $blog_path, $blog_title, $user_name, $user_email, $usermeta );79 _deprecated_function( __FUNCTION__, '1.3', 'bp_members_signup_blog' ); 80 bp_members_signup_blog( $blog_domain, $blog_path, $blog_title, $user_name, $user_email, $usermeta ); 74 81 } 75 82 76 83 function bp_core_activate_signup( $key ) { 77 _deprecated_function( __FUNCTION__, '1.3', 'bp_ users_activate_signup' );78 bp_ users_activate_signup( $key );84 _deprecated_function( __FUNCTION__, '1.3', 'bp_members_activate_signup' ); 85 bp_members_activate_signup( $key ); 79 86 } 80 87 81 88 function bp_core_new_user_activity( $user ) { 82 _deprecated_function( __FUNCTION__, '1.3', 'bp_ users_new_user_activity' );83 bp_ users_new_user_activity( $user );89 _deprecated_function( __FUNCTION__, '1.3', 'bp_members_new_user_activity' ); 90 bp_members_new_user_activity( $user ); 84 91 } 85 92 86 93 function bp_core_map_user_registration( $user_id ) { 87 _deprecated_function( __FUNCTION__, '1.3', 'bp_ users_map_user_registration' );88 bp_ users_map_user_registration( $user_id );94 _deprecated_function( __FUNCTION__, '1.3', 'bp_members_map_user_registration' ); 95 bp_members_map_user_registration( $user_id ); 89 96 } 90 97 91 98 function bp_core_signup_avatar_upload_dir() { 92 _deprecated_function( __FUNCTION__, '1.3', 'bp_ users_signup_avatar_upload_dir' );93 bp_ users_signup_avatar_upload_dir();99 _deprecated_function( __FUNCTION__, '1.3', 'bp_members_signup_avatar_upload_dir' ); 100 bp_members_signup_avatar_upload_dir(); 94 101 } 95 102 96 103 function bp_core_signup_send_validation_email( $user_id, $user_email, $key ) { 97 _deprecated_function( __FUNCTION__, '1.3', 'bp_ users_signup_send_validation_email' );98 bp_ users_signup_send_validation_email( $user_id, $user_email, $key );104 _deprecated_function( __FUNCTION__, '1.3', 'bp_members_signup_send_validation_email' ); 105 bp_members_signup_send_validation_email( $user_id, $user_email, $key ); 99 106 } 100 107 101 108 function bp_core_signup_disable_inactive( $auth_obj, $username ) { 102 _deprecated_function( __FUNCTION__, '1.3', 'bp_ users_signup_disable_inactive' );103 bp_ users_signup_disable_inactive( $auth_obj, $username );109 _deprecated_function( __FUNCTION__, '1.3', 'bp_members_signup_disable_inactive' ); 110 bp_members_signup_disable_inactive( $auth_obj, $username ); 104 111 } 105 112 106 113 function bp_core_wpsignup_redirect() { 107 _deprecated_function( __FUNCTION__, '1.3', 'bp_ users_wpsignup_redirect' );108 bp_ users_wpsignup_redirect();114 _deprecated_function( __FUNCTION__, '1.3', 'bp_members_wpsignup_redirect' ); 115 bp_members_wpsignup_redirect(); 109 116 } 110 117 … … 117 124 118 125 function bp_core_can_edit_settings() { 119 _deprecated_function( __FUNCTION__, '1.3', 'bp_ users_can_edit_settings' );120 bp_ users_can_edit_settings();126 _deprecated_function( __FUNCTION__, '1.3', 'bp_members_can_edit_settings' ); 127 bp_members_can_edit_settings(); 121 128 } 122 129 … … 163 170 164 171 function bp_core_add_notification( $item_id, $user_id, $component_name, $component_action, $secondary_item_id = false, $date_notified = false ) { 165 _deprecated_function( __FUNCTION__, '1.3', 'bp_ users_add_notification' );166 bp_ users_add_notification( $item_id, $user_id, $component_name, $component_action, $secondary_item_id, $date_notified );172 _deprecated_function( __FUNCTION__, '1.3', 'bp_members_add_notification' ); 173 bp_members_add_notification( $item_id, $user_id, $component_name, $component_action, $secondary_item_id, $date_notified ); 167 174 } 168 175 169 176 function bp_core_delete_notification( $id ) { 170 _deprecated_function( __FUNCTION__, '1.3', 'bp_ users_delete_notification' );171 bp_ users_delete_notification( $id );177 _deprecated_function( __FUNCTION__, '1.3', 'bp_members_delete_notification' ); 178 bp_members_delete_notification( $id ); 172 179 } 173 180 174 181 function bp_core_get_notification( $id ) { 175 _deprecated_function( __FUNCTION__, '1.3', 'bp_ users_get_notification' );176 bp_ users_get_notification( $id );182 _deprecated_function( __FUNCTION__, '1.3', 'bp_members_get_notification' ); 183 bp_members_get_notification( $id ); 177 184 } 178 185 179 186 function bp_core_get_notifications_for_user( $user_id ) { 180 _deprecated_function( __FUNCTION__, '1.3', 'bp_ users_get_notifications_for_user' );181 bp_ users_get_notifications_for_user( $user_id );187 _deprecated_function( __FUNCTION__, '1.3', 'bp_members_get_notifications_for_user' ); 188 bp_members_get_notifications_for_user( $user_id ); 182 189 } 183 190 184 191 function bp_core_delete_notifications_by_type( $user_id, $component_name, $component_action ) { 185 _deprecated_function( __FUNCTION__, '1.3', 'bp_ users_delete_notifications_by_type' );186 bp_ users_delete_notifications_by_type( $user_id, $component_name, $component_action );192 _deprecated_function( __FUNCTION__, '1.3', 'bp_members_delete_notifications_by_type' ); 193 bp_members_delete_notifications_by_type( $user_id, $component_name, $component_action ); 187 194 } 188 195 189 196 function bp_core_delete_notifications_for_user_by_item_id( $user_id, $item_id, $component_name, $component_action, $secondary_item_id = false ) { 190 _deprecated_function( __FUNCTION__, '1.3', 'bp_ users_delete_notifications_by_item_id' );191 bp_ users_delete_notifications_by_item_id( $user_id, $item_id, $component_name, $component_action, $secondary_item_id );197 _deprecated_function( __FUNCTION__, '1.3', 'bp_members_delete_notifications_by_item_id' ); 198 bp_members_delete_notifications_by_item_id( $user_id, $item_id, $component_name, $component_action, $secondary_item_id ); 192 199 } 193 200 194 201 function bp_core_delete_all_notifications_by_type( $item_id, $component_name, $component_action = false, $secondary_item_id = false ) { 195 _deprecated_function( __FUNCTION__, '1.3', 'bp_ users_delete_all_notifications_by_type' );196 bp_ users_delete_all_notifications_by_type( $item_id, $component_name, $component_action, $secondary_item_id );202 _deprecated_function( __FUNCTION__, '1.3', 'bp_members_delete_all_notifications_by_type' ); 203 bp_members_delete_all_notifications_by_type( $item_id, $component_name, $component_action, $secondary_item_id ); 197 204 } 198 205 199 206 function bp_core_delete_notifications_from_user( $user_id, $component_name, $component_action ) { 200 _deprecated_function( __FUNCTION__, '1.3', 'bp_ users_delete_notifications_from_user' );201 bp_ users_delete_notifications_from_user( $user_id, $component_name, $component_action );207 _deprecated_function( __FUNCTION__, '1.3', 'bp_members_delete_notifications_from_user' ); 208 bp_members_delete_notifications_from_user( $user_id, $component_name, $component_action ); 202 209 } 203 210 204 211 function bp_core_check_notification_access( $user_id, $notification_id ) { 205 _deprecated_function( __FUNCTION__, '1.3', 'bp_ users_check_notification_access' );206 bp_ users_check_notification_access( $user_id, $notification_id );212 _deprecated_function( __FUNCTION__, '1.3', 'bp_members_check_notification_access' ); 213 bp_members_check_notification_access( $user_id, $notification_id ); 207 214 } 208 215 -
trunk/bp-forums/bp-forums-functions.php
r3916 r3917 24 24 return !empty( $bp->site_options['bp-disable-forum-directory'] ); 25 25 } 26 27 function bp_forums_directory_forums_setup() {28 global $bp;29 30 if ( bp_is_current_component( 'forums' ) ) {31 if ( bp_forum_directory_is_disabled() || !bp_is_active( 'groups' ) )32 return false;33 34 if ( !bp_forums_is_installed_correctly() ) {35 bp_core_add_message( __( 'The forums component has not been set up yet.', 'buddypress' ), 'error' );36 bp_core_redirect( $bp->root_domain );37 }38 39 $bp->is_directory = true;40 41 do_action( 'bbpress_init' );42 43 // Check to see if the user has posted a new topic from the forums page.44 if ( isset( $_POST['submit_topic'] ) && function_exists( 'bp_forums_new_topic' ) ) {45 check_admin_referer( 'bp_forums_new_topic' );46 47 if ( $bp->groups->current_group = groups_get_group( array( 'group_id' => $_POST['topic_group_id'] ) ) ) {48 // Auto join this user if they are not yet a member of this group49 if ( !is_super_admin() && 'public' == $bp->groups->current_group->status && !groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) )50 groups_join_group( $bp->groups->current_group->id, $bp->groups->current_group->id );51 52 $error_message = '';53 if ( $forum_id = groups_get_groupmeta( $bp->groups->current_group->id, 'forum_id' ) ) {54 if ( empty( $_POST['topic_title'] ) )55 $error_message = __( 'Please provide a title for your forum topic.', 'buddypress' );56 else if ( empty( $_POST['topic_text'] ) )57 $error_message = __( 'Forum posts cannot be empty. Please enter some text.', 'buddypress' );58 59 if ( $error_message ) {60 bp_core_add_message( $error_message, 'error' );61 $redirect = bp_get_group_permalink( $bp->groups->current_group ) . 'forum';62 } else {63 if ( !$topic = groups_new_group_forum_topic( $_POST['topic_title'], $_POST['topic_text'], $_POST['topic_tags'], $forum_id ) ) {64 bp_core_add_message( __( 'There was an error when creating the topic', 'buddypress'), 'error' );65 $redirect = bp_get_group_permalink( $bp->groups->current_group ) . 'forum';66 } else {67 bp_core_add_message( __( 'The topic was created successfully', 'buddypress') );68 $redirect = bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic->topic_slug . '/';69 }70 }71 72 bp_core_redirect( $redirect );73 74 } else {75 bp_core_add_message( __( 'Please pick the group forum where you would like to post this topic.', 'buddypress' ), 'error' );76 }77 }78 }79 80 do_action( 'bp_forums_directory_forums_setup' );81 82 bp_core_load_template( apply_filters( 'bp_forums_template_directory_forums_setup', 'forums/index' ) );83 }84 }85 add_action( 'wp', 'bp_forums_directory_forums_setup', 2 );86 26 87 27 /** Forum Functions ***********************************************************/ … … 380 320 381 321 // Fetch fullname for the topic's last poster 382 if ( bp_is_active( ' profile' ) ) {322 if ( bp_is_active( 'xprofile' ) ) { 383 323 $poster_names = $wpdb->get_results( $wpdb->prepare( "SELECT t.topic_id, pd.value FROM {$bp->profile->table_name_data} pd, {$bbdb->topics} t WHERE pd.user_id = t.topic_last_poster AND pd.field_id = 1 AND t.topic_id IN ( {$topic_ids} )" ) ); 384 324 for ( $i = 0; $i < count( $topics ); $i++ ) { … … 498 438 499 439 // Fetch fullname for each poster. 500 if ( bp_is_active( ' profile' ) ) {440 if ( bp_is_active( 'xprofile' ) ) { 501 441 $poster_names = $wpdb->get_results( $wpdb->prepare( "SELECT pd.user_id, pd.value FROM {$bp->profile->table_name_data} pd WHERE pd.user_id IN ( {$user_ids} )" ) ); 502 442 for ( $i = 0; $i < count( $posts ); $i++ ) { -
trunk/bp-forums/bp-forums-loader.php
r3877 r3917 18 18 */ 19 19 function BP_Forums_Component() { 20 parent::start( 'forums', __( 'Discussion Forums', 'buddypress' ) ); 20 parent::start( 21 'forums', 22 __( 'Discussion Forums', 'buddypress' ), 23 BP_PLUGIN_DIR 24 ); 21 25 } 22 26 … … 41 45 define( 'BP_FORUMS_SLUG', $this->id ); 42 46 43 // Do some slug checks44 $this->slug = BP_FORUMS_SLUG;45 $this->root_slug = isset( $bp->pages->forums->slug ) ? $bp->pages->forums->slug : $this->slug;46 47 47 // The location of the bbPress stand-alone config file 48 48 if ( isset( $bp->site_options['bb-config-location'] ) ) 49 49 $this->bbconfig = $bp->site_options['bb-config-location']; 50 50 51 // The default text for the blogs directory search box 52 $this->default_search_string = __( 'Search Forums...', 'buddypress' ); 51 // All globals for messaging component. 52 // Note that global_tables is included in this array. 53 $globals = array( 54 'slug' => BP_FORUMS_SLUG, 55 'root_slug' => isset( $bp->pages->forums->slug ) ? $bp->pages->forums->slug : BP_FORUMS_SLUG, 56 'notification_callback' => 'messages_format_notifications', 57 'search_string' => __( 'Search Forums...', 'buddypress' ), 58 ); 53 59 54 // Register this in the active components array 55 $bp->active_components[$this->id] = $this->id; 60 parent::_setup_globals( $globals ); 56 61 } 57 62 … … 61 66 function _includes() { 62 67 63 // Support for bbPress stand-alone 68 // Files to include 69 $includes = array( 70 'actions', 71 'screens', 72 'classes', 73 'filters', 74 'template', 75 'functions', 76 ); 77 78 // Admin area 79 if ( is_admin() ) 80 $includes[] = 'admin'; 81 82 // bbPress stand-alone 64 83 if ( !defined( 'BB_PATH' ) ) 65 require ( BP_PLUGIN_DIR . '/bp-forums/bp-forums-bbpress-sa.php' );84 $includes[] = 'bbpress-sa'; 66 85 67 // Admin 68 if ( is_admin() ) 69 require ( BP_PLUGIN_DIR . '/bp-forums/bp-forums-admin.php' ); 70 71 require ( BP_PLUGIN_DIR . '/bp-forums/bp-forums-actions.php' ); 72 require ( BP_PLUGIN_DIR . '/bp-forums/bp-forums-screens.php' ); 73 require ( BP_PLUGIN_DIR . '/bp-forums/bp-forums-filters.php' ); 74 require ( BP_PLUGIN_DIR . '/bp-forums/bp-forums-template.php' ); 75 require ( BP_PLUGIN_DIR . '/bp-forums/bp-forums-functions.php' ); 86 parent::_includes( $includes ); 76 87 } 77 88 … … 85 96 86 97 // Add 'Forums' to the main navigation 87 bp_core_new_nav_item(array(98 $main_nav = array( 88 99 'name' => __( 'Forums', 'buddypress' ), 89 100 'slug' => $this->slug, … … 91 102 'screen_function' => 'bp_forums_screen_topics', 92 103 'default_subnav_slug' => 'topics', 93 'item_css_id' => $this->id )104 'item_css_id' => $this->id 94 105 ); 95 106 … … 113 124 114 125 // Additional menu if friends is active 115 bp_core_new_subnav_item(array(126 $sub_nav[] = array( 116 127 'name' => __( 'Topics Started', 'buddypress' ), 117 128 'slug' => 'topics', … … 121 132 'position' => 20, 122 133 'item_css_id' => 'forums-friends' 123 ) );134 ); 124 135 125 136 // Additional menu if friends is active 126 bp_core_new_subnav_item(array(137 $sub_nav[] = array( 127 138 'name' => __( 'Replies', 'buddypress' ), 128 139 'slug' => 'replies', … … 132 143 'position' => 40, 133 144 'item_css_id' => 'forums-friends' 134 ) );145 ); 135 146 136 147 // Favorite forums items 137 bp_core_new_subnav_item(array(148 $sub_nav[] = array( 138 149 'name' => __( 'Favorite Topics', 'buddypress' ), 139 150 'slug' => 'favorites', … … 143 154 'position' => 60, 144 155 'item_css_id' => 'forums-favs' 145 ) ); 156 ); 157 158 parent::_setup_nav( $main_nav, $sub_nav ); 159 } 160 161 /** 162 * Sets up the title for pages and <title> 163 * 164 * @global obj $bp 165 */ 166 function _setup_title() { 167 global $bp; 146 168 147 169 // Adjust title based on view … … 157 179 } 158 180 } 181 182 parent::_setup_title(); 159 183 } 160 184 } -
trunk/bp-forums/bp-forums-screens.php
r3806 r3917 1 1 <?php 2 2 3 function bp_forums_directory_forums_setup() { 4 global $bp; 5 6 if ( bp_is_current_component( 'forums' ) ) { 7 if ( bp_forum_directory_is_disabled() || !bp_is_active( 'groups' ) ) 8 return false; 9 10 if ( !bp_forums_is_installed_correctly() ) { 11 bp_core_add_message( __( 'The forums component has not been set up yet.', 'buddypress' ), 'error' ); 12 bp_core_redirect( $bp->root_domain ); 13 } 14 15 $bp->is_directory = true; 16 17 do_action( 'bbpress_init' ); 18 19 // Check to see if the user has posted a new topic from the forums page. 20 if ( isset( $_POST['submit_topic'] ) && function_exists( 'bp_forums_new_topic' ) ) { 21 check_admin_referer( 'bp_forums_new_topic' ); 22 23 if ( $bp->groups->current_group = groups_get_group( array( 'group_id' => $_POST['topic_group_id'] ) ) ) { 24 // Auto join this user if they are not yet a member of this group 25 if ( !is_super_admin() && 'public' == $bp->groups->current_group->status && !groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) 26 groups_join_group( $bp->groups->current_group->id, $bp->groups->current_group->id ); 27 28 $error_message = ''; 29 if ( $forum_id = groups_get_groupmeta( $bp->groups->current_group->id, 'forum_id' ) ) { 30 if ( empty( $_POST['topic_title'] ) ) 31 $error_message = __( 'Please provide a title for your forum topic.', 'buddypress' ); 32 else if ( empty( $_POST['topic_text'] ) ) 33 $error_message = __( 'Forum posts cannot be empty. Please enter some text.', 'buddypress' ); 34 35 if ( $error_message ) { 36 bp_core_add_message( $error_message, 'error' ); 37 $redirect = bp_get_group_permalink( $bp->groups->current_group ) . 'forum'; 38 } else { 39 if ( !$topic = groups_new_group_forum_topic( $_POST['topic_title'], $_POST['topic_text'], $_POST['topic_tags'], $forum_id ) ) { 40 bp_core_add_message( __( 'There was an error when creating the topic', 'buddypress'), 'error' ); 41 $redirect = bp_get_group_permalink( $bp->groups->current_group ) . 'forum'; 42 } else { 43 bp_core_add_message( __( 'The topic was created successfully', 'buddypress') ); 44 $redirect = bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic->topic_slug . '/'; 45 } 46 } 47 48 bp_core_redirect( $redirect ); 49 50 } else { 51 bp_core_add_message( __( 'Please pick the group forum where you would like to post this topic.', 'buddypress' ), 'error' ); 52 } 53 } 54 } 55 56 do_action( 'bp_forums_directory_forums_setup' ); 57 58 bp_core_load_template( apply_filters( 'bp_forums_template_directory_forums_setup', 'forums/index' ) ); 59 } 60 } 61 add_action( 'bp_screens', 'bp_forums_directory_forums_setup' ); 62 3 63 ?> -
trunk/bp-friends/bp-friends-classes.php
r3903 r3917 159 159 160 160 // filter the user_ids based on the search criteria. 161 if ( bp_is_active( ' profile' ) ) {161 if ( bp_is_active( 'xprofile' ) ) { 162 162 $sql = "SELECT DISTINCT user_id FROM {$bp->profile->table_name_data} WHERE user_id IN ($fids) AND value LIKE '$filter%%' {$pag_sql}"; 163 163 $total_sql = "SELECT COUNT(DISTINCT user_id) FROM {$bp->profile->table_name_data} WHERE user_id IN ($fids) AND value LIKE '$filter%%'"; … … 225 225 226 226 // filter the user_ids based on the search criteria. 227 if ( bp_is_active( ' profile' ) ) {227 if ( bp_is_active( 'xprofile' ) ) { 228 228 $sql = $wpdb->prepare( "SELECT DISTINCT d.user_id as id FROM {$bp->profile->table_name_data} d, $users_table u WHERE d.user_id = u.id AND d.value LIKE '$filter%%' ORDER BY d.value DESC $pag_sql" ); 229 229 } else { … … 248 248 249 249 // filter the user_ids based on the search criteria. 250 if ( bp_is_active( ' profile' ) ) {250 if ( bp_is_active( 'xprofile' ) ) { 251 251 $sql = $wpdb->prepare( "SELECT COUNT(DISTINCT d.user_id) FROM {$bp->profile->table_name_data} d, $users_table u WHERE d.user_id = u.id AND d.value LIKE '$filter%%'" ); 252 252 } else { … … 265 265 global $wpdb, $bp; 266 266 267 if ( !bp_is_active( ' profile' ) )267 if ( !bp_is_active( 'xprofile' ) ) 268 268 return false; 269 269 -
trunk/bp-friends/bp-friends-loader.php
r3903 r3917 1 1 <?php 2 2 3 // Required Files 4 require ( BP_PLUGIN_DIR . '/bp-friends/bp-friends-classes.php' ); 5 require ( BP_PLUGIN_DIR . '/bp-friends/bp-friends-template.php' ); 3 /** 4 * BuddyPress Friends Streams Loader 5 * 6 * The friends component is for users to create relationships with each other 7 * 8 * @package BuddyPress 9 * @subpackage Friends Core 10 */ 6 11 7 define ( 'BP_FRIENDS_DB_VERSION', '1800' ); 12 class BP_Friends_Component extends BP_Component { 8 13 9 // Define the slug for the component 10 if ( !defined( 'BP_FRIENDS_SLUG' ) ) 11 define ( 'BP_FRIENDS_SLUG', 'friends' ); 12 13 function friends_setup_globals() { 14 global $bp; 15 16 // For internal identification 17 $bp->friends->id = 'friends'; 18 19 // Slug 20 $bp->friends->slug = BP_FRIENDS_SLUG; 21 22 // Table 23 $bp->friends->table_name = $bp->table_prefix . 'bp_friends'; 24 25 // Notifications 26 $bp->friends->notification_callback = 'friends_format_notifications'; 27 28 // Register this in the active components array 29 $bp->active_components[$bp->friends->slug] = $bp->friends->id; 30 31 do_action( 'friends_setup_globals' ); 32 } 33 add_action( 'bp_setup_globals', 'friends_setup_globals' ); 34 35 function friends_setup_nav() { 36 global $bp; 37 38 // Add 'Friends' to the main navigation 39 bp_core_new_nav_item( array( 'name' => sprintf( __( 'Friends <span>(%d)</span>', 'buddypress' ), friends_get_total_friend_count() ), 'slug' => $bp->friends->slug, 'position' => 60, 'screen_function' => 'friends_screen_my_friends', 'default_subnav_slug' => 'my-friends', 'item_css_id' => $bp->friends->id ) ); 40 41 $friends_link = $bp->loggedin_user->domain . $bp->friends->slug . '/'; 42 43 // Add the subnav items to the friends nav item 44 bp_core_new_subnav_item( array( 'name' => __( 'My Friends', 'buddypress' ), 'slug' => 'my-friends', 'parent_url' => $friends_link, 'parent_slug' => $bp->friends->slug, 'screen_function' => 'friends_screen_my_friends', 'position' => 10, 'item_css_id' => 'friends-my-friends' ) ); 45 bp_core_new_subnav_item( array( 'name' => __( 'Requests', 'buddypress' ), 'slug' => 'requests', 'parent_url' => $friends_link, 'parent_slug' => $bp->friends->slug, 'screen_function' => 'friends_screen_requests', 'position' => 20, 'user_has_access' => bp_is_my_profile() ) ); 46 47 if ( $bp->current_component == $bp->friends->slug ) { 48 if ( bp_is_my_profile() ) { 49 $bp->bp_options_title = __( 'My Friends', 'buddypress' ); 50 } else { 51 $bp->bp_options_avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb' ) ); 52 $bp->bp_options_title = $bp->displayed_user->fullname; 53 } 14 /** 15 * Start the friends component creation process 16 * 17 * @since BuddyPress {unknown} 18 */ 19 function BP_Friends_Component() { 20 parent::start( 21 'friends', 22 __( 'Friend Connections', 'buddypress' ), 23 BP_PLUGIN_DIR 24 ); 54 25 } 55 26 56 do_action( 'friends_setup_nav' ); 57 } 58 add_action( 'bp_setup_nav', 'friends_setup_nav' ); 27 /** 28 * Include files 29 */ 30 function _includes() { 31 // Files to include 32 $includes = array( 33 'actions', 34 'screens', 35 'filters', 36 'classes', 37 'activity', 38 'template', 39 'functions', 40 'notifications', 41 ); 59 42 60 /******************************************************************************** 61 * Screen Functions 62 * 63 * Screen functions are the controllers of BuddyPress. They will execute when their 64 * specific URL is caught. They will first save or manipulate data using business 65 * functions, then pass on the user to a template file. 66 */ 67 68 function friends_screen_my_friends() { 69 global $bp; 70 71 // Delete any friendship acceptance notifications for the user when viewing a profile 72 bp_users_delete_notifications_by_type( $bp->loggedin_user->id, $bp->friends->id, 'friendship_accepted' ); 73 74 do_action( 'friends_screen_my_friends' ); 75 76 bp_core_load_template( apply_filters( 'friends_template_my_friends', 'members/single/home' ) ); 77 } 78 79 function friends_screen_requests() { 80 global $bp; 81 82 if ( isset( $bp->action_variables[0] ) && isset( $bp->action_variables[1] ) && 'accept' == $bp->action_variables[0] && is_numeric( $bp->action_variables[1] ) ) { 83 // Check the nonce 84 check_admin_referer( 'friends_accept_friendship' ); 85 86 if ( friends_accept_friendship( $bp->action_variables[1] ) ) 87 bp_core_add_message( __( 'Friendship accepted', 'buddypress' ) ); 88 else 89 bp_core_add_message( __( 'Friendship could not be accepted', 'buddypress' ), 'error' ); 90 91 bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/' . $bp->current_action ); 92 93 } elseif ( isset( $bp->action_variables[0] ) && isset( $bp->action_variables[1] ) && 'reject' == $bp->action_variables[0] && is_numeric( $bp->action_variables[1] ) ) { 94 // Check the nonce 95 check_admin_referer( 'friends_reject_friendship' ); 96 97 if ( friends_reject_friendship( $bp->action_variables[1] ) ) 98 bp_core_add_message( __( 'Friendship rejected', 'buddypress' ) ); 99 else 100 bp_core_add_message( __( 'Friendship could not be rejected', 'buddypress' ), 'error' ); 101 102 bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/' . $bp->current_action ); 43 parent::_includes( $includes ); 103 44 } 104 45 105 do_action( 'friends_screen_requests' ); 46 /** 47 * Setup globals 48 * 49 * The BP_FRIENDS_SLUG constant is deprecated, and only used here for 50 * backwards compatibility. 51 * 52 * @since BuddyPress {unknown} 53 * @global obj $bp 54 */ 55 function _setup_globals() { 56 global $bp; 106 57 107 if ( isset( $_GET['new'] ) ) 108 bp_users_delete_notifications_by_type( $bp->loggedin_user->id, $bp->friends->id, 'friendship_request' ); 58 define ( 'BP_FRIENDS_DB_VERSION', '1800' ); 109 59 110 bp_core_load_template( apply_filters( 'friends_template_requests', 'members/single/home' ) ); 111 } 60 // Define a slug, if necessary 61 if ( !defined( 'BP_FRIENDS_SLUG' ) ) 62 define( 'BP_FRIENDS_SLUG', $this->id ); 112 63 113 function friends_screen_notification_settings() { 114 global $bp; 64 // Global tables for messaging component 65 $global_tables = array( 66 'table_name' => $bp->table_prefix . 'bp_friends', 67 'table_name_meta' => $bp->table_prefix . 'bp_friends_meta', 68 ); 115 69 70 // All globals for messaging component. 71 // Note that global_tables is included in this array. 72 $globals = array( 73 'path' => BP_PLUGIN_DIR, 74 'slug' => BP_FRIENDS_SLUG, 75 'root_slug' => isset( $bp->pages->friends->slug ) ? $bp->pages->friends->slug : BP_FRIENDS_SLUG, 76 'search_string' => __( 'Search Friends...', 'buddypress' ), 77 'notification_callback' => 'friends_format_notifications', 78 'global_tables' => $global_tables, 79 ); 116 80 117 if ( !$send_requests = get_user_meta( $bp->displayed_user->id, 'notification_friends_friendship_request', true ) )118 $send_requests = 'yes';81 parent::_setup_globals( $globals ); 82 } 119 83 120 if ( !$accept_requests = get_user_meta( $bp->displayed_user->id, 'notification_friends_friendship_accepted', true ) ) 121 $accept_requests = 'yes'; 122 ?> 84 /** 85 * Setup BuddyBar navigation 86 * 87 * @global obj $bp 88 */ 89 function _setup_nav() { 90 global $bp; 123 91 124 <table class="notification-settings zebra" id="friends-notification-settings">125 <thead>126 <tr>127 <th class="icon"></th>128 <th class="title"><?php _e( 'Friends', 'buddypress' ) ?></th>129 <th class="yes"><?php _e( 'Yes', 'buddypress' ) ?></th>130 <th class="no"><?php _e( 'No', 'buddypress' )?></th>131 </tr>132 </thead>92 // Add 'Friends' to the main navigation 93 $main_nav = array( 94 'name' => sprintf( __( 'Friends <span>(%d)</span>', 'buddypress' ), friends_get_total_friend_count() ), 95 'slug' => $this->slug, 96 'position' => 60, 97 'screen_function' => 'friends_screen_my_friends', 98 'default_subnav_slug' => 'my-friends', 99 'item_css_id' => $bp->friends->id 100 ); 133 101 134 <tbody> 135 <tr id="friends-notification-settings-request"> 136 <td></td> 137 <td><?php _e( 'A member sends you a friendship request', 'buddypress' ) ?></td> 138 <td class="yes"><input type="radio" name="notifications[notification_friends_friendship_request]" value="yes" <?php checked( $send_requests, 'yes', true ) ?>/></td> 139 <td class="no"><input type="radio" name="notifications[notification_friends_friendship_request]" value="no" <?php checked( $send_requests, 'no', true ) ?>/></td> 140 </tr> 141 <tr id="friends-notification-settings-accepted"> 142 <td></td> 143 <td><?php _e( 'A member accepts your friendship request', 'buddypress' ) ?></td> 144 <td class="yes"><input type="radio" name="notifications[notification_friends_friendship_accepted]" value="yes" <?php checked( $accept_requests, 'yes', true ) ?>/></td> 145 <td class="no"><input type="radio" name="notifications[notification_friends_friendship_accepted]" value="no" <?php checked( $accept_requests, 'no', true ) ?>/></td> 146 </tr> 102 $friends_link = trailingslashit( $bp->loggedin_user->domain . $bp->friends->slug ); 147 103 148 <?php do_action( 'friends_screen_notification_settings' ); ?> 104 // Add the subnav items to the friends nav item 105 $sub_nav[] = array( 106 'name' => __( 'My Friends', 'buddypress' ), 107 'slug' => 'my-friends', 108 'parent_url' => $friends_link, 109 'parent_slug' => $bp->friends->slug, 110 'screen_function' => 'friends_screen_my_friends', 111 'position' => 10, 112 'item_css_id' => 'friends-my-friends' 113 ); 149 114 150 </tbody> 151 </table> 115 $sub_nav[] = array( 116 'name' => __( 'Requests', 'buddypress' ), 117 'slug' => 'requests', 118 'parent_url' => $friends_link, 119 'parent_slug' => $bp->friends->slug, 120 'screen_function' => 'friends_screen_requests', 121 'position' => 20, 122 'user_has_access' => bp_is_my_profile() 123 ); 152 124 153 <?php 154 } 155 add_action( 'bp_notification_settings', 'friends_screen_notification_settings' ); 125 parent::_setup_nav( $main_nav, $sub_nav ); 126 } 156 127 128 /** 129 * Sets up the title for pages and <title> 130 * 131 * @global obj $bp 132 */ 133 function _setup_title() { 134 global $bp; 157 135 158 /******************************************************************************** 159 * Action Functions 160 * 161 * Action functions are exactly the same as screen functions, however they do not 162 * have a template screen associated with them. Usually they will send the user 163 * back to the default screen after execution. 164 */ 165 166 function friends_action_add_friend() { 167 global $bp; 168 169 if ( $bp->current_component != $bp->friends->slug || $bp->current_action != 'add-friend' ) 170 return false; 171 172 $potential_friend_id = $bp->action_variables[0]; 173 174 if ( !is_numeric( $potential_friend_id ) || !isset( $potential_friend_id ) ) 175 return false; 176 177 if ( $potential_friend_id == $bp->loggedin_user->id ) 178 return false; 179 180 $friendship_status = BP_Friends_Friendship::check_is_friend( $bp->loggedin_user->id, $potential_friend_id ); 181 182 if ( 'not_friends' == $friendship_status ) { 183 184 if ( !check_admin_referer( 'friends_add_friend' ) ) 185 return false; 186 187 if ( !friends_add_friend( $bp->loggedin_user->id, $potential_friend_id ) ) { 188 bp_core_add_message( __( 'Friendship could not be requested.', 'buddypress' ), 'error' ); 189 } else { 190 bp_core_add_message( __( 'Friendship requested', 'buddypress' ) ); 136 // Adjust title 137 if ( bp_is_friends_component() ) { 138 if ( bp_is_my_profile() ) { 139 $bp->bp_options_title = __( 'My Friends', 'buddypress' ); 140 } else { 141 $bp->bp_options_avatar = bp_core_fetch_avatar( array( 142 'item_id' => $bp->displayed_user->id, 143 'type' => 'thumb' 144 ) ); 145 $bp->bp_options_title = $bp->displayed_user->fullname; 146 } 191 147 } 192 148 193 } else if ( 'is_friend' == $friendship_status ) { 194 bp_core_add_message( __( 'You are already friends with this user', 'buddypress' ), 'error' ); 195 } else { 196 bp_core_add_message( __( 'You already have a pending friendship request with this user', 'buddypress' ), 'error' ); 197 } 198 199 bp_core_redirect( wp_get_referer() ); 200 201 return false; 202 } 203 add_action( 'bp_init', 'friends_action_add_friend' ); 204 205 function friends_action_remove_friend() { 206 global $bp; 207 208 if ( $bp->current_component != $bp->friends->slug || $bp->current_action != 'remove-friend' ) 209 return false; 210 211 $potential_friend_id = $bp->action_variables[0]; 212 213 if ( !is_numeric( $potential_friend_id ) || !isset( $potential_friend_id ) ) 214 return false; 215 216 if ( $potential_friend_id == $bp->loggedin_user->id ) 217 return false; 218 219 $friendship_status = BP_Friends_Friendship::check_is_friend( $bp->loggedin_user->id, $potential_friend_id ); 220 221 if ( 'is_friend' == $friendship_status ) { 222 223 if ( !check_admin_referer( 'friends_remove_friend' ) ) 224 return false; 225 226 if ( !friends_remove_friend( $bp->loggedin_user->id, $potential_friend_id ) ) { 227 bp_core_add_message( __( 'Friendship could not be canceled.', 'buddypress' ), 'error' ); 228 } else { 229 bp_core_add_message( __( 'Friendship canceled', 'buddypress' ) ); 230 } 231 232 } else if ( 'is_friends' == $friendship_status ) { 233 bp_core_add_message( __( 'You are not yet friends with this user', 'buddypress' ), 'error' ); 234 } else { 235 bp_core_add_message( __( 'You have a pending friendship request with this user', 'buddypress' ), 'error' ); 236 } 237 238 bp_core_redirect( wp_get_referer() ); 239 240 return false; 241 } 242 add_action( 'bp_init', 'friends_action_remove_friend' ); 243 244 245 /******************************************************************************** 246 * Activity & Notification Functions 247 * 248 * These functions handle the recording, deleting and formatting of activity and 249 * notifications for the user and for this specific component. 250 */ 251 252 function friends_record_activity( $args = '' ) { 253 global $bp; 254 255 if ( !function_exists( 'bp_activity_add' ) ) 256 return false; 257 258 $defaults = array ( 259 'user_id' => $bp->loggedin_user->id, 260 'action' => '', 261 'content' => '', 262 'primary_link' => '', 263 'component' => $bp->friends->id, 264 'type' => false, 265 'item_id' => false, 266 'secondary_item_id' => false, 267 'recorded_time' => bp_core_current_time(), 268 'hide_sitewide' => false 269 ); 270 271 $r = wp_parse_args( $args, $defaults ); 272 extract( $r, EXTR_SKIP ); 273 274 return bp_activity_add( array( 'user_id' => $user_id, 'action' => $action, 'content' => $content, 'primary_link' => $primary_link, 'component' => $component, 'type' => $type, 'item_id' => $item_id, 'secondary_item_id' => $secondary_item_id, 'recorded_time' => $recorded_time, 'hide_sitewide' => $hide_sitewide ) ); 275 } 276 277 function friends_delete_activity( $args ) { 278 global $bp; 279 280 if ( function_exists('bp_activity_delete_by_item_id') ) { 281 extract( (array)$args ); 282 bp_activity_delete_by_item_id( array( 'item_id' => $item_id, 'component' => $bp->friends->id, 'type' => $type, 'user_id' => $user_id, 'secondary_item_id' => $secondary_item_id ) ); 149 parent::_setup_title(); 283 150 } 284 151 } 285 286 function friends_register_activity_actions() { 287 global $bp; 288 289 if ( !function_exists( 'bp_activity_set_action' ) ) 290 return false; 291 292 bp_activity_set_action( $bp->friends->id, 'friends_register_activity_action', __( 'New friendship created', 'buddypress' ) ); 293 294 do_action( 'friends_register_activity_actions' ); 295 } 296 add_action( 'bp_register_activity_actions', 'friends_register_activity_actions' ); 297 298 function friends_format_notifications( $action, $item_id, $secondary_item_id, $total_items ) { 299 global $bp; 300 301 switch ( $action ) { 302 case 'friendship_accepted': 303 if ( (int)$total_items > 1 ) { 304 return apply_filters( 'bp_friends_multiple_friendship_accepted_notification', '<a href="' . $bp->loggedin_user->domain . $bp->friends->slug . '/my-friends/newest" title="' . __( 'My Friends', 'buddypress' ) . '">' . sprintf( __('%d friends accepted your friendship requests', 'buddypress' ), (int)$total_items ) . '</a>', (int)$total_items ); 305 } else { 306 $user_fullname = bp_core_get_user_displayname( $item_id ); 307 $user_url = bp_core_get_user_domain( $item_id ); 308 return apply_filters( 'bp_friends_single_friendship_accepted_notification', '<a href="' . $user_url . '?new" title="' . $user_fullname .'\'s profile">' . sprintf( __( '%s accepted your friendship request', 'buddypress' ), $user_fullname ) . '</a>', $user_fullname ); 309 } 310 break; 311 312 case 'friendship_request': 313 if ( (int)$total_items > 1 ) { 314 return apply_filters( 'bp_friends_multiple_friendship_request_notification', '<a href="' . $bp->loggedin_user->domain . $bp->friends->slug . '/requests/?new" title="' . __( 'Friendship requests', 'buddypress' ) . '">' . sprintf( __('You have %d pending friendship requests', 'buddypress' ), (int)$total_items ) . '</a>', $total_items ); 315 } else { 316 $user_fullname = bp_core_get_user_displayname( $item_id ); 317 $user_url = bp_core_get_user_domain( $item_id ); 318 return apply_filters( 'bp_friends_single_friendship_request_notification', '<a href="' . $bp->loggedin_user->domain . $bp->friends->slug . '/requests/?new" title="' . __( 'Friendship requests', 'buddypress' ) . '">' . sprintf( __('You have a friendship request from %s', 'buddypress' ), $user_fullname ) . '</a>', $user_fullname ); 319 } 320 break; 321 } 322 323 do_action( 'friends_format_notifications', $action, $item_id, $secondary_item_id, $total_items ); 324 325 return false; 326 } 327 328 329 /******************************************************************************** 330 * Business Functions 331 * 332 * Business functions are where all the magic happens in BuddyPress. They will 333 * handle the actual saving or manipulation of information. Usually they will 334 * hand off to a database class for data access, then return 335 * true or false on success or failure. 336 */ 337 338 function friends_add_friend( $initiator_userid, $friend_userid, $force_accept = false ) { 339 global $bp; 340 341 $friendship = new BP_Friends_Friendship; 342 343 if ( (int)$friendship->is_confirmed ) 344 return true; 345 346 $friendship->initiator_user_id = $initiator_userid; 347 $friendship->friend_user_id = $friend_userid; 348 $friendship->is_confirmed = 0; 349 $friendship->is_limited = 0; 350 $friendship->date_created = bp_core_current_time(); 351 352 if ( $force_accept ) 353 $friendship->is_confirmed = 1; 354 355 if ( $friendship->save() ) { 356 357 if ( !$force_accept ) { 358 // Add the on screen notification 359 bp_users_add_notification( $friendship->initiator_user_id, $friendship->friend_user_id, $bp->friends->id, 'friendship_request' ); 360 361 // Send the email notification 362 require_once( BP_PLUGIN_DIR . '/bp-friends/bp-friends-notifications.php' ); 363 friends_notification_new_request( $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id ); 364 365 do_action( 'friends_friendship_requested', $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id ); 366 } else { 367 do_action( 'friends_friendship_accepted', $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id ); 368 } 369 370 return true; 371 } 372 373 return false; 374 } 375 376 function friends_remove_friend( $initiator_userid, $friend_userid ) { 377 global $bp; 378 379 $friendship_id = BP_Friends_Friendship::get_friendship_id( $initiator_userid, $friend_userid ); 380 $friendship = new BP_Friends_Friendship( $friendship_id ); 381 382 do_action( 'friends_before_friendship_delete', $friendship_id, $initiator_userid, $friend_userid ); 383 384 // Remove the activity stream item for the user who canceled the friendship 385 friends_delete_activity( array( 'item_id' => $friendship_id, 'type' => 'friendship_accepted', 'user_id' => $bp->displayed_user->id ) ); 386 387 do_action( 'friends_friendship_deleted', $friendship_id, $initiator_userid, $friend_userid ); 388 389 if ( $friendship->delete() ) { 390 friends_update_friend_totals( $initiator_userid, $friend_userid, 'remove' ); 391 392 return true; 393 } 394 395 return false; 396 } 397 398 function friends_accept_friendship( $friendship_id ) { 399 global $bp; 400 401 $friendship = new BP_Friends_Friendship( $friendship_id, true, false ); 402 403 if ( !$friendship->is_confirmed && BP_Friends_Friendship::accept( $friendship_id ) ) { 404 friends_update_friend_totals( $friendship->initiator_user_id, $friendship->friend_user_id ); 405 406 // Remove the friend request notice 407 bp_users_delete_notifications_by_item_id( $friendship->friend_user_id, $friendship->initiator_user_id, $bp->friends->id, 'friendship_request' ); 408 409 // Add a friend accepted notice for the initiating user 410 bp_users_add_notification( $friendship->friend_user_id, $friendship->initiator_user_id, $bp->friends->id, 'friendship_accepted' ); 411 412 $initiator_link = bp_core_get_userlink( $friendship->initiator_user_id ); 413 $friend_link = bp_core_get_userlink( $friendship->friend_user_id ); 414 415 // Record in activity streams for the initiator 416 friends_record_activity( array( 417 'user_id' => $friendship->initiator_user_id, 418 'type' => 'friendship_created', 419 'action' => apply_filters( 'friends_activity_friendship_accepted_action', sprintf( __( '%1$s and %2$s are now friends', 'buddypress' ), $initiator_link, $friend_link ), $friendship ), 420 'item_id' => $friendship_id, 421 'secondary_item_id' => $friendship->friend_user_id 422 ) ); 423 424 // Record in activity streams for the friend 425 friends_record_activity( array( 426 'user_id' => $friendship->friend_user_id, 427 'type' => 'friendship_created', 428 'action' => apply_filters( 'friends_activity_friendship_accepted_action', sprintf( __( '%1$s and %2$s are now friends', 'buddypress' ), $friend_link, $initiator_link ), $friendship ), 429 'item_id' => $friendship_id, 430 'secondary_item_id' => $friendship->initiator_user_id, 431 'hide_sitewide' => true // We've already got the first entry site wide 432 ) ); 433 434 // Send the email notification 435 require_once( BP_PLUGIN_DIR . '/bp-friends/bp-friends-notifications.php' ); 436 friends_notification_accepted_request( $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id ); 437 438 do_action( 'friends_friendship_accepted', $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id ); 439 440 return true; 441 } 442 443 return false; 444 } 445 446 function friends_reject_friendship( $friendship_id ) { 447 $friendship = new BP_Friends_Friendship( $friendship_id, true, false ); 448 449 if ( !$friendship->is_confirmed && BP_Friends_Friendship::reject( $friendship_id ) ) { 450 // Remove the friend request notice 451 bp_users_delete_notifications_by_item_id( $friendship->friend_user_id, $friendship->initiator_user_id, $bp->friends->id, 'friendship_request' ); 452 453 do_action_ref_array( 'friends_friendship_rejected', array( $friendship_id, &$friendship ) ); 454 return true; 455 } 456 457 return false; 458 } 459 460 function friends_check_friendship( $user_id, $possible_friend_id ) { 461 global $bp; 462 463 if ( 'is_friend' == BP_Friends_Friendship::check_is_friend( $user_id, $possible_friend_id ) ) 464 return true; 465 466 return false; 467 } 468 469 // Returns - 'is_friend', 'not_friends', 'pending' 470 function friends_check_friendship_status( $user_id, $possible_friend_id ) { 471 return BP_Friends_Friendship::check_is_friend( $user_id, $possible_friend_id ); 472 } 473 474 function friends_get_total_friend_count( $user_id = 0 ) { 475 global $bp; 476 477 if ( !$user_id ) 478 $user_id = ( $bp->displayed_user->id ) ? $bp->displayed_user->id : $bp->loggedin_user->id; 479 480 if ( !$count = wp_cache_get( 'bp_total_friend_count_' . $user_id, 'bp' ) ) { 481 $count = get_user_meta( $user_id, 'total_friend_count', true ); 482 if ( empty( $count ) ) $count = 0; 483 wp_cache_set( 'bp_total_friend_count_' . $user_id, $count, 'bp' ); 484 } 485 486 return apply_filters( 'friends_get_total_friend_count', $count ); 487 } 488 489 function friends_check_user_has_friends( $user_id ) { 490 $friend_count = friends_get_total_friend_count( $user_id ); 491 492 if ( empty( $friend_count ) ) 493 return false; 494 495 if ( !(int)$friend_count ) 496 return false; 497 498 return true; 499 } 500 501 function friends_get_friendship_id( $initiator_user_id, $friend_user_id ) { 502 return BP_Friends_Friendship::get_friendship_id( $initiator_user_id, $friend_user_id ); 503 } 504 505 function friends_get_friend_user_ids( $user_id, $friend_requests_only = false, $assoc_arr = false, $filter = false ) { 506 return BP_Friends_Friendship::get_friend_user_ids( $user_id, $friend_requests_only, $assoc_arr, $filter ); 507 } 508 509 function friends_search_friends( $search_terms, $user_id, $pag_num = 10, $pag_page = 1 ) { 510 return BP_Friends_Friendship::search_friends( $search_terms, $user_id, $pag_num, $pag_page ); 511 } 512 513 function friends_get_friendship_request_user_ids( $user_id ) { 514 return BP_Friends_Friendship::get_friendship_request_user_ids( $user_id ); 515 } 516 517 function friends_get_recently_active( $user_id, $per_page = 0, $page = 0, $filter = '' ) { 518 return apply_filters( 'friends_get_recently_active', BP_Core_User::get_users( 'active', $per_page, $page, $user_id, $filter ) ); 519 } 520 521 function friends_get_alphabetically( $user_id, $per_page = 0, $page = 0, $filter = '' ) { 522 return apply_filters( 'friends_get_alphabetically', BP_Core_User::get_users( 'alphabetical', $per_page, $page, $user_id, $filter ) ); 523 } 524 525 function friends_get_newest( $user_id, $per_page = 0, $page = 0, $filter = '' ) { 526 return apply_filters( 'friends_get_newest', BP_Core_User::get_users( 'newest', $per_page, $page, $user_id, $filter ) ); 527 } 528 529 function friends_get_bulk_last_active( $friend_ids ) { 530 return BP_Friends_Friendship::get_bulk_last_active( $friend_ids ); 531 } 532 533 function friends_get_friends_invite_list( $user_id = 0 ) { 534 global $bp; 535 536 if ( !$user_id ) 537 $user_id = $bp->loggedin_user->id; 538 539 if ( bp_has_members( 'user_id=' . $user_id . '&type=alphabetical&per_page=0' ) ) { 540 while ( bp_members() ) : bp_the_member(); 541 $friends[] = array( 542 'id' => bp_get_member_user_id(), 543 'full_name' => bp_get_member_name() 544 ); 545 endwhile; 546 } 547 548 if ( empty($friends) ) 549 return false; 550 551 return $friends; 552 } 553 554 function friends_count_invitable_friends( $user_id, $group_id ) { 555 return BP_Friends_Friendship::get_invitable_friend_count( $user_id, $group_id ); 556 } 557 558 function friends_get_friend_count_for_user( $user_id ) { 559 return BP_Friends_Friendship::total_friend_count( $user_id ); 560 } 561 562 function friends_search_users( $search_terms, $user_id, $pag_num = 0, $pag_page = 0 ) { 563 global $bp; 564 565 $user_ids = BP_Friends_Friendship::search_users( $search_terms, $user_id, $pag_num, $pag_page ); 566 567 if ( !$user_ids ) 568 return false; 569 570 for ( $i = 0; $i < count( $user_ids ); $i++ ) 571 $users[] = new BP_Core_User($user_ids[$i]); 572 573 return array( 'users' => $users, 'count' => BP_Friends_Friendship::search_users_count( $search_terms ) ); 574 } 575 576 function friends_is_friendship_confirmed( $friendship_id ) { 577 $friendship = new BP_Friends_Friendship( $friendship_id ); 578 return $friendship->is_confirmed; 579 } 580 581 function friends_update_friend_totals( $initiator_user_id, $friend_user_id, $status = 'add' ) { 582 if ( 'add' == $status ) { 583 update_user_meta( $initiator_user_id, 'total_friend_count', (int)get_user_meta( $initiator_user_id, 'total_friend_count', true ) + 1 ); 584 update_user_meta( $friend_user_id, 'total_friend_count', (int)get_user_meta( $friend_user_id, 'total_friend_count', true ) + 1 ); 585 } else { 586 update_user_meta( $initiator_user_id, 'total_friend_count', (int)get_user_meta( $initiator_user_id, 'total_friend_count', true ) - 1 ); 587 update_user_meta( $friend_user_id, 'total_friend_count', (int)get_user_meta( $friend_user_id, 'total_friend_count', true ) - 1 ); 588 } 589 } 590 591 function friends_remove_data( $user_id ) { 592 global $bp; 593 594 do_action( 'friends_before_remove_data', $user_id ); 595 596 BP_Friends_Friendship::delete_all_for_user($user_id); 597 598 // Remove usermeta 599 delete_user_meta( $user_id, 'total_friend_count' ); 600 601 // Remove friendship requests FROM user 602 bp_users_delete_notifications_from_user( $user_id, $bp->friends->id, 'friendship_request' ); 603 604 do_action( 'friends_remove_data', $user_id ); 605 } 606 add_action( 'wpmu_delete_user', 'friends_remove_data' ); 607 add_action( 'delete_user', 'friends_remove_data' ); 608 add_action( 'bp_make_spam_user', 'friends_remove_data' ); 609 610 611 /******************************************************************************** 612 * Caching 613 * 614 * Caching functions handle the clearing of cached objects and pages on specific 615 * actions throughout BuddyPress. 616 */ 617 618 function friends_clear_friend_object_cache( $friendship_id ) { 619 if ( !$friendship = new BP_Friends_Friendship( $friendship_id ) ) 620 return false; 621 622 wp_cache_delete( 'friends_friend_ids_' . $friendship->initiator_user_id, 'bp' ); 623 wp_cache_delete( 'friends_friend_ids_' . $friendship->friend_user_id, 'bp' ); 624 wp_cache_delete( 'bp_total_friend_count_' . $friendship->initiator_user_id, 'bp' ); 625 wp_cache_delete( 'bp_total_friend_count_' . $friendship->friend_user_id, 'bp' ); 626 } 627 628 function friends_clear_friend_notifications() { 629 global $bp; 630 631 if ( isset( $_GET['new'] ) ) 632 bp_users_delete_notifications_by_type( $bp->loggedin_user->id, $bp->friends->id, 'friendship_accepted' ); 633 } 634 add_action( 'bp_activity_screen_my_activity', 'friends_clear_friend_notifications' ); 635 636 // List actions to clear object caches on 637 add_action( 'friends_friendship_accepted', 'friends_clear_friend_object_cache' ); 638 add_action( 'friends_friendship_deleted', 'friends_clear_friend_object_cache' ); 639 640 // List actions to clear super cached pages on, if super cache is installed 641 add_action( 'friends_friendship_rejected', 'bp_core_clear_cache' ); 642 add_action( 'friends_friendship_accepted', 'bp_core_clear_cache' ); 643 add_action( 'friends_friendship_deleted', 'bp_core_clear_cache' ); 644 add_action( 'friends_friendship_requested', 'bp_core_clear_cache' ); 152 // Create the friends component 153 $bp->friends = new BP_Friends_Component(); 645 154 646 155 ?> -
trunk/bp-groups/bp-groups-actions.php
r3845 r3917 182 182 bp_core_load_template( apply_filters( 'groups_template_create_group', 'groups/create' ) ); 183 183 } 184 add_action( ' wp', 'groups_action_create_group', 3);184 add_action( 'bp_actions', 'groups_action_create_group' ); 185 185 186 186 function groups_action_join_group() { … … 216 216 bp_core_load_template( apply_filters( 'groups_template_group_home', 'groups/single/home' ) ); 217 217 } 218 add_action( ' wp', 'groups_action_join_group', 3);218 add_action( 'bp_actions', 'groups_action_join_group' ); 219 219 220 220 … … 241 241 bp_core_load_template( apply_filters( 'groups_template_group_home', 'groups/single/home' ) ); 242 242 } 243 add_action( ' wp', 'groups_action_leave_group', 3);243 add_action( 'bp_actions', 'groups_action_leave_group' ); 244 244 245 245 … … 277 277 } 278 278 } 279 add_action( ' wp', 'groups_action_redirect_to_random_group', 6);279 add_action( 'bp_actions', 'groups_action_redirect_to_random_group' ); 280 280 281 281 function groups_action_group_feed() { … … 296 296 die; 297 297 } 298 add_action( ' wp', 'groups_action_group_feed', 3);298 add_action( 'bp_actions', 'groups_action_group_feed' ); 299 299 300 300 ?> -
trunk/bp-groups/bp-groups-classes.php
r3905 r3917 1020 1020 $exclude_sql = $wpdb->prepare( " AND m.user_id NOT IN ({$exclude})" ); 1021 1021 1022 if ( bp_is_active( ' profile' ) )1022 if ( bp_is_active( 'xprofile' ) ) 1023 1023 $members = $wpdb->get_results( $wpdb->prepare( "SELECT m.user_id, m.date_modified, m.is_banned, u.user_login, u.user_nicename, u.user_email, pd.value as display_name FROM {$bp->groups->table_name_members} m, {$wpdb->users} u, {$bp->profile->table_name_data} pd WHERE u.ID = m.user_id AND u.ID = pd.user_id AND pd.field_id = 1 AND group_id = %d AND is_confirmed = 1 {$banned_sql} {$exclude_admins_sql} {$exclude_sql} ORDER BY m.date_modified DESC {$pag_sql}", $group_id ) ); 1024 1024 else -
trunk/bp-groups/bp-groups-functions.php
r3903 r3917 7 7 * true or false on success or failure. 8 8 */ 9 10 function groups_directory_groups_setup() {11 global $bp;12 13 if ( bp_is_current_component( 'groups' ) && !bp_current_action() && !bp_current_item() ) {14 $bp->is_directory = true;15 16 do_action( 'groups_directory_groups_setup' );17 18 bp_core_load_template( apply_filters( 'groups_template_directory_groups', 'groups/index' ) );19 }20 }21 add_action( 'wp', 'groups_directory_groups_setup', 2 );22 9 23 10 function groups_setup_adminbar_menu() { … … 218 205 219 206 // Remove all notifications for any user belonging to this group 220 bp_ users_delete_all_notifications_by_type( $group_id, $bp->groups->slug );207 bp_members_delete_all_notifications_by_type( $group_id, $bp->groups->slug ); 221 208 222 209 // Remove forum if component is active and current group has one … … 608 595 groups_update_groupmeta( $group_id, 'last_activity', bp_core_current_time() ); 609 596 610 bp_ users_delete_notifications_by_item_id( $user_id, $group_id, $bp->groups->id, 'group_invite' );597 bp_members_delete_notifications_by_item_id( $user_id, $group_id, $bp->groups->id, 'group_invite' ); 611 598 612 599 do_action( 'groups_accept_invite', $user_id, $group_id ); … … 629 616 630 617 if ( $delete ) 631 bp_ users_delete_notifications_by_item_id( $user_id, $group_id, $bp->groups->id, 'group_invite' );618 bp_members_delete_notifications_by_item_id( $user_id, $group_id, $bp->groups->id, 'group_invite' ); 632 619 633 620 return $delete; -
trunk/bp-groups/bp-groups-loader.php
r3858 r3917 21 21 */ 22 22 function BP_Groups_Component() { 23 parent::start( 'groups', __( 'User Groups', 'buddypress' ) ); 23 parent::start( 24 'groups', 25 __( 'User Groups', 'buddypress' ), 26 BP_PLUGIN_DIR 27 ); 28 } 29 30 /** 31 * Include files 32 */ 33 function _includes() { 34 $includes = array( 35 'cache', 36 'forums', 37 'actions', 38 'filters', 39 'screens', 40 'classes', 41 'widgets', 42 'activity', 43 'template', 44 'functions' 45 ); 46 parent::_includes( $includes ); 24 47 } 25 48 … … 40 63 define( 'BP_GROUPS_SLUG', $this->id ); 41 64 42 // Do some slug checks 43 $this->slug = BP_GROUPS_SLUG; 44 $this->root_slug = isset( $bp->pages->groups->slug ) ? $bp->pages->groups->slug : $this->slug; 45 46 // Tables 47 $this->table_name = $bp->table_prefix . 'bp_groups'; 48 $this->table_name_members = $bp->table_prefix . 'bp_groups_members'; 49 $this->table_name_groupmeta = $bp->table_prefix . 'bp_groups_groupmeta'; 50 51 // Notifications 52 $this->notification_callback = 'groups_format_notifications'; 65 // Global tables for messaging component 66 $global_tables = array( 67 'table_name' => $bp->table_prefix . 'bp_groups', 68 'table_name_members' => $bp->table_prefix . 'bp_groups_members', 69 'table_name_groupmeta' => $bp->table_prefix . 'bp_groups_groupmeta' 70 ); 71 72 // All globals for messaging component. 73 // Note that global_tables is included in this array. 74 $globals = array( 75 'slug' => BP_GROUPS_SLUG, 76 'root_slug' => isset( $bp->pages->groups->slug ) ? $bp->pages->groups->slug : BP_GROUPS_SLUG, 77 'notification_callback' => 'groups_format_notifications', 78 'search_string' => __( 'Search Groups...', 'buddypress' ), 79 'global_tables' => $global_tables, 80 ); 81 82 parent::_setup_globals( $globals ); 83 84 /** Single Group Globals **********************************************/ 85 86 // Are we viewing a single group? 87 if ( bp_is_groups_component() && $group_id = BP_Groups_Group::group_exists( bp_current_action() ) ) { 88 89 $bp->is_single_item = true; 90 $this->current_group = new BP_Groups_Group( $group_id ); 91 92 // When in a single group, the first action is bumped down one because of the 93 // group name, so we need to adjust this and set the group name to current_item. 94 $bp->current_item = isset( $bp->current_action ) ? $bp->current_action : false; 95 $bp->current_action = isset( $bp->action_variables[0] ) ? $bp->action_variables[0] : false; 96 array_shift( $bp->action_variables ); 97 98 // Using "item" not "group" for generic support in other components. 99 if ( is_super_admin() ) 100 $bp->is_item_admin = 1; 101 else 102 $bp->is_item_admin = groups_is_user_admin( $bp->loggedin_user->id, $this->current_group->id ); 103 104 // If the user is not an admin, check if they are a moderator 105 if ( empty( $bp->is_item_admin ) ) 106 $bp->is_item_mod = groups_is_user_mod( $bp->loggedin_user->id, $this->current_group->id ); 107 108 // Is the logged in user a member of the group? 109 if ( ( is_user_logged_in() && groups_is_user_member( $bp->loggedin_user->id, $this->current_group->id ) ) ) 110 $this->current_group->is_user_member = true; 111 else 112 $this->current_group->is_user_member = false; 113 114 // Should this group be visible to the logged in user? 115 if ( 'public' == $this->current_group->status || $this->current_group->is_user_member ) 116 $this->current_group->is_visible = true; 117 else 118 $this->current_group->is_visible = false; 119 120 // If this is a private or hidden group, does the user have access? 121 if ( 'private' == $this->current_group->status || 'hidden' == $this->current_group->status ) { 122 if ( $this->current_group->is_user_member && is_user_logged_in() || is_super_admin() ) 123 $this->current_group->user_has_access = true; 124 else 125 $this->current_group->user_has_access = false; 126 } else { 127 $this->current_group->user_has_access = true; 128 } 129 130 // Set current_group to 0 to prevent debug errors 131 } else { 132 $this->current_group = 0; 133 } 53 134 54 135 // Illegal group names/slugs 55 $this->forbidden_names 136 $this->forbidden_names = apply_filters( 'groups_forbidden_names', array( 56 137 'my-groups', 57 138 'create', … … 70 151 ) ); 71 152 72 // The default text for the blogs directory search box73 $bp->default_search_strings[$this->id] = __( 'Search Groups...', 'buddypress' );74 75 153 // Preconfigured group creation steps 76 154 $this->group_creation_steps = apply_filters( 'groups_create_group_steps', array( … … 104 182 105 183 // Auto join group when non group member performs group activity 106 $this->auto_join = defined( 'BP_DISABLE_AUTO_GROUP_JOIN' ) ? false : true; 107 108 // The default text for the groups directory search box 109 $this->default_search_string = __( 'Search Groups...', 'buddypress' ); 110 111 // Register this in the active components array 112 $bp->active_components[$this->id] = $this->id; 113 } 114 115 /** 116 * Include files 117 */ 118 function _includes() { 119 require_once( BP_PLUGIN_DIR . '/bp-groups/bp-groups-cache.php' ); 120 require_once( BP_PLUGIN_DIR . '/bp-groups/bp-groups-forums.php' ); 121 require_once( BP_PLUGIN_DIR . '/bp-groups/bp-groups-actions.php' ); 122 require_once( BP_PLUGIN_DIR . '/bp-groups/bp-groups-filters.php' ); 123 require_once( BP_PLUGIN_DIR . '/bp-groups/bp-groups-screens.php' ); 124 require_once( BP_PLUGIN_DIR . '/bp-groups/bp-groups-classes.php' ); 125 require_once( BP_PLUGIN_DIR . '/bp-groups/bp-groups-widgets.php' ); 126 require_once( BP_PLUGIN_DIR . '/bp-groups/bp-groups-activity.php' ); 127 require_once( BP_PLUGIN_DIR . '/bp-groups/bp-groups-template.php' ); 128 require_once( BP_PLUGIN_DIR . '/bp-groups/bp-groups-functions.php' ); 184 $this->auto_join = defined( 'BP_DISABLE_AUTO_GROUP_JOIN' ); 129 185 } 130 186 … … 137 193 global $bp; 138 194 139 // Are we viewing a single group?140 if ( bp_is_current_component( 'groups' ) && $group_id = BP_Groups_Group::group_exists( bp_current_action() ) ) {141 142 $bp->is_single_item = true;143 $this->current_group = new BP_Groups_Group( $group_id );144 145 // Using "item" not "group" for generic support in other components.146 if ( is_super_admin() )147 $bp->is_item_admin = 1;148 else149 $bp->is_item_admin = groups_is_user_admin( $bp->loggedin_user->id, $this->current_group->id );150 151 // If the user is not an admin, check if they are a moderator152 if ( empty( $bp->is_item_admin ) )153 $bp->is_item_mod = groups_is_user_mod( $bp->loggedin_user->id, $this->current_group->id );154 155 // Is the logged in user a member of the group?156 if ( ( is_user_logged_in() && groups_is_user_member( $bp->loggedin_user->id, $this->current_group->id ) ) )157 $this->current_group->is_user_member = true;158 else159 $this->current_group->is_user_member = false;160 161 // Should this group be visible to the logged in user?162 if ( 'public' == $this->current_group->status || $this->current_group->is_user_member )163 $this->current_group->is_visible = true;164 else165 $this->current_group->is_visible = false;166 167 // Set current_group to 0 to prevent debug errors168 } else {169 $this->current_group = 0;170 }171 172 195 // Add 'Groups' to the main navigation 173 bp_core_new_nav_item(array(196 $main_nav = array( 174 197 'name' => sprintf( __( 'Groups <span>(%d)</span>', 'buddypress' ), groups_total_groups_for_user() ), 175 198 'slug' => $this->slug, … … 178 201 'default_subnav_slug' => 'my-groups', 179 202 'item_css_id' => $this->id 180 ) );203 ); 181 204 182 205 $groups_link = trailingslashit( $bp->loggedin_user->domain . $this->slug ); 183 206 184 207 // Add the My Groups nav item 185 bp_core_new_subnav_item(array(208 $sub_nav[] = array( 186 209 'name' => __( 'My Groups', 'buddypress' ), 187 210 'slug' => 'my-groups', … … 191 214 'position' => 10, 192 215 'item_css_id' => 'groups-my-groups' 193 ) );216 ); 194 217 195 218 // Add the Group Invites nav item 196 bp_core_new_subnav_item(array(219 $sub_nav[] = array( 197 220 'name' => __( 'Invitations', 'buddypress' ), 198 221 'slug' => 'invites', … … 202 225 'position' => 30, 203 226 'user_has_access' => bp_is_my_profile() 204 ) ); 205 206 207 if ( bp_is_current_component( 'groups' ) ) { 227 ); 228 229 parent::_setup_nav( $main_nav, $sub_nav ); 230 231 if ( bp_is_groups_component() ) { 232 if ( bp_is_single_item() ) { 233 234 // Add 'Groups' to the main navigation 235 $main_nav = array( 236 'name' => __( 'Groups', 'buddypress' ), 237 'slug' => $this->root_slug, 238 'position' => -1, // Do not show in BuddyBar 239 'screen_function' => 'groups_screen_group_home', 240 'default_subnav_slug' => 'home', 241 'item_css_id' => $this->id 242 ); 243 244 $group_link = trailingslashit( $bp->root_domain . '/' . $this->root_slug . '/' . $this->current_group->slug ); 245 246 // Add the "Home" subnav item, as this will always be present 247 $sub_nav[] = array( 248 'name' => __( 'Home', 'buddypress' ), 249 'slug' => 'home', 250 'parent_url' => $group_link, 251 'parent_slug' => $this->root_slug, 252 'screen_function' => 'groups_screen_group_home', 253 'position' => 10, 254 'item_css_id' => 'home' 255 ); 256 257 // If the user is a group mod or more, then show the group admin nav item 258 if ( bp_is_item_admin() || bp_is_item_mod() ) { 259 $sub_nav[] = array( 260 'name' => __( 'Admin', 'buddypress' ), 261 'slug' => 'admin', 262 'parent_url' => $group_link, 263 'parent_slug' => $this->root_slug, 264 'screen_function' => 'groups_screen_group_admin', 265 'position' => 20, 266 'user_has_access' => ( $bp->is_item_admin + (int)$bp->is_item_mod ), 267 'item_css_id' => 'admin' 268 ); 269 } 270 271 // If this is a private group, and the user is not a member, show a "Request Membership" nav item. 272 if ( is_user_logged_in() && 273 !is_super_admin() && 274 !$this->current_group->is_user_member && 275 !groups_check_for_membership_request( $bp->loggedin_user->id, $this->current_group->id ) && 276 $this->current_group->status == 'private' 277 ) { 278 $sub_nav[] = array( 279 'name' => __( 'Request Membership', 'buddypress' ), 280 'slug' => 'request-membership', 281 'parent_url' => $group_link, 282 'parent_slug' => $this->root_slug, 283 'screen_function' => 'groups_screen_group_request_membership', 284 'position' => 30 285 ); 286 } 287 288 // Forums are enabled and turned on 289 if ( $this->current_group->enable_forum && bp_is_active( 'forums' ) ) { 290 $sub_nav[] = array( 291 'name' => __( 'Forum', 'buddypress' ), 292 'slug' => 'forum', 293 'parent_url' => $group_link, 294 'parent_slug' => $this->root_slug, 295 'screen_function' => 'groups_screen_group_forum', 296 'position' => 40, 297 'user_has_access' => $this->current_group->user_has_access, 298 'item_css_id' => 'forums' 299 ); 300 } 301 302 $sub_nav[] = array( 303 'name' => sprintf( __( 'Members (%s)', 'buddypress' ), number_format( $this->current_group->total_member_count ) ), 304 'slug' => 'members', 305 'parent_url' => $group_link, 306 'parent_slug' => $this->root_slug, 307 'screen_function' => 'groups_screen_group_members', 308 'position' => 60, 309 'user_has_access' => $this->current_group->user_has_access, 310 'item_css_id' => 'members' 311 ); 312 313 if ( is_user_logged_in() && groups_is_user_member( $bp->loggedin_user->id, $this->current_group->id ) ) { 314 if ( bp_is_active( 'friends' ) ) { 315 $sub_nav[] = array( 316 'name' => __( 'Send Invites', 'buddypress' ), 317 'slug' => 'send-invites', 318 'parent_url' => $group_link, 319 'parent_slug' => $this->root_slug, 320 'screen_function' => 'groups_screen_group_invite', 321 'item_css_id' => 'invite', 322 'position' => 70, 323 'user_has_access' => $this->current_group->user_has_access 324 ); 325 } 326 } 327 328 parent::_setup_nav( $main_nav, $sub_nav ); 329 } 330 } 331 332 if ( isset( $this->current_group->user_has_access ) ) 333 do_action( 'groups_setup_nav', $this->current_group->user_has_access ); 334 else 335 do_action( 'groups_setup_nav'); 336 } 337 338 /** 339 * Sets up the title for pages and <title> 340 * 341 * @global obj $bp 342 */ 343 function _setup_title() { 344 global $bp; 345 346 if ( bp_is_groups_component() ) { 208 347 209 348 if ( bp_is_my_profile() && !bp_is_single_item() ) { … … 211 350 $bp->bp_options_title = __( 'My Groups', 'buddypress' ); 212 351 213 } else if ( !bp_is_my_profile() && ! $bp->is_single_item) {352 } else if ( !bp_is_my_profile() && !bp_is_single_item() ) { 214 353 215 354 $bp->bp_options_avatar = bp_core_fetch_avatar( array( … … 222 361 // group navigation menu using the $this->current_group global. 223 362 } else if ( bp_is_single_item() ) { 224 // When in a single group, the first action is bumped down one because of the225 // group name, so we need to adjust this and set the group name to current_item.226 $bp->current_item = isset( $bp->current_action ) ? $bp->current_action : false;227 $bp->current_action = isset( $bp->action_variables[0] ) ? $bp->action_variables[0] : false;228 array_shift( $bp->action_variables );229 230 363 $bp->bp_options_title = $this->current_group->name; 231 364 $bp->bp_options_avatar = bp_core_fetch_avatar( array( … … 238 371 if ( empty( $bp->bp_options_avatar ) ) 239 372 $bp->bp_options_avatar = '<img src="' . esc_attr( $group->avatar_full ) . '" class="avatar" alt="' . esc_attr( $group->name ) . '" />'; 240 241 // Add 'Groups' to the main navigation242 bp_core_new_nav_item( array(243 'name' => __( 'Groups', 'buddypress' ),244 'slug' => $this->root_slug,245 'position' => -1, // Do not show in BuddyBar246 'screen_function' => 'groups_screen_group_home',247 'default_subnav_slug' => 'home',248 'item_css_id' => $this->id249 ) );250 251 $group_link = trailingslashit( $bp->root_domain . '/' . $this->root_slug . '/' . $this->current_group->slug );252 253 // If this is a private or hidden group, does the user have access?254 if ( 'private' == $this->current_group->status || 'hidden' == $this->current_group->status ) {255 if ( $this->current_group->is_user_member && is_user_logged_in() || is_super_admin() )256 $this->current_group->user_has_access = true;257 else258 $this->current_group->user_has_access = false;259 } else {260 $this->current_group->user_has_access = true;261 }262 263 // Add the "Home" subnav item, as this will always be present264 bp_core_new_subnav_item( array(265 'name' => __( 'Home', 'buddypress' ),266 'slug' => 'home',267 'parent_url' => $group_link,268 'parent_slug' => $this->root_slug,269 'screen_function' => 'groups_screen_group_home',270 'position' => 10,271 'item_css_id' => 'home'272 ) );273 274 // If the user is a group mod or more, then show the group admin nav item275 if ( bp_is_item_admin() || bp_is_item_mod() ) {276 bp_core_new_subnav_item( array(277 'name' => __( 'Admin', 'buddypress' ),278 'slug' => 'admin',279 'parent_url' => $group_link,280 'parent_slug' => $this->root_slug,281 'screen_function' => 'groups_screen_group_admin',282 'position' => 20,283 'user_has_access' => ( $bp->is_item_admin + (int)$bp->is_item_mod ),284 'item_css_id' => 'admin'285 ) );286 }287 288 // If this is a private group, and the user is not a member, show a "Request Membership" nav item.289 if ( is_user_logged_in() &&290 !is_super_admin() &&291 !$this->current_group->is_user_member &&292 !groups_check_for_membership_request( $bp->loggedin_user->id, $this->current_group->id ) &&293 $this->current_group->status == 'private'294 ) {295 bp_core_new_subnav_item( array(296 'name' => __( 'Request Membership', 'buddypress' ),297 'slug' => 'request-membership',298 'parent_url' => $group_link,299 'parent_slug' => $this->root_slug,300 'screen_function' => 'groups_screen_group_request_membership',301 'position' => 30302 ) );303 }304 305 // Forums are enabled and turned on306 if ( $this->current_group->enable_forum && bp_is_active( 'forums' ) ) {307 bp_core_new_subnav_item( array(308 'name' => __( 'Forum', 'buddypress' ),309 'slug' => 'forum',310 'parent_url' => $group_link,311 'parent_slug' => $this->root_slug,312 'screen_function' => 'groups_screen_group_forum',313 'position' => 40,314 'user_has_access' => $this->current_group->user_has_access,315 'item_css_id' => 'forums'316 ) );317 }318 319 bp_core_new_subnav_item( array(320 'name' => sprintf( __( 'Members (%s)', 'buddypress' ), number_format( $this->current_group->total_member_count ) ),321 'slug' => 'members',322 'parent_url' => $group_link,323 'parent_slug' => $this->root_slug,324 'screen_function' => 'groups_screen_group_members',325 'position' => 60,326 'user_has_access' => $this->current_group->user_has_access,327 'item_css_id' => 'members'328 ) );329 330 if ( is_user_logged_in() && groups_is_user_member( $bp->loggedin_user->id, $this->current_group->id ) ) {331 if ( bp_is_active( 'friends' ) ) {332 bp_core_new_subnav_item( array(333 'name' => __( 'Send Invites', 'buddypress' ),334 'slug' => 'send-invites',335 'parent_url' => $group_link,336 'parent_slug' => $this->root_slug,337 'screen_function' => 'groups_screen_group_invite',338 'item_css_id' => 'invite',339 'position' => 70,340 'user_has_access' => $this->current_group->user_has_access341 ) );342 }343 }344 373 } 345 374 } 346 375 347 if ( isset( $this->current_group->user_has_access ) ) 348 do_action( 'groups_setup_nav', $this->current_group->user_has_access ); 349 else 350 do_action( 'groups_setup_nav'); 376 parent::_setup_title(); 351 377 } 352 378 } -
trunk/bp-groups/bp-groups-notifications.php
r3903 r3917 46 46 global $bp; 47 47 48 bp_ users_add_notification( $requesting_user_id, $admin_id, 'groups', 'new_membership_request', $group_id );48 bp_members_add_notification( $requesting_user_id, $admin_id, 'groups', 'new_membership_request', $group_id ); 49 49 50 50 if ( 'no' == get_user_meta( $admin_id, 'notification_groups_membership_request', true ) ) … … 96 96 // Post a screen notification first. 97 97 if ( $accepted ) 98 bp_ users_add_notification( $group_id, $requesting_user_id, 'groups', 'membership_request_accepted' );98 bp_members_add_notification( $group_id, $requesting_user_id, 'groups', 'membership_request_accepted' ); 99 99 else 100 bp_ users_add_notification( $group_id, $requesting_user_id, 'groups', 'membership_request_rejected' );100 bp_members_add_notification( $group_id, $requesting_user_id, 'groups', 'membership_request_rejected' ); 101 101 102 102 if ( 'no' == get_user_meta( $requesting_user_id, 'notification_membership_request_completed', true ) ) … … 159 159 160 160 // Post a screen notification first. 161 bp_ users_add_notification( $group_id, $user_id, 'groups', $type );161 bp_members_add_notification( $group_id, $user_id, 'groups', $type ); 162 162 163 163 if ( 'no' == get_user_meta( $user_id, 'notification_groups_admin_promotion', true ) ) … … 209 209 210 210 // Post a screen notification first. 211 bp_ users_add_notification( $group->id, $invited_user_id, 'groups', 'group_invite' );211 bp_members_add_notification( $group->id, $invited_user_id, 'groups', 'group_invite' ); 212 212 213 213 if ( 'no' == get_user_meta( $invited_user_id, 'notification_groups_invite', true ) ) -
trunk/bp-groups/bp-groups-screens.php
r3910 r3917 9 9 */ 10 10 11 function groups_directory_groups_setup() { 12 global $bp; 13 14 if ( bp_is_groups_component() && !bp_current_action() && !bp_current_item() ) { 15 $bp->is_directory = true; 16 17 do_action( 'groups_directory_groups_setup' ); 18 19 bp_core_load_template( apply_filters( 'groups_template_directory_groups', 'groups/index' ) ); 20 } 21 } 22 add_action( 'bp_screens', 'groups_directory_groups_setup', 2 ); 23 11 24 function groups_screen_my_groups() { 12 25 global $bp; … … 14 27 // Delete group request notifications for the user 15 28 if ( isset( $_GET['n'] ) ) { 16 bp_ users_delete_notifications_by_type( $bp->loggedin_user->id, $bp->groups->id, 'membership_request_accepted' );17 bp_ users_delete_notifications_by_type( $bp->loggedin_user->id, $bp->groups->id, 'membership_request_rejected' );18 bp_ users_delete_notifications_by_type( $bp->loggedin_user->id, $bp->groups->id, 'member_promoted_to_mod' );19 bp_ users_delete_notifications_by_type( $bp->loggedin_user->id, $bp->groups->id, 'member_promoted_to_admin' );29 bp_members_delete_notifications_by_type( $bp->loggedin_user->id, $bp->groups->id, 'membership_request_accepted' ); 30 bp_members_delete_notifications_by_type( $bp->loggedin_user->id, $bp->groups->id, 'membership_request_rejected' ); 31 bp_members_delete_notifications_by_type( $bp->loggedin_user->id, $bp->groups->id, 'member_promoted_to_mod' ); 32 bp_members_delete_notifications_by_type( $bp->loggedin_user->id, $bp->groups->id, 'member_promoted_to_admin' ); 20 33 } 21 34 … … 68 81 69 82 // Remove notifications 70 bp_ users_delete_notifications_by_type( $bp->loggedin_user->id, $bp->groups->id, 'group_invite' );83 bp_members_delete_notifications_by_type( $bp->loggedin_user->id, $bp->groups->id, 'group_invite' ); 71 84 72 85 do_action( 'groups_screen_group_invites', $group_id ); … … 80 93 if ( bp_is_single_item() ) { 81 94 if ( isset( $_GET['n'] ) ) { 82 bp_ users_delete_notifications_by_type( $bp->loggedin_user->id, $bp->groups->id, 'membership_request_accepted' );83 bp_ users_delete_notifications_by_type( $bp->loggedin_user->id, $bp->groups->id, 'membership_request_rejected' );84 bp_ users_delete_notifications_by_type( $bp->loggedin_user->id, $bp->groups->id, 'member_promoted_to_mod' );85 bp_ users_delete_notifications_by_type( $bp->loggedin_user->id, $bp->groups->id, 'member_promoted_to_admin' );95 bp_members_delete_notifications_by_type( $bp->loggedin_user->id, $bp->groups->id, 'membership_request_accepted' ); 96 bp_members_delete_notifications_by_type( $bp->loggedin_user->id, $bp->groups->id, 'membership_request_rejected' ); 97 bp_members_delete_notifications_by_type( $bp->loggedin_user->id, $bp->groups->id, 'member_promoted_to_mod' ); 98 bp_members_delete_notifications_by_type( $bp->loggedin_user->id, $bp->groups->id, 'member_promoted_to_admin' ); 86 99 } 87 100 … … 410 423 bp_core_load_template( apply_filters( 'groups_template_group_home', 'groups/single/home' ) ); 411 424 } 412 add_action( ' wp', 'groups_screen_group_activity_permalink', 3);425 add_action( 'bp_screens', 'groups_screen_group_activity_permalink' ); 413 426 414 427 function groups_screen_group_admin() { … … 454 467 } 455 468 } 456 add_action( ' wp', 'groups_screen_group_admin_edit_details', 4);469 add_action( 'bp_screens', 'groups_screen_group_admin_edit_details' ); 457 470 458 471 function groups_screen_group_admin_settings() { … … 490 503 } 491 504 } 492 add_action( ' wp', 'groups_screen_group_admin_settings', 4);505 add_action( 'bp_screens', 'groups_screen_group_admin_settings' ); 493 506 494 507 function groups_screen_group_admin_avatar() { … … 548 561 } 549 562 } 550 add_action( ' wp', 'groups_screen_group_admin_avatar', 4);563 add_action( 'bp_screens', 'groups_screen_group_admin_avatar' ); 551 564 552 565 function groups_screen_group_admin_manage_members() { … … 658 671 } 659 672 } 660 add_action( ' wp', 'groups_screen_group_admin_manage_members', 4);673 add_action( 'bp_screens', 'groups_screen_group_admin_manage_members' ); 661 674 662 675 function groups_screen_group_admin_requests() { … … 673 686 674 687 // Remove any screen notifications 675 bp_ users_delete_notifications_by_type( $bp->loggedin_user->id, $bp->groups->id, 'new_membership_request' );688 bp_members_delete_notifications_by_type( $bp->loggedin_user->id, $bp->groups->id, 'new_membership_request' ); 676 689 677 690 $request_action = $bp->action_variables[1]; … … 716 729 } 717 730 } 718 add_action( ' wp', 'groups_screen_group_admin_requests', 4);731 add_action( 'bp_screens', 'groups_screen_group_admin_requests' ); 719 732 720 733 function groups_screen_group_admin_delete_group() { … … 752 765 } 753 766 } 754 add_action( ' wp', 'groups_screen_group_admin_delete_group', 4);767 add_action( 'bp_screens', 'groups_screen_group_admin_delete_group' ); 755 768 756 769 function groups_screen_notification_settings() { -
trunk/bp-loader.php
r3789 r3917 9 9 * Network: true 10 10 */ 11 12 11 /** Constants *****************************************************************/ 13 12 … … 44 43 /** Loader ********************************************************************/ 45 44 46 // Register BuddyPress themes contained within the bp-themes folder 47 register_theme_directory( WP_PLUGIN_DIR . '/buddypress/bp-themes' ); 48 49 // Test to see whether this is a new installation or an upgraded version of BuddyPress 50 if ( !$bp_db_version = get_site_option( 'bp-db-version' ) ) 51 $bp_db_version = get_site_option( 'bp-core-db-version' ); // BP 1.2 option name 52 53 // This is a new installation. Run the wizard before loading BP core files 54 if ( empty( $bp_db_version ) ) { 55 define( 'BP_IS_INSTALL', true ); 56 require_once( WP_PLUGIN_DIR . '/buddypress/bp-core/admin/bp-core-update.php' ); 57 58 // Existing successful installation 59 } else { 60 61 /*** 62 * This file will load in each BuddyPress component based on which 63 * of the components have been activated on the "BuddyPress" admin menu. 64 */ 65 require_once( WP_PLUGIN_DIR . '/buddypress/bp-core/bp-core-loader.php' ); 66 $bp_deactivated = apply_filters( 'bp_deactivated_components', get_site_option( 'bp-deactivated-components' ) ); 67 68 /** 69 * At this point in the stack, BuddyPress core has been loaded but 70 * individual components (friends/activity/groups/etc...) have not. 71 * 72 * The 'bp_core_loaded' action lets you execute code ahead of the 73 * other components. 74 */ 75 do_action( 'bp_core_loaded' ); 76 77 // Activity Streams 78 if ( !isset( $bp_deactivated['bp-activity/bp-activity-loader.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-activity/bp-activity-loader.php') ) 79 include( BP_PLUGIN_DIR . '/bp-activity/bp-activity-loader.php' ); 80 81 // Blog Tracking 82 if ( !isset( $bp_deactivated['bp-blogs/bp-blogs-loader.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-blogs/bp-blogs-loader.php') ) 83 include( BP_PLUGIN_DIR . '/bp-blogs/bp-blogs-loader.php' ); 84 85 // bbPress Forum Integration 86 if ( !isset( $bp_deactivated['bp-forums/bp-forums-loader.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-forums/bp-forums-loader.php') ) 87 include( BP_PLUGIN_DIR . '/bp-forums/bp-forums-loader.php' ); 88 89 // Friend Connections 90 if ( !isset( $bp_deactivated['bp-friends/bp-friends-loader.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-friends/bp-friends-loader.php') ) 91 include( BP_PLUGIN_DIR . '/bp-friends/bp-friends-loader.php' ); 92 93 // Groups Support 94 if ( !isset( $bp_deactivated['bp-groups/bp-groups-loader.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-groups/bp-groups-loader.php') ) 95 include( BP_PLUGIN_DIR . '/bp-groups/bp-groups-loader.php' ); 96 97 // Private Messaging 98 if ( !isset( $bp_deactivated['bp-messages/bp-messages-loader.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-messages/bp-messages-loader.php') ) 99 include( BP_PLUGIN_DIR . '/bp-messages/bp-messages-loader.php' ); 100 101 // Extended Profiles 102 if ( !isset( $bp_deactivated['bp-xprofile/bp-xprofile-loader.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-xprofile/bp-xprofile-loader.php') ) 103 include( BP_PLUGIN_DIR . '/bp-xprofile/bp-xprofile-loader.php' ); 104 105 // Users 106 include( BP_PLUGIN_DIR . '/bp-users/bp-users-loader.php' ); 107 108 // Settings 109 include( BP_PLUGIN_DIR . '/bp-settings/bp-settings-loader.php' ); 110 111 // If this is an upgrade, load the upgrade file 112 if ( $bp_db_version < constant( 'BP_DB_VERSION' ) ) { 113 define( 'BP_IS_UPGRADE', true ); 114 require_once( WP_PLUGIN_DIR . '/buddypress/bp-core/admin/bp-core-update.php' ); 115 } 116 } 117 118 /******************************************************************************** 119 * Functions to set up custom BuddyPress actions that components should 120 * hook in to. 121 */ 122 123 /** 124 * Include files on this action 125 */ 126 function bp_include() { 127 do_action( 'bp_include' ); 128 } 129 130 /** 131 * Setup BuddyPress root directory components 132 */ 133 function bp_setup_root_components() { 134 do_action( 'bp_setup_root_components' ); 135 } 136 137 /** 138 * Setup global variables and objects 139 */ 140 function bp_setup_globals() { 141 do_action( 'bp_setup_globals' ); 142 } 143 144 /** 145 * Set navigation elements 146 */ 147 function bp_setup_nav() { 148 do_action( 'bp_setup_nav' ); 149 } 150 151 /** 152 * Register widgets 153 */ 154 function bp_setup_widgets() { 155 do_action( 'bp_register_widgets' ); 156 } 157 158 /** 159 * Initlialize code 160 */ 161 function bp_init() { 162 do_action( 'bp_init' ); 163 } 164 165 /** 166 * Attached to plugins_loaded 167 */ 168 function bp_loaded() { 169 do_action( 'bp_loaded' ); 170 } 171 172 /** 173 * Attach potential template screens 174 */ 175 function bp_screens() { 176 do_action( 'bp_screens' ); 177 } 45 require_once( BP_PLUGIN_DIR . '/bp-core/bp-core-bootstrap.php' ); 178 46 179 47 /** -
trunk/bp-members/bp-members-actions.php
r3916 r3917 26 26 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() 27 27 */ 28 function bp_ users_action_set_spammer_status() {28 function bp_members_action_set_spammer_status() { 29 29 global $bp, $wpdb, $wp_version; 30 30 … … 80 80 do_action( 'bp_make_spam_user', $bp->displayed_user->id ); 81 81 82 do_action( 'bp_ users_action_set_spammer_status', $bp->displayed_user->id, $is_spam );82 do_action( 'bp_members_action_set_spammer_status', $bp->displayed_user->id, $is_spam ); 83 83 84 84 bp_core_redirect( wp_get_referer() ); 85 85 } 86 86 } 87 add_action( ' wp', 'bp_users_action_set_spammer_status', 3);87 add_action( 'bp_actions', 'bp_members_action_set_spammer_status' ); 88 88 89 89 /** … … 93 93 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() 94 94 */ 95 function bp_ users_action_delete_user() {95 function bp_members_action_delete_user() { 96 96 global $bp; 97 97 … … 112 112 } 113 113 114 do_action( 'bp_ users_action_delete_user', $errors );114 do_action( 'bp_members_action_delete_user', $errors ); 115 115 116 116 if ( $errors ) … … 120 120 } 121 121 } 122 add_action( 'wp', 'bp_users_action_delete_user', 3 ); 122 add_action( 'bp_actions', 'bp_members_action_delete_user' ); 123 124 /** 125 * Returns the user_id for a user based on their username. 126 * 127 * @package BuddyPress Core 128 * @param $username str Username to check. 129 * @return false on no match 130 * @return int the user ID of the matched user. 131 */ 132 function bp_core_get_random_member() { 133 global $bp; 134 135 if ( isset( $_GET['random-member'] ) ) { 136 $user = bp_core_get_users( array( 'type' => 'random', 'per_page' => 1 ) ); 137 bp_core_redirect( bp_core_get_user_domain( $user['users'][0]->id ) ); 138 } 139 } 140 add_action( 'bp_actions', 'bp_core_get_random_member' ); 123 141 124 142 ?> -
trunk/bp-members/bp-members-functions.php
r3916 r3917 130 130 * @package BuddyPress Core 131 131 * @param $username str Username to check. 132 * @return false on no match133 * @return int the user ID of the matched user.134 */135 function bp_core_get_random_member() {136 global $bp;137 138 if ( isset( $_GET['random-member'] ) ) {139 $user = bp_core_get_users( array( 'type' => 'random', 'per_page' => 1 ) );140 bp_core_redirect( bp_core_get_user_domain( $user['users'][0]->id ) );141 }142 }143 add_action( 'wp', 'bp_core_get_random_member' );144 145 /**146 * Returns the user_id for a user based on their username.147 *148 * @package BuddyPress Core149 * @param $username str Username to check.150 132 * @global $wpdb WordPress DB access object. 151 133 * @return false on no match … … 242 224 // Check $username for empty spaces and default to nicename if found 243 225 if ( strstr( $username, ' ' ) ) 244 $username = bp_ users_get_user_nicename( $user_id );226 $username = bp_members_get_user_nicename( $user_id ); 245 227 246 228 // Add this to cache … … 265 247 * @return str the username of the matched user. 266 248 */ 267 function bp_ users_get_user_nicename( $user_id ) {249 function bp_members_get_user_nicename( $user_id ) { 268 250 global $bp; 269 251 270 if ( !$user_nicename = wp_cache_get( 'bp_ users_user_nicename_' . $user_id, 'bp' ) ) {252 if ( !$user_nicename = wp_cache_get( 'bp_members_user_nicename_' . $user_id, 'bp' ) ) { 271 253 $update_cache = true; 272 254 … … 303 285 // Add this to cache 304 286 if ( true == $update_cache && !empty( $user_nicename ) ) 305 wp_cache_set( 'bp_ users_user_nicename_' . $user_id, $user_nicename, 'bp' );306 307 return apply_filters( 'bp_ users_get_user_nicename', $user_nicename );287 wp_cache_set( 'bp_members_user_nicename_' . $user_id, $user_nicename, 'bp' ); 288 289 return apply_filters( 'bp_members_get_user_nicename', $user_nicename ); 308 290 } 309 291 … … 399 381 400 382 if ( !$fullname = wp_cache_get( 'bp_user_fullname_' . $user_id, 'bp' ) ) { 401 if ( bp_is_active( ' profile' ) ) {383 if ( bp_is_active( 'xprofile' ) ) { 402 384 $fullname = xprofile_get_field_data( stripslashes( $bp->site_options['bp-xprofile-fullname-field-name'] ), $user_id ); 403 385 … … 640 622 add_action( 'bp_make_spam_user', 'bp_core_remove_data' ); 641 623 642 function bp_ users_can_edit_settings() {624 function bp_members_can_edit_settings() { 643 625 if ( bp_is_my_profile() ) 644 626 return true; -
trunk/bp-members/bp-members-loader.php
r3916 r3917 2 2 3 3 /** 4 * BuddyPress User Loader4 * BuddyPress Member Loader 5 5 * 6 * A users component to help contain all of the user specific slugs6 * A members component to help contain all of the user specific slugs 7 7 * 8 8 * @package BuddyPress … … 10 10 */ 11 11 12 class BP_ User_Component extends BP_Component {13 14 /** 15 * Start the users component creation process12 class BP_Members_Component extends BP_Component { 13 14 /** 15 * Start the members component creation process 16 16 * 17 17 * @since BuddyPress {unknown} 18 18 */ 19 function BP_User_Component() { 20 parent::start( 'members', __( 'Members', 'buddypress' ) ); 19 function BP_Members_Component() { 20 parent::start( 21 'members', 22 __( 'Members', 'buddypress' ), 23 BP_PLUGIN_DIR 24 ); 25 } 26 27 /** 28 * Include files 29 * 30 * @global obj $bp 31 */ 32 function _includes() { 33 $includes = array( 34 'signup', 35 'actions', 36 'filters', 37 'screens', 38 'template', 39 'functions', 40 'notifications', 41 ); 42 parent::_includes( $includes ); 21 43 } 22 44 … … 38 60 39 61 // Do some slug checks 40 $this->slug = BP_MEMBERS_SLUG; 41 $this->root_slug = isset( $bp->pages->members->slug ) ? $bp->pages->members->slug : $this->slug; 42 43 // Tables 44 $this->table_name = $bp->table_prefix . 'bp_users'; 45 $this->table_name_meta = $bp->table_prefix . 'bp_users_meta'; 46 47 // The default text for the members directory search box 48 $this->default_search_string = __( 'Search Members...', 'buddypress' ); 62 $global_tables = array( 63 'table_name' => $bp->table_prefix . 'bp_users', 64 'table_name_meta' => $bp->table_prefix . 'bp_members_meta', 65 ); 66 67 $globals = array( 68 'slug' => BP_MEMBERS_SLUG, 69 'root_slug' => isset( $bp->pages->members->slug ) ? $bp->pages->members->slug : BP_MEMBERS_SLUG, 70 'search_string' => __( 'Search Members...', 'buddypress' ), 71 'global_tables' => $global_tables 72 ); 73 74 parent::_setup_globals( $globals ); 49 75 50 76 /** Logged in user ****************************************************/ 51 52 // Logged in user is the 'current_user'53 $current_user = wp_get_current_user();54 55 // The user ID of the user who is currently logged in.56 $bp->loggedin_user->id = $current_user->ID;57 58 // The domain for the user currently logged in. eg: http://domain.com/members/andy59 $bp->loggedin_user->domain = bp_core_get_user_domain( $bp->loggedin_user->id );60 61 // The core userdata of the user who is currently logged in.62 $bp->loggedin_user->userdata = bp_core_get_core_userdata( $bp->loggedin_user->id );63 77 64 78 // Fetch the full name for the logged in user … … 68 82 $bp->loggedin_user->is_super_admin = is_super_admin(); 69 83 $bp->loggedin_user->is_site_admin = $bp->loggedin_user->is_super_admin; // deprecated 1.2.6 84 85 // The domain for the user currently logged in. eg: http://domain.com/members/andy 86 $bp->loggedin_user->domain = bp_core_get_user_domain( $bp->loggedin_user->id ); 87 88 // The core userdata of the user who is currently logged in. 89 $bp->loggedin_user->userdata = bp_core_get_core_userdata( $bp->loggedin_user->id ); 70 90 71 91 /** … … 99 119 $bp->displayed_user->fullname = bp_core_get_user_displayname( $bp->displayed_user->id ); 100 120 101 /** Active Component **************************************************/102 103 // Users is active104 $bp->active_components[$this->id] = $this->id;105 106 121 /** Default Profile Component *****************************************/ 107 122 if ( !$bp->current_component && $bp->displayed_user->id ) … … 111 126 112 127 /** 113 * Include files114 *115 * @global obj $bp116 */117 function _includes() {118 require_once( BP_PLUGIN_DIR . '/bp-users/bp-users-signup.php' );119 require_once( BP_PLUGIN_DIR . '/bp-users/bp-users-actions.php' );120 require_once( BP_PLUGIN_DIR . '/bp-users/bp-users-filters.php' );121 require_once( BP_PLUGIN_DIR . '/bp-users/bp-users-screens.php' );122 require_once( BP_PLUGIN_DIR . '/bp-users/bp-users-template.php' );123 require_once( BP_PLUGIN_DIR . '/bp-users/bp-users-functions.php' );124 require_once( BP_PLUGIN_DIR . '/bp-users/bp-users-notifications.php' );125 }126 127 /**128 128 * Setup BuddyBar navigation 129 129 * … … 136 136 137 137 // Add 'User' to the main navigation 138 bp_core_new_nav_item(array(138 $main_nav = array( 139 139 'name' => __( 'User', 'buddypress' ), 140 140 'slug' => $this->slug, 141 141 'position' => 10, 142 'screen_function' => 'bp_ users_screen_my_users',142 'screen_function' => 'bp_members_screen_my_users', 143 143 'default_subnav_slug' => 'just-me', 144 144 'item_css_id' => $this->id 145 ) );145 ); 146 146 147 147 // Stop if there is no user displayed or logged in … … 155 155 156 156 // Add the subnav items to the users nav item if we are using a theme that supports this 157 bp_core_new_subnav_item(array(157 $sub_nav[] = array( 158 158 'name' => __( 'Personal', 'buddypress' ), 159 159 'slug' => 'just-me', 160 160 'parent_url' => $users_link, 161 161 'parent_slug' => $this->slug, 162 'screen_function' => 'bp_ users_screen_my_users',162 'screen_function' => 'bp_members_screen_my_users', 163 163 'position' => 10 164 ) );164 ); 165 165 166 166 // Additional menu if friends is active 167 167 if ( bp_is_active( 'friends' ) ) { 168 bp_core_new_subnav_item(array(168 $sub_nav[] = array( 169 169 'name' => __( 'Friends', 'buddypress' ), 170 170 'slug' => BP_FRIENDS_SLUG, 171 171 'parent_url' => $users_link, 172 172 'parent_slug' => $this->slug, 173 'screen_function' => 'bp_ users_screen_friends',173 'screen_function' => 'bp_members_screen_friends', 174 174 'position' => 20, 175 175 'item_css_id' => 'users-friends' 176 ) );176 ); 177 177 } 178 178 179 179 // Additional menu if groups is active 180 180 if ( bp_is_active( 'groups' ) ) { 181 bp_core_new_subnav_item(array(181 $sub_nav[] = array( 182 182 'name' => __( 'Groups', 'buddypress' ), 183 183 'slug' => BP_GROUPS_SLUG, 184 184 'parent_url' => $users_link, 185 185 'parent_slug' => $this->slug, 186 'screen_function' => 'bp_ users_screen_groups',186 'screen_function' => 'bp_members_screen_groups', 187 187 'position' => 30, 188 188 'item_css_id' => 'users-groups' 189 ) );189 ); 190 190 } 191 191 192 192 // Favorite users items 193 bp_core_new_subnav_item(array(193 $sub_nav[] = array( 194 194 'name' => __( 'Favorites', 'buddypress' ), 195 195 'slug' => 'favorites', 196 196 'parent_url' => $users_link, 197 197 'parent_slug' => $this->slug, 198 'screen_function' => 'bp_ users_screen_favorites',198 'screen_function' => 'bp_members_screen_favorites', 199 199 'position' => 40, 200 200 'item_css_id' => 'users-favs' 201 ) );201 ); 202 202 203 203 // @ mentions 204 bp_core_new_subnav_item(array(204 $sub_nav[] = array( 205 205 'name' => sprintf( __( '@%s Mentions', 'buddypress' ), $user_login ), 206 206 'slug' => 'mentions', 207 207 'parent_url' => $users_link, 208 208 'parent_slug' => $this->slug, 209 'screen_function' => 'bp_ users_screen_mentions',209 'screen_function' => 'bp_members_screen_mentions', 210 210 'position' => 50, 211 211 'item_css_id' => 'users-mentions' 212 ) );212 ); 213 213 214 214 // Adjust title based on view 215 215 if ( bp_is_users_component() ) { 216 216 if ( bp_is_my_profile() ) { 217 $bp->bp_options_title = __( ' My User', 'buddypress' );217 $bp->bp_options_title = __( 'You', 'buddypress' ); 218 218 } else { 219 219 $bp->bp_options_avatar = bp_core_fetch_avatar( array( … … 224 224 } 225 225 } 226 227 parent::_setup_nav( $main_nav, $sub_nav ); 226 228 } 227 229 } 228 230 // Create the users component 229 $bp->members = new BP_ User_Component();231 $bp->members = new BP_Members_Component(); 230 232 231 233 ?> -
trunk/bp-members/bp-members-notifications.php
r3916 r3917 1 1 <?php 2 2 3 function bp_ users_add_notification( $item_id, $user_id, $component_name, $component_action, $secondary_item_id = 0, $date_notified = false ) {3 function bp_members_add_notification( $item_id, $user_id, $component_name, $component_action, $secondary_item_id = 0, $date_notified = false ) { 4 4 global $bp; 5 5 … … 24 24 } 25 25 26 function bp_ users_delete_notification( $id ) {27 if ( !bp_ users_check_notification_access( $bp->loggedin_user->id, $id ) )26 function bp_members_delete_notification( $id ) { 27 if ( !bp_members_check_notification_access( $bp->loggedin_user->id, $id ) ) 28 28 return false; 29 29 … … 31 31 } 32 32 33 function bp_ users_get_notification( $id ) {33 function bp_members_get_notification( $id ) { 34 34 return new BP_Core_Notification( $id ); 35 35 } 36 36 37 function bp_ users_get_notifications_for_user( $user_id ) {37 function bp_members_get_notifications_for_user( $user_id ) { 38 38 global $bp; 39 39 … … 72 72 } 73 73 74 function bp_ users_delete_notifications_by_type( $user_id, $component_name, $component_action ) {74 function bp_members_delete_notifications_by_type( $user_id, $component_name, $component_action ) { 75 75 return BP_Core_Notification::delete_for_user_by_type( $user_id, $component_name, $component_action ); 76 76 } 77 77 78 function bp_ users_delete_notifications_for_user_by_item_id( $user_id, $item_id, $component_name, $component_action, $secondary_item_id = false ) {78 function bp_members_delete_notifications_for_user_by_item_id( $user_id, $item_id, $component_name, $component_action, $secondary_item_id = false ) { 79 79 return BP_Core_Notification::delete_for_user_by_item_id( $user_id, $item_id, $component_name, $component_action, $secondary_item_id ); 80 80 } 81 81 82 function bp_ users_delete_all_notifications_by_type( $item_id, $component_name, $component_action = false, $secondary_item_id = false ) {82 function bp_members_delete_all_notifications_by_type( $item_id, $component_name, $component_action = false, $secondary_item_id = false ) { 83 83 return BP_Core_Notification::delete_all_by_type( $item_id, $component_name, $component_action, $secondary_item_id ); 84 84 } 85 85 86 function bp_ users_delete_notifications_from_user( $user_id, $component_name, $component_action ) {86 function bp_members_delete_notifications_from_user( $user_id, $component_name, $component_action ) { 87 87 return BP_Core_Notification::delete_from_user_by_type( $user_id, $component_name, $component_action ); 88 88 } 89 89 90 function bp_ users_check_notification_access( $user_id, $notification_id ) {90 function bp_members_check_notification_access( $user_id, $notification_id ) { 91 91 if ( !BP_Core_Notification::check_access( $user_id, $notification_id ) ) 92 92 return false; -
trunk/bp-members/bp-members-screens.php
r3916 r3917 1 1 <?php 2 2 3 function bp_ users_screen_index() {3 function bp_members_screen_index() { 4 4 global $bp; 5 5 … … 7 7 $bp->is_directory = true; 8 8 9 do_action( 'bp_ users_screen_index' );9 do_action( 'bp_members_screen_index' ); 10 10 11 bp_core_load_template( apply_filters( 'bp_ users_screen_index', 'members/index' ) );11 bp_core_load_template( apply_filters( 'bp_members_screen_index', 'members/index' ) ); 12 12 } 13 13 } 14 add_action( ' wp', 'bp_users_screen_index', 2);14 add_action( 'bp_screens', 'bp_members_screen_index' ); 15 15 16 16 -
trunk/bp-members/bp-members-signup.php
r3916 r3917 2 2 3 3 4 function bp_ users_screen_signup() {4 function bp_members_screen_signup() { 5 5 global $bp, $wpdb; 6 6 … … 30 30 31 31 // Check the base account details for problems 32 $account_details = bp_ users_validate_user_signup( $_POST['signup_username'], $_POST['signup_email'] );32 $account_details = bp_members_validate_user_signup( $_POST['signup_username'], $_POST['signup_email'] ); 33 33 34 34 // If there are errors with account details, set them for display … … 82 82 83 83 if ( 'blog' == $active_signup || 'all' == $active_signup ) { 84 $blog_details = bp_ users_validate_blog_signup( $_POST['signup_blog_url'], $_POST['signup_blog_title'] );84 $blog_details = bp_members_validate_blog_signup( $_POST['signup_blog_url'], $_POST['signup_blog_title'] ); 85 85 86 86 // If there are errors with blog details, set them for display … … 98 98 if ( !empty( $bp->signup->errors ) ) { 99 99 foreach ( (array)$bp->signup->errors as $fieldname => $error_message ) 100 add_action( 'bp_' . $fieldname . '_errors', create_function( '', 'echo apply_filters(\'bp_ users_signup_error_message\', "<div class=\"error\">' . $error_message . '</div>" );' ) );100 add_action( 'bp_' . $fieldname . '_errors', create_function( '', 'echo apply_filters(\'bp_members_signup_error_message\', "<div class=\"error\">' . $error_message . '</div>" );' ) ); 101 101 } else { 102 102 $bp->signup->step = 'save-details'; … … 135 135 // Finally, sign up the user and/or blog 136 136 if ( isset( $_POST['signup_with_blog'] ) && is_multisite() ) 137 bp_ users_signup_blog( $blog_details['domain'], $blog_details['path'], $blog_details['blog_title'], $_POST['signup_username'], $_POST['signup_email'], $usermeta );137 bp_members_signup_blog( $blog_details['domain'], $blog_details['path'], $blog_details['blog_title'], $_POST['signup_username'], $_POST['signup_email'], $usermeta ); 138 138 else 139 bp_ users_signup_user( $_POST['signup_username'], $_POST['signup_password'], $_POST['signup_email'], $usermeta );139 bp_members_signup_user( $_POST['signup_username'], $_POST['signup_password'], $_POST['signup_email'], $usermeta ); 140 140 141 141 $bp->signup->step = 'completed-confirmation'; … … 148 148 149 149 do_action( 'bp_core_screen_signup' ); 150 bp_core_load_template( apply_filters( 'bp_ users_template_register', 'registration/register' ) );151 } 152 add_action( ' wp', 'bp_users_screen_signup', 3);153 154 function bp_ users_screen_activation() {150 bp_core_load_template( apply_filters( 'bp_members_template_register', 'registration/register' ) ); 151 } 152 add_action( 'bp_screens', 'bp_members_screen_signup' ); 153 154 function bp_members_screen_activation() { 155 155 global $bp, $wpdb; 156 156 … … 162 162 163 163 // Activate the signup 164 $user = apply_filters( 'bp_ users_activate_account', bp_users_activate_signup( $_GET['key'] ) );164 $user = apply_filters( 'bp_members_activate_account', bp_members_activate_signup( $_GET['key'] ) ); 165 165 166 166 // If there were errors, add a message and redirect … … 191 191 bp_core_load_template( apply_filters( 'bp_core_template_activate', 'registration/activate' ) ); 192 192 } 193 add_action( ' wp', 'bp_users_screen_activation', 3);193 add_action( 'bp_screens', 'bp_members_screen_activation' ); 194 194 195 195 … … 206 206 * Flush illegal names by getting and setting 'illegal_names' site option 207 207 */ 208 function bp_ users_flush_illegal_names() {208 function bp_members_flush_illegal_names() { 209 209 $illegal_names = get_site_option( 'illegal_names' ); 210 210 update_site_option( 'illegal_names', $illegal_names ); … … 219 219 * @return array Merged and unique array of illegal names 220 220 */ 221 function bp_ users_illegal_names( $value = '', $oldvalue = '' ) {221 function bp_members_illegal_names( $value = '', $oldvalue = '' ) { 222 222 223 223 // Make sure $value is array … … 263 263 264 264 // Add our slugs to the array and allow them to be filtered 265 $filtered_illegal_names = apply_filters( 'bp_ users_illegal_usernames', array_merge( array( 'www', 'web', 'root', 'admin', 'main', 'invite', 'administrator' ), $bp_component_slugs ) );265 $filtered_illegal_names = apply_filters( 'bp_members_illegal_usernames', array_merge( array( 'www', 'web', 'root', 'admin', 'main', 'invite', 'administrator' ), $bp_component_slugs ) ); 266 266 267 267 // Merge the arrays together … … 271 271 $illegal_names = array_unique( (array)$merged_names ); 272 272 273 return apply_filters( 'bp_ users_illegal_names', $illegal_names );274 } 275 add_filter( 'pre_update_site_option_illegal_names', 'bp_ users_illegal_names', 10, 2 );273 return apply_filters( 'bp_members_illegal_names', $illegal_names ); 274 } 275 add_filter( 'pre_update_site_option_illegal_names', 'bp_members_illegal_names', 10, 2 ); 276 276 277 277 /** … … 283 283 * @return array Results of user validation including errors, if any 284 284 */ 285 function bp_ users_validate_user_signup( $user_name, $user_email ) {285 function bp_members_validate_user_signup( $user_name, $user_email ) { 286 286 global $wpdb; 287 287 … … 299 299 300 300 // Make sure illegal names include BuddyPress slugs and values 301 bp_ users_flush_illegal_names();301 bp_members_flush_illegal_names(); 302 302 303 303 $illegal_names = get_site_option( 'illegal_names' ); … … 347 347 $result = apply_filters( 'wpmu_validate_user_signup', $result ); 348 348 349 return apply_filters( 'bp_ users_validate_user_signup', $result );350 } 351 352 function bp_ users_validate_blog_signup( $blog_url, $blog_title ) {349 return apply_filters( 'bp_members_validate_user_signup', $result ); 350 } 351 352 function bp_members_validate_blog_signup( $blog_url, $blog_title ) { 353 353 if ( !is_multisite() || !function_exists( 'wpmu_validate_blog_signup' ) ) 354 354 return false; 355 355 356 return apply_filters( 'bp_ users_validate_blog_signup', wpmu_validate_blog_signup( $blog_url, $blog_title ) );357 } 358 359 function bp_ users_signup_user( $user_login, $user_password, $user_email, $usermeta ) {356 return apply_filters( 'bp_members_validate_blog_signup', wpmu_validate_blog_signup( $blog_url, $blog_title ) ); 357 } 358 359 function bp_members_signup_user( $user_login, $user_password, $user_email, $usermeta ) { 360 360 global $bp, $wpdb; 361 361 … … 406 406 * and validate their email address. Multisite installs send their own email, so this is only for single blog installs. 407 407 * 408 * To disable sending activation emails you can user the filter 'bp_ users_signup_send_activation_key' and return false.408 * To disable sending activation emails you can user the filter 'bp_members_signup_send_activation_key' and return false. 409 409 */ 410 if ( apply_filters( 'bp_ users_signup_send_activation_key', true ) ) {410 if ( apply_filters( 'bp_members_signup_send_activation_key', true ) ) { 411 411 if ( !is_multisite() ) { 412 412 $activation_key = wp_hash( $user_id ); 413 413 update_user_meta( $user_id, 'activation_key', $activation_key ); 414 bp_ users_signup_send_validation_email( $user_id, $user_email, $activation_key );414 bp_members_signup_send_validation_email( $user_id, $user_email, $activation_key ); 415 415 } 416 416 } 417 417 418 do_action( 'bp_ users_signup_user', $user_id, $user_login, $user_password, $user_email, $usermeta );418 do_action( 'bp_members_signup_user', $user_id, $user_login, $user_password, $user_email, $usermeta ); 419 419 420 420 return $user_id; 421 421 } 422 422 423 function bp_ users_signup_blog( $blog_domain, $blog_path, $blog_title, $user_name, $user_email, $usermeta ) {423 function bp_members_signup_blog( $blog_domain, $blog_path, $blog_title, $user_name, $user_email, $usermeta ) { 424 424 if ( !is_multisite() || !function_exists( 'wpmu_signup_blog' ) ) 425 425 return false; 426 426 427 return apply_filters( 'bp_ users_signup_blog', wpmu_signup_blog( $blog_domain, $blog_path, $blog_title, $user_name, $user_email, $usermeta ) );428 } 429 430 function bp_ users_activate_signup( $key ) {427 return apply_filters( 'bp_members_signup_blog', wpmu_signup_blog( $blog_domain, $blog_path, $blog_title, $user_name, $user_email, $usermeta ) ); 428 } 429 430 function bp_members_activate_signup( $key ) { 431 431 global $bp, $wpdb; 432 432 … … 481 481 require_once( ABSPATH . WPINC . '/registration.php' ); 482 482 483 wp_update_user( array( 'ID' => $user_id, 'user_url' => bp_ users_get_user_domain( $user_id ), 'display_name' => bp_core_get_user_displayname( $user_id ) ) );483 wp_update_user( array( 'ID' => $user_id, 'user_url' => bp_members_get_user_domain( $user_id ), 'display_name' => bp_core_get_user_displayname( $user_id ) ) ); 484 484 485 485 // Set the password on multisite installs … … 490 490 wp_cache_delete( 'bp_total_member_count', 'bp' ); 491 491 492 do_action( 'bp_ users_activated_user', $user_id, $key, $user );492 do_action( 'bp_members_activated_user', $user_id, $key, $user ); 493 493 494 494 return $user_id; 495 495 } 496 496 497 function bp_ users_new_user_activity( $user ) {497 function bp_members_new_user_activity( $user ) { 498 498 if ( empty( $user ) || !function_exists( 'bp_activity_add' ) ) 499 499 return false; … … 507 507 return false; 508 508 509 $userlink = bp_ users_get_userlink( $user_id );509 $userlink = bp_members_get_userlink( $user_id ); 510 510 511 511 bp_activity_add( array( 512 'user_id' => $user_id,513 'action' => apply_filters( 'bp_users_activity_registered_member_action', sprintf( __( '%s became a registered member', 'buddypress' ), $userlink ), $user_id ),514 'component' => ' profile',515 'type' => 'new_member'512 'user_id' => $user_id, 513 'action' => apply_filters( 'bp_members_activity_registered_member_action', sprintf( __( '%s became a registered member', 'buddypress' ), $userlink ), $user_id ), 514 'component' => 'xprofile', 515 'type' => 'new_member' 516 516 ) ); 517 517 } 518 add_action( 'bp_ users_activated_user', 'bp_users_new_user_activity' );519 520 function bp_ users_map_user_registration( $user_id ) {518 add_action( 'bp_members_activated_user', 'bp_members_new_user_activity' ); 519 520 function bp_members_map_user_registration( $user_id ) { 521 521 // Only map data when the site admin is adding users, not on registration. 522 522 if ( !is_admin() ) … … 535 535 } 536 536 } 537 add_action( 'user_register', 'bp_ users_map_user_registration' );538 539 function bp_ users_signup_avatar_upload_dir() {537 add_action( 'user_register', 'bp_members_map_user_registration' ); 538 539 function bp_members_signup_avatar_upload_dir() { 540 540 global $bp; 541 541 … … 553 553 $newsubdir = '/avatars/signups/' . $bp->signup->avatar_dir; 554 554 555 return apply_filters( 'bp_ users_signup_avatar_upload_dir', array( 'path' => $path, 'url' => $newurl, 'subdir' => $newsubdir, 'basedir' => $newbdir, 'baseurl' => $newburl, 'error' => false ) );556 } 557 558 function bp_ users_signup_send_validation_email( $user_id, $user_email, $key ) {555 return apply_filters( 'bp_members_signup_avatar_upload_dir', array( 'path' => $path, 'url' => $newurl, 'subdir' => $newsubdir, 'basedir' => $newbdir, 'baseurl' => $newburl, 'error' => false ) ); 556 } 557 558 function bp_members_signup_send_validation_email( $user_id, $user_email, $key ) { 559 559 $activate_url = bp_get_activation_page() ."?key=$key"; 560 560 $activate_url = esc_url( $activate_url ); … … 566 566 567 567 // Send the message 568 $to = apply_filters( 'bp_ users_signup_send_validation_email_to', $user_email, $user_id );569 $subject = apply_filters( 'bp_ users_signup_send_validation_email_subject', $subject, $user_id );570 $message = apply_filters( 'bp_ users_signup_send_validation_email_message', $message, $user_id, $activate_url );568 $to = apply_filters( 'bp_members_signup_send_validation_email_to', $user_email, $user_id ); 569 $subject = apply_filters( 'bp_members_signup_send_validation_email_subject', $subject, $user_id ); 570 $message = apply_filters( 'bp_members_signup_send_validation_email_message', $message, $user_id, $activate_url ); 571 571 572 572 wp_mail( $to, $subject, $message ); 573 573 574 do_action( 'bp_ users_sent_user_validation_email', $subject, $message, $user_id, $user_email, $key );574 do_action( 'bp_members_sent_user_validation_email', $subject, $message, $user_id, $user_email, $key ); 575 575 } 576 576 577 577 // Stop user accounts logging in that have not been activated (user_status = 2) 578 function bp_ users_signup_disable_inactive( $auth_obj, $username ) {578 function bp_members_signup_disable_inactive( $auth_obj, $username ) { 579 579 global $bp, $wpdb; 580 580 … … 589 589 return $auth_obj; 590 590 } 591 add_filter( 'authenticate', 'bp_ users_signup_disable_inactive', 30, 2 );592 593 / * Kill the wp-signup.php if custom registration signup templates are present */594 function bp_ users_wpsignup_redirect() {591 add_filter( 'authenticate', 'bp_members_signup_disable_inactive', 30, 2 ); 592 593 // Kill the wp-signup.php if custom registration signup templates are present 594 function bp_members_wpsignup_redirect() { 595 595 $action = ''; 596 596 if ( isset( $_GET['action'] ) ) … … 604 604 } 605 605 if ( is_multisite() ) 606 add_action( ' wp', 'bp_users_wpsignup_redirect' );606 add_action( 'bp_screens', 'bp_members_wpsignup_redirect' ); 607 607 else 608 add_action( 'bp_init', 'bp_ users_wpsignup_redirect' );608 add_action( 'bp_init', 'bp_members_wpsignup_redirect' ); 609 609 610 610 ?> -
trunk/bp-members/bp-members-template.php
r3916 r3917 409 409 global $members_template; 410 410 411 if ( !bp_is_active( ' profile' ) )411 if ( !bp_is_active( 'xprofile' ) ) 412 412 return false; 413 413 … … 927 927 * @since 1.3 928 928 */ 929 function bp_ users_activity_feed() {929 function bp_members_activity_feed() { 930 930 if ( !bp_is_active( 'activity' ) || !bp_is_user() ) 931 931 return; ?> … … 935 935 <?php 936 936 } 937 add_action( 'bp_head', 'bp_ users_activity_feed' );937 add_action( 'bp_head', 'bp_members_activity_feed' ); 938 938 939 939 ?> -
trunk/bp-messages/bp-messages-actions.php
r3757 r3917 41 41 bp_core_load_template( apply_filters( 'messages_template_view_message', 'members/single/home' ) ); 42 42 } 43 add_action( ' wp', 'messages_action_view_message', 3);43 add_action( 'bp_actions', 'messages_action_view_message' ); 44 44 45 45 function messages_action_delete_message() { … … 66 66 } 67 67 } 68 add_action( ' wp', 'messages_action_delete_message', 3);68 add_action( 'bp_actions', 'messages_action_delete_message' ); 69 69 70 70 function messages_action_bulk_delete() { … … 90 90 } 91 91 } 92 add_action( ' wp', 'messages_action_bulk_delete', 3);92 add_action( 'bp_actions', 'messages_action_bulk_delete' ); 93 93 94 94 ?> -
trunk/bp-messages/bp-messages-cssjs.php
r3777 r3917 5 5 6 6 // Include the autocomplete JS for composing a message. 7 if ( $bp->current_component == $bp->messages->slug && 'compose' == $bp->current_action) {7 if ( bp_is_messages_component() && bp_is_current_action( 'compose' ) ) { 8 8 add_action( 'wp_head', 'messages_autocomplete_init_jsblock' ); 9 9 … … 22 22 } 23 23 } 24 add_action( ' wp', 'messages_add_autocomplete_js', 2);24 add_action( 'bp_actions', 'messages_add_autocomplete_js' ); 25 25 26 26 function messages_add_autocomplete_css() { 27 27 global $bp; 28 28 29 if ( $bp->current_component == $bp->messages->slug && 'compose' == $bp->current_action) {29 if ( bp_is_messages_component() && bp_is_current_item( 'compose' ) ) { 30 30 if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) 31 31 wp_enqueue_style( 'bp-messages-autocomplete', BP_PLUGIN_URL . '/bp-messages/css/autocomplete/jquery.autocompletefb.dev.css', array(), BP_VERSION ); -
trunk/bp-messages/bp-messages-functions.php
r3903 r3917 85 85 // Send screen notifications to the recipients 86 86 foreach ( (array)$message->recipients as $recipient ) 87 bp_ users_add_notification( $message->id, $recipient->user_id, 'messages', 'new_message' );87 bp_members_add_notification( $message->id, $recipient->user_id, 'messages', 'new_message' ); 88 88 89 89 // Send email notifications to the recipients … … 193 193 } 194 194 195 /******************************************************************************* 196 * These functions handle the recording, deleting and formatting of activity and 197 * notifications for the user and for this specific component. 198 */ 199 200 function messages_format_notifications( $action, $item_id, $secondary_item_id, $total_items ) { 201 global $bp; 202 203 if ( 'new_message' == $action ) { 204 if ( (int)$total_items > 1 ) 205 return apply_filters( 'bp_messages_multiple_new_message_notification', '<a href="' . $bp->loggedin_user->domain . $bp->messages->slug . '/inbox" title="' . __( 'Inbox', 'buddypress' ) . '">' . sprintf( __('You have %d new messages', 'buddypress' ), (int)$total_items ) . '</a>', $total_items ); 206 else 207 return apply_filters( 'bp_messages_single_new_message_notification', '<a href="' . $bp->loggedin_user->domain . $bp->messages->slug . '/inbox" title="' . __( 'Inbox', 'buddypress' ) . '">' . sprintf( __('You have %d new message', 'buddypress' ), (int)$total_items ) . '</a>', $total_items ); 208 } 209 210 do_action( 'messages_format_notifications', $action, $item_id, $secondary_item_id, $total_items ); 211 212 return false; 213 } 214 195 215 ?> -
trunk/bp-messages/bp-messages-loader.php
r3757 r3917 1 1 <?php 2 2 3 / / Required Files4 require ( BP_PLUGIN_DIR . '/bp-messages/bp-messages-cssjs.php' ); 5 require ( BP_PLUGIN_DIR . '/bp-messages/bp-messages-actions.php' ); 6 require ( BP_PLUGIN_DIR . '/bp-messages/bp-messages-screens.php' ); 7 require ( BP_PLUGIN_DIR . '/bp-messages/bp-messages-classes.php' ); 8 require ( BP_PLUGIN_DIR . '/bp-messages/bp-messages-filters.php' ); 9 require ( BP_PLUGIN_DIR . '/bp-messages/bp-messages-template.php' ); 10 require ( BP_PLUGIN_DIR . '/bp-messages/bp-messages-functions.php' ); 3 /** 4 * BuddyPress Private Messages Loader 5 * 6 * A private messages component, for users to send messages to each other 7 * 8 * @package BuddyPress 9 * @subpackage Messages Core 10 */ 11 11 12 function messages_setup_globals() { 13 global $bp; 12 class BP_Messages_Component extends BP_Component { 14 13 15 if ( !defined( 'BP_MESSAGES_SLUG' ) ) 16 define ( 'BP_MESSAGES_SLUG', 'messages' ); 17 18 // For internal identification 19 $bp->messages->id = 'messages'; 20 21 // Slug 22 $bp->messages->slug = BP_MESSAGES_SLUG; 23 24 // Tables 25 $bp->messages->table_name_notices = $bp->table_prefix . 'bp_messages_notices'; 26 $bp->messages->table_name_messages = $bp->table_prefix . 'bp_messages_messages'; 27 $bp->messages->table_name_recipients = $bp->table_prefix . 'bp_messages_recipients'; 28 29 // Notifications 30 $bp->messages->notification_callback = 'messages_format_notifications'; 31 32 // Register this in the active components array 33 $bp->active_components[$bp->messages->slug] = $bp->messages->id; 34 35 // Include all members in the To: autocomplete? 36 $bp->messages->autocomplete_all = defined( 'BP_MESSAGES_AUTOCOMPLETE_ALL' ) ? true : false; 37 38 do_action( 'messages_setup_globals' ); 39 } 40 add_action( 'bp_setup_globals', 'messages_setup_globals' ); 41 42 function messages_setup_nav() { 43 global $bp; 44 45 if ( $count = messages_get_unread_count() ) 46 $name = sprintf( __('Messages <strong>(%s)</strong>', 'buddypress'), $count ); 47 else 48 $name = __('Messages <strong></strong>', 'buddypress'); 49 50 // Add 'Messages' to the main navigation 51 bp_core_new_nav_item( array( 'name' => $name, 'slug' => $bp->messages->slug, 'position' => 50, 'show_for_displayed_user' => false, 'screen_function' => 'messages_screen_inbox', 'default_subnav_slug' => 'inbox', 'item_css_id' => $bp->messages->id ) ); 52 53 $messages_link = $bp->loggedin_user->domain . $bp->messages->slug . '/'; 54 55 // Add the subnav items to the profile 56 bp_core_new_subnav_item( array( 'name' => __( 'Inbox', 'buddypress' ), 'slug' => 'inbox', 'parent_url' => $messages_link, 'parent_slug' => $bp->messages->slug, 'screen_function' => 'messages_screen_inbox', 'position' => 10, 'user_has_access' => bp_is_my_profile() ) ); 57 bp_core_new_subnav_item( array( 'name' => __( 'Sent Messages', 'buddypress' ), 'slug' => 'sentbox', 'parent_url' => $messages_link, 'parent_slug' => $bp->messages->slug, 'screen_function' => 'messages_screen_sentbox', 'position' => 20, 'user_has_access' => bp_is_my_profile() ) ); 58 bp_core_new_subnav_item( array( 'name' => __( 'Compose', 'buddypress' ), 'slug' => 'compose', 'parent_url' => $messages_link, 'parent_slug' => $bp->messages->slug, 'screen_function' => 'messages_screen_compose', 'position' => 30, 'user_has_access' => bp_is_my_profile() ) ); 59 60 if ( is_super_admin() ) 61 bp_core_new_subnav_item( array( 'name' => __( 'Notices', 'buddypress' ), 'slug' => 'notices', 'parent_url' => $messages_link, 'parent_slug' => $bp->messages->slug, 'screen_function' => 'messages_screen_notices', 'position' => 90, 'user_has_access' => is_super_admin() ) ); 62 63 if ( $bp->current_component == $bp->messages->slug ) { 64 if ( bp_is_my_profile() ) { 65 $bp->bp_options_title = __( 'My Messages', 'buddypress' ); 66 } else { 67 $bp_options_avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb' ) ); 68 $bp->bp_options_title = $bp->displayed_user->fullname; 69 } 14 /** 15 * Start the messages component creation process 16 * 17 * @since BuddyPress {unknown} 18 */ 19 function BP_Messages_Component() { 20 parent::start( 21 'messages', 22 __( 'Private Messages', 'buddypress' ), 23 BP_PLUGIN_DIR 24 ); 70 25 } 71 26 72 do_action( 'messages_setup_nav' ); 73 } 74 add_action( 'bp_setup_nav', 'messages_setup_nav' ); 27 /** 28 * Include files 29 */ 30 function _includes() { 31 // Files to include 32 $includes = array( 33 'cssjs', 34 'cache', 35 'actions', 36 'screens', 37 'classes', 38 'filters', 39 'template', 40 'functions', 41 ); 75 42 76 /******************************************************************************* 77 * These functions handle the recording, deleting and formatting of activity and 78 * notifications for the user and for this specific component. 79 */ 80 81 function messages_format_notifications( $action, $item_id, $secondary_item_id, $total_items ) { 82 global $bp; 83 84 if ( 'new_message' == $action ) { 85 if ( (int)$total_items > 1 ) 86 return apply_filters( 'bp_messages_multiple_new_message_notification', '<a href="' . $bp->loggedin_user->domain . $bp->messages->slug . '/inbox" title="' . __( 'Inbox', 'buddypress' ) . '">' . sprintf( __('You have %d new messages', 'buddypress' ), (int)$total_items ) . '</a>', $total_items ); 87 else 88 return apply_filters( 'bp_messages_single_new_message_notification', '<a href="' . $bp->loggedin_user->domain . $bp->messages->slug . '/inbox" title="' . __( 'Inbox', 'buddypress' ) . '">' . sprintf( __('You have %d new message', 'buddypress' ), (int)$total_items ) . '</a>', $total_items ); 43 parent::_includes( $includes ); 89 44 } 90 45 91 do_action( 'messages_format_notifications', $action, $item_id, $secondary_item_id, $total_items ); 46 /** 47 * Setup globals 48 * 49 * The BP_MESSAGES_SLUG constant is deprecated, and only used here for 50 * backwards compatibility. 51 * 52 * @since BuddyPress {unknown} 53 * @global obj $bp 54 */ 55 function _setup_globals() { 56 global $bp; 92 57 93 return false; 58 // Define a slug, if necessary 59 if ( !defined( 'BP_MESSAGES_SLUG' ) ) 60 define( 'BP_MESSAGES_SLUG', $this->id ); 61 62 // Global tables for messaging component 63 $global_tables = array( 64 'table_name_notices' => $bp->table_prefix . 'bp_messages_notices', 65 'table_name_messages' => $bp->table_prefix . 'bp_messages_messages', 66 'table_name_recipients' => $bp->table_prefix . 'bp_messages_recipients' 67 ); 68 69 // All globals for messaging component. 70 // Note that global_tables is included in this array. 71 $globals = array( 72 'slug' => BP_MESSAGES_SLUG, 73 'root_slug' => isset( $bp->pages->messages->slug ) ? $bp->pages->messages->slug : BP_MESSAGES_SLUG, 74 'notification_callback' => 'messages_format_notifications', 75 'search_string' => __( 'Search Messages...', 'buddypress' ), 76 'autocomplete_all' => defined( 'BP_MESSAGES_AUTOCOMPLETE_ALL' ), 77 'global_tables' => $global_tables, 78 ); 79 80 parent::_setup_globals( $globals ); 81 } 82 83 /** 84 * Setup BuddyBar navigation 85 * 86 * @global obj $bp 87 */ 88 function _setup_nav() { 89 global $bp; 90 91 if ( $count = messages_get_unread_count() ) 92 $name = sprintf( __( 'Messages <strong>(%s)</strong>', 'buddypress' ), $count ); 93 else 94 $name = __( 'Messages <strong></strong>', 'buddypress' ); 95 96 // Add 'Messages' to the main navigation 97 $main_nav = array( 98 'name' => $name, 99 'slug' => $this->slug, 100 'root_slug' => $this->root_slug, 101 'position' => 50, 102 'show_for_displayed_user' => false, 103 'screen_function' => 'messages_screen_inbox', 104 'default_subnav_slug' => 'inbox', 105 'item_css_id' => $this->id 106 ); 107 108 // Link to user messages 109 $messages_link = trailingslashit( $bp->loggedin_user->domain . $this->slug ); 110 111 // Add the subnav items to the profile 112 $sub_nav[] = array( 113 'name' => __( 'Inbox', 'buddypress' ), 114 'slug' => 'inbox', 115 'parent_url' => $messages_link, 116 'parent_slug' => $this->slug, 117 'screen_function' => 'messages_screen_inbox', 118 'position' => 10, 119 'user_has_access' => bp_is_my_profile() 120 ); 121 122 $sub_nav[] = array( 123 'name' => __( 'Sent Messages', 'buddypress' ), 124 'slug' => 'sentbox', 125 'parent_url' => $messages_link, 126 'parent_slug' => $this->slug, 127 'screen_function' => 'messages_screen_sentbox', 128 'position' => 20, 129 'user_has_access' => bp_is_my_profile() 130 ); 131 132 $sub_nav[] = array( 133 'name' => __( 'Compose', 'buddypress' ), 134 'slug' => 'compose', 135 'parent_url' => $messages_link, 136 'parent_slug' => $this->slug, 137 'screen_function' => 'messages_screen_compose', 138 'position' => 30, 139 'user_has_access' => bp_is_my_profile() 140 ); 141 142 if ( is_super_admin() ) { 143 $sub_nav[] = array( 144 'name' => __( 'Notices', 'buddypress' ), 145 'slug' => 'notices', 146 'parent_url' => $messages_link, 147 'parent_slug' => $this->slug, 148 'screen_function' => 'messages_screen_notices', 149 'position' => 90, 150 'user_has_access' => is_super_admin() 151 ); 152 } 153 154 if ( bp_is_messages_component() ) { 155 if ( bp_is_my_profile() ) { 156 $bp->bp_options_title = __( 'My Messages', 'buddypress' ); 157 } else { 158 $bp->bp_options_avatar = bp_core_fetch_avatar( array( 159 'item_id' => $bp->displayed_user->id, 160 'type' => 'thumb' 161 ) ); 162 $bp->bp_options_title = $bp->displayed_user->fullname; 163 } 164 } 165 166 parent::_setup_nav( $main_nav, $sub_nav ); 167 } 94 168 } 95 96 /******************************************************************************* 97 * Caching functions handle the clearing of cached objects and pages on specific 98 * actions throughout BuddyPress. 99 */ 100 101 // List actions to clear super cached pages on, if super cache is installed 102 add_action( 'messages_delete_thread', 'bp_core_clear_cache' ); 103 add_action( 'messages_send_notice', 'bp_core_clear_cache' ); 104 add_action( 'messages_message_sent', 'bp_core_clear_cache' ); 105 106 // Don't cache message inbox/sentbox/compose as it's too problematic 107 add_action( 'messages_screen_compose', 'bp_core_clear_cache' ); 108 add_action( 'messages_screen_sentbox', 'bp_core_clear_cache' ); 109 add_action( 'messages_screen_inbox', 'bp_core_clear_cache' ); 169 // Create the messages component 170 $bp->messages = new BP_Messages_Component(); 110 171 111 172 ?> -
trunk/bp-messages/bp-messages-template.php
r3757 r3917 166 166 } else { 167 167 if ( 'inbox' == $bp->current_action ) 168 bp_ users_delete_notifications_by_type( $bp->loggedin_user->id, $bp->messages->id, 'new_message' );168 bp_members_delete_notifications_by_type( $bp->loggedin_user->id, $bp->messages->id, 'new_message' ); 169 169 170 170 if ( 'sentbox' == $bp->current_action ) -
trunk/bp-settings/bp-settings-actions.php
r3838 r3917 107 107 108 108 // Load the template 109 bp_core_load_template( apply_filters( 'bp_ users_template_settings', 'members/single/settings/general' ) );109 bp_core_load_template( apply_filters( 'bp_members_template_settings', 'members/single/settings/general' ) ); 110 110 } 111 111 -
trunk/bp-settings/bp-settings-loader.php
r3778 r3917 9 9 */ 10 10 function BP_Settings_Component() { 11 parent::start( 'settings', __( 'Settings', 'buddypress' ) ); 11 parent::start( 12 'settings', 13 __( 'Settings', 'buddypress' ), 14 BP_PLUGIN_DIR 15 ); 16 } 17 18 /** 19 * Include files 20 * 21 * @global obj $bp 22 */ 23 function _includes() { 24 // Files to include 25 $includes = array( 26 'actions', 27 'screens', 28 'template', 29 'functions', 30 ); 31 32 parent::_includes( $includes ); 12 33 } 13 34 … … 28 49 define( 'BP_SETTINGS_SLUG', $this->id ); 29 50 30 // Do some slug checks 31 $this->slug = BP_SETTINGS_SLUG; 32 $this->root_slug = isset( $bp->pages->settings->slug ) ? $bp->pages->settings->slug : $this->slug; 33 34 // Register this in the active components array 35 $bp->active_components[$this->id] = $this->id; 36 } 51 // All globals for messaging component. 52 // Note that global_tables is included in this array. 53 $globals = array( 54 'slug' => BP_SETTINGS_SLUG, 55 'root_slug' => isset( $bp->pages->settings->slug ) ? $bp->pages->settings->slug : BP_SETTINGS_SLUG, 56 ); 37 57 38 /** 39 * Include files 40 * 41 * @global obj $bp 42 */ 43 function _includes() { 44 require_once( BP_PLUGIN_DIR . '/bp-settings/bp-settings-actions.php' ); 45 require_once( BP_PLUGIN_DIR . '/bp-settings/bp-settings-screens.php' ); 46 require_once( BP_PLUGIN_DIR . '/bp-settings/bp-settings-template.php' ); 47 require_once( BP_PLUGIN_DIR . '/bp-settings/bp-settings-functions.php' ); 58 parent::_setup_globals( $globals ); 48 59 } 49 60 … … 57 68 58 69 // Add the settings navigation item 59 bp_core_new_nav_item(array(70 $main_nav = array( 60 71 'name' => __( 'Settings', 'buddypress' ), 61 72 'slug' => $this->slug, 62 73 'position' => 100, 63 'show_for_displayed_user' => bp_ users_can_edit_settings(),74 'show_for_displayed_user' => bp_members_can_edit_settings(), 64 75 'screen_function' => 'bp_settings_screen_general_settings', 65 76 'default_subnav_slug' => 'general' 66 ) );77 ); 67 78 68 $settings_link = trailingslashit( $bp->displayed_user->domain . $ bp->settings->slug );79 $settings_link = trailingslashit( $bp->displayed_user->domain . $this->slug ); 69 80 70 81 // Add General Settings nav item 71 bp_core_new_subnav_item(array(82 $sub_nav[] = array( 72 83 'name' => __( 'General', 'buddypress' ), 73 84 'slug' => 'general', … … 76 87 'screen_function' => 'bp_settings_screen_general_settings', 77 88 'position' => 10, 78 'user_has_access' => bp_ users_can_edit_settings()79 ) );89 'user_has_access' => bp_members_can_edit_settings() 90 ); 80 91 81 92 // Add Notifications nav item 82 bp_core_new_subnav_item(array(93 $sub_nav[] = array( 83 94 'name' => __( 'Notifications', 'buddypress' ), 84 95 'slug' => 'notifications', … … 87 98 'screen_function' => 'bp_settings_screen_notification_settings', 88 99 'position' => 20, 89 'user_has_access' => bp_ users_can_edit_settings()90 ) );100 'user_has_access' => bp_members_can_edit_settings() 101 ); 91 102 92 103 // Add Delete Account nav item 93 104 if ( !is_super_admin() && empty( $bp->site_options['bp-disable-account-deletion'] ) ) { 94 bp_core_new_subnav_item(array(105 $sub_nav[] = array( 95 106 'name' => __( 'Delete Account', 'buddypress' ), 96 107 'slug' => 'delete-account', … … 100 111 'position' => 90, 101 112 'user_has_access' => bp_is_my_profile() 102 ) );113 ); 103 114 } 115 116 parent::_setup_nav( $main_nav, $sub_nav ); 104 117 } 105 118 } -
trunk/bp-themes/bp-default/groups/single/members.php
r3819 r3917 16 16 <option value="newest"><?php _e( 'Newest Registered', 'buddypress' ); ?></option> 17 17 18 <?php if ( bp_is_active( ' profile' ) ) : ?>18 <?php if ( bp_is_active( 'xprofile' ) ) : ?> 19 19 20 20 <option value="alphabetical"><?php _e( 'Alphabetical', 'buddypress' ); ?></option> -
trunk/bp-themes/bp-default/members/index.php
r3810 r3917 55 55 <option value="newest"><?php _e( 'Newest Registered', 'buddypress' ); ?></option> 56 56 57 <?php if ( bp_is_active( ' profile' ) ) : ?>57 <?php if ( bp_is_active( 'xprofile' ) ) : ?> 58 58 59 59 <option value="alphabetical"><?php _e( 'Alphabetical', 'buddypress' ); ?></option> -
trunk/bp-themes/bp-default/members/single/profile.php
r3810 r3917 36 36 37 37 // Display XProfile 38 elseif ( bp_is_active( ' profile' ) )38 elseif ( bp_is_active( 'xprofile' ) ) 39 39 locate_template( array( 'members/single/profile/profile-loop.php' ), true ); 40 40 -
trunk/bp-themes/bp-default/members/single/settings/delete-account.php
r3757 r3917 58 58 <input type="checkbox" name="delete-account-understand" id="delete-account-understand" value="1" onclick="if(this.checked) { document.getElementById('delete-account-button').disabled = ''; } else { document.getElementById('delete-account-button').disabled = 'disabled'; }" /> <?php _e( 'I understand the consequences of deleting my account.', 'buddypress' ); ?> 59 59 60 <?php do_action( 'bp_ users_delete_account_before_submit' ); ?>60 <?php do_action( 'bp_members_delete_account_before_submit' ); ?> 61 61 62 62 <div class="submit"> … … 64 64 </div> 65 65 66 <?php do_action( 'bp_ users_delete_account_after_submit' ); ?>66 <?php do_action( 'bp_members_delete_account_after_submit' ); ?> 67 67 68 68 <?php wp_nonce_field( 'delete-account' ); ?> -
trunk/bp-themes/bp-default/members/single/settings/notifications.php
r3757 r3917 57 57 <?php do_action( 'bp_notification_settings' ); ?> 58 58 59 <?php do_action( 'bp_ users_notification_settings_before_submit' ); ?>59 <?php do_action( 'bp_members_notification_settings_before_submit' ); ?> 60 60 61 61 <div class="submit"> … … 63 63 </div> 64 64 65 <?php do_action( 'bp_ users_notification_settings_after_submit' ); ?>65 <?php do_action( 'bp_members_notification_settings_after_submit' ); ?> 66 66 67 67 <?php wp_nonce_field('bp_settings_notifications'); ?> -
trunk/bp-themes/bp-default/registration/register.php
r3790 r3917 48 48 <?php /***** Extra Profile Details ******/ ?> 49 49 50 <?php if ( bp_is_active( ' profile' ) ) : ?>50 <?php if ( bp_is_active( 'xprofile' ) ) : ?> 51 51 52 52 <?php do_action( 'bp_before_signup_profile_fields' ) ?> … … 57 57 58 58 <?php /* Use the profile field loop to render input fields for the 'base' profile field group */ ?> 59 <?php if ( bp_is_active( ' profile' ) ) : if ( bp_has_profile( 'profile_group_id=1' ) ) : while ( bp_profile_groups() ) : bp_the_profile_group(); ?>59 <?php if ( bp_is_active( 'xprofile' ) ) : if ( bp_has_profile( 'profile_group_id=1' ) ) : while ( bp_profile_groups() ) : bp_the_profile_group(); ?> 60 60 61 61 <?php while ( bp_profile_fields() ) : bp_the_profile_field(); ?> -
trunk/bp-xprofile/bp-xprofile-actions.php
r3791 r3917 38 38 bp_core_redirect( wp_get_referer() ); 39 39 } 40 add_action( ' wp', 'xprofile_action_delete_avatar', 3);40 add_action( 'bp_actions', 'xprofile_action_delete_avatar' ); 41 41 42 42 ?> -
trunk/bp-xprofile/bp-xprofile-loader.php
r3790 r3917 19 19 */ 20 20 function BP_XProfile_Component() { 21 parent::start( 'profile', __( 'Extended Profiles', 'buddypress' ) ); 21 parent::start( 22 'xprofile', 23 __( 'Extended Profiles', 'buddypress' ), 24 BP_PLUGIN_DIR 25 ); 26 } 27 28 /** 29 * Include files 30 */ 31 function _includes() { 32 $includes = array( 33 'cssjs', 34 'actions', 35 'screens', 36 'classes', 37 'filters', 38 'template', 39 'functions' 40 ); 41 42 if ( is_admin() ) 43 $includes[] = 'admin'; 44 45 parent::_includes( $includes ); 22 46 } 23 47 … … 43 67 define ( 'BP_XPROFILE_FULLNAME_FIELD_NAME', stripslashes( $bp->site_options['bp-xprofile-fullname-field-name'] ) ); 44 68 45 // Do some slug checks46 $this->slug = BP_XPROFILE_SLUG;47 $this->root_slug = isset( $bp->pages->xprofile->slug ) ? $bp->pages->xprofile->slug : $this->slug;48 49 // Tables50 $this->table_name_data = $bp->table_prefix . 'bp_xprofile_data';51 $this->table_name_groups = $bp->table_prefix . 'bp_xprofile_groups';52 $this->table_name_fields = $bp->table_prefix . 'bp_xprofile_fields';53 $this->table_name_meta = $bp->table_prefix . 'bp_xprofile_meta';54 55 // Notifications56 $this->notification_callback = 'xprofile_format_notifications';57 58 // Register this in the active components array59 $bp->active_components[$this->id] = $this->id;60 61 69 // Set the support field type ids 62 70 $this->field_types = apply_filters( 'xprofile_field_types', array( … … 69 77 'datebox' 70 78 ) ); 71 }72 79 73 /** 74 * Include files 75 */ 76 function _includes() { 77 require_once( BP_PLUGIN_DIR . '/bp-xprofile/bp-xprofile-cssjs.php' ); 78 require_once( BP_PLUGIN_DIR . '/bp-xprofile/bp-xprofile-admin.php' ); 79 require_once( BP_PLUGIN_DIR . '/bp-xprofile/bp-xprofile-actions.php' ); 80 require_once( BP_PLUGIN_DIR . '/bp-xprofile/bp-xprofile-screens.php' ); 81 require_once( BP_PLUGIN_DIR . '/bp-xprofile/bp-xprofile-classes.php' ); 82 require_once( BP_PLUGIN_DIR . '/bp-xprofile/bp-xprofile-filters.php' ); 83 require_once( BP_PLUGIN_DIR . '/bp-xprofile/bp-xprofile-template.php' ); 84 require_once( BP_PLUGIN_DIR . '/bp-xprofile/bp-xprofile-functions.php' ); 80 // Tables 81 $global_tables = array( 82 'table_name_data' => $bp->table_prefix . 'bp_xprofile_data', 83 'table_name_groups' => $bp->table_prefix . 'bp_xprofile_groups', 84 'table_name_fields' => $bp->table_prefix . 'bp_xprofile_fields', 85 'table_name_meta' => $bp->table_prefix . 'bp_xprofile_meta', 86 ); 87 88 $globals = array( 89 'slug' => BP_XPROFILE_SLUG, 90 'root_slug' => isset( $bp->pages->xprofile->slug ) ? $bp->pages->xprofile->slug : BP_XPROFILE_SLUG, 91 'notification_callback' => 'xprofile_format_notifications', 92 'global_tables' => $global_tables 93 ); 94 95 parent::_setup_globals( $globals ); 85 96 } 86 97 … … 94 105 95 106 // Add 'Profile' to the main navigation 96 bp_core_new_nav_item(array(107 $main_nav = array( 97 108 'name' => __( 'Profile', 'buddypress' ), 98 109 'slug' => $this->slug, … … 101 112 'default_subnav_slug' => 'public', 102 113 'item_css_id' => $this->id 103 ) );114 ); 104 115 105 116 $profile_link = trailingslashit( $bp->loggedin_user->domain . $this->slug ); 106 117 107 118 // Add the subnav items to the profile 108 bp_core_new_subnav_item(array(119 $sub_nav[] = array( 109 120 'name' => __( 'Public', 'buddypress' ), 110 121 'slug' => 'public', … … 113 124 'screen_function' => 'xprofile_screen_display_profile', 114 125 'position' => 10 115 ) );126 ); 116 127 117 128 // Edit Profile 118 bp_core_new_subnav_item(array(129 $sub_nav[] = array( 119 130 'name' => __( 'Edit Profile', 'buddypress' ), 120 131 'slug' => 'edit', … … 123 134 'screen_function' => 'xprofile_screen_edit_profile', 124 135 'position' => 20 125 ) );136 ); 126 137 127 138 // Change Avatar 128 bp_core_new_subnav_item(array(139 $sub_nav[] = array( 129 140 'name' => __( 'Change Avatar', 'buddypress' ), 130 141 'slug' => 'change-avatar', … … 133 144 'screen_function' => 'xprofile_screen_change_avatar', 134 145 'position' => 30 135 ) );146 ); 136 147 137 if ( $bp->current_component == $this->id ) { 148 parent::_setup_nav( $main_nav, $sub_nav ); 149 } 150 151 /** 152 * Sets up the title for pages and <title> 153 * 154 * @global obj $bp 155 */ 156 function _setup_title() { 157 global $bp; 158 159 if ( bp_is_profile_component() ) { 138 160 if ( bp_is_my_profile() ) { 139 161 $bp->bp_options_title = __( 'My Profile', 'buddypress' ); … … 146 168 } 147 169 } 170 171 parent::_setup_title(); 148 172 } 149 173 } -
trunk/bp-xprofile/bp-xprofile-template.php
r3903 r3917 739 739 bp_button( array ( 740 740 'id' => 'edit_profile', 741 'component' => ' profile',741 'component' => 'xprofile', 742 742 'must_be_logged_in' => true, 743 743 'block_self' => true,
Note: See TracChangeset
for help on using the changeset viewer.