Version Description
Download this release
Release Info
Developer | apeatling |
Plugin | BuddyPress |
Version | 1.2 |
Comparing to | |
See all releases |
Code changes from version 1.1.3 to 1.2
- bp-activity.php +884 -111
- bp-activity/bp-activity-classes.php +356 -142
- bp-activity/bp-activity-filters.php +98 -1
- bp-activity/bp-activity-notifications.php +139 -0
- bp-activity/bp-activity-templatetags.php +584 -100
- bp-activity/bp-activity-widgets.php +0 -87
- bp-activity/deprecated/bp-activity-deprecated.php +0 -95
- bp-activity/deprecated/css/structure.css +0 -15
- bp-activity/deprecated/images/rss.png +0 -0
- bp-activity/feeds/bp-activity-favorites-feed.php +63 -0
- bp-activity/feeds/bp-activity-friends-feed.php +22 -8
- bp-activity/feeds/bp-activity-group-feed.php +53 -0
- bp-activity/feeds/bp-activity-mentions-feed.php +58 -0
- bp-activity/feeds/bp-activity-mygroups-feed.php +58 -0
- bp-activity/feeds/bp-activity-personal-feed.php +21 -8
- bp-activity/feeds/bp-activity-sitewide-feed.php +14 -6
- bp-blogs.php +215 -166
- bp-blogs/admin-tabs/admin.css +0 -56
- bp-blogs/admin-tabs/bp-blogs-comments-tab.php +0 -3
- bp-blogs/admin-tabs/bp-blogs-posts-tab.php +0 -3
- bp-blogs/admin-tabs/bp-blogs-tab.php +0 -3
- bp-blogs/bp-blogs-classes.php +255 -219
- bp-blogs/bp-blogs-templatetags.php +323 -1153
- bp-blogs/bp-blogs-widgets.php +39 -31
- bp-blogs/deprecated/bp-blogs-deprecated.php +0 -105
- bp-blogs/deprecated/css/structure.css +0 -84
- bp-blogs/deprecated/js/directory-blogs.js +0 -104
- bp-core.php +549 -185
- bp-core/bp-core-activation.php +38 -32
- bp-core/bp-core-admin.php +17 -69
- bp-core/bp-core-adminbar.php +137 -166
- bp-core/bp-core-avatars.php +83 -55
- bp-core/bp-core-catchuri.php +7 -5
- bp-core/bp-core-classes.php +246 -103
- bp-core/bp-core-cssjs.php +18 -29
- bp-core/bp-core-notifications.php +2 -2
- bp-core/bp-core-settings.php +24 -15
- bp-core/bp-core-signup.php +121 -42
- bp-core/bp-core-templatetags.php +788 -610
- bp-core/bp-core-widgets.php +42 -118
- bp-core/bp-core-wpabstraction.php +157 -0
- bp-core/css/widget-members.css +0 -0
- bp-core/deprecated/bp-core-deprecated.php +0 -965
- bp-core/deprecated/css/admin-bar.css +0 -239
- bp-core/deprecated/css/structure.css +0 -322
- bp-core/deprecated/images/accept_button_side.gif +0 -0
- bp-core/deprecated/images/add_button_side.gif +0 -0
- bp-core/deprecated/images/add_friend_button.gif +0 -0
- bp-core/deprecated/images/admin-menu-arrow.gif +0 -0
- bp-core/deprecated/images/admin_bar_back.gif +0 -0
- bp-core/deprecated/images/admin_bar_logo.gif +0 -0
- bp-core/deprecated/images/ajax-loader.gif +0 -0
- bp-core/deprecated/images/blog.png +0 -0
- bp-core/deprecated/images/button_back.gif +0 -0
- bp-core/deprecated/images/check_button_side.gif +0 -0
- bp-core/deprecated/images/loading_button_side.gif +0 -0
- bp-core/deprecated/images/logout_bullet.gif +0 -0
- bp-core/deprecated/images/member.png +0 -0
- bp-core/deprecated/images/nav_bullet.gif +0 -0
- bp-core/deprecated/images/reject_button_side.gif +0 -0
- bp-core/deprecated/images/remove_button_side.gif +0 -0
- bp-core/deprecated/images/remove_friend_button.gif +0 -0
- bp-core/deprecated/images/requested_friend_button.gif +0 -0
- bp-core/deprecated/images/view_button_side.gif +0 -0
- bp-core/deprecated/js/directory-members.js +0 -111
- bp-core/deprecated/js/general.js +0 -100
- bp-core/deprecated/js/jquery/jquery.livequery.pack.js +0 -9
- bp-core/deprecated/js/jquery/jquery.tablednd.js +0 -314
- bp-core/images/Jcrop.gif +0 -0
- bp-core/images/admin_menu_icon.png +0 -0
- bp-core/images/mystery-man.jpg +0 -0
- bp-core/js/admin-bar.js +0 -9
- bp-core/js/widget-members.js +12 -12
- bp-forums.php +176 -34
- bp-forums/bb-config.php +1 -1
- bp-forums/bp-forums-admin.php +19 -10
- bp-forums/bp-forums-bbpress.php +2 -1
- bp-forums/bp-forums-filters.php +30 -10
- bp-forums/bp-forums-templatetags.php +141 -87
- bp-forums/deprecated/images/closed.png +0 -0
- bp-friends.php +158 -238
- bp-friends/bp-friends-classes.php +12 -20
- bp-friends/bp-friends-notifications.php +13 -7
- bp-friends/bp-friends-templatetags.php +138 -381
- bp-friends/deprecated/bp-friends-deprecated.php +0 -102
- bp-friends/deprecated/css/structure.css +0 -28
- bp-friends/deprecated/images/ajax-loader.gif +0 -0
- bp-friends/deprecated/js/general.js +0 -73
- bp-groups.php +635 -783
- bp-groups/bp-groups-admin.php +0 -129
- bp-groups/bp-groups-classes.php +313 -240
- bp-groups/bp-groups-filters.php +25 -24
- bp-groups/bp-groups-notifications.php +116 -84
- bp-groups/bp-groups-templatetags.php +432 -814
- bp-groups/bp-groups-widgets.php +14 -14
- bp-groups/deprecated/bp-groups-deprecated.php +0 -842
- bp-groups/deprecated/css/structure.css +0 -38
- bp-groups/deprecated/images/ajax-loader.gif +0 -0
- bp-groups/deprecated/images/none-thumbnail.gif +0 -0
- bp-groups/deprecated/images/none.gif +0 -0
- bp-groups/deprecated/js/directory-groups.js +0 -138
- bp-groups/deprecated/js/general.js +0 -196
- bp-groups/js/widget-groups.js +12 -12
- bp-languages/buddypress.pot +162 -20
bp-activity.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
define ( 'BP_ACTIVITY_DB_VERSION', '
|
4 |
|
5 |
/* Define the slug for the component */
|
6 |
if ( !defined( 'BP_ACTIVITY_SLUG' ) )
|
@@ -8,46 +8,67 @@ if ( !defined( 'BP_ACTIVITY_SLUG' ) )
|
|
8 |
|
9 |
require ( BP_PLUGIN_DIR . '/bp-activity/bp-activity-classes.php' );
|
10 |
require ( BP_PLUGIN_DIR . '/bp-activity/bp-activity-templatetags.php' );
|
11 |
-
require ( BP_PLUGIN_DIR . '/bp-activity/bp-activity-widgets.php' );
|
12 |
require ( BP_PLUGIN_DIR . '/bp-activity/bp-activity-filters.php' );
|
13 |
|
14 |
-
/* Include deprecated functions if settings allow */
|
15 |
-
if ( !defined( 'BP_IGNORE_DEPRECATED' ) )
|
16 |
-
require ( BP_PLUGIN_DIR . '/bp-activity/deprecated/bp-activity-deprecated.php' );
|
17 |
-
|
18 |
function bp_activity_install() {
|
19 |
global $wpdb, $bp;
|
20 |
|
21 |
if ( !empty($wpdb->charset) )
|
22 |
$charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
|
23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
$sql[] = "CREATE TABLE {$bp->activity->table_name} (
|
25 |
id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
26 |
user_id bigint(20) NOT NULL,
|
27 |
-
|
28 |
-
|
|
|
29 |
content longtext NOT NULL,
|
30 |
primary_link varchar(150) NOT NULL,
|
31 |
item_id varchar(75) NOT NULL,
|
32 |
-
secondary_item_id varchar(75)
|
33 |
date_recorded datetime NOT NULL,
|
34 |
hide_sitewide bool DEFAULT 0,
|
|
|
|
|
35 |
KEY date_recorded (date_recorded),
|
36 |
KEY user_id (user_id),
|
37 |
KEY item_id (item_id),
|
38 |
-
KEY
|
|
|
|
|
|
|
|
|
|
|
39 |
) {$charset_collate};";
|
40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
require_once( ABSPATH . 'wp-admin/upgrade-functions.php' );
|
42 |
dbDelta($sql);
|
43 |
|
44 |
-
/* Drop the old sitewide and user activity tables */
|
45 |
-
$wpdb->query( "DROP TABLE IF EXISTS {$wpdb->base_prefix}bp_activity_user_activity" );
|
46 |
-
$wpdb->query( "DROP TABLE IF EXISTS {$wpdb->base_prefix}bp_activity_sitewide" );
|
47 |
-
|
48 |
-
/* TODO: Rename the old user activity cached table */
|
49 |
-
//$wpdb->query( "RENAME TABLE {$wpdb->base_prefix}bp_activity_user_activity_cached TO {$bp->activity->table_name}" );
|
50 |
-
|
51 |
update_site_option( 'bp-activity-db-version', BP_ACTIVITY_DB_VERSION );
|
52 |
}
|
53 |
|
@@ -57,21 +78,22 @@ function bp_activity_setup_globals() {
|
|
57 |
/* Internal identifier */
|
58 |
$bp->activity->id = 'activity';
|
59 |
|
60 |
-
$bp->activity->table_name = $wpdb->base_prefix . '
|
|
|
61 |
$bp->activity->slug = BP_ACTIVITY_SLUG;
|
|
|
62 |
|
63 |
/* Register this in the active components array */
|
64 |
$bp->active_components[$bp->activity->slug] = $bp->activity->id;
|
65 |
|
66 |
do_action( 'bp_activity_setup_globals' );
|
67 |
}
|
68 |
-
add_action( '
|
69 |
-
add_action( 'admin_menu', 'bp_activity_setup_globals', 2 );
|
70 |
|
71 |
function bp_activity_check_installed() {
|
72 |
global $wpdb, $bp;
|
73 |
|
74 |
-
if (
|
75 |
bp_activity_install();
|
76 |
}
|
77 |
add_action( 'admin_menu', 'bp_activity_check_installed' );
|
@@ -80,7 +102,7 @@ function bp_activity_setup_root_component() {
|
|
80 |
/* Register 'activity' as a root component (for RSS feed use) */
|
81 |
bp_core_add_root_component( BP_ACTIVITY_SLUG );
|
82 |
}
|
83 |
-
add_action( '
|
84 |
|
85 |
function bp_activity_setup_nav() {
|
86 |
global $bp;
|
@@ -88,14 +110,24 @@ function bp_activity_setup_nav() {
|
|
88 |
/* Add 'Activity' to the main navigation */
|
89 |
bp_core_new_nav_item( array( 'name' => __( 'Activity', 'buddypress' ), 'slug' => $bp->activity->slug, 'position' => 10, 'screen_function' => 'bp_activity_screen_my_activity', 'default_subnav_slug' => 'just-me', 'item_css_id' => $bp->activity->id ) );
|
90 |
|
91 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
|
93 |
-
|
94 |
-
bp_core_new_subnav_item( array( 'name' => __( '
|
95 |
-
bp_core_new_subnav_item( array( 'name' => __( 'My Friends', 'buddypress' ), 'slug' => 'my-friends', 'parent_url' => $activity_link, 'parent_slug' => $bp->activity->slug, 'screen_function' => 'bp_activity_screen_friends_activity', 'position' => 20, 'item_css_id' => 'activity-my-friends' ) );
|
96 |
|
97 |
if ( $bp->current_component == $bp->activity->slug ) {
|
98 |
-
if (
|
99 |
$bp->bp_options_title = __( 'My Activity', 'buddypress' );
|
100 |
} else {
|
101 |
$bp->bp_options_avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb' ) );
|
@@ -105,9 +137,21 @@ function bp_activity_setup_nav() {
|
|
105 |
|
106 |
do_action( 'bp_activity_setup_nav' );
|
107 |
}
|
108 |
-
add_action( '
|
109 |
add_action( 'admin_menu', 'bp_activity_setup_nav' );
|
110 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
111 |
|
112 |
/********************************************************************************
|
113 |
* Screen Functions
|
@@ -119,20 +163,127 @@ add_action( 'admin_menu', 'bp_activity_setup_nav' );
|
|
119 |
|
120 |
function bp_activity_screen_my_activity() {
|
121 |
do_action( 'bp_activity_screen_my_activity' );
|
122 |
-
bp_core_load_template( apply_filters( 'bp_activity_template_my_activity', '
|
123 |
}
|
124 |
|
125 |
-
function
|
126 |
global $bp;
|
127 |
|
128 |
-
|
|
|
|
|
129 |
if ( !is_site_admin() )
|
130 |
$bp->is_item_admin = false;
|
131 |
|
132 |
-
do_action( '
|
133 |
-
bp_core_load_template( apply_filters( 'bp_activity_template_friends_activity', '
|
134 |
}
|
135 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
|
137 |
/********************************************************************************
|
138 |
* Action Functions
|
@@ -142,6 +293,41 @@ function bp_activity_screen_friends_activity() {
|
|
142 |
* back to the default screen after execution.
|
143 |
*/
|
144 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
145 |
function bp_activity_action_delete_activity() {
|
146 |
global $bp;
|
147 |
|
@@ -155,32 +341,134 @@ function bp_activity_action_delete_activity() {
|
|
155 |
check_admin_referer( 'bp_activity_delete_link' );
|
156 |
|
157 |
$activity_id = $bp->action_variables[0];
|
|
|
158 |
|
159 |
/* Check access */
|
160 |
-
if ( !is_site_admin() )
|
161 |
-
|
162 |
|
163 |
-
|
164 |
-
|
165 |
-
}
|
166 |
|
167 |
/* Now delete the activity item */
|
168 |
-
if (
|
169 |
bp_core_add_message( __( 'Activity deleted', 'buddypress' ) );
|
170 |
else
|
171 |
bp_core_add_message( __( 'There was an error when deleting that activity', 'buddypress' ), 'error' );
|
172 |
|
173 |
-
|
174 |
-
|
175 |
-
bp_core_redirect( $_SERVER['HTTP_REFERER'] );
|
176 |
}
|
177 |
add_action( 'wp', 'bp_activity_action_delete_activity', 3 );
|
178 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
179 |
|
180 |
function bp_activity_action_sitewide_feed() {
|
181 |
global $bp, $wp_query;
|
182 |
|
183 |
-
if ( $bp->current_component != $bp->activity->slug || $bp->current_action != 'feed' || $bp->displayed_user->id )
|
184 |
return false;
|
185 |
|
186 |
$wp_query->is_404 = false;
|
@@ -208,7 +496,7 @@ add_action( 'wp', 'bp_activity_action_personal_feed', 3 );
|
|
208 |
function bp_activity_action_friends_feed() {
|
209 |
global $bp, $wp_query;
|
210 |
|
211 |
-
if ( $bp->current_component != $bp->activity->slug || !$bp->displayed_user->id || $bp->current_action != '
|
212 |
return false;
|
213 |
|
214 |
$wp_query->is_404 = false;
|
@@ -219,6 +507,47 @@ function bp_activity_action_friends_feed() {
|
|
219 |
}
|
220 |
add_action( 'wp', 'bp_activity_action_friends_feed', 3 );
|
221 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
222 |
|
223 |
/********************************************************************************
|
224 |
* Business Functions
|
@@ -229,35 +558,99 @@ add_action( 'wp', 'bp_activity_action_friends_feed', 3 );
|
|
229 |
* true or false on success or failure.
|
230 |
*/
|
231 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
232 |
function bp_activity_add( $args = '' ) {
|
233 |
global $bp, $wpdb;
|
234 |
|
235 |
$defaults = array(
|
236 |
-
'
|
237 |
-
|
238 |
-
'
|
239 |
-
'
|
|
|
|
|
|
|
|
|
240 |
|
241 |
'user_id' => $bp->loggedin_user->id, // Optional: The user to record the activity for, can be false if this activity is not for a user.
|
242 |
-
'item_id' => false, // Optional: The ID of the specific item being recorded, e.g. a blog_id
|
243 |
'secondary_item_id' => false, // Optional: A second ID used to further filter e.g. a comment_id
|
244 |
-
'recorded_time' =>
|
245 |
'hide_sitewide' => false // Should this be hidden on the sitewide activity stream?
|
246 |
);
|
247 |
|
248 |
-
$
|
249 |
-
extract( $
|
|
|
|
|
|
|
|
|
250 |
|
251 |
-
|
252 |
-
|
253 |
-
|
|
|
254 |
|
255 |
-
$activity = new BP_Activity_Activity;
|
256 |
$activity->user_id = $user_id;
|
|
|
|
|
|
|
257 |
$activity->content = $content;
|
258 |
$activity->primary_link = $primary_link;
|
259 |
-
$activity->component_name = $component_name;
|
260 |
-
$activity->component_action = $component_action;
|
261 |
$activity->item_id = $item_id;
|
262 |
$activity->secondary_item_id = $secondary_item_id;
|
263 |
$activity->date_recorded = $recorded_time;
|
@@ -266,85 +659,302 @@ function bp_activity_add( $args = '' ) {
|
|
266 |
if ( !$activity->save() )
|
267 |
return false;
|
268 |
|
269 |
-
|
|
|
|
|
270 |
|
271 |
-
|
272 |
-
|
273 |
|
274 |
-
|
|
|
275 |
|
276 |
-
function
|
277 |
global $bp;
|
278 |
|
279 |
$defaults = array(
|
280 |
-
'
|
281 |
-
'
|
282 |
-
'component_action' => false, // optional
|
283 |
-
'user_id' => false, // optional
|
284 |
-
'secondary_item_id' => false // optional
|
285 |
);
|
286 |
|
287 |
$r = wp_parse_args( $args, $defaults );
|
288 |
extract( $r, EXTR_SKIP );
|
289 |
|
290 |
-
if (
|
291 |
return false;
|
292 |
|
293 |
-
|
|
|
|
|
|
|
294 |
|
295 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
296 |
}
|
297 |
|
298 |
-
function
|
299 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
300 |
return false;
|
301 |
|
302 |
-
|
|
|
303 |
|
304 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
305 |
}
|
306 |
|
307 |
-
|
308 |
-
|
309 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
310 |
|
311 |
-
if (
|
312 |
return false;
|
313 |
|
314 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
315 |
|
316 |
return true;
|
317 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
318 |
|
319 |
-
function
|
320 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
321 |
return false;
|
322 |
|
323 |
-
|
|
|
|
|
|
|
324 |
|
325 |
return true;
|
326 |
}
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
if ( !$pos = strpos( $content, '<div' ) ) {
|
333 |
-
if ( !$pos = strpos( $content, '<ul' ) ) {
|
334 |
-
$content .= ' <span class="time-since">%s</span>';
|
335 |
-
}
|
336 |
-
}
|
337 |
}
|
|
|
338 |
}
|
339 |
|
340 |
-
|
341 |
-
|
342 |
-
|
|
|
|
|
343 |
|
344 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
345 |
}
|
346 |
|
347 |
-
return apply_filters( '
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
348 |
}
|
349 |
|
350 |
function bp_activity_set_action( $component_id, $key, $value ) {
|
@@ -368,10 +978,69 @@ function bp_activity_get_action( $component_id, $key ) {
|
|
368 |
return apply_filters( 'bp_activity_get_action', $bp->activity->actions->{$component_id}->{$key}, $component_id, $key );
|
369 |
}
|
370 |
|
371 |
-
function
|
372 |
-
|
373 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
374 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
375 |
return apply_filters( 'bp_activity_check_exists_by_content', BP_Activity_Activity::check_exists_by_content( $content ) );
|
376 |
}
|
377 |
|
@@ -379,21 +1048,115 @@ function bp_activity_get_last_updated() {
|
|
379 |
return apply_filters( 'bp_activity_get_last_updated', BP_Activity_Activity::get_last_updated() );
|
380 |
}
|
381 |
|
382 |
-
function
|
383 |
-
|
|
|
|
|
|
|
|
|
|
|
384 |
}
|
385 |
|
386 |
-
|
387 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
388 |
}
|
389 |
|
390 |
-
function
|
391 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
392 |
}
|
393 |
|
394 |
function bp_activity_remove_data( $user_id ) {
|
395 |
// Clear the user's activity from the sitewide stream and clear their activity tables
|
396 |
-
|
|
|
|
|
|
|
|
|
397 |
|
398 |
do_action( 'bp_activity_remove_data', $user_id );
|
399 |
}
|
@@ -401,9 +1164,19 @@ add_action( 'wpmu_delete_user', 'bp_activity_remove_data' );
|
|
401 |
add_action( 'delete_user', 'bp_activity_remove_data' );
|
402 |
add_action( 'make_spam_user', 'bp_activity_remove_data' );
|
403 |
|
404 |
-
|
405 |
-
|
406 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
407 |
}
|
|
|
|
|
408 |
|
409 |
?>
|
1 |
<?php
|
2 |
|
3 |
+
define ( 'BP_ACTIVITY_DB_VERSION', '2060' );
|
4 |
|
5 |
/* Define the slug for the component */
|
6 |
if ( !defined( 'BP_ACTIVITY_SLUG' ) )
|
8 |
|
9 |
require ( BP_PLUGIN_DIR . '/bp-activity/bp-activity-classes.php' );
|
10 |
require ( BP_PLUGIN_DIR . '/bp-activity/bp-activity-templatetags.php' );
|
|
|
11 |
require ( BP_PLUGIN_DIR . '/bp-activity/bp-activity-filters.php' );
|
12 |
|
|
|
|
|
|
|
|
|
13 |
function bp_activity_install() {
|
14 |
global $wpdb, $bp;
|
15 |
|
16 |
if ( !empty($wpdb->charset) )
|
17 |
$charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
|
18 |
|
19 |
+
/* Rename the old user activity cached table if needed. */
|
20 |
+
if ( $wpdb->get_var( "SHOW TABLES LIKE '%{$wpdb->base_prefix}bp_activity_user_activity_cached%'" ) )
|
21 |
+
$wpdb->query( "RENAME TABLE {$wpdb->base_prefix}bp_activity_user_activity_cached TO {$bp->activity->table_name}" );
|
22 |
+
|
23 |
+
/* Rename fields from pre BP 1.2 */
|
24 |
+
if ( $wpdb->get_var( "SHOW TABLES LIKE '%{$bp->activity->table_name}%'" ) ) {
|
25 |
+
if ( $wpdb->get_var( "SHOW COLUMNS FROM {$bp->activity->table_name} LIKE 'component_action'" ) )
|
26 |
+
$wpdb->query( "ALTER TABLE {$bp->activity->table_name} CHANGE component_action type varchar(75) NOT NULL" );
|
27 |
+
|
28 |
+
if ( $wpdb->get_var( "SHOW COLUMNS FROM {$bp->activity->table_name} LIKE 'component_name'" ) )
|
29 |
+
$wpdb->query( "ALTER TABLE {$bp->activity->table_name} CHANGE component_name component varchar(75) NOT NULL" );
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Build the tables
|
34 |
+
*/
|
35 |
$sql[] = "CREATE TABLE {$bp->activity->table_name} (
|
36 |
id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
37 |
user_id bigint(20) NOT NULL,
|
38 |
+
component varchar(75) NOT NULL,
|
39 |
+
type varchar(75) NOT NULL,
|
40 |
+
action text NOT NULL,
|
41 |
content longtext NOT NULL,
|
42 |
primary_link varchar(150) NOT NULL,
|
43 |
item_id varchar(75) NOT NULL,
|
44 |
+
secondary_item_id varchar(75) DEFAULT NULL,
|
45 |
date_recorded datetime NOT NULL,
|
46 |
hide_sitewide bool DEFAULT 0,
|
47 |
+
mptt_left int(11) NOT NULL,
|
48 |
+
mptt_right int(11) NOT NULL,
|
49 |
KEY date_recorded (date_recorded),
|
50 |
KEY user_id (user_id),
|
51 |
KEY item_id (item_id),
|
52 |
+
KEY secondary_item_id (secondary_item_id),
|
53 |
+
KEY component (component),
|
54 |
+
KEY type (type),
|
55 |
+
KEY mptt_left (mptt_left),
|
56 |
+
KEY mptt_right (mptt_right),
|
57 |
+
KEY hide_sitewide (hide_sitewide)
|
58 |
) {$charset_collate};";
|
59 |
|
60 |
+
$sql[] = "CREATE TABLE {$bp->activity->table_name_meta} (
|
61 |
+
id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
62 |
+
activity_id bigint(20) NOT NULL,
|
63 |
+
meta_key varchar(255) DEFAULT NULL,
|
64 |
+
meta_value longtext DEFAULT NULL,
|
65 |
+
KEY activity_id (activity_id),
|
66 |
+
KEY meta_key (meta_key)
|
67 |
+
) {$charset_collate};";
|
68 |
+
|
69 |
require_once( ABSPATH . 'wp-admin/upgrade-functions.php' );
|
70 |
dbDelta($sql);
|
71 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
update_site_option( 'bp-activity-db-version', BP_ACTIVITY_DB_VERSION );
|
73 |
}
|
74 |
|
78 |
/* Internal identifier */
|
79 |
$bp->activity->id = 'activity';
|
80 |
|
81 |
+
$bp->activity->table_name = $wpdb->base_prefix . 'bp_activity';
|
82 |
+
$bp->activity->table_name_meta = $wpdb->base_prefix . 'bp_activity_meta';
|
83 |
$bp->activity->slug = BP_ACTIVITY_SLUG;
|
84 |
+
$bp->activity->format_notification_function = 'bp_activity_format_notifications';
|
85 |
|
86 |
/* Register this in the active components array */
|
87 |
$bp->active_components[$bp->activity->slug] = $bp->activity->id;
|
88 |
|
89 |
do_action( 'bp_activity_setup_globals' );
|
90 |
}
|
91 |
+
add_action( 'bp_setup_globals', 'bp_activity_setup_globals' );
|
|
|
92 |
|
93 |
function bp_activity_check_installed() {
|
94 |
global $wpdb, $bp;
|
95 |
|
96 |
+
if ( $bp->site_options['bp-activity-db-version'] < BP_ACTIVITY_DB_VERSION )
|
97 |
bp_activity_install();
|
98 |
}
|
99 |
add_action( 'admin_menu', 'bp_activity_check_installed' );
|
102 |
/* Register 'activity' as a root component (for RSS feed use) */
|
103 |
bp_core_add_root_component( BP_ACTIVITY_SLUG );
|
104 |
}
|
105 |
+
add_action( 'bp_setup_root_components', 'bp_activity_setup_root_component' );
|
106 |
|
107 |
function bp_activity_setup_nav() {
|
108 |
global $bp;
|
110 |
/* Add 'Activity' to the main navigation */
|
111 |
bp_core_new_nav_item( array( 'name' => __( 'Activity', 'buddypress' ), 'slug' => $bp->activity->slug, 'position' => 10, 'screen_function' => 'bp_activity_screen_my_activity', 'default_subnav_slug' => 'just-me', 'item_css_id' => $bp->activity->id ) );
|
112 |
|
113 |
+
$user_domain = ( !empty( $bp->displayed_user->domain ) ) ? $bp->displayed_user->domain : $bp->loggedin_user->domain;
|
114 |
+
$user_login = ( !empty( $bp->displayed_user->userdata->user_login ) ) ? $bp->displayed_user->userdata->user_login : $bp->loggedin_user->userdata->user_login;
|
115 |
+
$activity_link = $user_domain . $bp->activity->slug . '/';
|
116 |
+
|
117 |
+
/* Add the subnav items to the activity nav item if we are using a theme that supports this */
|
118 |
+
bp_core_new_subnav_item( array( 'name' => __( 'Personal', 'buddypress' ), 'slug' => 'just-me', 'parent_url' => $activity_link, 'parent_slug' => $bp->activity->slug, 'screen_function' => 'bp_activity_screen_my_activity', 'position' => 10 ) );
|
119 |
+
|
120 |
+
if ( bp_is_active( 'friends' ) )
|
121 |
+
bp_core_new_subnav_item( array( 'name' => __( 'Friends', 'buddypress' ), 'slug' => BP_FRIENDS_SLUG, 'parent_url' => $activity_link, 'parent_slug' => $bp->activity->slug, 'screen_function' => 'bp_activity_screen_friends', 'position' => 20, 'item_css_id' => 'activity-friends' ) );
|
122 |
+
|
123 |
+
if ( bp_is_active( 'groups' ) )
|
124 |
+
bp_core_new_subnav_item( array( 'name' => __( 'Groups', 'buddypress' ), 'slug' => BP_GROUPS_SLUG, 'parent_url' => $activity_link, 'parent_slug' => $bp->activity->slug, 'screen_function' => 'bp_activity_screen_groups', 'position' => 30, 'item_css_id' => 'activity-groups' ) );
|
125 |
|
126 |
+
bp_core_new_subnav_item( array( 'name' => __( 'Favorites', 'buddypress' ), 'slug' => 'favorites', 'parent_url' => $activity_link, 'parent_slug' => $bp->activity->slug, 'screen_function' => 'bp_activity_screen_favorites', 'position' => 40, 'item_css_id' => 'activity-favs' ) );
|
127 |
+
bp_core_new_subnav_item( array( 'name' => sprintf( __( '@%s Mentions', 'buddypress' ), $user_login ), 'slug' => 'mentions', 'parent_url' => $activity_link, 'parent_slug' => $bp->activity->slug, 'screen_function' => 'bp_activity_screen_mentions', 'position' => 50, 'item_css_id' => 'activity-mentions' ) );
|
|
|
128 |
|
129 |
if ( $bp->current_component == $bp->activity->slug ) {
|
130 |
+
if ( bp_is_my_profile() ) {
|
131 |
$bp->bp_options_title = __( 'My Activity', 'buddypress' );
|
132 |
} else {
|
133 |
$bp->bp_options_avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb' ) );
|
137 |
|
138 |
do_action( 'bp_activity_setup_nav' );
|
139 |
}
|
140 |
+
add_action( 'bp_setup_nav', 'bp_activity_setup_nav' );
|
141 |
add_action( 'admin_menu', 'bp_activity_setup_nav' );
|
142 |
|
143 |
+
function bp_activity_directory_activity_setup() {
|
144 |
+
global $bp;
|
145 |
+
|
146 |
+
if ( $bp->current_component == $bp->activity->slug && empty( $bp->current_action ) ) {
|
147 |
+
$bp->is_directory = true;
|
148 |
+
|
149 |
+
do_action( 'bp_activity_directory_activity_setup' );
|
150 |
+
bp_core_load_template( apply_filters( 'bp_activity_directory_activity_setup', 'activity/index' ) );
|
151 |
+
}
|
152 |
+
}
|
153 |
+
add_action( 'wp', 'bp_activity_directory_activity_setup', 2 );
|
154 |
+
|
155 |
|
156 |
/********************************************************************************
|
157 |
* Screen Functions
|
163 |
|
164 |
function bp_activity_screen_my_activity() {
|
165 |
do_action( 'bp_activity_screen_my_activity' );
|
166 |
+
bp_core_load_template( apply_filters( 'bp_activity_template_my_activity', 'members/single/home' ) );
|
167 |
}
|
168 |
|
169 |
+
function bp_activity_screen_friends() {
|
170 |
global $bp;
|
171 |
|
172 |
+
if ( !bp_is_active( 'friends' ) )
|
173 |
+
return false;
|
174 |
+
|
175 |
if ( !is_site_admin() )
|
176 |
$bp->is_item_admin = false;
|
177 |
|
178 |
+
do_action( 'bp_activity_screen_friends' );
|
179 |
+
bp_core_load_template( apply_filters( 'bp_activity_template_friends_activity', 'members/single/home' ) );
|
180 |
}
|
181 |
|
182 |
+
function bp_activity_screen_groups() {
|
183 |
+
global $bp;
|
184 |
+
|
185 |
+
if ( !bp_is_active( 'groups' ) )
|
186 |
+
return false;
|
187 |
+
|
188 |
+
if ( !is_site_admin() )
|
189 |
+
$bp->is_item_admin = false;
|
190 |
+
|
191 |
+
do_action( 'bp_activity_screen_groups' );
|
192 |
+
bp_core_load_template( apply_filters( 'bp_activity_template_groups_activity', 'members/single/home' ) );
|
193 |
+
}
|
194 |
+
|
195 |
+
function bp_activity_screen_favorites() {
|
196 |
+
global $bp;
|
197 |
+
|
198 |
+
if ( !is_site_admin() )
|
199 |
+
$bp->is_item_admin = false;
|
200 |
+
|
201 |
+
do_action( 'bp_activity_screen_favorites' );
|
202 |
+
bp_core_load_template( apply_filters( 'bp_activity_template_favorite_activity', 'members/single/home' ) );
|
203 |
+
}
|
204 |
+
|
205 |
+
function bp_activity_screen_mentions() {
|
206 |
+
global $bp;
|
207 |
+
|
208 |
+
if ( !is_site_admin() )
|
209 |
+
$bp->is_item_admin = false;
|
210 |
+
|
211 |
+
do_action( 'bp_activity_screen_mentions' );
|
212 |
+
bp_core_load_template( apply_filters( 'bp_activity_template_mention_activity', 'members/single/home' ) );
|
213 |
+
}
|
214 |
+
|
215 |
+
function bp_activity_screen_single_activity_permalink() {
|
216 |
+
global $bp;
|
217 |
+
|
218 |
+
if ( !$bp->displayed_user->id || $bp->current_component != $bp->activity->slug )
|
219 |
+
return false;
|
220 |
+
|
221 |
+
if ( empty( $bp->current_action ) || !is_numeric( $bp->current_action ) )
|
222 |
+
return false;
|
223 |
+
|
224 |
+
/* Get the activity details */
|
225 |
+
$activity = bp_activity_get_specific( array( 'activity_ids' => $bp->current_action ) );
|
226 |
+
|
227 |
+
if ( !$activity = $activity['activities'][0] )
|
228 |
+
bp_core_redirect( $bp->root_domain );
|
229 |
+
|
230 |
+
$has_access = true;
|
231 |
+
/* Redirect based on the type of activity */
|
232 |
+
if ( $activity->component == $bp->groups->id ) {
|
233 |
+
if ( !function_exists( 'groups_get_group' ) )
|
234 |
+
bp_core_redirect( $bp->root_domain );
|
235 |
+
|
236 |
+
if ( $group = groups_get_group( array( 'group_id' => $activity->item_id ) ) ) {
|
237 |
+
/* Check to see if the group is not public, if so, check the user has access to see this activity */
|
238 |
+
if ( 'public' != $group->status ) {
|
239 |
+
if ( !groups_is_user_member( $bp->loggedin_user->id, $group->id ) )
|
240 |
+
$has_access = false;
|
241 |
+
}
|
242 |
+
}
|
243 |
+
}
|
244 |
+
|
245 |
+
$has_access = apply_filters( 'bp_activity_permalink_access', $has_access, &$activity );
|
246 |
+
|
247 |
+
do_action( 'bp_activity_screen_single_activity_permalink', $activity, $has_access );
|
248 |
+
|
249 |
+
if ( !$has_access ) {
|
250 |
+
bp_core_add_message( __( 'You do not have access to this activity.', 'buddypress' ), 'error' );
|
251 |
+
bp_core_redirect( $bp->loggedin_user->domain );
|
252 |
+
}
|
253 |
+
|
254 |
+
bp_core_load_template( apply_filters( 'bp_activity_template_profile_activity_permalink', 'members/single/activity/permalink' ) );
|
255 |
+
}
|
256 |
+
/* This screen is not attached to a nav item, so we need to add an action for it. */
|
257 |
+
add_action( 'wp', 'bp_activity_screen_single_activity_permalink', 3 );
|
258 |
+
|
259 |
+
function bp_activity_screen_notification_settings() {
|
260 |
+
global $bp; ?>
|
261 |
+
<table class="notification-settings" id="activity-notification-settings">
|
262 |
+
<tr>
|
263 |
+
<th class="icon"></th>
|
264 |
+
<th class="title"><?php _e( 'Activity', 'buddypress' ) ?></th>
|
265 |
+
<th class="yes"><?php _e( 'Yes', 'buddypress' ) ?></th>
|
266 |
+
<th class="no"><?php _e( 'No', 'buddypress' )?></th>
|
267 |
+
</tr>
|
268 |
+
|
269 |
+
<tr>
|
270 |
+
<td></td>
|
271 |
+
<td><?php printf( __( 'A member mentions you in an update using "@%s"', 'buddypress' ), bp_core_get_username( $bp->loggedin_user->id, $bp->loggedin_user->userdata->user_nicename, $bp->loggedin_user->userdata->user_login ) ) ?></td>
|
272 |
+
<td class="yes"><input type="radio" name="notifications[notification_activity_new_mention]" value="yes" <?php if ( !get_usermeta( $bp->loggedin_user->id, 'notification_activity_new_mention' ) || 'yes' == get_usermeta( $bp->loggedin_user->id, 'notification_activity_new_mention' ) ) { ?>checked="checked" <?php } ?>/></td>
|
273 |
+
<td class="no"><input type="radio" name="notifications[notification_activity_new_mention]" value="no" <?php if ( 'no' == get_usermeta( $bp->loggedin_user->id, 'notification_activity_new_mention' ) ) { ?>checked="checked" <?php } ?>/></td>
|
274 |
+
</tr>
|
275 |
+
<tr>
|
276 |
+
<td></td>
|
277 |
+
<td><?php printf( __( "A member replies to an update or comment you've posted", 'buddypress' ), $current_user->user_login ) ?></td>
|
278 |
+
<td class="yes"><input type="radio" name="notifications[notification_activity_new_reply]" value="yes" <?php if ( !get_usermeta( $bp->loggedin_user->id, 'notification_activity_new_reply' ) || 'yes' == get_usermeta( $bp->loggedin_user->id, 'notification_activity_new_reply' ) ) { ?>checked="checked" <?php } ?>/></td>
|
279 |
+
<td class="no"><input type="radio" name="notifications[notification_activity_new_reply]" value="no" <?php if ( 'no' == get_usermeta( $bp->loggedin_user->id, 'notification_activity_new_reply' ) ) { ?>checked="checked" <?php } ?>/></td>
|
280 |
+
</tr>
|
281 |
+
|
282 |
+
<?php do_action( 'bp_activity_screen_notification_settings' ) ?>
|
283 |
+
</table>
|
284 |
+
<?php
|
285 |
+
}
|
286 |
+
add_action( 'bp_notification_settings', 'bp_activity_screen_notification_settings', 1 );
|
287 |
|
288 |
/********************************************************************************
|
289 |
* Action Functions
|
293 |
* back to the default screen after execution.
|
294 |
*/
|
295 |
|
296 |
+
function bp_activity_action_permalink_router() {
|
297 |
+
global $bp;
|
298 |
+
|
299 |
+
if ( $bp->current_component != $bp->activity->slug || $bp->current_action != 'p' )
|
300 |
+
return false;
|
301 |
+
|
302 |
+
if ( empty( $bp->action_variables[0] ) || !is_numeric( $bp->action_variables[0] ) )
|
303 |
+
return false;
|
304 |
+
|
305 |
+
/* Get the activity details */
|
306 |
+
$activity = bp_activity_get_specific( array( 'activity_ids' => $bp->action_variables[0] ) );
|
307 |
+
|
308 |
+
if ( !$activity = $activity['activities'][0] )
|
309 |
+
bp_core_redirect( $bp->root_domain );
|
310 |
+
|
311 |
+
$redirect = false;
|
312 |
+
/* Redirect based on the type of activity */
|
313 |
+
if ( $activity->component == $bp->groups->id ) {
|
314 |
+
if ( $activity->user_id )
|
315 |
+
$redirect = bp_core_get_user_domain( $activity->user_id, $activity->user_nicename, $activity->user_login ) . $bp->activity->slug . '/' . $activity->id;
|
316 |
+
else {
|
317 |
+
if ( $group = groups_get_group( array( 'group_id' => $activity->item_id ) ) )
|
318 |
+
$redirect = bp_get_group_permalink( $group ) . $bp->activity->slug . '/' . $activity->id;
|
319 |
+
}
|
320 |
+
} else
|
321 |
+
$redirect = bp_core_get_user_domain( $activity->user_id, $activity->user_nicename, $activity->user_login ) . $bp->activity->slug . '/' . $activity->id;
|
322 |
+
|
323 |
+
if ( !$redirect )
|
324 |
+
bp_core_redirect( $bp->root_domain );
|
325 |
+
|
326 |
+
/* Redirect to the actual activity permalink page */
|
327 |
+
bp_core_redirect( apply_filters( 'bp_activity_action_permalink_url', $redirect . '/', &$activity ) );
|
328 |
+
}
|
329 |
+
add_action( 'wp', 'bp_activity_action_permalink_router', 3 );
|
330 |
+
|
331 |
function bp_activity_action_delete_activity() {
|
332 |
global $bp;
|
333 |
|
341 |
check_admin_referer( 'bp_activity_delete_link' );
|
342 |
|
343 |
$activity_id = $bp->action_variables[0];
|
344 |
+
$activity = new BP_Activity_Activity( $activity_id );
|
345 |
|
346 |
/* Check access */
|
347 |
+
if ( !is_site_admin() && $activity->user_id != $bp->loggedin_user->id )
|
348 |
+
return false;
|
349 |
|
350 |
+
/* Call the action before the delete so plugins can still fetch information about it */
|
351 |
+
do_action( 'bp_activity_action_delete_activity', $activity_id, $activity->user_id );
|
|
|
352 |
|
353 |
/* Now delete the activity item */
|
354 |
+
if ( bp_activity_delete( array( 'id' => $activity_id, 'user_id' => $activity->user_id ) ) )
|
355 |
bp_core_add_message( __( 'Activity deleted', 'buddypress' ) );
|
356 |
else
|
357 |
bp_core_add_message( __( 'There was an error when deleting that activity', 'buddypress' ), 'error' );
|
358 |
|
359 |
+
bp_core_redirect( wp_get_referer() );
|
|
|
|
|
360 |
}
|
361 |
add_action( 'wp', 'bp_activity_action_delete_activity', 3 );
|
362 |
|
363 |
+
function bp_activity_action_post_update() {
|
364 |
+
global $bp;
|
365 |
+
|
366 |
+
if ( !is_user_logged_in() || $bp->current_component != $bp->activity->slug || $bp->current_action != 'post' )
|
367 |
+
return false;
|
368 |
+
|
369 |
+
/* Check the nonce */
|
370 |
+
check_admin_referer( 'post_update', '_wpnonce_post_update' );
|
371 |
+
|
372 |
+
$content = apply_filters( 'bp_activity_post_update_content', $_POST['whats-new'] );
|
373 |
+
$object = apply_filters( 'bp_activity_post_update_object', $_POST['whats-new-post-object'] );
|
374 |
+
$item_id = apply_filters( 'bp_activity_post_update_item_id', $_POST['whats-new-post-in'] );
|
375 |
+
|
376 |
+
if ( empty( $content ) ) {
|
377 |
+
bp_core_add_message( __( 'Please enter some content to post.', 'buddypress' ), 'error' );
|
378 |
+
bp_core_redirect( wp_get_referer() );
|
379 |
+
}
|
380 |
+
|
381 |
+
if ( !(int)$item_id ) {
|
382 |
+
$activity_id = bp_activity_post_update( array( 'content' => $content ) );
|
383 |
+
|
384 |
+
} else if ( 'groups' == $object && function_exists( 'groups_post_update' ) ) {
|
385 |
+
if ( (int)$item_id ) {
|
386 |
+
$activity_id = groups_post_update( array( 'content' => $content, 'group_id' => $item_id ) );
|
387 |
+
}
|
388 |
+
} else
|
389 |
+
$activity_id = apply_filters( 'bp_activity_custom_update', $object, $item_id, $content );
|
390 |
+
|
391 |
+
if ( !empty( $activity_id ) )
|
392 |
+
bp_core_add_message( __( 'Update Posted!', 'buddypress' ) );
|
393 |
+
else
|
394 |
+
bp_core_add_message( __( 'There was an error when posting your update, please try again.', 'buddypress' ), 'error' );
|
395 |
+
|
396 |
+
bp_core_redirect( wp_get_referer() );
|
397 |
+
}
|
398 |
+
add_action( 'wp', 'bp_activity_action_post_update', 3 );
|
399 |
+
|
400 |
+
function bp_activity_action_post_comment() {
|
401 |
+
global $bp;
|
402 |
+
|
403 |
+
if ( !is_user_logged_in() || $bp->current_component != $bp->activity->slug || $bp->current_action != 'reply' )
|
404 |
+
return false;
|
405 |
+
|
406 |
+
/* Check the nonce */
|
407 |
+
check_admin_referer( 'new_activity_comment', '_wpnonce_new_activity_comment' );
|
408 |
+
|
409 |
+
$activity_id = apply_filters( 'bp_activity_post_comment_activity_id', $_POST['comment_form_id'] );
|
410 |
+
$content = apply_filters( 'bp_activity_post_comment_content', $_POST['ac_input_' . $activity_id] );
|
411 |
+
|
412 |
+
if ( empty( $content ) ) {
|
413 |
+
bp_core_add_message( __( 'Please do not leave the comment area blank.', 'buddypress' ), 'error' );
|
414 |
+
bp_core_redirect( wp_get_referer() . '#ac-form-' . $activity_id );
|
415 |
+
}
|
416 |
+
|
417 |
+
$comment_id = bp_activity_new_comment( array(
|
418 |
+
'content' => $content,
|
419 |
+
'activity_id' => $activity_id,
|
420 |
+
'parent_id' => $parent_id
|
421 |
+
));
|
422 |
+
|
423 |
+
if ( !empty( $comment_id ) )
|
424 |
+
bp_core_add_message( __( 'Reply Posted!', 'buddypress' ) );
|
425 |
+
else
|
426 |
+
bp_core_add_message( __( 'There was an error posting that reply, please try again.', 'buddypress' ), 'error' );
|
427 |
+
|
428 |
+
bp_core_redirect( wp_get_referer() . '#ac-form-' . $activity_id );
|
429 |
+
}
|
430 |
+
add_action( 'wp', 'bp_activity_action_post_comment', 3 );
|
431 |
+
|
432 |
+
function bp_activity_action_mark_favorite() {
|
433 |
+
global $bp;
|
434 |
+
|
435 |
+
if ( !is_user_logged_in() || $bp->current_component != $bp->activity->slug || $bp->current_action != 'favorite' )
|
436 |
+
return false;
|
437 |
+
|
438 |
+
/* Check the nonce */
|
439 |
+
check_admin_referer( 'mark_favorite' );
|
440 |
+
|
441 |
+
if ( bp_activity_add_user_favorite( $bp->action_variables[0] ) )
|
442 |
+
bp_core_add_message( __( 'Activity marked as favorite.', 'buddypress' ) );
|
443 |
+
else
|
444 |
+
bp_core_add_message( __( 'There was an error marking that activity as a favorite, please try again.', 'buddypress' ), 'error' );
|
445 |
+
|
446 |
+
bp_core_redirect( wp_get_referer() . '#activity-' . $bp->action_variables[0] );
|
447 |
+
}
|
448 |
+
add_action( 'wp', 'bp_activity_action_mark_favorite', 3 );
|
449 |
+
|
450 |
+
function bp_activity_action_remove_favorite() {
|
451 |
+
global $bp;
|
452 |
+
|
453 |
+
if ( !is_user_logged_in() || $bp->current_component != $bp->activity->slug || $bp->current_action != 'unfavorite' )
|
454 |
+
return false;
|
455 |
+
|
456 |
+
/* Check the nonce */
|
457 |
+
check_admin_referer( 'unmark_favorite' );
|
458 |
+
|
459 |
+
if ( bp_activity_remove_user_favorite( $bp->action_variables[0] ) )
|
460 |
+
bp_core_add_message( __( 'Activity removed as favorite.', 'buddypress' ) );
|
461 |
+
else
|
462 |
+
bp_core_add_message( __( 'There was an error removing that activity as a favorite, please try again.', 'buddypress' ), 'error' );
|
463 |
+
|
464 |
+
bp_core_redirect( wp_get_referer() . '#activity-' . $bp->action_variables[0] );
|
465 |
+
}
|
466 |
+
add_action( 'wp', 'bp_activity_action_remove_favorite', 3 );
|
467 |
|
468 |
function bp_activity_action_sitewide_feed() {
|
469 |
global $bp, $wp_query;
|
470 |
|
471 |
+
if ( $bp->current_component != $bp->activity->slug || $bp->current_action != 'feed' || $bp->displayed_user->id || $bp->groups->current_group )
|
472 |
return false;
|
473 |
|
474 |
$wp_query->is_404 = false;
|
496 |
function bp_activity_action_friends_feed() {
|
497 |
global $bp, $wp_query;
|
498 |
|
499 |
+
if ( $bp->current_component != $bp->activity->slug || !$bp->displayed_user->id || $bp->current_action != 'friends' || $bp->action_variables[0] != 'feed' )
|
500 |
return false;
|
501 |
|
502 |
$wp_query->is_404 = false;
|
507 |
}
|
508 |
add_action( 'wp', 'bp_activity_action_friends_feed', 3 );
|
509 |
|
510 |
+
function bp_activity_action_my_groups_feed() {
|
511 |
+
global $bp, $wp_query;
|
512 |
+
|
513 |
+
if ( $bp->current_component != $bp->activity->slug || !$bp->displayed_user->id || $bp->current_action != 'groups' || $bp->action_variables[0] != 'feed' )
|
514 |
+
return false;
|
515 |
+
|
516 |
+
$wp_query->is_404 = false;
|
517 |
+
status_header( 200 );
|
518 |
+
|
519 |
+
include_once( 'bp-activity/feeds/bp-activity-mygroups-feed.php' );
|
520 |
+
die;
|
521 |
+
}
|
522 |
+
add_action( 'wp', 'bp_activity_action_my_groups_feed', 3 );
|
523 |
+
|
524 |
+
function bp_activity_action_mentions_feed() {
|
525 |
+
global $bp, $wp_query;
|
526 |
+
|
527 |
+
if ( $bp->current_component != $bp->activity->slug || !$bp->displayed_user->id || $bp->current_action != 'mentions' || $bp->action_variables[0] != 'feed' )
|
528 |
+
return false;
|
529 |
+
|
530 |
+
$wp_query->is_404 = false;
|
531 |
+
status_header( 200 );
|
532 |
+
|
533 |
+
include_once( 'bp-activity/feeds/bp-activity-mentions-feed.php' );
|
534 |
+
die;
|
535 |
+
}
|
536 |
+
add_action( 'wp', 'bp_activity_action_mentions_feed', 3 );
|
537 |
+
|
538 |
+
function bp_activity_action_favorites_feed() {
|
539 |
+
global $bp, $wp_query;
|
540 |
+
|
541 |
+
if ( $bp->current_component != $bp->activity->slug || !$bp->displayed_user->id || $bp->current_action != 'favorites' || $bp->action_variables[0] != 'feed' )
|
542 |
+
return false;
|
543 |
+
|
544 |
+
$wp_query->is_404 = false;
|
545 |
+
status_header( 200 );
|
546 |
+
|
547 |
+
include_once( 'bp-activity/feeds/bp-activity-favorites-feed.php' );
|
548 |
+
die;
|
549 |
+
}
|
550 |
+
add_action( 'wp', 'bp_activity_action_favorites_feed', 3 );
|
551 |
|
552 |
/********************************************************************************
|
553 |
* Business Functions
|
558 |
* true or false on success or failure.
|
559 |
*/
|
560 |
|
561 |
+
function bp_activity_get( $args = '' ) {
|
562 |
+
$defaults = array(
|
563 |
+
'max' => false, // Maximum number of results to return
|
564 |
+
'page' => 1, // page 1 without a per_page will result in no pagination.
|
565 |
+
'per_page' => false, // results per page
|
566 |
+
'sort' => 'DESC', // sort ASC or DESC
|
567 |
+
'display_comments' => false, // false for no comments. 'stream' for within stream display, 'threaded' for below each activity item
|
568 |
+
|
569 |
+
'search_terms' => false, // Pass search terms as a string
|
570 |
+
'show_hidden' => false, // Show activity items that are hidden site-wide?
|
571 |
+
|
572 |
+
/**
|
573 |
+
* Pass filters as an array -- all filter items can be multiple values comma separated:
|
574 |
+
* array(
|
575 |
+
* 'user_id' => false, // user_id to filter on
|
576 |
+
* 'object' => false, // object to filter on e.g. groups, profile, status, friends
|
577 |
+
* 'action' => false, // action to filter on e.g. activity_update, profile_updated
|
578 |
+
* 'primary_id' => false, // object ID to filter on e.g. a group_id or forum_id or blog_id etc.
|
579 |
+
* 'secondary_id' => false, // secondary object ID to filter on e.g. a post_id
|
580 |
+
* );
|
581 |
+
*/
|
582 |
+
'filter' => array()
|
583 |
+
);
|
584 |
+
|
585 |
+
$r = wp_parse_args( $args, $defaults );
|
586 |
+
extract( $r, EXTR_SKIP );
|
587 |
+
|
588 |
+
/* Attempt to return a cached copy of the first page of sitewide activity. */
|
589 |
+
if ( 1 == (int)$page && empty( $max ) && empty( $search_terms ) && empty( $filter ) && 'DESC' == $sort ) {
|
590 |
+
if ( !$activity = wp_cache_get( 'bp_activity_sitewide_front', 'bp' ) ) {
|
591 |
+
$activity = BP_Activity_Activity::get( $max, $page, $per_page, $sort, $search_terms, $filter, $display_comments, $show_hidden );
|
592 |
+
wp_cache_set( 'bp_activity_sitewide_front', BP_Activity_Activity::get( $max, $page, $per_page, $sort, $search_terms, $filter, $display_comments, $show_hidden ), 'bp' );
|
593 |
+
}
|
594 |
+
} else
|
595 |
+
$activity = BP_Activity_Activity::get( $max, $page, $per_page, $sort, $search_terms, $filter, $display_comments, $show_hidden );
|
596 |
+
|
597 |
+
return apply_filters( 'bp_activity_get', $activity, &$r );
|
598 |
+
}
|
599 |
+
|
600 |
+
function bp_activity_get_specific( $args = '' ) {
|
601 |
+
$defaults = array(
|
602 |
+
'activity_ids' => false, // A single activity_id or array of IDs.
|
603 |
+
'page' => 1, // page 1 without a per_page will result in no pagination.
|
604 |
+
'per_page' => false, // results per page
|
605 |
+
'max' => false, // Maximum number of results to return
|
606 |
+
'sort' => 'DESC', // sort ASC or DESC
|
607 |
+
'display_comments' => false // true or false to display threaded comments for these specific activity items
|
608 |
+
);
|
609 |
+
|
610 |
+
$r = wp_parse_args( $args, $defaults );
|
611 |
+
extract( $r, EXTR_SKIP );
|
612 |
+
|
613 |
+
return apply_filters( 'bp_activity_get_specific', BP_Activity_Activity::get_specific( $activity_ids, $max, $page, $per_page, $sort, $display_comments ) );
|
614 |
+
}
|
615 |
+
|
616 |
function bp_activity_add( $args = '' ) {
|
617 |
global $bp, $wpdb;
|
618 |
|
619 |
$defaults = array(
|
620 |
+
'id' => false, // Pass an existing activity ID to update an existing entry.
|
621 |
+
|
622 |
+
'action' => '', // The activity action - e.g. "Jon Doe posted an update"
|
623 |
+
'content' => '', // Optional: The content of the activity item e.g. "BuddyPress is awesome guys!"
|
624 |
+
|
625 |
+
'component' => false, // The name/ID of the component e.g. groups, profile, mycomponent
|
626 |
+
'type' => false, // The activity type e.g. activity_update, profile_updated
|
627 |
+
'primary_link' => '', // Optional: The primary URL for this item in RSS feeds (defaults to activity permalink)
|
628 |
|
629 |
'user_id' => $bp->loggedin_user->id, // Optional: The user to record the activity for, can be false if this activity is not for a user.
|
630 |
+
'item_id' => false, // Optional: The ID of the specific item being recorded, e.g. a blog_id
|
631 |
'secondary_item_id' => false, // Optional: A second ID used to further filter e.g. a comment_id
|
632 |
+
'recorded_time' => gmdate( "Y-m-d H:i:s" ), // The GMT time that this activity was recorded
|
633 |
'hide_sitewide' => false // Should this be hidden on the sitewide activity stream?
|
634 |
);
|
635 |
|
636 |
+
$params = wp_parse_args( $args, $defaults );
|
637 |
+
extract( $params, EXTR_SKIP );
|
638 |
+
|
639 |
+
/* Make sure we are backwards compatible */
|
640 |
+
if ( empty( $component ) && !empty( $component_name ) )
|
641 |
+
$component = $component_name;
|
642 |
|
643 |
+
if ( empty( $type ) && !empty( $component_action ) )
|
644 |
+
$type = $component_action;
|
645 |
+
|
646 |
+
$activity = new BP_Activity_Activity( $id );
|
647 |
|
|
|
648 |
$activity->user_id = $user_id;
|
649 |
+
$activity->component = $component;
|
650 |
+
$activity->type = $type;
|
651 |
+
$activity->action = $action;
|
652 |
$activity->content = $content;
|
653 |
$activity->primary_link = $primary_link;
|
|
|
|
|
654 |
$activity->item_id = $item_id;
|
655 |
$activity->secondary_item_id = $secondary_item_id;
|
656 |
$activity->date_recorded = $recorded_time;
|
659 |
if ( !$activity->save() )
|
660 |
return false;
|
661 |
|
662 |
+
/* If this is an activity comment, rebuild the tree */
|
663 |
+
if ( 'activity_comment' == $activity->type )
|
664 |
+
BP_Activity_Activity::rebuild_activity_comment_tree( $activity->item_id );
|
665 |
|
666 |
+
wp_cache_delete( 'bp_activity_sitewide_front', 'bp' );
|
667 |
+
do_action( 'bp_activity_add', $params );
|
668 |
|
669 |
+
return $activity->id;
|
670 |
+
}
|
671 |
|
672 |
+
function bp_activity_post_update( $args = '' ) {
|
673 |
global $bp;
|
674 |
|
675 |
$defaults = array(
|
676 |
+
'content' => false,
|
677 |
+
'user_id' => $bp->loggedin_user->id
|
|
|
|
|
|
|
678 |
);
|
679 |
|
680 |
$r = wp_parse_args( $args, $defaults );
|
681 |
extract( $r, EXTR_SKIP );
|
682 |
|
683 |
+
if ( empty( $content ) || !strlen( trim( $content ) ) )
|
684 |
return false;
|
685 |
|
686 |
+
/* Record this on the user's profile */
|
687 |
+
$from_user_link = bp_core_get_userlink( $user_id );
|
688 |
+
$activity_action = sprintf( __( '%s posted an update:', 'buddypress' ), $from_user_link );
|
689 |
+
$activity_content = $content;
|
690 |
|
691 |
+
$primary_link = bp_core_get_userlink( $user_id, false, true );
|
692 |
+
|
693 |
+
/* Now write the values */
|
694 |
+
$activity_id = bp_activity_add( array(
|
695 |
+
'user_id' => $user_id,
|
696 |
+
'action' => apply_filters( 'bp_activity_new_update_action', $activity_action ),
|
697 |
+
'content' => apply_filters( 'bp_activity_new_update_content', $activity_content ),
|
698 |
+
'primary_link' => apply_filters( 'bp_activity_new_update_primary_link', $primary_link ),
|
699 |
+
'component' => $bp->activity->id,
|
700 |
+
'type' => 'activity_update'
|
701 |
+
) );
|
702 |
+
|
703 |
+
/* Add this update to the "latest update" usermeta so it can be fetched anywhere. */
|
704 |
+
update_usermeta( $bp->loggedin_user->id, 'bp_latest_update', array( 'id' => $activity_id, 'content' => wp_filter_kses( $content ) ) );
|
705 |
+
|
706 |
+
/* Require the notifications code so email notifications can be set on the 'bp_activity_posted_update' action. */
|
707 |
+
require_once( BP_PLUGIN_DIR . '/bp-activity/bp-activity-notifications.php' );
|
708 |
+
|
709 |
+
do_action( 'bp_activity_posted_update', $content, $user_id, $activity_id );
|
710 |
+
|
711 |
+
return $activity_id;
|
712 |
}
|
713 |
|
714 |
+
function bp_activity_new_comment( $args = '' ) {
|
715 |
+
global $bp;
|
716 |
+
|
717 |
+
$defaults = array(
|
718 |
+
'content' => false,
|
719 |
+
'user_id' => $bp->loggedin_user->id,
|
720 |
+
'activity_id' => false, // ID of the root activity item
|
721 |
+
'parent_id' => false // ID of a parent comment (optional)
|
722 |
+
);
|
723 |
+
|
724 |
+
$params = wp_parse_args( $args, $defaults );
|
725 |
+
extract( $params, EXTR_SKIP );
|
726 |
+
|
727 |
+
if ( empty($content) || empty($user_id) || empty($activity_id) )
|
728 |
return false;
|
729 |
|
730 |
+
if ( empty($parent_id) )
|
731 |
+
$parent_id = $activity_id;
|
732 |
|
733 |
+
/* Check to see if the parent activity is hidden, and if so, hide this comment publically. */
|
734 |
+
$activity = new BP_Activity_Activity( $activity_id );
|
735 |
+
$is_hidden = ( (int)$activity->hide_sitewide ) ? 1 : 0;
|
736 |
+
|
737 |
+
/* Insert the activity comment */
|
738 |
+
$comment_id = bp_activity_add( array(
|
739 |
+
'action' => apply_filters( 'bp_activity_comment_action', sprintf( __( '%s posted a new activity comment:', 'buddypress' ), bp_core_get_userlink( $user_id ) ) ),
|
740 |
+
'content' => apply_filters( 'bp_activity_comment_content', $content ),
|
741 |
+
'component' => $bp->activity->id,
|
742 |
+
'type' => 'activity_comment',
|
743 |
+
'user_id' => $user_id,
|
744 |
+
'item_id' => $activity_id,
|
745 |
+
'secondary_item_id' => $parent_id,
|
746 |
+
'hide_sitewide' => $is_hidden
|
747 |
+
) );
|
748 |
+
|
749 |
+
/* Send an email notification if settings allow */
|
750 |
+
require_once( BP_PLUGIN_DIR . '/bp-activity/bp-activity-notifications.php' );
|
751 |
+
bp_activity_new_comment_notification( $comment_id, $user_id, $params );
|
752 |
+
|
753 |
+
/* Clear the comment cache for this activity */
|
754 |
+
wp_cache_delete( 'bp_activity_comments_' . $parent_id );
|
755 |
+
|
756 |
+
do_action( 'bp_activity_comment_posted', $comment_id, $params );
|
757 |
+
|
758 |
+
return $comment_id;
|
759 |
+
}
|
760 |
+
|
761 |
+
/**
|
762 |
+
* bp_activity_get_activity_id()
|
763 |
+
*
|
764 |
+
* Fetch the activity_id for an existing activity entry in the DB.
|
765 |
+
*
|
766 |
+
* @package BuddyPress Activity
|
767 |
+
*/
|
768 |
+
function bp_activity_get_activity_id( $args = '' ) {
|
769 |
+
$defaults = array(
|
770 |
+
'user_id' => false,
|
771 |
+
'component' => false,
|
772 |
+
'type' => false,
|
773 |
+
'item_id' => false,
|
774 |
+
'secondary_item_id' => false,
|
775 |
+
'action' => false,
|
776 |
+
'content' => false
|
777 |
+
);
|
778 |
+
|
779 |
+
$r = wp_parse_args( $args, $defaults );
|
780 |
+
extract( $r, EXTR_SKIP );
|
781 |
+
|
782 |
+
return apply_filters( 'bp_activity_get_activity_id', BP_Activity_Activity::get_id( $user_id, $component, $type, $item_id, $secondary_item_id, $action, $content ) );
|
783 |
}
|
784 |
|
785 |
+
/***
|
786 |
+
* Deleting Activity
|
787 |
+
*
|
788 |
+
* If you're looking to hook into one action that provides the ID(s) of
|
789 |
+
* the activity/activities deleted, then use:
|
790 |
+
*
|
791 |
+
* add_action( 'bp_activity_deleted_activities', 'my_function' );
|
792 |
+
*
|
793 |
+
* The action passes one parameter that is a single activity ID or an
|
794 |
+
* array of activity IDs depending on the number deleted.
|
795 |
+
*
|
796 |
+
* If you are deleting an activity comment please use bp_activity_delete_comment();
|
797 |
+
*/
|
798 |
+
|
799 |
+
function bp_activity_delete( $args = '' ) {
|
800 |
+
global $bp;
|
801 |
+
|
802 |
+
/* Pass one or more the of following variables to delete by those variables */
|
803 |
+
$defaults = array(
|
804 |
+
'id' => false,
|
805 |
+
'action' => false,
|
806 |
+
'content' => false,
|
807 |
+
'component' => false,
|
808 |
+
'type' => false,
|
809 |
+
'primary_link' => false,
|
810 |
+
'user_id' => false,
|
811 |
+
'item_id' => false,
|
812 |
+
'secondary_item_id' => false,
|
813 |
+
'date_recorded' => false,
|
814 |
+
'hide_sitewide' => false
|
815 |
+
);
|
816 |
+
|
817 |
+
$args = wp_parse_args( $args, $defaults );
|
818 |
|
819 |
+
if ( !$activity_ids_deleted = BP_Activity_Activity::delete( $args ) )
|
820 |
return false;
|
821 |
|
822 |
+
/* Check if the user's latest update has been deleted */
|
823 |
+
if ( empty( $args['user_id'] ) )
|
824 |
+
$user_id = $bp->loggedin_user->id;
|
825 |
+
else
|
826 |
+
$user_id = $args['user_id'];
|
827 |
+
|
828 |
+
$latest_update = get_usermeta( $user_id, 'bp_latest_update' );
|
829 |
+
if ( !empty( $latest_update ) ) {
|
830 |
+
if ( in_array( (int)$latest_update['id'], (array)$activity_ids_deleted ) )
|
831 |
+
delete_usermeta( $user_id, 'bp_latest_update' );
|
832 |
+
}
|
833 |
+
|
834 |
+
do_action( 'bp_activity_delete', $args );
|
835 |
+
do_action( 'bp_activity_deleted_activities', $activity_ids_deleted );
|
836 |
+
|
837 |
+
wp_cache_delete( 'bp_activity_sitewide_front', 'bp' );
|
838 |
|
839 |
return true;
|
840 |
}
|
841 |
+
/* The following functions have been deprecated in place of bp_activity_delete() */
|
842 |
+
function bp_activity_delete_by_item_id( $args = '' ) {
|
843 |
+
global $bp;
|
844 |
+
|
845 |
+
$defaults = array( 'item_id' => false, 'component' => false, 'type' => false, 'user_id' => false, 'secondary_item_id' => false );
|
846 |
+
$r = wp_parse_args( $args, $defaults );
|
847 |
+
extract( $r, EXTR_SKIP );
|
848 |
+
|
849 |
+
return bp_activity_delete( array( 'item_id' => $item_id, 'component' => $component, 'type' => $type, 'user_id' => $user_id, 'secondary_item_id' => $secondary_item_id ) );
|
850 |
+
}
|
851 |
+
|
852 |
+
function bp_activity_delete_by_activity_id( $activity_id ) {
|
853 |
+
return bp_activity_delete( array( 'id' => $activity_id ) );
|
854 |
+
}
|
855 |
|
856 |
+
function bp_activity_delete_by_content( $user_id, $content, $component, $type ) {
|
857 |
+
return bp_activity_delete( array( 'user_id' => $user_id, 'content' => $content, 'component' => $component, 'type' => $type ) );
|
858 |
+
}
|
859 |
+
|
860 |
+
function bp_activity_delete_for_user_by_component( $user_id, $component ) {
|
861 |
+
return bp_activity_delete( array( 'user_id' => $user_id, 'component' => $component ) );
|
862 |
+
}
|
863 |
+
/* End deprecation */
|
864 |
+
|
865 |
+
function bp_activity_delete_comment( $activity_id, $comment_id ) {
|
866 |
+
/***
|
867 |
+
* You may want to hook into this filter if you want to override this function and
|
868 |
+
* handle the deletion of child comments differently. Make sure you return false.
|
869 |
+
*/
|
870 |
+
if ( !apply_filters( 'bp_activity_delete_comment_pre', true, $activity_id, $comment_id ) )
|
871 |
+
return false;
|
872 |
+
|
873 |
+
/* Delete any children of this comment. */
|
874 |
+
bp_activity_delete_children( $activity_id, $comment_id );
|
875 |
+
|
876 |
+
/* Delete the actual comment */
|
877 |
+
if ( !bp_activity_delete( array( 'id' => $comment_id, 'type' => 'activity_comment' ) ) )
|
878 |
return false;
|
879 |
|
880 |
+
/* Recalculate the comment tree */
|
881 |
+
BP_Activity_Activity::rebuild_activity_comment_tree( $activity_id );
|
882 |
+
|
883 |
+
do_action( 'bp_activity_delete_comment', $activity_id, $comment_id );
|
884 |
|
885 |
return true;
|
886 |
}
|
887 |
+
function bp_activity_delete_children( $activity_id, $comment_id) {
|
888 |
+
/* Recursively delete all children of this comment. */
|
889 |
+
if ( $children = BP_Activity_Activity::get_child_comments( $comment_id ) ) {
|
890 |
+
foreach( (array)$children as $child )
|
891 |
+
bp_activity_delete_children( $activity_id, $child->id );
|
|
|
|
|
|
|
|
|
|
|
892 |
}
|
893 |
+
bp_activity_delete( array( 'secondary_item_id' => $comment_id, 'type' => 'activity_comment', 'item_id' => $activity_id ) );
|
894 |
}
|
895 |
|
896 |
+
function bp_activity_get_permalink( $activity_id, $activity_obj = false ) {
|
897 |
+
global $bp;
|
898 |
+
|
899 |
+
if ( !$activity_obj )
|
900 |
+
$activity_obj = new BP_Activity_Activity( $activity_id );
|
901 |
|
902 |
+
if ( 'new_blog_post' == $activity_obj->type || 'new_blog_comment' == $activity_obj->type || 'new_forum_topic' == $activity_obj->type || 'new_forum_post' == $activity_obj->type )
|
903 |
+
$link = $activity_obj->primary_link;
|
904 |
+
else {
|
905 |
+
if ( 'activity_comment' == $activity_obj->type )
|
906 |
+
$link = $bp->root_domain . '/' . BP_ACTIVITY_SLUG . '/p/' . $activity_obj->item_id . '/';
|
907 |
+
else
|
908 |
+
$link = $bp->root_domain . '/' . BP_ACTIVITY_SLUG . '/p/' . $activity_obj->id . '/';
|
909 |
}
|
910 |
|
911 |
+
return apply_filters( 'bp_activity_get_permalink', $link );
|
912 |
+
}
|
913 |
+
|
914 |
+
function bp_activity_hide_user_activity( $user_id ) {
|
915 |
+
return BP_Activity_Activity::hide_all_for_user( $user_id );
|
916 |
+
}
|
917 |
+
|
918 |
+
/**
|
919 |
+
* bp_activity_thumbnail_content_images()
|
920 |
+
*
|
921 |
+
* Take content, remove all images and replace them with one thumbnail image.
|
922 |
+
*
|
923 |
+
* @package BuddyPress Activity
|
924 |
+
* @param $content str - The content to work with
|
925 |
+
* @return $content str - The content with images stripped and replaced with a single thumb.
|
926 |
+
*/
|
927 |
+
function bp_activity_thumbnail_content_images( $content ) {
|
928 |
+
preg_match_all( '/<img[^>]*>/Ui', $content, $matches );
|
929 |
+
$content = preg_replace('/<img[^>]*>/Ui', '', $content );
|
930 |
+
|
931 |
+
if ( !empty( $matches ) ) {
|
932 |
+
/* Get the SRC value */
|
933 |
+
preg_match( '/<img.*?(src\=[\'|"]{0,1}.*?[\'|"]{0,1})[\s|>]{1}/i', $matches[0][0], $src );
|
934 |
+
|
935 |
+
/* Get the width and height */
|
936 |
+
preg_match( '/<img.*?(height\=[\'|"]{0,1}.*?[\'|"]{0,1})[\s|>]{1}/i', $matches[0][0], $height );
|
937 |
+
preg_match( '/<img.*?(width\=[\'|"]{0,1}.*?[\'|"]{0,1})[\s|>]{1}/i', $matches[0][0], $width );
|
938 |
+
|
939 |
+
if ( !empty( $src ) ) {
|
940 |
+
$src = substr( substr( str_replace( 'src=', '', $src[1] ), 0, -1 ), 1 );
|
941 |
+
$height = substr( substr( str_replace( 'height=', '', $height[1] ), 0, -1 ), 1 );
|
942 |
+
$width = substr( substr( str_replace( 'width=', '', $width[1] ), 0, -1 ), 1 );
|
943 |
+
|
944 |
+
if ( empty( $width ) || empty( $height ) ) {
|
945 |
+
$width = 100;
|
946 |
+
$height = 100;
|
947 |
+
}
|
948 |
+
|
949 |
+
$ratio = (int)$width / (int)$height;
|
950 |
+
$new_height = 100;
|
951 |
+
$new_width = $new_height * $ratio;
|
952 |
+
|
953 |
+
$content = '<img src="' . esc_attr( $src) . '" width="' . $new_width . '" height="' . $new_height . '" alt="' . __( 'Thumbnail', 'buddypress' ) . '" class="align-left thumbnail" />' . $content;
|
954 |
+
}
|
955 |
+
}
|
956 |
+
|
957 |
+
return apply_filters( 'bp_activity_thumbnail_content_images', $content, $matches );
|
958 |
}
|
959 |
|
960 |
function bp_activity_set_action( $component_id, $key, $value ) {
|
978 |
return apply_filters( 'bp_activity_get_action', $bp->activity->actions->{$component_id}->{$key}, $component_id, $key );
|
979 |
}
|
980 |
|
981 |
+
function bp_activity_get_user_favorites( $user_id ) {
|
982 |
+
$my_favs = maybe_unserialize( get_usermeta( $user_id, 'bp_favorite_activities' ) );
|
983 |
+
$existing_favs = bp_activity_get_specific( array( 'activity_ids' => $my_favs ) );
|
984 |
+
|
985 |
+
foreach( (array)$existing_favs['activities'] as $fav )
|
986 |
+
$new_favs[] = $fav->id;
|
987 |
+
|
988 |
+
$new_favs = array_unique( (array)$new_favs );
|
989 |
+
update_usermeta( $user_id, 'bp_favorite_activities', $new_favs );
|
990 |
+
|
991 |
+
return apply_filters( 'bp_activity_get_user_favorites', $new_favs );
|
992 |
+
}
|
993 |
+
|
994 |
+
function bp_activity_add_user_favorite( $activity_id, $user_id = false ) {
|
995 |
+
global $bp;
|
996 |
+
|
997 |
+
if ( !$user_id )
|
998 |
+
$user_id = $bp->loggedin_user->id;
|
999 |
+
|
1000 |
+
/* Update the user's personal favorites */
|
1001 |
+
$my_favs = maybe_unserialize( get_usermeta( $bp->loggedin_user->id, 'bp_favorite_activities' ) );
|
1002 |
+
$my_favs[] = $activity_id;
|
1003 |
+
|
1004 |
+
/* Update the total number of users who have favorited this activity */
|
1005 |
+
$fav_count = bp_activity_get_meta( $activity_id, 'favorite_count' );
|
1006 |
+
|
1007 |
+
if ( !empty( $fav_count ) )
|
1008 |
+
$fav_count = (int)$fav_count + 1;
|
1009 |
+
else
|
1010 |
+
$fav_count = 1;
|
1011 |
+
|
1012 |
+
update_usermeta( $bp->loggedin_user->id, 'bp_favorite_activities', $my_favs );
|
1013 |
+
bp_activity_update_meta( $activity_id, 'favorite_count', $fav_count );
|
1014 |
+
|
1015 |
+
return true;
|
1016 |
+
}
|
1017 |
+
|
1018 |
+
function bp_activity_remove_user_favorite( $activity_id, $user_id = false ) {
|
1019 |
+
global $bp;
|
1020 |
+
|
1021 |
+
if ( !$user_id )
|
1022 |
+
$user_id = $bp->loggedin_user->id;
|
1023 |
|
1024 |
+
/* Remove the fav from the user's favs */
|
1025 |
+
$my_favs = maybe_unserialize( get_usermeta( $user_id, 'bp_favorite_activities' ) );
|
1026 |
+
$my_favs = array_flip( (array) $my_favs );
|
1027 |
+
unset( $my_favs[$activity_id] );
|
1028 |
+
$my_favs = array_unique( array_flip( $my_favs ) );
|
1029 |
+
|
1030 |
+
/* Update the total number of users who have favorited this activity */
|
1031 |
+
$fav_count = bp_activity_get_meta( $activity_id, 'favorite_count' );
|
1032 |
+
|
1033 |
+
if ( !empty( $fav_count ) ) {
|
1034 |
+
$fav_count = (int)$fav_count - 1;
|
1035 |
+
bp_activity_update_meta( $activity_id, 'favorite_count', $fav_count );
|
1036 |
+
}
|
1037 |
+
|
1038 |
+
update_usermeta( $user_id, 'bp_favorite_activities', $my_favs );
|
1039 |
+
|
1040 |
+
return true;
|
1041 |
+
}
|
1042 |
+
|
1043 |
+
function bp_activity_check_exists_by_content( $content ) {
|
1044 |
return apply_filters( 'bp_activity_check_exists_by_content', BP_Activity_Activity::check_exists_by_content( $content ) );
|
1045 |
}
|
1046 |
|
1048 |
return apply_filters( 'bp_activity_get_last_updated', BP_Activity_Activity::get_last_updated() );
|
1049 |
}
|
1050 |
|
1051 |
+
function bp_activity_total_favorites_for_user( $user_id = false ) {
|
1052 |
+
global $bp;
|
1053 |
+
|
1054 |
+
if ( !$user_id )
|
1055 |
+
$user_id = ( $bp->displayed_user->id ) ? $bp->displayed_user->id : $bp->loggedin_user->id;
|
1056 |
+
|
1057 |
+
return BP_Activity_Activity::total_favorite_count( $user_id );
|
1058 |
}
|
1059 |
|
1060 |
+
/********************************************************************************
|
1061 |
+
* Activity Meta Functions
|
1062 |
+
*
|
1063 |
+
* Meta functions allow you to store extra data for a particular item.
|
1064 |
+
*/
|
1065 |
+
|
1066 |
+
function bp_activity_delete_meta( $activity_id, $meta_key = false, $meta_value = false ) {
|
1067 |
+
global $wpdb, $bp;
|
1068 |
+
|
1069 |
+
if ( !is_numeric( $activity_id ) )
|
1070 |
+
return false;
|
1071 |
+
|
1072 |
+
$meta_key = preg_replace( '|[^a-z0-9_]|i', '', $meta_key );
|
1073 |
+
|
1074 |
+
if ( is_array( $meta_value ) || is_object( $meta_value ) )
|
1075 |
+
$meta_value = serialize( $meta_value );
|
1076 |
+
|
1077 |
+
$meta_value = trim( $meta_value );
|
1078 |
+
|
1079 |
+
if ( !$meta_key ) {
|
1080 |
+
$wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name_meta} WHERE activity_id = %d", $activity_id ) );
|
1081 |
+
} else if ( $meta_value ) {
|
1082 |
+
$wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name_meta} WHERE activity_id = %d AND meta_key = %s AND meta_value = %s", $activity_id, $meta_key, $meta_value ) );
|
1083 |
+
} else {
|
1084 |
+
$wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name_meta} WHERE activity_id = %d AND meta_key = %s", $activity_id, $meta_key ) );
|
1085 |
+
}
|
1086 |
+
|
1087 |
+
wp_cache_delete( 'bp_activity_meta_' . $meta_key . '_' . $activity_id, 'bp' );
|
1088 |
+
|
1089 |
+
return true;
|
1090 |
}
|
1091 |
|
1092 |
+
function bp_activity_get_meta( $activity_id, $meta_key = '' ) {
|
1093 |
+
global $wpdb, $bp;
|
1094 |
+
|
1095 |
+
$activity_id = (int)$activity_id;
|
1096 |
+
|
1097 |
+
if ( !$activity_id )
|
1098 |
+
return false;
|
1099 |
+
|
1100 |
+
if ( !empty($meta_key) ) {
|
1101 |
+
$meta_key = preg_replace( '|[^a-z0-9_]|i', '', $meta_key );
|
1102 |
+
|
1103 |
+
if ( !$metas = wp_cache_get( 'bp_activity_meta_' . $meta_key . '_' . $activity_id, 'bp' ) ) {
|
1104 |
+
$metas = $wpdb->get_col( $wpdb->prepare("SELECT meta_value FROM {$bp->activity->table_name_meta} WHERE activity_id = %d AND meta_key = %s", $activity_id, $meta_key ) );
|
1105 |
+
wp_cache_set( 'bp_activity_meta_' . $meta_key . '_' . $activity_id, $metas, 'bp' );
|
1106 |
+
}
|
1107 |
+
} else
|
1108 |
+
$metas = $wpdb->get_col( $wpdb->prepare( "SELECT meta_value FROM {$bp->activity->table_name_meta} WHERE activity_id = %d", $activity_id ) );
|
1109 |
+
|
1110 |
+
if ( empty($metas) )
|
1111 |
+
return false;
|
1112 |
+
|
1113 |
+
$metas = array_map( 'maybe_unserialize', $metas );
|
1114 |
+
|
1115 |
+
if ( 1 == count($metas) )
|
1116 |
+
return $metas[0];
|
1117 |
+
else
|
1118 |
+
return $metas;
|
1119 |
+
}
|
1120 |
+
|
1121 |
+
function bp_activity_update_meta( $activity_id, $meta_key, $meta_value ) {
|
1122 |
+
global $wpdb, $bp;
|
1123 |
+
|
1124 |
+
if ( !is_numeric( $activity_id ) )
|
1125 |
+
return false;
|
1126 |
+
|
1127 |
+
$meta_key = preg_replace( '|[^a-z0-9_]|i', '', $meta_key );
|
1128 |
+
|
1129 |
+
if ( is_string( $meta_value ) )
|
1130 |
+
$meta_value = stripslashes( $wpdb->escape( $meta_value ) );
|
1131 |
+
|
1132 |
+
$meta_value = maybe_serialize( $meta_value );
|
1133 |
+
|
1134 |
+
if ( empty( $meta_value ) ) {
|
1135 |
+
return bp_activity_delete_meta( $activity_id, $meta_key );
|
1136 |
+
}
|
1137 |
+
|
1138 |
+
$cur = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name_meta} WHERE activity_id = %d AND meta_key = %s", $activity_id, $meta_key ) );
|
1139 |
+
|
1140 |
+
if ( !$cur ) {
|
1141 |
+
$wpdb->query( $wpdb->prepare( "INSERT INTO {$bp->activity->table_name_meta} ( activity_id, meta_key, meta_value ) VALUES ( %d, %s, %s )", $activity_id, $meta_key, $meta_value ) );
|
1142 |
+
} else if ( $cur->meta_value != $meta_value ) {
|
1143 |
+
$wpdb->query( $wpdb->prepare( "UPDATE {$bp->activity->table_name_meta} SET meta_value = %s WHERE activity_id = %d AND meta_key = %s", $meta_value, $activity_id, $meta_key ) );
|
1144 |
+
} else {
|
1145 |
+
return false;
|
1146 |
+
}
|
1147 |
+
|
1148 |
+
wp_cache_set( 'bp_activity_meta_' . $meta_key . '_' . $activity_id, $meta_value, 'bp' );
|
1149 |
+
|
1150 |
+
return true;
|
1151 |
}
|
1152 |
|
1153 |
function bp_activity_remove_data( $user_id ) {
|
1154 |
// Clear the user's activity from the sitewide stream and clear their activity tables
|
1155 |
+
bp_activity_delete( array( 'user_id' => $user_id ) );
|
1156 |
+
|
1157 |
+
// Remove any usermeta
|
1158 |
+
delete_usermeta( $user_id, 'bp_latest_update' );
|
1159 |
+
delete_usermeta( $user_id, 'bp_favorite_activities' );
|
1160 |
|
1161 |
do_action( 'bp_activity_remove_data', $user_id );
|
1162 |
}
|
1164 |
add_action( 'delete_user', 'bp_activity_remove_data' );
|
1165 |
add_action( 'make_spam_user', 'bp_activity_remove_data' );
|
1166 |
|
1167 |
+
|
1168 |
+
/********************************************************************************
|
1169 |
+
* Custom Actions
|
1170 |
+
*
|
1171 |
+
* Functions to set up custom BuddyPress actions that all other components can
|
1172 |
+
* hook in to.
|
1173 |
+
*/
|
1174 |
+
|
1175 |
+
/* Allow core components and dependent plugins to register activity actions */
|
1176 |
+
function bp_register_activity_actions() {
|
1177 |
+
do_action( 'bp_register_activity_actions' );
|
1178 |
}
|
1179 |
+
add_action( 'plugins_loaded', 'bp_register_activity_actions' );
|
1180 |
+
|
1181 |
|
1182 |
?>
|
bp-activity/bp-activity-classes.php
CHANGED
@@ -6,8 +6,10 @@ Class BP_Activity_Activity {
|
|
6 |
var $secondary_item_id;
|
7 |
var $user_id;
|
8 |
var $primary_link;
|
9 |
-
var $
|
10 |
-
var $
|
|
|
|
|
11 |
var $date_recorded;
|
12 |
var $hide_sitewide = false;
|
13 |
|
@@ -23,217 +25,401 @@ Class BP_Activity_Activity {
|
|
23 |
function populate() {
|
24 |
global $wpdb, $bp;
|
25 |
|
26 |
-
$
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
|
|
|
|
|
|
|
|
38 |
}
|
39 |
|
40 |
function save() {
|
41 |
global $wpdb, $bp, $current_user;
|
42 |
|
43 |
-
do_action( 'bp_activity_before_save',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
|
45 |
-
if ( !$
|
46 |
return false;
|
47 |
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
}
|
61 |
|
62 |
-
|
63 |
-
|
|
|
64 |
|
65 |
-
|
66 |
-
|
|
|
67 |
|
68 |
-
/*
|
69 |
-
if (
|
70 |
-
|
71 |
-
|
72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
}
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
}
|
79 |
}
|
80 |
|
81 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
}
|
83 |
|
84 |
-
function
|
85 |
global $wpdb, $bp;
|
86 |
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
/* If we have an item id, try and match on that, if not do a content match */
|
91 |
-
if ( $this->item_id ) {
|
92 |
-
if ( $this->secondary_item_id )
|
93 |
-
$secondary_sql = $wpdb->prepare( " AND secondary_item_id = %s", $secondary_item_id );
|
94 |
|
95 |
-
|
96 |
-
} else {
|
97 |
-
return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->activity->table_name} WHERE user_id = %d AND content = %s AND component_name = %s AND component_action = %s", $this->user_id, $this->content, $this->component_name, $this->component_action ) );
|
98 |
-
}
|
99 |
-
}
|
100 |
|
101 |
-
|
|
|
102 |
|
103 |
-
|
104 |
-
|
105 |
|
106 |
-
if ( $
|
107 |
-
$
|
108 |
|
109 |
-
|
110 |
-
|
111 |
|
112 |
-
if ( $
|
113 |
-
$
|
114 |
|
115 |
-
|
116 |
-
|
|
|
|
|
|
|
117 |
|
118 |
-
|
119 |
-
return BP_Activity_Activity::delete( $item_id, $component_name, $component_action, $user_id, $secondary_item_id );
|
120 |
}
|
121 |
|
122 |
-
function
|
123 |
global $bp, $wpdb;
|
124 |
|
125 |
-
|
126 |
-
}
|
127 |
|
128 |
-
|
129 |
-
|
130 |
|
131 |
-
|
132 |
-
|
133 |
|
134 |
-
|
135 |
-
|
136 |
|
137 |
-
|
138 |
-
|
139 |
|
140 |
-
|
141 |
-
|
142 |
|
143 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
144 |
}
|
145 |
|
146 |
-
function
|
147 |
global $wpdb, $bp;
|
148 |
|
149 |
-
|
150 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
151 |
|
152 |
-
if ( $
|
153 |
-
$
|
154 |
|
155 |
-
|
156 |
-
|
157 |
-
$filter_sql = BP_Activity_Activity::get_filter_sql( $filter );
|
158 |
|
159 |
-
if (
|
160 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
161 |
else
|
162 |
-
|
163 |
|
164 |
-
|
|
|
165 |
|
166 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
167 |
}
|
168 |
|
169 |
-
function
|
170 |
-
global $
|
171 |
|
172 |
-
|
|
|
173 |
|
174 |
-
|
175 |
-
return false;
|
176 |
|
177 |
-
|
178 |
-
|
179 |
|
180 |
-
|
181 |
-
|
182 |
|
183 |
-
|
184 |
-
|
185 |
-
$filter_sql = BP_Activity_Activity::get_filter_sql( $filter );
|
186 |
|
187 |
-
$
|
188 |
|
189 |
-
|
190 |
-
|
191 |
|
192 |
-
|
|
|
193 |
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
|
|
198 |
|
199 |
-
|
|
|
|
|
200 |
|
201 |
-
return
|
202 |
}
|
203 |
|
204 |
-
function
|
205 |
global $wpdb, $bp;
|
206 |
|
207 |
-
if (
|
208 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
209 |
|
210 |
-
|
211 |
-
|
|
|
212 |
|
213 |
-
|
214 |
-
|
215 |
-
|
|
|
216 |
|
217 |
-
|
218 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
219 |
else
|
220 |
-
$
|
221 |
|
222 |
-
|
|
|
|
|
223 |
|
224 |
-
|
|
|
|
|
|
|
225 |
}
|
226 |
|
227 |
-
function
|
228 |
global $wpdb, $bp;
|
229 |
|
230 |
-
return $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT
|
231 |
}
|
232 |
|
233 |
function get_sitewide_items_for_feed( $limit = 35 ) {
|
234 |
global $wpdb, $bp;
|
235 |
|
236 |
-
$activities =
|
|
|
237 |
for ( $i = 0; $i < count($activities); $i++ ) {
|
238 |
$title = explode( '<span', $activities[$i]['content'] );
|
239 |
|
@@ -249,13 +435,19 @@ Class BP_Activity_Activity {
|
|
249 |
function get_filter_sql( $filter_array ) {
|
250 |
global $wpdb;
|
251 |
|
|
|
|
|
|
|
|
|
|
|
|
|
252 |
if ( !empty( $filter_array['object'] ) ) {
|
253 |
$object_filter = explode( ',', $filter_array['object'] );
|
254 |
-
$object_sql = '
|
255 |
|
256 |
$counter = 1;
|
257 |
foreach( (array) $object_filter as $object ) {
|
258 |
-
$object_sql .= $wpdb->prepare( "
|
259 |
|
260 |
if ( $counter != count( $object_filter ) )
|
261 |
$object_sql .= ' || ';
|
@@ -264,15 +456,16 @@ Class BP_Activity_Activity {
|
|
264 |
}
|
265 |
|
266 |
$object_sql .= ' )';
|
|
|
267 |
}
|
268 |
|
269 |
if ( !empty( $filter_array['action'] ) ) {
|
270 |
$action_filter = explode( ',', $filter_array['action'] );
|
271 |
-
$action_sql = '
|
272 |
|
273 |
$counter = 1;
|
274 |
foreach( (array) $action_filter as $action ) {
|
275 |
-
$action_sql .= $wpdb->prepare( "
|
276 |
|
277 |
if ( $counter != count( $action_filter ) )
|
278 |
$action_sql .= ' || ';
|
@@ -281,15 +474,16 @@ Class BP_Activity_Activity {
|
|
281 |
}
|
282 |
|
283 |
$action_sql .= ' )';
|
|
|
284 |
}
|
285 |
|
286 |
if ( !empty( $filter_array['primary_id'] ) ) {
|
287 |
$pid_filter = explode( ',', $filter_array['primary_id'] );
|
288 |
-
$pid_sql = '
|
289 |
|
290 |
$counter = 1;
|
291 |
foreach( (array) $pid_filter as $pid ) {
|
292 |
-
$pid_sql .= $wpdb->prepare( "item_id = %s", trim( $pid ) );
|
293 |
|
294 |
if ( $counter != count( $pid_filter ) )
|
295 |
$pid_sql .= ' || ';
|
@@ -298,15 +492,16 @@ Class BP_Activity_Activity {
|
|
298 |
}
|
299 |
|
300 |
$pid_sql .= ' )';
|
|
|
301 |
}
|
302 |
|
303 |
if ( !empty( $filter_array['secondary_id'] ) ) {
|
304 |
$sid_filter = explode( ',', $filter_array['secondary_id'] );
|
305 |
-
$sid_sql = '
|
306 |
|
307 |
$counter = 1;
|
308 |
foreach( (array) $sid_filter as $sid ) {
|
309 |
-
$sid_sql .= $wpdb->prepare( "secondary_item_id = %s", trim( $sid ) );
|
310 |
|
311 |
if ( $counter != count( $sid_filter ) )
|
312 |
$sid_sql .= ' || ';
|
@@ -315,9 +510,13 @@ Class BP_Activity_Activity {
|
|
315 |
}
|
316 |
|
317 |
$sid_sql .= ' )';
|
|
|
318 |
}
|
319 |
|
320 |
-
|
|
|
|
|
|
|
321 |
}
|
322 |
|
323 |
function get_last_updated() {
|
@@ -326,11 +525,26 @@ Class BP_Activity_Activity {
|
|
326 |
return $wpdb->get_var( $wpdb->prepare( "SELECT date_recorded FROM {$bp->activity->table_name} ORDER BY date_recorded ASC LIMIT 1" ) );
|
327 |
}
|
328 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
329 |
function check_exists_by_content( $content ) {
|
330 |
global $wpdb, $bp;
|
331 |
|
332 |
return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->activity->table_name} WHERE content = %s", $content ) );
|
333 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
334 |
}
|
335 |
|
336 |
?>
|
6 |
var $secondary_item_id;
|
7 |
var $user_id;
|
8 |
var $primary_link;
|
9 |
+
var $component;
|
10 |
+
var $type;
|
11 |
+
var $action;
|
12 |
+
var $content;
|
13 |
var $date_recorded;
|
14 |
var $hide_sitewide = false;
|
15 |
|
25 |
function populate() {
|
26 |
global $wpdb, $bp;
|
27 |
|
28 |
+
$row = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} WHERE id = %d", $this->id ) );
|
29 |
+
if ( $row ) {
|
30 |
+
$this->id = $row->id;
|
31 |
+
$this->item_id = $row->item_id;
|
32 |
+
$this->secondary_item_id = $row->secondary_item_id;
|
33 |
+
$this->user_id = $row->user_id;
|
34 |
+
$this->primary_link = $row->primary_link;
|
35 |
+
$this->component = $row->component;
|
36 |
+
$this->type = $row->type;
|
37 |
+
$this->action = $row->type;
|
38 |
+
$this->content = $row->content;
|
39 |
+
$this->date_recorded = $row->date_recorded;
|
40 |
+
$this->hide_sitewide = $row->hide_sitewide;
|
41 |
+
$this->mptt_left = $row->mptt_left;
|
42 |
+
$this->mptt_right = $row->mptt_right;
|
43 |
+
}
|
44 |
}
|
45 |
|
46 |
function save() {
|
47 |
global $wpdb, $bp, $current_user;
|
48 |
|
49 |
+
do_action( 'bp_activity_before_save', &$this );
|
50 |
+
|
51 |
+
$this->id = apply_filters( 'bp_activity_id_before_save', $this->id, &$this );
|
52 |
+
$this->item_id = apply_filters( 'bp_activity_item_id_before_save', $this->item_id, &$this );
|
53 |
+
$this->secondary_item_id = apply_filters( 'bp_activity_secondary_item_id_before_save', $this->secondary_item_id, &$this );
|
54 |
+
$this->user_id = apply_filters( 'bp_activity_user_id_before_save', $this->user_id, &$this );
|
55 |
+
$this->primary_link = apply_filters( 'bp_activity_primary_link_before_save', $this->primary_link, &$this );
|
56 |
+
$this->component = apply_filters( 'bp_activity_component_before_save', $this->component, &$this );
|
57 |
+
$this->type = apply_filters( 'bp_activity_type_before_save', $this->type, &$this );
|
58 |
+
$this->action = apply_filters( 'bp_activity_action_before_save', $this->action, &$this );
|
59 |
+
$this->content = apply_filters( 'bp_activity_content_before_save', $this->content, &$this );
|
60 |
+
$this->date_recorded = apply_filters( 'bp_activity_date_recorded_before_save', $this->date_recorded, &$this );
|
61 |
+
$this->hide_sitewide = apply_filters( 'bp_activity_hide_sitewide_before_save', $this->hide_sitewide, &$this );
|
62 |
+
$this->mptt_left = apply_filters( 'bp_activity_mptt_left_before_save', $this->mptt_left, &$this );
|
63 |
+
$this->mptt_right = apply_filters( 'bp_activity_mptt_right_before_save', $this->mptt_right, &$this );
|
64 |
+
|
65 |
+
if ( !$this->component || !$this->type )
|
66 |
+
return false;
|
67 |
+
|
68 |
+
if ( !$this->primary_link )
|
69 |
+
$this->primary_link = $bp->loggedin_user->domain;
|
70 |
+
|
71 |
+
/* If we have an existing ID, update the activity item, otherwise insert it. */
|
72 |
+
if ( $this->id )
|
73 |
+
$q = $wpdb->prepare( "UPDATE {$bp->activity->table_name} SET user_id = %d, component = %s, type = %s, action = %s, content = %s, primary_link = %s, date_recorded = %s, item_id = %s, secondary_item_id = %s, hide_sitewide = %d WHERE id = %d", $this->user_id, $this->component, $this->type, $this->action, $this->content, $this->primary_link, $this->date_recorded, $this->item_id, $this->secondary_item_id, $this->hide_sitewide, $this->id );
|
74 |
+
else
|
75 |
+
$q = $wpdb->prepare( "INSERT INTO {$bp->activity->table_name} ( user_id, component, type, action, content, primary_link, date_recorded, item_id, secondary_item_id, hide_sitewide ) VALUES ( %d, %s, %s, %s, %s, %s, %s, %s, %s, %d )", $this->user_id, $this->component, $this->type, $this->action, $this->content, $this->primary_link, $this->date_recorded, $this->item_id, $this->secondary_item_id, $this->hide_sitewide );
|
76 |
|
77 |
+
if ( !$wpdb->query( $q ) )
|
78 |
return false;
|
79 |
|
80 |
+
if ( empty( $this->id ) )
|
81 |
+
$this->id = $wpdb->insert_id;
|
82 |
+
|
83 |
+
do_action( 'bp_activity_after_save', &$this );
|
84 |
+
return true;
|
85 |
+
}
|
86 |
+
|
87 |
+
/* Static Functions */
|
88 |
+
|
89 |
+
function get( $max = false, $page = 1, $per_page = 25, $sort = 'DESC', $search_terms = false, $filter = false, $display_comments = false, $show_hidden = false ) {
|
90 |
+
global $wpdb, $bp;
|
91 |
+
|
92 |
+
/* Select conditions */
|
93 |
+
$select_sql = "SELECT a.*, u.user_email, u.user_nicename, u.user_login, u.display_name";
|
94 |
+
|
95 |
+
$from_sql = " FROM {$bp->activity->table_name} a LEFT JOIN {$wpdb->users} u ON a.user_id = u.ID";
|
96 |
+
|
97 |
+
/* Where conditions */
|
98 |
+
$where_conditions = array();
|
99 |
+
|
100 |
+
/* Searching */
|
101 |
+
if ( $search_terms ) {
|
102 |
+
$search_terms = $wpdb->escape( $search_terms );
|
103 |
+
$where_conditions['search_sql'] = "a.content LIKE '%%" . like_escape( $search_terms ) . "%%'";
|
104 |
}
|
105 |
|
106 |
+
/* Filtering */
|
107 |
+
if ( $filter && $filter_sql = BP_Activity_Activity::get_filter_sql( $filter ) )
|
108 |
+
$where_conditions['filter_sql'] = $filter_sql;
|
109 |
|
110 |
+
/* Sorting */
|
111 |
+
if ( $sort != 'ASC' && $sort != 'DESC' )
|
112 |
+
$sort = 'DESC';
|
113 |
|
114 |
+
/* Hide Hidden Items? */
|
115 |
+
if ( !$show_hidden )
|
116 |
+
$where_conditions['hidden_sql'] = "a.hide_sitewide = 0";
|
117 |
+
|
118 |
+
/* Alter the query based on whether we want to show activity item comments in the stream like normal comments or threaded below the activity */
|
119 |
+
if ( !$display_comments || 'threaded' == $display_comments ) {
|
120 |
+
$where_conditions[] = "a.type != 'activity_comment'";
|
121 |
+
}
|
122 |
+
|
123 |
+
$where_sql = 'WHERE ' . join( ' AND ', $where_conditions );
|
124 |
+
|
125 |
+
if ( $per_page && $page ) {
|
126 |
+
$pag_sql = $wpdb->prepare( "LIMIT %d, %d", intval( ( $page - 1 ) * $per_page ), intval( $per_page ) );
|
127 |
+
$activities = $wpdb->get_results( $wpdb->prepare( "{$select_sql} {$from_sql} {$where_sql} ORDER BY a.date_recorded {$sort} {$pag_sql}" ) );
|
128 |
+
} else
|
129 |
+
$activities = $wpdb->get_results( $wpdb->prepare( "{$select_sql} {$from_sql} {$where_sql} ORDER BY a.date_recorded {$sort} {$pag_sql}" ) );
|
130 |
+
|
131 |
+
$total_activities = $wpdb->get_var( $wpdb->prepare( "SELECT count(a.id) FROM {$bp->activity->table_name} a {$where_sql} ORDER BY a.date_recorded {$sort}" ) );
|
132 |
+
|
133 |
+
/* Get the fullnames of users so we don't have to query in the loop */
|
134 |
+
if ( function_exists( 'xprofile_install' ) && $activities ) {
|
135 |
+
foreach ( (array)$activities as $activity ) {
|
136 |
+
if ( (int)$activity->user_id )
|
137 |
+
$activity_user_ids[] = $activity->user_id;
|
138 |
}
|
139 |
+
|
140 |
+
$activity_user_ids = implode( ',', array_unique( (array)$activity_user_ids ) );
|
141 |
+
if ( !empty( $activity_user_ids ) ) {
|
142 |
+
if ( $names = $wpdb->get_results( $wpdb->prepare( "SELECT user_id, value AS user_fullname FROM {$bp->profile->table_name_data} WHERE field_id = 1 AND user_id IN ({$activity_user_ids})" ) ) ) {
|
143 |
+
foreach ( (array)$names as $name )
|
144 |
+
$tmp_names[$name->user_id] = $name->user_fullname;
|
145 |
+
|
146 |
+
foreach ( (array)$activities as $i => $activity ) {
|
147 |
+
if ( !empty( $tmp_names[$activity->user_id] ) )
|
148 |
+
$activities[$i]->user_fullname = $tmp_names[$activity->user_id];
|
149 |
+
}
|
150 |
+
|
151 |
+
unset( $names );
|
152 |
+
unset( $tmp_names );
|
153 |
+
}
|
154 |
}
|
155 |
}
|
156 |
|
157 |
+
if ( $activities && $display_comments )
|
158 |
+
$activities = BP_Activity_Activity::append_comments( &$activities );
|
159 |
+
|
160 |
+
/* If $max is set, only return up to the max results */
|
161 |
+
if ( !empty( $max ) ) {
|
162 |
+
if ( (int)$total_activities > (int)$max )
|
163 |
+
$total_activities = $max;
|
164 |
+
}
|
165 |
+
|
166 |
+
return array( 'activities' => $activities, 'total' => (int)$total_activities );
|
167 |
}
|
168 |
|
169 |
+
function get_specific( $activity_ids, $max = false, $page = 1, $per_page = 25, $sort = 'DESC', $display_comments = false ) {
|
170 |
global $wpdb, $bp;
|
171 |
|
172 |
+
if ( is_array( $activity_ids ) )
|
173 |
+
$activity_ids = implode( ',', $activity_ids );
|
|
|
|
|
|
|
|
|
|
|
174 |
|
175 |
+
$activity_ids = $wpdb->escape( $activity_ids );
|
|
|
|
|
|
|
|
|
176 |
|
177 |
+
if ( empty( $activity_ids ) )
|
178 |
+
return false;
|
179 |
|
180 |
+
if ( $per_page && $page )
|
181 |
+
$pag_sql = $wpdb->prepare( "LIMIT %d, %d", intval( ( $page - 1 ) * $per_page ), intval( $per_page ) );
|
182 |
|
183 |
+
if ( $sort != 'ASC' && $sort != 'DESC' )
|
184 |
+
$sort = 'DESC';
|
185 |
|
186 |
+
$activities = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} WHERE id IN ({$activity_ids}) ORDER BY date_recorded {$sort} $pag_sql" ) );
|
187 |
+
$total_activities = $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM {$bp->activity->table_name} WHERE id IN ({$activity_ids})" ) );
|
188 |
|
189 |
+
if ( $display_comments )
|
190 |
+
$activities = BP_Activity_Activity::append_comments( $activities );
|
191 |
|
192 |
+
/* If $max is set, only return up to the max results */
|
193 |
+
if ( !empty( $max ) ) {
|
194 |
+
if ( (int)$total_activities > (int)$max )
|
195 |
+
$total_activities = $max;
|
196 |
+
}
|
197 |
|
198 |
+
return array( 'activities' => $activities, 'total' => (int)$total_activities );
|
|
|
199 |
}
|
200 |
|
201 |
+
function get_id( $user_id, $component, $type, $item_id, $secondary_item_id, $action, $content ) {
|
202 |
global $bp, $wpdb;
|
203 |
|
204 |
+
$where_args = false;
|
|
|
205 |
|
206 |
+
if ( !empty( $user_id ) )
|
207 |
+
$where_args[] = $wpdb->prepare( "user_id = %d", $user_id );
|
208 |
|
209 |
+
if ( !empty( $component ) )
|
210 |
+
$where_args[] = $wpdb->prepare( "component = %s", $component );
|
211 |
|
212 |
+
if ( !empty( $type ) )
|
213 |
+
$where_args[] = $wpdb->prepare( "type = %s", $type );
|
214 |
|
215 |
+
if ( !empty( $item_id ) )
|
216 |
+
$where_args[] = $wpdb->prepare( "item_id = %s", $item_id );
|
217 |
|
218 |
+
if ( !empty( $secondary_item_id ) )
|
219 |
+
$where_args[] = $wpdb->prepare( "secondary_item_id = %s", $secondary_item_id );
|
220 |
|
221 |
+
if ( !empty( $action ) )
|
222 |
+
$where_args[] = $wpdb->prepare( "action = %s", $action );
|
223 |
+
|
224 |
+
if ( !empty( $content ) )
|
225 |
+
$where_args[] = $wpdb->prepare( "content = %s", $content );
|
226 |
+
|
227 |
+
if ( !empty( $where_args ) )
|
228 |
+
$where_sql = 'WHERE ' . join( ' AND ', $where_args );
|
229 |
+
else
|
230 |
+
return false;
|
231 |
+
|
232 |
+
return $wpdb->get_var( "SELECT id FROM {$bp->activity->table_name} {$where_sql}" );
|
233 |
}
|
234 |
|
235 |
+
function delete( $args ) {
|
236 |
global $wpdb, $bp;
|
237 |
|
238 |
+
extract( $args );
|
239 |
+
|
240 |
+
$defaults = array(
|
241 |
+
'id' => false,
|
242 |
+
'action' => false,
|
243 |
+
'content' => false,
|
244 |
+
'component' => false,
|
245 |
+
'type' => false,
|
246 |
+
'primary_link' => false,
|
247 |
+
'user_id' => false,
|
248 |
+
'item_id' => false,
|
249 |
+
'secondary_item_id' => false,
|
250 |
+
'date_recorded' => false,
|
251 |
+
'hide_sitewide' => false
|
252 |
+
);
|
253 |
+
|
254 |
+
$where_args = false;
|
255 |
|
256 |
+
if ( !empty( $id ) )
|
257 |
+
$where_args[] = $wpdb->prepare( "id = %d", $id );
|
258 |
|
259 |
+
if ( !empty( $user_id ) )
|
260 |
+
$where_args[] = $wpdb->prepare( "user_id = %d", $user_id );
|
|
|
261 |
|
262 |
+
if ( !empty( $action ) )
|
263 |
+
$where_args[] = $wpdb->prepare( "action = %s", $action );
|
264 |
+
|
265 |
+
if ( !empty( $content ) )
|
266 |
+
$where_args[] = $wpdb->prepare( "content = %s", $content );
|
267 |
+
|
268 |
+
if ( !empty( $component ) )
|
269 |
+
$where_args[] = $wpdb->prepare( "component = %s", $component );
|
270 |
+
|
271 |
+
if ( !empty( $type ) )
|
272 |
+
$where_args[] = $wpdb->prepare( "type = %s", $type );
|
273 |
+
|
274 |
+
if ( !empty( $primary_link ) )
|
275 |
+
$where_args[] = $wpdb->prepare( "primary_link = %s", $primary_link );
|
276 |
+
|
277 |
+
if ( !empty( $item_id ) )
|
278 |
+
$where_args[] = $wpdb->prepare( "item_id = %s", $item_id );
|
279 |
+
|
280 |
+
if ( !empty( $secondary_item_id ) )
|
281 |
+
$where_args[] = $wpdb->prepare( "secondary_item_id = %s", $secondary_item_id );
|
282 |
+
|
283 |
+
if ( !empty( $date_recorded ) )
|
284 |
+
$where_args[] = $wpdb->prepare( "date_recorded = %s", $date_recorded );
|
285 |
+
|
286 |
+
if ( !empty( $hide_sitewide ) )
|
287 |
+
$where_args[] = $wpdb->prepare( "hide_sitewide = %d", $hide_sitewide );
|
288 |
+
|
289 |
+
if ( !empty( $where_args ) )
|
290 |
+
$where_sql = 'WHERE ' . join( ' AND ', $where_args );
|
291 |
else
|
292 |
+
return false;
|
293 |
|
294 |
+
/* Fetch the activity IDs so we can delete any comments for this activity item */
|
295 |
+
$activity_ids = $wpdb->get_col( $wpdb->prepare( "SELECT id FROM {$bp->activity->table_name} {$where_sql}" ) );
|
296 |
|
297 |
+
if ( !$wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name} {$where_sql}" ) ) )
|
298 |
+
return false;
|
299 |
+
|
300 |
+
if ( $activity_ids ) {
|
301 |
+
BP_Activity_Activity::delete_activity_item_comments( $activity_ids );
|
302 |
+
BP_Activity_Activity::delete_activity_meta_entries( $activity_ids );
|
303 |
+
|
304 |
+
return $activity_ids;
|
305 |
+
}
|
306 |
+
|
307 |
+
return $activity_ids;
|
308 |
}
|
309 |
|
310 |
+
function delete_activity_item_comments( $activity_ids ) {
|
311 |
+
global $bp, $wpdb;
|
312 |
|
313 |
+
if ( is_array($activity_ids) )
|
314 |
+
$activity_ids = implode( ',', $activity_ids );
|
315 |
|
316 |
+
$activity_ids = $wpdb->escape( $activity_ids );
|
|
|
317 |
|
318 |
+
return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name} WHERE type = 'activity_comment' AND item_id IN ({$activity_ids})" ) );
|
319 |
+
}
|
320 |
|
321 |
+
function delete_activity_meta_entries( $activity_ids ) {
|
322 |
+
global $bp, $wpdb;
|
323 |
|
324 |
+
if ( is_array($activity_ids) )
|
325 |
+
$activity_ids = implode( ',', $activity_ids );
|
|
|
326 |
|
327 |
+
$activity_ids = $wpdb->escape( $activity_ids );
|
328 |
|
329 |
+
return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name_meta} WHERE activity_id IN ({$activity_ids})" ) );
|
330 |
+
}
|
331 |
|
332 |
+
function append_comments( $activities ) {
|
333 |
+
global $bp, $wpdb;
|
334 |
|
335 |
+
/* Now fetch the activity comments and parse them into the correct position in the activities array. */
|
336 |
+
foreach( (array)$activities as $activity ) {
|
337 |
+
if ( 'activity_comment' != $activity->type && $activity->mptt_left && $activity->mptt_right )
|
338 |
+
$activity_comments[$activity->id] = BP_Activity_Activity::get_activity_comments( $activity->id, $activity->mptt_left, $activity->mptt_right );
|
339 |
+
}
|
340 |
|
341 |
+
/* Merge the comments with the activity items */
|
342 |
+
foreach( (array)$activities as $key => $activity )
|
343 |
+
$activities[$key]->children = $activity_comments[$activity->id];
|
344 |
|
345 |
+
return $activities;
|
346 |
}
|
347 |
|
348 |
+
function get_activity_comments( $activity_id, $left, $right ) {
|
349 |
global $wpdb, $bp;
|
350 |
|
351 |
+
if ( !$comments = wp_cache_get( 'bp_activity_comments_' . $activity_id ) ) {
|
352 |
+
/* Select the user's fullname with the query so we don't have to fetch it for each comment */
|
353 |
+
if ( function_exists( 'xprofile_install' ) ) {
|
354 |
+
$fullname_select = ", pd.value as user_fullname";
|
355 |
+
$fullname_from = ", {$bp->profile->table_name_data} pd ";
|
356 |
+
$fullname_where = "AND pd.user_id = a.user_id AND pd.field_id = 1";
|
357 |
+
}
|
358 |
+
|
359 |
+
/* Retrieve all descendants of the $root node */
|
360 |
+
$descendants = $wpdb->get_results( $wpdb->prepare( "SELECT a.*, u.user_email, u.user_nicename, u.user_login, u.display_name{$fullname_select} FROM {$bp->activity->table_name} a, {$wpdb->users} u{$fullname_from} WHERE u.ID = a.user_id {$fullname_where} AND a.type = 'activity_comment' AND a.item_id = %d AND a.mptt_left BETWEEN %d AND %d ORDER BY a.date_recorded ASC", $activity_id, $left, $right ) );
|
361 |
|
362 |
+
/* Loop descendants and build an assoc array */
|
363 |
+
foreach ( (array)$descendants as $d ) {
|
364 |
+
$d->children = array();
|
365 |
|
366 |
+
/* If we have a reference on the parent */
|
367 |
+
if ( isset( $ref[ $d->secondary_item_id ] ) ) {
|
368 |
+
$ref[ $d->secondary_item_id ]->children[ $d->id ] = $d;
|
369 |
+
$ref[ $d->id ] =& $ref[ $d->secondary_item_id ]->children[ $d->id ];
|
370 |
|
371 |
+
/* If we don't have a reference on the parent, put in the root level */
|
372 |
+
} else {
|
373 |
+
$comments[ $d->id ] = $d;
|
374 |
+
$ref[ $d->id ] =& $comments[ $d->id ];
|
375 |
+
}
|
376 |
+
}
|
377 |
+
wp_cache_set( 'bp_activity_comments_' . $activity_id, $comments, 'bp' );
|
378 |
+
}
|
379 |
+
|
380 |
+
return $comments;
|
381 |
+
}
|
382 |
+
|
383 |
+
function rebuild_activity_comment_tree( $parent_id, $left = 1 ) {
|
384 |
+
global $wpdb, $bp;
|
385 |
+
|
386 |
+
/* The right value of this node is the left value + 1 */
|
387 |
+
$right = $left + 1;
|
388 |
+
|
389 |
+
/* Get all descendants of this node */
|
390 |
+
$descendants = BP_Activity_Activity::get_child_comments( $parent_id );
|
391 |
+
|
392 |
+
/* Loop the descendants and recalculate the left and right values */
|
393 |
+
foreach ( (array)$descendants as $descendant )
|
394 |
+
$right = BP_Activity_Activity::rebuild_activity_comment_tree( $descendant->id, $right );
|
395 |
+
|
396 |
+
/* We've got the left value, and now that we've processed the children of this node we also know the right value */
|
397 |
+
if ( 1 == $left )
|
398 |
+
$wpdb->query( $wpdb->prepare( "UPDATE {$bp->activity->table_name} SET mptt_left = %d, mptt_right = %d WHERE id = %d", $left, $right, $parent_id ) );
|
399 |
else
|
400 |
+
$wpdb->query( $wpdb->prepare( "UPDATE {$bp->activity->table_name} SET mptt_left = %d, mptt_right = %d WHERE type = 'activity_comment' AND id = %d", $left, $right, $parent_id ) );
|
401 |
|
402 |
+
/* Return the right value of this node + 1 */
|
403 |
+
return $right + 1;
|
404 |
+
}
|
405 |
|
406 |
+
function get_child_comments( $parent_id ) {
|
407 |
+
global $bp, $wpdb;
|
408 |
+
|
409 |
+
return $wpdb->get_results( $wpdb->prepare( "SELECT id FROM {$bp->activity->table_name} WHERE type = 'activity_comment' AND secondary_item_id = %d", $parent_id ) );
|
410 |
}
|
411 |
|
412 |
+
function get_recorded_components() {
|
413 |
global $wpdb, $bp;
|
414 |
|
415 |
+
return $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT component FROM {$bp->activity->table_name} ORDER BY component ASC" ) );
|
416 |
}
|
417 |
|
418 |
function get_sitewide_items_for_feed( $limit = 35 ) {
|
419 |
global $wpdb, $bp;
|
420 |
|
421 |
+
$activities = bp_activity_get_sitewide( array( 'max' => $limit ) );
|
422 |
+
|
423 |
for ( $i = 0; $i < count($activities); $i++ ) {
|
424 |
$title = explode( '<span', $activities[$i]['content'] );
|
425 |
|
435 |
function get_filter_sql( $filter_array ) {
|
436 |
global $wpdb;
|
437 |
|
438 |
+
if ( !empty( $filter_array['user_id'] ) ) {
|
439 |
+
$user_filter = explode( ',', $filter_array['user_id'] );
|
440 |
+
$user_sql = ' ( a.user_id IN ( ' . $filter_array['user_id'] . ' ) )';
|
441 |
+
$filter_sql[] = $user_sql;
|
442 |
+
}
|
443 |
+
|
444 |
if ( !empty( $filter_array['object'] ) ) {
|
445 |
$object_filter = explode( ',', $filter_array['object'] );
|
446 |
+
$object_sql = ' ( ';
|
447 |
|
448 |
$counter = 1;
|
449 |
foreach( (array) $object_filter as $object ) {
|
450 |
+
$object_sql .= $wpdb->prepare( "a.component = %s", trim( $object ) );
|
451 |
|
452 |
if ( $counter != count( $object_filter ) )
|
453 |
$object_sql .= ' || ';
|
456 |
}
|
457 |
|
458 |
$object_sql .= ' )';
|
459 |
+
$filter_sql[] = $object_sql;
|
460 |
}
|
461 |
|
462 |
if ( !empty( $filter_array['action'] ) ) {
|
463 |
$action_filter = explode( ',', $filter_array['action'] );
|
464 |
+
$action_sql = ' ( ';
|
465 |
|
466 |
$counter = 1;
|
467 |
foreach( (array) $action_filter as $action ) {
|
468 |
+
$action_sql .= $wpdb->prepare( "a.type = %s", trim( $action ) );
|
469 |
|
470 |
if ( $counter != count( $action_filter ) )
|
471 |
$action_sql .= ' || ';
|
474 |
}
|
475 |
|
476 |
$action_sql .= ' )';
|
477 |
+
$filter_sql[] = $action_sql;
|
478 |
}
|
479 |
|
480 |
if ( !empty( $filter_array['primary_id'] ) ) {
|
481 |
$pid_filter = explode( ',', $filter_array['primary_id'] );
|
482 |
+
$pid_sql = ' ( ';
|
483 |
|
484 |
$counter = 1;
|
485 |
foreach( (array) $pid_filter as $pid ) {
|
486 |
+
$pid_sql .= $wpdb->prepare( "a.item_id = %s", trim( $pid ) );
|
487 |
|
488 |
if ( $counter != count( $pid_filter ) )
|
489 |
$pid_sql .= ' || ';
|
492 |
}
|
493 |
|
494 |
$pid_sql .= ' )';
|
495 |
+
$filter_sql[] = $pid_sql;
|
496 |
}
|
497 |
|
498 |
if ( !empty( $filter_array['secondary_id'] ) ) {
|
499 |
$sid_filter = explode( ',', $filter_array['secondary_id'] );
|
500 |
+
$sid_sql = ' ( ';
|
501 |
|
502 |
$counter = 1;
|
503 |
foreach( (array) $sid_filter as $sid ) {
|
504 |
+
$sid_sql .= $wpdb->prepare( "a.secondary_item_id = %s", trim( $sid ) );
|
505 |
|
506 |
if ( $counter != count( $sid_filter ) )
|
507 |
$sid_sql .= ' || ';
|
510 |
}
|
511 |
|
512 |
$sid_sql .= ' )';
|
513 |
+
$filter_sql[] = $sid_sql;
|
514 |
}
|
515 |
|
516 |
+
if ( empty($filter_sql) )
|
517 |
+
return false;
|
518 |
+
|
519 |
+
return join( ' AND ', $filter_sql );
|
520 |
}
|
521 |
|
522 |
function get_last_updated() {
|
525 |
return $wpdb->get_var( $wpdb->prepare( "SELECT date_recorded FROM {$bp->activity->table_name} ORDER BY date_recorded ASC LIMIT 1" ) );
|
526 |
}
|
527 |
|
528 |
+
function total_favorite_count( $user_id ) {
|
529 |
+
global $bp;
|
530 |
+
|
531 |
+
if ( !$favorite_activity_entries = get_usermeta( $user_id, 'bp_favorite_activities' ) )
|
532 |
+
return 0;
|
533 |
+
|
534 |
+
return count( maybe_unserialize( $favorite_activity_entries ) );
|
535 |
+
}
|
536 |
+
|
537 |
function check_exists_by_content( $content ) {
|
538 |
global $wpdb, $bp;
|
539 |
|
540 |
return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->activity->table_name} WHERE content = %s", $content ) );
|
541 |
}
|
542 |
+
|
543 |
+
function hide_all_for_user( $user_id ) {
|
544 |
+
global $wpdb, $bp;
|
545 |
+
|
546 |
+
return $wpdb->get_var( $wpdb->prepare( "UPDATE {$bp->activity->table_name} SET hide_sitewide = 1 WHERE user_id = %d", $user_id ) );
|
547 |
+
}
|
548 |
}
|
549 |
|
550 |
?>
|
bp-activity/bp-activity-filters.php
CHANGED
@@ -1,16 +1,69 @@
|
|
1 |
<?php
|
2 |
|
3 |
/* Apply WordPress defined filters */
|
|
|
|
|
4 |
add_filter( 'bp_get_activity_content', 'bp_activity_filter_kses', 1 );
|
5 |
-
add_filter( '
|
|
|
|
|
|
|
|
|
6 |
|
|
|
|
|
7 |
add_filter( 'bp_get_activity_content', 'force_balance_tags' );
|
|
|
|
|
|
|
|
|
|
|
8 |
add_filter( 'bp_get_activity_content', 'wptexturize' );
|
|
|
|
|
|
|
|
|
|
|
9 |
add_filter( 'bp_get_activity_content', 'convert_smilies' );
|
|
|
|
|
|
|
|
|
|
|
10 |
add_filter( 'bp_get_activity_content', 'convert_chars' );
|
|
|
|
|
|
|
|
|
|
|
11 |
add_filter( 'bp_get_activity_content', 'wpautop' );
|
|
|
|
|
|
|
|
|
12 |
add_filter( 'bp_get_activity_content', 'make_clickable' );
|
|
|
|
|
|
|
|
|
|
|
13 |
add_filter( 'bp_get_activity_content', 'stripslashes_deep' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
function bp_activity_filter_kses( $content ) {
|
16 |
global $allowedtags;
|
@@ -18,6 +71,9 @@ function bp_activity_filter_kses( $content ) {
|
|
18 |
$activity_allowedtags = $allowedtags;
|
19 |
$activity_allowedtags['span'] = array();
|
20 |
$activity_allowedtags['span']['class'] = array();
|
|
|
|
|
|
|
21 |
$activity_allowedtags['a']['class'] = array();
|
22 |
$activity_allowedtags['img'] = array();
|
23 |
$activity_allowedtags['img']['src'] = array();
|
@@ -27,9 +83,50 @@ function bp_activity_filter_kses( $content ) {
|
|
27 |
$activity_allowedtags['img']['height'] = array();
|
28 |
$activity_allowedtags['img']['class'] = array();
|
29 |
$activity_allowedtags['img']['id'] = array();
|
|
|
|
|
30 |
|
|
|
31 |
return wp_kses( $content, $activity_allowedtags );
|
32 |
}
|
33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
?>
|
1 |
<?php
|
2 |
|
3 |
/* Apply WordPress defined filters */
|
4 |
+
add_filter( 'bp_get_activity_action', 'bp_activity_filter_kses', 1 );
|
5 |
+
add_filter( 'bp_get_activity_content_body', 'bp_activity_filter_kses', 1 );
|
6 |
add_filter( 'bp_get_activity_content', 'bp_activity_filter_kses', 1 );
|
7 |
+
add_filter( 'bp_get_activity_parent_content', 'bp_activity_filter_kses', 1 );
|
8 |
+
add_filter( 'bp_get_activity_latest_update', 'bp_activity_filter_kses', 1 );
|
9 |
+
add_filter( 'bp_get_activity_feed_item_description', 'bp_activity_filter_kses', 1 );
|
10 |
+
add_filter( 'bp_activity_content_before_save', 'bp_activity_filter_kses', 1 );
|
11 |
+
add_filter( 'bp_activity_action_before_save', 'bp_activity_filter_kses', 1 );
|
12 |
|
13 |
+
add_filter( 'bp_get_activity_action', 'force_balance_tags' );
|
14 |
+
add_filter( 'bp_get_activity_content_body', 'force_balance_tags' );
|
15 |
add_filter( 'bp_get_activity_content', 'force_balance_tags' );
|
16 |
+
add_filter( 'bp_get_activity_latest_update', 'force_balance_tags' );
|
17 |
+
add_filter( 'bp_get_activity_feed_item_description', 'force_balance_tags' );
|
18 |
+
|
19 |
+
add_filter( 'bp_get_activity_action', 'wptexturize' );
|
20 |
+
add_filter( 'bp_get_activity_content_body', 'wptexturize' );
|
21 |
add_filter( 'bp_get_activity_content', 'wptexturize' );
|
22 |
+
add_filter( 'bp_get_activity_parent_content', 'wptexturize' );
|
23 |
+
add_filter( 'bp_get_activity_latest_update', 'wptexturize' );
|
24 |
+
|
25 |
+
add_filter( 'bp_get_activity_action', 'convert_smilies' );
|
26 |
+
add_filter( 'bp_get_activity_content_body', 'convert_smilies' );
|
27 |
add_filter( 'bp_get_activity_content', 'convert_smilies' );
|
28 |
+
add_filter( 'bp_get_activity_parent_content', 'convert_smilies' );
|
29 |
+
add_filter( 'bp_get_activity_latest_update', 'convert_smilies' );
|
30 |
+
|
31 |
+
add_filter( 'bp_get_activity_action', 'convert_chars' );
|
32 |
+
add_filter( 'bp_get_activity_content_body', 'convert_chars' );
|
33 |
add_filter( 'bp_get_activity_content', 'convert_chars' );
|
34 |
+
add_filter( 'bp_get_activity_parent_content', 'convert_chars' );
|
35 |
+
add_filter( 'bp_get_activity_latest_update', 'convert_chars' );
|
36 |
+
|
37 |
+
add_filter( 'bp_get_activity_action', 'wpautop' );
|
38 |
+
add_filter( 'bp_get_activity_content_body', 'wpautop' );
|
39 |
add_filter( 'bp_get_activity_content', 'wpautop' );
|
40 |
+
add_filter( 'bp_get_activity_feed_item_description', 'wpautop' );
|
41 |
+
|
42 |
+
add_filter( 'bp_get_activity_action', 'make_clickable' );
|
43 |
+
add_filter( 'bp_get_activity_content_body', 'make_clickable' );
|
44 |
add_filter( 'bp_get_activity_content', 'make_clickable' );
|
45 |
+
add_filter( 'bp_get_activity_parent_content', 'make_clickable' );
|
46 |
+
add_filter( 'bp_get_activity_latest_update', 'make_clickable' );
|
47 |
+
add_filter( 'bp_get_activity_feed_item_description', 'make_clickable' );
|
48 |
+
|
49 |
+
add_filter( 'bp_get_activity_action', 'stripslashes_deep' );
|
50 |
add_filter( 'bp_get_activity_content', 'stripslashes_deep' );
|
51 |
+
add_filter( 'bp_get_activity_content_body', 'stripslashes_deep' );
|
52 |
+
add_filter( 'bp_get_activity_parent_content', 'stripslashes_deep' );
|
53 |
+
add_filter( 'bp_get_activity_latest_update', 'stripslashes_deep' );
|
54 |
+
add_filter( 'bp_get_activity_feed_item_description', 'stripslashes_deep' );
|
55 |
+
|
56 |
+
add_filter( 'bp_get_activity_content', 'bp_activity_make_nofollow_filter' );
|
57 |
+
add_filter( 'bp_get_activity_content_body', 'bp_activity_make_nofollow_filter' );
|
58 |
+
add_filter( 'bp_get_activity_parent_content', 'bp_activity_make_nofollow_filter' );
|
59 |
+
add_filter( 'bp_get_activity_latest_update', 'bp_activity_make_nofollow_filter' );
|
60 |
+
add_filter( 'bp_get_activity_feed_item_description', 'bp_activity_make_nofollow_filter' );
|
61 |
+
|
62 |
+
add_filter( 'bp_get_activity_parent_content', 'bp_create_excerpt' );
|
63 |
+
|
64 |
+
/* Allow shortcodes in activity posts */
|
65 |
+
add_filter( 'bp_get_activity_content', 'do_shortcode' );
|
66 |
+
add_filter( 'bp_get_activity_content_body', 'do_shortcode' );
|
67 |
|
68 |
function bp_activity_filter_kses( $content ) {
|
69 |
global $allowedtags;
|
71 |
$activity_allowedtags = $allowedtags;
|
72 |
$activity_allowedtags['span'] = array();
|
73 |
$activity_allowedtags['span']['class'] = array();
|
74 |
+
$activity_allowedtags['div'] = array();
|
75 |
+
$activity_allowedtags['div']['class'] = array();
|
76 |
+
$activity_allowedtags['div']['id'] = array();
|
77 |
$activity_allowedtags['a']['class'] = array();
|
78 |
$activity_allowedtags['img'] = array();
|
79 |
$activity_allowedtags['img']['src'] = array();
|
83 |
$activity_allowedtags['img']['height'] = array();
|
84 |
$activity_allowedtags['img']['class'] = array();
|
85 |
$activity_allowedtags['img']['id'] = array();
|
86 |
+
$activity_allowedtags['img']['title'] = array();
|
87 |
+
$activity_allowedtags['code'] = array();
|
88 |
|
89 |
+
$activity_allowedtags = apply_filters( 'bp_activity_allowed_tags', $activity_allowedtags );
|
90 |
return wp_kses( $content, $activity_allowedtags );
|
91 |
}
|
92 |
|
93 |
+
function bp_activity_at_name_filter( $content ) {
|
94 |
+
include_once( ABSPATH . WPINC . '/registration.php' );
|
95 |
+
|
96 |
+
$pattern = '/[@]+([A-Za-z0-9-_]+)/';
|
97 |
+
preg_match_all( $pattern, $content, $usernames );
|
98 |
+
|
99 |
+
/* Make sure there's only one instance of each username */
|
100 |
+
if ( !$usernames = array_unique( $usernames[1] ) )
|
101 |
+
return $content;
|
102 |
+
|
103 |
+
foreach( (array)$usernames as $username ) {
|
104 |
+
if ( !$user_id = username_exists( $username ) )
|
105 |
+
continue;
|
106 |
+
|
107 |
+
/* Increase the number of new @ mentions for the user */
|
108 |
+
$new_mention_count = (int)get_usermeta( $user_id, 'bp_new_mention_count' );
|
109 |
+
update_usermeta( $user_id, 'bp_new_mention_count', $new_mention_count + 1 );
|
110 |
+
|
111 |
+
$content = str_replace( "@$username", "<a href='" . bp_core_get_user_domain( bp_core_get_userid( $username ) ) . "' rel='nofollow'>@$username</a>", $content );
|
112 |
+
}
|
113 |
+
|
114 |
+
return $content;
|
115 |
+
}
|
116 |
+
add_filter( 'bp_activity_new_update_content', 'bp_activity_at_name_filter' );
|
117 |
+
add_filter( 'groups_activity_new_update_content', 'bp_activity_at_name_filter' );
|
118 |
+
add_filter( 'pre_comment_content', 'bp_activity_at_name_filter' );
|
119 |
+
add_filter( 'group_forum_topic_text_before_save', 'bp_activity_at_name_filter' );
|
120 |
+
add_filter( 'group_forum_post_text_before_save', 'bp_activity_at_name_filter' );
|
121 |
+
add_filter( 'bp_activity_comment_content', 'bp_activity_at_name_filter' );
|
122 |
+
|
123 |
+
function bp_activity_make_nofollow_filter( $text ) {
|
124 |
+
return preg_replace_callback( '|<a (.+?)>|i', 'bp_activity_make_nofollow_filter_callback', $text );
|
125 |
+
}
|
126 |
+
function bp_activity_make_nofollow_filter_callback( $matches ) {
|
127 |
+
$text = $matches[1];
|
128 |
+
$text = str_replace( array( ' rel="nofollow"', " rel='nofollow'"), '', $text );
|
129 |
+
return "<a $text rel=\"nofollow\">";
|
130 |
+
}
|
131 |
|
132 |
?>
|
bp-activity/bp-activity-notifications.php
ADDED
@@ -0,0 +1,139 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
function bp_activity_at_message_notification( $content, $poster_user_id, $activity_id ) {
|
4 |
+
global $bp;
|
5 |
+
|
6 |
+
/* Scan for @username strings in an activity update. Notify each user. */
|
7 |
+
$pattern = '/[@]+([A-Za-z0-9-_]+)/';
|
8 |
+
preg_match_all( $pattern, $content, $usernames );
|
9 |
+
|
10 |
+
/* Make sure there's only one instance of each username */
|
11 |
+
if ( !$usernames = array_unique( $usernames[1] ) )
|
12 |
+
return false;
|
13 |
+
|
14 |
+
foreach( (array)$usernames as $username ) {
|
15 |
+
if ( !$receiver_user_id = bp_core_get_userid($username) )
|
16 |
+
continue;
|
17 |
+
|
18 |
+
// Now email the user with the contents of the message (if they have enabled email notifications)
|
19 |
+
if ( 'no' != get_usermeta( $user_id, 'notification_activity_new_mention' ) ) {
|
20 |
+
$poster_name = bp_core_get_user_displayname( $poster_user_id );
|
21 |
+
|
22 |
+
$message_link = bp_activity_get_permalink( $activity_id );
|
23 |
+
$settings_link = bp_core_get_user_domain( $receiver_user_id ) . BP_SETTINGS_SLUG . '/notifications/';
|
24 |
+
|
25 |
+
$poster_name = stripslashes( $poster_name );
|
26 |
+
$content = bp_activity_filter_kses( stripslashes($content) );
|
27 |
+
|
28 |
+
// Set up and send the message
|
29 |
+
$ud = bp_core_get_core_userdata( $receiver_user_id );
|
30 |
+
$to = $ud->user_email;
|
31 |
+
$subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( '%s mentioned you in an update', 'buddypress' ), $poster_name );
|
32 |
+
|
33 |
+
$message = sprintf( __(
|
34 |
+
'%s mentioned you in an update:
|
35 |
+
|
36 |
+
"%s"
|
37 |
+
|
38 |
+
To view and respond to the message, log in and visit: %s
|
39 |
+
|
40 |
+
---------------------
|
41 |
+
', 'buddypress' ), $poster_name, $content, $message_link );
|
42 |
+
|
43 |
+
$message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
|
44 |
+
|
45 |
+
/* Send the message */
|
46 |
+
$to = apply_filters( 'bp_activity_at_message_notification_to', $to );
|
47 |
+
$subject = apply_filters( 'bp_activity_at_message_notification_subject', $subject, $poster_name );
|
48 |
+
$message = apply_filters( 'bp_activity_at_message_notification_message', $message, $poster_name, $content, $message_link );
|
49 |
+
|
50 |
+
wp_mail( $to, $subject, $message );
|
51 |
+
}
|
52 |
+
}
|
53 |
+
}
|
54 |
+
add_action( 'bp_activity_posted_update', 'bp_activity_at_message_notification', 10, 3 );
|
55 |
+
|
56 |
+
function bp_activity_new_comment_notification( $comment_id, $commenter_id, $params ) {
|
57 |
+
global $bp;
|
58 |
+
|
59 |
+
extract( $params );
|
60 |
+
|
61 |
+
$original_activity = new BP_Activity_Activity( $activity_id );
|
62 |
+
|
63 |
+
if ( $original_activity->user_id != $commenter_id && 'no' != get_usermeta( $original_activity->user_id, 'notification_activity_new_reply' ) ) {
|
64 |
+
$poster_name = bp_core_get_user_displayname( $commenter_id );
|
65 |
+
$thread_link = bp_activity_get_permalink( $activity_id );
|
66 |
+
$settings_link = bp_core_get_user_domain( $original_activity->user_id ) . BP_SETTINGS_SLUG . '/notifications/';
|
67 |
+
|
68 |
+
$poster_name = stripslashes( $poster_name );
|
69 |
+
$content = bp_activity_filter_kses( stripslashes($content) );
|
70 |
+
|
71 |
+
// Set up and send the message
|
72 |
+
$ud = bp_core_get_core_userdata( $original_activity->user_id );
|
73 |
+
$to = $ud->user_email;
|
74 |
+
$subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( '%s replied to one of your updates', 'buddypress' ), $poster_name );
|
75 |
+
|
76 |
+
$message = sprintf( __(
|
77 |
+
'%s replied to one of your updates:
|
78 |
+
|
79 |
+
"%s"
|
80 |
+
|
81 |
+
To view your original update and all comments, log in and visit: %s
|
82 |
+
|
83 |
+
---------------------
|
84 |
+
', 'buddypress' ), $poster_name, $content, $thread_link );
|
85 |
+
|
86 |
+
$message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
|
87 |
+
|
88 |
+
/* Send the message */
|
89 |
+
$to = apply_filters( 'bp_activity_new_comment_notification_to', $to );
|
90 |
+
$subject = apply_filters( 'bp_activity_new_comment_notification_subject', $subject, $poster_name );
|
91 |
+
$message = apply_filters( 'bp_activity_new_comment_notification_message', $message, $poster_name, $content, $thread_link );
|
92 |
+
|
93 |
+
wp_mail( $to, $subject, $message );
|
94 |
+
}
|
95 |
+
|
96 |
+
/***
|
97 |
+
* If this is a reply to another comment, send an email notification to the
|
98 |
+
* author of the immediate parent comment.
|
99 |
+
*/
|
100 |
+
if ( $activity_id == $parent_id )
|
101 |
+
return false;
|
102 |
+
|
103 |
+
$parent_comment = new BP_Activity_Activity( $parent_id );
|
104 |
+
|
105 |
+
if ( $parent_comment->user_id != $commenter_id && $original_activity->user_id != $parent_comment->user_id && 'no' != get_usermeta( $parent_comment->user_id, 'notification_activity_new_reply' ) ) {
|
106 |
+
$poster_name = bp_core_get_user_displayname( $commenter_id );
|
107 |
+
$thread_link = bp_activity_get_permalink( $activity_id );
|
108 |
+
$settings_link = bp_core_get_user_domain( $parent_comment->user_id ) . BP_SETTINGS_SLUG . '/notifications/';
|
109 |
+
|
110 |
+
// Set up and send the message
|
111 |
+
$ud = bp_core_get_core_userdata( $parent_comment->user_id );
|
112 |
+
$to = $ud->user_email;
|
113 |
+
$subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( '%s replied to one of your comments', 'buddypress' ), $poster_name );
|
114 |
+
|
115 |
+
$poster_name = stripslashes( $poster_name );
|
116 |
+
$content = bp_activity_filter_kses( stripslashes( $content ) );
|
117 |
+
|
118 |
+
$message = sprintf( __(
|
119 |
+
'%s replied to one of your comments:
|
120 |
+
|
121 |
+
"%s"
|
122 |
+
|
123 |
+
To view the original activity, your comment and all replies, log in and visit: %s
|
124 |
+
|
125 |
+
---------------------
|
126 |
+
', 'buddypress' ), $poster_name, $content, $thread_link );
|
127 |
+
|
128 |
+
$message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
|
129 |
+
|
130 |
+
/* Send the message */
|
131 |
+
$to = apply_filters( 'bp_activity_new_comment_notification_comment_author_to', $to );
|
132 |
+
$subject = apply_filters( 'bp_activity_new_comment_notification_comment_author_subject', $subject, $poster_name );
|
133 |
+
$message = apply_filters( 'bp_activity_new_comment_notification_comment_author_message', $message, $poster_name, $content );
|
134 |
+
|
135 |
+
wp_mail( $to, $subject, $message );
|
136 |
+
}
|
137 |
+
}
|
138 |
+
|
139 |
+
?>
|
bp-activity/bp-activity-templatetags.php
CHANGED
@@ -6,7 +6,6 @@ class BP_Activity_Template {
|
|
6 |
var $total_activity_count;
|
7 |
var $activities;
|
8 |
var $activity;
|
9 |
-
var $activity_type;
|
10 |
|
11 |
var $in_the_loop;
|
12 |
|
@@ -16,21 +15,24 @@ class BP_Activity_Template {
|
|
16 |
|
17 |
var $full_name;
|
18 |
|
19 |
-
function bp_activity_template( $
|
20 |
global $bp;
|
21 |
|
22 |
-
$this->pag_page = isset( $_REQUEST['acpage'] ) ? intval( $_REQUEST['acpage'] ) :
|
23 |
$this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
|
24 |
-
$this->activity_type = $type;
|
25 |
|
26 |
-
if
|
27 |
-
|
28 |
|
29 |
-
|
30 |
-
|
31 |
|
32 |
-
if (
|
33 |
-
|
|
|
|
|
|
|
|
|
34 |
|
35 |
if ( !$max || $max >= (int)$this->activities['total'] )
|
36 |
$this->total_activity_count = (int)$this->activities['total'];
|
@@ -50,14 +52,28 @@ class BP_Activity_Template {
|
|
50 |
|
51 |
$this->full_name = $bp->displayed_user->fullname;
|
52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
if ( (int) $this->total_activity_count && (int) $this->pag_num ) {
|
54 |
$this->pag_links = paginate_links( array(
|
55 |
'base' => add_query_arg( 'acpage', '%#%' ),
|
56 |
'format' => '',
|
57 |
'total' => ceil( (int)$this->total_activity_count / (int)$this->pag_num ),
|
58 |
'current' => (int)$this->pag_page,
|
59 |
-
'prev_text' => '&
|
60 |
-
'next_text' => '&
|
61 |
'mid_size' => 1
|
62 |
));
|
63 |
}
|
@@ -114,36 +130,122 @@ class BP_Activity_Template {
|
|
114 |
function bp_has_activities( $args = '' ) {
|
115 |
global $bp, $activities_template;
|
116 |
|
117 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
|
|
|
119 |
$defaults = array(
|
120 |
-
'
|
121 |
-
'
|
122 |
-
'
|
123 |
-
'
|
124 |
-
'
|
125 |
-
'
|
126 |
-
'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
'secondary_id' => false, // secondary object ID to filter on e.g. a post_id
|
|
|
|
|
|
|
128 |
);
|
129 |
|
130 |
$r = wp_parse_args( $args, $defaults );
|
131 |
-
extract( $r
|
132 |
-
|
133 |
-
|
134 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
135 |
|
136 |
if ( $max ) {
|
137 |
if ( $per_page > $max )
|
138 |
$per_page = $max;
|
139 |
}
|
140 |
|
|
|
|
|
141 |
if ( isset( $_GET['afilter'] ) )
|
142 |
$filter = array( 'object' => $_GET['afilter'] );
|
143 |
-
else
|
144 |
-
$filter = array( 'object' => $object, 'action' => $action, 'primary_id' => $primary_id, 'secondary_id' => $secondary_id );
|
|
|
|
|
145 |
|
146 |
-
$activities_template = new BP_Activity_Template( $type, $user_id, $per_page, $max, $filter );
|
147 |
return apply_filters( 'bp_has_activities', $activities_template->has_activities(), &$activities_template );
|
148 |
}
|
149 |
|
@@ -158,14 +260,17 @@ function bp_the_activity() {
|
|
158 |
}
|
159 |
|
160 |
function bp_activity_pagination_count() {
|
161 |
-
|
|
|
|
|
|
|
162 |
|
163 |
-
|
164 |
-
|
|
|
165 |
|
166 |
-
|
167 |
-
|
168 |
-
}
|
169 |
|
170 |
function bp_activity_pagination_links() {
|
171 |
echo bp_get_activity_pagination_links();
|
@@ -176,6 +281,24 @@ function bp_activity_pagination_links() {
|
|
176 |
return apply_filters( 'bp_get_activity_pagination_links', $activities_template->pag_links );
|
177 |
}
|
178 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
179 |
function bp_activities_title() {
|
180 |
global $bp_activity_title;
|
181 |
|
@@ -198,6 +321,56 @@ function bp_activities_no_activity() {
|
|
198 |
return apply_filters( 'bp_get_activities_no_activity', $bp_activity_no_activity );
|
199 |
}
|
200 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
201 |
function bp_activity_user_id() {
|
202 |
echo bp_get_activity_user_id();
|
203 |
}
|
@@ -206,6 +379,20 @@ function bp_activity_user_id() {
|
|
206 |
return apply_filters( 'bp_get_activity_user_id', $activities_template->activity->user_id );
|
207 |
}
|
208 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
209 |
function bp_activity_avatar( $args = '' ) {
|
210 |
echo bp_get_activity_avatar( $args );
|
211 |
}
|
@@ -217,7 +404,8 @@ function bp_activity_avatar( $args = '' ) {
|
|
217 |
'width' => 20,
|
218 |
'height' => 20,
|
219 |
'class' => 'avatar',
|
220 |
-
'alt' => __( 'Avatar', 'buddypress' )
|
|
|
221 |
);
|
222 |
|
223 |
$r = wp_parse_args( $args, $defaults );
|
@@ -230,81 +418,263 @@ function bp_activity_avatar( $args = '' ) {
|
|
230 |
$item_id = $activities_template->activity->item_id;
|
231 |
|
232 |
$object = 'user';
|
233 |
-
if ( $bp->groups->id == $activities_template->activity->
|
234 |
$object = 'group';
|
235 |
-
if ( $bp->blogs->id == $activities_template->activity->
|
236 |
$object = 'blog';
|
237 |
|
238 |
-
$object = apply_filters( 'bp_get_activity_avatar_object_' . $activities_template->activity->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
239 |
|
240 |
-
return apply_filters( '
|
241 |
}
|
242 |
|
243 |
function bp_activity_content() {
|
244 |
echo bp_get_activity_content();
|
245 |
}
|
246 |
function bp_get_activity_content() {
|
247 |
-
global $activities_template
|
248 |
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
|
|
|
|
253 |
|
|
|
254 |
return apply_filters( 'bp_get_activity_content', $content );
|
255 |
}
|
256 |
|
257 |
-
function
|
258 |
-
|
259 |
|
260 |
-
|
261 |
-
|
262 |
|
263 |
-
|
264 |
-
|
265 |
|
266 |
-
|
267 |
-
|
268 |
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
280 |
|
281 |
-
|
282 |
-
|
283 |
-
|
|
|
|
|
|
|
284 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
285 |
}
|
|
|
|
|
286 |
|
287 |
-
|
288 |
-
|
289 |
-
$content[1] = '</span> <span class="activity-delete-link">' . bp_get_activity_delete_link() . '</span>' . $content[1];
|
290 |
|
291 |
-
|
|
|
|
|
|
|
292 |
|
293 |
-
|
294 |
-
|
295 |
|
296 |
-
|
|
|
297 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
298 |
|
299 |
-
function bp_activity_insert_time_since( $content, $date ) {
|
300 |
-
if ( !$content || !$date )
|
301 |
return false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
302 |
|
303 |
-
|
304 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
305 |
|
306 |
-
|
|
|
307 |
}
|
|
|
|
|
|
|
|
|
308 |
|
309 |
function bp_activity_css_class() {
|
310 |
echo bp_get_activity_css_class();
|
@@ -312,7 +682,23 @@ function bp_activity_css_class() {
|
|
312 |
function bp_get_activity_css_class() {
|
313 |
global $activities_template;
|
314 |
|
315 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
316 |
}
|
317 |
|
318 |
function bp_activity_delete_link() {
|
@@ -324,6 +710,24 @@ function bp_activity_delete_link() {
|
|
324 |
return apply_filters( 'bp_get_activity_delete_link', '<a href="' . wp_nonce_url( $bp->root_domain . '/' . $bp->activity->slug . '/delete/' . $activities_template->activity->id, 'bp_activity_delete_link' ) . '" class="item-button delete-activity confirm">' . __( 'Delete', 'buddypress' ) . '</a>' );
|
325 |
}
|
326 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
327 |
function bp_activity_filter_links( $args = false ) {
|
328 |
echo bp_get_activity_filter_links( $args );
|
329 |
}
|
@@ -338,46 +742,50 @@ function bp_activity_filter_links( $args = false ) {
|
|
338 |
extract( $r, EXTR_SKIP );
|
339 |
|
340 |
/* Fetch the names of components that have activity recorded in the DB */
|
341 |
-
$
|
342 |
|
343 |
-
if ( !$
|
344 |
return false;
|
345 |
|
346 |
-
foreach ( (array) $
|
347 |
-
|
|
|
|
|
|
|
|
|
348 |
$selected = ' class="selected"';
|
349 |
else
|
350 |
unset($selected);
|
351 |
|
352 |
-
$
|
353 |
|
354 |
switch ( $style ) {
|
355 |
case 'list':
|
356 |
$tag = 'li';
|
357 |
-
$before = '<li id="afilter-' . $
|
358 |
$after = '</li>';
|
359 |
break;
|
360 |
case 'paragraph':
|
361 |
$tag = 'p';
|
362 |
-
$before = '<p id="afilter-' . $
|
363 |
$after = '</p>';
|
364 |
break;
|
365 |
case 'span':
|
366 |
$tag = 'span';
|
367 |
-
$before = '<span id="afilter-' . $
|
368 |
$after = '</span>';
|
369 |
break;
|
370 |
}
|
371 |
|
372 |
-
$link = add_query_arg( 'afilter', $
|
373 |
$link = remove_query_arg( 'acpage' , $link );
|
374 |
|
375 |
-
$link = apply_filters( 'bp_get_activity_filter_link_href', $link, $
|
376 |
|
377 |
/* Make sure all core internal component names are translatable */
|
378 |
-
$
|
379 |
|
380 |
-
$component_links[] = $before . '<a href="' . attribute_escape( $link ) . '">' . ucwords( __( $
|
381 |
}
|
382 |
|
383 |
$link = remove_query_arg( 'afilter' , $link );
|
@@ -388,26 +796,84 @@ function bp_activity_filter_links( $args = false ) {
|
|
388 |
return apply_filters( 'bp_get_activity_filter_links', implode( "\n", $component_links ) );
|
389 |
}
|
390 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
391 |
function bp_sitewide_activity_feed_link() {
|
392 |
echo bp_get_sitewide_activity_feed_link();
|
393 |
}
|
394 |
function bp_get_sitewide_activity_feed_link() {
|
395 |
global $bp;
|
396 |
|
397 |
-
return apply_filters( 'bp_get_sitewide_activity_feed_link', site_url( $bp->activity->slug . '/feed' ) );
|
398 |
}
|
399 |
|
400 |
-
function
|
401 |
-
echo
|
402 |
}
|
403 |
-
|
|
|
|
|
404 |
global $bp;
|
405 |
|
406 |
-
if (
|
407 |
-
|
408 |
-
else
|
409 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
410 |
}
|
|
|
|
|
411 |
|
412 |
/* Template tags for RSS feed output */
|
413 |
|
@@ -426,8 +892,21 @@ function bp_activity_feed_item_title() {
|
|
426 |
function bp_get_activity_feed_item_title() {
|
427 |
global $activities_template;
|
428 |
|
429 |
-
|
430 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
431 |
}
|
432 |
|
433 |
function bp_activity_feed_item_link() {
|
@@ -454,7 +933,12 @@ function bp_activity_feed_item_description() {
|
|
454 |
function bp_get_activity_feed_item_description() {
|
455 |
global $activities_template;
|
456 |
|
457 |
-
|
|
|
|
|
|
|
|
|
|
|
458 |
}
|
459 |
|
460 |
?>
|
6 |
var $total_activity_count;
|
7 |
var $activities;
|
8 |
var $activity;
|
|
|
9 |
|
10 |
var $in_the_loop;
|
11 |
|
15 |
|
16 |
var $full_name;
|
17 |
|
18 |
+
function bp_activity_template( $page, $per_page, $max, $include, $sort, $filter, $search_terms, $display_comments, $show_hidden ) {
|
19 |
global $bp;
|
20 |
|
21 |
+
$this->pag_page = isset( $_REQUEST['acpage'] ) ? intval( $_REQUEST['acpage'] ) : $page;
|
22 |
$this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
|
|
|
23 |
|
24 |
+
/* Check if blog/forum replies are disabled */
|
25 |
+
$this->disable_blogforum_replies = $bp->site_options['bp-disable-blogforum-comments'];
|
26 |
|
27 |
+
/* Get an array of the logged in user's favorite activities */
|
28 |
+
$this->my_favs = maybe_unserialize( get_usermeta( $bp->loggedin_user->id, 'bp_favorite_activities' ) );
|
29 |
|
30 |
+
if ( !empty( $include ) ) {
|
31 |
+
/* Fetch specific activity items based on ID's */
|
32 |
+
$this->activities = bp_activity_get_specific( array( 'activity_ids' => explode( ',', $include ), 'max' => $max, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'sort' => $sort, 'display_comments' => $display_comments ) );
|
33 |
+
} else {
|
34 |
+
$this->activities = bp_activity_get( array( 'display_comments' => $display_comments, 'max' => $max, 'per_page' => $this->pag_num, 'page' => $this->pag_page, 'sort' => $sort, 'search_terms' => $search_terms, 'filter' => $filter, 'show_hidden' => $show_hidden ) );
|
35 |
+
}
|
36 |
|
37 |
if ( !$max || $max >= (int)$this->activities['total'] )
|
38 |
$this->total_activity_count = (int)$this->activities['total'];
|
52 |
|
53 |
$this->full_name = $bp->displayed_user->fullname;
|
54 |
|
55 |
+
/* Fetch parent content for activity comments so we do not have to query in the loop */
|
56 |
+
foreach ( (array)$this->activities as $activity ) {
|
57 |
+
if ( 'activity_comment' != $activity->type ) continue;
|
58 |
+
$parent_ids[] = $activity->item_id;
|
59 |
+
}
|
60 |
+
|
61 |
+
if ( !empty( $parent_ids ) )
|
62 |
+
$activity_parents = bp_activity_get_specific( array( 'activity_ids' => $parent_ids ) );
|
63 |
+
|
64 |
+
if ( !empty( $activity_parents['activities'] ) ) {
|
65 |
+
foreach( $activity_parents['activities'] as $parent ) $this->activity_parents[$parent->id] = $parent;
|
66 |
+
unset( $activity_parents );
|
67 |
+
}
|
68 |
+
|
69 |
if ( (int) $this->total_activity_count && (int) $this->pag_num ) {
|
70 |
$this->pag_links = paginate_links( array(
|
71 |
'base' => add_query_arg( 'acpage', '%#%' ),
|
72 |
'format' => '',
|
73 |
'total' => ceil( (int)$this->total_activity_count / (int)$this->pag_num ),
|
74 |
'current' => (int)$this->pag_page,
|
75 |
+
'prev_text' => '←',
|
76 |
+
'next_text' => '→',
|
77 |
'mid_size' => 1
|
78 |
));
|
79 |
}
|
130 |
function bp_has_activities( $args = '' ) {
|
131 |
global $bp, $activities_template;
|
132 |
|
133 |
+
/***
|
134 |
+
* Set the defaults based on the current page. Any of these will be overridden
|
135 |
+
* if arguments are directly passed into the loop. Custom plugins should always
|
136 |
+
* pass their parameters directly to the loop.
|
137 |
+
*/
|
138 |
+
$user_id = false;
|
139 |
+
$include = false;
|
140 |
+
$show_hidden = false;
|
141 |
+
$object = false;
|
142 |
+
$primary_id = false;
|
143 |
+
|
144 |
+
/* User filtering */
|
145 |
+
if ( !empty( $bp->displayed_user->id ) )
|
146 |
+
$user_id = $bp->displayed_user->id;
|
147 |
+
|
148 |
+
/* Group filtering */
|
149 |
+
if ( !empty( $bp->groups->current_group ) ) {
|
150 |
+
$object = $bp->groups->id;
|
151 |
+
$primary_id = $bp->groups->current_group->id;
|
152 |
+
|
153 |
+
if ( 'public' != $bp->groups->current_group->status && groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) )
|
154 |
+
$show_hidden = true;
|
155 |
+
}
|
156 |
+
|
157 |
+
/* Support for permalinks on single item pages: /groups/my-group/activity/124/ */
|
158 |
+
if ( $bp->current_action == $bp->activity->slug )
|
159 |
+
$include = $bp->action_variables[0];
|
160 |
|
161 |
+
/* Note: any params used for filtering can be a single value, or multiple values comma separated. */
|
162 |
$defaults = array(
|
163 |
+
'display_comments' => 'threaded', // false for none, stream/threaded - show comments in the stream or threaded under items
|
164 |
+
'include' => $include, // pass an activity_id or string of ID's comma separated
|
165 |
+
'sort' => 'DESC', // sort DESC or ASC
|
166 |
+
'page' => 1, // which page to load
|
167 |
+
'per_page' => 20, // number of items per page
|
168 |
+
'max' => false, // max number to return
|
169 |
+
'show_hidden' => $show_hidden, // Show activity items that are hidden site-wide?
|
170 |
+
|
171 |
+
/* Scope - pre-built activity filters for a user (friends/groups/favorites/mentions) */
|
172 |
+
'scope' => $bp->current_action,
|
173 |
+
|
174 |
+
/* Filtering */
|
175 |
+
'user_id' => $user_id, // user_id to filter on
|
176 |
+
'object' => $object, // object to filter on e.g. groups, profile, status, friends
|
177 |
+
'action' => false, // action to filter on e.g. activity_update, new_forum_post, profile_updated
|
178 |
+
'primary_id' => $primary_id, // object ID to filter on e.g. a group_id or forum_id or blog_id etc.
|
179 |
'secondary_id' => false, // secondary object ID to filter on e.g. a post_id
|
180 |
+
|
181 |
+
/* Searching */
|
182 |
+
'search_terms' => false // specify terms to search on
|
183 |
);
|
184 |
|
185 |
$r = wp_parse_args( $args, $defaults );
|
186 |
+
extract( $r );
|
187 |
+
|
188 |
+
/* If you have passed a "scope" then this will override any filters you have passed. */
|
189 |
+
if ( 'just-me' == $scope || 'friends' == $scope || 'groups' == $scope || 'favorites' == $scope || 'mentions' == $scope ) {
|
190 |
+
if ( 'just-me' == $scope )
|
191 |
+
$display_comments = 'stream';
|
192 |
+
|
193 |
+
$show_hidden = ( $user_id == $bp->loggedin_user->id ) ? 1 : 0;
|
194 |
+
|
195 |
+
if ( $user_id = ( !empty( $bp->displayed_user->id ) ) ? $bp->displayed_user->id : $bp->loggedin_user->id ) {
|
196 |
+
switch ( $scope ) {
|
197 |
+
case 'friends':
|
198 |
+
if ( function_exists( 'friends_get_friend_user_ids' ) )
|
199 |
+
$friends = friends_get_friend_user_ids( $user_id );
|
200 |
+
if ( empty( $friends ) )
|
201 |
+
return false;
|
202 |
+
|
203 |
+
$user_id = implode( ',', (array)$friends );
|
204 |
+
break;
|
205 |
+
case 'groups':
|
206 |
+
if ( function_exists( 'groups_get_user_groups' ) ) {
|
207 |
+
$groups = groups_get_user_groups( $user_id );
|
208 |
+
if ( empty( $groups['groups'] ) )
|
209 |
+
return false;
|
210 |
+
|
211 |
+
$object = $bp->groups->id;
|
212 |
+
$primary_id = implode( ',', (array)$groups['groups'] );
|
213 |
+
|
214 |
+
$user_id = false;
|
215 |
+
}
|
216 |
+
break;
|
217 |
+
case 'favorites':
|
218 |
+
$favs = bp_activity_get_user_favorites( $user_id );
|
219 |
+
if ( empty( $favs ) )
|
220 |
+
return false;
|
221 |
+
|
222 |
+
$include = implode( ',', (array)$favs );
|
223 |
+
break;
|
224 |
+
case 'mentions':
|
225 |
+
$user_nicename = ( !empty( $bp->displayed_user->id ) ) ? $bp->displayed_user->userdata->user_nicename : $bp->loggedin_user->userdata->user_nicename;
|
226 |
+
$user_login = ( !empty( $bp->displayed_user->id ) ) ? $bp->displayed_user->userdata->user_login : $bp->loggedin_user->userdata->user_login;
|
227 |
+
$search_terms = '@' . bp_core_get_username( $user_id, $user_nicename, $user_login );
|
228 |
+
$display_comments = 'stream';
|
229 |
+
$user_id = false;
|
230 |
+
break;
|
231 |
+
}
|
232 |
+
}
|
233 |
+
}
|
234 |
|
235 |
if ( $max ) {
|
236 |
if ( $per_page > $max )
|
237 |
$per_page = $max;
|
238 |
}
|
239 |
|
240 |
+
/* Support for basic filters in earlier BP versions. */
|
241 |
+
$filter = false;
|
242 |
if ( isset( $_GET['afilter'] ) )
|
243 |
$filter = array( 'object' => $_GET['afilter'] );
|
244 |
+
else if ( !empty( $user_id ) || !empty( $object ) || !empty( $action ) || !empty( $primary_id ) || !empty( $secondary_id ) )
|
245 |
+
$filter = array( 'user_id' => $user_id, 'object' => $object, 'action' => $action, 'primary_id' => $primary_id, 'secondary_id' => $secondary_id );
|
246 |
+
|
247 |
+
$activities_template = new BP_Activity_Template( $page, $per_page, $max, $include, $sort, $filter, $search_terms, $display_comments, $show_hidden );
|
248 |
|
|
|
249 |
return apply_filters( 'bp_has_activities', $activities_template->has_activities(), &$activities_template );
|
250 |
}
|
251 |
|
260 |
}
|
261 |
|
262 |
function bp_activity_pagination_count() {
|
263 |
+
echo bp_get_activity_pagination_count();
|
264 |
+
}
|
265 |
+
function bp_get_activity_pagination_count() {
|
266 |
+
global $bp, $activities_template;
|
267 |
|
268 |
+
$from_num = bp_core_number_format( intval( ( $activities_template->pag_page - 1 ) * $activities_template->pag_num ) + 1 );
|
269 |
+
$to_num = bp_core_number_format( ( $from_num + ( $activities_template->pag_num - 1 ) > $activities_template->total_activity_count ) ? $activities_template->total_activity_count : $from_num + ( $activities_template->pag_num - 1 ) );
|
270 |
+
$total = bp_core_number_format( $activities_template->total_activity_count );
|
271 |
|
272 |
+
return sprintf( __( 'Viewing item %s to %s (of %s items)', 'buddypress' ), $from_num, $to_num, $total ) . ' <span class="ajax-loader"></span>';
|
273 |
+
}
|
|
|
274 |
|
275 |
function bp_activity_pagination_links() {
|
276 |
echo bp_get_activity_pagination_links();
|
281 |
return apply_filters( 'bp_get_activity_pagination_links', $activities_template->pag_links );
|
282 |
}
|
283 |
|
284 |
+
function bp_activity_count() {
|
285 |
+
echo bp_get_activity_count();
|
286 |
+
}
|
287 |
+
function bp_get_activity_count() {
|
288 |
+
global $activities_template;
|
289 |
+
|
290 |
+
return apply_filters( 'bp_get_activity_count', (int)$activities_template->activity_count );
|
291 |
+
}
|
292 |
+
|
293 |
+
function bp_activity_per_page() {
|
294 |
+
echo bp_get_activity_per_page();
|
295 |
+
}
|
296 |
+
function bp_get_activity_per_page() {
|
297 |
+
global $activities_template;
|
298 |
+
|
299 |
+
return apply_filters( 'bp_get_activity_per_page', (int)$activities_template->pag_num );
|
300 |
+
}
|
301 |
+
|
302 |
function bp_activities_title() {
|
303 |
global $bp_activity_title;
|
304 |
|
321 |
return apply_filters( 'bp_get_activities_no_activity', $bp_activity_no_activity );
|
322 |
}
|
323 |
|
324 |
+
function bp_activity_id() {
|
325 |
+
echo bp_get_activity_id();
|
326 |
+
}
|
327 |
+
function bp_get_activity_id() {
|
328 |
+
global $activities_template;
|
329 |
+
return apply_filters( 'bp_get_activity_id', $activities_template->activity->id );
|
330 |
+
}
|
331 |
+
|
332 |
+
function bp_activity_item_id() {
|
333 |
+
echo bp_get_activity_item_id();
|
334 |
+
}
|
335 |
+
function bp_get_activity_item_id() {
|
336 |
+
global $activities_template;
|
337 |
+
return apply_filters( 'bp_get_activity_item_id', $activities_template->activity->item_id );
|
338 |
+
}
|
339 |
+
|
340 |
+
function bp_activity_secondary_item_id() {
|
341 |
+
echo bp_get_activity_secondary_item_id();
|
342 |
+
}
|
343 |
+
function bp_get_activity_secondary_item_id() {
|
344 |
+
global $activities_template;
|
345 |
+
return apply_filters( 'bp_get_activity_secondary_item_id', $activities_template->activity->secondary_item_id );
|
346 |
+
}
|
347 |
+
|
348 |
+
function bp_activity_date_recorded() {
|
349 |
+
echo bp_get_activity_date_recorded();
|
350 |
+
}
|
351 |
+
function bp_get_activity_date_recorded() {
|
352 |
+
global $activities_template;
|
353 |
+
return apply_filters( 'bp_get_activity_date_recorded', $activities_template->activity->date_recorded );
|
354 |
+
}
|
355 |
+
|
356 |
+
function bp_activity_object_name() {
|
357 |
+
echo bp_get_activity_object_name();
|
358 |
+
}
|
359 |
+
function bp_get_activity_object_name() {
|
360 |
+
global $activities_template;
|
361 |
+
return apply_filters( 'bp_get_activity_object_name', $activities_template->activity->component );
|
362 |
+
}
|
363 |
+
|
364 |
+
function bp_activity_type() {
|
365 |
+
echo bp_get_activity_type();
|
366 |
+
}
|
367 |
+
function bp_get_activity_type() {
|
368 |
+
global $activities_template;
|
369 |
+
return apply_filters( 'bp_get_activity_type', $activities_template->activity->type );
|
370 |
+
}
|
371 |
+
function bp_activity_action_name() { echo bp_activity_type(); }
|
372 |
+
function bp_get_activity_action_name() { return bp_get_activity_type(); }
|
373 |
+
|
374 |
function bp_activity_user_id() {
|
375 |
echo bp_get_activity_user_id();
|
376 |
}
|
379 |
return apply_filters( 'bp_get_activity_user_id', $activities_template->activity->user_id );
|
380 |
}
|
381 |
|
382 |
+
function bp_activity_user_link() {
|
383 |
+
echo bp_get_activity_user_link();
|
384 |
+
}
|
385 |
+
function bp_get_activity_user_link() {
|
386 |
+
global $activities_template;
|
387 |
+
|
388 |
+
if ( empty( $activities_template->activity->user_id ) )
|
389 |
+
$link = $activities_template->activity->primary_link;
|
390 |
+
else
|
391 |
+
$link = bp_core_get_user_domain( $activities_template->activity->user_id, $activities_template->activity->user_nicename, $activities_template->activity->user_login );
|
392 |
+
|
393 |
+
return apply_filters( 'bp_get_activity_user_link', $link );
|
394 |
+
}
|
395 |
+
|
396 |
function bp_activity_avatar( $args = '' ) {
|
397 |
echo bp_get_activity_avatar( $args );
|
398 |
}
|
404 |
'width' => 20,
|
405 |
'height' => 20,
|
406 |
'class' => 'avatar',
|
407 |
+
'alt' => __( 'Avatar', 'buddypress' ),
|
408 |
+
'email' => false
|
409 |
);
|
410 |
|
411 |
$r = wp_parse_args( $args, $defaults );
|
418 |
$item_id = $activities_template->activity->item_id;
|
419 |
|
420 |
$object = 'user';
|
421 |
+
if ( $bp->groups->id == $activities_template->activity->component && !(int) $activities_template->activity->user_id )
|
422 |
$object = 'group';
|
423 |
+
if ( $bp->blogs->id == $activities_template->activity->component && !(int) $activities_template->activity->user_id )
|
424 |
$object = 'blog';
|
425 |
|
426 |
+
$object = apply_filters( 'bp_get_activity_avatar_object_' . $activities_template->activity->component, $object );
|
427 |
+
|
428 |
+
/* If this is a user object pass the users' email address for Gravatar so we don't have to refetch it. */
|
429 |
+
if ( 'user' == $object && empty($email) )
|
430 |
+
$email = $activities_template->activity->user_email;
|
431 |
+
|
432 |
+
return apply_filters( 'bp_get_activity_avatar', bp_core_fetch_avatar( array( 'item_id' => $item_id, 'object' => $object, 'type' => $type, 'alt' => $alt, 'class' => $class, 'width' => $width, 'height' => $height, 'email' => $email ) ) );
|
433 |
+
}
|
434 |
+
|
435 |
+
function bp_activity_action() {
|
436 |
+
echo bp_get_activity_action();
|
437 |
+
}
|
438 |
+
function bp_get_activity_action() {
|
439 |
+
global $activities_template;
|
440 |
+
|
441 |
+
$action = $activities_template->activity->action;
|
442 |
+
|
443 |
+
if ( !empty( $action ) )
|
444 |
+
$action = bp_insert_activity_meta( $action );
|
445 |
+
|
446 |
+
return apply_filters( 'bp_get_activity_action', $action, &$activities_template->activity );
|
447 |
+
}
|
448 |
+
|
449 |
+
function bp_activity_content_body() {
|
450 |
+
echo bp_get_activity_content_body();
|
451 |
+
}
|
452 |
+
function bp_get_activity_content_body() {
|
453 |
+
global $activities_template;
|
454 |
+
|
455 |
+
/* Backwards compatibility if action is not being used */
|
456 |
+
if ( empty( $activities_template->activity->action ) && !empty( $activities_template->activity->content ) )
|
457 |
+
$activities_template->activity->content = bp_insert_activity_meta( $activities_template->activity->content );
|
458 |
|
459 |
+
return apply_filters( 'bp_get_activity_content_body', $activities_template->activity->content, &$activities_template->activity );
|
460 |
}
|
461 |
|
462 |
function bp_activity_content() {
|
463 |
echo bp_get_activity_content();
|
464 |
}
|
465 |
function bp_get_activity_content() {
|
466 |
+
global $activities_template;
|
467 |
|
468 |
+
/***
|
469 |
+
* If you want to filter activity update content, please use
|
470 |
+
* the filter 'bp_get_activity_content_body'
|
471 |
+
*
|
472 |
+
* This function is mainly for backwards comptibility.
|
473 |
+
*/
|
474 |
|
475 |
+
$content = bp_get_activity_action() . bp_get_activity_content_body();
|
476 |
return apply_filters( 'bp_get_activity_content', $content );
|
477 |
}
|
478 |
|
479 |
+
function bp_insert_activity_meta( $content ) {
|
480 |
+
global $activities_template, $bp;
|
481 |
|
482 |
+
/* Strip any legacy time since placeholders -- TODO: Remove this in 1.3 */
|
483 |
+
$content = str_replace( '<span class="time-since">%s</span>', '', $content );
|
484 |
|
485 |
+
/* Insert the time since. */
|
486 |
+
$content .= ' ' . apply_filters( 'bp_activity_time_since', '<span class="time-since">' . sprintf( __( ' %s ago', 'buddypress' ), bp_core_time_since( $activities_template->activity->date_recorded ) ) . '</span>', &$activities_template->activity );
|
487 |
|
488 |
+
/* Insert the permalink */
|
489 |
+
$content .= apply_filters( 'bp_activity_permalink', ' · <a href="' . bp_activity_get_permalink( $activities_template->activity->id, $activities_template->activity ) . '" class="view" title="' . __( 'View Thread / Permalink', 'buddypress' ) . '">' . __( 'View', 'buddypress' ) . '</a>', &$activities_template->activity );
|
490 |
|
491 |
+
/* Add the delete link if the user has permission on this item */
|
492 |
+
if ( ( is_user_logged_in() && $activities_template->activity->user_id == $bp->loggedin_user->id ) || $bp->is_item_admin || is_site_admin() )
|
493 |
+
$content .= apply_filters( 'bp_activity_delete_link', ' · ' . bp_get_activity_delete_link(), &$activities_template->activity );
|
494 |
|
495 |
+
return apply_filters( 'bp_insert_activity_meta', $content );
|
496 |
+
}
|
497 |
+
|
498 |
+
function bp_activity_parent_content( $args = '' ) {
|
499 |
+
echo bp_get_activity_parent_content($args);
|
500 |
+
}
|
501 |
+
function bp_get_activity_parent_content( $args = '' ) {
|
502 |
+
global $bp, $activities_template;
|
503 |
+
|
504 |
+
$defaults = array(
|
505 |
+
'hide_user' => false
|
506 |
+
);
|
507 |
+
|
508 |
+
$r = wp_parse_args( $args, $defaults );
|
509 |
+
extract( $r, EXTR_SKIP );
|
510 |
+
|
511 |
+
/* Get the ID of the parent activity content */
|
512 |
+
if ( !$parent_id = $activities_template->activity->item_id )
|
513 |
+
return false;
|
514 |
+
|
515 |
+
/* Get the content of the parent */
|
516 |
+
if ( empty( $activities_template->activity_parents[$parent_id] ) )
|
517 |
+
return false;
|
518 |
+
|
519 |
+
if ( empty( $activities_template->activity_parents[$parent_id]->content ) )
|
520 |
+
$content = $activities_template->activity_parents[$parent_id]->action;
|
521 |
+
else
|
522 |
+
$content = $activities_template->activity_parents[$parent_id]->action . $activities_template->activity_parents[$parent_id]->content;
|
523 |
+
|
524 |
+
/* Remove the time since content for backwards compatibility */
|
525 |
+
$content = str_replace( '<span class="time-since">%s</span>', '', $content );
|
526 |
+
|
527 |
+
/* Remove images */
|
528 |
+
$content = preg_replace( '/<img[^>]*>/Ui', '', $content );
|
529 |
+
|
530 |
+
return apply_filters( 'bp_get_activity_parent_content', $content );
|
531 |
+
}
|
532 |
+
|
533 |
+
function bp_activity_is_favorite() {
|
534 |
+
echo bp_get_is_activity_favorite();
|
535 |
+
}
|
536 |
+
function bp_get_activity_is_favorite() {
|
537 |
+
global $bp, $activities_template;
|
538 |
+
|
539 |
+
return apply_filters( 'bp_get_activity_is_favorite', in_array( $activities_template->activity->id, (array)$activities_template->my_favs ) );
|
540 |
+
}
|
541 |
+
|
542 |
+
function bp_activity_comments( $args = '' ) {
|
543 |
+
echo bp_activity_get_comments( $args );
|
544 |
+
}
|
545 |
+
function bp_activity_get_comments( $args = '' ) {
|
546 |
+
global $activities_template, $bp;
|
547 |
+
|
548 |
+
if ( !$activities_template->activity->children )
|
549 |
+
return false;
|
550 |
+
|
551 |
+
$comments_html = bp_activity_recurse_comments( $activities_template->activity );
|
552 |
+
|
553 |
+
return apply_filters( 'bp_activity_get_comments', $comments_html );
|
554 |
+
}
|
555 |
+
/* TODO: The HTML in this function is temporary and will be moved to the template in a future version. */
|
556 |
+
function bp_activity_recurse_comments( $comment ) {
|
557 |
+
global $activities_template, $bp;
|
558 |
+
|
559 |
+
if ( !$comment->children )
|
560 |
+
return false;
|
561 |
+
|
562 |
+
$content .= '<ul>';
|
563 |
+
foreach ( (array)$comment->children as $comment ) {
|
564 |
+
if ( !$comment->user_fullname )
|
565 |
+
$comment->user_fullname = $comment->display_name;
|
566 |
+
|
567 |
+
$content .= '<li id="acomment-' . $comment->id . '">';
|
568 |
+
$content .= '<div class="acomment-avatar"><a href="' . bp_core_get_user_domain( $comment->user_id, $comment->user_nicename, $comment->user_login ) . '">' . bp_core_fetch_avatar( array( 'item_id' => $comment->user_id, 'width' => 25, 'height' => 25, 'email' => $comment->user_email ) ) . '</a></div>';
|
569 |
+
$content .= '<div class="acomment-meta"><a href="' . bp_core_get_user_domain( $comment->user_id, $comment->user_nicename, $comment->user_login ) . '">' . apply_filters( 'bp_get_member_name', $comment->user_fullname ) . '</a> · ' . sprintf( __( '%s ago', 'buddypress' ), bp_core_time_since( strtotime( $comment->date_recorded ) ) );
|
570 |
+
|
571 |
+
/* Reply link - the span is so that threaded reply links can be hidden when JS is off. */
|
572 |
+
if ( is_user_logged_in() )
|
573 |
+
$content .= '<span class="acomment-replylink"> · <a href="#acomment-' . $comment->id . '" class="acomment-reply" id="acomment-reply-' . $activities_template->activity->id . '">' . __( 'Reply', 'buddypress' ) . '</a></span>';
|
574 |
+
|
575 |
+
/* Delete link */
|
576 |
+
if ( is_site_admin() || $bp->loggedin_user->id == $comment->user_id )
|
577 |
+
$content .= ' · <a href="' . wp_nonce_url( $bp->root_domain . '/' . $bp->activity->slug . '/delete/?cid=' . $comment->id, 'bp_activity_delete_link' ) . '" class="delete acomment-delete">' . __( 'Delete', 'buddypress' ) . '</a>';
|
578 |
+
|
579 |
+
$content .= '</div>';
|
580 |
+
$content .= '<div class="acomment-content">' . apply_filters( 'bp_get_activity_content', $comment->content ) . '</div>';
|
581 |
|
582 |
+
$content .= bp_activity_recurse_comments( $comment );
|
583 |
+
$content .= '</li>';
|
584 |
+
}
|
585 |
+
$content .= '</ul>';
|
586 |
+
|
587 |
+
return apply_filters( 'bp_activity_recurse_comments', $content );
|
588 |
}
|
589 |
+
|
590 |
+
function bp_activity_comment_count() {
|
591 |
+
echo bp_activity_get_comment_count();
|
592 |
+
}
|
593 |
+
function bp_activity_get_comment_count( $args = '' ) {
|
594 |
+
global $activities_template, $bp;
|
595 |
+
|
596 |
+
if ( !$activities_template->activity->children )
|
597 |
+
return 0;
|
598 |
+
|
599 |
+
$count = bp_activity_recurse_comment_count( $activities_template->activity );
|
600 |
+
|
601 |
+
return apply_filters( 'bp_activity_get_comment_count', (int)$count );
|
602 |
}
|
603 |
+
function bp_activity_recurse_comment_count( $comment, $count = 0 ) {
|
604 |
+
global $activities_template, $bp;
|
605 |
|
606 |
+
if ( !$comment->children )
|
607 |
+
return $count;
|
|
|
608 |
|
609 |
+
foreach ( (array)$comment->children as $comment ) {
|
610 |
+
$count++;
|
611 |
+
$count = bp_activity_recurse_comment_count( $comment, $count );
|
612 |
+
}
|
613 |
|
614 |
+
return $count;
|
615 |
+
}
|
616 |
|
617 |
+
function bp_activity_comment_link() {
|
618 |
+
echo bp_get_activity_comment_link();
|
619 |
}
|
620 |
+
function bp_get_activity_comment_link() {
|
621 |
+
global $activities_template;
|
622 |
+
return apply_filters( 'bp_get_activity_comment_link', '?ac=' . $activities_template->activity->id . '/#ac-form-' . $activities_template->activity->id );
|
623 |
+
}
|
624 |
+
|
625 |
+
function bp_activity_comment_form_nojs_display() {
|
626 |
+
echo bp_get_activity_comment_form_nojs_display();
|
627 |
+
}
|
628 |
+
function bp_get_activity_comment_form_nojs_display() {
|
629 |
+
global $activities_template;
|
630 |
+
if ( $_GET['ac'] == $activities_template->activity->id . '/' )
|
631 |
+
return 'style="display: block"';
|
632 |
|
|
|
|
|
633 |
return false;
|
634 |
+
}
|
635 |
+
|
636 |
+
function bp_activity_comment_form_action() {
|
637 |
+
echo bp_get_activity_comment_form_action();
|
638 |
+
}
|
639 |
+
function bp_get_activity_comment_form_action() {
|
640 |
+
return apply_filters( 'bp_get_activity_comment_form_action', site_url( BP_ACTIVITY_SLUG . '/reply/' ) );
|
641 |
+
}
|
642 |
|
643 |
+
function bp_activity_permalink_id() {
|
644 |
+
echo bp_get_activity_permalink_id();
|
645 |
+
}
|
646 |
+
function bp_get_activity_permalink_id() {
|
647 |
+
global $bp;
|
648 |
+
|
649 |
+
return apply_filters( 'bp_get_activity_permalink_id', $bp->current_action );
|
650 |
+
}
|
651 |
+
|
652 |
+
function bp_activity_thread_permalink() {
|
653 |
+
echo bp_get_activity_thread_permalink();
|
654 |
+
}
|
655 |
+
function bp_get_activity_thread_permalink() {
|
656 |
+
global $bp, $activities_template;
|
657 |
+
|
658 |
+
$link = bp_activity_get_permalink( $activities_template->activity->id, $activities_template->activity );
|
659 |
+
|
660 |
+
return apply_filters( 'bp_get_activity_thread_permalink', $link );
|
661 |
+
}
|
662 |
+
|
663 |
+
function bp_activity_favorite_link() {
|
664 |
+
echo bp_get_activity_favorite_link();
|
665 |
+
}
|
666 |
+
function bp_get_activity_favorite_link() {
|
667 |
+
global $activities_template;
|
668 |
+
return apply_filters( 'bp_get_activity_favorite_link', wp_nonce_url( site_url( BP_ACTIVITY_SLUG . '/favorite/' . $activities_template->activity->id . '/' ), 'mark_favorite' ) );
|
669 |
+
}
|
670 |
|
671 |
+
function bp_activity_unfavorite_link() {
|
672 |
+
echo bp_get_activity_unfavorite_link();
|
673 |
}
|
674 |
+
function bp_get_activity_unfavorite_link() {
|
675 |
+
global $activities_template;
|
676 |
+
return apply_filters( 'bp_get_activity_unfavorite_link', wp_nonce_url( site_url( BP_ACTIVITY_SLUG . '/unfavorite/' . $activities_template->activity->id . '/' ), 'unmark_favorite' ) );
|
677 |
+
}
|
678 |
|
679 |
function bp_activity_css_class() {
|
680 |
echo bp_get_activity_css_class();
|
682 |
function bp_get_activity_css_class() {
|
683 |
global $activities_template;
|
684 |
|
685 |
+
$mini_activity_actions = apply_filters( 'bp_activity_mini_activity_types', array(
|
686 |
+
'friendship_accepted',
|
687 |
+
'friendship_created',
|
688 |
+
'new_blog',
|
689 |
+
'joined_group',
|
690 |
+
'created_group',
|
691 |
+
'new_member'
|
692 |
+
) );
|
693 |
+
|
694 |
+
$class = '';
|
695 |
+
if ( in_array( $activities_template->activity->type, (array)$mini_activity_actions ) || empty( $activities_template->activity->content ) )
|
696 |
+
$class = ' mini';
|
697 |
+
|
698 |
+
if ( bp_activity_get_comment_count() && bp_activity_can_comment() )
|
699 |
+
$class .= ' has-comments';
|
700 |
+
|
701 |
+
return apply_filters( 'bp_get_activity_css_class', $activities_template->activity->component . ' ' . $activities_template->activity->type . $class );
|
702 |
}
|
703 |
|
704 |
function bp_activity_delete_link() {
|
710 |
return apply_filters( 'bp_get_activity_delete_link', '<a href="' . wp_nonce_url( $bp->root_domain . '/' . $bp->activity->slug . '/delete/' . $activities_template->activity->id, 'bp_activity_delete_link' ) . '" class="item-button delete-activity confirm">' . __( 'Delete', 'buddypress' ) . '</a>' );
|
711 |
}
|
712 |
|
713 |
+
function bp_activity_latest_update( $user_id = false ) {
|
714 |
+
echo bp_get_activity_latest_update( $user_id );
|
715 |
+
}
|
716 |
+
function bp_get_activity_latest_update( $user_id = false ) {
|
717 |
+
global $bp;
|
718 |
+
|
719 |
+
if ( !$user_id )
|
720 |
+
$user_id = $bp->displayed_user->id;
|
721 |
+
|
722 |
+
if ( !$update = get_usermeta( $user_id, 'bp_latest_update' ) )
|
723 |
+
return false;
|
724 |
+
|
725 |
+
$latest_update = '"' . trim( strip_tags( bp_create_excerpt( $update['content'], 40 ) ) ) . '"';
|
726 |
+
$latest_update .= ' · <a href="' . $bp->root_domain . '/' . BP_ACTIVITY_SLUG . '/p/' . $update['id'] . '/"> ' . __( 'View', 'buddypress' ) . '</a>';
|
727 |
+
|
728 |
+
return apply_filters( 'bp_get_activity_latest_update', $latest_update );
|
729 |
+
}
|
730 |
+
|
731 |
function bp_activity_filter_links( $args = false ) {
|
732 |
echo bp_get_activity_filter_links( $args );
|
733 |
}
|
742 |
extract( $r, EXTR_SKIP );
|
743 |
|
744 |
/* Fetch the names of components that have activity recorded in the DB */
|
745 |
+
$components = BP_Activity_Activity::get_recorded_components();
|
746 |
|
747 |
+
if ( !$components )
|
748 |
return false;
|
749 |
|
750 |
+
foreach ( (array) $components as $component ) {
|
751 |
+
/* Skip the activity comment filter */
|
752 |
+
if ( 'activity' == $component )
|
753 |
+
continue;
|
754 |
+
|
755 |
+
if ( isset( $_GET['afilter'] ) && $component == $_GET['afilter'] )
|
756 |
$selected = ' class="selected"';
|
757 |
else
|
758 |
unset($selected);
|
759 |
|
760 |
+
$component = attribute_escape( $component );
|
761 |
|
762 |
switch ( $style ) {
|
763 |
case 'list':
|
764 |
$tag = 'li';
|
765 |
+
$before = '<li id="afilter-' . $component . '"' . $selected . '>';
|
766 |
$after = '</li>';
|
767 |
break;
|
768 |
case 'paragraph':
|
769 |
$tag = 'p';
|
770 |
+
$before = '<p id="afilter-' . $component . '"' . $selected . '>';
|
771 |
$after = '</p>';
|
772 |
break;
|
773 |
case 'span':
|
774 |
$tag = 'span';
|
775 |
+
$before = '<span id="afilter-' . $component . '"' . $selected . '>';
|
776 |
$after = '</span>';
|
777 |
break;
|
778 |
}
|
779 |
|
780 |
+
$link = add_query_arg( 'afilter', $component );
|
781 |
$link = remove_query_arg( 'acpage' , $link );
|
782 |
|
783 |
+
$link = apply_filters( 'bp_get_activity_filter_link_href', $link, $component );
|
784 |
|
785 |
/* Make sure all core internal component names are translatable */
|
786 |
+
$translatable_components = array( __( 'profile', 'buddypress'), __( 'friends', 'buddypress' ), __( 'groups', 'buddypress' ), __( 'status', 'buddypress' ), __( 'blogs', 'buddypress' ) );
|
787 |
|
788 |
+
$component_links[] = $before . '<a href="' . attribute_escape( $link ) . '">' . ucwords( __( $component, 'buddypress' ) ) . '</a>' . $after;
|
789 |
}
|
790 |
|
791 |
$link = remove_query_arg( 'afilter' , $link );
|
796 |
return apply_filters( 'bp_get_activity_filter_links', implode( "\n", $component_links ) );
|
797 |
}
|
798 |
|
799 |
+
function bp_activity_can_comment() {
|
800 |
+
global $activities_template, $bp;
|
801 |
+
|
802 |
+
if ( false === $activities_template->disable_blogforum_replies || (int)$activities_template->disable_blogforum_replies ) {
|
803 |
+
if ( 'new_blog_post' == bp_get_activity_action_name() || 'new_blog_comment' == bp_get_activity_action_name() || 'new_forum_topic' == bp_get_activity_action_name() || 'new_forum_post' == bp_get_activity_action_name() )
|
804 |
+
return false;
|
805 |
+
}
|
806 |
+
|
807 |
+
if ( 'activity_comment' == bp_get_activity_action_name() )
|
808 |
+
return false;
|
809 |
+
|
810 |
+
return true;
|
811 |
+
}
|
812 |
+
|
813 |
+
function bp_total_favorite_count_for_user( $user_id = false ) {
|
814 |
+
echo bp_get_total_favorite_count_for_user( $user_id );
|
815 |
+
}
|
816 |
+
function bp_get_total_favorite_count_for_user( $user_id = false ) {
|
817 |
+
return apply_filters( 'bp_get_total_favorite_count_for_user', bp_activity_total_favorites_for_user( $user_id ) );
|
818 |
+
}
|
819 |
+
|
820 |
+
function bp_total_mention_count_for_user( $user_id = false ) {
|
821 |
+
echo bp_get_total_favorite_count_for_user( $user_id );
|
822 |
+
}
|
823 |
+
function bp_get_total_mention_count_for_user( $user_id = false ) {
|
824 |
+
return apply_filters( 'bp_get_total_mention_count_for_user', get_usermeta( $user_id, 'bp_new_mention_count' ) );
|
825 |
+
}
|
826 |
+
|
827 |
+
function bp_send_public_message_link() {
|
828 |
+
echo bp_get_send_public_message_link();
|
829 |
+
}
|
830 |
+
function bp_get_send_public_message_link() {
|
831 |
+
global $bp;
|
832 |
+
|
833 |
+
return apply_filters( 'bp_get_send_public_message_link', $bp->loggedin_user->domain . $bp->activity->slug . '/?r=' . bp_core_get_username( $bp->displayed_user->user_id, $bp->displayed_user->userdata->user_nicename, $bp->displayed_user->userdata->user_login ) );
|
834 |
+
}
|
835 |
+
|
836 |
+
function bp_activity_post_form_action() {
|
837 |
+
echo bp_get_activity_post_form_action();
|
838 |
+
}
|
839 |
+
function bp_get_activity_post_form_action() {
|
840 |
+
return apply_filters( 'bp_get_activity_post_form_action', site_url( BP_ACTIVITY_SLUG . '/post/' ) );
|
841 |
+
}
|
842 |
+
|
843 |
+
/* RSS Feed Template Tags ***************************/
|
844 |
+
|
845 |
function bp_sitewide_activity_feed_link() {
|
846 |
echo bp_get_sitewide_activity_feed_link();
|
847 |
}
|
848 |
function bp_get_sitewide_activity_feed_link() {
|
849 |
global $bp;
|
850 |
|
851 |
+
return apply_filters( 'bp_get_sitewide_activity_feed_link', site_url( $bp->activity->slug . '/feed/' ) );
|
852 |
}
|
853 |
|
854 |
+
function bp_member_activity_feed_link() {
|
855 |
+
echo bp_get_member_activity_feed_link();
|
856 |
}
|
857 |
+
function bp_activities_member_rss_link() { echo bp_get_member_activity_feed_link(); }
|
858 |
+
|
859 |
+
function bp_get_member_activity_feed_link() {
|
860 |
global $bp;
|
861 |
|
862 |
+
if ( $bp->current_component == $bp->profile->slug || 'just-me' == $bp->current_action )
|
863 |
+
$link = $bp->displayed_user->domain . $bp->activity->slug . '/feed/';
|
864 |
+
else if ( 'friends' == $bp->current_action )
|
865 |
+
$link = $bp->displayed_user->domain . $bp->activity->slug . '/friends/feed/';
|
866 |
+
else if ( 'groups' == $bp->current_action )
|
867 |
+
$link = $bp->displayed_user->domain . $bp->activity->slug . '/groups/feed/';
|
868 |
+
else if ( 'favorites' == $bp->current_action )
|
869 |
+
$link = $bp->displayed_user->domain . $bp->activity->slug . '/favorites/feed/';
|
870 |
+
else if ( 'mentions' == $bp->current_action )
|
871 |
+
$link = $bp->displayed_user->domain . $bp->activity->slug . '/mentions/feed/';
|
872 |
+
|
873 |
+
return apply_filters( 'bp_get_activities_member_rss_link', $link );
|
874 |
}
|
875 |
+
function bp_get_activities_member_rss_link() { return bp_get_member_activity_feed_link(); }
|
876 |
+
|
877 |
|
878 |
/* Template tags for RSS feed output */
|
879 |
|
892 |
function bp_get_activity_feed_item_title() {
|
893 |
global $activities_template;
|
894 |
|
895 |
+
if ( !empty( $activities_template->activity->action ) )
|
896 |
+
$content = $activities_template->activity->action;
|
897 |
+
else
|
898 |
+
$content = $activities_template->activity->content;
|
899 |
+
|
900 |
+
$content = explode( '<span', $content );
|
901 |
+
$title = trim( strip_tags( html_entity_decode( utf8_encode( $content[0] ) ) ) );
|
902 |
+
|
903 |
+
if ( ':' == substr( $title, -1 ) )
|
904 |
+
$title = substr( $title, 0, -1 );
|
905 |
+
|
906 |
+
if ( 'activity_update' == $activities_template->activity->type )
|
907 |
+
$title .= ': ' . strip_tags( bp_create_excerpt( $activities_template->activity->content, 15 ) );
|
908 |
+
|
909 |
+
return apply_filters( 'bp_get_activity_feed_item_title', $title );
|
910 |
}
|
911 |
|
912 |
function bp_activity_feed_item_link() {
|
933 |
function bp_get_activity_feed_item_description() {
|
934 |
global $activities_template;
|
935 |
|
936 |
+
if ( empty( $activities_template->activity->action ) )
|
937 |
+
$content = $activities_template->activity->content;
|
938 |
+
else
|
939 |
+
$content = $activities_template->activity->action . $activities_template->activity->content;
|
940 |
+
|
941 |
+
return apply_filters( 'bp_get_activity_feed_item_description', html_entity_decode( str_replace( '%s', '', $content ) ) );
|
942 |
}
|
943 |
|
944 |
?>
|
bp-activity/bp-activity-widgets.php
DELETED
@@ -1,87 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/* Register widgets for blogs component */
|
4 |
-
function bp_activity_register_widgets() {
|
5 |
-
add_action('widgets_init', create_function('', 'return register_widget("BP_Activity_Widget");') );
|
6 |
-
}
|
7 |
-
add_action( 'plugins_loaded', 'bp_activity_register_widgets' );
|
8 |
-
|
9 |
-
class BP_Activity_Widget extends WP_Widget {
|
10 |
-
function bp_activity_widget() {
|
11 |
-
parent::WP_Widget( false, $name = __( 'Site Wide Activity', 'buddypress' ) );
|
12 |
-
}
|
13 |
-
|
14 |
-
function widget($args, $instance) {
|
15 |
-
global $bp;
|
16 |
-
|
17 |
-
extract( $args );
|
18 |
-
|
19 |
-
echo $before_widget;
|
20 |
-
echo $before_title
|
21 |
-
. $widget_name .
|
22 |
-
' <a class="rss-image" href="' . bp_get_sitewide_activity_feed_link() . '" title="' . __( 'Site Wide Activity RSS Feed', 'buddypress' ) . '">' . __( '[RSS]', 'buddypress' ) . '</a>'
|
23 |
-
. $after_title; ?>
|
24 |
-
|
25 |
-
<?php if ( bp_has_activities( 'type=sitewide&max=' . $instance['max_items'] . '&per_page=' . $instance['per_page'] ) ) : ?>
|
26 |
-
|
27 |
-
<?php if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) ) : ?>
|
28 |
-
<div class="pagination">
|
29 |
-
<div class="pag-count" id="activity-count">
|
30 |
-
<?php bp_activity_pagination_count() ?>
|
31 |
-
</div>
|
32 |
-
|
33 |
-
<div class="pagination-links" id="activity-pag">
|
34 |
-
<?php bp_activity_pagination_links() ?>
|
35 |
-
</div>
|
36 |
-
</div>
|
37 |
-
|
38 |
-
<ul id="activity-filter-links">
|
39 |
-
<?php bp_activity_filter_links() ?>
|
40 |
-
</ul>
|
41 |
-
<?php endif; ?>
|
42 |
-
|
43 |
-
<ul id="site-wide-stream" class="activity-list">
|
44 |
-
<?php while ( bp_activities() ) : bp_the_activity(); ?>
|
45 |
-
<li class="<?php bp_activity_css_class() ?>">
|
46 |
-
<?php if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) ) : ?>
|
47 |
-
<div class="activity-avatar">
|
48 |
-
<?php bp_activity_avatar() ?>
|
49 |
-
</div>
|
50 |
-
<?php endif; ?>
|
51 |
-
|
52 |
-
<?php bp_activity_content() ?>
|
53 |
-
</li>
|
54 |
-
<?php endwhile; ?>
|
55 |
-
</ul>
|
56 |
-
|
57 |
-
<?php else: ?>
|
58 |
-
|
59 |
-
<div class="widget-error">
|
60 |
-
<?php _e('There has been no recent site activity.', 'buddypress') ?>
|
61 |
-
</div>
|
62 |
-
<?php endif;?>
|
63 |
-
|
64 |
-
<?php echo $after_widget; ?>
|
65 |
-
<?php
|
66 |
-
}
|
67 |
-
|
68 |
-
function update( $new_instance, $old_instance ) {
|
69 |
-
$instance = $old_instance;
|
70 |
-
$instance['max_items'] = strip_tags( $new_instance['max_items'] );
|
71 |
-
$instance['per_page'] = strip_tags( $new_instance['per_page'] );
|
72 |
-
|
73 |
-
return $instance;
|
74 |
-
}
|
75 |
-
|
76 |
-
function form( $instance ) {
|
77 |
-
$instance = wp_parse_args( (array) $instance, array( 'max_items' => 200, 'per_page' => 25 ) );
|
78 |
-
$per_page = strip_tags( $instance['per_page'] );
|
79 |
-
$max_items = strip_tags( $instance['max_items'] );
|
80 |
-
?>
|
81 |
-
|
82 |
-
<p><label for="bp-activity-widget-sitewide-per-page"><?php _e('Number of Items Per Page:', 'buddypress'); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'per_page' ); ?>" name="<?php echo $this->get_field_name( 'per_page' ); ?>" type="text" value="<?php echo attribute_escape( $per_page ); ?>" style="width: 30%" /></label></p>
|
83 |
-
<p><label for="bp-core-widget-members-max"><?php _e('Max items to show:', 'buddypress'); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'max_items' ); ?>" name="<?php echo $this->get_field_name( 'max_items' ); ?>" type="text" value="<?php echo attribute_escape( $max_items ); ?>" style="width: 30%" /></label></p>
|
84 |
-
<?php
|
85 |
-
}
|
86 |
-
}
|
87 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bp-activity/deprecated/bp-activity-deprecated.php
DELETED
@@ -1,95 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/***
|
3 |
-
* Deprecated Activity Stream Functionality
|
4 |
-
*
|
5 |
-
* This file contains functions that are deprecated.
|
6 |
-
* You should not under any circumstance use these functions as they are
|
7 |
-
* either no longer valid, or have been replaced with something much more awesome.
|
8 |
-
*
|
9 |
-
* If you are using functions in this file you should slap the back of your head
|
10 |
-
* and then use the functions or solutions that have replaced them.
|
11 |
-
* Most functions contain a note telling you what you should be doing or using instead.
|
12 |
-
*
|
13 |
-
* Of course, things will still work if you use these functions but you will
|
14 |
-
* be the laughing stock of the BuddyPress community. We will all point and laugh at
|
15 |
-
* you. You'll also be making things harder for yourself in the long run,
|
16 |
-
* and you will miss out on lovely performance and functionality improvements.
|
17 |
-
*
|
18 |
-
* If you've checked you are not using any deprecated functions and finished your little
|
19 |
-
* dance, you can add the following line to your wp-config.php file to prevent any of
|
20 |
-
* these old functions from being loaded:
|
21 |
-
*
|
22 |
-
* define( 'BP_IGNORE_DEPRECATED', true );
|
23 |
-
*/
|
24 |
-
|
25 |
-
function bp_activity_deprecated_globals() {
|
26 |
-
global $bp;
|
27 |
-
|
28 |
-
/* If we are using a BuddyPress 1.1+ theme ignore this. */
|
29 |
-
if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
|
30 |
-
return $template;
|
31 |
-
|
32 |
-
$bp->activity->image_base = BP_PLUGIN_URL . '/bp-activity/images';
|
33 |
-
}
|
34 |
-
add_action( 'plugins_loaded', 'bp_activity_deprecated_globals', 5 );
|
35 |
-
add_action( 'admin_menu', 'bp_activity_deprecated_globals', 2 );
|
36 |
-
|
37 |
-
/* DEPRECATED - use bp_activity_add() */
|
38 |
-
function bp_activity_record( $item_id, $component_name, $component_action, $is_private, $secondary_item_id = false, $user_id = false, $secondary_user_id = false, $recorded_time = false ) {
|
39 |
-
global $bp, $wpdb;
|
40 |
-
|
41 |
-
if ( !$user_id )
|
42 |
-
$user_id = $bp->loggedin_user->id;
|
43 |
-
|
44 |
-
if ( !$recorded_time )
|
45 |
-
$recorded_time = time();
|
46 |
-
|
47 |
-
$args = compact( 'user_id', 'content', 'component_name', 'component_action', 'item_id', 'secondary_item_id', 'recorded_time' );
|
48 |
-
bp_activity_add( $args );
|
49 |
-
|
50 |
-
if ( $secondary_user_id ) {
|
51 |
-
$hide_sitewide = true;
|
52 |
-
$args = compact( 'user_id', 'content', 'component_name', 'component_action', 'item_id', 'secondary_item_id', 'recorded_time', 'hide_sitewide' );
|
53 |
-
bp_activity_add( $args );
|
54 |
-
}
|
55 |
-
|
56 |
-
do_action( 'bp_activity_record', $item_id, $component_name, $component_action, $is_private, $secondary_item_id, $user_id, $secondary_user_id );
|
57 |
-
|
58 |
-
return true;
|
59 |
-
}
|
60 |
-
|
61 |
-
/* DEPRECATED - use bp_activity_delete_by_item_id() */
|
62 |
-
function bp_activity_delete( $item_id, $component_name, $component_action, $user_id, $secondary_item_id ) {
|
63 |
-
if ( !bp_activity_delete_by_item_id( array( 'item_id' => $item_id, 'component_name' => $component_name, 'component_action' => $component_action, 'user_id' => $user_id, 'secondary_item_id' => $secondary_item_id ) ) )
|
64 |
-
return false;
|
65 |
-
|
66 |
-
do_action( 'bp_activity_delete', $item_id, $component_name, $component_action, $user_id, $secondary_item_id );
|
67 |
-
|
68 |
-
return true;
|
69 |
-
}
|
70 |
-
|
71 |
-
/* DEPRECATED - use the activity template loop directly */
|
72 |
-
function bp_activity_get_list( $user_id, $title, $no_activity, $limit = false ) {
|
73 |
-
global $bp_activity_user_id, $bp_activity_limit, $bp_activity_title, $bp_activity_no_activity;
|
74 |
-
|
75 |
-
$bp_activity_user_id = $user_id;
|
76 |
-
$bp_activity_limit = $limit;
|
77 |
-
$bp_activity_title = $title;
|
78 |
-
$bp_activity_no_activity = $no_activity;
|
79 |
-
|
80 |
-
locate_template( array( '/activity/activity-list.php' ), true );
|
81 |
-
}
|
82 |
-
|
83 |
-
|
84 |
-
/* DEPRECATED - Structural CSS is now theme based. */
|
85 |
-
function bp_activity_add_structure_css() {
|
86 |
-
/* If we are using a BuddyPress 1.1+ theme ignore this. */
|
87 |
-
if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
|
88 |
-
return $template;
|
89 |
-
|
90 |
-
/* Enqueue the structure CSS file to give basic positional formatting for components */
|
91 |
-
wp_enqueue_style( 'bp-activity-structure', BP_PLUGIN_URL . '/bp-activity/deprecated/css/structure.css' );
|
92 |
-
}
|
93 |
-
add_action( 'bp_styles', 'bp_activity_add_structure_css' );
|
94 |
-
|
95 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bp-activity/deprecated/css/structure.css
DELETED
@@ -1,15 +0,0 @@
|
|
1 |
-
/*
|
2 |
-
Basic layout structure styles for BuddyPress Activity Streams. Formats BuddyPress activity pages within any WordPress theme.
|
3 |
-
No colors, fonts or pretty stuff.
|
4 |
-
|
5 |
-
These structure styles can be overridden by the theme CSS file if needed.
|
6 |
-
*/
|
7 |
-
|
8 |
-
#activity-list li {
|
9 |
-
margin: 15px 0;
|
10 |
-
}
|
11 |
-
|
12 |
-
#activity-list li blockquote {
|
13 |
-
padding: 7px 15px 7px 40px;
|
14 |
-
margin: 5px 0;
|
15 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bp-activity/deprecated/images/rss.png
DELETED
Binary file
|
bp-activity/feeds/bp-activity-favorites-feed.php
ADDED
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* RSS2 Feed Template for displaying a member's favorite activity
|
4 |
+
*
|
5 |
+
* @package BuddyPress
|
6 |
+
*/
|
7 |
+
header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
|
8 |
+
header('Status: 200 OK');
|
9 |
+
?>
|
10 |
+
<?php echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?>
|
11 |
+
|
12 |
+
<rss version="2.0"
|
13 |
+
xmlns:content="http://purl.org/rss/1.0/modules/content/"
|
14 |
+
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
|
15 |
+
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
16 |
+
xmlns:atom="http://www.w3.org/2005/Atom"
|
17 |
+
<?php do_action('bp_activity_mentions_feed'); ?>
|
18 |
+
>
|
19 |
+
|
20 |
+
<channel>
|
21 |
+
<title><?php echo bp_site_name() ?> | <?php echo $bp->displayed_user->fullname; ?> | <?php _e( 'Favorite Activity', 'buddypress' ) ?></title>
|
22 |
+
<atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
|
23 |
+
<link><?php echo site_url( BP_ACTIVITY_SLUG . '/#my-favorites/' ) ?></link>
|
24 |
+
<description><?php echo $bp->displayed_user->fullname; ?> - <?php _e( 'Favorite Activity', 'buddypress' ) ?></description>
|
25 |
+
<pubDate><?php echo mysql2date('D, d M Y H:i:s O', bp_activity_get_last_updated(), false); ?></pubDate>
|
26 |
+
<generator>http://buddypress.org/?v=<?php echo BP_VERSION ?></generator>
|
27 |
+
<language><?php echo get_option('rss_language'); ?></language>
|
28 |
+
<?php do_action('bp_activity_favorites_feed_head'); ?>
|
29 |
+
|
30 |
+
<?php
|
31 |
+
$favs = bp_activity_get_user_favorites( $bp->displayed_user->id );
|
32 |
+
$fav_ids = implode( ',', (array)$favs );
|
33 |
+
?>
|
34 |
+
|
35 |
+
<?php if ( bp_has_activities( 'include=' . $fav_ids . '&max=50&display_comments=stream' ) ) : ?>
|
36 |
+
<?php while ( bp_activities() ) : bp_the_activity(); ?>
|
37 |
+
<item>
|
38 |
+
<guid><?php bp_activity_thread_permalink() ?></guid>
|
39 |
+
<title><![CDATA[<?php bp_activity_feed_item_title() ?>]]></title>
|
40 |
+
<link><?php echo bp_activity_thread_permalink() ?></link>
|
41 |
+
<pubDate><?php echo mysql2date('D, d M Y H:i:s O', bp_get_activity_feed_item_date(), false); ?></pubDate>
|
42 |
+
|
43 |
+
<description>
|
44 |
+
<![CDATA[
|
45 |
+
<?php bp_activity_feed_item_description() ?>
|
46 |
+
|
47 |
+
<?php if ( bp_activity_can_comment() ) : ?>
|
48 |
+
<p><?php printf( __( 'Comments: %s', 'buddypress' ), bp_activity_get_comment_count() ); ?></p>
|
49 |
+
<?php endif; ?>
|
50 |
+
|
51 |
+
<?php if ( 'activity_comment' == bp_get_activity_action_name() ) : ?>
|
52 |
+
<br /><strong><?php _e( 'In reply to', 'buddypress' ) ?></strong> -
|
53 |
+
<?php bp_activity_parent_content() ?>
|
54 |
+
<?php endif; ?>
|
55 |
+
]]>
|
56 |
+
</description>
|
57 |
+
<?php do_action('bp_activity_favorites_feed_item'); ?>
|
58 |
+
</item>
|
59 |
+
<?php endwhile; ?>
|
60 |
+
|
61 |
+
<?php endif; ?>
|
62 |
+
</channel>
|
63 |
+
</rss>
|
bp-activity/feeds/bp-activity-friends-feed.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* RSS2 Feed Template for displaying
|
4 |
*
|
5 |
* @package BuddyPress
|
6 |
*/
|
@@ -18,7 +18,7 @@ header('Status: 200 OK');
|
|
18 |
>
|
19 |
|
20 |
<channel>
|
21 |
-
<title><?php echo $bp->displayed_user->fullname; ?>
|
22 |
<atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
|
23 |
<link><?php echo $bp->displayed_user->domain . $bp->activity->slug . '/my-friends/feed' ?></link>
|
24 |
<description><?php printf( __( '%s - Friends Activity Feed', 'buddypress' ), $bp->displayed_user->fullname ) ?></description>
|
@@ -26,17 +26,31 @@ header('Status: 200 OK');
|
|
26 |
<generator>http://buddypress.org/?v=<?php echo BP_VERSION ?></generator>
|
27 |
<language><?php echo get_option('rss_language'); ?></language>
|
28 |
<?php do_action('bp_activity_friends_feed_head'); ?>
|
29 |
-
|
30 |
-
<?php
|
|
|
31 |
<?php while ( bp_activities() ) : bp_the_activity(); ?>
|
32 |
<item>
|
33 |
-
<guid><?php
|
34 |
<title><![CDATA[<?php bp_activity_feed_item_title() ?>]]></title>
|
35 |
-
<link><?php echo
|
36 |
<pubDate><?php echo mysql2date('D, d M Y H:i:s O', bp_get_activity_feed_item_date(), false); ?></pubDate>
|
37 |
|
38 |
-
<description
|
39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
</item>
|
41 |
<?php endwhile; ?>
|
42 |
|
1 |
<?php
|
2 |
/**
|
3 |
+
* RSS2 Feed Template for displaying a member's friends activity stream.
|
4 |
*
|
5 |
* @package BuddyPress
|
6 |
*/
|
18 |
>
|
19 |
|
20 |
<channel>
|
21 |
+
<title><?php echo bp_site_name() ?> | <?php echo $bp->displayed_user->fullname; ?> | <?php _e( 'Friends Activity', 'buddypress' ) ?></title>
|
22 |
<atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
|
23 |
<link><?php echo $bp->displayed_user->domain . $bp->activity->slug . '/my-friends/feed' ?></link>
|
24 |
<description><?php printf( __( '%s - Friends Activity Feed', 'buddypress' ), $bp->displayed_user->fullname ) ?></description>
|
26 |
<generator>http://buddypress.org/?v=<?php echo BP_VERSION ?></generator>
|
27 |
<language><?php echo get_option('rss_language'); ?></language>
|
28 |
<?php do_action('bp_activity_friends_feed_head'); ?>
|
29 |
+
|
30 |
+
<?php $friend_ids = implode( ',', friends_get_friend_user_ids( $bp->displayed_user->id ) ); ?>
|
31 |
+
<?php if ( bp_has_activities( 'user_id=' . $friend_ids . '&max=50&display_comments=stream' ) ) : ?>
|
32 |
<?php while ( bp_activities() ) : bp_the_activity(); ?>
|
33 |
<item>
|
34 |
+
<guid><?php bp_activity_thread_permalink() ?></guid>
|
35 |
<title><![CDATA[<?php bp_activity_feed_item_title() ?>]]></title>
|
36 |
+
<link><?php echo bp_activity_thread_permalink() ?></link>
|
37 |
<pubDate><?php echo mysql2date('D, d M Y H:i:s O', bp_get_activity_feed_item_date(), false); ?></pubDate>
|
38 |
|
39 |
+
<description>
|
40 |
+
<![CDATA[
|
41 |
+
<?php bp_activity_feed_item_description() ?>
|
42 |
+
|
43 |
+
<?php if ( bp_activity_can_comment() ) : ?>
|
44 |
+
<p><?php printf( __( 'Comments: %s', 'buddypress' ), bp_activity_get_comment_count() ); ?></p>
|
45 |
+
<?php endif; ?>
|
46 |
+
|
47 |
+
<?php if ( 'activity_comment' == bp_get_activity_action_name() ) : ?>
|
48 |
+
<br /><strong><?php _e( 'In reply to', 'buddypress' ) ?></strong> -
|
49 |
+
<?php bp_activity_parent_content() ?>
|
50 |
+
<?php endif; ?>
|
51 |
+
]]>
|
52 |
+
</description>
|
53 |
+
<?php do_action('bp_activity_personal_feed_item'); ?>
|
54 |
</item>
|
55 |
<?php endwhile; ?>
|
56 |
|
bp-activity/feeds/bp-activity-group-feed.php
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* RSS2 Feed Template for displaying a group activity stream
|
4 |
+
*
|
5 |
+
* @package BuddyPress
|
6 |
+
*/
|
7 |
+
header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
|
8 |
+
header('Status: 200 OK');
|
9 |
+
?>
|
10 |
+
<?php echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?>
|
11 |
+
|
12 |
+
<rss version="2.0"
|
13 |
+
xmlns:content="http://purl.org/rss/1.0/modules/content/"
|
14 |
+
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
|
15 |
+
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
16 |
+
xmlns:atom="http://www.w3.org/2005/Atom"
|
17 |
+
<?php do_action('bp_activity_group_feed'); ?>
|
18 |
+
>
|
19 |
+
|
20 |
+
<channel>
|
21 |
+
<title><?php echo bp_site_name() ?> | <?php echo $bp->groups->current_group->name ?> | <?php _e( 'Group Activity', 'buddypress' ) ?></title>
|
22 |
+
<atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
|
23 |
+
<link><?php echo bp_get_group_permalink( $bp->groups->current_group ) . $bp->activity->slug . '/feed' ?></link>
|
24 |
+
<description><?php printf( __( '%s - Group Activity Feed', 'buddypress' ), $bp->groups->current_group->name ) ?></description>
|
25 |
+
<pubDate><?php echo mysql2date('D, d M Y H:i:s O', bp_activity_get_last_updated(), false); ?></pubDate>
|
26 |
+
<generator>http://buddypress.org/?v=<?php echo BP_VERSION ?></generator>
|
27 |
+
<language><?php echo get_option('rss_language'); ?></language>
|
28 |
+
<?php do_action('bp_activity_group_feed_head'); ?>
|
29 |
+
|
30 |
+
<?php if ( bp_has_activities( 'object=' . $bp->groups->id . '&primary_id=' . $bp->groups->current_group->id . '&max=50&display_comments=threaded' ) ) : ?>
|
31 |
+
<?php while ( bp_activities() ) : bp_the_activity(); ?>
|
32 |
+
<item>
|
33 |
+
<guid><?php bp_activity_thread_permalink() ?></guid>
|
34 |
+
<title><![CDATA[<?php bp_activity_feed_item_title() ?>]]></title>
|
35 |
+
<link><?php echo bp_activity_thread_permalink() ?></link>
|
36 |
+
<pubDate><?php echo mysql2date('D, d M Y H:i:s O', bp_get_activity_feed_item_date(), false); ?></pubDate>
|
37 |
+
|
38 |
+
<description>
|
39 |
+
<![CDATA[
|
40 |
+
<?php bp_activity_feed_item_description() ?>
|
41 |
+
|
42 |
+
<?php if ( bp_activity_can_comment() ) : ?>
|
43 |
+
<p><?php printf( __( 'Comments: %s', 'buddypress' ), bp_activity_get_comment_count() ); ?></p>
|
44 |
+
<?php endif; ?>
|
45 |
+
]]>
|
46 |
+
</description>
|
47 |
+
<?php do_action('bp_activity_group_feed_item'); ?>
|
48 |
+
</item>
|
49 |
+
<?php endwhile; ?>
|
50 |
+
|
51 |
+
<?php endif; ?>
|
52 |
+
</channel>
|
53 |
+
</rss>
|
bp-activity/feeds/bp-activity-mentions-feed.php
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* RSS2 Feed Template for displaying a member's group's activity
|
4 |
+
*
|
5 |
+
* @package BuddyPress
|
6 |
+
*/
|
7 |
+
header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
|
8 |
+
header('Status: 200 OK');
|
9 |
+
?>
|
10 |
+
<?php echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?>
|
11 |
+
|
12 |
+
<rss version="2.0"
|
13 |
+
xmlns:content="http://purl.org/rss/1.0/modules/content/"
|
14 |
+
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
|
15 |
+
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
16 |
+
xmlns:atom="http://www.w3.org/2005/Atom"
|
17 |
+
<?php do_action('bp_activity_mentions_feed'); ?>
|
18 |
+
>
|
19 |
+
|
20 |
+
<channel>
|
21 |
+
<title><?php echo bp_site_name() ?> | <?php echo $bp->displayed_user->fullname; ?> | <?php _e( 'Mentions', 'buddypress' ) ?></title>
|
22 |
+
<atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
|
23 |
+
<link><?php echo site_url( BP_ACTIVITY_SLUG . '/#mentions/' ) ?></link>
|
24 |
+
<description><?php echo $bp->displayed_user->fullname; ?> - <?php _e( 'Mentions', 'buddypress' ) ?></description>
|
25 |
+
<pubDate><?php echo mysql2date('D, d M Y H:i:s O', bp_activity_get_last_updated(), false); ?></pubDate>
|
26 |
+
<generator>http://buddypress.org/?v=<?php echo BP_VERSION ?></generator>
|
27 |
+
<language><?php echo get_option('rss_language'); ?></language>
|
28 |
+
<?php do_action('bp_activity_mentions_feed_head'); ?>
|
29 |
+
|
30 |
+
<?php if ( bp_has_activities( 'max=50&display_comments=stream&search_terms=@' . bp_core_get_username( $bp->displayed_user->id, $bp->displayed_user->userdata->user_nicename, $bp->displayed_user->userdata->user_login ) ) ) : ?>
|
31 |
+
<?php while ( bp_activities() ) : bp_the_activity(); ?>
|
32 |
+
<item>
|
33 |
+
<guid><?php bp_activity_thread_permalink() ?></guid>
|
34 |
+
<title><![CDATA[<?php bp_activity_feed_item_title() ?>]]></title>
|
35 |
+
<link><?php echo bp_activity_thread_permalink() ?></link>
|
36 |
+
<pubDate><?php echo mysql2date('D, d M Y H:i:s O', bp_get_activity_feed_item_date(), false); ?></pubDate>
|
37 |
+
|
38 |
+
<description>
|
39 |
+
<![CDATA[
|
40 |
+
<?php bp_activity_feed_item_description() ?>
|
41 |
+
|
42 |
+
<?php if ( bp_activity_can_comment() ) : ?>
|
43 |
+
<p><?php printf( __( 'Comments: %s', 'buddypress' ), bp_activity_get_comment_count() ); ?></p>
|
44 |
+
<?php endif; ?>
|
45 |
+
|
46 |
+
<?php if ( 'activity_comment' == bp_get_activity_action_name() ) : ?>
|
47 |
+
<br /><strong><?php _e( 'In reply to', 'buddypress' ) ?></strong> -
|
48 |
+
<?php bp_activity_parent_content() ?>
|
49 |
+
<?php endif; ?>
|
50 |
+
]]>
|
51 |
+
</description>
|
52 |
+
<?php do_action('bp_activity_mentions_feed_item'); ?>
|
53 |
+
</item>
|
54 |
+
<?php endwhile; ?>
|
55 |
+
|
56 |
+
<?php endif; ?>
|
57 |
+
</channel>
|
58 |
+
</rss>
|
bp-activity/feeds/bp-activity-mygroups-feed.php
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* RSS2 Feed Template for displaying a member's group's activity
|
4 |
+
*
|
5 |
+
* @package BuddyPress
|
6 |
+
*/
|
7 |
+
header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
|
8 |
+
header('Status: 200 OK');
|
9 |
+
?>
|
10 |
+
<?php echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?>
|
11 |
+
|
12 |
+
<rss version="2.0"
|
13 |
+
xmlns:content="http://purl.org/rss/1.0/modules/content/"
|
14 |
+
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
|
15 |
+
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
16 |
+
xmlns:atom="http://www.w3.org/2005/Atom"
|
17 |
+
<?php do_action('bp_activity_mygroups_feed'); ?>
|
18 |
+
>
|
19 |
+
|
20 |
+
<channel>
|
21 |
+
<title><?php echo bp_site_name() ?> | <?php echo $bp->displayed_user->fullname; ?> | <?php _e( 'My Groups - Public Activity', 'buddypress' ) ?></title>
|
22 |
+
<atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
|
23 |
+
<link><?php echo site_url( BP_ACTIVITY_SLUG . '/#my-groups/' ) ?></link>
|
24 |
+
<description><?php echo $bp->displayed_user->fullname; ?> - <?php _e( 'My Groups - Public Activity', 'buddypress' ) ?></description>
|
25 |
+
<pubDate><?php echo mysql2date('D, d M Y H:i:s O', bp_activity_get_last_updated(), false); ?></pubDate>
|
26 |
+
<generator>http://buddypress.org/?v=<?php echo BP_VERSION ?></generator>
|
27 |
+
<language><?php echo get_option('rss_language'); ?></language>
|
28 |
+
<?php do_action('bp_activity_mygroups_feed_head'); ?>
|
29 |
+
|
30 |
+
<?php
|
31 |
+
$groups = groups_get_user_groups( $bp->loggedin_user->id );
|
32 |
+
$group_ids = implode( ',', $groups['groups'] );
|
33 |
+
?>
|
34 |
+
|
35 |
+
<?php if ( bp_has_activities( 'object=' . $bp->groups->id . '&primary_id=' . $group_ids . '&max=50&display_comments=threaded' ) ) : ?>
|
36 |
+
<?php while ( bp_activities() ) : bp_the_activity(); ?>
|
37 |
+
<item>
|
38 |
+
<guid><?php bp_activity_thread_permalink() ?></guid>
|
39 |
+
<title><![CDATA[<?php bp_activity_feed_item_title() ?>]]></title>
|
40 |
+
<link><?php echo bp_activity_thread_permalink() ?></link>
|
41 |
+
<pubDate><?php echo mysql2date('D, d M Y H:i:s O', bp_get_activity_feed_item_date(), false); ?></pubDate>
|
42 |
+
|
43 |
+
<description>
|
44 |
+
<![CDATA[
|
45 |
+
<?php bp_activity_feed_item_description() ?>
|
46 |
+
|
47 |
+
<?php if ( bp_activity_can_comment() ) : ?>
|
48 |
+
<p><?php printf( __( 'Comments: %s', 'buddypress' ), bp_activity_get_comment_count() ); ?></p>
|
49 |
+
<?php endif; ?>
|
50 |
+
]]>
|
51 |
+
</description>
|
52 |
+
<?php do_action('bp_activity_mygroups_feed_item'); ?>
|
53 |
+
</item>
|
54 |
+
<?php endwhile; ?>
|
55 |
+
|
56 |
+
<?php endif; ?>
|
57 |
+
</channel>
|
58 |
+
</rss>
|
bp-activity/feeds/bp-activity-personal-feed.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* RSS2 Feed Template for displaying
|
4 |
*
|
5 |
* @package BuddyPress
|
6 |
*/
|
@@ -18,7 +18,7 @@ header('Status: 200 OK');
|
|
18 |
>
|
19 |
|
20 |
<channel>
|
21 |
-
<title><?php echo $bp->displayed_user->fullname; ?>
|
22 |
<atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
|
23 |
<link><?php echo $bp->displayed_user->domain . $bp->activity->slug . '/feed' ?></link>
|
24 |
<description><?php printf( __( '%s - Activity Feed', 'buddypress' ), $bp->displayed_user->fullname ) ?></description>
|
@@ -26,17 +26,30 @@ header('Status: 200 OK');
|
|
26 |
<generator>http://buddypress.org/?v=<?php echo BP_VERSION ?></generator>
|
27 |
<language><?php echo get_option('rss_language'); ?></language>
|
28 |
<?php do_action('bp_activity_personal_feed_head'); ?>
|
29 |
-
|
30 |
-
<?php if ( bp_has_activities( '
|
31 |
<?php while ( bp_activities() ) : bp_the_activity(); ?>
|
32 |
<item>
|
33 |
-
<guid><?php
|
34 |
<title><![CDATA[<?php bp_activity_feed_item_title() ?>]]></title>
|
35 |
-
<link><?php echo
|
36 |
<pubDate><?php echo mysql2date('D, d M Y H:i:s O', bp_get_activity_feed_item_date(), false); ?></pubDate>
|
37 |
|
38 |
-
<description
|
39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
</item>
|
41 |
<?php endwhile; ?>
|
42 |
|
1 |
<?php
|
2 |
/**
|
3 |
+
* RSS2 Feed Template for displaying a member's activity stream.
|
4 |
*
|
5 |
* @package BuddyPress
|
6 |
*/
|
18 |
>
|
19 |
|
20 |
<channel>
|
21 |
+
<title><?php echo bp_site_name() ?> | <?php echo $bp->displayed_user->fullname; ?> | <?php _e( 'Activity', 'buddypress' ) ?></title>
|
22 |
<atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
|
23 |
<link><?php echo $bp->displayed_user->domain . $bp->activity->slug . '/feed' ?></link>
|
24 |
<description><?php printf( __( '%s - Activity Feed', 'buddypress' ), $bp->displayed_user->fullname ) ?></description>
|
26 |
<generator>http://buddypress.org/?v=<?php echo BP_VERSION ?></generator>
|
27 |
<language><?php echo get_option('rss_language'); ?></language>
|
28 |
<?php do_action('bp_activity_personal_feed_head'); ?>
|
29 |
+
|
30 |
+
<?php if ( bp_has_activities( 'user_id=' . $bp->displayed_user->id . '&max=50&display_comments=stream' ) ) : ?>
|
31 |
<?php while ( bp_activities() ) : bp_the_activity(); ?>
|
32 |
<item>
|
33 |
+
<guid><?php bp_activity_thread_permalink() ?></guid>
|
34 |
<title><![CDATA[<?php bp_activity_feed_item_title() ?>]]></title>
|
35 |
+
<link><?php echo bp_activity_thread_permalink() ?></link>
|
36 |
<pubDate><?php echo mysql2date('D, d M Y H:i:s O', bp_get_activity_feed_item_date(), false); ?></pubDate>
|
37 |
|
38 |
+
<description>
|
39 |
+
<![CDATA[
|
40 |
+
<?php bp_activity_feed_item_description() ?>
|
41 |
+
|
42 |
+
<?php if ( bp_activity_can_comment() ) : ?>
|
43 |
+
<p><?php printf( __( 'Comments: %s', 'buddypress' ), bp_activity_get_comment_count() ); ?></p>
|
44 |
+
<?php endif; ?>
|
45 |
+
|
46 |
+
<?php if ( 'activity_comment' == bp_get_activity_action_name() ) : ?>
|
47 |
+
<br /><strong><?php _e( 'In reply to', 'buddypress' ) ?></strong> -
|
48 |
+
<?php bp_activity_parent_content() ?>
|
49 |
+
<?php endif; ?>
|
50 |
+
]]>
|
51 |
+
</description>
|
52 |
+
<?php do_action('bp_activity_personal_feed_item'); ?>
|
53 |
</item>
|
54 |
<?php endwhile; ?>
|
55 |
|
bp-activity/feeds/bp-activity-sitewide-feed.php
CHANGED
@@ -19,7 +19,7 @@ header('Status: 200 OK');
|
|
19 |
>
|
20 |
|
21 |
<channel>
|
22 |
-
<title><?php echo
|
23 |
<atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
|
24 |
<link><?php echo site_url() . '/' . $bp->activity->slug . '/feed' ?></link>
|
25 |
<description><?php _e( 'Site Wide Activity Feed', 'buddypress' ) ?></description>
|
@@ -27,16 +27,24 @@ header('Status: 200 OK');
|
|
27 |
<generator>http://buddypress.org/?v=<?php echo BP_VERSION ?></generator>
|
28 |
<language><?php echo get_option('rss_language'); ?></language>
|
29 |
<?php do_action('bp_activity_sitewide_feed_head'); ?>
|
30 |
-
|
31 |
-
<?php if ( bp_has_activities( 'type=sitewide&max=50' ) ) : ?>
|
32 |
<?php while ( bp_activities() ) : bp_the_activity(); ?>
|
33 |
<item>
|
34 |
-
<guid><?php
|
35 |
<title><![CDATA[<?php bp_activity_feed_item_title() ?>]]></title>
|
36 |
-
<link><?php
|
37 |
<pubDate><?php echo mysql2date('D, d M Y H:i:s O', bp_get_activity_feed_item_date(), false); ?></pubDate>
|
38 |
|
39 |
-
<description
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
<?php do_action('bp_activity_personal_feed_item'); ?>
|
41 |
</item>
|
42 |
<?php endwhile; ?>
|
19 |
>
|
20 |
|
21 |
<channel>
|
22 |
+
<title><?php echo bp_site_name() ?> | <?php _e( 'Site Wide Activity', 'buddypress' ) ?></title>
|
23 |
<atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
|
24 |
<link><?php echo site_url() . '/' . $bp->activity->slug . '/feed' ?></link>
|
25 |
<description><?php _e( 'Site Wide Activity Feed', 'buddypress' ) ?></description>
|
27 |
<generator>http://buddypress.org/?v=<?php echo BP_VERSION ?></generator>
|
28 |
<language><?php echo get_option('rss_language'); ?></language>
|
29 |
<?php do_action('bp_activity_sitewide_feed_head'); ?>
|
30 |
+
|
31 |
+
<?php if ( bp_has_activities( 'type=sitewide&max=50&display_comments=threaded' ) ) : ?>
|
32 |
<?php while ( bp_activities() ) : bp_the_activity(); ?>
|
33 |
<item>
|
34 |
+
<guid><?php bp_activity_thread_permalink() ?></guid>
|
35 |
<title><![CDATA[<?php bp_activity_feed_item_title() ?>]]></title>
|
36 |
+
<link><?php bp_activity_thread_permalink() ?></link>
|
37 |
<pubDate><?php echo mysql2date('D, d M Y H:i:s O', bp_get_activity_feed_item_date(), false); ?></pubDate>
|
38 |
|
39 |
+
<description>
|
40 |
+
<![CDATA[
|
41 |
+
<?php bp_activity_feed_item_description() ?>
|
42 |
+
|
43 |
+
<?php if ( bp_activity_can_comment() ) : ?>
|
44 |
+
<p><?php printf( __( 'Comments: %s', 'buddypress' ), bp_activity_get_comment_count() ); ?></p>
|
45 |
+
<?php endif; ?>
|
46 |
+
]]>
|
47 |
+
</description>
|
48 |
<?php do_action('bp_activity_personal_feed_item'); ?>
|
49 |
</item>
|
50 |
<?php endwhile; ?>
|
bp-blogs.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
define ( 'BP_BLOGS_DB_VERSION', '
|
4 |
|
5 |
/* Define the slug for the component */
|
6 |
if ( !defined( 'BP_BLOGS_SLUG' ) )
|
@@ -8,11 +8,10 @@ if ( !defined( 'BP_BLOGS_SLUG' ) )
|
|
8 |
|
9 |
require ( BP_PLUGIN_DIR . '/bp-blogs/bp-blogs-classes.php' );
|
10 |
require ( BP_PLUGIN_DIR . '/bp-blogs/bp-blogs-templatetags.php' );
|
11 |
-
require ( BP_PLUGIN_DIR . '/bp-blogs/bp-blogs-widgets.php' );
|
12 |
|
13 |
-
/* Include
|
14 |
-
if (
|
15 |
-
require ( BP_PLUGIN_DIR . '/bp-blogs/
|
16 |
|
17 |
function bp_blogs_install() {
|
18 |
global $wpdb, $bp;
|
@@ -67,27 +66,9 @@ function bp_blogs_install() {
|
|
67 |
dbDelta($sql);
|
68 |
|
69 |
// On first installation - record all existing blogs in the system.
|
70 |
-
if ( !(int)
|
71 |
-
|
72 |
bp_blogs_record_existing_blogs();
|
73 |
add_site_option( 'bp-blogs-first-install', 1 );
|
74 |
-
|
75 |
-
} else {
|
76 |
-
|
77 |
-
// Import blog titles and descriptions into the blogmeta table
|
78 |
-
if ( get_site_option( 'bp-blogs-version' ) <= '0.1.5' ) {
|
79 |
-
$blog_ids = $wpdb->get_col( $wpdb->prepare( "SELECT blog_id FROM " . $bp->blogs->table_name ) );
|
80 |
-
|
81 |
-
for ( $i = 0; $i < count($blog_ids); $i++ ) {
|
82 |
-
$name = get_blog_option( $blog_ids[$i], 'blogname' );
|
83 |
-
$desc = get_blog_option( $blog_ids[$i], 'blogdescription' );
|
84 |
-
|
85 |
-
bp_blogs_update_blogmeta( $blog_ids[$i], 'name', $name );
|
86 |
-
bp_blogs_update_blogmeta( $blog_ids[$i], 'description', $desc );
|
87 |
-
bp_blogs_update_blogmeta( $blog_ids[$i], 'last_activity', time() );
|
88 |
-
}
|
89 |
-
}
|
90 |
-
|
91 |
}
|
92 |
|
93 |
update_site_option( 'bp-blogs-db-version', BP_BLOGS_DB_VERSION );
|
@@ -96,9 +77,10 @@ function bp_blogs_install() {
|
|
96 |
function bp_blogs_check_installed() {
|
97 |
global $wpdb, $bp, $userdata;
|
98 |
|
99 |
-
if
|
|
|
100 |
/* Need to check db tables exist, activate hook no-worky in mu-plugins folder. */
|
101 |
-
if (
|
102 |
bp_blogs_install();
|
103 |
}
|
104 |
}
|
@@ -122,14 +104,13 @@ function bp_blogs_setup_globals() {
|
|
122 |
|
123 |
do_action( 'bp_blogs_setup_globals' );
|
124 |
}
|
125 |
-
add_action( '
|
126 |
-
add_action( 'admin_menu', 'bp_blogs_setup_globals', 2 );
|
127 |
|
128 |
function bp_blogs_setup_root_component() {
|
129 |
/* Register 'blogs' as a root component */
|
130 |
bp_core_add_root_component( BP_BLOGS_SLUG );
|
131 |
}
|
132 |
-
add_action( '
|
133 |
|
134 |
/**
|
135 |
* bp_blogs_setup_nav()
|
@@ -138,25 +119,24 @@ add_action( 'plugins_loaded', 'bp_blogs_setup_root_component', 2 );
|
|
138 |
*
|
139 |
* @package BuddyPress Blogs
|
140 |
* @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
|
141 |
-
* @uses
|
142 |
*/
|
143 |
function bp_blogs_setup_nav() {
|
144 |
global $bp;
|
145 |
|
|
|
|
|
|
|
|
|
|
|
146 |
/* Add 'Blogs' to the main navigation */
|
147 |
-
bp_core_new_nav_item( array( 'name' => __( 'Blogs', 'buddypress' ), 'slug' => $bp->blogs->slug, 'position' => 30, 'screen_function' => 'bp_blogs_screen_my_blogs', 'default_subnav_slug' => 'my-blogs', 'item_css_id' => $bp->blogs->id ) );
|
148 |
|
149 |
$blogs_link = $bp->loggedin_user->domain . $bp->blogs->slug . '/';
|
150 |
|
151 |
-
/* Add the subnav items to the blogs nav item */
|
152 |
-
bp_core_new_subnav_item( array( 'name' => __( 'My Blogs', 'buddypress' ), 'slug' => 'my-blogs', 'parent_url' => $blogs_link, 'parent_slug' => $bp->blogs->slug, 'screen_function' => 'bp_blogs_screen_my_blogs', 'position' => 10, 'item_css_id' => 'my-blogs-list' ) );
|
153 |
-
bp_core_new_subnav_item( array( 'name' => __( 'Recent Posts', 'buddypress' ), 'slug' => 'recent-posts', 'parent_url' => $blogs_link, 'parent_slug' => $bp->blogs->slug, 'screen_function' => 'bp_blogs_screen_recent_posts', 'position' => 20 ) );
|
154 |
-
bp_core_new_subnav_item( array( 'name' => __( 'Recent Comments', 'buddypress' ), 'slug' => 'recent-comments', 'parent_url' => $blogs_link, 'parent_slug' => $bp->blogs->slug, 'screen_function' => 'bp_blogs_screen_recent_comments', 'position' => 30 ) );
|
155 |
-
bp_core_new_subnav_item( array( 'name' => __( 'Create a Blog', 'buddypress' ), 'slug' => 'create-a-blog', 'parent_url' => $blogs_link, 'parent_slug' => $bp->blogs->slug, 'screen_function' => 'bp_blogs_screen_create_a_blog', 'position' => 40 ) );
|
156 |
-
|
157 |
/* Set up the component options navigation for Blog */
|
158 |
if ( 'blogs' == $bp->current_component ) {
|
159 |
-
if (
|
160 |
if ( function_exists('xprofile_setup_nav') ) {
|
161 |
$bp->bp_options_title = __('My Blogs', 'buddypress');
|
162 |
}
|
@@ -169,17 +149,17 @@ function bp_blogs_setup_nav() {
|
|
169 |
|
170 |
do_action( 'bp_blogs_setup_nav' );
|
171 |
}
|
172 |
-
add_action( '
|
173 |
add_action( 'admin_menu', 'bp_blogs_setup_nav' );
|
174 |
|
175 |
function bp_blogs_directory_blogs_setup() {
|
176 |
global $bp;
|
177 |
|
178 |
-
if ( $bp->current_component == $bp->blogs->slug && empty( $bp->current_action ) ) {
|
179 |
$bp->is_directory = true;
|
180 |
|
181 |
do_action( 'bp_blogs_directory_blogs_setup' );
|
182 |
-
bp_core_load_template( apply_filters( 'bp_blogs_template_directory_blogs_setup', '
|
183 |
}
|
184 |
}
|
185 |
add_action( 'wp', 'bp_blogs_directory_blogs_setup', 2 );
|
@@ -194,24 +174,39 @@ add_action( 'wp', 'bp_blogs_directory_blogs_setup', 2 );
|
|
194 |
*/
|
195 |
|
196 |
function bp_blogs_screen_my_blogs() {
|
|
|
|
|
|
|
|
|
|
|
197 |
do_action( 'bp_blogs_screen_my_blogs' );
|
198 |
-
bp_core_load_template( apply_filters( 'bp_blogs_template_my_blogs', '
|
199 |
}
|
200 |
|
201 |
function bp_blogs_screen_recent_posts() {
|
202 |
do_action( 'bp_blogs_screen_recent_posts' );
|
203 |
-
bp_core_load_template( apply_filters( 'bp_blogs_template_recent_posts', '
|
204 |
}
|
205 |
|
206 |
function bp_blogs_screen_recent_comments() {
|
207 |
do_action( 'bp_blogs_screen_recent_comments' );
|
208 |
-
bp_core_load_template( apply_filters( 'bp_blogs_template_recent_comments', '
|
209 |
}
|
210 |
|
211 |
function bp_blogs_screen_create_a_blog() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
212 |
do_action( 'bp_blogs_screen_create_a_blog' );
|
213 |
bp_core_load_template( apply_filters( 'bp_blogs_template_create_a_blog', 'blogs/create' ) );
|
214 |
}
|
|
|
|
|
215 |
|
216 |
|
217 |
/********************************************************************************
|
@@ -233,7 +228,7 @@ function bp_blogs_register_activity_actions() {
|
|
233 |
|
234 |
do_action( 'bp_blogs_register_activity_actions' );
|
235 |
}
|
236 |
-
add_action( '
|
237 |
|
238 |
function bp_blogs_record_activity( $args = '' ) {
|
239 |
global $bp;
|
@@ -248,30 +243,61 @@ function bp_blogs_record_activity( $args = '' ) {
|
|
248 |
|
249 |
$defaults = array(
|
250 |
'user_id' => $bp->loggedin_user->id,
|
251 |
-
'
|
252 |
-
'
|
253 |
-
'
|
254 |
-
'
|
|
|
255 |
'item_id' => false,
|
256 |
'secondary_item_id' => false,
|
257 |
-
'recorded_time' =>
|
258 |
'hide_sitewide' => false
|
259 |
);
|
260 |
|
261 |
$r = wp_parse_args( $args, $defaults );
|
262 |
extract( $r, EXTR_SKIP );
|
263 |
|
264 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
265 |
}
|
266 |
|
267 |
function bp_blogs_delete_activity( $args = true ) {
|
|
|
|
|
268 |
if ( function_exists('bp_activity_delete_by_item_id') ) {
|
269 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
270 |
|
271 |
bp_activity_delete_by_item_id( array(
|
272 |
'item_id' => $item_id,
|
273 |
-
'
|
274 |
-
'
|
275 |
'user_id' => $user_id,
|
276 |
'secondary_item_id' => $secondary_item_id
|
277 |
) );
|
@@ -287,28 +313,47 @@ function bp_blogs_delete_activity( $args = true ) {
|
|
287 |
* true or false on success or failure.
|
288 |
*/
|
289 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
290 |
function bp_blogs_record_existing_blogs() {
|
291 |
global $wpdb;
|
292 |
|
293 |
$blog_ids = $wpdb->get_col( $wpdb->prepare( "SELECT blog_id FROM {$wpdb->base_prefix}blogs WHERE public = 1 AND mature = 0 AND spam = 0 AND deleted = 0" ) );
|
294 |
|
295 |
if ( $blog_ids ) {
|
296 |
-
foreach( $blog_ids as $blog_id ) {
|
297 |
$users = get_users_of_blog( $blog_id );
|
298 |
|
299 |
if ( $users ) {
|
300 |
-
foreach ( $users as $user ) {
|
301 |
$role = unserialize( $user->meta_value );
|
302 |
|
303 |
if ( !isset( $role['subscriber'] ) )
|
304 |
-
bp_blogs_record_blog( $blog_id, $user->user_id );
|
305 |
}
|
306 |
}
|
307 |
}
|
308 |
}
|
309 |
}
|
310 |
|
311 |
-
function bp_blogs_record_blog( $blog_id, $user_id, $no_activity =
|
312 |
global $bp;
|
313 |
|
314 |
if ( !$user_id )
|
@@ -325,16 +370,16 @@ function bp_blogs_record_blog( $blog_id, $user_id, $no_activity = true ) {
|
|
325 |
|
326 |
bp_blogs_update_blogmeta( $recorded_blog->blog_id, 'name', $name );
|
327 |
bp_blogs_update_blogmeta( $recorded_blog->blog_id, 'description', $description );
|
328 |
-
bp_blogs_update_blogmeta( $recorded_blog->blog_id, 'last_activity',
|
329 |
|
330 |
/* Only record this activity if the blog is public */
|
331 |
-
if ( (int)$_POST['blog_public']
|
332 |
/* Record this in activity streams */
|
333 |
bp_blogs_record_activity( array(
|
334 |
'user_id' => $recorded_blog->user_id,
|
335 |
-
'
|
336 |
'primary_link' => apply_filters( 'bp_blogs_activity_created_blog_primary_link', get_blog_option( $recorded_blog->blog_id, 'siteurl' ), $recorded_blog->blog_id ),
|
337 |
-
'
|
338 |
'item_id' => $recorded_blog->blog_id
|
339 |
) );
|
340 |
}
|
@@ -353,7 +398,7 @@ function bp_blogs_record_post( $post_id, $post, $user_id = false ) {
|
|
353 |
$user_id = (int)$post->post_author;
|
354 |
|
355 |
/* This is to stop infinate loops with Donncha's sitewide tags plugin */
|
356 |
-
if ( (int)
|
357 |
return false;
|
358 |
|
359 |
/* Don't record this if it's not a post */
|
@@ -363,39 +408,41 @@ function bp_blogs_record_post( $post_id, $post, $user_id = false ) {
|
|
363 |
if ( !$is_recorded = BP_Blogs_Post::is_recorded( $post_id, $blog_id, $user_id ) ) {
|
364 |
if ( 'publish' == $post->post_status && '' == $post->post_password ) {
|
365 |
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
|
|
|
|
371 |
|
372 |
-
|
373 |
|
374 |
-
|
|
|
375 |
|
376 |
-
if ( (int)get_blog_option( $blog_id, 'blog_public' ) ) {
|
377 |
/* Record this in activity streams */
|
378 |
-
$post_permalink =
|
379 |
|
380 |
-
$
|
381 |
-
$activity_content
|
382 |
|
383 |
bp_blogs_record_activity( array(
|
384 |
'user_id' => (int)$post->post_author,
|
385 |
-
'
|
|
|
386 |
'primary_link' => apply_filters( 'bp_blogs_activity_new_post_primary_link', $post_permalink, $post_id ),
|
387 |
-
'
|
388 |
-
'item_id' => $
|
389 |
-
'
|
|
|
390 |
));
|
391 |
}
|
392 |
}
|
393 |
} else {
|
394 |
$existing_post = new BP_Blogs_Post( null, $blog_id, $post_id );
|
395 |
|
396 |
-
/* Delete and the activity stream item as we are probably going to re-add it later with new info. */
|
397 |
-
bp_blogs_delete_activity( array( 'item_id' => $existing_post->id, 'component_name' => $bp->blogs->slug, 'component_action' => 'new_blog_post' ) );
|
398 |
-
|
399 |
/* Delete the recorded post if the status is not published or it is password protected */
|
400 |
if ( 'publish' != $post->post_status || '' != $post->post_password ) {
|
401 |
return bp_blogs_remove_post( $post_id, $blog_id, $existing_post );
|
@@ -409,21 +456,22 @@ function bp_blogs_record_post( $post_id, $post, $user_id = false ) {
|
|
409 |
bp_blogs_record_post( $post_id );
|
410 |
}
|
411 |
|
412 |
-
if ( (int)get_blog_option( $blog_id, 'blog_public' ) ) {
|
413 |
/* Now re-record the post in the activity streams */
|
414 |
-
$post_permalink =
|
415 |
|
416 |
-
$
|
417 |
-
$activity_content
|
418 |
|
419 |
-
/* Record this in activity streams */
|
420 |
bp_blogs_record_activity( array(
|
421 |
'user_id' => (int)$post->post_author,
|
422 |
-
'
|
|
|
423 |
'primary_link' => apply_filters( 'bp_blogs_activity_new_post_primary_link', $post_permalink, $post_id ),
|
424 |
-
'
|
425 |
-
'item_id' => $
|
426 |
-
'
|
|
|
427 |
) );
|
428 |
}
|
429 |
}
|
@@ -452,32 +500,36 @@ function bp_blogs_record_comment( $comment_id, $is_approved ) {
|
|
452 |
if ( !empty( $post->post_password ) )
|
453 |
return false;
|
454 |
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
|
|
|
|
461 |
|
462 |
-
|
463 |
|
464 |
-
|
|
|
465 |
|
466 |
-
if ( (int)get_blog_option( $recorded_comment->blog_id, 'blog_public' ) ) {
|
467 |
/* Record in activity streams */
|
468 |
-
$comment_link =
|
469 |
-
$
|
470 |
-
$activity_content
|
471 |
|
472 |
/* Record this in activity streams */
|
473 |
bp_blogs_record_activity( array(
|
474 |
-
'user_id' => $
|
475 |
-
'
|
|
|
476 |
'primary_link' => apply_filters( 'bp_blogs_activity_new_comment_primary_link', $comment_link, &$comment, &$recorded_comment ),
|
477 |
-
'
|
478 |
-
'item_id' => $
|
479 |
-
'secondary_item_id' => $
|
480 |
-
'recorded_time' =>
|
481 |
) );
|
482 |
}
|
483 |
|
@@ -485,47 +537,17 @@ function bp_blogs_record_comment( $comment_id, $is_approved ) {
|
|
485 |
}
|
486 |
add_action( 'comment_post', 'bp_blogs_record_comment', 10, 2 );
|
487 |
|
488 |
-
function
|
489 |
-
|
490 |
-
|
491 |
-
if ( 'approve' != $comment_status )
|
492 |
-
return false;
|
493 |
-
|
494 |
-
$recorded_comment = bp_blogs_record_comment( $comment_id, true );
|
495 |
-
$comment = get_comment($comment_id);
|
496 |
-
$comment->post = get_post( $comment->comment_post_ID );
|
497 |
-
|
498 |
-
bp_blogs_delete_activity( array( 'item_id' => $comment_id, 'secondary_item_id' => $recorded_comment->blog_id, 'component_name' => $bp->blogs->slug, 'component_action' => 'new_blog_comment' ) );
|
499 |
-
|
500 |
-
if ( (int)get_blog_option( $recorded_comment->blog_id, 'blog_public' ) ) {
|
501 |
-
/* Record in activity streams */
|
502 |
-
$comment_link = bp_post_get_permalink( $comment->post, $recorded_comment->blog_id );
|
503 |
-
$activity_content = sprintf( __( '%s commented on the blog post %s', 'buddypress' ), bp_core_get_userlink( $recorded_comment->user_id ), '<a href="' . $comment_link . '#comment-' . $comment->comment_ID . '">' . $comment->post->post_title . '</a>' );
|
504 |
-
$activity_content .= '<blockquote>' . bp_create_excerpt( $comment->comment_content ) . '</blockquote>';
|
505 |
-
|
506 |
-
/* Record this in activity streams */
|
507 |
-
bp_blogs_record_activity( array(
|
508 |
-
'user_id' => $recorded_comment->user_id,
|
509 |
-
'content' => apply_filters( 'bp_blogs_activity_new_comment', $activity_content, &$comment, &$recorded_comment, $comment_link ),
|
510 |
-
'primary_link' => apply_filters( 'bp_blogs_activity_new_comment_primary_link', $comment_link, &$comment, &$recorded_comment ),
|
511 |
-
'component_action' => 'new_blog_comment',
|
512 |
-
'item_id' => $comment_id,
|
513 |
-
'secondary_item_id' => $recorded_comment->blog_id,
|
514 |
-
'recorded_time' => $recorded_comment->date_created
|
515 |
-
) );
|
516 |
-
}
|
517 |
-
}
|
518 |
-
add_action( 'wp_set_comment_status', 'bp_blogs_approve_comment', 10, 2 );
|
519 |
|
520 |
-
|
521 |
-
if ( 'spam' == $comment_status || 'hold' == $comment_status || 'delete' == $comment_status )
|
522 |
-
bp_blogs_remove_comment( $comment_id );
|
523 |
}
|
524 |
-
add_action( 'wp_set_comment_status', '
|
525 |
|
526 |
function bp_blogs_add_user_to_blog( $user_id, $role, $blog_id ) {
|
527 |
if ( $role != 'subscriber' ) {
|
528 |
-
bp_blogs_record_blog( $blog_id, $user_id );
|
529 |
}
|
530 |
}
|
531 |
add_action( 'add_user_to_blog', 'bp_blogs_add_user_to_blog', 10, 3 );
|
@@ -543,7 +565,7 @@ function bp_blogs_remove_blog( $blog_id ) {
|
|
543 |
BP_Blogs_Blog::delete_blog_for_all( $blog_id );
|
544 |
|
545 |
// Delete activity stream item
|
546 |
-
bp_blogs_delete_activity( array( 'item_id' => $blog_id, '
|
547 |
|
548 |
do_action( 'bp_blogs_remove_blog', $blog_id );
|
549 |
}
|
@@ -558,7 +580,7 @@ function bp_blogs_remove_blog_for_user( $user_id, $blog_id ) {
|
|
558 |
BP_Blogs_Blog::delete_blog_for_user( $blog_id, $user_id );
|
559 |
|
560 |
// Delete activity stream item
|
561 |
-
bp_blogs_delete_activity( array( 'item_id' => $blog_id, '
|
562 |
|
563 |
do_action( 'bp_blogs_remove_blog_for_user', $blog_id, $user_id );
|
564 |
}
|
@@ -579,7 +601,7 @@ function bp_blogs_remove_post( $post_id, $blog_id = false, $existing_post = fals
|
|
579 |
BP_Blogs_Post::delete( $post_id, $blog_id );
|
580 |
|
581 |
// Delete activity stream item
|
582 |
-
bp_blogs_delete_activity( array( 'item_id' => $
|
583 |
|
584 |
do_action( 'bp_blogs_remove_post', $blog_id, $post_id, $post->user_id );
|
585 |
}
|
@@ -592,12 +614,35 @@ function bp_blogs_remove_comment( $comment_id ) {
|
|
592 |
BP_Blogs_Comment::delete( $comment_id, $wpdb->blogid );
|
593 |
|
594 |
// Delete activity stream item
|
595 |
-
bp_blogs_delete_activity( array( 'item_id' => $
|
596 |
|
597 |
do_action( 'bp_blogs_remove_comment', $blog_id, $comment_id, $bp->loggedin_user->id );
|
598 |
}
|
599 |
add_action( 'delete_comment', 'bp_blogs_remove_comment' );
|
600 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
601 |
function bp_blogs_remove_data_for_blog( $blog_id ) {
|
602 |
global $bp;
|
603 |
|
@@ -607,14 +652,14 @@ function bp_blogs_remove_data_for_blog( $blog_id ) {
|
|
607 |
BP_Blogs_Comment::delete_comments_for_blog( $blog_id );
|
608 |
|
609 |
// Delete activity stream item
|
610 |
-
bp_blogs_delete_activity( array( 'item_id' => $blog_id, '
|
611 |
|
612 |
do_action( 'bp_blogs_remove_data_for_blog', $blog_id );
|
613 |
}
|
614 |
add_action( 'delete_blog', 'bp_blogs_remove_data_for_blog', 1 );
|
615 |
|
616 |
-
function bp_blogs_get_blogs_for_user( $user_id ) {
|
617 |
-
return BP_Blogs_Blog::get_blogs_for_user( $user_id );
|
618 |
}
|
619 |
|
620 |
function bp_blogs_get_posts_for_user( $user_id ) {
|
@@ -638,8 +683,8 @@ function bp_blogs_get_all_blogs( $limit = null, $page = null ) {
|
|
638 |
return BP_Blogs_Blog::get_all( $limit, $page );
|
639 |
}
|
640 |
|
641 |
-
function
|
642 |
-
return BP_Blogs_Blog::
|
643 |
}
|
644 |
|
645 |
function bp_blogs_get_all_posts( $limit = null, $page = null ) {
|
@@ -662,7 +707,7 @@ function bp_blogs_redirect_to_random_blog() {
|
|
662 |
global $bp, $wpdb;
|
663 |
|
664 |
if ( $bp->current_component == $bp->blogs->slug && isset( $_GET['random-blog'] ) ) {
|
665 |
-
$blog =
|
666 |
|
667 |
bp_core_redirect( get_blog_option( $blog['blogs'][0]->blog_id, 'siteurl') );
|
668 |
}
|
@@ -698,8 +743,7 @@ function bp_blogs_delete_blogmeta( $blog_id, $meta_key = false, $meta_value = fa
|
|
698 |
$wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blogmeta} WHERE blog_id = %d AND meta_key = %s", $blog_id, $meta_key ) );
|
699 |
}
|
700 |
|
701 |
-
|
702 |
-
// wp_cache_delete($group_id, 'groups');
|
703 |
|
704 |
return true;
|
705 |
}
|
@@ -715,14 +759,10 @@ function bp_blogs_get_blogmeta( $blog_id, $meta_key = '') {
|
|
715 |
if ( !empty($meta_key) ) {
|
716 |
$meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key);
|
717 |
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
//if ( false !== $user && isset($user->$meta_key) )
|
723 |
-
// $metas = array($user->$meta_key);
|
724 |
-
//else
|
725 |
-
$metas = $wpdb->get_col( $wpdb->prepare("SELECT meta_value FROM {$bp->blogs->table_name_blogmeta} WHERE blog_id = %d AND meta_key = %s", $blog_id, $meta_key) );
|
726 |
} else {
|
727 |
$metas = $wpdb->get_col( $wpdb->prepare("SELECT meta_value FROM {$bp->blogs->table_name_blogmeta} WHERE blog_id = %d", $blog_id) );
|
728 |
}
|
@@ -769,8 +809,7 @@ function bp_blogs_update_blogmeta( $blog_id, $meta_key, $meta_value ) {
|
|
769 |
return false;
|
770 |
}
|
771 |
|
772 |
-
|
773 |
-
// wp_cache_delete($user_id, 'users');
|
774 |
|
775 |
return true;
|
776 |
}
|
@@ -786,9 +825,18 @@ function bp_blogs_remove_data( $user_id ) {
|
|
786 |
add_action( 'wpmu_delete_user', 'bp_blogs_remove_data', 1 );
|
787 |
add_action( 'delete_user', 'bp_blogs_remove_data', 1 );
|
788 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
789 |
function bp_blogs_clear_blog_object_cache( $blog_id, $user_id ) {
|
790 |
wp_cache_delete( 'bp_blogs_of_user_' . $user_id, 'bp' );
|
791 |
wp_cache_delete( 'bp_blogs_for_user_' . $user_id, 'bp' );
|
|
|
792 |
|
793 |
/* Clear the sitewide activity cache */
|
794 |
wp_cache_delete( 'sitewide_activity', 'bp' );
|
@@ -799,6 +847,7 @@ function bp_blogs_format_clear_blog_cache( $recorded_blog_obj ) {
|
|
799 |
|
800 |
/* Clear the sitewide activity cache */
|
801 |
wp_cache_delete( 'sitewide_activity', 'bp' );
|
|
|
802 |
}
|
803 |
|
804 |
function bp_blogs_clear_post_object_cache( $blog_id, $post_id, $user_id ) {
|
1 |
<?php
|
2 |
|
3 |
+
define ( 'BP_BLOGS_DB_VERSION', '2000' );
|
4 |
|
5 |
/* Define the slug for the component */
|
6 |
if ( !defined( 'BP_BLOGS_SLUG' ) )
|
8 |
|
9 |
require ( BP_PLUGIN_DIR . '/bp-blogs/bp-blogs-classes.php' );
|
10 |
require ( BP_PLUGIN_DIR . '/bp-blogs/bp-blogs-templatetags.php' );
|
|
|
11 |
|
12 |
+
/* Include the sitewide blog posts widget if this is a multisite installation */
|
13 |
+
if ( bp_core_is_multisite() )
|
14 |
+
require ( BP_PLUGIN_DIR . '/bp-blogs/bp-blogs-widgets.php' );
|
15 |
|
16 |
function bp_blogs_install() {
|
17 |
global $wpdb, $bp;
|
66 |
dbDelta($sql);
|
67 |
|
68 |
// On first installation - record all existing blogs in the system.
|
69 |
+
if ( !(int)$bp->site_options['bp-blogs-first-install'] && bp_core_is_multisite() ) {
|
|
|
70 |
bp_blogs_record_existing_blogs();
|
71 |
add_site_option( 'bp-blogs-first-install', 1 );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
}
|
73 |
|
74 |
update_site_option( 'bp-blogs-db-version', BP_BLOGS_DB_VERSION );
|
77 |
function bp_blogs_check_installed() {
|
78 |
global $wpdb, $bp, $userdata;
|
79 |
|
80 |
+
/* Only create the bp-blogs tables if this is a multisite install */
|
81 |
+
if ( is_site_admin() && bp_core_is_multisite() ) {
|
82 |
/* Need to check db tables exist, activate hook no-worky in mu-plugins folder. */
|
83 |
+
if ( $bp->site_options['bp-blogs-db-version'] < BP_BLOGS_DB_VERSION )
|
84 |
bp_blogs_install();
|
85 |
}
|
86 |
}
|
104 |
|
105 |
do_action( 'bp_blogs_setup_globals' );
|
106 |
}
|
107 |
+
add_action( 'bp_setup_globals', 'bp_blogs_setup_globals' );
|
|
|
108 |
|
109 |
function bp_blogs_setup_root_component() {
|
110 |
/* Register 'blogs' as a root component */
|
111 |
bp_core_add_root_component( BP_BLOGS_SLUG );
|
112 |
}
|
113 |
+
add_action( 'bp_setup_root_components', 'bp_blogs_setup_root_component' );
|
114 |
|
115 |
/**
|
116 |
* bp_blogs_setup_nav()
|
119 |
*
|
120 |
* @package BuddyPress Blogs
|
121 |
* @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
|
122 |
+
* @uses bp_is_my_profile() Checks to see if the current user being viewed is the logged in user
|
123 |
*/
|
124 |
function bp_blogs_setup_nav() {
|
125 |
global $bp;
|
126 |
|
127 |
+
/* Blog/post/comment menus should not appear on single WordPress setups. Although comments
|
128 |
+
and posts made by users will still show on their activity stream .*/
|
129 |
+
if ( !bp_core_is_multisite() )
|
130 |
+
return false;
|
131 |
+
|
132 |
/* Add 'Blogs' to the main navigation */
|
133 |
+
bp_core_new_nav_item( array( 'name' => sprintf( __( 'Blogs <span>(%d)</span>', 'buddypress' ), bp_blogs_total_blogs_for_user() ), 'slug' => $bp->blogs->slug, 'position' => 30, 'screen_function' => 'bp_blogs_screen_my_blogs', 'default_subnav_slug' => 'my-blogs', 'item_css_id' => $bp->blogs->id ) );
|
134 |
|
135 |
$blogs_link = $bp->loggedin_user->domain . $bp->blogs->slug . '/';
|
136 |
|
|
|
|
|
|
|
|
|
|
|
|
|
137 |
/* Set up the component options navigation for Blog */
|
138 |
if ( 'blogs' == $bp->current_component ) {
|
139 |
+
if ( bp_is_my_profile() ) {
|
140 |
if ( function_exists('xprofile_setup_nav') ) {
|
141 |
$bp->bp_options_title = __('My Blogs', 'buddypress');
|
142 |
}
|
149 |
|
150 |
do_action( 'bp_blogs_setup_nav' );
|
151 |
}
|
152 |
+
add_action( 'bp_setup_nav', 'bp_blogs_setup_nav' );
|
153 |
add_action( 'admin_menu', 'bp_blogs_setup_nav' );
|
154 |
|
155 |
function bp_blogs_directory_blogs_setup() {
|
156 |
global $bp;
|
157 |
|
158 |
+
if ( bp_core_is_multisite() && $bp->current_component == $bp->blogs->slug && empty( $bp->current_action ) ) {
|
159 |
$bp->is_directory = true;
|
160 |
|
161 |
do_action( 'bp_blogs_directory_blogs_setup' );
|
162 |
+
bp_core_load_template( apply_filters( 'bp_blogs_template_directory_blogs_setup', 'blogs/index' ) );
|
163 |
}
|
164 |
}
|
165 |
add_action( 'wp', 'bp_blogs_directory_blogs_setup', 2 );
|
174 |
*/
|
175 |
|
176 |
function bp_blogs_screen_my_blogs() {
|
177 |
+
global $bp;
|
178 |
+
|
179 |
+
if ( !bp_core_is_multisite() )
|
180 |
+
return false;
|
181 |
+
|
182 |
do_action( 'bp_blogs_screen_my_blogs' );
|
183 |
+
bp_core_load_template( apply_filters( 'bp_blogs_template_my_blogs', 'members/single/home' ) );
|
184 |
}
|
185 |
|
186 |
function bp_blogs_screen_recent_posts() {
|
187 |
do_action( 'bp_blogs_screen_recent_posts' );
|
188 |
+
bp_core_load_template( apply_filters( 'bp_blogs_template_recent_posts', 'members/single/home' ) );
|
189 |
}
|
190 |
|
191 |
function bp_blogs_screen_recent_comments() {
|
192 |
do_action( 'bp_blogs_screen_recent_comments' );
|
193 |
+
bp_core_load_template( apply_filters( 'bp_blogs_template_recent_comments', 'members/single/home' ) );
|
194 |
}
|
195 |
|
196 |
function bp_blogs_screen_create_a_blog() {
|
197 |
+
global $bp;
|
198 |
+
|
199 |
+
if ( !bp_core_is_multisite() || $bp->current_component != $bp->blogs->slug || 'create' != $bp->current_action )
|
200 |
+
return false;
|
201 |
+
|
202 |
+
if ( !is_user_logged_in() || !bp_blog_signup_enabled() )
|
203 |
+
return false;
|
204 |
+
|
205 |
do_action( 'bp_blogs_screen_create_a_blog' );
|
206 |
bp_core_load_template( apply_filters( 'bp_blogs_template_create_a_blog', 'blogs/create' ) );
|
207 |
}
|
208 |
+
/* The create screen is not attached to a nav item, so we need to attach it to an action */
|
209 |
+
add_action( 'wp', 'bp_blogs_screen_create_a_blog', 3 );
|
210 |
|
211 |
|
212 |
/********************************************************************************
|
228 |
|
229 |
do_action( 'bp_blogs_register_activity_actions' );
|
230 |
}
|
231 |
+
add_action( 'bp_register_activity_actions', 'bp_blogs_register_activity_actions' );
|
232 |
|
233 |
function bp_blogs_record_activity( $args = '' ) {
|
234 |
global $bp;
|
243 |
|
244 |
$defaults = array(
|
245 |
'user_id' => $bp->loggedin_user->id,
|
246 |
+
'action' => '',
|
247 |
+
'content' => '',
|
248 |
+
'primary_link' => '',
|
249 |
+
'component' => $bp->blogs->id,
|
250 |
+
'type' => false,
|
251 |
'item_id' => false,
|
252 |
'secondary_item_id' => false,
|
253 |
+
'recorded_time' => gmdate( "Y-m-d H:i:s" ),
|
254 |
'hide_sitewide' => false
|
255 |
);
|
256 |
|
257 |
$r = wp_parse_args( $args, $defaults );
|
258 |
extract( $r, EXTR_SKIP );
|
259 |
|
260 |
+
/* Remove large images and replace them with just one image thumbnail */
|
261 |
+
if ( function_exists( 'bp_activity_thumbnail_content_images' ) && !empty( $content ) )
|
262 |
+
$content = bp_activity_thumbnail_content_images( $content );
|
263 |
+
|
264 |
+
if ( !empty( $action ) )
|
265 |
+
$action = apply_filters( 'bp_blogs_record_activity_action', $action );
|
266 |
+
|
267 |
+
if ( !empty( $content ) )
|
268 |
+
$content = apply_filters( 'bp_blogs_record_activity_content', bp_create_excerpt( $content ) );
|
269 |
+
|
270 |
+
/* Check for an existing entry and update if one exists. */
|
271 |
+
$id = bp_activity_get_activity_id( array(
|
272 |
+
'user_id' => $user_id,
|
273 |
+
'component' => $component,
|
274 |
+
'type' => $type,
|
275 |
+
'item_id' => $item_id,
|
276 |
+
'secondary_item_id' => $secondary_item_id
|
277 |
+
) );
|
278 |
+
|
279 |
+
return bp_activity_add( array( 'id' => $id, '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 ) );
|
280 |
}
|
281 |
|
282 |
function bp_blogs_delete_activity( $args = true ) {
|
283 |
+
global $bp;
|
284 |
+
|
285 |
if ( function_exists('bp_activity_delete_by_item_id') ) {
|
286 |
+
$defaults = array(
|
287 |
+
'item_id' => false,
|
288 |
+
'component' => $bp->blogs->id,
|
289 |
+
'type' => false,
|
290 |
+
'user_id' => false,
|
291 |
+
'secondary_item_id' => false
|
292 |
+
);
|
293 |
+
|
294 |
+
$params = wp_parse_args( $args, $defaults );
|
295 |
+
extract( $params, EXTR_SKIP );
|
296 |
|
297 |
bp_activity_delete_by_item_id( array(
|
298 |
'item_id' => $item_id,
|
299 |
+
'component' => $component,
|
300 |
+
'type' => $type,
|
301 |
'user_id' => $user_id,
|
302 |
'secondary_item_id' => $secondary_item_id
|
303 |
) );
|
313 |
* true or false on success or failure.
|
314 |
*/
|
315 |
|
316 |
+
function bp_blogs_get_blogs( $args = '' ) {
|
317 |
+
global $bp;
|
318 |
+
|
319 |
+
$defaults = array(
|
320 |
+
'type' => 'active', // active, alphabetical, newest, or random.
|
321 |
+
'user_id' => false, // Pass a user_id to limit to only blogs that this user has privilages higher than subscriber on.
|
322 |
+
'search_terms' => false, // Limit to blogs that match these search terms
|
323 |
+
|
324 |
+
'per_page' => 20, // The number of results to return per page
|
325 |
+
'page' => 1, // The page to return if limiting per page
|
326 |
+
);
|
327 |
+
|
328 |
+
$params = wp_parse_args( $args, $defaults );
|
329 |
+
extract( $params, EXTR_SKIP );
|
330 |
+
|
331 |
+
return apply_filters( 'bp_blogs_get_blogs', BP_Blogs_Blog::get( $type, $per_page, $page, $user_id, $search_terms ), &$params );
|
332 |
+
}
|
333 |
+
|
334 |
+
|
335 |
function bp_blogs_record_existing_blogs() {
|
336 |
global $wpdb;
|
337 |
|
338 |
$blog_ids = $wpdb->get_col( $wpdb->prepare( "SELECT blog_id FROM {$wpdb->base_prefix}blogs WHERE public = 1 AND mature = 0 AND spam = 0 AND deleted = 0" ) );
|
339 |
|
340 |
if ( $blog_ids ) {
|
341 |
+
foreach( (array)$blog_ids as $blog_id ) {
|
342 |
$users = get_users_of_blog( $blog_id );
|
343 |
|
344 |
if ( $users ) {
|
345 |
+
foreach ( (array)$users as $user ) {
|
346 |
$role = unserialize( $user->meta_value );
|
347 |
|
348 |
if ( !isset( $role['subscriber'] ) )
|
349 |
+
bp_blogs_record_blog( $blog_id, $user->user_id, true );
|
350 |
}
|
351 |
}
|
352 |
}
|
353 |
}
|
354 |
}
|
355 |
|
356 |
+
function bp_blogs_record_blog( $blog_id, $user_id, $no_activity = false ) {
|
357 |
global $bp;
|
358 |
|
359 |
if ( !$user_id )
|
370 |
|
371 |
bp_blogs_update_blogmeta( $recorded_blog->blog_id, 'name', $name );
|
372 |
bp_blogs_update_blogmeta( $recorded_blog->blog_id, 'description', $description );
|
373 |
+
bp_blogs_update_blogmeta( $recorded_blog->blog_id, 'last_activity', gmdate( "Y-m-d H:i:s" ) );
|
374 |
|
375 |
/* Only record this activity if the blog is public */
|
376 |
+
if ( (int)$_POST['blog_public'] && !$no_activity ) {
|
377 |
/* Record this in activity streams */
|
378 |
bp_blogs_record_activity( array(
|
379 |
'user_id' => $recorded_blog->user_id,
|
380 |
+
'action' => apply_filters( 'bp_blogs_activity_created_blog_action', sprintf( __( '%s created the blog %s', 'buddypress'), bp_core_get_userlink( $recorded_blog->user_id ), '<a href="' . get_blog_option( $recorded_blog->blog_id, 'siteurl' ) . '">' . attribute_escape( $name ) . '</a>' ), &$recorded_blog, $name, $description ),
|
381 |
'primary_link' => apply_filters( 'bp_blogs_activity_created_blog_primary_link', get_blog_option( $recorded_blog->blog_id, 'siteurl' ), $recorded_blog->blog_id ),
|
382 |
+
'type' => 'new_blog',
|
383 |
'item_id' => $recorded_blog->blog_id
|
384 |
) );
|
385 |
}
|
398 |
$user_id = (int)$post->post_author;
|
399 |
|
400 |
/* This is to stop infinate loops with Donncha's sitewide tags plugin */
|
401 |
+
if ( (int)$bp->site_options['tags_blog_id'] == (int)$blog_id )
|
402 |
return false;
|
403 |
|
404 |
/* Don't record this if it's not a post */
|
408 |
if ( !$is_recorded = BP_Blogs_Post::is_recorded( $post_id, $blog_id, $user_id ) ) {
|
409 |
if ( 'publish' == $post->post_status && '' == $post->post_password ) {
|
410 |
|
411 |
+
/* If we're on a multiblog install, record this post */
|
412 |
+
if ( bp_core_is_multisite() ) {
|
413 |
+
$recorded_post = new BP_Blogs_Post;
|
414 |
+
$recorded_post->user_id = $user_id;
|
415 |
+
$recorded_post->blog_id = $blog_id;
|
416 |
+
$recorded_post->post_id = $post_id;
|
417 |
+
$recorded_post->date_created = strtotime( $post->post_date );
|
418 |
|
419 |
+
$recorded_post_id = $recorded_post->save();
|
420 |
|
421 |
+
bp_blogs_update_blogmeta( $recorded_post->blog_id, 'last_activity', gmdate( "Y-m-d H:i:s" ) );
|
422 |
+
}
|
423 |
|
424 |
+
if ( (int)get_blog_option( $blog_id, 'blog_public' ) || !bp_core_is_multisite() ) {
|
425 |
/* Record this in activity streams */
|
426 |
+
$post_permalink = get_permalink( $post_id );
|
427 |
|
428 |
+
$activity_action = sprintf( __( '%s wrote a new blog post: %s', 'buddypress' ), bp_core_get_userlink( (int)$post->post_author ), '<a href="' . $post_permalink . '">' . $post->post_title . '</a>' );
|
429 |
+
$activity_content = $post->post_content;
|
430 |
|
431 |
bp_blogs_record_activity( array(
|
432 |
'user_id' => (int)$post->post_author,
|
433 |
+
'action' => apply_filters( 'bp_blogs_activity_new_post_action', $activity_action, &$post, $post_permalink ),
|
434 |
+
'content' => apply_filters( 'bp_blogs_activity_new_post_content', $activity_content, &$post, $post_permalink ),
|
435 |
'primary_link' => apply_filters( 'bp_blogs_activity_new_post_primary_link', $post_permalink, $post_id ),
|
436 |
+
'type' => 'new_blog_post',
|
437 |
+
'item_id' => $blog_id,
|
438 |
+
'secondary_item_id' => $post_id,
|
439 |
+
'recorded_time' => $post->post_date_gmt
|
440 |
));
|
441 |
}
|
442 |
}
|
443 |
} else {
|
444 |
$existing_post = new BP_Blogs_Post( null, $blog_id, $post_id );
|
445 |
|
|
|
|
|
|
|
446 |
/* Delete the recorded post if the status is not published or it is password protected */
|
447 |
if ( 'publish' != $post->post_status || '' != $post->post_password ) {
|
448 |
return bp_blogs_remove_post( $post_id, $blog_id, $existing_post );
|
456 |
bp_blogs_record_post( $post_id );
|
457 |
}
|
458 |
|
459 |
+
if ( (int)get_blog_option( $blog_id, 'blog_public' ) || !bp_core_is_multisite() ) {
|
460 |
/* Now re-record the post in the activity streams */
|
461 |
+
$post_permalink = get_permalink( $post_id );
|
462 |
|
463 |
+
$activity_action = sprintf( __( '%s wrote a new blog post: %s', 'buddypress' ), bp_core_get_userlink( (int)$post->post_author ), '<a href="' . $post_permalink . '">' . $post->post_title . '</a>' );
|
464 |
+
$activity_content = $post->post_content;
|
465 |
|
|
|
466 |
bp_blogs_record_activity( array(
|
467 |
'user_id' => (int)$post->post_author,
|
468 |
+
'action' => apply_filters( 'bp_blogs_activity_new_post_action', $activity_action, &$post, $post_permalink ),
|
469 |
+
'content' => apply_filters( 'bp_blogs_activity_new_post_content', $activity_content, &$post, $post_permalink ),
|
470 |
'primary_link' => apply_filters( 'bp_blogs_activity_new_post_primary_link', $post_permalink, $post_id ),
|
471 |
+
'type' => 'new_blog_post',
|
472 |
+
'item_id' => $blog_id,
|
473 |
+
'secondary_item_id' => $post_id,
|
474 |
+
'recorded_time' => $post->post_date_gmt
|
475 |
) );
|
476 |
}
|
477 |
}
|
500 |
if ( !empty( $post->post_password ) )
|
501 |
return false;
|
502 |
|
503 |
+
/* If we're on a multiblog install, record this post */
|
504 |
+
if ( bp_core_is_multisite() ) {
|
505 |
+
$recorded_comment = new BP_Blogs_Comment;
|
506 |
+
$recorded_comment->user_id = $user_id;
|
507 |
+
$recorded_comment->blog_id = $wpdb->blogid;
|
508 |
+
$recorded_comment->comment_id = $comment_id;
|
509 |
+
$recorded_comment->comment_post_id = $comment->comment_post_ID;
|
510 |
+
$recorded_comment->date_created = strtotime( $comment->comment_date_gmt );
|
511 |
|
512 |
+
$recorded_commment_id = $recorded_comment->save();
|
513 |
|
514 |
+
bp_blogs_update_blogmeta( $recorded_comment->blog_id, 'last_activity', gmdate( "Y-m-d H:i:s" ) );
|
515 |
+
}
|
516 |
|
517 |
+
if ( (int)get_blog_option( $recorded_comment->blog_id, 'blog_public' ) || !bp_core_is_multisite() ) {
|
518 |
/* Record in activity streams */
|
519 |
+
$comment_link = get_permalink( $comment->comment_post_ID ) . '#comment-' . $comment_id;
|
520 |
+
$activity_action = sprintf( __( '%s commented on the blog post %s', 'buddypress' ), bp_core_get_userlink( $user_id ), '<a href="' . $comment_link . '#comment-' . $comment->comment_ID . '">' . $comment->post->post_title . '</a>' );
|
521 |
+
$activity_content = $comment->comment_content;
|
522 |
|
523 |
/* Record this in activity streams */
|
524 |
bp_blogs_record_activity( array(
|
525 |
+
'user_id' => $user_id,
|
526 |
+
'action' => apply_filters( 'bp_blogs_activity_new_comment_action', $activity_action, &$comment, &$recorded_comment, $comment_link ),
|
527 |
+
'content' => apply_filters( 'bp_blogs_activity_new_comment_content', $activity_content, &$comment, &$recorded_comment, $comment_link ),
|
528 |
'primary_link' => apply_filters( 'bp_blogs_activity_new_comment_primary_link', $comment_link, &$comment, &$recorded_comment ),
|
529 |
+
'type' => 'new_blog_comment',
|
530 |
+
'item_id' => $wpdb->blogid,
|
531 |
+
'secondary_item_id' => $comment_id,
|
532 |
+
'recorded_time' => $comment->comment_date_gmt
|
533 |
) );
|
534 |
}
|
535 |
|
537 |
}
|
538 |
add_action( 'comment_post', 'bp_blogs_record_comment', 10, 2 );
|
539 |
|
540 |
+
function bp_blogs_manage_comment( $comment_id, $comment_status ) {
|
541 |
+
if ( 'spam' == $comment_status || 'hold' == $comment_status || 'delete' == $comment_status || 'trash' == $comment_status )
|
542 |
+
return bp_blogs_remove_comment( $comment_id );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
543 |
|
544 |
+
return bp_blogs_record_comment( $comment_id, true );
|
|
|
|
|
545 |
}
|
546 |
+
add_action( 'wp_set_comment_status', 'bp_blogs_manage_comment', 10, 2 );
|
547 |
|
548 |
function bp_blogs_add_user_to_blog( $user_id, $role, $blog_id ) {
|
549 |
if ( $role != 'subscriber' ) {
|
550 |
+
bp_blogs_record_blog( $blog_id, $user_id, true );
|
551 |
}
|
552 |
}
|
553 |
add_action( 'add_user_to_blog', 'bp_blogs_add_user_to_blog', 10, 3 );
|
565 |
BP_Blogs_Blog::delete_blog_for_all( $blog_id );
|
566 |
|
567 |
// Delete activity stream item
|
568 |
+
bp_blogs_delete_activity( array( 'item_id' => $blog_id, 'component' => $bp->blogs->slug, 'type' => 'new_blog' ) );
|
569 |
|
570 |
do_action( 'bp_blogs_remove_blog', $blog_id );
|
571 |
}
|
580 |
BP_Blogs_Blog::delete_blog_for_user( $blog_id, $user_id );
|
581 |
|
582 |
// Delete activity stream item
|
583 |
+
bp_blogs_delete_activity( array( 'item_id' => $blog_id, 'component' => $bp->blogs->slug, 'type' => 'new_blog' ) );
|
584 |
|
585 |
do_action( 'bp_blogs_remove_blog_for_user', $blog_id, $user_id );
|
586 |
}
|
601 |
BP_Blogs_Post::delete( $post_id, $blog_id );
|
602 |
|
603 |
// Delete activity stream item
|
604 |
+
bp_blogs_delete_activity( array( 'item_id' => $blog_id, 'secondary_item_id' => $post_id, 'component' => $bp->blogs->slug, 'type' => 'new_blog_post' ) );
|
605 |
|
606 |
do_action( 'bp_blogs_remove_post', $blog_id, $post_id, $post->user_id );
|
607 |
}
|
614 |
BP_Blogs_Comment::delete( $comment_id, $wpdb->blogid );
|
615 |
|
616 |
// Delete activity stream item
|
617 |
+
bp_blogs_delete_activity( array( 'item_id' => $wpdb->blogid , 'secondary_item_id' => $comment_id, 'type' => 'new_blog_comment' ) );
|
618 |
|
619 |
do_action( 'bp_blogs_remove_comment', $blog_id, $comment_id, $bp->loggedin_user->id );
|
620 |
}
|
621 |
add_action( 'delete_comment', 'bp_blogs_remove_comment' );
|
622 |
|
623 |
+
function bp_blogs_total_blogs() {
|
624 |
+
if ( !$count = wp_cache_get( 'bp_total_blogs', 'bp' ) ) {
|
625 |
+
$blogs = BP_Blogs_Blog::get_all();
|
626 |
+
$count = $blogs['total'];
|
627 |
+
wp_cache_set( 'bp_total_blogs', $count, 'bp' );
|
628 |
+
}
|
629 |
+
return $count;
|
630 |
+
}
|
631 |
+
|
632 |
+
function bp_blogs_total_blogs_for_user( $user_id = false ) {
|
633 |
+
global $bp;
|
634 |
+
|
635 |
+
if ( !$user_id )
|
636 |
+
$user_id = ( $bp->displayed_user->id ) ? $bp->displayed_user->id : $bp->loggedin_user->id;
|
637 |
+
|
638 |
+
if ( !$count = wp_cache_get( 'bp_total_blogs_for_user_' . $user_id, 'bp' ) ) {
|
639 |
+
$count = BP_Blogs_Blog::total_blog_count_for_user( $user_id );
|
640 |
+
wp_cache_set( 'bp_total_blogs_for_user_' . $user_id, $count, 'bp' );
|
641 |
+
}
|
642 |
+
|
643 |
+
return $count;
|
644 |
+
}
|
645 |
+
|
646 |
function bp_blogs_remove_data_for_blog( $blog_id ) {
|
647 |
global $bp;
|
648 |
|
652 |
BP_Blogs_Comment::delete_comments_for_blog( $blog_id );
|
653 |
|
654 |
// Delete activity stream item
|
655 |
+
bp_blogs_delete_activity( array( 'item_id' => $blog_id, 'component' => $bp->blogs->slug, 'type' => false ) );
|
656 |
|
657 |
do_action( 'bp_blogs_remove_data_for_blog', $blog_id );
|
658 |
}
|
659 |
add_action( 'delete_blog', 'bp_blogs_remove_data_for_blog', 1 );
|
660 |
|
661 |
+
function bp_blogs_get_blogs_for_user( $user_id, $show_hidden = false ) {
|
662 |
+
return BP_Blogs_Blog::get_blogs_for_user( $user_id, $show_hidden );
|
663 |
}
|
664 |
|
665 |
function bp_blogs_get_posts_for_user( $user_id ) {
|
683 |
return BP_Blogs_Blog::get_all( $limit, $page );
|
684 |
}
|
685 |
|
686 |
+
function bp_blogs_get_random_blogs( $limit = null, $page = null ) {
|
687 |
+
return BP_Blogs_Blog::get( 'random', $limit, $page );
|
688 |
}
|
689 |
|
690 |
function bp_blogs_get_all_posts( $limit = null, $page = null ) {
|
707 |
global $bp, $wpdb;
|
708 |
|
709 |
if ( $bp->current_component == $bp->blogs->slug && isset( $_GET['random-blog'] ) ) {
|
710 |
+
$blog = bp_blogs_get_random_blogs( 1, 1 );
|
711 |
|
712 |
bp_core_redirect( get_blog_option( $blog['blogs'][0]->blog_id, 'siteurl') );
|
713 |
}
|
743 |
$wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blogmeta} WHERE blog_id = %d AND meta_key = %s", $blog_id, $meta_key ) );
|
744 |
}
|
745 |
|
746 |
+
wp_cache_delete( 'bp_blogs_blogmeta_' . $blog_id . '_' . $meta_key, 'bp' );
|
|
|
747 |
|
748 |
return true;
|
749 |
}
|
759 |
if ( !empty($meta_key) ) {
|
760 |
$meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key);
|
761 |
|
762 |
+
if ( !$metas = wp_cache_get( 'bp_blogs_blogmeta_' . $blog_id . '_' . $meta_key, 'bp' ) ) {
|
763 |
+
$metas = $wpdb->get_col( $wpdb->prepare( "SELECT meta_value FROM {$bp->blogs->table_name_blogmeta} WHERE blog_id = %d AND meta_key = %s", $blog_id, $meta_key ) );
|
764 |
+
wp_cache_set( 'bp_blogs_blogmeta_' . $blog_id . '_' . $meta_key, $metas, 'bp' );
|
765 |
+
}
|
|
|
|
|
|
|
|
|
766 |
} else {
|
767 |
$metas = $wpdb->get_col( $wpdb->prepare("SELECT meta_value FROM {$bp->blogs->table_name_blogmeta} WHERE blog_id = %d", $blog_id) );
|
768 |
}
|
809 |
return false;
|
810 |
}
|
811 |
|
812 |
+
wp_cache_set( 'bp_blogs_blogmeta_' . $blog_id . '_' . $meta_key, $metas, 'bp' );
|
|
|
813 |
|
814 |
return true;
|
815 |
}
|
825 |
add_action( 'wpmu_delete_user', 'bp_blogs_remove_data', 1 );
|
826 |
add_action( 'delete_user', 'bp_blogs_remove_data', 1 );
|
827 |
|
828 |
+
|
829 |
+
/********************************************************************************
|
830 |
+
* Caching
|
831 |
+
*
|
832 |
+
* Caching functions handle the clearing of cached objects and pages on specific
|
833 |
+
* actions throughout BuddyPress.
|
834 |
+
*/
|
835 |
+
|
836 |
function bp_blogs_clear_blog_object_cache( $blog_id, $user_id ) {
|
837 |
wp_cache_delete( 'bp_blogs_of_user_' . $user_id, 'bp' );
|
838 |
wp_cache_delete( 'bp_blogs_for_user_' . $user_id, 'bp' );
|
839 |
+
wp_cache_delete( 'bp_total_blogs_for_user_' . $user_id, 'bp' );
|
840 |
|
841 |
/* Clear the sitewide activity cache */
|
842 |
wp_cache_delete( 'sitewide_activity', 'bp' );
|
847 |
|
848 |
/* Clear the sitewide activity cache */
|
849 |
wp_cache_delete( 'sitewide_activity', 'bp' );
|
850 |
+
wp_cache_delete( 'bp_total_blogs', 'bp' );
|
851 |
}
|
852 |
|
853 |
function bp_blogs_clear_post_object_cache( $blog_id, $post_id, $user_id ) {
|
bp-blogs/admin-tabs/admin.css
DELETED
@@ -1,56 +0,0 @@
|
|
1 |
-
ul#blog-list, ul#comment-list {
|
2 |
-
margin: 0;
|
3 |
-
padding: 0;
|
4 |
-
list-style: none;
|
5 |
-
}
|
6 |
-
ul#blog-list h4 {
|
7 |
-
font: normal 1.6em georgia, times, serif;
|
8 |
-
margin: 0.8em 0 0.2em 0;
|
9 |
-
}
|
10 |
-
|
11 |
-
ul#blog-list li, ul#comment-list li {
|
12 |
-
border-bottom: 1px solid #ddd;
|
13 |
-
}
|
14 |
-
|
15 |
-
.post {
|
16 |
-
border-bottom: 1px solid #ddd;
|
17 |
-
padding: 0.5em;
|
18 |
-
}
|
19 |
-
|
20 |
-
.post h2 {
|
21 |
-
font: normal 1.4em georgia, times, serif !important;
|
22 |
-
border: none !important;
|
23 |
-
margin: 0.5em 0 0.2em 0 !important;
|
24 |
-
}
|
25 |
-
|
26 |
-
.post hr {
|
27 |
-
visibility: hidden;
|
28 |
-
clear: both;
|
29 |
-
}
|
30 |
-
|
31 |
-
.post p.date {
|
32 |
-
margin: 0;
|
33 |
-
font-size: 0.9em;
|
34 |
-
}
|
35 |
-
|
36 |
-
.post p.date, .small, h2 span {
|
37 |
-
font: italic 1em Georgia, times, serif;
|
38 |
-
color: #888;
|
39 |
-
font-size: 0.95em;
|
40 |
-
}
|
41 |
-
|
42 |
-
.post span.tags {
|
43 |
-
background: url(/wp-content/themes/buddypress/images/tag_icon.gif) center left no-repeat;
|
44 |
-
padding-left: 1.6em;
|
45 |
-
float: left;
|
46 |
-
}
|
47 |
-
|
48 |
-
.post span.comments {
|
49 |
-
float: right;
|
50 |
-
background: url(/wp-content/themes/buddypress/images/comments_icon.gif) center right no-repeat;
|
51 |
-
padding-right: 1.8em;
|
52 |
-
}
|
53 |
-
|
54 |
-
ul#comment-list li {
|
55 |
-
padding: 0.8em;
|
56 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bp-blogs/admin-tabs/bp-blogs-comments-tab.php
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
<div class="wrap">
|
2 |
-
<?php locate_template( array( 'blogs/recent-comments.php' ), true ); ?>
|
3 |
-
</div>
|
|
|
|
|
|
bp-blogs/admin-tabs/bp-blogs-posts-tab.php
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
<div class="wrap">
|
2 |
-
<?php locate_template( array( 'blogs/recent-posts.php' ), true ); ?>
|
3 |
-
</div>
|
|
|
|
|
|
bp-blogs/admin-tabs/bp-blogs-tab.php
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
<div class="wrap">
|
2 |
-
<?php locate_template( array( 'blogs/my-blogs.php' ), true ); ?>
|
3 |
-
</div>
|
|
|
|
|
|
bp-blogs/bp-blogs-classes.php
CHANGED
@@ -4,10 +4,10 @@ Class BP_Blogs_Blog {
|
|
4 |
var $id;
|
5 |
var $user_id;
|
6 |
var $blog_id;
|
7 |
-
|
8 |
function bp_blogs_blog( $id = null ) {
|
9 |
global $bp, $wpdb;
|
10 |
-
|
11 |
if ( !$user_id )
|
12 |
$user_id = $bp->displayed_user->id;
|
13 |
|
@@ -16,32 +16,32 @@ Class BP_Blogs_Blog {
|
|
16 |
$this->populate();
|
17 |
}
|
18 |
}
|
19 |
-
|
20 |
function populate() {
|
21 |
global $wpdb, $bp;
|
22 |
-
|
23 |
$blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->blogs->table_name} WHERE id = %d", $this->id ) );
|
24 |
|
25 |
$this->user_id = $blog->user_id;
|
26 |
$this->blog_id = $blog->blog_id;
|
27 |
}
|
28 |
-
|
29 |
function save() {
|
30 |
global $wpdb, $bp;
|
31 |
-
|
32 |
$this->user_id = apply_filters( 'bp_blogs_blog_user_id_before_save', $this->user_id, $this->id );
|
33 |
$this->blog_id = apply_filters( 'bp_blogs_blog_id_before_save', $this->blog_id, $this->id );
|
34 |
-
|
35 |
do_action( 'bp_blogs_blog_before_save', $this );
|
36 |
-
|
37 |
// Don't try and save if there is no user ID or blog ID set.
|
38 |
if ( !$this->user_id || !$this->blog_id )
|
39 |
return false;
|
40 |
-
|
41 |
// Don't save if this blog has already been recorded for the user.
|
42 |
if ( !$this->id && $this->exists() )
|
43 |
return false;
|
44 |
-
|
45 |
if ( $this->id ) {
|
46 |
// Update
|
47 |
$sql = $wpdb->prepare( "UPDATE {$bp->blogs->table_name} SET user_id = %d, blog_id = %d WHERE id = %d", $this->user_id, $this->blog_id, $this->id );
|
@@ -49,52 +49,98 @@ Class BP_Blogs_Blog {
|
|
49 |
// Save
|
50 |
$sql = $wpdb->prepare( "INSERT INTO {$bp->blogs->table_name} ( user_id, blog_id ) VALUES ( %d, %d )", $this->user_id, $this->blog_id );
|
51 |
}
|
52 |
-
|
53 |
if ( !$wpdb->query($sql) )
|
54 |
return false;
|
55 |
-
|
56 |
do_action( 'bp_blogs_blog_after_save', $this );
|
57 |
-
|
58 |
if ( $this->id )
|
59 |
return $this->id;
|
60 |
else
|
61 |
return $wpdb->insert_id;
|
62 |
}
|
63 |
-
|
64 |
function exists() {
|
65 |
global $bp, $wpdb;
|
66 |
-
|
67 |
return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->blogs->table_name} WHERE user_id = %d AND blog_id = %d", $this->user_id, $this->blog_id ) );
|
68 |
}
|
69 |
-
|
70 |
/* Static Functions */
|
71 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
function delete_blog_for_all( $blog_id ) {
|
73 |
global $wpdb, $bp;
|
74 |
-
|
75 |
if ( !$bp->blogs )
|
76 |
bp_blogs_setup_globals();
|
77 |
-
|
78 |
bp_blogs_delete_blogmeta( $blog_id );
|
79 |
|
80 |
return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name} WHERE blog_id = %d", $blog_id ) );
|
81 |
}
|
82 |
-
|
83 |
function delete_blog_for_user( $blog_id, $user_id = null ) {
|
84 |
global $wpdb, $bp;
|
85 |
-
|
86 |
if ( !$bp->blogs )
|
87 |
bp_blogs_setup_globals();
|
88 |
-
|
89 |
if ( !$user_id )
|
90 |
$user_id = $bp->loggedin_user->id;
|
91 |
|
92 |
return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name} WHERE user_id = %d AND blog_id = %d", $user_id, $blog_id ) );
|
93 |
}
|
94 |
-
|
95 |
function delete_blogs_for_user( $user_id = null ) {
|
96 |
global $wpdb, $bp;
|
97 |
-
|
98 |
if ( !$bp->blogs )
|
99 |
bp_blogs_setup_globals();
|
100 |
|
@@ -103,170 +149,159 @@ Class BP_Blogs_Blog {
|
|
103 |
|
104 |
return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name} WHERE user_id = %d", $user_id ) );
|
105 |
}
|
106 |
-
|
107 |
-
function get_blogs_for_user( $user_id =
|
108 |
global $bp, $wpdb;
|
109 |
-
|
110 |
if ( !$bp->blogs )
|
111 |
bp_blogs_setup_globals();
|
112 |
-
|
113 |
if ( !$user_id )
|
114 |
$user_id = $bp->displayed_user->id;
|
115 |
-
|
116 |
// Show logged in users their hidden blogs.
|
117 |
-
if ( !
|
118 |
-
$
|
119 |
else
|
120 |
-
$
|
121 |
-
|
122 |
-
$total_blog_count = BP_Blogs_Blog::
|
123 |
-
|
124 |
-
|
125 |
-
$
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
);
|
131 |
}
|
132 |
|
133 |
-
return array( 'blogs' => $
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
134 |
}
|
135 |
-
|
136 |
function is_recorded( $blog_id ) {
|
137 |
global $bp, $wpdb;
|
138 |
-
|
139 |
if ( !$bp->blogs )
|
140 |
bp_blogs_setup_globals();
|
141 |
-
|
142 |
return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->blogs->table_name} WHERE blog_id = %d", $blog_id ) );
|
143 |
}
|
144 |
-
|
145 |
-
function
|
146 |
global $bp, $wpdb;
|
147 |
-
|
148 |
if ( !$bp->blogs )
|
149 |
bp_blogs_setup_globals();
|
150 |
-
|
151 |
if ( !$user_id )
|
152 |
$user_id = $bp->displayed_user->id;
|
153 |
|
154 |
// If the user is logged in return the blog count including their hidden blogs.
|
155 |
-
if ( !
|
156 |
return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT b.blog_id) FROM {$bp->blogs->table_name} b LEFT JOIN {$wpdb->base_prefix}blogs wb ON b.blog_id = wb.blog_id WHERE wb.public = 1 AND wb.deleted = 0 AND wb.spam = 0 AND wb.mature = 0 AND wb.archived = '0' AND user_id = %d", $user_id) );
|
157 |
else
|
158 |
return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT b.blog_id) FROM {$bp->blogs->table_name} b LEFT JOIN {$wpdb->base_prefix}blogs wb ON b.blog_id = wb.blog_id WHERE wb.deleted = 0 AND wb.spam = 0 AND wb.mature = 0 AND wb.archived = '0' AND user_id = %d", $user_id) );
|
159 |
}
|
160 |
-
|
161 |
-
function get_all( $limit = null, $page = null ) {
|
162 |
-
global $bp, $wpdb;
|
163 |
-
|
164 |
-
if ( !$bp->blogs )
|
165 |
-
bp_blogs_setup_globals();
|
166 |
-
|
167 |
-
if ( $limit && $page ) {
|
168 |
-
$pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
|
169 |
-
$total_blogs = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT bm.blog_id) FROM {$bp->blogs->table_name_blogmeta} bm LEFT JOIN {$wpdb->base_prefix}blogs wb ON bm.blog_id = wb.blog_id WHERE wb.public = 1 AND wb.archived = '0' AND wb.spam = 0 AND wb.mature = 0 AND wb.deleted = 0 AND bm.meta_key = 'last_activity' ORDER BY CONVERT(bm.meta_value, SIGNED) DESC" ) );
|
170 |
-
}
|
171 |
-
|
172 |
-
$paged_blogs = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT bm.blog_id FROM {$bp->blogs->table_name_blogmeta} bm LEFT JOIN {$wpdb->base_prefix}blogs wb ON bm.blog_id = wb.blog_id WHERE wb.public = 1 AND wb.archived = '0' AND wb.spam = 0 AND wb.mature = 0 AND wb.deleted = 0 AND bm.meta_key = 'last_activity' ORDER BY CONVERT(bm.meta_value, SIGNED) DESC {$pag_sql}" ) );
|
173 |
|
174 |
-
return array( 'blogs' => $paged_blogs, 'total' => $total_blogs );
|
175 |
-
}
|
176 |
-
|
177 |
-
function get_by_letter( $letter, $limit = null, $page = null ) {
|
178 |
-
global $bp, $wpdb;
|
179 |
-
|
180 |
-
if ( !$bp->blogs )
|
181 |
-
bp_blogs_setup_globals();
|
182 |
-
|
183 |
-
$letter = like_escape( $wpdb->escape( $letter ) );
|
184 |
-
|
185 |
-
if ( $limit && $page ) {
|
186 |
-
$pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
|
187 |
-
$total_blogs = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT bm.blog_id) FROM {$bp->blogs->table_name_blogmeta} bm LEFT JOIN {$wpdb->base_prefix}blogs wb ON bm.blog_id = wb.blog_id WHERE bm.meta_key = 'name' AND bm.meta_value LIKE '$letter%%' AND wb.public = 1 AND wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 ORDER BY bm.meta_value ASC" ) );
|
188 |
-
}
|
189 |
-
|
190 |
-
$paged_blogs = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT bm.blog_id FROM {$bp->blogs->table_name_blogmeta} bm LEFT JOIN {$wpdb->base_prefix}blogs wb ON bm.blog_id = wb.blog_id WHERE bm.meta_key = 'name' AND bm.meta_value LIKE '$letter%%' AND wb.public = 1 AND wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 ORDER BY bm.meta_value ASC{$pag_sql}" ) );
|
191 |
-
|
192 |
-
return array( 'blogs' => $paged_blogs, 'total' => $total_blogs );
|
193 |
-
}
|
194 |
-
|
195 |
function search_blogs( $filter, $limit = null, $page = null ) {
|
196 |
global $wpdb, $bp;
|
197 |
-
|
198 |
if ( !$bp->blogs )
|
199 |
bp_blogs_setup_globals();
|
200 |
-
|
201 |
$filter = like_escape( $wpdb->escape( $filter ) );
|
202 |
-
|
203 |
-
if (
|
|
|
|
|
|
|
204 |
$pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
|
205 |
-
$total_blogs = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT bm.blog_id) FROM {$bp->blogs->table_name_blogmeta} bm LEFT JOIN {$wpdb->base_prefix}blogs wb ON bm.blog_id = wb.blog_id WHERE ( ( bm.meta_key = 'name' OR bm.meta_key = 'description' ) AND bm.meta_value LIKE '%%$filter%%' ) AND wb.public = 1 AND wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 ORDER BY meta_value ASC" ) );
|
206 |
-
}
|
207 |
|
208 |
-
$paged_blogs = $wpdb->get_results(
|
209 |
-
|
210 |
-
|
|
|
211 |
}
|
212 |
-
|
213 |
-
function
|
214 |
global $bp, $wpdb;
|
215 |
-
|
216 |
if ( !$bp->blogs )
|
217 |
bp_blogs_setup_globals();
|
218 |
-
|
219 |
-
if (
|
|
|
|
|
|
|
220 |
$pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
|
221 |
-
|
222 |
-
}
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
return array( 'blogs' => $paged_blogs, 'total' => $total_blogs );
|
227 |
}
|
228 |
-
|
229 |
-
function
|
230 |
global $bp, $wpdb;
|
231 |
-
|
232 |
if ( !$bp->blogs )
|
233 |
bp_blogs_setup_globals();
|
234 |
-
|
235 |
-
|
|
|
|
|
|
|
|
|
|
|
236 |
$pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
|
237 |
-
|
238 |
-
}
|
239 |
-
|
240 |
-
$paged_blogs = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT bm.blog_id FROM {$bp->blogs->table_name_blogmeta} bm LEFT JOIN {$wpdb->base_prefix}blogs wb ON bm.blog_id = wb.blog_id WHERE wb.public = 1 AND wb.archived = '0' AND wb.spam = 0 AND wb.mature = 0 AND wb.deleted = 0 AND bm.meta_key = 'last_activity' ORDER BY CONVERT(bm.meta_value, SIGNED) DESC {$pag_sql}" ) );
|
241 |
|
242 |
return array( 'blogs' => $paged_blogs, 'total' => $total_blogs );
|
243 |
}
|
244 |
-
|
245 |
-
function
|
246 |
global $bp, $wpdb;
|
247 |
-
|
248 |
-
if (
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
254 |
}
|
255 |
-
|
256 |
-
$paged_blogs = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT wb.blog_id FROM {$wpdb->base_prefix}blogs wb WHERE wb.public = 1 AND wb.archived = '0' AND wb.spam = 0 AND wb.mature = 0 AND wb.deleted = 0 ORDER BY wb.registered DESC {$pag_sql}" ) );
|
257 |
|
258 |
-
return
|
259 |
}
|
260 |
-
|
261 |
function is_hidden( $blog_id ) {
|
262 |
global $wpdb;
|
263 |
|
264 |
if ( !$bp->blogs )
|
265 |
bp_blogs_setup_globals();
|
266 |
-
|
267 |
if ( !(int)$wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT public FROM {$wpdb->base_prefix}blogs WHERE blog_id = %d", $blog_id ) ) )
|
268 |
return true;
|
269 |
-
|
270 |
return false;
|
271 |
}
|
272 |
}
|
@@ -277,7 +312,7 @@ Class BP_Blogs_Post {
|
|
277 |
var $blog_id;
|
278 |
var $post_id;
|
279 |
var $date_created;
|
280 |
-
|
281 |
function bp_blogs_post( $id = null, $blog_id = null, $post_id = null ) {
|
282 |
global $bp, $wpdb;
|
283 |
|
@@ -296,17 +331,17 @@ Class BP_Blogs_Post {
|
|
296 |
$post = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->blogs->table_name_blog_posts} WHERE id = %d", $this->id ) );
|
297 |
else
|
298 |
$post = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->blogs->table_name_blog_posts} WHERE blog_id = %d AND post_id = %d", $this->blog_id, $this->post_id ) );
|
299 |
-
|
300 |
-
$this->id = $post->id;
|
301 |
$this->user_id = $post->user_id;
|
302 |
$this->blog_id = $post->blog_id;
|
303 |
$this->post_id = $post->post_id;
|
304 |
$this->date_created = $post->date_created;
|
305 |
}
|
306 |
-
|
307 |
function save() {
|
308 |
global $wpdb, $bp;
|
309 |
-
|
310 |
$this->post_id = apply_filters( 'bp_blogs_post_id_before_save', $this->post_id, $this->id );
|
311 |
$this->blog_id = apply_filters( 'bp_blogs_post_blog_id_before_save', $this->blog_id, $this->id );
|
312 |
$this->user_id = apply_filters( 'bp_blogs_post_user_id_before_save', $this->user_id, $this->id );
|
@@ -321,44 +356,44 @@ Class BP_Blogs_Post {
|
|
321 |
// Save
|
322 |
$sql = $wpdb->prepare( "INSERT INTO {$bp->blogs->table_name_blog_posts} ( post_id, blog_id, user_id, date_created ) VALUES ( %d, %d, %d, FROM_UNIXTIME(%d) )", $this->post_id, $this->blog_id, $this->user_id, $this->date_created );
|
323 |
}
|
324 |
-
|
325 |
if ( !$wpdb->query($sql) )
|
326 |
return false;
|
327 |
|
328 |
do_action( 'bp_blogs_post_after_save', $this );
|
329 |
-
|
330 |
if ( $this->id )
|
331 |
return $this->id;
|
332 |
else
|
333 |
-
return $wpdb->insert_id;
|
334 |
}
|
335 |
-
|
336 |
/* Static Functions */
|
337 |
-
|
338 |
function delete( $post_id, $blog_id ) {
|
339 |
global $wpdb, $bp, $current_user;
|
340 |
-
|
341 |
if ( !$bp->blogs )
|
342 |
bp_blogs_setup_globals();
|
343 |
|
344 |
return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blog_posts} WHERE blog_id = %d AND post_id = %d", $blog_id, $post_id ) );
|
345 |
}
|
346 |
-
|
347 |
function delete_oldest( $user_id = null ) {
|
348 |
global $wpdb, $bp;
|
349 |
-
|
350 |
if ( !$bp->blogs )
|
351 |
bp_blogs_setup_globals();
|
352 |
-
|
353 |
if ( !$user_id )
|
354 |
$user_id = $current_user->ID;
|
355 |
-
|
356 |
-
return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blog_posts} WHERE user_id = %d ORDER BY date_created ASC LIMIT 1", $user_id ) );
|
357 |
}
|
358 |
-
|
359 |
function delete_posts_for_user( $user_id = null ) {
|
360 |
global $wpdb, $bp;
|
361 |
-
|
362 |
if ( !$bp->blogs )
|
363 |
bp_blogs_setup_globals();
|
364 |
|
@@ -367,49 +402,50 @@ Class BP_Blogs_Post {
|
|
367 |
|
368 |
return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blog_posts} WHERE user_id = %d", $user_id ) );
|
369 |
}
|
370 |
-
|
371 |
function delete_posts_for_blog( $blog_id ) {
|
372 |
global $wpdb, $bp;
|
373 |
-
|
374 |
if ( !$bp->blogs )
|
375 |
bp_blogs_setup_globals();
|
376 |
-
|
377 |
return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blog_posts} WHERE blog_id = %d", $blog_id ) );
|
378 |
}
|
379 |
-
|
380 |
function get_latest_posts( $blog_id = null, $limit = 5 ) {
|
381 |
global $wpdb, $bp;
|
382 |
-
|
383 |
if ( !$bp->blogs )
|
384 |
bp_blogs_setup_globals();
|
385 |
-
|
386 |
if ( $blog_id )
|
387 |
$blog_sql = $wpdb->prepare( " AND p.blog_id = %d", $blog_id );
|
388 |
-
|
389 |
$post_ids = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT p.post_id, p.blog_id FROM {$bp->blogs->table_name_blog_posts} p LEFT JOIN {$wpdb->base_prefix}blogs b ON p.blog_id = b.blog_id WHERE b.public = 1 AND b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 $blog_sql ORDER BY p.date_created DESC LIMIT $limit" ) );
|
390 |
|
391 |
for ( $i = 0; $i < count($post_ids); $i++ ) {
|
392 |
$posts[$i] = BP_Blogs_Post::fetch_post_content($post_ids[$i]);
|
393 |
}
|
394 |
-
|
395 |
return $posts;
|
396 |
}
|
397 |
-
|
398 |
function get_posts_for_user( $user_id = null ) {
|
399 |
global $bp, $wpdb;
|
400 |
-
|
401 |
if ( !$bp->blogs )
|
402 |
bp_blogs_setup_globals();
|
403 |
-
|
404 |
if ( !$user_id )
|
405 |
$user_id = $bp->displayed_user->id;
|
406 |
-
|
407 |
// Show a logged in user their posts on private blogs, but not anyone else.
|
408 |
-
if ( !
|
409 |
$post_ids = $wpdb->get_results( $wpdb->prepare( "SELECT p.post_id, p.blog_id FROM {$bp->blogs->table_name_blog_posts} p LEFT JOIN {$wpdb->base_prefix}blogs b ON p.blog_id = b.blog_id WHERE b.public = 1 AND b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND p.user_id = %d ORDER BY p.date_created DESC", $user_id) );
|
410 |
$total_post_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(p.post_id) FROM {$bp->blogs->table_name_blog_posts} p LEFT JOIN {$wpdb->base_prefix}blogs b ON p.blog_id = b.blog_id WHERE b.public = 1 AND b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND p.user_id = %d", $user_id) );
|
411 |
} else {
|
412 |
$post_ids = $wpdb->get_results( $wpdb->prepare( "SELECT p.post_id, p.blog_id FROM {$bp->blogs->table_name_blog_posts} p LEFT JOIN {$wpdb->base_prefix}blogs b ON p.blog_id = b.blog_id WHERE b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND p.user_id = %d ORDER BY p.date_created DESC", $user_id) );
|
|
|
413 |
$total_post_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(p.post_id) FROM {$bp->blogs->table_name_blog_posts} p LEFT JOIN {$wpdb->base_prefix}blogs b ON p.blog_id = b.blog_id WHERE b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND p.user_id = %d", $user_id) );
|
414 |
}
|
415 |
|
@@ -419,7 +455,7 @@ Class BP_Blogs_Post {
|
|
419 |
|
420 |
return array( 'posts' => $posts, 'count' => $total_post_count );
|
421 |
}
|
422 |
-
|
423 |
function fetch_post_content( $post_object ) {
|
424 |
// TODO: switch_to_blog() calls are expensive and this needs to be changed.
|
425 |
switch_to_blog( $post_object->blog_id );
|
@@ -429,52 +465,52 @@ Class BP_Blogs_Post {
|
|
429 |
|
430 |
return $post;
|
431 |
}
|
432 |
-
|
433 |
function get_total_recorded_for_user( $user_id = null ) {
|
434 |
global $bp, $wpdb;
|
435 |
-
|
436 |
if ( !$bp->blogs )
|
437 |
bp_blogs_setup_globals();
|
438 |
-
|
439 |
if ( !$user_id )
|
440 |
$user_id = $current_user->ID;
|
441 |
|
442 |
return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(post_id) FROM {$bp->blogs->table_name_blog_posts} WHERE user_id = %d", $user_id ) );
|
443 |
}
|
444 |
-
|
445 |
function is_recorded( $post_id, $blog_id, $user_id = null ) {
|
446 |
global $bp, $wpdb, $current_user;
|
447 |
-
|
448 |
if ( !$bp->blogs )
|
449 |
bp_blogs_setup_globals();
|
450 |
-
|
451 |
if ( !$user_id )
|
452 |
$user_id = $current_user->ID;
|
453 |
-
|
454 |
return $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM {$bp->blogs->table_name_blog_posts} WHERE post_id = %d AND blog_id = %d AND user_id = %d", $post_id, $blog_id, $user_id ) );
|
455 |
}
|
456 |
-
|
457 |
function total_post_count( $blog_id ) {
|
458 |
global $bp, $wpdb;
|
459 |
-
|
460 |
if ( !$bp->blogs )
|
461 |
bp_blogs_setup_globals();
|
462 |
-
|
463 |
if ( !$blog_id )
|
464 |
return false;
|
465 |
-
|
466 |
return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(post_id) FROM {$bp->blogs->table_name_blog_posts} WHERE blog_id = %d", $blog_id ) );
|
467 |
}
|
468 |
-
|
469 |
function get_all() {
|
470 |
global $bp, $wpdb;
|
471 |
-
|
472 |
if ( !$bp->blogs )
|
473 |
bp_blogs_setup_globals();
|
474 |
-
|
475 |
return $wpdb->get_col( $wpdb->prepare( "SELECT post_id, blog_id FROM " . $bp->blogs->table_name_blog_posts ) );
|
476 |
}
|
477 |
-
|
478 |
}
|
479 |
|
480 |
Class BP_Blogs_Comment {
|
@@ -484,13 +520,13 @@ Class BP_Blogs_Comment {
|
|
484 |
var $comment_id;
|
485 |
var $comment_post_id;
|
486 |
var $date_created;
|
487 |
-
|
488 |
function bp_blogs_comment( $id = false, $blog_id = false, $comment_id = false ) {
|
489 |
global $bp, $wpdb;
|
490 |
|
491 |
if ( !$user_id )
|
492 |
$user_id = $bp->displayed_user->id;
|
493 |
-
|
494 |
if ( $id || ( !$id && $blog_id && $comment_id ) ) {
|
495 |
$this->id = $id;
|
496 |
$this->blog_id = $blog_id;
|
@@ -501,19 +537,19 @@ Class BP_Blogs_Comment {
|
|
501 |
|
502 |
function populate() {
|
503 |
global $wpdb, $bp;
|
504 |
-
|
505 |
if ( $this->id )
|
506 |
$comment = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->blogs->table_name_blog_comments} WHERE id = %d", $this->id ) );
|
507 |
else
|
508 |
$comment = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->blogs->table_name_blog_comments} WHERE blog_id = %d AND comment_id = %d", (int)$this->blog_id, (int)$this->comment_id ) );
|
509 |
-
|
510 |
$this->comment_id = $comment->comment_id;
|
511 |
$this->user_id = $comment->user_id;
|
512 |
$this->blog_id = $comment->blog_id;
|
513 |
$this->comment_post_id = $comment->comment_post_id;
|
514 |
$this->date_created = $comment->date_created;
|
515 |
}
|
516 |
-
|
517 |
function save() {
|
518 |
global $wpdb, $bp;
|
519 |
|
@@ -524,7 +560,7 @@ Class BP_Blogs_Comment {
|
|
524 |
$this->date_created = apply_filters( 'bp_blogs_comment_date_created_before_save', $this->date_created, $this->id );
|
525 |
|
526 |
do_action( 'bp_blogs_comment_before_save', $this );
|
527 |
-
|
528 |
if ( $this->id ) {
|
529 |
// Update
|
530 |
$sql = $wpdb->prepare( "UPDATE {$bp->blogs->table_name_blog_comments} SET comment_id = %d, comment_post_id = %d, blog_id = %d, user_id = %d, date_created = FROM_UNIXTIME(%d) WHERE id = %d", $this->comment_id, $this->comment_post_id, $this->blog_id, $this->user_id, $this->date_created, $this->id );
|
@@ -535,41 +571,41 @@ Class BP_Blogs_Comment {
|
|
535 |
|
536 |
if ( !$wpdb->query($sql) )
|
537 |
return false;
|
538 |
-
|
539 |
do_action( 'bp_blogs_comment_after_save', $this );
|
540 |
-
|
541 |
if ( $this->id )
|
542 |
return $this->id;
|
543 |
else
|
544 |
-
return $wpdb->insert_id;
|
545 |
}
|
546 |
|
547 |
/* Static Functions */
|
548 |
-
|
549 |
function delete( $comment_id, $blog_id ) {
|
550 |
global $wpdb, $bp, $current_user;
|
551 |
-
|
552 |
if ( !$bp->blogs )
|
553 |
bp_blogs_setup_globals();
|
554 |
-
|
555 |
return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blog_comments} WHERE comment_id = %d AND blog_id = %d", $comment_id, $blog_id ) );
|
556 |
}
|
557 |
-
|
558 |
function delete_oldest( $user_id = null ) {
|
559 |
global $wpdb, $bp, $current_user;
|
560 |
-
|
561 |
if ( !$bp->blogs )
|
562 |
bp_blogs_setup_globals();
|
563 |
-
|
564 |
if ( !$user_id )
|
565 |
$user_id = $current_user->ID;
|
566 |
-
|
567 |
-
return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blog_comments} WHERE user_id = %d ORDER BY date_created ASC LIMIT 1", $user_id ) );
|
568 |
}
|
569 |
-
|
570 |
function delete_comments_for_user( $user_id = null ) {
|
571 |
global $wpdb, $bp;
|
572 |
-
|
573 |
if ( !$bp->blogs )
|
574 |
bp_blogs_setup_globals();
|
575 |
|
@@ -578,88 +614,88 @@ Class BP_Blogs_Comment {
|
|
578 |
|
579 |
return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blog_comments} WHERE user_id = %d", $user_id ) );
|
580 |
}
|
581 |
-
|
582 |
function delete_comments_for_blog( $blog_id ) {
|
583 |
global $wpdb, $bp;
|
584 |
-
|
585 |
if ( !$bp->blogs )
|
586 |
bp_blogs_setup_globals();
|
587 |
-
|
588 |
return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blog_comments} WHERE blog_id = %d", $blog_id ) );
|
589 |
}
|
590 |
-
|
591 |
function get_comments_for_user( $user_id = null ) {
|
592 |
global $bp, $wpdb;
|
593 |
-
|
594 |
if ( !$bp->blogs )
|
595 |
bp_blogs_setup_globals();
|
596 |
|
597 |
if ( !$user_id )
|
598 |
$user_id = $bp->displayed_user->id;
|
599 |
-
|
600 |
// Show the logged in user their comments on hidden blogs, but not to anyone else.
|
601 |
-
if ( !
|
602 |
$comment_ids = $wpdb->get_results( $wpdb->prepare( "SELECT c.comment_id, c.blog_id FROM {$bp->blogs->table_name_blog_comments} c LEFT JOIN {$wpdb->base_prefix}blogs b ON c.blog_id = b.blog_id WHERE b.public = 1 AND b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND c.user_id = %d ORDER BY c.date_created ASC", $user_id) );
|
603 |
$total_comment_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(c.comment_id) FROM {$bp->blogs->table_name_blog_comments} c LEFT JOIN {$wpdb->base_prefix}blogs b ON c.blog_id = b.blog_id WHERE b.public = 1 AND b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND c.user_id = %d", $user_id) );
|
604 |
} else {
|
605 |
$comment_ids = $wpdb->get_results( $wpdb->prepare( "SELECT c.comment_id, c.blog_id FROM {$bp->blogs->table_name_blog_comments} c LEFT JOIN {$wpdb->base_prefix}blogs b ON c.blog_id = b.blog_id WHERE b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND c.user_id = %d ORDER BY c.date_created ASC", $user_id) );
|
|
|
606 |
$total_comment_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(c.comment_id) FROM {$bp->blogs->table_name_blog_comments} c LEFT JOIN {$wpdb->base_prefix}blogs b ON c.blog_id = b.blog_id WHERE b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND c.user_id = %d", $user_id) );
|
607 |
}
|
608 |
-
|
609 |
-
for ( $i = 0; $i < count($comment_ids); $i++ )
|
610 |
$comments[$i] = BP_Blogs_Comment::fetch_comment_content($comment_ids[$i]);
|
611 |
-
}
|
612 |
|
613 |
return array( 'comments' => $comments, 'count' => $total_comment_count );
|
614 |
}
|
615 |
-
|
616 |
-
function fetch_comment_content( $comment_object ) {
|
617 |
switch_to_blog($comment_object->blog_id);
|
618 |
$comment = get_comment($comment_object->comment_id);
|
619 |
$comment->blog_id = $comment_object->blog_id;
|
620 |
$comment->post = &get_post( $comment->comment_post_ID );
|
621 |
restore_current_blog();
|
622 |
-
|
623 |
return $comment;
|
624 |
}
|
625 |
-
|
626 |
function get_total_recorded_for_user( $user_id = null ) {
|
627 |
global $bp, $wpdb, $current_user;
|
628 |
-
|
629 |
if ( !$bp->blogs )
|
630 |
bp_blogs_setup_globals();
|
631 |
-
|
632 |
if ( !$user_id )
|
633 |
$user_id = $current_user->ID;
|
634 |
|
635 |
return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(comment_id) FROM {$bp->blogs->table_name_blog_comments} WHERE user_id = %d", $user_id ) );
|
636 |
}
|
637 |
-
|
638 |
function total_comment_count( $blog_id, $post_id ) {
|
639 |
global $bp, $wpdb;
|
640 |
-
|
641 |
if ( !$bp->blogs )
|
642 |
bp_blogs_setup_globals();
|
643 |
-
|
644 |
if ( $post_id )
|
645 |
$post_sql = $wpdb->prepare( " AND comment_post_id = %d", $post_id );
|
646 |
|
647 |
return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(comment_id) WHERE blog_id = %d{$post_sql}", $blog_id ) );
|
648 |
}
|
649 |
-
|
650 |
-
|
651 |
function is_recorded( $comment_id, $comment_post_id, $blog_id, $user_id = null ) {
|
652 |
global $bp, $wpdb, $current_user;
|
653 |
-
|
654 |
if ( !$bp->blogs )
|
655 |
bp_blogs_setup_globals();
|
656 |
-
|
657 |
if ( !$user_id )
|
658 |
$user_id = $current_user->ID;
|
659 |
-
|
660 |
return $wpdb->get_var( $wpdb->prepare( "SELECT comment_id FROM {$bp->blogs->table_name_blog_comments} WHERE comment_id = %d AND blog_id = %d AND comment_post_id = %d AND user_id = %d", $comment_id, $blog_id, $comment_post_id, $user_id ) );
|
661 |
}
|
662 |
-
|
663 |
}
|
664 |
|
665 |
?>
|
4 |
var $id;
|
5 |
var $user_id;
|
6 |
var $blog_id;
|
7 |
+
|
8 |
function bp_blogs_blog( $id = null ) {
|
9 |
global $bp, $wpdb;
|
10 |
+
|
11 |
if ( !$user_id )
|
12 |
$user_id = $bp->displayed_user->id;
|
13 |
|
16 |
$this->populate();
|
17 |
}
|
18 |
}
|
19 |
+
|
20 |
function populate() {
|
21 |
global $wpdb, $bp;
|
22 |
+
|
23 |
$blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->blogs->table_name} WHERE id = %d", $this->id ) );
|
24 |
|
25 |
$this->user_id = $blog->user_id;
|
26 |
$this->blog_id = $blog->blog_id;
|
27 |
}
|
28 |
+
|
29 |
function save() {
|
30 |
global $wpdb, $bp;
|
31 |
+
|
32 |
$this->user_id = apply_filters( 'bp_blogs_blog_user_id_before_save', $this->user_id, $this->id );
|
33 |
$this->blog_id = apply_filters( 'bp_blogs_blog_id_before_save', $this->blog_id, $this->id );
|
34 |
+
|
35 |
do_action( 'bp_blogs_blog_before_save', $this );
|
36 |
+
|
37 |
// Don't try and save if there is no user ID or blog ID set.
|
38 |
if ( !$this->user_id || !$this->blog_id )
|
39 |
return false;
|
40 |
+
|
41 |
// Don't save if this blog has already been recorded for the user.
|
42 |
if ( !$this->id && $this->exists() )
|
43 |
return false;
|
44 |
+
|
45 |
if ( $this->id ) {
|
46 |
// Update
|
47 |
$sql = $wpdb->prepare( "UPDATE {$bp->blogs->table_name} SET user_id = %d, blog_id = %d WHERE id = %d", $this->user_id, $this->blog_id, $this->id );
|
49 |
// Save
|
50 |
$sql = $wpdb->prepare( "INSERT INTO {$bp->blogs->table_name} ( user_id, blog_id ) VALUES ( %d, %d )", $this->user_id, $this->blog_id );
|
51 |
}
|
52 |
+
|
53 |
if ( !$wpdb->query($sql) )
|
54 |
return false;
|
55 |
+
|
56 |
do_action( 'bp_blogs_blog_after_save', $this );
|
57 |
+
|
58 |
if ( $this->id )
|
59 |
return $this->id;
|
60 |
else
|
61 |
return $wpdb->insert_id;
|
62 |
}
|
63 |
+
|
64 |
function exists() {
|
65 |
global $bp, $wpdb;
|
66 |
+
|
67 |
return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->blogs->table_name} WHERE user_id = %d AND blog_id = %d", $this->user_id, $this->blog_id ) );
|
68 |
}
|
69 |
+
|
70 |
/* Static Functions */
|
71 |
+
|
72 |
+
function get( $type, $limit = false, $page = false, $user_id = false, $search_terms = false ) {
|
73 |
+
global $bp, $wpdb;
|
74 |
+
|
75 |
+
if ( !$bp->blogs )
|
76 |
+
bp_blogs_setup_globals();
|
77 |
+
|
78 |
+
if ( !is_user_logged_in() || ( !is_site_admin() && ( $user_id != $bp->loggedin_user->id ) ) )
|
79 |
+
$hidden_sql = "AND wb.public = 1";
|
80 |
+
|
81 |
+
if ( $limit && $page )
|
82 |
+
$pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
|
83 |
+
|
84 |
+
if ( $user_id )
|
85 |
+
$user_sql = $wpdb->prepare( " AND b.user_id = %d", $user_id );
|
86 |
+
|
87 |
+
switch ( $type ) {
|
88 |
+
case 'active': default:
|
89 |
+
$order_sql = "ORDER BY bm.meta_value DESC";
|
90 |
+
break;
|
91 |
+
case 'alphabetical':
|
92 |
+
$order_sql = "ORDER BY bm2.meta_value ASC";
|
93 |
+
break;
|
94 |
+
case 'newest':
|
95 |
+
$order_sql = "ORDER BY wb.registered DESC";
|
96 |
+
break;
|
97 |
+
case 'random':
|
98 |
+
$order_sql = "ORDER BY RAND()";
|
99 |
+
break;
|
100 |
+
}
|
101 |
+
|
102 |
+
if ( !empty( $search_terms ) ) {
|
103 |
+
$filter = like_escape( $wpdb->escape( $search_terms ) );
|
104 |
+
$paged_blogs = $wpdb->get_results( "SELECT b.blog_id, b.user_id as admin_user_id, u.user_email as admin_user_email, wb.domain, wb.path, bm.meta_value as last_activity, bm2.meta_value as name, bm3.meta_value as description FROM {$bp->blogs->table_name} b, {$bp->blogs->table_name_blogmeta} bm, {$bp->blogs->table_name_blogmeta} bm2, {$bp->blogs->table_name_blogmeta} bm3, {$wpdb->base_prefix}blogs wb, {$wpdb->users} u WHERE b.blog_id = wb.blog_id AND b.user_id = u.ID AND b.blog_id = bm.blog_id AND b.blog_id = bm2.blog_id AND b.blog_id = bm3.blog_id AND wb.archived = '0' AND wb.spam = 0 AND wb.mature = 0 AND wb.deleted = 0 {$hidden_sql} AND bm.meta_key = 'last_activity' AND bm2.meta_key = 'name' AND bm3.meta_key = 'description' AND ( bm2.meta_value LIKE '%%$filter%%' || bm3.meta_value LIKE '%%$filter%%' ) {$user_sql} GROUP BY b.blog_id {$order_sql} {$pag_sql}" );
|
105 |
+
$total_blogs = $wpdb->get_var( "SELECT COUNT(DISTINCT b.blog_id) FROM {$bp->blogs->table_name} b, {$wpdb->base_prefix}blogs wb, {$bp->blogs->table_name_blogmeta} bm, {$bp->blogs->table_name_blogmeta} bm2 WHERE b.blog_id = wb.blog_id AND bm.blog_id = b.blog_id AND bm2.blog_id = b.blog_id AND wb.archived = '0' AND wb.spam = 0 AND wb.mature = 0 AND wb.deleted = 0 {$hidden_sql} AND bm.meta_key = 'name' AND bm2.meta_key = 'description' AND ( bm.meta_value LIKE '%%$filter%%' || bm2.meta_value LIKE '%%$filter%%' ) {$user_sql}" );
|
106 |
+
} else {
|
107 |
+
$paged_blogs = $wpdb->get_results( $wpdb->prepare( "SELECT b.blog_id, b.user_id as admin_user_id, u.user_email as admin_user_email, wb.domain, wb.path, bm.meta_value as last_activity, bm2.meta_value as name, bm3.meta_value as description FROM {$bp->blogs->table_name} b, {$bp->blogs->table_name_blogmeta} bm, {$bp->blogs->table_name_blogmeta} bm2, {$bp->blogs->table_name_blogmeta} bm3, {$wpdb->base_prefix}blogs wb, {$wpdb->users} u WHERE b.blog_id = wb.blog_id AND b.user_id = u.ID AND b.blog_id = bm.blog_id AND b.blog_id = bm2.blog_id AND b.blog_id = bm3.blog_id {$user_sql} AND wb.archived = '0' AND wb.spam = 0 AND wb.mature = 0 AND wb.deleted = 0 {$hidden_sql} AND bm.meta_key = 'last_activity' AND bm2.meta_key = 'name' AND bm3.meta_key = 'description' GROUP BY b.blog_id {$order_sql} {$pag_sql}" ) );
|
108 |
+
$total_blogs = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT b.blog_id) FROM {$bp->blogs->table_name} b, {$wpdb->base_prefix}blogs wb WHERE b.blog_id = wb.blog_id {$user_sql} AND wb.archived = '0' AND wb.spam = 0 AND wb.mature = 0 AND wb.deleted = 0 {$hidden_sql}" ) );
|
109 |
+
}
|
110 |
+
|
111 |
+
foreach ( (array)$paged_blogs as $blog ) $blog_ids[] = $blog->blog_id;
|
112 |
+
$blog_ids = $wpdb->escape( join( ',', (array)$blog_ids ) );
|
113 |
+
$paged_blogs = BP_Blogs_Blog::get_blog_extras( &$paged_blogs, $blog_ids, $type );
|
114 |
+
|
115 |
+
return array( 'blogs' => $paged_blogs, 'total' => $total_blogs );
|
116 |
+
}
|
117 |
+
|
118 |
function delete_blog_for_all( $blog_id ) {
|
119 |
global $wpdb, $bp;
|
120 |
+
|
121 |
if ( !$bp->blogs )
|
122 |
bp_blogs_setup_globals();
|
123 |
+
|
124 |
bp_blogs_delete_blogmeta( $blog_id );
|
125 |
|
126 |
return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name} WHERE blog_id = %d", $blog_id ) );
|
127 |
}
|
128 |
+
|
129 |
function delete_blog_for_user( $blog_id, $user_id = null ) {
|
130 |
global $wpdb, $bp;
|
131 |
+
|
132 |
if ( !$bp->blogs )
|
133 |
bp_blogs_setup_globals();
|
134 |
+
|
135 |
if ( !$user_id )
|
136 |
$user_id = $bp->loggedin_user->id;
|
137 |
|
138 |
return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name} WHERE user_id = %d AND blog_id = %d", $user_id, $blog_id ) );
|
139 |
}
|
140 |
+
|
141 |
function delete_blogs_for_user( $user_id = null ) {
|
142 |
global $wpdb, $bp;
|
143 |
+
|
144 |
if ( !$bp->blogs )
|
145 |
bp_blogs_setup_globals();
|
146 |
|
149 |
|
150 |
return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name} WHERE user_id = %d", $user_id ) );
|
151 |
}
|
152 |
+
|
153 |
+
function get_blogs_for_user( $user_id = false, $show_hidden = false ) {
|
154 |
global $bp, $wpdb;
|
155 |
+
|
156 |
if ( !$bp->blogs )
|
157 |
bp_blogs_setup_globals();
|
158 |
+
|
159 |
if ( !$user_id )
|
160 |
$user_id = $bp->displayed_user->id;
|
161 |
+
|
162 |
// Show logged in users their hidden blogs.
|
163 |
+
if ( !bp_is_my_profile() && !$show_hidden )
|
164 |
+
$blogs = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT b.id, bm1.meta_value as name, bm2.meta_value as description, wb.domain, wb.path FROM {$bp->blogs->table_name} b, {$wpdb->base_prefix}blogs wb, {$bp->blogs->table_name_blogmeta} bm1, {$bp->blogs->table_name_blogmeta} bm2 WHERE b.blog_id = wb.blog_id AND b.blog_id = bm1.blog_id AND b.blog_id = bm2.blog_id AND bm1.meta_key = 'name' AND bm2.meta_key = 'description' AND wb.public = 1 AND wb.deleted = 0 AND wb.spam = 0 AND wb.mature = 0 AND wb.archived = '0' AND b.user_id = %d ORDER BY b.id", $user_id) );
|
165 |
else
|
166 |
+
$blogs = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT b.id, bm1.meta_value as name, bm2.meta_value as description, wb.domain, wb.path FROM {$bp->blogs->table_name} b, {$wpdb->base_prefix}blogs wb, {$bp->blogs->table_name_blogmeta} bm1, {$bp->blogs->table_name_blogmeta} bm2 WHERE b.blog_id = wb.blog_id AND b.blog_id = bm1.blog_id AND b.blog_id = bm2.blog_id AND bm1.meta_key = 'name' AND bm2.meta_key = 'description' AND wb.deleted = 0 AND wb.spam = 0 AND wb.mature = 0 AND wb.archived = '0' AND b.user_id = %d ORDER BY b.id", $user_id) );
|
167 |
+
|
168 |
+
$total_blog_count = BP_Blogs_Blog::total_blog_count_for_user( $user_id );
|
169 |
+
|
170 |
+
foreach ( (array)$blogs as $blog ) {
|
171 |
+
$user_blogs[$blog->id] = new stdClass;
|
172 |
+
$user_blogs[$blog->id]->id = $blog->id;
|
173 |
+
$user_blogs[$blog->id]->siteurl = ( is_ssl() ) ? 'https://' . $blog->domain . $blog->path : 'http://' . $blog->domain . $blog->path;
|
174 |
+
$user_blogs[$blog->id]->name = $blog->name;
|
175 |
+
$user_blogs[$blog->id]->description = $blog->description;
|
|
|
176 |
}
|
177 |
|
178 |
+
return array( 'blogs' => $user_blogs, 'count' => $total_blog_count );
|
179 |
+
}
|
180 |
+
|
181 |
+
function get_blog_ids_for_user( $user_id = false ) {
|
182 |
+
global $bp, $wpdb;
|
183 |
+
|
184 |
+
if ( !$bp->blogs )
|
185 |
+
bp_blogs_setup_globals();
|
186 |
+
|
187 |
+
if ( !$user_id )
|
188 |
+
$user_id = $bp->displayed_user->id;
|
189 |
+
|
190 |
+
return $wpdb->get_col( $wpdb->prepare( "SELECT blog_id FROM {$bp->blogs->table_name} WHERE user_id = %d", $user_id ) );
|
191 |
}
|
192 |
+
|
193 |
function is_recorded( $blog_id ) {
|
194 |
global $bp, $wpdb;
|
195 |
+
|
196 |
if ( !$bp->blogs )
|
197 |
bp_blogs_setup_globals();
|
198 |
+
|
199 |
return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->blogs->table_name} WHERE blog_id = %d", $blog_id ) );
|
200 |
}
|
201 |
+
|
202 |
+
function total_blog_count_for_user( $user_id = null ) {
|
203 |
global $bp, $wpdb;
|
204 |
+
|
205 |
if ( !$bp->blogs )
|
206 |
bp_blogs_setup_globals();
|
207 |
+
|
208 |
if ( !$user_id )
|
209 |
$user_id = $bp->displayed_user->id;
|
210 |
|
211 |
// If the user is logged in return the blog count including their hidden blogs.
|
212 |
+
if ( !is_user_logged_in() || $user_id != $bp->loggedin_user->id )
|
213 |
return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT b.blog_id) FROM {$bp->blogs->table_name} b LEFT JOIN {$wpdb->base_prefix}blogs wb ON b.blog_id = wb.blog_id WHERE wb.public = 1 AND wb.deleted = 0 AND wb.spam = 0 AND wb.mature = 0 AND wb.archived = '0' AND user_id = %d", $user_id) );
|
214 |
else
|
215 |
return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT b.blog_id) FROM {$bp->blogs->table_name} b LEFT JOIN {$wpdb->base_prefix}blogs wb ON b.blog_id = wb.blog_id WHERE wb.deleted = 0 AND wb.spam = 0 AND wb.mature = 0 AND wb.archived = '0' AND user_id = %d", $user_id) );
|
216 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
217 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
218 |
function search_blogs( $filter, $limit = null, $page = null ) {
|
219 |
global $wpdb, $bp;
|
220 |
+
|
221 |
if ( !$bp->blogs )
|
222 |
bp_blogs_setup_globals();
|
223 |
+
|
224 |
$filter = like_escape( $wpdb->escape( $filter ) );
|
225 |
+
|
226 |
+
if ( !is_site_admin() )
|
227 |
+
$hidden_sql = "AND wb.public = 1";
|
228 |
+
|
229 |
+
if ( $limit && $page )
|
230 |
$pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
|
|
|
|
|
231 |
|
232 |
+
$paged_blogs = $wpdb->get_results( "SELECT DISTINCT bm.blog_id FROM {$bp->blogs->table_name_blogmeta} bm LEFT JOIN {$wpdb->base_prefix}blogs wb ON bm.blog_id = wb.blog_id WHERE ( ( bm.meta_key = 'name' OR bm.meta_key = 'description' ) AND bm.meta_value LIKE '%%$filter%%' ) {$hidden_sql} AND wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 ORDER BY meta_value ASC{$pag_sql}" );
|
233 |
+
$total_blogs = $wpdb->get_var( "SELECT COUNT(DISTINCT bm.blog_id) FROM {$bp->blogs->table_name_blogmeta} bm LEFT JOIN {$wpdb->base_prefix}blogs wb ON bm.blog_id = wb.blog_id WHERE ( ( bm.meta_key = 'name' OR bm.meta_key = 'description' ) AND bm.meta_value LIKE '%%$filter%%' ) {$hidden_sql} AND wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 ORDER BY meta_value ASC" );
|
234 |
+
|
235 |
+
return array( 'blogs' => $paged_blogs, 'total' => $total_blogs );
|
236 |
}
|
237 |
+
|
238 |
+
function get_all( $limit = null, $page = null ) {
|
239 |
global $bp, $wpdb;
|
240 |
+
|
241 |
if ( !$bp->blogs )
|
242 |
bp_blogs_setup_globals();
|
243 |
+
|
244 |
+
if ( !is_site_admin() )
|
245 |
+
$hidden_sql = "AND wb.public = 1";
|
246 |
+
|
247 |
+
if ( $limit && $page )
|
248 |
$pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
|
249 |
+
|
250 |
+
$paged_blogs = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT b.blog_id FROM {$bp->blogs->table_name} b LEFT JOIN {$wpdb->base_prefix}blogs wb ON b.blog_id = wb.blog_id WHERE wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 {$hidden_sql} {$pag_sql}" ) );
|
251 |
+
$total_blogs = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT b.blog_id) FROM {$bp->blogs->table_name} b LEFT JOIN {$wpdb->base_prefix}blogs wb ON b.blog_id = wb.blog_id WHERE wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 {$hidden_sql}" ) );
|
252 |
+
|
|
|
253 |
return array( 'blogs' => $paged_blogs, 'total' => $total_blogs );
|
254 |
}
|
255 |
+
|
256 |
+
function get_by_letter( $letter, $limit = null, $page = null ) {
|
257 |
global $bp, $wpdb;
|
258 |
+
|
259 |
if ( !$bp->blogs )
|
260 |
bp_blogs_setup_globals();
|
261 |
+
|
262 |
+
$letter = like_escape( $wpdb->escape( $letter ) );
|
263 |
+
|
264 |
+
if ( !is_site_admin() )
|
265 |
+
$hidden_sql = "AND wb.public = 1";
|
266 |
+
|
267 |
+
if ( $limit && $page )
|
268 |
$pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
|
269 |
+
|
270 |
+
$paged_blogs = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT bm.blog_id FROM {$bp->blogs->table_name_blogmeta} bm LEFT JOIN {$wpdb->base_prefix}blogs wb ON bm.blog_id = wb.blog_id WHERE bm.meta_key = 'name' AND bm.meta_value LIKE '$letter%%' {$hidden_sql} AND wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 ORDER BY bm.meta_value ASC{$pag_sql}" ) );
|
271 |
+
$total_blogs = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT bm.blog_id) FROM {$bp->blogs->table_name_blogmeta} bm LEFT JOIN {$wpdb->base_prefix}blogs wb ON bm.blog_id = wb.blog_id WHERE bm.meta_key = 'name' AND bm.meta_value LIKE '$letter%%' {$hidden_sql} AND wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 ORDER BY bm.meta_value ASC" ) );
|
|
|
272 |
|
273 |
return array( 'blogs' => $paged_blogs, 'total' => $total_blogs );
|
274 |
}
|
275 |
+
|
276 |
+
function get_blog_extras( $paged_blogs, $blog_ids, $type = false ) {
|
277 |
global $bp, $wpdb;
|
278 |
+
|
279 |
+
if ( empty( $blog_ids ) )
|
280 |
+
return $paged_blogs;
|
281 |
+
|
282 |
+
/* Fetch lastest post for each blog. */
|
283 |
+
$post_ids = $wpdb->get_results( $wpdb->prepare( "SELECT p.post_id, p.blog_id FROM {$bp->blogs->table_name_blog_posts} p LEFT JOIN {$wpdb->base_prefix}blogs b ON p.blog_id = b.blog_id WHERE b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND p.blog_id IN ( {$blog_ids} ) GROUP BY p.blog_id ORDER BY p.date_created DESC" ) );
|
284 |
+
|
285 |
+
for ( $i = 0; $i < count( $paged_blogs ); $i++ ) {
|
286 |
+
foreach ( (array)$post_ids as $post ) {
|
287 |
+
if ( $post->blog_id == $paged_blogs[$i]->blog_id ) {
|
288 |
+
$paged_blogs[$i]->latest_post = $wpdb->get_row( "SELECT post_title, guid FROM {$wpdb->base_prefix}" . $post->blog_id . "_posts WHERE post_status = 'publish' AND post_type = 'post' ORDER BY id DESC LIMIT 1" );
|
289 |
+
}
|
290 |
+
}
|
291 |
}
|
|
|
|
|
292 |
|
293 |
+
return $paged_blogs;
|
294 |
}
|
295 |
+
|
296 |
function is_hidden( $blog_id ) {
|
297 |
global $wpdb;
|
298 |
|
299 |
if ( !$bp->blogs )
|
300 |
bp_blogs_setup_globals();
|
301 |
+
|
302 |
if ( !(int)$wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT public FROM {$wpdb->base_prefix}blogs WHERE blog_id = %d", $blog_id ) ) )
|
303 |
return true;
|
304 |
+
|
305 |
return false;
|
306 |
}
|
307 |
}
|
312 |
var $blog_id;
|
313 |
var $post_id;
|
314 |
var $date_created;
|
315 |
+
|
316 |
function bp_blogs_post( $id = null, $blog_id = null, $post_id = null ) {
|
317 |
global $bp, $wpdb;
|
318 |
|
331 |
$post = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->blogs->table_name_blog_posts} WHERE id = %d", $this->id ) );
|
332 |
else
|
333 |
$post = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->blogs->table_name_blog_posts} WHERE blog_id = %d AND post_id = %d", $this->blog_id, $this->post_id ) );
|
334 |
+
|
335 |
+
$this->id = $post->id;
|
336 |
$this->user_id = $post->user_id;
|
337 |
$this->blog_id = $post->blog_id;
|
338 |
$this->post_id = $post->post_id;
|
339 |
$this->date_created = $post->date_created;
|
340 |
}
|
341 |
+
|
342 |
function save() {
|
343 |
global $wpdb, $bp;
|
344 |
+
|
345 |
$this->post_id = apply_filters( 'bp_blogs_post_id_before_save', $this->post_id, $this->id );
|
346 |
$this->blog_id = apply_filters( 'bp_blogs_post_blog_id_before_save', $this->blog_id, $this->id );
|
347 |
$this->user_id = apply_filters( 'bp_blogs_post_user_id_before_save', $this->user_id, $this->id );
|
356 |
// Save
|
357 |
$sql = $wpdb->prepare( "INSERT INTO {$bp->blogs->table_name_blog_posts} ( post_id, blog_id, user_id, date_created ) VALUES ( %d, %d, %d, FROM_UNIXTIME(%d) )", $this->post_id, $this->blog_id, $this->user_id, $this->date_created );
|
358 |
}
|
359 |
+
|
360 |
if ( !$wpdb->query($sql) )
|
361 |
return false;
|
362 |
|
363 |
do_action( 'bp_blogs_post_after_save', $this );
|
364 |
+
|
365 |
if ( $this->id )
|
366 |
return $this->id;
|
367 |
else
|
368 |
+
return $wpdb->insert_id;
|
369 |
}
|
370 |
+
|
371 |
/* Static Functions */
|
372 |
+
|
373 |
function delete( $post_id, $blog_id ) {
|
374 |
global $wpdb, $bp, $current_user;
|
375 |
+
|
376 |
if ( !$bp->blogs )
|
377 |
bp_blogs_setup_globals();
|
378 |
|
379 |
return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blog_posts} WHERE blog_id = %d AND post_id = %d", $blog_id, $post_id ) );
|
380 |
}
|
381 |
+
|
382 |
function delete_oldest( $user_id = null ) {
|
383 |
global $wpdb, $bp;
|
384 |
+
|
385 |
if ( !$bp->blogs )
|
386 |
bp_blogs_setup_globals();
|
387 |
+
|
388 |
if ( !$user_id )
|
389 |
$user_id = $current_user->ID;
|
390 |
+
|
391 |
+
return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blog_posts} WHERE user_id = %d ORDER BY date_created ASC LIMIT 1", $user_id ) );
|
392 |
}
|
393 |
+
|
394 |
function delete_posts_for_user( $user_id = null ) {
|
395 |
global $wpdb, $bp;
|
396 |
+
|
397 |
if ( !$bp->blogs )
|
398 |
bp_blogs_setup_globals();
|
399 |
|
402 |
|
403 |
return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blog_posts} WHERE user_id = %d", $user_id ) );
|
404 |
}
|
405 |
+
|
406 |
function delete_posts_for_blog( $blog_id ) {
|
407 |
global $wpdb, $bp;
|
408 |
+
|
409 |
if ( !$bp->blogs )
|
410 |
bp_blogs_setup_globals();
|
411 |
+
|
412 |
return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blog_posts} WHERE blog_id = %d", $blog_id ) );
|
413 |
}
|
414 |
+
|
415 |
function get_latest_posts( $blog_id = null, $limit = 5 ) {
|
416 |
global $wpdb, $bp;
|
417 |
+
|
418 |
if ( !$bp->blogs )
|
419 |
bp_blogs_setup_globals();
|
420 |
+
|
421 |
if ( $blog_id )
|
422 |
$blog_sql = $wpdb->prepare( " AND p.blog_id = %d", $blog_id );
|
423 |
+
|
424 |
$post_ids = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT p.post_id, p.blog_id FROM {$bp->blogs->table_name_blog_posts} p LEFT JOIN {$wpdb->base_prefix}blogs b ON p.blog_id = b.blog_id WHERE b.public = 1 AND b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 $blog_sql ORDER BY p.date_created DESC LIMIT $limit" ) );
|
425 |
|
426 |
for ( $i = 0; $i < count($post_ids); $i++ ) {
|
427 |
$posts[$i] = BP_Blogs_Post::fetch_post_content($post_ids[$i]);
|
428 |
}
|
429 |
+
|
430 |
return $posts;
|
431 |
}
|
432 |
+
|
433 |
function get_posts_for_user( $user_id = null ) {
|
434 |
global $bp, $wpdb;
|
435 |
+
|
436 |
if ( !$bp->blogs )
|
437 |
bp_blogs_setup_globals();
|
438 |
+
|
439 |
if ( !$user_id )
|
440 |
$user_id = $bp->displayed_user->id;
|
441 |
+
|
442 |
// Show a logged in user their posts on private blogs, but not anyone else.
|
443 |
+
if ( !bp_is_my_profile() ) {
|
444 |
$post_ids = $wpdb->get_results( $wpdb->prepare( "SELECT p.post_id, p.blog_id FROM {$bp->blogs->table_name_blog_posts} p LEFT JOIN {$wpdb->base_prefix}blogs b ON p.blog_id = b.blog_id WHERE b.public = 1 AND b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND p.user_id = %d ORDER BY p.date_created DESC", $user_id) );
|
445 |
$total_post_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(p.post_id) FROM {$bp->blogs->table_name_blog_posts} p LEFT JOIN {$wpdb->base_prefix}blogs b ON p.blog_id = b.blog_id WHERE b.public = 1 AND b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND p.user_id = %d", $user_id) );
|
446 |
} else {
|
447 |
$post_ids = $wpdb->get_results( $wpdb->prepare( "SELECT p.post_id, p.blog_id FROM {$bp->blogs->table_name_blog_posts} p LEFT JOIN {$wpdb->base_prefix}blogs b ON p.blog_id = b.blog_id WHERE b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND p.user_id = %d ORDER BY p.date_created DESC", $user_id) );
|
448 |
+
|
449 |
$total_post_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(p.post_id) FROM {$bp->blogs->table_name_blog_posts} p LEFT JOIN {$wpdb->base_prefix}blogs b ON p.blog_id = b.blog_id WHERE b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND p.user_id = %d", $user_id) );
|
450 |
}
|
451 |
|
455 |
|
456 |
return array( 'posts' => $posts, 'count' => $total_post_count );
|
457 |
}
|
458 |
+
|
459 |
function fetch_post_content( $post_object ) {
|
460 |
// TODO: switch_to_blog() calls are expensive and this needs to be changed.
|
461 |
switch_to_blog( $post_object->blog_id );
|
465 |
|
466 |
return $post;
|
467 |
}
|
468 |
+
|
469 |
function get_total_recorded_for_user( $user_id = null ) {
|
470 |
global $bp, $wpdb;
|
471 |
+
|
472 |
if ( !$bp->blogs )
|
473 |
bp_blogs_setup_globals();
|
474 |
+
|
475 |
if ( !$user_id )
|
476 |
$user_id = $current_user->ID;
|
477 |
|
478 |
return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(post_id) FROM {$bp->blogs->table_name_blog_posts} WHERE user_id = %d", $user_id ) );
|
479 |
}
|
480 |
+
|
481 |
function is_recorded( $post_id, $blog_id, $user_id = null ) {
|
482 |
global $bp, $wpdb, $current_user;
|
483 |
+
|
484 |
if ( !$bp->blogs )
|
485 |
bp_blogs_setup_globals();
|
486 |
+
|
487 |
if ( !$user_id )
|
488 |
$user_id = $current_user->ID;
|
489 |
+
|
490 |
return $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM {$bp->blogs->table_name_blog_posts} WHERE post_id = %d AND blog_id = %d AND user_id = %d", $post_id, $blog_id, $user_id ) );
|
491 |
}
|
492 |
+
|
493 |
function total_post_count( $blog_id ) {
|
494 |
global $bp, $wpdb;
|
495 |
+
|
496 |
if ( !$bp->blogs )
|
497 |
bp_blogs_setup_globals();
|
498 |
+
|
499 |
if ( !$blog_id )
|
500 |
return false;
|
501 |
+
|
502 |
return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(post_id) FROM {$bp->blogs->table_name_blog_posts} WHERE blog_id = %d", $blog_id ) );
|
503 |
}
|
504 |
+
|
505 |
function get_all() {
|
506 |
global $bp, $wpdb;
|
507 |
+
|
508 |
if ( !$bp->blogs )
|
509 |
bp_blogs_setup_globals();
|
510 |
+
|
511 |
return $wpdb->get_col( $wpdb->prepare( "SELECT post_id, blog_id FROM " . $bp->blogs->table_name_blog_posts ) );
|
512 |
}
|
513 |
+
|
514 |
}
|
515 |
|
516 |
Class BP_Blogs_Comment {
|
520 |
var $comment_id;
|
521 |
var $comment_post_id;
|
522 |
var $date_created;
|
523 |
+
|
524 |
function bp_blogs_comment( $id = false, $blog_id = false, $comment_id = false ) {
|
525 |
global $bp, $wpdb;
|
526 |
|
527 |
if ( !$user_id )
|
528 |
$user_id = $bp->displayed_user->id;
|
529 |
+
|
530 |
if ( $id || ( !$id && $blog_id && $comment_id ) ) {
|
531 |
$this->id = $id;
|
532 |
$this->blog_id = $blog_id;
|
537 |
|
538 |
function populate() {
|
539 |
global $wpdb, $bp;
|
540 |
+
|
541 |
if ( $this->id )
|
542 |
$comment = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->blogs->table_name_blog_comments} WHERE id = %d", $this->id ) );
|
543 |
else
|
544 |
$comment = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->blogs->table_name_blog_comments} WHERE blog_id = %d AND comment_id = %d", (int)$this->blog_id, (int)$this->comment_id ) );
|
545 |
+
|
546 |
$this->comment_id = $comment->comment_id;
|
547 |
$this->user_id = $comment->user_id;
|
548 |
$this->blog_id = $comment->blog_id;
|
549 |
$this->comment_post_id = $comment->comment_post_id;
|
550 |
$this->date_created = $comment->date_created;
|
551 |
}
|
552 |
+
|
553 |
function save() {
|
554 |
global $wpdb, $bp;
|
555 |
|
560 |
$this->date_created = apply_filters( 'bp_blogs_comment_date_created_before_save', $this->date_created, $this->id );
|
561 |
|
562 |
do_action( 'bp_blogs_comment_before_save', $this );
|
563 |
+
|
564 |
if ( $this->id ) {
|
565 |
// Update
|
566 |
$sql = $wpdb->prepare( "UPDATE {$bp->blogs->table_name_blog_comments} SET comment_id = %d, comment_post_id = %d, blog_id = %d, user_id = %d, date_created = FROM_UNIXTIME(%d) WHERE id = %d", $this->comment_id, $this->comment_post_id, $this->blog_id, $this->user_id, $this->date_created, $this->id );
|
571 |
|
572 |
if ( !$wpdb->query($sql) )
|
573 |
return false;
|
574 |
+
|
575 |
do_action( 'bp_blogs_comment_after_save', $this );
|
576 |
+
|
577 |
if ( $this->id )
|
578 |
return $this->id;
|
579 |
else
|
580 |
+
return $wpdb->insert_id;
|
581 |
}
|
582 |
|
583 |
/* Static Functions */
|
584 |
+
|
585 |
function delete( $comment_id, $blog_id ) {
|
586 |
global $wpdb, $bp, $current_user;
|
587 |
+
|
588 |
if ( !$bp->blogs )
|
589 |
bp_blogs_setup_globals();
|
590 |
+
|
591 |
return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blog_comments} WHERE comment_id = %d AND blog_id = %d", $comment_id, $blog_id ) );
|
592 |
}
|
593 |
+
|
594 |
function delete_oldest( $user_id = null ) {
|
595 |
global $wpdb, $bp, $current_user;
|
596 |
+
|
597 |
if ( !$bp->blogs )
|
598 |
bp_blogs_setup_globals();
|
599 |
+
|
600 |
if ( !$user_id )
|
601 |
$user_id = $current_user->ID;
|
602 |
+
|
603 |
+
return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blog_comments} WHERE user_id = %d ORDER BY date_created ASC LIMIT 1", $user_id ) );
|
604 |
}
|
605 |
+
|
606 |
function delete_comments_for_user( $user_id = null ) {
|
607 |
global $wpdb, $bp;
|
608 |
+
|
609 |
if ( !$bp->blogs )
|
610 |
bp_blogs_setup_globals();
|
611 |
|
614 |
|
615 |
return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blog_comments} WHERE user_id = %d", $user_id ) );
|
616 |
}
|
617 |
+
|
618 |
function delete_comments_for_blog( $blog_id ) {
|
619 |
global $wpdb, $bp;
|
620 |
+
|
621 |
if ( !$bp->blogs )
|
622 |
bp_blogs_setup_globals();
|
623 |
+
|
624 |
return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blog_comments} WHERE blog_id = %d", $blog_id ) );
|
625 |
}
|
626 |
+
|
627 |
function get_comments_for_user( $user_id = null ) {
|
628 |
global $bp, $wpdb;
|
629 |
+
|
630 |
if ( !$bp->blogs )
|
631 |
bp_blogs_setup_globals();
|
632 |
|
633 |
if ( !$user_id )
|
634 |
$user_id = $bp->displayed_user->id;
|
635 |
+
|
636 |
// Show the logged in user their comments on hidden blogs, but not to anyone else.
|
637 |
+
if ( !bp_is_my_profile() ) {
|
638 |
$comment_ids = $wpdb->get_results( $wpdb->prepare( "SELECT c.comment_id, c.blog_id FROM {$bp->blogs->table_name_blog_comments} c LEFT JOIN {$wpdb->base_prefix}blogs b ON c.blog_id = b.blog_id WHERE b.public = 1 AND b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND c.user_id = %d ORDER BY c.date_created ASC", $user_id) );
|
639 |
$total_comment_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(c.comment_id) FROM {$bp->blogs->table_name_blog_comments} c LEFT JOIN {$wpdb->base_prefix}blogs b ON c.blog_id = b.blog_id WHERE b.public = 1 AND b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND c.user_id = %d", $user_id) );
|
640 |
} else {
|
641 |
$comment_ids = $wpdb->get_results( $wpdb->prepare( "SELECT c.comment_id, c.blog_id FROM {$bp->blogs->table_name_blog_comments} c LEFT JOIN {$wpdb->base_prefix}blogs b ON c.blog_id = b.blog_id WHERE b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND c.user_id = %d ORDER BY c.date_created ASC", $user_id) );
|
642 |
+
|
643 |
$total_comment_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(c.comment_id) FROM {$bp->blogs->table_name_blog_comments} c LEFT JOIN {$wpdb->base_prefix}blogs b ON c.blog_id = b.blog_id WHERE b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND c.user_id = %d", $user_id) );
|
644 |
}
|
645 |
+
|
646 |
+
for ( $i = 0; $i < count($comment_ids); $i++ )
|
647 |
$comments[$i] = BP_Blogs_Comment::fetch_comment_content($comment_ids[$i]);
|
|
|
648 |
|
649 |
return array( 'comments' => $comments, 'count' => $total_comment_count );
|
650 |
}
|
651 |
+
|
652 |
+
function fetch_comment_content( $comment_object ) {
|
653 |
switch_to_blog($comment_object->blog_id);
|
654 |
$comment = get_comment($comment_object->comment_id);
|
655 |
$comment->blog_id = $comment_object->blog_id;
|
656 |
$comment->post = &get_post( $comment->comment_post_ID );
|
657 |
restore_current_blog();
|
658 |
+
|
659 |
return $comment;
|
660 |
}
|
661 |
+
|
662 |
function get_total_recorded_for_user( $user_id = null ) {
|
663 |
global $bp, $wpdb, $current_user;
|
664 |
+
|
665 |
if ( !$bp->blogs )
|
666 |
bp_blogs_setup_globals();
|
667 |
+
|
668 |
if ( !$user_id )
|
669 |
$user_id = $current_user->ID;
|
670 |
|
671 |
return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(comment_id) FROM {$bp->blogs->table_name_blog_comments} WHERE user_id = %d", $user_id ) );
|
672 |
}
|
673 |
+
|
674 |
function total_comment_count( $blog_id, $post_id ) {
|
675 |
global $bp, $wpdb;
|
676 |
+
|
677 |
if ( !$bp->blogs )
|
678 |
bp_blogs_setup_globals();
|
679 |
+
|
680 |
if ( $post_id )
|
681 |
$post_sql = $wpdb->prepare( " AND comment_post_id = %d", $post_id );
|
682 |
|
683 |
return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(comment_id) WHERE blog_id = %d{$post_sql}", $blog_id ) );
|
684 |
}
|
685 |
+
|
686 |
+
|
687 |
function is_recorded( $comment_id, $comment_post_id, $blog_id, $user_id = null ) {
|
688 |
global $bp, $wpdb, $current_user;
|
689 |
+
|
690 |
if ( !$bp->blogs )
|
691 |
bp_blogs_setup_globals();
|
692 |
+
|
693 |
if ( !$user_id )
|
694 |
$user_id = $current_user->ID;
|
695 |
+
|
696 |
return $wpdb->get_var( $wpdb->prepare( "SELECT comment_id FROM {$bp->blogs->table_name_blog_comments} WHERE comment_id = %d AND blog_id = %d AND comment_post_id = %d AND user_id = %d", $comment_id, $blog_id, $comment_post_id, $user_id ) );
|
697 |
}
|
698 |
+
|
699 |
}
|
700 |
|
701 |
?>
|
bp-blogs/bp-blogs-templatetags.php
CHANGED
@@ -1,25 +1,322 @@
|
|
1 |
<?php
|
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
/* Blog registration template tags */
|
4 |
|
5 |
function bp_blog_signup_enabled() {
|
6 |
-
$
|
7 |
-
|
|
|
|
|
8 |
if ( !$active_signup )
|
9 |
$active_signup = 'all';
|
10 |
-
|
11 |
$active_signup = apply_filters( 'wpmu_active_signup', $active_signup ); // return "all", "none", "blog" or "user"
|
12 |
-
|
13 |
if ( 'none' == $active_signup || 'user' == $active_signup )
|
14 |
return false;
|
15 |
-
|
16 |
return true;
|
17 |
}
|
18 |
|
19 |
function bp_show_blog_signup_form($blogname = '', $blog_title = '', $errors = '') {
|
20 |
global $current_user, $current_site;
|
21 |
global $bp;
|
22 |
-
|
23 |
require_once( ABSPATH . WPINC . '/registration.php' );
|
24 |
|
25 |
if ( isset($_POST['submit']) ) {
|
@@ -43,16 +340,16 @@ function bp_show_blog_signup_form($blogname = '', $blog_title = '', $errors = ''
|
|
43 |
|
44 |
<p><?php _e("If you’re not going to use a great blog domain, leave it for a new user. Now have at it!", 'buddypress') ?></p>
|
45 |
|
46 |
-
<form class="standard-form" id="setupform" method="post" action="
|
47 |
|
48 |
<input type="hidden" name="stage" value="gimmeanotherblog" />
|
49 |
<?php do_action( "signup_hidden_fields" ); ?>
|
50 |
-
|
51 |
<?php bp_blogs_signup_blog($blogname, $blog_title, $errors); ?>
|
52 |
<p>
|
53 |
-
<input id="submit" type="submit" name="submit" class="submit" value="<?php _e('Create Blog &
|
54 |
</p>
|
55 |
-
|
56 |
<?php wp_nonce_field( 'bp_blog_signup_form' ) ?>
|
57 |
</form>
|
58 |
<?php
|
@@ -61,7 +358,7 @@ function bp_show_blog_signup_form($blogname = '', $blog_title = '', $errors = ''
|
|
61 |
|
62 |
function bp_blogs_signup_blog( $blogname = '', $blog_title = '', $errors = '' ) {
|
63 |
global $current_site;
|
64 |
-
|
65 |
// Blog name
|
66 |
if( 'no' == constant( "VHOST" ) )
|
67 |
echo '<label for="blogname">' . __('Blog Name:', 'buddypress') . '</label>';
|
@@ -73,9 +370,9 @@ function bp_blogs_signup_blog( $blogname = '', $blog_title = '', $errors = '' )
|
|
73 |
<?php }
|
74 |
|
75 |
if( 'no' == constant( "VHOST" ) ) {
|
76 |
-
echo '<span class="prefix_address">' . $current_site->domain . $current_site->path . '</span
|
77 |
} else {
|
78 |
-
echo '<input name="blogname" type="text" id="blogname" value="'.$blogname.'" maxlength="50"
|
79 |
}
|
80 |
if ( !is_user_logged_in() ) {
|
81 |
print '(<strong>' . __( 'Your address will be ' , 'buddypress');
|
@@ -89,7 +386,7 @@ function bp_blogs_signup_blog( $blogname = '', $blog_title = '', $errors = '' )
|
|
89 |
|
90 |
// Blog Title
|
91 |
?>
|
92 |
-
<label for="blog_title"><?php _e('Blog Title:', 'buddypress') ?></label>
|
93 |
<?php if ( $errmsg = $errors->get_error_message('blog_title') ) { ?>
|
94 |
<p class="error"><?php echo $errmsg ?></p>
|
95 |
<?php }
|
@@ -98,7 +395,7 @@ function bp_blogs_signup_blog( $blogname = '', $blog_title = '', $errors = '' )
|
|
98 |
|
99 |
<p>
|
100 |
<label for="blog_public_on"><?php _e('Privacy:', 'buddypress') ?></label>
|
101 |
-
<?php _e('I would like my blog to appear in search engines like Google and Technorati, and in public listings around this site.', 'buddypress'); ?>
|
102 |
|
103 |
|
104 |
<label class="checkbox" for="blog_public_on">
|
@@ -118,11 +415,11 @@ function bp_blogs_signup_blog( $blogname = '', $blog_title = '', $errors = '' )
|
|
118 |
function bp_blogs_validate_blog_signup() {
|
119 |
global $wpdb, $current_user, $blogname, $blog_title, $errors, $domain, $path;
|
120 |
|
121 |
-
if ( !check_admin_referer( 'bp_blog_signup_form' ) )
|
122 |
return false;
|
123 |
|
124 |
$current_user = wp_get_current_user();
|
125 |
-
|
126 |
if( !is_user_logged_in() )
|
127 |
die();
|
128 |
|
@@ -136,13 +433,13 @@ function bp_blogs_validate_blog_signup() {
|
|
136 |
}
|
137 |
|
138 |
$public = (int) $_POST['blog_public'];
|
139 |
-
|
140 |
$meta = apply_filters( 'signup_create_blog_meta', array( 'lang_id' => 1, 'public' => $public ) ); // depreciated
|
141 |
$meta = apply_filters( 'add_signup_meta', $meta );
|
142 |
-
|
143 |
/* If this is a VHOST install, remove the username from the domain as we are setting this blog
|
144 |
up inside a user domain, not the root domain. */
|
145 |
-
|
146 |
wpmu_create_blog( $domain, $path, $blog_title, $current_user->id, $meta, $wpdb->siteid );
|
147 |
bp_blogs_confirm_blog_signup($domain, $path, $blog_title, $current_user->user_login, $current_user->user_email, $meta);
|
148 |
return true;
|
@@ -168,1156 +465,30 @@ function bp_blogs_confirm_blog_signup( $domain, $path, $blog_title, $user_name,
|
|
168 |
|
169 |
function bp_create_blog_link() {
|
170 |
global $bp;
|
171 |
-
|
172 |
-
if (
|
173 |
echo apply_filters( 'bp_create_blog_link', '<a href="' . $bp->loggedin_user->domain . $bp->blogs->slug . '/create-a-blog">' . __('Create a Blog', 'buddypress') . '</a>' );
|
174 |
}
|
175 |
}
|
176 |
|
177 |
function bp_blogs_blog_tabs() {
|
178 |
global $bp, $groups_template;
|
179 |
-
|
180 |
// Don't show these tabs on a user's own profile
|
181 |
-
if (
|
182 |
return false;
|
183 |
-
|
184 |
$current_tab = $bp->current_action
|
185 |
?>
|
186 |
<ul class="content-header-nav">
|
187 |
<li<?php if ( 'my-blogs' == $current_tab || empty( $current_tab ) ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->blogs->slug ?>/my-blogs"><?php printf( __( "%s's Blogs", 'buddypress' ), $bp->displayed_user->fullname ) ?></a></li>
|
188 |
<li<?php if ( 'recent-posts' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->blogs->slug ?>/recent-posts"><?php printf( __( "%s's Recent Posts", 'buddypress' ), $bp->displayed_user->fullname ) ?></a></li>
|
189 |
-
<li<?php if ( 'recent-comments' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->blogs->slug ?>/recent-comments"><?php printf( __( "%s's Recent Comments", 'buddypress' ), $bp->displayed_user->fullname ) ?></a></li>
|
190 |
</ul>
|
191 |
<?php
|
192 |
do_action( 'bp_blogs_blog_tabs', $current_tab );
|
193 |
}
|
194 |
|
195 |
-
/**********************************************************************
|
196 |
-
* User Blog listing template class
|
197 |
-
*/
|
198 |
-
|
199 |
-
class BP_Blogs_User_Blogs_Template {
|
200 |
-
var $current_blog = -1;
|
201 |
-
var $blog_count;
|
202 |
-
var $blogs;
|
203 |
-
var $blog;
|
204 |
-
|
205 |
-
var $in_the_loop;
|
206 |
-
|
207 |
-
var $pag_page;
|
208 |
-
var $pag_num;
|
209 |
-
var $pag_links;
|
210 |
-
var $total_blog_count;
|
211 |
-
|
212 |
-
function bp_blogs_user_blogs_template( $user_id, $per_page, $max ) {
|
213 |
-
global $bp;
|
214 |
-
|
215 |
-
if ( !$user_id )
|
216 |
-
$user_id = $bp->displayed_user->id;
|
217 |
-
|
218 |
-
$this->pag_page = isset( $_GET['fpage'] ) ? intval( $_GET['fpage'] ) : 1;
|
219 |
-
$this->pag_num = isset( $_GET['num'] ) ? intval( $_GET['num'] ) : $per_page;
|
220 |
-
|
221 |
-
if ( !$this->blogs = wp_cache_get( 'bp_blogs_for_user_' . $user_id, 'bp' ) ) {
|
222 |
-
$this->blogs = bp_blogs_get_blogs_for_user( $user_id );
|
223 |
-
wp_cache_set( 'bp_blogs_for_user_' . $user_id, $this->blogs, 'bp' );
|
224 |
-
}
|
225 |
-
|
226 |
-
if ( !$max || $max >= (int)$this->blogs['count'] )
|
227 |
-
$this->total_blog_count = (int)$this->blogs['count'];
|
228 |
-
else
|
229 |
-
$this->total_blog_count = (int)$max;
|
230 |
-
|
231 |
-
$this->blogs = array_slice( (array)$this->blogs['blogs'], intval( ( $this->pag_page - 1 ) * $this->pag_num), intval( $this->pag_num ) );
|
232 |
-
|
233 |
-
if ( $max ) {
|
234 |
-
if ( $max >= count($this->blogs) )
|
235 |
-
$this->blog_count = count($this->blogs);
|
236 |
-
else
|
237 |
-
$this->blog_count = (int)$max;
|
238 |
-
} else {
|
239 |
-
$this->blog_count = count($this->blogs);
|
240 |
-
}
|
241 |
-
|
242 |
-
$this->pag_links = paginate_links( array(
|
243 |
-
'base' => add_query_arg( 'fpage', '%#%' ),
|
244 |
-
'format' => '',
|
245 |
-
'total' => ceil($this->total_blog_count / $this->pag_num),
|
246 |
-
'current' => $this->pag_page,
|
247 |
-
'prev_text' => '«',
|
248 |
-
'next_text' => '»',
|
249 |
-
'mid_size' => 1
|
250 |
-
));
|
251 |
-
}
|
252 |
-
|
253 |
-
function has_blogs() {
|
254 |
-
if ( $this->blog_count )
|
255 |
-
return true;
|
256 |
-
|
257 |
-
return false;
|
258 |
-
}
|
259 |
-
|
260 |
-
function next_blog() {
|
261 |
-
$this->current_blog++;
|
262 |
-
$this->blog = $this->blogs[$this->current_blog];
|
263 |
-
|
264 |
-
return $this->blog;
|
265 |
-
}
|
266 |
-
|
267 |
-
function rewind_blogs() {
|
268 |
-
$this->current_blog = -1;
|
269 |
-
if ( $this->blog_count > 0 ) {
|
270 |
-
$this->blog = $this->blogs[0];
|
271 |
-
}
|
272 |
-
}
|
273 |
-
|
274 |
-
function user_blogs() {
|
275 |
-
if ( $this->current_blog + 1 < $this->blog_count ) {
|
276 |
-
return true;
|
277 |
-
} elseif ( $this->current_blog + 1 == $this->blog_count ) {
|
278 |
-
do_action('loop_end');
|
279 |
-
// Do some cleaning up after the loop
|
280 |
-
$this->rewind_blogs();
|
281 |
-
}
|
282 |
-
|
283 |
-
$this->in_the_loop = false;
|
284 |
-
return false;
|
285 |
-
}
|
286 |
-
|
287 |
-
function the_blog() {
|
288 |
-
global $blog;
|
289 |
-
|
290 |
-
$this->in_the_loop = true;
|
291 |
-
$blog = $this->next_blog();
|
292 |
-
|
293 |
-
if ( 0 == $this->current_blog ) // loop has just started
|
294 |
-
do_action('loop_start');
|
295 |
-
}
|
296 |
-
}
|
297 |
-
|
298 |
-
function bp_has_blogs( $args = '' ) {
|
299 |
-
global $blogs_template;
|
300 |
-
|
301 |
-
$defaults = array(
|
302 |
-
'user_id' => false,
|
303 |
-
'per_page' => 10,
|
304 |
-
'max' => false
|
305 |
-
);
|
306 |
-
|
307 |
-
$r = wp_parse_args( $args, $defaults );
|
308 |
-
extract( $r, EXTR_SKIP );
|
309 |
-
|
310 |
-
$blogs_template = new BP_Blogs_User_Blogs_Template( $user_id, $per_page, $max );
|
311 |
-
return apply_filters( 'bp_has_blogs', $blogs_template->has_blogs(), &$blogs_template );
|
312 |
-
}
|
313 |
-
|
314 |
-
function bp_blogs() {
|
315 |
-
global $blogs_template;
|
316 |
-
return $blogs_template->user_blogs();
|
317 |
-
}
|
318 |
-
|
319 |
-
function bp_the_blog() {
|
320 |
-
global $blogs_template;
|
321 |
-
return $blogs_template->the_blog();
|
322 |
-
}
|
323 |
-
|
324 |
-
function bp_blogs_pagination_count() {
|
325 |
-
global $bp, $blogs_template;
|
326 |
-
|
327 |
-
$from_num = intval( ( $blogs_template->pag_page - 1 ) * $blogs_template->pag_num ) + 1;
|
328 |
-
$to_num = ( $from_num + ( $blogs_template->pag_num - 1 ) > $blogs_template->total_blog_count ) ? $blogs_template->total_blog_count : $from_num + ( $blogs_template->pag_num - 1 ) ;
|
329 |
-
|
330 |
-
echo sprintf( __( 'Viewing blog %d to %d (of %d blogs)', 'buddypress' ), $from_num, $to_num, $blogs_template->total_blog_count ); ?>
|
331 |
-
<span class="ajax-loader"></span><?php
|
332 |
-
}
|
333 |
-
|
334 |
-
function bp_blogs_pagination_links() {
|
335 |
-
echo bp_get_blogs_pagination_links();
|
336 |
-
}
|
337 |
-
function bp_get_blogs_pagination_links() {
|
338 |
-
global $blogs_template;
|
339 |
-
|
340 |
-
return apply_filters( 'bp_get_blogs_pagination_links', $blogs_template->pag_links );
|
341 |
-
}
|
342 |
-
|
343 |
-
function bp_blog_title() {
|
344 |
-
echo bp_get_blog_title();
|
345 |
-
}
|
346 |
-
function bp_get_blog_title() {
|
347 |
-
global $blogs_template;
|
348 |
-
|
349 |
-
return apply_filters( 'bp_get_blog_title', $blogs_template->blog['title'] );
|
350 |
-
}
|
351 |
-
|
352 |
-
function bp_blog_description() {
|
353 |
-
echo bp_get_blog_description();
|
354 |
-
}
|
355 |
-
function bp_get_blog_description() {
|
356 |
-
global $blogs_template;
|
357 |
-
|
358 |
-
return apply_filters( 'bp_get_blog_description', $blogs_template->blog['description'] );
|
359 |
-
}
|
360 |
-
|
361 |
-
function bp_blog_permalink() {
|
362 |
-
echo bp_get_blog_permalink();
|
363 |
-
}
|
364 |
-
function bp_get_blog_permalink() {
|
365 |
-
global $blogs_template;
|
366 |
-
|
367 |
-
return apply_filters( 'bp_get_blog_permalink', $blogs_template->blog['siteurl'] );
|
368 |
-
}
|
369 |
-
|
370 |
-
|
371 |
-
/**********************************************************************
|
372 |
-
* User Blog Posts listing template class
|
373 |
-
*/
|
374 |
-
|
375 |
-
class BP_Blogs_Blog_Post_Template {
|
376 |
-
var $current_post = -1;
|
377 |
-
var $post_count;
|
378 |
-
var $posts;
|
379 |
-
var $post;
|
380 |
-
|
381 |
-
var $in_the_loop;
|
382 |
-
|
383 |
-
var $pag_page;
|
384 |
-
var $pag_num;
|
385 |
-
var $pag_links;
|
386 |
-
var $total_post_count;
|
387 |
-
|
388 |
-
function bp_blogs_blog_post_template( $user_id, $per_page, $max ) {
|
389 |
-
global $bp;
|
390 |
-
|
391 |
-
if ( !$user_id )
|
392 |
-
$user_id = $bp->displayed_user->id;
|
393 |
-
|
394 |
-
$this->pag_page = isset( $_GET['fpage'] ) ? intval( $_GET['fpage'] ) : 1;
|
395 |
-
$this->pag_num = isset( $_GET['num'] ) ? intval( $_GET['num'] ) : $per_page;
|
396 |
-
|
397 |
-
if ( !$this->posts = wp_cache_get( 'bp_user_posts_' . $user_id, 'bp' ) ) {
|
398 |
-
$this->posts = bp_blogs_get_posts_for_user( $user_id );
|
399 |
-
wp_cache_set( 'bp_user_posts_' . $user_id, $this->posts, 'bp' );
|
400 |
-
}
|
401 |
-
|
402 |
-
if ( !$max || $max >= (int)$this->posts['count'] )
|
403 |
-
$this->total_post_count = (int)$this->posts['count'];
|
404 |
-
else
|
405 |
-
$this->total_post_count = (int)$max;
|
406 |
-
|
407 |
-
$this->posts = array_slice( (array)$this->posts['posts'], intval( ( $this->pag_page - 1 ) * $this->pag_num), intval( $this->pag_num ) );
|
408 |
-
|
409 |
-
if ( $max ) {
|
410 |
-
if ( $max >= count($this->posts) )
|
411 |
-
$this->post_count = count($this->posts);
|
412 |
-
else
|
413 |
-
$this->post_count = (int)$max;
|
414 |
-
} else {
|
415 |
-
$this->post_count = count($this->posts);
|
416 |
-
}
|
417 |
-
|
418 |
-
$this->pag_links = paginate_links( array(
|
419 |
-
'base' => add_query_arg( 'fpage', '%#%' ),
|
420 |
-
'format' => '',
|
421 |
-
'total' => ceil($this->total_post_count / $this->pag_num),
|
422 |
-
'current' => $this->pag_page,
|
423 |
-
'prev_text' => '«',
|
424 |
-
'next_text' => '»',
|
425 |
-
'mid_size' => 1
|
426 |
-
));
|
427 |
-
}
|
428 |
-
|
429 |
-
function has_posts() {
|
430 |
-
if ( $this->post_count )
|
431 |
-
return true;
|
432 |
-
|
433 |
-
return false;
|
434 |
-
}
|
435 |
-
|
436 |
-
function next_post() {
|
437 |
-
$this->current_post++;
|
438 |
-
$this->post = $this->posts[$this->current_post];
|
439 |
-
|
440 |
-
return $this->post;
|
441 |
-
}
|
442 |
-
|
443 |
-
function rewind_posts() {
|
444 |
-
$this->current_post = -1;
|
445 |
-
if ( $this->post_count > 0 ) {
|
446 |
-
$this->post = $this->posts[0];
|
447 |
-
}
|
448 |
-
}
|
449 |
-
|
450 |
-
function user_posts() {
|
451 |
-
if ( $this->current_post + 1 < $this->post_count ) {
|
452 |
-
return true;
|
453 |
-
} elseif ( $this->current_post + 1 == $this->post_count ) {
|
454 |
-
do_action('loop_end');
|
455 |
-
// Do some cleaning up after the loop
|
456 |
-
$this->rewind_posts();
|
457 |
-
}
|
458 |
-
|
459 |
-
$this->in_the_loop = false;
|
460 |
-
return false;
|
461 |
-
}
|
462 |
-
|
463 |
-
function the_post() {
|
464 |
-
global $post;
|
465 |
-
|
466 |
-
$this->in_the_loop = true;
|
467 |
-
$post = $this->next_post();
|
468 |
-
|
469 |
-
if ( 0 == $this->current_post ) // loop has just started
|
470 |
-
do_action('loop_start');
|
471 |
-
}
|
472 |
-
}
|
473 |
-
|
474 |
-
function bp_has_posts( $args = '' ) {
|
475 |
-
global $posts_template;
|
476 |
-
|
477 |
-
$defaults = array(
|
478 |
-
'user_id' => false,
|
479 |
-
'per_page' => 10,
|
480 |
-
'max' => false
|
481 |
-
);
|
482 |
-
|
483 |
-
$r = wp_parse_args( $args, $defaults );
|
484 |
-
extract( $r, EXTR_SKIP );
|
485 |
-
|
486 |
-
$posts_template = new BP_Blogs_Blog_Post_Template( $user_id, $per_page, $max );
|
487 |
-
return apply_filters( 'bp_has_posts', $posts_template->has_posts(), &$posts_template );
|
488 |
-
}
|
489 |
-
|
490 |
-
function bp_posts() {
|
491 |
-
global $posts_template;
|
492 |
-
return $posts_template->user_posts();
|
493 |
-
}
|
494 |
-
|
495 |
-
function bp_the_post() {
|
496 |
-
global $posts_template;
|
497 |
-
return $posts_template->the_post();
|
498 |
-
}
|
499 |
-
|
500 |
-
function bp_post_pagination_count() {
|
501 |
-
global $bp, $posts_template;
|
502 |
-
|
503 |
-
$from_num = intval( ( $posts_template->pag_page - 1 ) * $posts_template->pag_num ) + 1;
|
504 |
-
$to_num = ( $from_num + ( $posts_template->pag_num - 1 ) > $posts_template->total_post_count ) ? $posts_template->total_post_count : $from_num + ( $posts_template->pag_num - 1 ) ;
|
505 |
-
|
506 |
-
echo sprintf( __( 'Viewing post %d to %d (of %d posts)', 'buddypress' ), $from_num, $to_num, $posts_template->total_post_count ); ?>
|
507 |
-
<span class="ajax-loader"></span><?php
|
508 |
-
}
|
509 |
-
|
510 |
-
function bp_post_pagination_links() {
|
511 |
-
echo bp_get_post_pagination_links();
|
512 |
-
}
|
513 |
-
function bp_get_post_pagination_links() {
|
514 |
-
global $posts_template;
|
515 |
-
|
516 |
-
return apply_filters( 'bp_get_post_pagination_links', $posts_template->pag_links );
|
517 |
-
}
|
518 |
-
|
519 |
-
function bp_post_id() {
|
520 |
-
echo bp_get_post_id();
|
521 |
-
}
|
522 |
-
function bp_get_post_id() {
|
523 |
-
global $posts_template;
|
524 |
-
return apply_filters( 'bp_get_post_id', $posts_template->post->ID );
|
525 |
-
}
|
526 |
-
|
527 |
-
function bp_post_title( $deprecated = true ) {
|
528 |
-
if ( !$deprecated )
|
529 |
-
bp_get_post_title();
|
530 |
-
else
|
531 |
-
echo bp_get_post_title();
|
532 |
-
}
|
533 |
-
function bp_get_post_title() {
|
534 |
-
global $posts_template;
|
535 |
-
|
536 |
-
return apply_filters( 'bp_get_post_title', $posts_template->post->post_title );
|
537 |
-
}
|
538 |
-
|
539 |
-
function bp_post_permalink() {
|
540 |
-
global $posts_template;
|
541 |
-
|
542 |
-
echo bp_post_get_permalink();
|
543 |
-
}
|
544 |
-
|
545 |
-
function bp_post_excerpt() {
|
546 |
-
echo bp_get_post_excerpt();
|
547 |
-
}
|
548 |
-
function bp_get_post_excerpt() {
|
549 |
-
global $posts_template;
|
550 |
-
echo apply_filters( 'bp_get_post_excerpt', $posts_template->post->post_excerpt );
|
551 |
-
}
|
552 |
-
|
553 |
-
function bp_post_content() {
|
554 |
-
echo bp_get_post_content();
|
555 |
-
}
|
556 |
-
function bp_get_post_content() {
|
557 |
-
global $posts_template;
|
558 |
-
$content = $posts_template->post->post_content;
|
559 |
-
$content = apply_filters('the_content', $content);
|
560 |
-
$content = str_replace(']]>', ']]>', $content);
|
561 |
-
return apply_filters( 'bp_get_post_content', $content );
|
562 |
-
}
|
563 |
-
|
564 |
-
function bp_post_status() {
|
565 |
-
echo bp_get_post_status();
|
566 |
-
}
|
567 |
-
function bp_get_post_status() {
|
568 |
-
global $posts_template;
|
569 |
-
return apply_filters( 'bp_get_post_status', $posts_template->post->post_status );
|
570 |
-
}
|
571 |
-
|
572 |
-
function bp_post_date( $date_format = null, $deprecated = true ) {
|
573 |
-
if ( !$date_format )
|
574 |
-
$date_format = get_option('date_format');
|
575 |
-
|
576 |
-
if ( !$deprecated )
|
577 |
-
return bp_get_post_date( $date_format );
|
578 |
-
else
|
579 |
-
echo bp_get_post_date();
|
580 |
-
}
|
581 |
-
function bp_get_post_date( $date_format = null ) {
|
582 |
-
global $posts_template;
|
583 |
-
|
584 |
-
if ( !$date_format )
|
585 |
-
$date_format = get_option('date_format');
|
586 |
-
|
587 |
-
echo apply_filters( 'bp_get_post_date', mysql2date( $date_format, $posts_template->post->post_date ) );
|
588 |
-
}
|
589 |
-
|
590 |
-
function bp_post_comment_count() {
|
591 |
-
echo bp_get_post_comment_count();
|
592 |
-
}
|
593 |
-
function bp_get_post_comment_count() {
|
594 |
-
global $posts_template;
|
595 |
-
return apply_filters( 'bp_get_post_comment_count', $posts_template->post->comment_count );
|
596 |
-
}
|
597 |
-
|
598 |
-
function bp_post_comments( $zero = 'No Comments', $one = '1 Comment', $more = '% Comments', $css_class = '', $none = 'Comments Off' ) {
|
599 |
-
global $posts_template, $wpdb;
|
600 |
-
|
601 |
-
$number = (int)$posts_template->post->comment_count;
|
602 |
-
|
603 |
-
if ( 0 == $number && 'closed' == $posts_template->postcomment_status && 'closed' == $posts_template->postping_status ) {
|
604 |
-
echo '<span' . ((!empty($css_class)) ? ' class="' . $css_class . '"' : '') . '>' . $none . '</span>';
|
605 |
-
return;
|
606 |
-
}
|
607 |
-
|
608 |
-
if ( !empty($posts_template->postpost_password) ) { // if there's a password
|
609 |
-
if ( !isset($_COOKIE['wp-postpass_' . COOKIEHASH]) || $_COOKIE['wp-postpass_' . COOKIEHASH] != $posts_template->postpost_password ) { // and it doesn't match the cookie
|
610 |
-
echo __('Enter your password to view comments', 'buddypress');
|
611 |
-
return;
|
612 |
-
}
|
613 |
-
}
|
614 |
-
|
615 |
-
echo '<a href="';
|
616 |
-
|
617 |
-
if ( 0 == $number )
|
618 |
-
echo bp_post_get_permalink() . '#respond';
|
619 |
-
else
|
620 |
-
echo bp_post_get_permalink() . '#comments';
|
621 |
-
echo '"';
|
622 |
-
|
623 |
-
if ( !empty( $css_class ) ) {
|
624 |
-
echo ' class="'.$css_class.'" ';
|
625 |
-
}
|
626 |
-
$title = attribute_escape( $posts_template->post->post_title );
|
627 |
-
|
628 |
-
echo apply_filters( 'comments_popup_link_attributes', '' );
|
629 |
-
|
630 |
-
echo ' title="' . sprintf( __('Comment on %s', 'buddypress'), $title ) . '">';
|
631 |
-
|
632 |
-
if ( 1 == $number )
|
633 |
-
printf( __( '%d Comment', 'buddypress' ), $number );
|
634 |
-
else
|
635 |
-
printf( __( '%d Comments', 'buddypress' ), $number );
|
636 |
-
|
637 |
-
echo '</a>';
|
638 |
-
}
|
639 |
-
|
640 |
-
function bp_post_author( $deprecated = true ) {
|
641 |
-
if ( !$deprecated )
|
642 |
-
return bp_get_post_author();
|
643 |
-
else
|
644 |
-
echo bp_get_post_author();
|
645 |
-
}
|
646 |
-
function bp_get_post_author() {
|
647 |
-
global $posts_template;
|
648 |
-
|
649 |
-
return apply_filters( 'bp_get_post_author', bp_core_get_userlink( $posts_template->post->post_author ) );
|
650 |
-
}
|
651 |
-
|
652 |
-
function bp_post_category( $separator = '', $parents = '', $post_id = false, $deprecated = true ) {
|
653 |
-
global $posts_template;
|
654 |
-
|
655 |
-
if ( !$deprecated )
|
656 |
-
return bp_get_post_category( $separator, $parents, $post_id );
|
657 |
-
else
|
658 |
-
echo bp_get_post_category();
|
659 |
-
}
|
660 |
-
function bp_get_post_category( $separator = '', $parents = '', $post_id = false ) {
|
661 |
-
global $posts_template;
|
662 |
-
|
663 |
-
if ( !$post_id )
|
664 |
-
$post_id = $posts_template->post->ID;
|
665 |
-
|
666 |
-
return apply_filters( 'bp_get_post_category', get_the_category_list( $separator, $parents, $post_id ) );
|
667 |
-
}
|
668 |
-
|
669 |
-
function bp_post_tags( $before = '', $sep = ', ', $after = '' ) {
|
670 |
-
global $posts_template, $wpdb;
|
671 |
-
|
672 |
-
/* Disabling this for now as it's too expensive and there is no global tags directory */
|
673 |
-
return false;
|
674 |
-
|
675 |
-
switch_to_blog( $posts_template->post->blog_id );
|
676 |
-
$terms = bp_post_get_term_list( $before, $sep, $after );
|
677 |
-
restore_current_blog();
|
678 |
-
}
|
679 |
-
|
680 |
-
function bp_post_blog_id() {
|
681 |
-
echo bp_get_post_blog_id();
|
682 |
-
}
|
683 |
-
function bp_get_post_blog_id() {
|
684 |
-
global $posts_template;
|
685 |
-
|
686 |
-
return apply_filters( 'bp_get_post_blog_id', $posts_template->post->blog_id );
|
687 |
-
}
|
688 |
-
|
689 |
-
function bp_post_blog_name() {
|
690 |
-
echo bp_get_post_blog_name();
|
691 |
-
}
|
692 |
-
function bp_get_post_blog_name() {
|
693 |
-
global $posts_template;
|
694 |
-
return apply_filters( 'bp_get_post_blog_name', get_blog_option( $posts_template->post->blog_id, 'blogname' ) );
|
695 |
-
}
|
696 |
-
|
697 |
-
function bp_post_blog_permalink() {
|
698 |
-
echo bp_get_post_blog_permalink();
|
699 |
-
}
|
700 |
-
function bp_get_post_blog_permalink() {
|
701 |
-
global $posts_template;
|
702 |
-
return apply_filters( 'bp_get_post_blog_permalink', get_blog_option( $posts_template->post->blog_id, 'siteurl' ) );
|
703 |
-
}
|
704 |
-
|
705 |
-
function bp_post_get_permalink( $post = null, $blog_id = null ) {
|
706 |
-
global $current_blog, $posts_template;
|
707 |
-
|
708 |
-
if ( !$post )
|
709 |
-
$post = $posts_template->post;
|
710 |
-
|
711 |
-
if ( !$blog_id )
|
712 |
-
$blog_id = $posts_template->post->blog_id;
|
713 |
-
|
714 |
-
if ( !$post || !$blog_id )
|
715 |
-
return false;
|
716 |
-
|
717 |
-
$rewritecode = array(
|
718 |
-
'%year%',
|
719 |
-
'%monthnum%',
|
720 |
-
'%day%',
|
721 |
-
'%hour%',
|
722 |
-
'%minute%',
|
723 |
-
'%second%',
|
724 |
-
$leavename? '' : '%postname%',
|
725 |
-
'%post_id%',
|
726 |
-
'%category%',
|
727 |
-
'%author%',
|
728 |
-
$leavename? '' : '%pagename%',
|
729 |
-
);
|
730 |
-
|
731 |
-
if ( 'page' == $post->post_type )
|
732 |
-
return get_page_link($post->ID, $leavename);
|
733 |
-
else if ( 'attachment' == $post->post_type )
|
734 |
-
return get_attachment_link($post->ID);
|
735 |
-
|
736 |
-
$permalink = get_blog_option( $blog_id, 'permalink_structure' );
|
737 |
-
$site_url = get_blog_option( $blog_id, 'siteurl' );
|
738 |
-
|
739 |
-
if ( '' != $permalink && !in_array($post->post_status, array('draft', 'pending')) ) {
|
740 |
-
$unixtime = strtotime($post->post_date);
|
741 |
-
|
742 |
-
$category = '';
|
743 |
-
if ( false !== strpos($permalink, '%category%') ) {
|
744 |
-
$cats = get_the_category($post->ID);
|
745 |
-
if ( $cats )
|
746 |
-
usort($cats, '_usort_terms_by_ID'); // order by ID
|
747 |
-
$category = $cats[0]->slug;
|
748 |
-
if ( $parent=$cats[0]->parent )
|
749 |
-
$category = get_category_parents($parent, FALSE, '/', TRUE) . $category;
|
750 |
-
|
751 |
-
// show default category in permalinks, without
|
752 |
-
// having to assign it explicitly
|
753 |
-
if ( empty($category) ) {
|
754 |
-
$default_category = get_category( get_option( 'default_category' ) );
|
755 |
-
$category = is_wp_error( $default_category ) ? '' : $default_category->slug;
|
756 |
-
}
|
757 |
-
}
|
758 |
-
|
759 |
-
$author = '';
|
760 |
-
if ( false !== strpos($permalink, '%author%') ) {
|
761 |
-
$authordata = get_userdata($post->post_author);
|
762 |
-
$author = $authordata->user_nicename;
|
763 |
-
}
|
764 |
-
|
765 |
-
$date = explode(" ",date('Y m d H i s', $unixtime));
|
766 |
-
$rewritereplace =
|
767 |
-
array(
|
768 |
-
$date[0],
|
769 |
-
$date[1],
|
770 |
-
$date[2],
|
771 |
-
$date[3],
|
772 |
-
$date[4],
|
773 |
-
$date[5],
|
774 |
-
$post->post_name,
|
775 |
-
$post->ID,
|
776 |
-
$category,
|
777 |
-
$author,
|
778 |
-
$post->post_name,
|
779 |
-
);
|
780 |
-
$permalink = $site_url . str_replace($rewritecode, $rewritereplace, $permalink);
|
781 |
-
$permalink = user_trailingslashit($permalink, 'single');
|
782 |
-
return apply_filters('post_link', $permalink, $post);
|
783 |
-
} else { // if they're not using the fancy permalink option
|
784 |
-
$permalink = $site_url . '/?p=' . $post->ID;
|
785 |
-
return apply_filters('post_link', $permalink, $post);
|
786 |
-
}
|
787 |
-
}
|
788 |
-
|
789 |
-
function bp_post_get_term_list( $before = '', $sep = '', $after = '' ) {
|
790 |
-
global $posts_template;
|
791 |
-
|
792 |
-
$terms = get_the_terms( $posts_template->post->ID, 'post_tag' );
|
793 |
-
|
794 |
-
if ( is_wp_error($terms) )
|
795 |
-
return $terms;
|
796 |
-
|
797 |
-
if ( empty( $terms ) )
|
798 |
-
return false;
|
799 |
-
|
800 |
-
foreach ( $terms as $term ) {
|
801 |
-
$link = get_blog_option( BP_ROOT_BLOG, 'siteurl') . '/tag/' . $term->slug;
|
802 |
-
$link = apply_filters('term_link', $link);
|
803 |
-
|
804 |
-
$term_links[] = '<a href="' . $link . '" rel="tag">' . $term->name . '</a>';
|
805 |
-
}
|
806 |
-
|
807 |
-
$term_links = apply_filters( "term_links-$taxonomy", $term_links );
|
808 |
-
|
809 |
-
echo $before . join($sep, $term_links) . $after;
|
810 |
-
}
|
811 |
-
|
812 |
-
|
813 |
-
/**********************************************************************
|
814 |
-
* User Blog Comments listing template class
|
815 |
-
*/
|
816 |
-
|
817 |
-
class BP_Blogs_Post_Comment_Template {
|
818 |
-
var $current_comment = -1;
|
819 |
-
var $comment_count;
|
820 |
-
var $comments;
|
821 |
-
var $comment;
|
822 |
-
|
823 |
-
var $in_the_loop;
|
824 |
-
|
825 |
-
var $pag_page;
|
826 |
-
var $pag_num;
|
827 |
-
var $pag_links;
|
828 |
-
var $total_comment_count;
|
829 |
-
|
830 |
-
function bp_blogs_post_comment_template( $user_id, $per_page, $max ) {
|
831 |
-
global $bp;
|
832 |
-
|
833 |
-
if ( !$user_id )
|
834 |
-
$user_id = $bp->displayed_user->id;
|
835 |
-
|
836 |
-
$this->pag_page = isset( $_GET['compage'] ) ? intval( $_GET['compage'] ) : 1;
|
837 |
-
$this->pag_num = isset( $_GET['num'] ) ? intval( $_GET['num'] ) : $per_page;
|
838 |
-
|
839 |
-
if ( !$this->comments = wp_cache_get( 'bp_user_comments_' . $user_id, 'bp' ) ) {
|
840 |
-
$this->comments = bp_blogs_get_comments_for_user( $user_id );
|
841 |
-
wp_cache_set( 'bp_user_comments_' . $user_id, $this->comments, 'bp' );
|
842 |
-
}
|
843 |
-
|
844 |
-
if ( !$max || $max >= (int)$this->comments['count'] )
|
845 |
-
$this->total_comment_count = (int)$this->comments['count'];
|
846 |
-
else
|
847 |
-
$this->total_comment_count = (int)$max;
|
848 |
-
|
849 |
-
$this->comments = array_slice( (array)$this->comments['comments'], intval( ( $this->pag_page - 1 ) * $this->pag_num), intval( $this->pag_num ) );
|
850 |
-
|
851 |
-
if ( $max ) {
|
852 |
-
if ( $max >= count($this->comments) )
|
853 |
-
$this->comment_count = count($this->comments);
|
854 |
-
else
|
855 |
-
$this->comment_count = (int)$max;
|
856 |
-
} else {
|
857 |
-
$this->comment_count = count($this->comments);
|
858 |
-
}
|
859 |
-
|
860 |
-
$this->pag_links = paginate_links( array(
|
861 |
-
'base' => add_query_arg( 'compage', '%#%' ),
|
862 |
-
'format' => '',
|
863 |
-
'total' => ceil($this->total_comment_count / $this->pag_num),
|
864 |
-
'current' => $this->pag_page,
|
865 |
-
'prev_text' => '«',
|
866 |
-
'next_text' => '»',
|
867 |
-
'mid_size' => 1
|
868 |
-
));
|
869 |
-
|
870 |
-
}
|
871 |
-
|
872 |
-
function has_comments() {
|
873 |
-
if ( $this->comment_count )
|
874 |
-
return true;
|
875 |
-
|
876 |
-
return false;
|
877 |
-
}
|
878 |
-
|
879 |
-
function next_comment() {
|
880 |
-
$this->current_comment++;
|
881 |
-
$this->comment = $this->comments[$this->current_comment];
|
882 |
-
|
883 |
-
return $this->comment;
|
884 |
-
}
|
885 |
-
|
886 |
-
function rewind_comments() {
|
887 |
-
$this->current_comment = -1;
|
888 |
-
if ( $this->comment_count > 0 ) {
|
889 |
-
$this->comment = $this->comments[0];
|
890 |
-
}
|
891 |
-
}
|
892 |
-
|
893 |
-
function user_comments() {
|
894 |
-
if ( $this->current_comment + 1 < $this->comment_count ) {
|
895 |
-
return true;
|
896 |
-
} elseif ( $this->current_comment + 1 == $this->comment_count ) {
|
897 |
-
do_action('loop_end');
|
898 |
-
// Do some cleaning up after the loop
|
899 |
-
$this->rewind_comments();
|
900 |
-
}
|
901 |
-
|
902 |
-
$this->in_the_loop = false;
|
903 |
-
return false;
|
904 |
-
}
|
905 |
-
|
906 |
-
function the_comment() {
|
907 |
-
global $comment;
|
908 |
-
|
909 |
-
$this->in_the_loop = true;
|
910 |
-
$comment = $this->next_comment();
|
911 |
-
|
912 |
-
if ( 0 == $this->current_comment ) // loop has just started
|
913 |
-
do_action('loop_start');
|
914 |
-
}
|
915 |
-
}
|
916 |
-
|
917 |
-
function bp_has_comments( $args = '' ) {
|
918 |
-
global $comments_template;
|
919 |
-
|
920 |
-
$defaults = array(
|
921 |
-
'user_id' => false,
|
922 |
-
'per_page' => 10,
|
923 |
-
'max' => false
|
924 |
-
);
|
925 |
-
|
926 |
-
$r = wp_parse_args( $args, $defaults );
|
927 |
-
extract( $r, EXTR_SKIP );
|
928 |
-
|
929 |
-
$comments_template = new BP_Blogs_Post_Comment_Template( $user_id, $per_page, $max );
|
930 |
-
return apply_filters( 'bp_has_comments', $comments_template->has_comments(), &$comments_template );
|
931 |
-
}
|
932 |
-
|
933 |
-
function bp_comments() {
|
934 |
-
global $comments_template;
|
935 |
-
return $comments_template->user_comments();
|
936 |
-
}
|
937 |
-
|
938 |
-
function bp_the_comment() {
|
939 |
-
global $comments_template;
|
940 |
-
return $comments_template->the_comment();
|
941 |
-
}
|
942 |
-
|
943 |
-
function bp_comments_pagination() {
|
944 |
-
echo bp_get_comments_pagination();
|
945 |
-
}
|
946 |
-
function bp_get_comments_pagination() {
|
947 |
-
global $comments_template;
|
948 |
-
|
949 |
-
return apply_filters( 'bp_get_comments_pagination', $comments_template->pag_links );
|
950 |
-
}
|
951 |
-
|
952 |
-
function bp_comment_id() {
|
953 |
-
echo bp_get_comment_id();
|
954 |
-
}
|
955 |
-
function bp_get_comment_id() {
|
956 |
-
global $comments_template;
|
957 |
-
echo apply_filters( 'bp_get_comment_id', $comments_template->comment->comment_ID );
|
958 |
-
}
|
959 |
-
|
960 |
-
function bp_comment_post_permalink( $depricated = true ) {
|
961 |
-
if ( !$depricated )
|
962 |
-
return bp_get_comment_post_permalink();
|
963 |
-
else
|
964 |
-
echo bp_get_comment_post_permalink();
|
965 |
-
}
|
966 |
-
function bp_get_comment_post_permalink() {
|
967 |
-
global $comments_template;
|
968 |
-
|
969 |
-
return apply_filters( 'bp_get_comment_post_permalink', bp_post_get_permalink( $comments_template->comment->post, $comments_template->comment->blog_id ) . '#comment-' . $comments_template->comment->comment_ID );
|
970 |
-
}
|
971 |
-
|
972 |
-
function bp_comment_post_title( $deprecated = true ) {
|
973 |
-
if ( !$deprecated )
|
974 |
-
return bp_get_comment_post_title();
|
975 |
-
else
|
976 |
-
echo bp_get_comment_post_title();
|
977 |
-
}
|
978 |
-
function bp_get_comment_post_title( $deprecated = true ) {
|
979 |
-
global $comments_template;
|
980 |
-
|
981 |
-
return apply_filters( 'bp_get_comment_post_title', $comments_template->comment->post->post_title );
|
982 |
-
}
|
983 |
-
|
984 |
-
function bp_comment_author( $deprecated = true ) {
|
985 |
-
global $comments_template;
|
986 |
-
|
987 |
-
if ( !$deprecated )
|
988 |
-
return bp_get_comment_author();
|
989 |
-
else
|
990 |
-
echo bp_get_comment_author();
|
991 |
-
}
|
992 |
-
function bp_get_comment_author() {
|
993 |
-
global $comments_template;
|
994 |
-
|
995 |
-
return apply_filters( 'bp_get_comment_author', bp_core_get_userlink( $comments_template->comment->user_id ) );
|
996 |
-
}
|
997 |
-
|
998 |
-
function bp_comment_content() {
|
999 |
-
echo bp_get_comment_content();
|
1000 |
-
}
|
1001 |
-
function bp_get_comment_content() {
|
1002 |
-
global $comments_template;
|
1003 |
-
$content = $comments_template->comment->comment_content;
|
1004 |
-
$content = apply_filters('the_content', $content);
|
1005 |
-
$content = str_replace(']]>', ']]>', $content);
|
1006 |
-
return apply_filters( 'bp_get_comment_content', $content );
|
1007 |
-
}
|
1008 |
-
|
1009 |
-
function bp_comment_date( $date_format = null, $deprecated = true ) {
|
1010 |
-
if ( !$date_format )
|
1011 |
-
$date_format = get_option('date_format');
|
1012 |
-
|
1013 |
-
if ( !$deprecated )
|
1014 |
-
return bp_get_comment_date( $date_format );
|
1015 |
-
else
|
1016 |
-
echo bp_get_comment_date( $date_format );
|
1017 |
-
}
|
1018 |
-
function bp_get_comment_date( $date_format = null ) {
|
1019 |
-
global $comments_template;
|
1020 |
-
|
1021 |
-
if ( !$date_format )
|
1022 |
-
$date_format = get_option('date_format');
|
1023 |
-
|
1024 |
-
return apply_filters( 'bp_get_comment_date', mysql2date( $date_format, $comments_template->comment->comment_date ) );
|
1025 |
-
}
|
1026 |
-
|
1027 |
-
function bp_comment_blog_permalink( $deprecated = true ) {
|
1028 |
-
if ( !$deprecated )
|
1029 |
-
return bp_get_comment_blog_permalink();
|
1030 |
-
else
|
1031 |
-
echo bp_get_comment_blog_permalink();
|
1032 |
-
}
|
1033 |
-
function bp_get_comment_blog_permalink() {
|
1034 |
-
global $comments_template;
|
1035 |
-
|
1036 |
-
return apply_filters( 'bp_get_comment_blog_permalink', get_blog_option( $comments_template->comment->blog_id, 'siteurl' ) );
|
1037 |
-
}
|
1038 |
-
|
1039 |
-
function bp_comment_blog_name( $deprecated = true ) {
|
1040 |
-
global $comments_template;
|
1041 |
-
|
1042 |
-
if ( !$deprecated )
|
1043 |
-
return bp_get_comment_blog_permalink();
|
1044 |
-
else
|
1045 |
-
echo bp_get_comment_blog_permalink();
|
1046 |
-
}
|
1047 |
-
function bp_get_comment_blog_name( $deprecated = true ) {
|
1048 |
-
global $comments_template;
|
1049 |
-
|
1050 |
-
return apply_filters( 'bp_get_comment_blog_name', get_blog_option( $comments_template->comment->blog_id, 'blogname' ) );
|
1051 |
-
}
|
1052 |
-
|
1053 |
-
/**********************************************************************
|
1054 |
-
* Site Wide Blog listing template class
|
1055 |
-
*/
|
1056 |
-
|
1057 |
-
class BP_Blogs_Site_Blogs_Template {
|
1058 |
-
var $current_blog = -1;
|
1059 |
-
var $blog_count;
|
1060 |
-
var $blogs;
|
1061 |
-
var $blog;
|
1062 |
-
|
1063 |
-
var $in_the_loop;
|
1064 |
-
|
1065 |
-
var $pag_page;
|
1066 |
-
var $pag_num;
|
1067 |
-
var $pag_links;
|
1068 |
-
var $total_blog_count;
|
1069 |
-
|
1070 |
-
function bp_blogs_site_blogs_template( $type, $per_page, $max ) {
|
1071 |
-
global $bp;
|
1072 |
-
|
1073 |
-
$this->pag_page = isset( $_REQUEST['bpage'] ) ? intval( $_REQUEST['bpage'] ) : 1;
|
1074 |
-
$this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
|
1075 |
-
|
1076 |
-
if ( isset( $_REQUEST['s'] ) && '' != $_REQUEST['s'] && $type != 'random' ) {
|
1077 |
-
$this->blogs = BP_Blogs_Blog::search_blogs( $_REQUEST['s'], $this->pag_num, $this->pag_page );
|
1078 |
-
} else if ( isset( $_REQUEST['letter'] ) && '' != $_REQUEST['letter'] ) {
|
1079 |
-
$this->blogs = BP_Blogs_Blog::get_by_letter( $_REQUEST['letter'], $this->pag_num, $this->pag_page );
|
1080 |
-
} else {
|
1081 |
-
switch ( $type ) {
|
1082 |
-
case 'random':
|
1083 |
-
$this->blogs = BP_Blogs_Blog::get_random( $this->pag_num, $this->pag_page );
|
1084 |
-
break;
|
1085 |
-
|
1086 |
-
case 'newest':
|
1087 |
-
$this->blogs = BP_Blogs_Blog::get_newest( $this->pag_num, $this->pag_page );
|
1088 |
-
break;
|
1089 |
-
|
1090 |
-
case 'active': default:
|
1091 |
-
$this->blogs = BP_Blogs_Blog::get_active( $this->pag_num, $this->pag_page );
|
1092 |
-
break;
|
1093 |
-
}
|
1094 |
-
}
|
1095 |
-
|
1096 |
-
if ( !$max || $max >= (int)$this->blogs['total'] )
|
1097 |
-
$this->total_blog_count = (int)$this->blogs['total'];
|
1098 |
-
else
|
1099 |
-
$this->total_blog_count = (int)$max;
|
1100 |
-
|
1101 |
-
$this->blogs = $this->blogs['blogs'];
|
1102 |
-
|
1103 |
-
if ( $max ) {
|
1104 |
-
if ( $max >= count($this->blogs) )
|
1105 |
-
$this->blog_count = count($this->blogs);
|
1106 |
-
else
|
1107 |
-
$this->blog_count = (int)$max;
|
1108 |
-
} else {
|
1109 |
-
$this->blog_count = count($this->blogs);
|
1110 |
-
}
|
1111 |
-
|
1112 |
-
$this->pag_links = paginate_links( array(
|
1113 |
-
'base' => add_query_arg( 'bpage', '%#%' ),
|
1114 |
-
'format' => '',
|
1115 |
-
'total' => ceil( (int) $this->total_blog_count / (int) $this->pag_num ),
|
1116 |
-
'current' => (int) $this->pag_page,
|
1117 |
-
'prev_text' => '«',
|
1118 |
-
'next_text' => '»',
|
1119 |
-
'mid_size' => 1
|
1120 |
-
));
|
1121 |
-
}
|
1122 |
-
|
1123 |
-
function has_blogs() {
|
1124 |
-
if ( $this->blog_count )
|
1125 |
-
return true;
|
1126 |
-
|
1127 |
-
return false;
|
1128 |
-
}
|
1129 |
-
|
1130 |
-
function next_blog() {
|
1131 |
-
$this->current_blog++;
|
1132 |
-
$this->blog = $this->blogs[$this->current_blog];
|
1133 |
-
|
1134 |
-
return $this->blog;
|
1135 |
-
}
|
1136 |
-
|
1137 |
-
function rewind_blogs() {
|
1138 |
-
$this->current_blog = -1;
|
1139 |
-
if ( $this->blog_count > 0 ) {
|
1140 |
-
$this->blog = $this->blogs[0];
|
1141 |
-
}
|
1142 |
-
}
|
1143 |
-
|
1144 |
-
function blogs() {
|
1145 |
-
if ( $this->current_blog + 1 < $this->blog_count ) {
|
1146 |
-
return true;
|
1147 |
-
} elseif ( $this->current_blog + 1 == $this->blog_count ) {
|
1148 |
-
do_action('loop_end');
|
1149 |
-
// Do some cleaning up after the loop
|
1150 |
-
$this->rewind_blogs();
|
1151 |
-
}
|
1152 |
-
|
1153 |
-
$this->in_the_loop = false;
|
1154 |
-
return false;
|
1155 |
-
}
|
1156 |
-
|
1157 |
-
function the_blog() {
|
1158 |
-
global $blog;
|
1159 |
-
|
1160 |
-
$this->in_the_loop = true;
|
1161 |
-
$this->blog = $this->next_blog();
|
1162 |
-
|
1163 |
-
if ( 0 == $this->current_blog ) // loop has just started
|
1164 |
-
do_action('loop_start');
|
1165 |
-
}
|
1166 |
-
}
|
1167 |
-
|
1168 |
-
function bp_rewind_site_blogs() {
|
1169 |
-
global $site_blogs_template;
|
1170 |
-
|
1171 |
-
$site_blogs_template->rewind_blogs();
|
1172 |
-
}
|
1173 |
-
|
1174 |
-
function bp_has_site_blogs( $args = '' ) {
|
1175 |
-
global $site_blogs_template;
|
1176 |
-
|
1177 |
-
$defaults = array(
|
1178 |
-
'type' => 'active',
|
1179 |
-
'per_page' => 10,
|
1180 |
-
'max' => false
|
1181 |
-
);
|
1182 |
-
|
1183 |
-
$r = wp_parse_args( $args, $defaults );
|
1184 |
-
extract( $r, EXTR_SKIP );
|
1185 |
-
|
1186 |
-
// type: active ( default ) | random | newest | popular
|
1187 |
-
|
1188 |
-
if ( $max ) {
|
1189 |
-
if ( $per_page > $max )
|
1190 |
-
$per_page = $max;
|
1191 |
-
}
|
1192 |
-
|
1193 |
-
$site_blogs_template = new BP_Blogs_Site_Blogs_Template( $type, $per_page, $max );
|
1194 |
-
|
1195 |
-
return $site_blogs_template->has_blogs();
|
1196 |
-
}
|
1197 |
-
|
1198 |
-
function bp_site_blogs() {
|
1199 |
-
global $site_blogs_template;
|
1200 |
-
|
1201 |
-
return $site_blogs_template->blogs();
|
1202 |
-
}
|
1203 |
-
|
1204 |
-
function bp_the_site_blog() {
|
1205 |
-
global $site_blogs_template;
|
1206 |
-
|
1207 |
-
return $site_blogs_template->the_blog();
|
1208 |
-
}
|
1209 |
-
|
1210 |
-
function bp_site_blogs_pagination_count() {
|
1211 |
-
global $bp, $site_blogs_template;
|
1212 |
-
|
1213 |
-
$from_num = intval( ( $site_blogs_template->pag_page - 1 ) * $site_blogs_template->pag_num ) + 1;
|
1214 |
-
$to_num = ( $from_num + ( $site_blogs_template->pag_num - 1 ) > $site_blogs_template->total_blog_count ) ? $site_blogs_template->total_blog_count : $from_num + ( $site_blogs_template->pag_num - 1 ) ;
|
1215 |
-
|
1216 |
-
echo sprintf( __( 'Viewing blog %d to %d (of %d blogs)', 'buddypress' ), $from_num, $to_num, $site_blogs_template->total_blog_count ); ?>
|
1217 |
-
<span class="ajax-loader"></span><?php
|
1218 |
-
}
|
1219 |
-
|
1220 |
-
function bp_site_blogs_pagination_links() {
|
1221 |
-
echo bp_get_site_blogs_pagination_links();
|
1222 |
-
}
|
1223 |
-
function bp_get_site_blogs_pagination_links() {
|
1224 |
-
global $site_blogs_template;
|
1225 |
-
|
1226 |
-
return apply_filters( 'bp_get_site_blogs_pagination_links', $site_blogs_template->pag_links );
|
1227 |
-
}
|
1228 |
-
|
1229 |
-
function bp_the_site_blog_avatar() {
|
1230 |
-
echo bp_get_the_site_blog_avatar();
|
1231 |
-
}
|
1232 |
-
function bp_get_the_site_blog_avatar() {
|
1233 |
-
global $site_blogs_template, $bp;
|
1234 |
-
|
1235 |
-
/***
|
1236 |
-
* In future BuddyPress versions you will be able to set the avatar for a blog.
|
1237 |
-
* Right now you can use a filter with the ID of the blog to change it if you wish.
|
1238 |
-
*/
|
1239 |
-
return apply_filters( 'bp_get_blogs_blog_avatar_' . $site_blogs_template->blog->blog_id, '<img src="' . apply_filters( 'bp_gravatar_url', 'http://www.gravatar.com/avatar/' ) . md5( $site_blogs_template->blog->blog_id . '.blogs@' . $bp->root_domain ) . '?d=identicon&s=150" class="avatar blog-avatar" alt="' . __( 'Blog Avatar', 'buddypress' ) . '" />', $site_blogs_template->blog->blog_id );
|
1240 |
-
}
|
1241 |
-
|
1242 |
-
function bp_the_site_blog_avatar_thumb() {
|
1243 |
-
echo bp_get_the_site_blog_avatar_thumb();
|
1244 |
-
}
|
1245 |
-
function bp_get_the_site_blog_avatar_thumb() {
|
1246 |
-
global $site_blogs_template, $bp;
|
1247 |
-
|
1248 |
-
return apply_filters( 'bp_get_blogs_blog_avatar_thumb_' . $site_blogs_template->blog->blog_id, '<img src="' . apply_filters( 'bp_gravatar_url', 'http://www.gravatar.com/avatar/' ) . md5( $site_blogs_template->blog->blog_id . '.blogs@' . $bp->root_domain ) . '?d=identicon&s=50" class="avatar blog-avatar thumb" alt="' . __( 'Blog Avatar', 'buddypress' ) . '" />', $site_blogs_template->blog->blog_id );
|
1249 |
-
}
|
1250 |
-
|
1251 |
-
function bp_the_site_blog_avatar_mini() {
|
1252 |
-
echo bp_get_the_site_blog_avatar_mini();
|
1253 |
-
}
|
1254 |
-
function bp_get_the_site_blog_avatar_mini() {
|
1255 |
-
global $site_blogs_template, $bp;
|
1256 |
-
|
1257 |
-
return apply_filters( 'bp_get_blogs_blog_avatar_mini_' . $site_blogs_template->blog->blog_id, '<img src="' . apply_filters( 'bp_gravatar_url', 'http://www.gravatar.com/avatar/' ) . md5( $site_blogs_template->blog->blog_id . '.blogs@' . $bp->root_domain ) . '?d=identicon&s=25" class="avatar blog-avatar mini" alt="' . __( 'Blog Avatar', 'buddypress' ) . '" />', $site_blogs_template->blog->blog_id );
|
1258 |
-
}
|
1259 |
-
|
1260 |
-
function bp_the_site_blog_link() {
|
1261 |
-
echo bp_get_the_site_blog_link();
|
1262 |
-
}
|
1263 |
-
function bp_get_the_site_blog_link() {
|
1264 |
-
global $site_blogs_template;
|
1265 |
-
|
1266 |
-
return apply_filters( 'bp_get_the_site_blog_link', get_blog_option( $site_blogs_template->blog->blog_id, 'siteurl' ) );
|
1267 |
-
}
|
1268 |
-
|
1269 |
-
function bp_the_site_blog_name() {
|
1270 |
-
echo bp_get_the_site_blog_name();
|
1271 |
-
}
|
1272 |
-
function bp_get_the_site_blog_name() {
|
1273 |
-
global $site_blogs_template;
|
1274 |
-
|
1275 |
-
return apply_filters( 'bp_get_the_site_blog_name', get_blog_option( $site_blogs_template->blog->blog_id, 'blogname' ) );
|
1276 |
-
}
|
1277 |
-
|
1278 |
-
function bp_the_site_blog_description() {
|
1279 |
-
echo apply_filters( 'bp_the_site_blog_description', bp_get_the_site_blog_description() );
|
1280 |
-
}
|
1281 |
-
function bp_get_the_site_blog_description() {
|
1282 |
-
global $site_blogs_template;
|
1283 |
-
|
1284 |
-
return apply_filters( 'bp_get_the_site_blog_description', get_blog_option( $site_blogs_template->blog->blog_id, 'blogdescription' ) );
|
1285 |
-
}
|
1286 |
-
|
1287 |
-
function bp_the_site_blog_last_active() {
|
1288 |
-
echo bp_get_the_site_blog_last_active();
|
1289 |
-
}
|
1290 |
-
function bp_get_the_site_blog_last_active() {
|
1291 |
-
global $site_blogs_template;
|
1292 |
-
|
1293 |
-
return apply_filters( 'bp_the_site_blog_last_active', bp_core_get_last_activity( bp_blogs_get_blogmeta( $site_blogs_template->blog->blog_id, 'last_activity' ), __( 'active %s ago', 'buddypress' ) ) );
|
1294 |
-
}
|
1295 |
-
|
1296 |
-
function bp_the_site_blog_latest_post() {
|
1297 |
-
echo bp_get_the_site_blog_latest_post();
|
1298 |
-
}
|
1299 |
-
function bp_get_the_site_blog_latest_post() {
|
1300 |
-
global $site_blogs_template;
|
1301 |
-
|
1302 |
-
if ( $post = bp_blogs_get_latest_posts( $site_blogs_template->blog->blog_id, 1 ) ) {
|
1303 |
-
return apply_filters( 'bp_get_the_site_blog_latest_post', sprintf( __( 'Latest Post: %s', 'buddypress' ), '<a href="' . bp_post_get_permalink( $post[0], $site_blogs_template->blog->blog_id ) . '">' . apply_filters( 'the_title', $post[0]->post_title ) . '</a>' ) );
|
1304 |
-
}
|
1305 |
-
}
|
1306 |
-
|
1307 |
-
function bp_the_site_blog_hidden_fields() {
|
1308 |
-
if ( isset( $_REQUEST['s'] ) ) {
|
1309 |
-
echo '<input type="hidden" id="search_terms" value="' . attribute_escape( $_REQUEST['s'] ). '" name="search_terms" />';
|
1310 |
-
}
|
1311 |
-
|
1312 |
-
if ( isset( $_REQUEST['letter'] ) ) {
|
1313 |
-
echo '<input type="hidden" id="selected_letter" value="' . attribute_escape( $_REQUEST['letter'] ) . '" name="selected_letter" />';
|
1314 |
-
}
|
1315 |
-
|
1316 |
-
if ( isset( $_REQUEST['blogs_search'] ) ) {
|
1317 |
-
echo '<input type="hidden" id="search_terms" value="' . attribute_escape( $_REQUEST['blogs_search'] ) . '" name="search_terms" />';
|
1318 |
-
}
|
1319 |
-
}
|
1320 |
-
|
1321 |
function bp_directory_blogs_search_form() {
|
1322 |
global $bp; ?>
|
1323 |
<form action="" method="get" id="search-blogs-form">
|
@@ -1327,5 +498,4 @@ function bp_directory_blogs_search_form() {
|
|
1327 |
<?php
|
1328 |
}
|
1329 |
|
1330 |
-
|
1331 |
?>
|
1 |
<?php
|
2 |
|
3 |
+
/**********************************************************************
|
4 |
+
* Blog listing template class.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class BP_Blogs_Template {
|
8 |
+
var $current_blog = -1;
|
9 |
+
var $blog_count;
|
10 |
+
var $blogs;
|
11 |
+
var $blog;
|
12 |
+
|
13 |
+
var $in_the_loop;
|
14 |
+
|
15 |
+
var $pag_page;
|
16 |
+
var $pag_num;
|
17 |
+
var $pag_links;
|
18 |
+
var $total_blog_count;
|
19 |
+
|
20 |
+
function bp_blogs_template( $type, $page, $per_page, $max, $user_id, $search_terms ) {
|
21 |
+
global $bp;
|
22 |
+
|
23 |
+
$this->pag_page = isset( $_REQUEST['bpage'] ) ? intval( $_REQUEST['bpage'] ) : $page;
|
24 |
+
$this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
|
25 |
+
|
26 |
+
if ( isset( $_REQUEST['letter'] ) && '' != $_REQUEST['letter'] )
|
27 |
+
$this->blogs = BP_Blogs_Blog::get_by_letter( $_REQUEST['letter'], $this->pag_num, $this->pag_page );
|
28 |
+
else
|
29 |
+
$this->blogs = bp_blogs_get_blogs( array( 'type' => $type, 'per_page' => $this->pag_num, 'page' => $this->pag_page, 'user_id' => $user_id, 'search_terms' => $search_terms ) );
|
30 |
+
|
31 |
+
if ( !$max || $max >= (int)$this->blogs['total'] )
|
32 |
+
$this->total_blog_count = (int)$this->blogs['total'];
|
33 |
+
else
|
34 |
+
$this->total_blog_count = (int)$max;
|
35 |
+
|
36 |
+
$this->blogs = $this->blogs['blogs'];
|
37 |
+
|
38 |
+
if ( $max ) {
|
39 |
+
if ( $max >= count($this->blogs) )
|
40 |
+
$this->blog_count = count($this->blogs);
|
41 |
+
else
|
42 |
+
$this->blog_count = (int)$max;
|
43 |
+
} else {
|
44 |
+
$this->blog_count = count($this->blogs);
|
45 |
+
}
|
46 |
+
|
47 |
+
$this->pag_links = paginate_links( array(
|
48 |
+
'base' => add_query_arg( 'bpage', '%#%' ),
|
49 |
+
'format' => '',
|
50 |
+
'total' => ceil( (int) $this->total_blog_count / (int) $this->pag_num ),
|
51 |
+
'current' => (int) $this->pag_page,
|
52 |
+
'prev_text' => '←',
|
53 |
+
'next_text' => '→',
|
54 |
+
'mid_size' => 1
|
55 |
+
));
|
56 |
+
}
|
57 |
+
|
58 |
+
function has_blogs() {
|
59 |
+
if ( $this->blog_count )
|
60 |
+
return true;
|
61 |
+
|
62 |
+
return false;
|
63 |
+
}
|
64 |
+
|
65 |
+
function next_blog() {
|
66 |
+
$this->current_blog++;
|
67 |
+
$this->blog = $this->blogs[$this->current_blog];
|
68 |
+
|
69 |
+
return $this->blog;
|
70 |
+
}
|
71 |
+
|
72 |
+
function rewind_blogs() {
|
73 |
+
$this->current_blog = -1;
|
74 |
+
if ( $this->blog_count > 0 ) {
|
75 |
+
$this->blog = $this->blogs[0];
|
76 |
+
}
|
77 |
+
}
|
78 |
+
|
79 |
+
function blogs() {
|
80 |
+
if ( $this->current_blog + 1 < $this->blog_count ) {
|
81 |
+
return true;
|
82 |
+
} elseif ( $this->current_blog + 1 == $this->blog_count ) {
|
83 |
+
do_action('loop_end');
|
84 |
+
// Do some cleaning up after the loop
|
85 |
+
$this->rewind_blogs();
|
86 |
+
}
|
87 |
+
|
88 |
+
$this->in_the_loop = false;
|
89 |
+
return false;
|
90 |
+
}
|
91 |
+
|
92 |
+
function the_blog() {
|
93 |
+
global $blog;
|
94 |
+
|
95 |
+
$this->in_the_loop = true;
|
96 |
+
$this->blog = $this->next_blog();
|
97 |
+
|
98 |
+
if ( 0 == $this->current_blog ) // loop has just started
|
99 |
+
do_action('loop_start');
|
100 |
+
}
|
101 |
+
}
|
102 |
+
|
103 |
+
function bp_rewind_blogs() {
|
104 |
+
global $blogs_template;
|
105 |
+
|
106 |
+
$blogs_template->rewind_blogs();
|
107 |
+
}
|
108 |
+
|
109 |
+
function bp_has_blogs( $args = '' ) {
|
110 |
+
global $bp, $blogs_template;
|
111 |
+
|
112 |
+
/***
|
113 |
+
* Set the defaults based on the current page. Any of these will be overridden
|
114 |
+
* if arguments are directly passed into the loop. Custom plugins should always
|
115 |
+
* pass their parameters directly to the loop.
|
116 |
+
*/
|
117 |
+
$type = 'active';
|
118 |
+
$user_id = false;
|
119 |
+
$search_terms = false;
|
120 |
+
|
121 |
+
/* User filtering */
|
122 |
+
if ( !empty( $bp->displayed_user->id ) )
|
123 |
+
$user_id = $bp->displayed_user->id;
|
124 |
+
|
125 |
+
if ( !empty( $_REQUEST['s'] ) )
|
126 |
+
$search_terms = $_REQUEST['s'];
|
127 |
+
|
128 |
+
$defaults = array(
|
129 |
+
'type' => $type,
|
130 |
+
'page' => 1,
|
131 |
+
'per_page' => 20,
|
132 |
+
'max' => false,
|
133 |
+
|
134 |
+
'user_id' => $user_id, // Pass a user_id to limit to only blogs this user has higher than subscriber access to
|
135 |
+
'search_terms' => $search_terms // Pass search terms to filter on the blog title or description.
|
136 |
+
);
|
137 |
+
|
138 |
+
$r = wp_parse_args( $args, $defaults );
|
139 |
+
extract( $r );
|
140 |
+
|
141 |
+
if ( $max ) {
|
142 |
+
if ( $per_page > $max )
|
143 |
+
$per_page = $max;
|
144 |
+
}
|
145 |
+
|
146 |
+
$blogs_template = new BP_Blogs_Template( $type, $page, $per_page, $max, $user_id, $search_terms );
|
147 |
+
return $blogs_template->has_blogs();
|
148 |
+
}
|
149 |
+
|
150 |
+
function bp_blogs() {
|
151 |
+
global $blogs_template;
|
152 |
+
|
153 |
+
return $blogs_template->blogs();
|
154 |
+
}
|
155 |
+
|
156 |
+
function bp_the_blog() {
|
157 |
+
global $blogs_template;
|
158 |
+
|
159 |
+
return $blogs_template->the_blog();
|
160 |
+
}
|
161 |
+
|
162 |
+
function bp_blogs_pagination_count() {
|
163 |
+
global $bp, $blogs_template;
|
164 |
+
|
165 |
+
$from_num = bp_core_number_format( intval( ( $blogs_template->pag_page - 1 ) * $blogs_template->pag_num ) + 1 );
|
166 |
+
$to_num = bp_core_number_format( ( $from_num + ( $blogs_template->pag_num - 1 ) > $blogs_template->total_blog_count ) ? $blogs_template->total_blog_count : $from_num + ( $blogs_template->pag_num - 1 ) );
|
167 |
+
$total = bp_core_number_format( $blogs_template->total_blog_count );
|
168 |
+
|
169 |
+
echo sprintf( __( 'Viewing blog %s to %s (of %s blogs)', 'buddypress' ), $from_num, $to_num, $total ); ?>
|
170 |
+
<span class="ajax-loader"></span><?php
|
171 |
+
}
|
172 |
+
|
173 |
+
function bp_blogs_pagination_links() {
|
174 |
+
echo bp_get_blogs_pagination_links();
|
175 |
+
}
|
176 |
+
function bp_get_blogs_pagination_links() {
|
177 |
+
global $blogs_template;
|
178 |
+
|
179 |
+
return apply_filters( 'bp_get_blogs_pagination_links', $blogs_template->pag_links );
|
180 |
+
}
|
181 |
+
|
182 |
+
function bp_blog_avatar( $args = '' ) {
|
183 |
+
echo bp_get_blog_avatar( $args );
|
184 |
+
}
|
185 |
+
function bp_get_blog_avatar( $args = '' ) {
|
186 |
+
global $blogs_template, $bp;
|
187 |
+
|
188 |
+
$defaults = array(
|
189 |
+
'type' => 'full',
|
190 |
+
'width' => false,
|
191 |
+
'height' => false,
|
192 |
+
'class' => 'avatar',
|
193 |
+
'id' => false,
|
194 |
+
'alt' => __( 'Blog avatar', 'buddypress' ),
|
195 |
+
'no_grav' => true
|
196 |
+
);
|
197 |
+
|
198 |
+
$r = wp_parse_args( $args, $defaults );
|
199 |
+
extract( $r, EXTR_SKIP );
|
200 |
+
|
201 |
+
/***
|
202 |
+
* In future BuddyPress versions you will be able to set the avatar for a blog.
|
203 |
+
* Right now you can use a filter with the ID of the blog to change it if you wish.
|
204 |
+
* By default it will return the avatar for the primary blog admin.
|
205 |
+
*/
|
206 |
+
return apply_filters( 'bp_get_blog_avatar_' . $blogs_template->blog->blog_id, bp_core_fetch_avatar( array( 'item_id' => $blogs_template->blog->admin_user_id, 'type' => $type, 'alt' => $alt, 'width' => $width, 'height' => $height, 'class' => $class, 'email' => $blogs_template->blog->admin_user_email ) ) );
|
207 |
+
}
|
208 |
+
|
209 |
+
function bp_blog_permalink() {
|
210 |
+
echo bp_get_blog_permalink();
|
211 |
+
}
|
212 |
+
function bp_get_blog_permalink() {
|
213 |
+
global $blogs_template;
|
214 |
+
|
215 |
+
if ( empty( $blogs_template->blog->domain ) )
|
216 |
+
$permalink = $bp->root_domain . $blogs_template->blog->path;
|
217 |
+
else {
|
218 |
+
$protocol = 'http://';
|
219 |
+
if ( is_ssl() )
|
220 |
+
$protocol = 'https://';
|
221 |
+
|
222 |
+
$permalink = $protocol . $blogs_template->blog->domain . $blogs_template->blog->path;
|
223 |
+
}
|
224 |
+
|
225 |
+
return apply_filters( 'bp_get_blog_permalink', $permalink );
|
226 |
+
}
|
227 |
+
|
228 |
+
function bp_blog_name() {
|
229 |
+
echo bp_get_blog_name();
|
230 |
+
}
|
231 |
+
function bp_get_blog_name() {
|
232 |
+
global $blogs_template;
|
233 |
+
|
234 |
+
return apply_filters( 'bp_get_blog_name', $blogs_template->blog->name );
|
235 |
+
}
|
236 |
+
|
237 |
+
function bp_blog_description() {
|
238 |
+
echo apply_filters( 'bp_blog_description', bp_get_blog_description() );
|
239 |
+
}
|
240 |
+
function bp_get_blog_description() {
|
241 |
+
global $blogs_template;
|
242 |
+
|
243 |
+
return apply_filters( 'bp_get_blog_description', $blogs_template->blog->description );
|
244 |
+
}
|
245 |
+
|
246 |
+
function bp_blog_last_active() {
|
247 |
+
echo bp_get_blog_last_active();
|
248 |
+
}
|
249 |
+
function bp_get_blog_last_active() {
|
250 |
+
global $blogs_template;
|
251 |
+
|
252 |
+
return apply_filters( 'bp_blog_last_active', bp_core_get_last_activity( $blogs_template->blog->last_activity, __( 'active %s ago', 'buddypress' ) ) );
|
253 |
+
}
|
254 |
+
|
255 |
+
function bp_blog_latest_post() {
|
256 |
+
echo bp_get_blog_latest_post();
|
257 |
+
}
|
258 |
+
function bp_get_blog_latest_post() {
|
259 |
+
global $blogs_template;
|
260 |
+
|
261 |
+
if ( null == $blogs_template->blog->latest_post )
|
262 |
+
return false;
|
263 |
+
|
264 |
+
return apply_filters( 'bp_get_blog_latest_post', sprintf( __( 'Latest Post: %s', 'buddypress' ), '<a href="' . $blogs_template->blog->latest_post->guid . '">' . apply_filters( 'the_title', $blogs_template->blog->latest_post->post_title ) . '</a>' ) );
|
265 |
+
}
|
266 |
+
|
267 |
+
function bp_blog_hidden_fields() {
|
268 |
+
if ( isset( $_REQUEST['s'] ) ) {
|
269 |
+
echo '<input type="hidden" id="search_terms" value="' . attribute_escape( $_REQUEST['s'] ). '" name="search_terms" />';
|
270 |
+
}
|
271 |
+
|
272 |
+
if ( isset( $_REQUEST['letter'] ) ) {
|
273 |
+
echo '<input type="hidden" id="selected_letter" value="' . attribute_escape( $_REQUEST['letter'] ) . '" name="selected_letter" />';
|
274 |
+
}
|
275 |
+
|
276 |
+
if ( isset( $_REQUEST['blogs_search'] ) ) {
|
277 |
+
echo '<input type="hidden" id="search_terms" value="' . attribute_escape( $_REQUEST['blogs_search'] ) . '" name="search_terms" />';
|
278 |
+
}
|
279 |
+
}
|
280 |
+
|
281 |
+
function bp_total_blog_count() {
|
282 |
+
echo bp_get_total_blog_count();
|
283 |
+
}
|
284 |
+
function bp_get_total_blog_count() {
|
285 |
+
return apply_filters( 'bp_get_total_blog_count', bp_blogs_total_blogs() );
|
286 |
+
}
|
287 |
+
add_filter( 'bp_get_total_blog_count', 'bp_core_number_format' );
|
288 |
+
|
289 |
+
function bp_total_blog_count_for_user( $user_id = false ) {
|
290 |
+
echo bp_get_total_blog_count_for_user( $user_id );
|
291 |
+
}
|
292 |
+
function bp_get_total_blog_count_for_user( $user_id = false ) {
|
293 |
+
return apply_filters( 'bp_get_total_blog_count_for_user', bp_blogs_total_blogs_for_user( $user_id ) );
|
294 |
+
}
|
295 |
+
add_filter( 'bp_get_total_blog_count_for_user', 'bp_core_number_format' );
|
296 |
+
|
297 |
+
|
298 |
/* Blog registration template tags */
|
299 |
|
300 |
function bp_blog_signup_enabled() {
|
301 |
+
global $bp;
|
302 |
+
|
303 |
+
$active_signup = $bp->site_options['registration'];
|
304 |
+
|
305 |
if ( !$active_signup )
|
306 |
$active_signup = 'all';
|
307 |
+
|
308 |
$active_signup = apply_filters( 'wpmu_active_signup', $active_signup ); // return "all", "none", "blog" or "user"
|
309 |
+
|
310 |
if ( 'none' == $active_signup || 'user' == $active_signup )
|
311 |
return false;
|
312 |
+
|
313 |
return true;
|
314 |
}
|
315 |
|
316 |
function bp_show_blog_signup_form($blogname = '', $blog_title = '', $errors = '') {
|
317 |
global $current_user, $current_site;
|
318 |
global $bp;
|
319 |
+
|
320 |
require_once( ABSPATH . WPINC . '/registration.php' );
|
321 |
|
322 |
if ( isset($_POST['submit']) ) {
|
340 |
|
341 |
<p><?php _e("If you’re not going to use a great blog domain, leave it for a new user. Now have at it!", 'buddypress') ?></p>
|
342 |
|
343 |
+
<form class="standard-form" id="setupform" method="post" action="">
|
344 |
|
345 |
<input type="hidden" name="stage" value="gimmeanotherblog" />
|
346 |
<?php do_action( "signup_hidden_fields" ); ?>
|
347 |
+
|
348 |
<?php bp_blogs_signup_blog($blogname, $blog_title, $errors); ?>
|
349 |
<p>
|
350 |
+
<input id="submit" type="submit" name="submit" class="submit" value="<?php _e('Create Blog →', 'buddypress') ?>" />
|
351 |
</p>
|
352 |
+
|
353 |
<?php wp_nonce_field( 'bp_blog_signup_form' ) ?>
|
354 |
</form>
|
355 |
<?php
|
358 |
|
359 |
function bp_blogs_signup_blog( $blogname = '', $blog_title = '', $errors = '' ) {
|
360 |
global $current_site;
|
361 |
+
|
362 |
// Blog name
|
363 |
if( 'no' == constant( "VHOST" ) )
|
364 |
echo '<label for="blogname">' . __('Blog Name:', 'buddypress') . '</label>';
|
370 |
<?php }
|
371 |
|
372 |
if( 'no' == constant( "VHOST" ) ) {
|
373 |
+
echo '<span class="prefix_address">' . $current_site->domain . $current_site->path . '</span> <input name="blogname" type="text" id="blogname" value="'.$blogname.'" maxlength="50" /><br />';
|
374 |
} else {
|
375 |
+
echo '<input name="blogname" type="text" id="blogname" value="'.$blogname.'" maxlength="50" /> <span class="suffix_address">.' . $current_site->domain . $current_site->path . '</span><br />';
|
376 |
}
|
377 |
if ( !is_user_logged_in() ) {
|
378 |
print '(<strong>' . __( 'Your address will be ' , 'buddypress');
|
386 |
|
387 |
// Blog Title
|
388 |
?>
|
389 |
+
<label for="blog_title"><?php _e('Blog Title:', 'buddypress') ?></label>
|
390 |
<?php if ( $errmsg = $errors->get_error_message('blog_title') ) { ?>
|
391 |
<p class="error"><?php echo $errmsg ?></p>
|
392 |
<?php }
|
395 |
|
396 |
<p>
|
397 |
<label for="blog_public_on"><?php _e('Privacy:', 'buddypress') ?></label>
|
398 |
+
<?php _e('I would like my blog to appear in search engines like Google and Technorati, and in public listings around this site.', 'buddypress'); ?>
|
399 |
|
400 |
|
401 |
<label class="checkbox" for="blog_public_on">
|
415 |
function bp_blogs_validate_blog_signup() {
|
416 |
global $wpdb, $current_user, $blogname, $blog_title, $errors, $domain, $path;
|
417 |
|
418 |
+
if ( !check_admin_referer( 'bp_blog_signup_form' ) )
|
419 |
return false;
|
420 |
|
421 |
$current_user = wp_get_current_user();
|
422 |
+
|
423 |
if( !is_user_logged_in() )
|
424 |
die();
|
425 |
|
433 |
}
|
434 |
|
435 |
$public = (int) $_POST['blog_public'];
|
436 |
+
|
437 |
$meta = apply_filters( 'signup_create_blog_meta', array( 'lang_id' => 1, 'public' => $public ) ); // depreciated
|
438 |
$meta = apply_filters( 'add_signup_meta', $meta );
|
439 |
+
|
440 |
/* If this is a VHOST install, remove the username from the domain as we are setting this blog
|
441 |
up inside a user domain, not the root domain. */
|
442 |
+
|
443 |
wpmu_create_blog( $domain, $path, $blog_title, $current_user->id, $meta, $wpdb->siteid );
|
444 |
bp_blogs_confirm_blog_signup($domain, $path, $blog_title, $current_user->user_login, $current_user->user_email, $meta);
|
445 |
return true;
|
465 |
|
466 |
function bp_create_blog_link() {
|
467 |
global $bp;
|
468 |
+
|
469 |
+
if ( bp_is_my_profile() ) {
|
470 |
echo apply_filters( 'bp_create_blog_link', '<a href="' . $bp->loggedin_user->domain . $bp->blogs->slug . '/create-a-blog">' . __('Create a Blog', 'buddypress') . '</a>' );
|
471 |
}
|
472 |
}
|
473 |
|
474 |
function bp_blogs_blog_tabs() {
|
475 |
global $bp, $groups_template;
|
476 |
+
|
477 |
// Don't show these tabs on a user's own profile
|
478 |
+
if ( bp_is_my_profile() )
|
479 |
return false;
|
480 |
+
|
481 |
$current_tab = $bp->current_action
|
482 |
?>
|
483 |
<ul class="content-header-nav">
|
484 |
<li<?php if ( 'my-blogs' == $current_tab || empty( $current_tab ) ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->blogs->slug ?>/my-blogs"><?php printf( __( "%s's Blogs", 'buddypress' ), $bp->displayed_user->fullname ) ?></a></li>
|
485 |
<li<?php if ( 'recent-posts' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->blogs->slug ?>/recent-posts"><?php printf( __( "%s's Recent Posts", 'buddypress' ), $bp->displayed_user->fullname ) ?></a></li>
|
486 |
+
<li<?php if ( 'recent-comments' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->blogs->slug ?>/recent-comments"><?php printf( __( "%s's Recent Comments", 'buddypress' ), $bp->displayed_user->fullname ) ?></a></li>
|
487 |
</ul>
|
488 |
<?php
|
489 |
do_action( 'bp_blogs_blog_tabs', $current_tab );
|
490 |
}
|
491 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
492 |
function bp_directory_blogs_search_form() {
|
493 |
global $bp; ?>
|
494 |
<form action="" method="get" id="search-blogs-form">
|
498 |
<?php
|
499 |
}
|
500 |
|
|
|
501 |
?>
|
bp-blogs/bp-blogs-widgets.php
CHANGED
@@ -1,10 +1,17 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
4 |
function bp_blogs_register_widgets() {
|
5 |
-
|
|
|
|
|
|
|
6 |
}
|
7 |
-
add_action( '
|
8 |
|
9 |
class BP_Blogs_Recent_Posts_Widget extends WP_Widget {
|
10 |
function bp_blogs_recent_posts_widget() {
|
@@ -13,49 +20,50 @@ class BP_Blogs_Recent_Posts_Widget extends WP_Widget {
|
|
13 |
|
14 |
function widget($args, $instance) {
|
15 |
global $bp;
|
16 |
-
|
17 |
extract( $args );
|
18 |
-
|
19 |
echo $before_widget;
|
20 |
echo $before_title
|
21 |
-
. $widget_name
|
22 |
. $after_title; ?>
|
23 |
-
|
24 |
<?php
|
25 |
if ( empty( $instance['max_posts'] ) || !$instance['max_posts'] )
|
26 |
$instance['max_posts'] = 10; ?>
|
27 |
-
|
28 |
-
<?php
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
</div>
|
35 |
-
<ul id="recent-posts" class="item-list">
|
36 |
-
<?php foreach ( $posts as $post ) : ?>
|
37 |
<li>
|
38 |
-
<div class="
|
39 |
-
<a href="<?php echo bp_post_get_permalink( $post, $post->blog_id ) ?>" title="<?php echo apply_filters( 'the_title', $post->post_title ) ?>"><?php echo bp_core_fetch_avatar( array( 'item_id' => $post->post_author, 'type' => 'thumb' ) ) ?></a>
|
40 |
-
</div>
|
41 |
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
|
|
|
|
|
|
|
|
46 |
<?php endif; ?>
|
47 |
-
|
48 |
</div>
|
49 |
</li>
|
50 |
-
|
51 |
-
<?php
|
|
|
52 |
</ul>
|
53 |
-
|
54 |
-
|
55 |
-
|
|
|
56 |
</div>
|
57 |
<?php endif; ?>
|
58 |
-
|
59 |
<?php echo $after_widget; ?>
|
60 |
<?php
|
61 |
}
|
1 |
<?php
|
2 |
|
3 |
+
/***
|
4 |
+
* The recent blogs widget is actually just the activity feed filtered on "new_blog_post".
|
5 |
+
* Why not make some of your own widgets using a filtered activity stream?
|
6 |
+
*/
|
7 |
+
|
8 |
function bp_blogs_register_widgets() {
|
9 |
+
global $current_blog, $bp;
|
10 |
+
|
11 |
+
if ( bp_is_active( 'activity' ) && (int)$current_blog->blog_id == BP_ROOT_BLOG )
|
12 |
+
add_action('widgets_init', create_function('', 'return register_widget("BP_Blogs_Recent_Posts_Widget");') );
|
13 |
}
|
14 |
+
add_action( 'bp_register_widgets', 'bp_blogs_register_widgets' );
|
15 |
|
16 |
class BP_Blogs_Recent_Posts_Widget extends WP_Widget {
|
17 |
function bp_blogs_recent_posts_widget() {
|
20 |
|
21 |
function widget($args, $instance) {
|
22 |
global $bp;
|
23 |
+
|
24 |
extract( $args );
|
25 |
+
|
26 |
echo $before_widget;
|
27 |
echo $before_title
|
28 |
+
. $widget_name
|
29 |
. $after_title; ?>
|
30 |
+
|
31 |
<?php
|
32 |
if ( empty( $instance['max_posts'] ) || !$instance['max_posts'] )
|
33 |
$instance['max_posts'] = 10; ?>
|
34 |
+
|
35 |
+
<?php if ( bp_has_activities( 'action=new_blog_post&max=' . $instance['max_posts'] . '&per_page=' . $instance['max_posts'] ) ) : ?>
|
36 |
+
|
37 |
+
<ul id="blog-post-list" class="activity-list item-list">
|
38 |
+
|
39 |
+
<?php while ( bp_activities() ) : bp_the_activity(); ?>
|
40 |
+
|
|
|
|
|
|
|
41 |
<li>
|
42 |
+
<div class="activity-content" style="margin: 0">
|
|
|
|
|
43 |
|
44 |
+
<div class="activity-header">
|
45 |
+
<?php bp_activity_action() ?>
|
46 |
+
</div>
|
47 |
+
|
48 |
+
<?php if ( bp_get_activity_content_body() ) : ?>
|
49 |
+
<div class="activity-inner">
|
50 |
+
<?php bp_activity_content_body() ?>
|
51 |
+
</div>
|
52 |
<?php endif; ?>
|
53 |
+
|
54 |
</div>
|
55 |
</li>
|
56 |
+
|
57 |
+
<?php endwhile; ?>
|
58 |
+
|
59 |
</ul>
|
60 |
+
|
61 |
+
<?php else : ?>
|
62 |
+
<div id="message" class="info">
|
63 |
+
<p><?php _e( 'Sorry, there were no blog posts found. Why not write one?', 'buddypress' ) ?></p>
|
64 |
</div>
|
65 |
<?php endif; ?>
|
66 |
+
|
67 |
<?php echo $after_widget; ?>
|
68 |
<?php
|
69 |
}
|
bp-blogs/deprecated/bp-blogs-deprecated.php
DELETED
@@ -1,105 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/***
|
3 |
-
* Deprecated Blogs Functionality
|
4 |
-
*
|
5 |
-
* This file contains functions that are deprecated.
|
6 |
-
* You should not under any circumstance use these functions as they are
|
7 |
-
* either no longer valid, or have been replaced with something much more awesome.
|
8 |
-
*
|
9 |
-
* If you are using functions in this file you should slap the back of your head
|
10 |
-
* and then use the functions or solutions that have replaced them.
|
11 |
-
* Most functions contain a note telling you what you should be doing or using instead.
|
12 |
-
*
|
13 |
-
* Of course, things will still work if you use these functions but you will
|
14 |
-
* be the laughing stock of the BuddyPress community. We will all point and laugh at
|
15 |
-
* you. You'll also be making things harder for yourself in the long run,
|
16 |
-
* and you will miss out on lovely performance and functionality improvements.
|
17 |
-
*
|
18 |
-
* If you've checked you are not using any deprecated functions and finished your little
|
19 |
-
* dance, you can add the following line to your wp-config.php file to prevent any of
|
20 |
-
* these old functions from being loaded:
|
21 |
-
*
|
22 |
-
* define( 'BP_IGNORE_DEPRECATED', true );
|
23 |
-
*/
|
24 |
-
|
25 |
-
function bp_blogs_force_buddypress_theme( $template ) {
|
26 |
-
global $bp;
|
27 |
-
|
28 |
-
/* If we are using a BuddyPress 1.1+ theme ignore this. */
|
29 |
-
if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
|
30 |
-
return $template;
|
31 |
-
|
32 |
-
if ( $bp->current_component == $bp->blogs->slug && empty( $bp->current_action ) ) {
|
33 |
-
$member_theme = get_site_option( 'active-member-theme' );
|
34 |
-
|
35 |
-
if ( empty( $member_theme ) )
|
36 |
-
$member_theme = 'bpmember';
|
37 |
-
|
38 |
-
add_filter( 'theme_root', 'bp_core_filter_buddypress_theme_root' );
|
39 |
-
add_filter( 'theme_root_uri', 'bp_core_filter_buddypress_theme_root_uri' );
|
40 |
-
|
41 |
-
return $member_theme;
|
42 |
-
} else {
|
43 |
-
return $template;
|
44 |
-
}
|
45 |
-
}
|
46 |
-
add_filter( 'template', 'bp_blogs_force_buddypress_theme' );
|
47 |
-
|
48 |
-
function bp_blogs_force_buddypress_stylesheet( $stylesheet ) {
|
49 |
-
global $bp;
|
50 |
-
|
51 |
-
/* If we are using a BuddyPress 1.1+ theme ignore this. */
|
52 |
-
if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
|
53 |
-
return $stylesheet;
|
54 |
-
|
55 |
-
if ( $bp->current_component == $bp->blogs->slug && empty( $bp->current_action ) ) {
|
56 |
-
$member_theme = get_site_option( 'active-member-theme' );
|
57 |
-
|
58 |
-
if ( empty( $member_theme ) )
|
59 |
-
$member_theme = 'bpmember';
|
60 |
-
|
61 |
-
add_filter( 'theme_root', 'bp_core_filter_buddypress_theme_root' );
|
62 |
-
add_filter( 'theme_root_uri', 'bp_core_filter_buddypress_theme_root_uri' );
|
63 |
-
|
64 |
-
return $member_theme;
|
65 |
-
} else {
|
66 |
-
return $stylesheet;
|
67 |
-
}
|
68 |
-
}
|
69 |
-
add_filter( 'stylesheet', 'bp_blogs_force_buddypress_stylesheet' );
|
70 |
-
|
71 |
-
function bp_blogs_add_structure_css() {
|
72 |
-
/* If we are using a BuddyPress 1.1+ theme ignore this. */
|
73 |
-
if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
|
74 |
-
return $template;
|
75 |
-
|
76 |
-
/* Enqueue the structure CSS file to give basic positional formatting for components */
|
77 |
-
wp_enqueue_style( 'bp-blogs-structure', BP_PLUGIN_URL . '/bp-blogs/deprecated/css/structure.css' );
|
78 |
-
}
|
79 |
-
add_action( 'bp_styles', 'bp_blogs_add_structure_css' );
|
80 |
-
|
81 |
-
function bp_blogs_directory_js() {
|
82 |
-
/* If we are using a BuddyPress 1.1+ theme ignore this. */
|
83 |
-
if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
|
84 |
-
return $template;
|
85 |
-
|
86 |
-
wp_enqueue_script( 'bp-blogs-directory-blogs', BP_PLUGIN_URL . '/bp-blogs/deprecated/js/directory-blogs.js', array( 'jquery', 'jquery-livequery-pack' ) );
|
87 |
-
}
|
88 |
-
add_action( 'bp_blogs_directory_blogs_setup', 'bp_blogs_directory_js' );
|
89 |
-
|
90 |
-
function bp_blogs_ajax_directory_blogs() {
|
91 |
-
global $bp;
|
92 |
-
|
93 |
-
/* If we are using a BuddyPress 1.1+ theme ignore this. */
|
94 |
-
if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
|
95 |
-
return false;
|
96 |
-
|
97 |
-
check_ajax_referer('directory_blogs');
|
98 |
-
|
99 |
-
locate_template( array( 'directories/blogs/blogs-loop.php' ), true );
|
100 |
-
}
|
101 |
-
add_action( 'wp_ajax_directory_blogs', 'bp_blogs_ajax_directory_blogs' );
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bp-blogs/deprecated/css/structure.css
DELETED
@@ -1,84 +0,0 @@
|
|
1 |
-
/*
|
2 |
-
Basic layout structure styles for BuddyPress Blogs. Formats BuddyPress blog pages within any WordPress theme.
|
3 |
-
No colors, fonts or pretty stuff.
|
4 |
-
|
5 |
-
These structure styles can be overridden by the theme CSS file if needed.
|
6 |
-
*/
|
7 |
-
|
8 |
-
#blog-info {
|
9 |
-
margin: -1em 0 2em 0;
|
10 |
-
}
|
11 |
-
|
12 |
-
.post {
|
13 |
-
padding-bottom: 2em;
|
14 |
-
margin-bottom: 2em;
|
15 |
-
float: left;
|
16 |
-
width: 100%;
|
17 |
-
}
|
18 |
-
|
19 |
-
#main #content .post h2 {
|
20 |
-
border: none;
|
21 |
-
padding: 0;
|
22 |
-
margin: 0;
|
23 |
-
}
|
24 |
-
|
25 |
-
.post span.tags {
|
26 |
-
padding-left: 1.6em;
|
27 |
-
float: left;
|
28 |
-
}
|
29 |
-
|
30 |
-
.post span.comments {
|
31 |
-
float: right;
|
32 |
-
padding-right: 1.8em;
|
33 |
-
}
|
34 |
-
|
35 |
-
.postmetadata {
|
36 |
-
padding: 0.5em 0;
|
37 |
-
}
|
38 |
-
|
39 |
-
.post-details {
|
40 |
-
padding: 1em 1.5em;
|
41 |
-
margin: 0 0 2em 0;
|
42 |
-
}
|
43 |
-
|
44 |
-
h4.archive {
|
45 |
-
padding-bottom: 0.5em;
|
46 |
-
margin: -1em 0 1em 0;
|
47 |
-
}
|
48 |
-
|
49 |
-
|
50 |
-
/**** BLOG SIGNUP FORM **********/
|
51 |
-
|
52 |
-
#setupform label {
|
53 |
-
display: block;
|
54 |
-
padding-bottom: 3px;
|
55 |
-
}
|
56 |
-
#setupform label.checkbox {
|
57 |
-
display: inline;
|
58 |
-
margin-right: 1em;
|
59 |
-
}
|
60 |
-
|
61 |
-
#setupform label.checkbox input {
|
62 |
-
display: inline;
|
63 |
-
}
|
64 |
-
|
65 |
-
#setupform p.error {
|
66 |
-
padding: 5px 10px;
|
67 |
-
width: 40%;
|
68 |
-
}
|
69 |
-
|
70 |
-
#setupform input#blog_title, #setupform input#blogname {
|
71 |
-
width: 25%;
|
72 |
-
padding: 5px;
|
73 |
-
margin-bottom: 1.5em;
|
74 |
-
margin-right: 5px;
|
75 |
-
}
|
76 |
-
#setupform input#blog_title {
|
77 |
-
width: 65%;
|
78 |
-
}
|
79 |
-
|
80 |
-
#setupform input#submit {
|
81 |
-
width: auto;
|
82 |
-
margin-top: 1.5em;
|
83 |
-
padding: 3px 10px;
|
84 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bp-blogs/deprecated/js/directory-blogs.js
DELETED
@@ -1,104 +0,0 @@
|
|
1 |
-
jQuery(document).ready( function() {
|
2 |
-
jQuery("ul#letter-list li a").livequery('click',
|
3 |
-
function() {
|
4 |
-
jQuery('#ajax-loader-blogs').toggle();
|
5 |
-
|
6 |
-
jQuery("div#blogs-list-options a").removeClass("selected");
|
7 |
-
jQuery(this).addClass('selected');
|
8 |
-
jQuery("input#blogs_search").val('');
|
9 |
-
|
10 |
-
var letter = jQuery(this).attr('id')
|
11 |
-
letter = letter.split('-');
|
12 |
-
|
13 |
-
jQuery.post( ajaxurl, {
|
14 |
-
action: 'directory_blogs',
|
15 |
-
'cookie': encodeURIComponent(document.cookie),
|
16 |
-
'_wpnonce': jQuery("input#_wpnonce-blog-filter").val(),
|
17 |
-
'letter': letter[1],
|
18 |
-
'page': 1
|
19 |
-
},
|
20 |
-
function(response)
|
21 |
-
{
|
22 |
-
response = response.substr(0, response.length-1);
|
23 |
-
jQuery("#blog-dir-list").fadeOut(200,
|
24 |
-
function() {
|
25 |
-
jQuery('#ajax-loader-blogs').toggle();
|
26 |
-
jQuery("#blog-dir-list").html(response);
|
27 |
-
jQuery("#blog-dir-list").fadeIn(200);
|
28 |
-
}
|
29 |
-
);
|
30 |
-
});
|
31 |
-
|
32 |
-
return false;
|
33 |
-
}
|
34 |
-
);
|
35 |
-
|
36 |
-
jQuery("form#search-blogs-form").submit( function() {
|
37 |
-
jQuery('#ajax-loader-blogs').toggle();
|
38 |
-
|
39 |
-
jQuery.post( ajaxurl, {
|
40 |
-
action: 'directory_blogs',
|
41 |
-
'cookie': encodeURIComponent(document.cookie),
|
42 |
-
'_wpnonce': jQuery("input#_wpnonce-blog-filter").val(),
|
43 |
-
's': jQuery("input#blogs_search").val(),
|
44 |
-
'page': 1
|
45 |
-
},
|
46 |
-
function(response)
|
47 |
-
{
|
48 |
-
response = response.substr(0, response.length-1);
|
49 |
-
jQuery("#blog-dir-list").fadeOut(200,
|
50 |
-
function() {
|
51 |
-
jQuery('#ajax-loader-blogs').toggle();
|
52 |
-
jQuery("#blog-dir-list").html(response);
|
53 |
-
jQuery("#blog-dir-list").fadeIn(200);
|
54 |
-
}
|
55 |
-
);
|
56 |
-
});
|
57 |
-
|
58 |
-
return false;
|
59 |
-
}
|
60 |
-
);
|
61 |
-
|
62 |
-
jQuery("div#blog-dir-pag a").livequery('click',
|
63 |
-
function() {
|
64 |
-
jQuery('#ajax-loader-blogs').toggle();
|
65 |
-
|
66 |
-
var page = jQuery(this).attr('href');
|
67 |
-
page = page.split('bpage=');
|
68 |
-
|
69 |
-
if ( !jQuery("input#selected_letter").val() )
|
70 |
-
var letter = '';
|
71 |
-
else
|
72 |
-
var letter = jQuery("input#selected_letter").val();
|
73 |
-
|
74 |
-
if ( !jQuery("input#search_terms").val() )
|
75 |
-
var search_terms = '';
|
76 |
-
else
|
77 |
-
var search_terms = jQuery("input#search_terms").val();
|
78 |
-
|
79 |
-
jQuery.post( ajaxurl, {
|
80 |
-
action: 'directory_blogs',
|
81 |
-
'cookie': encodeURIComponent(document.cookie),
|
82 |
-
'_wpnonce': jQuery("input#_wpnonce").val(),
|
83 |
-
'bpage': page[1],
|
84 |
-
'_wpnonce': jQuery("input#_wpnonce-blog-filter").val(),
|
85 |
-
|
86 |
-
'letter': letter,
|
87 |
-
's': search_terms
|
88 |
-
},
|
89 |
-
function(response)
|
90 |
-
{
|
91 |
-
response = response.substr(0, response.length-1);
|
92 |
-
jQuery("#blog-dir-list").fadeOut(200,
|
93 |
-
function() {
|
94 |
-
jQuery('#ajax-loader-blogs').toggle();
|
95 |
-
jQuery("#blog-dir-list").html(response);
|
96 |
-
jQuery("#blog-dir-list").fadeIn(200);
|
97 |
-
}
|
98 |
-
);
|
99 |
-
});
|
100 |
-
|
101 |
-
return false;
|
102 |
-
}
|
103 |
-
);
|
104 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bp-core.php
CHANGED
@@ -11,6 +11,9 @@ define( 'BP_CORE_DB_VERSION', '1800' );
|
|
11 |
define( 'BP_PLUGIN_DIR', WP_PLUGIN_DIR . '/buddypress' );
|
12 |
define( 'BP_PLUGIN_URL', plugins_url( $path = '/buddypress' ) );
|
13 |
|
|
|
|
|
|
|
14 |
/* Place your custom code (actions/filters) in a file called /plugins/bp-custom.php and it will be loaded before anything else. */
|
15 |
if ( file_exists( WP_PLUGIN_DIR . '/bp-custom.php' ) )
|
16 |
require( WP_PLUGIN_DIR . '/bp-custom.php' );
|
@@ -19,7 +22,7 @@ if ( file_exists( WP_PLUGIN_DIR . '/bp-custom.php' ) )
|
|
19 |
if ( !defined( 'BP_ROOT_BLOG' ) )
|
20 |
define( 'BP_ROOT_BLOG', 1 );
|
21 |
|
22 |
-
/* Define the user and usermeta table names, useful if you are using custom or shared tables */
|
23 |
if ( !defined( 'CUSTOM_USER_TABLE' ) )
|
24 |
define( 'CUSTOM_USER_TABLE', $wpdb->base_prefix . 'users' );
|
25 |
|
@@ -36,16 +39,15 @@ require ( BP_PLUGIN_DIR . '/bp-core/bp-core-settings.php' );
|
|
36 |
require ( BP_PLUGIN_DIR . '/bp-core/bp-core-widgets.php' );
|
37 |
require ( BP_PLUGIN_DIR . '/bp-core/bp-core-notifications.php' );
|
38 |
require ( BP_PLUGIN_DIR . '/bp-core/bp-core-signup.php' );
|
39 |
-
require ( BP_PLUGIN_DIR . '/bp-core/bp-core-activation.php' );
|
40 |
|
41 |
-
/*
|
|
|
|
|
|
|
|
|
42 |
if ( !defined( 'BP_DISABLE_ADMIN_BAR' ) )
|
43 |
require ( BP_PLUGIN_DIR . '/bp-core/bp-core-adminbar.php' );
|
44 |
|
45 |
-
/* If BP_IGNORE_DEPRECATED is defined, do not load any deprecated functions for backwards support */
|
46 |
-
if ( !defined( 'BP_IGNORE_DEPRECATED' ) )
|
47 |
-
require ( BP_PLUGIN_DIR . '/bp-core/deprecated/bp-core-deprecated.php' );
|
48 |
-
|
49 |
/* Define the slug for member pages and the members directory (e.g. domain.com/[members] ) */
|
50 |
if ( !defined( 'BP_MEMBERS_SLUG' ) )
|
51 |
define( 'BP_MEMBERS_SLUG', 'members' );
|
@@ -62,13 +64,9 @@ if ( !defined( 'BP_ACTIVATION_SLUG' ) )
|
|
62 |
if ( !defined( 'BP_SEARCH_SLUG' ) )
|
63 |
define( 'BP_SEARCH_SLUG', 'search' );
|
64 |
|
65 |
-
/*
|
66 |
-
if (
|
67 |
-
|
68 |
-
|
69 |
-
/* Register BuddyPress themes contained within the theme folder */
|
70 |
-
if ( function_exists( 'register_theme_folder' ) )
|
71 |
-
register_theme_folder( 'buddypress/bp-themes' );
|
72 |
|
73 |
|
74 |
/* "And now for something completely different" .... */
|
@@ -103,13 +101,19 @@ function bp_core_setup_globals() {
|
|
103 |
$bp->loggedin_user->id = $current_user->ID;
|
104 |
|
105 |
/* The domain for the user currently logged in. eg: http://domain.com/members/andy */
|
106 |
-
$bp->loggedin_user->domain = bp_core_get_user_domain($
|
|
|
|
|
|
|
107 |
|
108 |
/* The user id of the user currently being viewed, set in /bp-core/bp-core-catchuri.php */
|
109 |
$bp->displayed_user->id = $displayed_user_id;
|
110 |
|
111 |
/* The domain for the user currently being displayed */
|
112 |
-
$bp->displayed_user->domain = bp_core_get_user_domain($
|
|
|
|
|
|
|
113 |
|
114 |
/* The component being used eg: http://domain.com/members/andy/ [profile] */
|
115 |
$bp->current_component = $current_component; // type: string
|
@@ -127,10 +131,17 @@ function bp_core_setup_globals() {
|
|
127 |
$bp->is_single_item = false;
|
128 |
|
129 |
/* The default component to use if none are set and someone visits: http://domain.com/members/andy */
|
130 |
-
if ( defined( '
|
131 |
-
|
132 |
-
|
133 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
134 |
|
135 |
/* Sets up the array container for the component navigation rendered by bp_get_nav() */
|
136 |
$bp->bp_nav = array();
|
@@ -138,17 +149,11 @@ function bp_core_setup_globals() {
|
|
138 |
/* Sets up the array container for the component options navigation rendered by bp_get_options_nav() */
|
139 |
$bp->bp_options_nav = array();
|
140 |
|
141 |
-
/* Sets up container used for the title of the current component option and rendered by bp_get_options_title() */
|
142 |
-
$bp->bp_options_title = '';
|
143 |
-
|
144 |
-
/* Sets up container used for the avatar of the current component being viewed. Rendered by bp_get_options_avatar() */
|
145 |
-
$bp->bp_options_avatar = '';
|
146 |
-
|
147 |
/* Contains an array of all the active components. The key is the slug, value the internal ID of the component */
|
148 |
$bp->active_components = array();
|
149 |
|
150 |
/* Fetches the default Gravatar image to use if the user/group/blog has no avatar or gravatar */
|
151 |
-
$bp->grav_default->user = apply_filters( 'bp_user_gravatar_default',
|
152 |
$bp->grav_default->group = apply_filters( 'bp_group_gravatar_default', 'identicon' );
|
153 |
$bp->grav_default->blog = apply_filters( 'bp_blog_gravatar_default', 'identicon' );
|
154 |
|
@@ -157,31 +162,29 @@ function bp_core_setup_globals() {
|
|
157 |
$bp->displayed_user->fullname = bp_core_get_user_displayname( $bp->displayed_user->id );
|
158 |
|
159 |
/* Used to determine if user has admin rights on current content. If the logged in user is viewing
|
160 |
-
their own profile and wants to delete
|
161 |
-
generic variable so it can be used
|
162 |
'is_item_admin' would be 1 if they are a group admin, 0 if they are not. */
|
163 |
-
$bp->is_item_admin =
|
164 |
|
165 |
/* Used to determine if the logged in user is a moderator for the current content. */
|
166 |
$bp->is_item_mod = false;
|
167 |
|
168 |
$bp->core->table_name_notifications = $wpdb->base_prefix . 'bp_notifications';
|
169 |
|
170 |
-
if ( !$bp->current_component )
|
171 |
$bp->current_component = $bp->default_component;
|
172 |
|
173 |
do_action( 'bp_core_setup_globals' );
|
174 |
}
|
175 |
-
add_action( '
|
176 |
-
add_action( '_admin_menu', 'bp_core_setup_globals', 2 ); // must be _admin_menu hook.
|
177 |
-
|
178 |
|
179 |
/**
|
180 |
* bp_core_setup_root_uris()
|
181 |
*
|
182 |
* Adds the core URIs that should run in the root of the installation.
|
183 |
*
|
184 |
-
* For example: http://example.org/search or http://example.org/members
|
185 |
*
|
186 |
* @package BuddyPress Core
|
187 |
* @uses bp_core_add_root_component() Adds a slug to the root components global variable.
|
@@ -192,7 +195,6 @@ function bp_core_setup_root_uris() {
|
|
192 |
bp_core_add_root_component( BP_REGISTER_SLUG );
|
193 |
bp_core_add_root_component( BP_ACTIVATION_SLUG );
|
194 |
bp_core_add_root_component( BP_SEARCH_SLUG );
|
195 |
-
bp_core_add_root_component( BP_HOME_BLOG_SLUG );
|
196 |
}
|
197 |
add_action( 'plugins_loaded', 'bp_core_setup_root_uris', 2 );
|
198 |
|
@@ -229,14 +231,15 @@ function bp_core_install() {
|
|
229 |
KEY is_new (is_new),
|
230 |
KEY component_name (component_name),
|
231 |
KEY component_action (component_action),
|
232 |
-
KEY useritem (user_id,
|
233 |
) {$charset_collate};";
|
234 |
|
235 |
require_once( ABSPATH . 'wp-admin/upgrade-functions.php' );
|
236 |
dbDelta( $sql );
|
237 |
|
238 |
/* Add names of root components to the banned blog list to avoid conflicts */
|
239 |
-
|
|
|
240 |
|
241 |
update_site_option( 'bp-core-db-version', BP_CORE_DB_VERSION );
|
242 |
}
|
@@ -263,7 +266,7 @@ function bp_core_check_installed() {
|
|
263 |
require ( BP_PLUGIN_DIR . '/bp-core/bp-core-admin.php' );
|
264 |
|
265 |
/* Need to check db tables exist, activate hook no-worky in mu-plugins folder. */
|
266 |
-
if (
|
267 |
bp_core_install();
|
268 |
}
|
269 |
add_action( 'admin_menu', 'bp_core_check_installed' );
|
@@ -321,7 +324,7 @@ function bp_core_is_root_component( $component_name ) {
|
|
321 |
* @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
|
322 |
* @uses bp_core_new_nav_item() Adds a navigation item to the top level buddypress navigation
|
323 |
* @uses bp_core_new_subnav_item() Adds a sub navigation item to a nav item
|
324 |
-
* @uses
|
325 |
* @uses bp_core_fetch_avatar() Returns the either the thumb or full avatar URL for the user_id passed
|
326 |
*/
|
327 |
function bp_core_setup_nav() {
|
@@ -332,7 +335,7 @@ function bp_core_setup_nav() {
|
|
332 |
* built in WordPress profile information
|
333 |
*/
|
334 |
if ( !function_exists( 'xprofile_install' ) ) {
|
335 |
-
/* Fallback
|
336 |
$bp->core->profile->slug = 'profile';
|
337 |
$bp->active_components[$bp->core->profile->slug] = $bp->core->profile->slug;
|
338 |
|
@@ -358,7 +361,7 @@ function bp_core_setup_nav() {
|
|
358 |
|
359 |
|
360 |
if ( 'profile' == $bp->current_component ) {
|
361 |
-
if (
|
362 |
$bp->bp_options_title = __('My Profile', 'buddypress');
|
363 |
} else {
|
364 |
$bp->bp_options_avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb' ) );
|
@@ -367,19 +370,10 @@ function bp_core_setup_nav() {
|
|
367 |
}
|
368 |
}
|
369 |
}
|
370 |
-
add_action( '
|
371 |
add_action( 'admin_menu', 'bp_core_setup_nav' );
|
372 |
|
373 |
|
374 |
-
/********************************************************************************
|
375 |
-
* Screen Functions
|
376 |
-
*
|
377 |
-
* Screen functions are the controllers of BuddyPress. They will execute when their
|
378 |
-
* specific URL is caught. They will first save or manipulate data using business
|
379 |
-
* functions, then pass on the user to a template file.
|
380 |
-
*/
|
381 |
-
|
382 |
-
|
383 |
/********************************************************************************
|
384 |
* Action Functions
|
385 |
*
|
@@ -388,7 +382,6 @@ add_action( 'admin_menu', 'bp_core_setup_nav' );
|
|
388 |
* back to the default screen after execution.
|
389 |
*/
|
390 |
|
391 |
-
|
392 |
/**
|
393 |
* bp_core_action_directory_members()
|
394 |
*
|
@@ -407,7 +400,7 @@ function bp_core_action_directory_members() {
|
|
407 |
$bp->is_directory = true;
|
408 |
|
409 |
do_action( 'bp_core_action_directory_members' );
|
410 |
-
bp_core_load_template( apply_filters( 'bp_core_template_directory_members', '
|
411 |
}
|
412 |
}
|
413 |
add_action( 'wp', 'bp_core_action_directory_members', 2 );
|
@@ -423,9 +416,9 @@ add_action( 'wp', 'bp_core_action_directory_members', 2 );
|
|
423 |
* @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
|
424 |
*/
|
425 |
function bp_core_action_set_spammer_status() {
|
426 |
-
global $bp;
|
427 |
|
428 |
-
if ( !is_site_admin() ||
|
429 |
return false;
|
430 |
|
431 |
if ( 'admin' == $bp->current_component && ( 'mark-spammer' == $bp->current_action || 'unmark-spammer' == $bp->current_action ) ) {
|
@@ -433,7 +426,8 @@ function bp_core_action_set_spammer_status() {
|
|
433 |
check_admin_referer( 'mark-unmark-spammer' );
|
434 |
|
435 |
/* Get the functions file */
|
436 |
-
|
|
|
437 |
|
438 |
if ( 'mark-spammer' == $bp->current_action )
|
439 |
$is_spam = 1;
|
@@ -456,14 +450,21 @@ function bp_core_action_set_spammer_status() {
|
|
456 |
}
|
457 |
|
458 |
/* Finally, mark this user as a spammer */
|
459 |
-
|
|
|
|
|
|
|
460 |
|
461 |
if ( $is_spam )
|
462 |
bp_core_add_message( __( 'User marked as spammer. Spam users are visible only to site admins.', 'buddypress' ) );
|
463 |
else
|
464 |
bp_core_add_message( __( 'User removed as spammer.', 'buddypress' ) );
|
465 |
|
466 |
-
|
|
|
|
|
|
|
|
|
467 |
|
468 |
bp_core_redirect( wp_get_referer() );
|
469 |
}
|
@@ -481,7 +482,7 @@ add_action( 'wp', 'bp_core_action_set_spammer_status', 3 );
|
|
481 |
function bp_core_action_delete_user() {
|
482 |
global $bp;
|
483 |
|
484 |
-
if ( !is_site_admin() ||
|
485 |
return false;
|
486 |
|
487 |
if ( 'admin' == $bp->current_component && 'delete-user' == $bp->current_action ) {
|
@@ -517,6 +518,32 @@ add_action( 'wp', 'bp_core_action_delete_user', 3 );
|
|
517 |
* true or false on success or failure.
|
518 |
*/
|
519 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
520 |
/**
|
521 |
* bp_core_get_user_domain()
|
522 |
*
|
@@ -528,23 +555,46 @@ add_action( 'wp', 'bp_core_action_delete_user', 3 );
|
|
528 |
* @param user_id The ID of the user.
|
529 |
* @uses get_usermeta() WordPress function to get the usermeta for a user.
|
530 |
*/
|
531 |
-
function bp_core_get_user_domain( $user_id ) {
|
532 |
global $bp;
|
533 |
|
534 |
if ( !$user_id ) return;
|
535 |
|
536 |
-
|
|
|
537 |
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
|
|
542 |
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
548 |
}
|
549 |
|
550 |
/**
|
@@ -621,6 +671,7 @@ function bp_core_new_nav_item( $args = '' ) {
|
|
621 |
|
622 |
$bp->bp_nav[$slug] = array(
|
623 |
'name' => $name,
|
|
|
624 |
'link' => $bp->loggedin_user->domain . $slug . '/',
|
625 |
'css_id' => $item_css_id,
|
626 |
'show_for_displayed_user' => $show_for_displayed_user,
|
@@ -632,7 +683,7 @@ function bp_core_new_nav_item( $args = '' ) {
|
|
632 |
* the logged in user is not the displayed user
|
633 |
* looking at their own profile, don't create the nav item.
|
634 |
*/
|
635 |
-
if ( !$show_for_displayed_user && !
|
636 |
return false;
|
637 |
|
638 |
/***
|
@@ -699,7 +750,7 @@ function bp_core_sort_nav_items() {
|
|
699 |
if ( empty( $bp->bp_nav ) || !is_array( $bp->bp_nav ) )
|
700 |
return false;
|
701 |
|
702 |
-
foreach ( $bp->bp_nav as $slug => $nav_item ) {
|
703 |
if ( empty( $temp[$nav_item['position']]) )
|
704 |
$temp[$nav_item['position']] = $nav_item;
|
705 |
else {
|
@@ -716,20 +767,7 @@ function bp_core_sort_nav_items() {
|
|
716 |
$bp->bp_nav = &$temp;
|
717 |
}
|
718 |
add_action( 'wp_head', 'bp_core_sort_nav_items' );
|
719 |
-
|
720 |
-
/**
|
721 |
-
* bp_core_remove_nav_item()
|
722 |
-
*
|
723 |
-
* Removes a navigation item from the main navigation array.
|
724 |
-
*
|
725 |
-
* @package BuddyPress Core
|
726 |
-
* @param $slug The slug of the sub navigation item.
|
727 |
-
*/
|
728 |
-
function bp_core_remove_nav_item( $slug ) {
|
729 |
-
global $bp;
|
730 |
-
|
731 |
-
unset( $bp->bp_nav[$slug] );
|
732 |
-
}
|
733 |
|
734 |
/**
|
735 |
* bp_core_new_subnav_item()
|
@@ -791,11 +829,11 @@ function bp_core_sort_subnav_items() {
|
|
791 |
if ( empty( $bp->bp_options_nav ) || !is_array( $bp->bp_options_nav ) )
|
792 |
return false;
|
793 |
|
794 |
-
foreach ( $bp->bp_options_nav as $parent_slug => $subnav_items ) {
|
795 |
if ( !is_array( $subnav_items ) )
|
796 |
continue;
|
797 |
|
798 |
-
foreach ( $subnav_items as $subnav_item ) {
|
799 |
if ( empty( $temp[$subnav_item['position']]) )
|
800 |
$temp[$subnav_item['position']] = $subnav_item;
|
801 |
else {
|
@@ -813,6 +851,29 @@ function bp_core_sort_subnav_items() {
|
|
813 |
}
|
814 |
}
|
815 |
add_action( 'wp_head', 'bp_core_sort_subnav_items' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
816 |
|
817 |
/**
|
818 |
* bp_core_remove_subnav_item()
|
@@ -826,7 +887,19 @@ add_action( 'wp_head', 'bp_core_sort_subnav_items' );
|
|
826 |
function bp_core_remove_subnav_item( $parent_id, $slug ) {
|
827 |
global $bp;
|
828 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
829 |
unset( $bp->bp_options_nav[$parent_id][$slug] );
|
|
|
|
|
|
|
830 |
}
|
831 |
|
832 |
/**
|
@@ -852,7 +925,7 @@ function bp_core_reset_subnav_items($parent_slug) {
|
|
852 |
* Example:
|
853 |
* bp_core_load_template( 'profile/edit-profile' );
|
854 |
* Loads:
|
855 |
-
* wp-content/
|
856 |
*
|
857 |
* @package BuddyPress Core
|
858 |
* @param $username str Username to check.
|
@@ -906,11 +979,8 @@ function bp_core_get_random_member() {
|
|
906 |
global $bp, $wpdb;
|
907 |
|
908 |
if ( isset( $_GET['random-member'] ) ) {
|
909 |
-
$user =
|
910 |
-
|
911 |
-
$ud = get_userdata( $user['users'][0]->user_id );
|
912 |
-
|
913 |
-
bp_core_redirect( bp_core_get_user_domain( $user['users'][0]->user_id ) );
|
914 |
}
|
915 |
}
|
916 |
add_action( 'wp', 'bp_core_get_random_member' );
|
@@ -945,39 +1015,39 @@ function bp_core_get_userid( $username ) {
|
|
945 |
* @return false on no match
|
946 |
* @return str the username of the matched user.
|
947 |
*/
|
948 |
-
function bp_core_get_username( $
|
949 |
-
global $
|
950 |
|
951 |
-
if (
|
952 |
-
$
|
|
|
953 |
|
954 |
-
|
955 |
-
|
956 |
|
957 |
-
|
|
|
958 |
|
959 |
-
|
960 |
-
|
|
|
|
|
961 |
|
962 |
-
|
963 |
-
|
964 |
-
|
965 |
-
* Returns the URL with no HTML markup for a user based on their user id.
|
966 |
-
*
|
967 |
-
* @package BuddyPress Core
|
968 |
-
* @param $uid int User ID to check.
|
969 |
-
* @global $userdata WordPress user data for the current logged in user.
|
970 |
-
* @uses get_userdata() WordPress function to fetch the userdata for a user ID
|
971 |
-
* @return false on no match
|
972 |
-
* @return str The URL for the user with no HTML formatting.
|
973 |
-
*/
|
974 |
-
function bp_core_get_userurl( $uid ) {
|
975 |
-
global $bp;
|
976 |
|
977 |
-
|
978 |
-
|
|
|
|
|
|
|
979 |
|
980 |
-
|
|
|
|
|
|
|
|
|
981 |
}
|
982 |
|
983 |
/**
|
@@ -992,8 +1062,13 @@ function bp_core_get_userurl( $uid ) {
|
|
992 |
* @return str The email for the matched user.
|
993 |
*/
|
994 |
function bp_core_get_user_email( $uid ) {
|
995 |
-
|
996 |
-
|
|
|
|
|
|
|
|
|
|
|
997 |
}
|
998 |
|
999 |
/**
|
@@ -1018,34 +1093,22 @@ function bp_core_get_user_email( $uid ) {
|
|
1018 |
* @return false on no match
|
1019 |
* @return str The link text based on passed parameters.
|
1020 |
*/
|
1021 |
-
function bp_core_get_userlink( $user_id, $no_anchor = false, $just_link = false
|
1022 |
-
|
1023 |
|
1024 |
-
|
1025 |
-
|
1026 |
-
if ( !$ud )
|
1027 |
return false;
|
1028 |
|
1029 |
-
if ( function_exists('bp_fetch_user_fullname') ) {
|
1030 |
-
$display_name = bp_core_get_user_displayname( $user_id );
|
1031 |
-
|
1032 |
-
if ( $with_s )
|
1033 |
-
$display_name = sprintf( __( "%s's", 'buddypress' ), $display_name );
|
1034 |
-
|
1035 |
-
} else {
|
1036 |
-
$display_name = $ud->display_name;
|
1037 |
-
}
|
1038 |
-
|
1039 |
if ( $no_anchor )
|
1040 |
return $display_name;
|
1041 |
|
1042 |
-
if ( !$url =
|
1043 |
return false;
|
1044 |
|
1045 |
if ( $just_link )
|
1046 |
return $url;
|
1047 |
|
1048 |
-
return '<a href="' . $url . '">' . $display_name . '</a>';
|
1049 |
}
|
1050 |
|
1051 |
|
@@ -1063,9 +1126,17 @@ function bp_core_get_userlink( $user_id, $no_anchor = false, $just_link = false,
|
|
1063 |
* @uses wp_cache_set() Adds a value to the cache.
|
1064 |
* @return str The display name for the user in question.
|
1065 |
*/
|
1066 |
-
function bp_core_get_user_displayname( $
|
1067 |
global $bp;
|
1068 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1069 |
if ( !$user_id )
|
1070 |
return false;
|
1071 |
|
@@ -1073,8 +1144,8 @@ function bp_core_get_user_displayname( $user_id ) {
|
|
1073 |
if ( function_exists('xprofile_install') ) {
|
1074 |
$fullname = xprofile_get_field_data( 1, $user_id );
|
1075 |
|
1076 |
-
if ( empty($fullname)
|
1077 |
-
$ud =
|
1078 |
|
1079 |
if ( !empty( $ud->display_name ) )
|
1080 |
$fullname = $ud->display_name;
|
@@ -1084,7 +1155,7 @@ function bp_core_get_user_displayname( $user_id ) {
|
|
1084 |
xprofile_set_field_data( 1, $user_id, $fullname );
|
1085 |
}
|
1086 |
} else {
|
1087 |
-
$ud =
|
1088 |
|
1089 |
if ( !empty( $ud->display_name ) )
|
1090 |
$fullname = $ud->display_name;
|
@@ -1092,7 +1163,8 @@ function bp_core_get_user_displayname( $user_id ) {
|
|
1092 |
$fullname = $ud->user_nicename;
|
1093 |
}
|
1094 |
|
1095 |
-
|
|
|
1096 |
}
|
1097 |
|
1098 |
return apply_filters( 'bp_core_get_user_displayname', $fullname );
|
@@ -1135,6 +1207,26 @@ function bp_core_get_userlink_by_username( $username ) {
|
|
1135 |
return apply_filters( 'bp_core_get_userlink_by_username', bp_core_get_userlink( $user_id, false, false, true ) );
|
1136 |
}
|
1137 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1138 |
/**
|
1139 |
* bp_core_is_user_spammer()
|
1140 |
*
|
@@ -1147,7 +1239,12 @@ function bp_core_get_userlink_by_username( $username ) {
|
|
1147 |
function bp_core_is_user_spammer( $user_id ) {
|
1148 |
global $wpdb;
|
1149 |
|
1150 |
-
|
|
|
|
|
|
|
|
|
|
|
1151 |
}
|
1152 |
|
1153 |
/**
|
@@ -1181,7 +1278,6 @@ function bp_core_format_time( $time, $just_date = false ) {
|
|
1181 |
return $date;
|
1182 |
}
|
1183 |
|
1184 |
-
|
1185 |
/**
|
1186 |
* bp_core_add_message()
|
1187 |
*
|
@@ -1289,17 +1385,23 @@ function bp_core_time_since( $older_date, $newer_date = false ) {
|
|
1289 |
array( 1, __( 'second', 'buddypress' ), __( 'seconds', 'buddypress' ) )
|
1290 |
);
|
1291 |
|
1292 |
-
|
|
|
|
|
|
|
|
|
|
|
1293 |
|
1294 |
/* $newer_date will equal false if we want to know the time elapsed between a date and the current time */
|
1295 |
/* $newer_date will have a value if we want to work out time elapsed between two known dates */
|
1296 |
-
$newer_date = ( !$newer_date ) ? (
|
1297 |
|
1298 |
/* Difference in seconds */
|
1299 |
$since = $newer_date - $older_date;
|
1300 |
|
|
|
1301 |
if ( 0 > $since )
|
1302 |
-
return __( '
|
1303 |
|
1304 |
/**
|
1305 |
* We only want to output two chunks of time here, eg:
|
@@ -1325,8 +1427,6 @@ function bp_core_time_since( $older_date, $newer_date = false ) {
|
|
1325 |
$seconds2 = $chunks[$i + 1][0];
|
1326 |
$name2 = $chunks[$i + 1][1];
|
1327 |
|
1328 |
-
//if ( $chunks[$i + 1][1] == __( 'second', 'buddypress' ) ) return $output;
|
1329 |
-
|
1330 |
if ( ( $count2 = floor( ( $since - ( $seconds * $count ) ) / $seconds2 ) ) != 0 ) {
|
1331 |
/* Add to output var */
|
1332 |
$output .= ( 1 == $count2 ) ? _c( ',|Separator in time since', 'buddypress' ) . ' 1 '. $chunks[$i + 1][1] : _c( ',|Separator in time since', 'buddypress' ) . ' ' . $count2 . ' ' . $chunks[$i + 1][2];
|
@@ -1359,8 +1459,11 @@ function bp_core_record_activity() {
|
|
1359 |
|
1360 |
$activity = get_usermeta( $bp->loggedin_user->id, 'last_activity' );
|
1361 |
|
1362 |
-
if (
|
1363 |
-
|
|
|
|
|
|
|
1364 |
}
|
1365 |
add_action( 'wp_head', 'bp_core_record_activity' );
|
1366 |
|
@@ -1380,18 +1483,19 @@ function bp_core_get_last_activity( $last_activity_date, $string ) {
|
|
1380 |
if ( !$last_activity_date || empty( $last_activity_date ) ) {
|
1381 |
$last_active = __( 'not recently active', 'buddypress' );
|
1382 |
} else {
|
1383 |
-
|
1384 |
-
$last_active = bp_core_time_since( strtotime( $last_activity_date ) );
|
1385 |
-
} else {
|
1386 |
-
$last_active = bp_core_time_since( $last_activity_date );
|
1387 |
-
}
|
1388 |
-
|
1389 |
-
$last_active = sprintf( $string, $last_active );
|
1390 |
}
|
1391 |
|
1392 |
-
return $last_active;
|
1393 |
}
|
1394 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1395 |
|
1396 |
/**
|
1397 |
* bp_core_get_all_posts_for_user()
|
@@ -1409,10 +1513,9 @@ function bp_core_get_all_posts_for_user( $user_id = null ) {
|
|
1409 |
if ( !$user_id )
|
1410 |
$user_id = $bp->displayed_user->id;
|
1411 |
|
1412 |
-
return $wpdb->get_col( $wpdb->prepare( "SELECT post_id FROM $wpdb->posts WHERE post_author = %d AND post_status = 'publish' AND post_type = 'post'", $user_id ) );
|
1413 |
}
|
1414 |
|
1415 |
-
|
1416 |
/**
|
1417 |
* bp_core_get_site_path()
|
1418 |
*
|
@@ -1423,9 +1526,82 @@ function bp_core_get_all_posts_for_user( $user_id = null ) {
|
|
1423 |
* @uses bp_core_get_userlink_by_email() Fetches a userlink via email address.
|
1424 |
*/
|
1425 |
function bp_core_get_site_path() {
|
1426 |
-
global $current_site;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1427 |
|
1428 |
-
return $
|
1429 |
}
|
1430 |
|
1431 |
/**
|
@@ -1481,7 +1657,7 @@ function bp_core_add_illegal_names() {
|
|
1481 |
$bp_illegal_names = $bp->root_components;
|
1482 |
|
1483 |
if ( is_array( $current ) ) {
|
1484 |
-
foreach( $bp_illegal_names as $bp_illegal_name ) {
|
1485 |
if ( !in_array( $bp_illegal_name, $current ) )
|
1486 |
$current[] = $bp_illegal_name;
|
1487 |
}
|
@@ -1504,7 +1680,7 @@ function bp_core_add_illegal_names() {
|
|
1504 |
* @return The blog name for the root blog
|
1505 |
*/
|
1506 |
function bp_core_email_from_name_filter() {
|
1507 |
-
|
1508 |
}
|
1509 |
add_filter( 'wp_mail_from_name', 'bp_core_email_from_name_filter' );
|
1510 |
|
@@ -1519,12 +1695,12 @@ add_filter( 'wp_mail_from_name', 'bp_core_email_from_name_filter' );
|
|
1519 |
* @return noreply@sitedomain email address
|
1520 |
*/
|
1521 |
function bp_core_email_from_address_filter() {
|
1522 |
-
|
1523 |
-
|
|
|
1524 |
}
|
1525 |
add_filter( 'wp_mail_from', 'bp_core_email_from_address_filter' );
|
1526 |
|
1527 |
-
|
1528 |
/**
|
1529 |
* bp_core_delete_account()
|
1530 |
*
|
@@ -1537,7 +1713,7 @@ add_filter( 'wp_mail_from', 'bp_core_email_from_address_filter' );
|
|
1537 |
* @uses wpmu_delete_user() Deletes a user from the system.
|
1538 |
*/
|
1539 |
function bp_core_delete_account( $user_id = false ) {
|
1540 |
-
global $bp;
|
1541 |
|
1542 |
if ( !$user_id )
|
1543 |
$user_id = $bp->loggedin_user->id;
|
@@ -1547,13 +1723,18 @@ function bp_core_delete_account( $user_id = false ) {
|
|
1547 |
return false;
|
1548 |
|
1549 |
/* Site admins should not be allowed to be deleted */
|
1550 |
-
if ( is_site_admin( bp_core_get_username( $user_id ) ) )
|
1551 |
return false;
|
1552 |
|
1553 |
-
|
1554 |
-
|
|
|
|
|
|
|
|
|
1555 |
|
1556 |
-
|
|
|
1557 |
}
|
1558 |
|
1559 |
|
@@ -1661,7 +1842,9 @@ function bp_core_clear_cache() {
|
|
1661 |
function bp_core_print_generation_time() {
|
1662 |
global $wpdb;
|
1663 |
?>
|
|
|
1664 |
<!-- Generated in <?php timer_stop(1); ?> seconds. -->
|
|
|
1665 |
<?php
|
1666 |
}
|
1667 |
add_action( 'wp_footer', 'bp_core_print_generation_time' );
|
@@ -1716,12 +1899,15 @@ function bp_core_add_admin_menu_page( $args = '' ) {
|
|
1716 |
/**
|
1717 |
* bp_core_boot_spammer()
|
1718 |
*
|
1719 |
-
* When a user logs in, check if they have been marked as a spammer. If then simply
|
1720 |
* redirect them to the home page and stop them from logging in.
|
1721 |
*
|
1722 |
* @package BuddyPress Core
|
1723 |
-
* @param $
|
1724 |
-
* @
|
|
|
|
|
|
|
1725 |
*/
|
1726 |
function bp_core_boot_spammer( $auth_obj, $username ) {
|
1727 |
global $bp;
|
@@ -1730,6 +1916,8 @@ function bp_core_boot_spammer( $auth_obj, $username ) {
|
|
1730 |
|
1731 |
if ( (int)$user->spam )
|
1732 |
bp_core_redirect( $bp->root_domain );
|
|
|
|
|
1733 |
}
|
1734 |
add_filter( 'authenticate', 'bp_core_boot_spammer', 11, 2 );
|
1735 |
|
@@ -1788,6 +1976,188 @@ function bp_core_update_message() {
|
|
1788 |
}
|
1789 |
add_action( 'in_plugin_update_message-buddypress/bp-loader.php', 'bp_core_update_message' );
|
1790 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1791 |
/**
|
1792 |
* bp_core_clear_user_object_cache()
|
1793 |
*
|
@@ -1803,14 +2173,8 @@ function bp_core_clear_user_object_cache( $user_id ) {
|
|
1803 |
wp_cache_delete( 'newest_users' );
|
1804 |
}
|
1805 |
|
1806 |
-
// List actions to clear object caches on
|
1807 |
-
add_action( 'bp_core_delete_avatar', 'bp_core_clear_user_object_cache' );
|
1808 |
-
add_action( 'bp_core_avatar_save', 'bp_core_clear_user_object_cache' );
|
1809 |
-
|
1810 |
// List actions to clear super cached pages on, if super cache is installed
|
1811 |
add_action( 'wp_login', 'bp_core_clear_cache' );
|
1812 |
-
add_action( 'bp_core_delete_avatar', 'bp_core_clear_cache' );
|
1813 |
-
add_action( 'bp_core_avatar_save', 'bp_core_clear_cache' );
|
1814 |
add_action( 'bp_core_render_notice', 'bp_core_clear_cache' );
|
1815 |
|
1816 |
// Remove the catch non existent blogs hook so WPMU doesn't think BuddyPress pages are non existing blogs
|
11 |
define( 'BP_PLUGIN_DIR', WP_PLUGIN_DIR . '/buddypress' );
|
12 |
define( 'BP_PLUGIN_URL', plugins_url( $path = '/buddypress' ) );
|
13 |
|
14 |
+
/* Load the WP abstraction file so BuddyPress can run on all WordPress setups. */
|
15 |
+
require ( BP_PLUGIN_DIR . '/bp-core/bp-core-wpabstraction.php' );
|
16 |
+
|
17 |
/* Place your custom code (actions/filters) in a file called /plugins/bp-custom.php and it will be loaded before anything else. */
|
18 |
if ( file_exists( WP_PLUGIN_DIR . '/bp-custom.php' ) )
|
19 |
require( WP_PLUGIN_DIR . '/bp-custom.php' );
|
22 |
if ( !defined( 'BP_ROOT_BLOG' ) )
|
23 |
define( 'BP_ROOT_BLOG', 1 );
|
24 |
|
25 |
+
/* Define the user and usermeta table names, useful if you are using custom or shared tables. */
|
26 |
if ( !defined( 'CUSTOM_USER_TABLE' ) )
|
27 |
define( 'CUSTOM_USER_TABLE', $wpdb->base_prefix . 'users' );
|
28 |
|
39 |
require ( BP_PLUGIN_DIR . '/bp-core/bp-core-widgets.php' );
|
40 |
require ( BP_PLUGIN_DIR . '/bp-core/bp-core-notifications.php' );
|
41 |
require ( BP_PLUGIN_DIR . '/bp-core/bp-core-signup.php' );
|
|
|
42 |
|
43 |
+
/* Multisite includes built in account activation support. */
|
44 |
+
if ( bp_core_is_multisite() )
|
45 |
+
require ( BP_PLUGIN_DIR . '/bp-core/bp-core-activation.php' );
|
46 |
+
|
47 |
+
/* If BP_DISABLE_ADMIN_BAR is defined, do not load the global admin bar. */
|
48 |
if ( !defined( 'BP_DISABLE_ADMIN_BAR' ) )
|
49 |
require ( BP_PLUGIN_DIR . '/bp-core/bp-core-adminbar.php' );
|
50 |
|
|
|
|
|
|
|
|
|
51 |
/* Define the slug for member pages and the members directory (e.g. domain.com/[members] ) */
|
52 |
if ( !defined( 'BP_MEMBERS_SLUG' ) )
|
53 |
define( 'BP_MEMBERS_SLUG', 'members' );
|
64 |
if ( !defined( 'BP_SEARCH_SLUG' ) )
|
65 |
define( 'BP_SEARCH_SLUG', 'search' );
|
66 |
|
67 |
+
/* Register BuddyPress themes contained within the bp-theme folder */
|
68 |
+
if ( function_exists( 'register_theme_directory') )
|
69 |
+
register_theme_directory( WP_PLUGIN_DIR . '/buddypress/bp-themes' );
|
|
|
|
|
|
|
|
|
70 |
|
71 |
|
72 |
/* "And now for something completely different" .... */
|
101 |
$bp->loggedin_user->id = $current_user->ID;
|
102 |
|
103 |
/* The domain for the user currently logged in. eg: http://domain.com/members/andy */
|
104 |
+
$bp->loggedin_user->domain = bp_core_get_user_domain( $bp->loggedin_user->id );
|
105 |
+
|
106 |
+
/* The core userdata of the user who is currently logged in. */
|
107 |
+
$bp->loggedin_user->userdata = bp_core_get_core_userdata( $bp->loggedin_user->id );
|
108 |
|
109 |
/* The user id of the user currently being viewed, set in /bp-core/bp-core-catchuri.php */
|
110 |
$bp->displayed_user->id = $displayed_user_id;
|
111 |
|
112 |
/* The domain for the user currently being displayed */
|
113 |
+
$bp->displayed_user->domain = bp_core_get_user_domain( $bp->displayed_user->id );
|
114 |
+
|
115 |
+
/* The core userdata of the user who is currently being displayed */
|
116 |
+
$bp->displayed_user->userdata = bp_core_get_core_userdata( $bp->displayed_user->id );
|
117 |
|
118 |
/* The component being used eg: http://domain.com/members/andy/ [profile] */
|
119 |
$bp->current_component = $current_component; // type: string
|
131 |
$bp->is_single_item = false;
|
132 |
|
133 |
/* The default component to use if none are set and someone visits: http://domain.com/members/andy */
|
134 |
+
if ( !defined( 'BP_DEFAULT_COMPONENT' ) ) {
|
135 |
+
if ( defined( 'BP_ACTIVITY_SLUG' ) )
|
136 |
+
$bp->default_component = BP_ACTIVITY_SLUG;
|
137 |
+
else
|
138 |
+
$bp->default_component = 'profile';
|
139 |
+
} else {
|
140 |
+
$bp->default_component = BP_DEFAULT_COMPONENT;
|
141 |
+
}
|
142 |
+
|
143 |
+
/* Fetches all of the core database based BuddyPress settings in one foul swoop */
|
144 |
+
$bp->site_options = bp_core_get_site_options();
|
145 |
|
146 |
/* Sets up the array container for the component navigation rendered by bp_get_nav() */
|
147 |
$bp->bp_nav = array();
|
149 |
/* Sets up the array container for the component options navigation rendered by bp_get_options_nav() */
|
150 |
$bp->bp_options_nav = array();
|
151 |
|
|
|
|
|
|
|
|
|
|
|
|
|
152 |
/* Contains an array of all the active components. The key is the slug, value the internal ID of the component */
|
153 |
$bp->active_components = array();
|
154 |
|
155 |
/* Fetches the default Gravatar image to use if the user/group/blog has no avatar or gravatar */
|
156 |
+
$bp->grav_default->user = apply_filters( 'bp_user_gravatar_default', $bp->site_options['user-avatar-default'] );
|
157 |
$bp->grav_default->group = apply_filters( 'bp_group_gravatar_default', 'identicon' );
|
158 |
$bp->grav_default->blog = apply_filters( 'bp_blog_gravatar_default', 'identicon' );
|
159 |
|
162 |
$bp->displayed_user->fullname = bp_core_get_user_displayname( $bp->displayed_user->id );
|
163 |
|
164 |
/* Used to determine if user has admin rights on current content. If the logged in user is viewing
|
165 |
+
their own profile and wants to delete something, is_item_admin is used. This is a
|
166 |
+
generic variable so it can be used by other components. It can also be modified, so when viewing a group
|
167 |
'is_item_admin' would be 1 if they are a group admin, 0 if they are not. */
|
168 |
+
$bp->is_item_admin = bp_is_my_profile();
|
169 |
|
170 |
/* Used to determine if the logged in user is a moderator for the current content. */
|
171 |
$bp->is_item_mod = false;
|
172 |
|
173 |
$bp->core->table_name_notifications = $wpdb->base_prefix . 'bp_notifications';
|
174 |
|
175 |
+
if ( !$bp->current_component && $bp->displayed_user->id )
|
176 |
$bp->current_component = $bp->default_component;
|
177 |
|
178 |
do_action( 'bp_core_setup_globals' );
|
179 |
}
|
180 |
+
add_action( 'bp_setup_globals', 'bp_core_setup_globals' );
|
|
|
|
|
181 |
|
182 |
/**
|
183 |
* bp_core_setup_root_uris()
|
184 |
*
|
185 |
* Adds the core URIs that should run in the root of the installation.
|
186 |
*
|
187 |
+
* For example: http://example.org/search/ or http://example.org/members/
|
188 |
*
|
189 |
* @package BuddyPress Core
|
190 |
* @uses bp_core_add_root_component() Adds a slug to the root components global variable.
|
195 |
bp_core_add_root_component( BP_REGISTER_SLUG );
|
196 |
bp_core_add_root_component( BP_ACTIVATION_SLUG );
|
197 |
bp_core_add_root_component( BP_SEARCH_SLUG );
|
|
|
198 |
}
|
199 |
add_action( 'plugins_loaded', 'bp_core_setup_root_uris', 2 );
|
200 |
|
231 |
KEY is_new (is_new),
|
232 |
KEY component_name (component_name),
|
233 |
KEY component_action (component_action),
|
234 |
+
KEY useritem (user_id,is_new)
|
235 |
) {$charset_collate};";
|
236 |
|
237 |
require_once( ABSPATH . 'wp-admin/upgrade-functions.php' );
|
238 |
dbDelta( $sql );
|
239 |
|
240 |
/* Add names of root components to the banned blog list to avoid conflicts */
|
241 |
+
if ( bp_core_is_multisite() )
|
242 |
+
bp_core_add_illegal_names();
|
243 |
|
244 |
update_site_option( 'bp-core-db-version', BP_CORE_DB_VERSION );
|
245 |
}
|
266 |
require ( BP_PLUGIN_DIR . '/bp-core/bp-core-admin.php' );
|
267 |
|
268 |
/* Need to check db tables exist, activate hook no-worky in mu-plugins folder. */
|
269 |
+
if ( $bp->site_options['bp-core-db-version'] < BP_CORE_DB_VERSION )
|
270 |
bp_core_install();
|
271 |
}
|
272 |
add_action( 'admin_menu', 'bp_core_check_installed' );
|
324 |
* @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
|
325 |
* @uses bp_core_new_nav_item() Adds a navigation item to the top level buddypress navigation
|
326 |
* @uses bp_core_new_subnav_item() Adds a sub navigation item to a nav item
|
327 |
+
* @uses bp_is_my_profile() Returns true if the current user being viewed is equal the logged in user
|
328 |
* @uses bp_core_fetch_avatar() Returns the either the thumb or full avatar URL for the user_id passed
|
329 |
*/
|
330 |
function bp_core_setup_nav() {
|
335 |
* built in WordPress profile information
|
336 |
*/
|
337 |
if ( !function_exists( 'xprofile_install' ) ) {
|
338 |
+
/* Fallback values if xprofile is disabled */
|
339 |
$bp->core->profile->slug = 'profile';
|
340 |
$bp->active_components[$bp->core->profile->slug] = $bp->core->profile->slug;
|
341 |
|
361 |
|
362 |
|
363 |
if ( 'profile' == $bp->current_component ) {
|
364 |
+
if ( bp_is_my_profile() ) {
|
365 |
$bp->bp_options_title = __('My Profile', 'buddypress');
|
366 |
} else {
|
367 |
$bp->bp_options_avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb' ) );
|
370 |
}
|
371 |
}
|
372 |
}
|
373 |
+
add_action( 'bp_setup_nav', 'bp_core_setup_nav' );
|
374 |
add_action( 'admin_menu', 'bp_core_setup_nav' );
|
375 |
|
376 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
377 |
/********************************************************************************
|
378 |
* Action Functions
|
379 |
*
|
382 |
* back to the default screen after execution.
|
383 |
*/
|
384 |
|
|
|
385 |
/**
|
386 |
* bp_core_action_directory_members()
|
387 |
*
|
400 |
$bp->is_directory = true;
|
401 |
|
402 |
do_action( 'bp_core_action_directory_members' );
|
403 |
+
bp_core_load_template( apply_filters( 'bp_core_template_directory_members', 'members/index' ) );
|
404 |
}
|
405 |
}
|
406 |
add_action( 'wp', 'bp_core_action_directory_members', 2 );
|
416 |
* @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
|
417 |
*/
|
418 |
function bp_core_action_set_spammer_status() {
|
419 |
+
global $bp, $wpdb;
|
420 |
|
421 |
+
if ( !is_site_admin() || bp_is_my_profile() || !$bp->displayed_user->id )
|
422 |
return false;
|
423 |
|
424 |
if ( 'admin' == $bp->current_component && ( 'mark-spammer' == $bp->current_action || 'unmark-spammer' == $bp->current_action ) ) {
|
426 |
check_admin_referer( 'mark-unmark-spammer' );
|
427 |
|
428 |
/* Get the functions file */
|
429 |
+
if ( file_exists( ABSPATH . 'wp-admin/includes/mu.php' ) && bp_core_is_multisite() )
|
430 |
+
require( ABSPATH . 'wp-admin/includes/mu.php' );
|
431 |
|
432 |
if ( 'mark-spammer' == $bp->current_action )
|
433 |
$is_spam = 1;
|
450 |
}
|
451 |
|
452 |
/* Finally, mark this user as a spammer */
|
453 |
+
if ( bp_core_is_multisite() )
|
454 |
+
$wpdb->update( $wpdb->users, array( 'spam' => $is_spam ), array( 'ID' => $bp->displayed_user->id ) );
|
455 |
+
|
456 |
+
$wpdb->update( $wpdb->users, array( 'user_status' => $is_spam ), array( 'ID' => $bp->displayed_user->id ) );
|
457 |
|
458 |
if ( $is_spam )
|
459 |
bp_core_add_message( __( 'User marked as spammer. Spam users are visible only to site admins.', 'buddypress' ) );
|
460 |
else
|
461 |
bp_core_add_message( __( 'User removed as spammer.', 'buddypress' ) );
|
462 |
|
463 |
+
/* Hide this user's activity */
|
464 |
+
if ( $is_spam && function_exists( 'bp_activity_hide_user_activity' ) )
|
465 |
+
bp_activity_hide_user_activity( $bp->displayed_user->id );
|
466 |
+
|
467 |
+
do_action( 'bp_core_action_set_spammer_status', $bp->displayed_user->id, $is_spam );
|
468 |
|
469 |
bp_core_redirect( wp_get_referer() );
|
470 |
}
|
482 |
function bp_core_action_delete_user() {
|
483 |
global $bp;
|
484 |
|
485 |
+
if ( !is_site_admin() || bp_is_my_profile() || !$bp->displayed_user->id )
|
486 |
return false;
|
487 |
|
488 |
if ( 'admin' == $bp->current_component && 'delete-user' == $bp->current_action ) {
|
518 |
* true or false on success or failure.
|
519 |
*/
|
520 |
|
521 |
+
/**
|
522 |
+
* bp_core_get_users()
|
523 |
+
*
|
524 |
+
* Return an array of users IDs based on the parameters passed.
|
525 |
+
*
|
526 |
+
* @package BuddyPress Core
|
527 |
+
*/
|
528 |
+
function bp_core_get_users( $args = '' ) {
|
529 |
+
global $bp;
|
530 |
+
|
531 |
+
$defaults = array(
|
532 |
+
'type' => 'active', // active, newest, alphabetical, random or popular
|
533 |
+
'user_id' => false, // Pass a user_id to limit to only friend connections for this user
|
534 |
+
'search_terms' => false, // Limit to users that match these search terms
|
535 |
+
|
536 |
+
'per_page' => 20, // The number of results to return per page
|
537 |
+
'page' => 1, // The page to return if limiting per page
|
538 |
+
'populate_extras' => true, // Fetch the last active, where the user is a friend, total friend count, latest update
|
539 |
+
);
|
540 |
+
|
541 |
+
$params = wp_parse_args( $args, $defaults );
|
542 |
+
extract( $params, EXTR_SKIP );
|
543 |
+
|
544 |
+
return apply_filters( 'bp_core_get_users', BP_Core_User::get_users( $type, $per_page, $page, $user_id, $search_terms, $populate_extras ), &$params );
|
545 |
+
}
|
546 |
+
|
547 |
/**
|
548 |
* bp_core_get_user_domain()
|
549 |
*
|
555 |
* @param user_id The ID of the user.
|
556 |
* @uses get_usermeta() WordPress function to get the usermeta for a user.
|
557 |
*/
|
558 |
+
function bp_core_get_user_domain( $user_id, $user_nicename = false, $user_login = false ) {
|
559 |
global $bp;
|
560 |
|
561 |
if ( !$user_id ) return;
|
562 |
|
563 |
+
if ( !$domain = wp_cache_get( 'bp_user_domain_' . $user_id, 'bp' ) ) {
|
564 |
+
$username = bp_core_get_username( $user_id, $user_nicename, $user_login );
|
565 |
|
566 |
+
/* If we are using a members slug, include it. */
|
567 |
+
if ( !defined( 'BP_ENABLE_ROOT_PROFILES' ) )
|
568 |
+
$domain = $bp->root_domain . '/' . BP_MEMBERS_SLUG . '/' . $username . '/';
|
569 |
+
else
|
570 |
+
$domain = $bp->root_domain . '/' . $username . '/';
|
571 |
|
572 |
+
/* Cache the link */
|
573 |
+
if ( !empty( $domain ) )
|
574 |
+
wp_cache_set( 'bp_user_domain_' . $user_id, $domain, 'bp' );
|
575 |
+
}
|
576 |
+
|
577 |
+
return apply_filters( 'bp_core_get_user_domain', $domain );
|
578 |
+
}
|
579 |
+
|
580 |
+
/**
|
581 |
+
* bp_core_get_core_userdata()
|
582 |
+
*
|
583 |
+
* Fetch everything in the wp_users table for a user, without any usermeta.
|
584 |
+
*
|
585 |
+
* @package BuddyPress Core
|
586 |
+
* @param user_id The ID of the user.
|
587 |
+
* @uses BP_Core_User::get_core_userdata() Performs the query.
|
588 |
+
*/
|
589 |
+
function bp_core_get_core_userdata( $user_id ) {
|
590 |
+
if ( empty( $user_id ) )
|
591 |
+
return false;
|
592 |
+
|
593 |
+
if ( !$userdata = wp_cache_get( 'bp_core_userdata_' . $user_id, 'bp' ) ) {
|
594 |
+
$userdata = BP_Core_User::get_core_userdata( $user_id );
|
595 |
+
wp_cache_set( 'bp_core_userdata_' . $user_id, $userdata, 'bp' );
|
596 |
+
}
|
597 |
+
return apply_filters( 'bp_core_get_core_userdata', $userdata );
|
598 |
}
|
599 |
|
600 |
/**
|
671 |
|
672 |
$bp->bp_nav[$slug] = array(
|
673 |
'name' => $name,
|
674 |
+
'slug' => $slug,
|
675 |
'link' => $bp->loggedin_user->domain . $slug . '/',
|
676 |
'css_id' => $item_css_id,
|
677 |
'show_for_displayed_user' => $show_for_displayed_user,
|
683 |
* the logged in user is not the displayed user
|
684 |
* looking at their own profile, don't create the nav item.
|
685 |
*/
|
686 |
+
if ( !$show_for_displayed_user && !bp_is_my_profile() )
|
687 |
return false;
|
688 |
|
689 |
/***
|
750 |
if ( empty( $bp->bp_nav ) || !is_array( $bp->bp_nav ) )
|
751 |
return false;
|
752 |
|
753 |
+
foreach ( (array)$bp->bp_nav as $slug => $nav_item ) {
|
754 |
if ( empty( $temp[$nav_item['position']]) )
|
755 |
$temp[$nav_item['position']] = $nav_item;
|
756 |
else {
|
767 |
$bp->bp_nav = &$temp;
|
768 |
}
|
769 |
add_action( 'wp_head', 'bp_core_sort_nav_items' );
|
770 |
+
add_action( 'admin_head', 'bp_core_sort_nav_items' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
771 |
|
772 |
/**
|
773 |
* bp_core_new_subnav_item()
|
829 |
if ( empty( $bp->bp_options_nav ) || !is_array( $bp->bp_options_nav ) )
|
830 |
return false;
|
831 |
|
832 |
+
foreach ( (array)$bp->bp_options_nav as $parent_slug => $subnav_items ) {
|
833 |
if ( !is_array( $subnav_items ) )
|
834 |
continue;
|
835 |
|
836 |
+
foreach ( (array)$subnav_items as $subnav_item ) {
|
837 |
if ( empty( $temp[$subnav_item['position']]) )
|
838 |
$temp[$subnav_item['position']] = $subnav_item;
|
839 |
else {
|
851 |
}
|
852 |
}
|
853 |
add_action( 'wp_head', 'bp_core_sort_subnav_items' );
|
854 |
+
add_action( 'admin_head', 'bp_core_sort_subnav_items' );
|
855 |
+
|
856 |
+
/**
|
857 |
+
* bp_core_remove_nav_item()
|
858 |
+
*
|
859 |
+
* Removes a navigation item from the sub navigation array used in BuddyPress themes.
|
860 |
+
*
|
861 |
+
* @package BuddyPress Core
|
862 |
+
* @param $parent_id The id of the parent navigation item.
|
863 |
+
* @param $slug The slug of the sub navigation item.
|
864 |
+
*/
|
865 |
+
function bp_core_remove_nav_item( $parent_id ) {
|
866 |
+
global $bp;
|
867 |
+
|
868 |
+
/* Unset subnav items for this nav item */
|
869 |
+
if ( is_array( $bp->bp_options_nav[$parent_id] ) ) {
|
870 |
+
foreach( (array)$bp->bp_options_nav[$parent_id] as $subnav_item ) {
|
871 |
+
bp_core_remove_subnav_item( $parent_id, $subnav_item['slug'] );
|
872 |
+
}
|
873 |
+
}
|
874 |
+
|
875 |
+
unset( $bp->bp_nav[$parent_id] );
|
876 |
+
}
|
877 |
|
878 |
/**
|
879 |
* bp_core_remove_subnav_item()
|
887 |
function bp_core_remove_subnav_item( $parent_id, $slug ) {
|
888 |
global $bp;
|
889 |
|
890 |
+
$function = $bp->bp_options_nav[$parent_id][$slug]['screen_function'];
|
891 |
+
|
892 |
+
if ( $function ) {
|
893 |
+
if ( !is_object( $screen_function[0] ) )
|
894 |
+
remove_action( 'wp', $screen_function, 3 );
|
895 |
+
else
|
896 |
+
remove_action( 'wp', array( &$screen_function[0], $screen_function[1] ), 3 );
|
897 |
+
}
|
898 |
+
|
899 |
unset( $bp->bp_options_nav[$parent_id][$slug] );
|
900 |
+
|
901 |
+
if ( !count( $bp->bp_options_nav[$parent_id] ) )
|
902 |
+
unset($bp->bp_options_nav[$parent_id]);
|
903 |
}
|
904 |
|
905 |
/**
|
925 |
* Example:
|
926 |
* bp_core_load_template( 'profile/edit-profile' );
|
927 |
* Loads:
|
928 |
+
* wp-content/themes/[activated_theme]/profile/edit-profile.php
|
929 |
*
|
930 |
* @package BuddyPress Core
|
931 |
* @param $username str Username to check.
|
979 |
global $bp, $wpdb;
|
980 |
|
981 |
if ( isset( $_GET['random-member'] ) ) {
|
982 |
+
$user = bp_core_get_users( array( 'type' => 'random', 'per_page' => 1 ) );
|
983 |
+
bp_core_redirect( bp_core_get_user_domain( $user['users'][0]->id ) );
|
|
|
|
|
|
|
984 |
}
|
985 |
}
|
986 |
add_action( 'wp', 'bp_core_get_random_member' );
|
1015 |
* @return false on no match
|
1016 |
* @return str the username of the matched user.
|
1017 |
*/
|
1018 |
+
function bp_core_get_username( $user_id, $user_nicename = false, $user_login = false ) {
|
1019 |
+
global $bp;
|
1020 |
|
1021 |
+
if ( !$username = wp_cache_get( 'bp_user_username_' . $user_id, 'bp' ) ) {
|
1022 |
+
if ( empty( $user_nicename ) && empty( $user_login ) ) {
|
1023 |
+
$ud = false;
|
1024 |
|
1025 |
+
if ( $bp->loggedin_user->id == $user_id )
|
1026 |
+
$ud = &$bp->loggedin_user->userdata;
|
1027 |
|
1028 |
+
if ( $bp->displayed_user->id == $user_id )
|
1029 |
+
$ud = &$bp->displayed_user->userdata;
|
1030 |
|
1031 |
+
if ( empty( $ud ) ) {
|
1032 |
+
if ( !$ud = bp_core_get_core_userdata( $user_id ) )
|
1033 |
+
return false;
|
1034 |
+
}
|
1035 |
|
1036 |
+
$user_nicename = $ud->user_nicename;
|
1037 |
+
$user_login = $ud->user_login;
|
1038 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1039 |
|
1040 |
+
if ( defined( 'BP_ENABLE_USERNAME_COMPATIBILITY_MODE' ) )
|
1041 |
+
$username = $user_login;
|
1042 |
+
else
|
1043 |
+
$username = $user_nicename;
|
1044 |
+
}
|
1045 |
|
1046 |
+
/* Add this to cache */
|
1047 |
+
if ( !empty( $username ) )
|
1048 |
+
wp_cache_set( 'bp_user_username_' . $user_id, $username, 'bp' );
|
1049 |
+
|
1050 |
+
return apply_filters( 'bp_core_get_username', $username );
|
1051 |
}
|
1052 |
|
1053 |
/**
|
1062 |
* @return str The email for the matched user.
|
1063 |
*/
|
1064 |
function bp_core_get_user_email( $uid ) {
|
1065 |
+
if ( !$email = wp_cache_get( 'bp_user_email_' . $uid, 'bp' ) ) {
|
1066 |
+
$ud = bp_core_get_core_userdata($uid);
|
1067 |
+
$email = $ud->user_email;
|
1068 |
+
wp_cache_set( 'bp_user_email_' . $uid, $email, 'bp' );
|
1069 |
+
}
|
1070 |
+
|
1071 |
+
return apply_filters( 'bp_core_get_user_email', $email );
|
1072 |
}
|
1073 |
|
1074 |
/**
|
1093 |
* @return false on no match
|
1094 |
* @return str The link text based on passed parameters.
|
1095 |
*/
|
1096 |
+
function bp_core_get_userlink( $user_id, $no_anchor = false, $just_link = false ) {
|
1097 |
+
$display_name = bp_core_get_user_displayname( $user_id );
|
1098 |
|
1099 |
+
if ( empty( $display_name ) )
|
|
|
|
|
1100 |
return false;
|
1101 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1102 |
if ( $no_anchor )
|
1103 |
return $display_name;
|
1104 |
|
1105 |
+
if ( !$url = bp_core_get_user_domain($user_id) )
|
1106 |
return false;
|
1107 |
|
1108 |
if ( $just_link )
|
1109 |
return $url;
|
1110 |
|
1111 |
+
return apply_filters( 'bp_core_get_userlink', '<a href="' . $url . '" title="' . $display_name . '">' . $display_name . '</a>', $user_id );
|
1112 |
}
|
1113 |
|
1114 |
|
1126 |
* @uses wp_cache_set() Adds a value to the cache.
|
1127 |
* @return str The display name for the user in question.
|
1128 |
*/
|
1129 |
+
function bp_core_get_user_displayname( $user_id_or_username ) {
|
1130 |
global $bp;
|
1131 |
|
1132 |
+
if ( !$user_id_or_username )
|
1133 |
+
return false;
|
1134 |
+
|
1135 |
+
if ( !is_numeric( $user_id_or_username ) )
|
1136 |
+
$user_id = bp_core_get_userid( $user_id_or_username );
|
1137 |
+
else
|
1138 |
+
$user_id = $user_id_or_username;
|
1139 |
+
|
1140 |
if ( !$user_id )
|
1141 |
return false;
|
1142 |
|
1144 |
if ( function_exists('xprofile_install') ) {
|
1145 |
$fullname = xprofile_get_field_data( 1, $user_id );
|
1146 |
|
1147 |
+
if ( empty($fullname) ) {
|
1148 |
+
$ud = bp_core_get_core_userdata( $user_id );
|
1149 |
|
1150 |
if ( !empty( $ud->display_name ) )
|
1151 |
$fullname = $ud->display_name;
|
1155 |
xprofile_set_field_data( 1, $user_id, $fullname );
|
1156 |
}
|
1157 |
} else {
|
1158 |
+
$ud = bp_core_get_core_userdata($user_id);
|
1159 |
|
1160 |
if ( !empty( $ud->display_name ) )
|
1161 |
$fullname = $ud->display_name;
|
1163 |
$fullname = $ud->user_nicename;
|
1164 |
}
|
1165 |
|
1166 |
+
if ( !empty( $fullname ) )
|
1167 |
+
wp_cache_set( 'bp_user_fullname_' . $user_id, $fullname, 'bp' );
|
1168 |
}
|
1169 |
|
1170 |
return apply_filters( 'bp_core_get_user_displayname', $fullname );
|
1207 |
return apply_filters( 'bp_core_get_userlink_by_username', bp_core_get_userlink( $user_id, false, false, true ) );
|
1208 |
}
|
1209 |
|
1210 |
+
/**
|
1211 |
+
* bp_core_get_total_member_count()
|
1212 |
+
*
|
1213 |
+
* Returns the total number of members for the installation.
|
1214 |
+
*
|
1215 |
+
* @package BuddyPress Core
|
1216 |
+
* @return int The total number of members.
|
1217 |
+
*/
|
1218 |
+
function bp_core_get_total_member_count() {
|
1219 |
+
global $wpdb, $bp;
|
1220 |
+
|
1221 |
+
if ( !$count = wp_cache_get( 'bp_total_member_count', 'bp' ) ) {
|
1222 |
+
$status_sql = bp_core_get_status_sql();
|
1223 |
+
$count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(ID) FROM " . CUSTOM_USER_TABLE . " WHERE {$status_sql}" ) );
|
1224 |
+
wp_cache_set( 'bp_total_member_count', $count, 'bp' );
|
1225 |
+
}
|
1226 |
+
|
1227 |
+
return apply_filters( 'bp_core_get_total_member_count', $count );
|
1228 |
+
}
|
1229 |
+
|
1230 |
/**
|
1231 |
* bp_core_is_user_spammer()
|
1232 |
*
|
1239 |
function bp_core_is_user_spammer( $user_id ) {
|
1240 |
global $wpdb;
|
1241 |
|
1242 |
+
if ( bp_core_is_multisite() )
|
1243 |
+
$is_spammer = (int) $wpdb->get_var( $wpdb->prepare( "SELECT spam FROM " . CUSTOM_USER_TABLE . " WHERE ID = %d", $user_id ) );
|
1244 |
+
else
|
1245 |
+
$is_spammer = (int) $wpdb->get_var( $wpdb->prepare( "SELECT user_status FROM " . CUSTOM_USER_TABLE . " WHERE ID = %d", $user_id ) );
|
1246 |
+
|
1247 |
+
return apply_filters( 'bp_core_is_user_spammer', $is_spammer );
|
1248 |
}
|
1249 |
|
1250 |
/**
|
1278 |
return $date;
|
1279 |
}
|
1280 |
|
|
|
1281 |
/**
|
1282 |
* bp_core_add_message()
|
1283 |
*
|
1385 |
array( 1, __( 'second', 'buddypress' ), __( 'seconds', 'buddypress' ) )
|
1386 |
);
|
1387 |
|
1388 |
+
if ( !is_numeric( $older_date ) ) {
|
1389 |
+
$time_chunks = explode( ':', str_replace( ' ', ':', $older_date ) );
|
1390 |
+
$date_chunks = explode( '-', str_replace( ' ', '-', $older_date ) );
|
1391 |
+
|
1392 |
+
$older_date = gmmktime( (int)$time_chunks[1], (int)$time_chunks[2], (int)$time_chunks[3], (int)$date_chunks[1], (int)$date_chunks[2], (int)$date_chunks[0] );
|
1393 |
+
}
|
1394 |
|
1395 |
/* $newer_date will equal false if we want to know the time elapsed between a date and the current time */
|
1396 |
/* $newer_date will have a value if we want to work out time elapsed between two known dates */
|
1397 |
+
$newer_date = ( !$newer_date ) ? gmmktime( gmdate( 'H' ), gmdate( 'i' ), gmdate( 's' ), gmdate( 'n' ), gmdate( 'j' ), gmdate( 'Y' ) ) : $newer_date;
|
1398 |
|
1399 |
/* Difference in seconds */
|
1400 |
$since = $newer_date - $older_date;
|
1401 |
|
1402 |
+
/* Something went wrong with date calculation and we ended up with a negative date. */
|
1403 |
if ( 0 > $since )
|
1404 |
+
return __( 'sometime', 'buddypress' );
|
1405 |
|
1406 |
/**
|
1407 |
* We only want to output two chunks of time here, eg:
|
1427 |
$seconds2 = $chunks[$i + 1][0];
|
1428 |
$name2 = $chunks[$i + 1][1];
|
1429 |
|
|
|
|
|
1430 |
if ( ( $count2 = floor( ( $since - ( $seconds * $count ) ) / $seconds2 ) ) != 0 ) {
|
1431 |
/* Add to output var */
|
1432 |
$output .= ( 1 == $count2 ) ? _c( ',|Separator in time since', 'buddypress' ) . ' 1 '. $chunks[$i + 1][1] : _c( ',|Separator in time since', 'buddypress' ) . ' ' . $count2 . ' ' . $chunks[$i + 1][2];
|
1459 |
|
1460 |
$activity = get_usermeta( $bp->loggedin_user->id, 'last_activity' );
|
1461 |
|
1462 |
+
if ( !is_numeric( $activity ) )
|
1463 |
+
$activity = strtotime( $activity );
|
1464 |
+
|
1465 |
+
if ( '' == $activity || strtotime( gmdate( "Y-m-d H:i:s" ) ) >= strtotime( '+5 minutes', $activity ) )
|
1466 |
+
update_usermeta( $bp->loggedin_user->id, 'last_activity', gmdate( "Y-m-d H:i:s" ) );
|
1467 |
}
|
1468 |
add_action( 'wp_head', 'bp_core_record_activity' );
|
1469 |
|
1483 |
if ( !$last_activity_date || empty( $last_activity_date ) ) {
|
1484 |
$last_active = __( 'not recently active', 'buddypress' );
|
1485 |
} else {
|
1486 |
+
$last_active = sprintf( $string, bp_core_time_since( $last_activity_date ) );
|
|
|
|
|
|
|
|
|
|
|
|
|
1487 |
}
|
1488 |
|
1489 |
+
return apply_filters( 'bp_core_get_last_activity', $last_active, $last_activity_date, $string );
|
1490 |
}
|
1491 |
|
1492 |
+
function bp_core_number_format( $number, $decimals = false ) {
|
1493 |
+
/* Check we actually have a number first. */
|
1494 |
+
if ( empty( $number ) )
|
1495 |
+
return $number;
|
1496 |
+
|
1497 |
+
return apply_filters( 'bp_core_bp_core_number_format', number_format( $number, $decimals ), $number, $decimals );
|
1498 |
+
}
|
1499 |
|
1500 |
/**
|
1501 |
* bp_core_get_all_posts_for_user()
|
1513 |
if ( !$user_id )
|
1514 |
$user_id = $bp->displayed_user->id;
|
1515 |
|
1516 |
+
return apply_filters( 'bp_core_get_all_posts_for_user', $wpdb->get_col( $wpdb->prepare( "SELECT post_id FROM $wpdb->posts WHERE post_author = %d AND post_status = 'publish' AND post_type = 'post'", $user_id ) ) );
|
1517 |
}
|
1518 |
|
|
|
1519 |
/**
|
1520 |
* bp_core_get_site_path()
|
1521 |
*
|
1526 |
* @uses bp_core_get_userlink_by_email() Fetches a userlink via email address.
|
1527 |
*/
|
1528 |
function bp_core_get_site_path() {
|
1529 |
+
global $bp, $current_site;
|
1530 |
+
|
1531 |
+
if ( bp_core_is_multisite() )
|
1532 |
+
$site_path = $current_site->path;
|
1533 |
+
else {
|
1534 |
+
$site_path = (array) explode( '/', site_url() );
|
1535 |
+
|
1536 |
+
if ( count( $site_path ) < 2 )
|
1537 |
+
$site_path = '/';
|
1538 |
+
else {
|
1539 |
+
/* Unset the first three segments (http(s)://domain.com part) */
|
1540 |
+
unset( $site_path[0] );
|
1541 |
+
unset( $site_path[1] );
|
1542 |
+
unset( $site_path[2] );
|
1543 |
+
|
1544 |
+
$site_path = '/' . implode( '/', $site_path ) . '/';
|
1545 |
+
}
|
1546 |
+
}
|
1547 |
+
|
1548 |
+
return apply_filters( 'bp_core_get_site_path', $site_path );
|
1549 |
+
}
|
1550 |
+
|
1551 |
+
/**
|
1552 |
+
* bp_core_get_site_options()
|
1553 |
+
*
|
1554 |
+
* BuddyPress uses site options to store configuration settings. Many of these settings are needed
|
1555 |
+
* at run time. Instead of fetching them all and adding many initial queries to each page load, let's fetch
|
1556 |
+
* them all in one go.
|
1557 |
+
*
|
1558 |
+
* @package BuddyPress Core
|
1559 |
+
*/
|
1560 |
+
function bp_core_get_site_options() {
|
1561 |
+
global $bp, $wpdb;
|
1562 |
+
|
1563 |
+
$options = apply_filters( 'bp_core_site_options', array(
|
1564 |
+
'bp-core-db-version',
|
1565 |
+
'bp-activity-db-version',
|
1566 |
+
'bp-blogs-db-version',
|
1567 |
+
'bp-friends-db-version',
|
1568 |
+
'bp-groups-db-version',
|
1569 |
+
'bp-messages-db-version',
|
1570 |
+
'bp-xprofile-db-version',
|
1571 |
+
'bp-deactivated-components',
|
1572 |
+
'bp-blogs-first-install',
|
1573 |
+
'bp-disable-blog-forum-comments',
|
1574 |
+
'bp-xprofile-base-group-name',
|
1575 |
+
'bp-xprofile-fullname-field-name',
|
1576 |
+
'bp-disable-profile-sync',
|
1577 |
+
'bp-disable-avatar-uploads',
|
1578 |
+
'bp-disable-account-deletion',
|
1579 |
+
'bp-disable-forum-directory',
|
1580 |
+
'bp-disable-blogforum-comments',
|
1581 |
+
'bb-config-location',
|
1582 |
+
'hide-loggedout-adminbar',
|
1583 |
+
|
1584 |
+
/* Useful WordPress settings used often */
|
1585 |
+
'user-avatar-default',
|
1586 |
+
'tags_blog_id',
|
1587 |
+
'registration',
|
1588 |
+
'fileupload_maxk'
|
1589 |
+
) );
|
1590 |
+
|
1591 |
+
$meta_keys = "'" . implode( "','", (array)$options ) ."'";
|
1592 |
+
|
1593 |
+
if ( bp_core_is_multisite() )
|
1594 |
+
$meta = $wpdb->get_results( "SELECT meta_key AS name, meta_value AS value FROM {$wpdb->sitemeta} WHERE meta_key IN ({$meta_keys})" );
|
1595 |
+
else
|
1596 |
+
$meta = $wpdb->get_results( "SELECT option_name AS name, option_value AS value FROM {$wpdb->options} WHERE option_name IN ({$meta_keys})" );
|
1597 |
+
|
1598 |
+
$site_options = array();
|
1599 |
+
if ( !empty( $meta ) ) {
|
1600 |
+
foreach( (array)$meta as $meta_item )
|
1601 |
+
$site_options[$meta_item->name] = $meta_item->value;
|
1602 |
+
}
|
1603 |
|
1604 |
+
return apply_filters( 'bp_core_get_site_options', $site_options );
|
1605 |
}
|
1606 |
|
1607 |
/**
|
1657 |
$bp_illegal_names = $bp->root_components;
|
1658 |
|
1659 |
if ( is_array( $current ) ) {
|
1660 |
+
foreach( (array)$bp_illegal_names as $bp_illegal_name ) {
|
1661 |
if ( !in_array( $bp_illegal_name, $current ) )
|
1662 |
$current[] = $bp_illegal_name;
|
1663 |
}
|
1680 |
* @return The blog name for the root blog
|
1681 |
*/
|
1682 |
function bp_core_email_from_name_filter() {
|
1683 |
+
return apply_filters( 'bp_core_email_from_name_filter', get_blog_option( BP_ROOT_BLOG, 'blogname' ) );
|
1684 |
}
|
1685 |
add_filter( 'wp_mail_from_name', 'bp_core_email_from_name_filter' );
|
1686 |
|
1695 |
* @return noreply@sitedomain email address
|
1696 |
*/
|
1697 |
function bp_core_email_from_address_filter() {
|
1698 |
+
$domain = (array) explode( '/', site_url() );
|
1699 |
+
|
1700 |
+
return apply_filters( 'bp_core_email_from_address_filter', __( 'noreply', 'buddypress' ) . '@' . $domain[2] );
|
1701 |
}
|
1702 |
add_filter( 'wp_mail_from', 'bp_core_email_from_address_filter' );
|
1703 |
|
|
|
1704 |
/**
|
1705 |
* bp_core_delete_account()
|
1706 |
*
|
1713 |
* @uses wpmu_delete_user() Deletes a user from the system.
|
1714 |
*/
|
1715 |
function bp_core_delete_account( $user_id = false ) {
|
1716 |
+
global $bp, $wpdb;
|
1717 |
|
1718 |
if ( !$user_id )
|
1719 |
$user_id = $bp->loggedin_user->id;
|
1723 |
return false;
|
1724 |
|
1725 |
/* Site admins should not be allowed to be deleted */
|
1726 |
+
if ( bp_core_is_multisite() && is_site_admin( bp_core_get_username( $user_id ) ) )
|
1727 |
return false;
|
1728 |
|
1729 |
+
if ( bp_core_is_multisite() && function_exists('wpmu_delete_user') ) {
|
1730 |
+
require_once( ABSPATH . '/wp-admin/includes/mu.php' );
|
1731 |
+
require_once( ABSPATH . '/wp-admin/includes/user.php' );
|
1732 |
+
|
1733 |
+
return wpmu_delete_user( $user_id );
|
1734 |
+
}
|
1735 |
|
1736 |
+
require_once( ABSPATH . '/wp-admin/includes/user.php' );
|
1737 |
+
return wp_delete_user( $user_id );
|
1738 |
}
|
1739 |
|
1740 |
|
1842 |
function bp_core_print_generation_time() {
|
1843 |
global $wpdb;
|
1844 |
?>
|
1845 |
+
|
1846 |
<!-- Generated in <?php timer_stop(1); ?> seconds. -->
|
1847 |
+
|
1848 |
<?php
|
1849 |
}
|
1850 |
add_action( 'wp_footer', 'bp_core_print_generation_time' );
|
1899 |
/**
|
1900 |
* bp_core_boot_spammer()
|
1901 |
*
|
1902 |
+
* When a user logs in, check if they have been marked as a spammer. If yes then simply
|
1903 |
* redirect them to the home page and stop them from logging in.
|
1904 |
*
|
1905 |
* @package BuddyPress Core
|
1906 |
+
* @param $auth_obj The WP authorization object
|
1907 |
+
* @param $username The username of the user logging in.
|
1908 |
+
* @uses get_userdatabylogin() Get the userdata object for a user based on their username
|
1909 |
+
* @uses bp_core_redirect() Safe redirect to a page
|
1910 |
+
* @return $auth_obj If the user is not a spammer, return the authorization object
|
1911 |
*/
|
1912 |
function bp_core_boot_spammer( $auth_obj, $username ) {
|
1913 |
global $bp;
|
1916 |
|
1917 |
if ( (int)$user->spam )
|
1918 |
bp_core_redirect( $bp->root_domain );
|
1919 |
+
else
|
1920 |
+
return $auth_obj;
|
1921 |
}
|
1922 |
add_filter( 'authenticate', 'bp_core_boot_spammer', 11, 2 );
|
1923 |
|
1976 |
}
|
1977 |
add_action( 'in_plugin_update_message-buddypress/bp-loader.php', 'bp_core_update_message' );
|
1978 |
|
1979 |
+
/**
|
1980 |
+
* bp_core_filter_parent_theme()
|
1981 |
+
*
|
1982 |
+
* Remove social network parent theme from the theme list.
|
1983 |
+
*
|
1984 |
+
* @package BuddyPress Core
|
1985 |
+
*/
|
1986 |
+
function bp_core_filter_parent_theme() {
|
1987 |
+
global $wp_themes, $pagenow;
|
1988 |
+
|
1989 |
+
if ( is_admin() && 'themes.php' == $pagenow )
|
1990 |
+
$wp_themes = get_themes();
|
1991 |
+
|
1992 |
+
unset( $wp_themes['BuddyPress Classic Parent'] );
|
1993 |
+
}
|
1994 |
+
add_filter( 'admin_menu', 'bp_core_filter_parent_theme' );
|
1995 |
+
|
1996 |
+
/**
|
1997 |
+
* bp_core_allow_default_theme()
|
1998 |
+
*
|
1999 |
+
* On multiblog installations you must first allow themes to be activated and show
|
2000 |
+
* up on the theme selection screen. This function will let the BuddyPress bundled
|
2001 |
+
* themes show up on the root blog selection screen and bypass this step. It also
|
2002 |
+
* means that the themes won't show for selection on other blogs.
|
2003 |
+
*
|
2004 |
+
* @package BuddyPress Core
|
2005 |
+
*/
|
2006 |
+
function bp_core_allow_default_theme( $themes ) {
|
2007 |
+
global $bp, $current_blog;
|
2008 |
+
|
2009 |
+
if ( !is_site_admin() )
|
2010 |
+
return $themes;
|
2011 |
+
|
2012 |
+
if ( $current_blog->ID == $bp->root_blog ) {
|
2013 |
+
$themes['bp-default'] = 1;
|
2014 |
+
$themes['bp-classic'] = 1;
|
2015 |
+
}
|
2016 |
+
|
2017 |
+
return $themes;
|
2018 |
+
}
|
2019 |
+
add_filter( 'allowed_themes', 'bp_core_allow_default_theme' );
|
2020 |
+
|
2021 |
+
/**
|
2022 |
+
* bp_core_activation_notice()
|
2023 |
+
*
|
2024 |
+
* When BuddyPress is activated we must make sure that mod_rewrite is enabled.
|
2025 |
+
* We must also make sure a BuddyPress compatible theme is enabled. This function
|
2026 |
+
* will show helpful messages to the administrator.
|
2027 |
+
*
|
2028 |
+
* @package BuddyPress Core
|
2029 |
+
*/
|
2030 |
+
function bp_core_activation_notice() {
|
2031 |
+
global $wp_rewrite, $current_blog, $bp;
|
2032 |
+
|
2033 |
+
if ( isset( $_POST['permalink_structure'] ) )
|
2034 |
+
return false;
|
2035 |
+
|
2036 |
+
if ( !is_site_admin() )
|
2037 |
+
return false;
|
2038 |
+
|
2039 |
+
if ( !empty( $current_blog ) ) {
|
2040 |
+
if ( $current_blog->blog_id != BP_ROOT_BLOG )
|
2041 |
+
return false;
|
2042 |
+
}
|
2043 |
+
|
2044 |
+
if ( empty( $wp_rewrite->permalink_structure ) ) { ?>
|
2045 |
+
<div id="message" class="updated fade">
|
2046 |
+
<p><?php printf( __( '<strong>BuddyPress is almost ready</strong>. You must <a href="%s">update your permalink structure</a> to something other than the default for it to work.', 'buddypress' ), admin_url( 'options-permalink.php' ) ) ?></p>
|
2047 |
+
</div><?php
|
2048 |
+
} else {
|
2049 |
+
/* Get current theme info */
|
2050 |
+
$ct = current_theme_info();
|
2051 |
+
|
2052 |
+
if ( !in_array( 'buddypress', (array)$ct->tags ) ) { ?>
|
2053 |
+
<div id="message" class="updated fade">
|
2054 |
+
<p style="line-height: 150%"><?php printf( __( "<strong>BuddyPress is ready</strong>. You'll need to <a href='%s'>activate a BuddyPress compatible theme</a> to take advantage of all of the features. We've bundled a default theme, but you can always <a href='%s'>install some other compatible themes</a>.", 'buddypress' ), admin_url( 'themes.php' ), admin_url( 'theme-install.php?type=tag&s=buddypress&tab=search' ) ) ?></p>
|
2055 |
+
</div><?php
|
2056 |
+
}
|
2057 |
+
}
|
2058 |
+
}
|
2059 |
+
add_action( 'admin_notices', 'bp_core_activation_notice' );
|
2060 |
+
|
2061 |
+
/**
|
2062 |
+
* bp_core_filter_comments()
|
2063 |
+
*
|
2064 |
+
* Filter the blog post comments array and insert BuddyPress URLs for users.
|
2065 |
+
*
|
2066 |
+
* @package BuddyPress Core
|
2067 |
+
*/
|
2068 |
+
function bp_core_filter_comments( $comments, $post_id ) {
|
2069 |
+
global $wpdb;
|
2070 |
+
|
2071 |
+
foreach( (array)$comments as $comment ) {
|
2072 |
+
if ( $comment->user_id )
|
2073 |
+
$user_ids[] = $comment->user_id;
|
2074 |
+
}
|
2075 |
+
|
2076 |
+
if ( empty( $user_ids ) )
|
2077 |
+
return $comments;
|
2078 |
+
|
2079 |
+
$user_ids = implode( ',', $user_ids );
|
2080 |
+
|
2081 |
+
if ( !$userdata = $wpdb->get_results( $wpdb->prepare( "SELECT ID as user_id, user_login, user_nicename FROM {$wpdb->users} WHERE ID IN ({$user_ids})" ) ) )
|
2082 |
+
return $comments;
|
2083 |
+
|
2084 |
+
foreach( (array)$userdata as $user )
|
2085 |
+
$users[$user->user_id] = bp_core_get_user_domain( $user->user_id, $user->user_nicename, $user->user_login );
|
2086 |
+
|
2087 |
+
foreach( (array)$comments as $i => $comment ) {
|
2088 |
+
if ( !empty( $comment->user_id ) ) {
|
2089 |
+
if ( !empty( $users[$comment->user_id] ) )
|
2090 |
+
$comments[$i]->comment_author_url = $users[$comment->user_id];
|
2091 |
+
}
|
2092 |
+
}
|
2093 |
+
|
2094 |
+
return $comments;
|
2095 |
+
}
|
2096 |
+
add_filter( 'comments_array', 'bp_core_filter_comments', 10, 2 );
|
2097 |
+
|
2098 |
+
/**
|
2099 |
+
* bp_core_login_redirect()
|
2100 |
+
*
|
2101 |
+
* When a user logs in, always redirect them back to the previous page. NOT the admin area.
|
2102 |
+
*
|
2103 |
+
* @package BuddyPress Core
|
2104 |
+
*/
|
2105 |
+
function bp_core_login_redirect( $redirect_to ) {
|
2106 |
+
global $bp, $current_blog;
|
2107 |
+
|
2108 |
+
if ( bp_core_is_multisite() && $current_blog->blog_id != BP_ROOT_BLOG )
|
2109 |
+
return $redirect_to;
|
2110 |
+
|
2111 |
+
if ( !empty( $_REQUEST['redirect_to'] ) && strpos( $_REQUEST['redirect_to'], 'wp-admin' ) )
|
2112 |
+
return $redirect_to;
|
2113 |
+
|
2114 |
+
if ( false === strpos( wp_get_referer(), 'wp-login.php' ) && false === strpos( wp_get_referer(), 'activate' ) && empty( $_REQUEST['nr'] ) )
|
2115 |
+
return wp_get_referer();
|
2116 |
+
|
2117 |
+
return $bp->root_domain;
|
2118 |
+
}
|
2119 |
+
add_filter( 'login_redirect', 'bp_core_login_redirect' );
|
2120 |
+
|
2121 |
+
|
2122 |
+
/********************************************************************************
|
2123 |
+
* Custom Actions
|
2124 |
+
*
|
2125 |
+
* Functions to set up custom BuddyPress actions that all other components can
|
2126 |
+
* hook in to.
|
2127 |
+
*/
|
2128 |
+
|
2129 |
+
/* Allow core components and dependent plugins to set globals */
|
2130 |
+
function bp_setup_globals() {
|
2131 |
+
do_action( 'bp_setup_globals' );
|
2132 |
+
}
|
2133 |
+
add_action( 'plugins_loaded', 'bp_setup_globals', 5 );
|
2134 |
+
|
2135 |
+
/* Allow core components and dependent plugins to set root components */
|
2136 |
+
function bp_setup_root_components() {
|
2137 |
+
do_action( 'bp_setup_root_components' );
|
2138 |
+
}
|
2139 |
+
add_action( 'plugins_loaded', 'bp_setup_root_components', 2 );
|
2140 |
+
|
2141 |
+
/* Allow core components and dependent plugins to set their nav */
|
2142 |
+
function bp_setup_nav() {
|
2143 |
+
do_action( 'bp_setup_nav' );
|
2144 |
+
}
|
2145 |
+
add_action( 'plugins_loaded', 'bp_setup_nav' );
|
2146 |
+
|
2147 |
+
/* Allow core components and dependent plugins to register widgets */
|
2148 |
+
function bp_setup_widgets() {
|
2149 |
+
do_action( 'bp_register_widgets' );
|
2150 |
+
}
|
2151 |
+
add_action( 'plugins_loaded', 'bp_setup_widgets' );
|
2152 |
+
|
2153 |
+
|
2154 |
+
/********************************************************************************
|
2155 |
+
* Caching
|
2156 |
+
*
|
2157 |
+
* Caching functions handle the clearing of cached objects and pages on specific
|
2158 |
+
* actions throughout BuddyPress.
|
2159 |
+
*/
|
2160 |
+
|
2161 |
/**
|
2162 |
* bp_core_clear_user_object_cache()
|
2163 |
*
|
2173 |
wp_cache_delete( 'newest_users' );
|
2174 |
}
|
2175 |
|
|
|
|
|
|
|
|
|
2176 |
// List actions to clear super cached pages on, if super cache is installed
|
2177 |
add_action( 'wp_login', 'bp_core_clear_cache' );
|
|
|
|
|
2178 |
add_action( 'bp_core_render_notice', 'bp_core_clear_cache' );
|
2179 |
|
2180 |
// Remove the catch non existent blogs hook so WPMU doesn't think BuddyPress pages are non existing blogs
|
bp-core/bp-core-activation.php
CHANGED
@@ -3,11 +3,7 @@
|
|
3 |
function bp_core_screen_activation() {
|
4 |
global $bp, $wpdb;
|
5 |
|
6 |
-
if ( BP_ACTIVATION_SLUG != $bp->current_component )
|
7 |
-
return false;
|
8 |
-
|
9 |
-
/* If we are using a BuddyPress 1.0 theme ignore this. */
|
10 |
-
if ( file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
|
11 |
return false;
|
12 |
|
13 |
/* Check if an activation key has been passed */
|
@@ -34,7 +30,7 @@ function bp_core_screen_activation() {
|
|
34 |
if ( !empty( $signup['meta']['profile_field_ids'] ) ) {
|
35 |
$profile_field_ids = explode( ',', $signup['meta']['profile_field_ids'] );
|
36 |
|
37 |
-
foreach( $profile_field_ids as $field_id ) {
|
38 |
$current_field = $signup['meta']["field_{$field_id}"];
|
39 |
|
40 |
if ( !empty( $current_field ) )
|
@@ -48,8 +44,8 @@ function bp_core_screen_activation() {
|
|
48 |
$hashed_key = wp_hash( $_GET['key'] );
|
49 |
|
50 |
/* Check if the avatar folder exists. If it does, move rename it, move it and delete the signup avatar dir */
|
51 |
-
if ( file_exists(
|
52 |
-
@rename(
|
53 |
}
|
54 |
|
55 |
/* Record the new user in the activity streams */
|
@@ -58,14 +54,15 @@ function bp_core_screen_activation() {
|
|
58 |
|
59 |
bp_activity_add( array(
|
60 |
'user_id' => $signup['user_id'],
|
61 |
-
'
|
62 |
-
'
|
63 |
-
'
|
64 |
-
'component_action' => 'new_member'
|
65 |
) );
|
66 |
}
|
67 |
|
68 |
do_action( 'bp_core_account_activated', &$signup, $_GET['key'] );
|
|
|
|
|
69 |
bp_core_add_message( __( 'Your account is now active!', 'buddypress' ) );
|
70 |
|
71 |
$bp->activation_complete = true;
|
@@ -85,6 +82,8 @@ add_action( 'wp', 'bp_core_screen_activation', 3 );
|
|
85 |
* Since the user now chooses their password, sending it over clear-text to an
|
86 |
* email address is no longer necessary. It's also a terrible idea security wise.
|
87 |
*
|
|
|
|
|
88 |
* This will only disable the email if a custom registration template is being used.
|
89 |
*/
|
90 |
function bp_core_disable_welcome_email() {
|
@@ -93,20 +92,17 @@ function bp_core_disable_welcome_email() {
|
|
93 |
|
94 |
return false;
|
95 |
}
|
96 |
-
|
|
|
97 |
|
98 |
// Notify user of signup success.
|
99 |
function bp_core_activation_signup_blog_notification( $domain, $path, $title, $user, $user_email, $key, $meta ) {
|
100 |
global $current_site;
|
101 |
|
102 |
// Send email with activation link.
|
103 |
-
|
104 |
-
$activate_url = bp_activation_page( false ) . "?key=$key";
|
105 |
-
} else {
|
106 |
-
$activate_url = bp_activation_page( false ) ."?key=$key";
|
107 |
-
}
|
108 |
-
|
109 |
$activate_url = clean_url($activate_url);
|
|
|
110 |
$admin_email = get_site_option( "admin_email" );
|
111 |
|
112 |
if ( empty( $admin_email ) )
|
@@ -117,39 +113,49 @@ function bp_core_activation_signup_blog_notification( $domain, $path, $title, $u
|
|
117 |
$message = sprintf(__("Thanks for registering! To complete the activation of your account and blog, please click the following link:\n\n%s\n\n\n\nAfter you activate, you can visit your blog here:\n\n%s", 'buddypress' ), $activate_url, clean_url("http://{$domain}{$path}" ) );
|
118 |
$subject = '[' . $from_name . '] ' . sprintf(__('Activate %s', 'buddypress' ), clean_url('http://' . $domain . $path));
|
119 |
|
120 |
-
|
|
|
|
|
|
|
|
|
|
|
121 |
|
122 |
// Return false to stop the original WPMU function from continuing
|
123 |
return false;
|
124 |
}
|
125 |
-
|
|
|
126 |
|
127 |
function bp_core_activation_signup_user_notification( $user, $user_email, $key, $meta ) {
|
128 |
global $current_site;
|
129 |
|
130 |
-
|
131 |
-
if ( 'no' == constant( "VHOST" ) ) {
|
132 |
-
$activate_url = bp_activation_page( false ) . "?key=$key";
|
133 |
-
} else {
|
134 |
-
$activate_url = bp_activation_page( false ) ."?key=$key";
|
135 |
-
}
|
136 |
-
|
137 |
$activate_url = clean_url($activate_url);
|
138 |
$admin_email = get_site_option( "admin_email" );
|
139 |
|
140 |
if ( empty( $admin_email ) )
|
141 |
$admin_email = 'support@' . $_SERVER['SERVER_NAME'];
|
142 |
|
|
|
|
|
|
|
|
|
143 |
$from_name = ( '' == get_site_option( "site_name" ) ) ? 'WordPress' : wp_specialchars( get_site_option( "site_name" ) );
|
144 |
$message_headers = "MIME-Version: 1.0\n" . "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";
|
145 |
-
$message = sprintf(__("Thanks for registering! To complete the activation of your account please click the following link:\n\n%s\n\n", 'buddypress' ), $activate_url, clean_url("http://{$domain}{$path}" ) );
|
146 |
-
$subject = '[' . $from_name . '] ' .
|
|
|
|
|
|
|
|
|
|
|
147 |
|
148 |
-
wp_mail($
|
149 |
|
150 |
// Return false to stop the original WPMU function from continuing
|
151 |
return false;
|
152 |
}
|
153 |
-
|
|
|
154 |
|
155 |
?>
|
3 |
function bp_core_screen_activation() {
|
4 |
global $bp, $wpdb;
|
5 |
|
6 |
+
if ( !bp_core_is_multisite() || BP_ACTIVATION_SLUG != $bp->current_component )
|
|
|
|
|
|
|
|
|
7 |
return false;
|
8 |
|
9 |
/* Check if an activation key has been passed */
|
30 |
if ( !empty( $signup['meta']['profile_field_ids'] ) ) {
|
31 |
$profile_field_ids = explode( ',', $signup['meta']['profile_field_ids'] );
|
32 |
|
33 |
+
foreach( (array)$profile_field_ids as $field_id ) {
|
34 |
$current_field = $signup['meta']["field_{$field_id}"];
|
35 |
|
36 |
if ( !empty( $current_field ) )
|
44 |
$hashed_key = wp_hash( $_GET['key'] );
|
45 |
|
46 |
/* Check if the avatar folder exists. If it does, move rename it, move it and delete the signup avatar dir */
|
47 |
+
if ( file_exists( BP_AVATAR_UPLOAD_PATH . '/avatars/signups/' . $hashed_key ) ) {
|
48 |
+
@rename( BP_AVATAR_UPLOAD_PATH . '/avatars/signups/' . $hashed_key, BP_AVATAR_UPLOAD_PATH . '/avatars/' . $signup['user_id'] );
|
49 |
}
|
50 |
|
51 |
/* Record the new user in the activity streams */
|
54 |
|
55 |
bp_activity_add( array(
|
56 |
'user_id' => $signup['user_id'],
|
57 |
+
'action' => apply_filters( 'bp_core_activity_registered_member_action', sprintf( __( '%s became a registered member', 'buddypress' ), $userlink ), $signup['user_id'] ),
|
58 |
+
'component' => 'profile',
|
59 |
+
'type' => 'new_member'
|
|
|
60 |
) );
|
61 |
}
|
62 |
|
63 |
do_action( 'bp_core_account_activated', &$signup, $_GET['key'] );
|
64 |
+
wp_cache_delete( 'bp_total_member_count', 'bp' );
|
65 |
+
|
66 |
bp_core_add_message( __( 'Your account is now active!', 'buddypress' ) );
|
67 |
|
68 |
$bp->activation_complete = true;
|
82 |
* Since the user now chooses their password, sending it over clear-text to an
|
83 |
* email address is no longer necessary. It's also a terrible idea security wise.
|
84 |
*
|
85 |
+
* The only exception to this is when an admin has generated an account for a user.
|
86 |
+
*
|
87 |
* This will only disable the email if a custom registration template is being used.
|
88 |
*/
|
89 |
function bp_core_disable_welcome_email() {
|
92 |
|
93 |
return false;
|
94 |
}
|
95 |
+
if ( !is_admin() && empty( $_GET['e'] ) )
|
96 |
+
add_filter( 'wpmu_welcome_user_notification', 'bp_core_disable_welcome_email' );
|
97 |
|
98 |
// Notify user of signup success.
|
99 |
function bp_core_activation_signup_blog_notification( $domain, $path, $title, $user, $user_email, $key, $meta ) {
|
100 |
global $current_site;
|
101 |
|
102 |
// Send email with activation link.
|
103 |
+
$activate_url = bp_get_activation_page() ."?key=$key";
|
|
|
|
|
|
|
|
|
|
|
104 |
$activate_url = clean_url($activate_url);
|
105 |
+
|
106 |
$admin_email = get_site_option( "admin_email" );
|
107 |
|
108 |
if ( empty( $admin_email ) )
|
113 |
$message = sprintf(__("Thanks for registering! To complete the activation of your account and blog, please click the following link:\n\n%s\n\n\n\nAfter you activate, you can visit your blog here:\n\n%s", 'buddypress' ), $activate_url, clean_url("http://{$domain}{$path}" ) );
|
114 |
$subject = '[' . $from_name . '] ' . sprintf(__('Activate %s', 'buddypress' ), clean_url('http://' . $domain . $path));
|
115 |
|
116 |
+
/* Send the message */
|
117 |
+
$to = apply_filters( 'bp_core_activation_signup_blog_notification_to', $user_email );
|
118 |
+
$subject = apply_filters( 'bp_core_activation_signup_blog_notification_subject', $subject );
|
119 |
+
$message = apply_filters( 'bp_core_activation_signup_blog_notification_message', $message );
|
120 |
+
|
121 |
+
wp_mail( $to, $subject, $message, $message_headers );
|
122 |
|
123 |
// Return false to stop the original WPMU function from continuing
|
124 |
return false;
|
125 |
}
|
126 |
+
if ( !is_admin() )
|
127 |
+
add_filter( 'wpmu_signup_blog_notification', 'bp_core_activation_signup_blog_notification', 1, 7 );
|
128 |
|
129 |
function bp_core_activation_signup_user_notification( $user, $user_email, $key, $meta ) {
|
130 |
global $current_site;
|
131 |
|
132 |
+
$activate_url = bp_get_activation_page() ."?key=$key";
|
|
|
|
|
|
|
|
|
|
|
|
|
133 |
$activate_url = clean_url($activate_url);
|
134 |
$admin_email = get_site_option( "admin_email" );
|
135 |
|
136 |
if ( empty( $admin_email ) )
|
137 |
$admin_email = 'support@' . $_SERVER['SERVER_NAME'];
|
138 |
|
139 |
+
/* If this is an admin generated activation, add a param to email the user login details */
|
140 |
+
if ( is_admin() )
|
141 |
+
$email = '&e=1';
|
142 |
+
|
143 |
$from_name = ( '' == get_site_option( "site_name" ) ) ? 'WordPress' : wp_specialchars( get_site_option( "site_name" ) );
|
144 |
$message_headers = "MIME-Version: 1.0\n" . "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";
|
145 |
+
$message = sprintf( __( "Thanks for registering! To complete the activation of your account please click the following link:\n\n%s\n\n", 'buddypress' ), $activate_url . $email, clean_url("http://{$domain}{$path}" ) );
|
146 |
+
$subject = '[' . $from_name . '] ' . __( 'Activate Your Account', 'buddypress' );
|
147 |
+
|
148 |
+
/* Send the message */
|
149 |
+
$to = apply_filters( 'bp_core_activation_signup_user_notification_to', $user_email );
|
150 |
+
$subject = apply_filters( 'bp_core_activation_signup_user_notification_subject', $subject );
|
151 |
+
$message = apply_filters( 'bp_core_activation_signup_user_notification_message', $message );
|
152 |
|
153 |
+
wp_mail( $to, $subject, $message, $message_headers );
|
154 |
|
155 |
// Return false to stop the original WPMU function from continuing
|
156 |
return false;
|
157 |
}
|
158 |
+
if ( !is_admin() || ( is_admin() && empty( $_POST['noconfirmation'] ) ) )
|
159 |
+
add_filter( 'wpmu_signup_user_notification', 'bp_core_activation_signup_user_notification', 1, 4 );
|
160 |
|
161 |
?>
|
bp-core/bp-core-admin.php
CHANGED
@@ -10,15 +10,15 @@ function bp_core_admin_settings() {
|
|
10 |
return false;
|
11 |
|
12 |
// Settings form submitted, now save the settings.
|
13 |
-
foreach ( $_POST['bp-admin'] as $key => $value ) {
|
14 |
|
15 |
if ( function_exists( 'xprofile_install' ) ) {
|
16 |
if ( 'bp-xprofile-base-group-name' == $key ) {
|
17 |
-
$wpdb->query( $wpdb->prepare( "UPDATE {$bp->profile->table_name_groups} SET name = %s WHERE
|
18 |
}
|
19 |
|
20 |
if ( 'bp-xprofile-fullname-field-name' == $key ) {
|
21 |
-
$wpdb->query( $wpdb->prepare( "UPDATE {$bp->profile->table_name_fields} SET name = %s WHERE
|
22 |
}
|
23 |
}
|
24 |
|
@@ -76,20 +76,11 @@ function bp_core_admin_settings() {
|
|
76 |
<input type="radio" name="bp-admin[bp-disable-avatar-uploads]"<?php if ( !(int)get_site_option( 'bp-disable-avatar-uploads' ) ) : ?> checked="checked"<?php endif; ?> id="bp-admin-disable-avatar-uploads-no" value="0" /> <?php _e( 'No', 'buddypress' ) ?>
|
77 |
</td>
|
78 |
</tr>
|
79 |
-
<?php if ( function_exists('bp_wire_install') ) { ?>
|
80 |
-
<tr>
|
81 |
-
<th scope="row"><?php _e( 'Allow non-friends to post on profile wires?', 'buddypress' ) ?>:</th>
|
82 |
-
<td>
|
83 |
-
<input type="radio" name="bp-admin[non-friend-wire-posting]"<?php if ( (int)get_site_option( 'non-friend-wire-posting' ) ) : ?> checked="checked"<?php endif; ?> id="bp-admin-non-friend-wire-post" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?>
|
84 |
-
<input type="radio" name="bp-admin[non-friend-wire-posting]"<?php if ( !(int)get_site_option( 'non-friend-wire-posting' ) ) : ?> checked="checked"<?php endif; ?> id="bp-admin-non-friend-wire-post" value="0" /> <?php _e( 'No', 'buddypress' ) ?>
|
85 |
-
</td>
|
86 |
-
</tr>
|
87 |
-
<?php } ?>
|
88 |
<tr>
|
89 |
<th scope="row"><?php _e( 'Disable user account deletion?', 'buddypress' ) ?>:</th>
|
90 |
<td>
|
91 |
<input type="radio" name="bp-admin[bp-disable-account-deletion]"<?php if ( (int)get_site_option( 'bp-disable-account-deletion' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-account-deletion" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?>
|
92 |
-
<input type="radio" name="bp-admin[bp-disable-account-deletion]"<?php if ( !(int)get_site_option( 'bp-disable-account-deletion' )
|
93 |
</td>
|
94 |
</tr>
|
95 |
<?php if ( function_exists( 'bp_forums_setup') ) : ?>
|
@@ -97,36 +88,18 @@ function bp_core_admin_settings() {
|
|
97 |
<th scope="row"><?php _e( 'Disable global forum directory?', 'buddypress' ) ?>:</th>
|
98 |
<td>
|
99 |
<input type="radio" name="bp-admin[bp-disable-forum-directory]"<?php if ( (int)get_site_option( 'bp-disable-forum-directory' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-forum-directory" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?>
|
100 |
-
<input type="radio" name="bp-admin[bp-disable-forum-directory]"<?php if ( !(int)get_site_option( 'bp-disable-forum-directory' )
|
101 |
</td>
|
102 |
</tr>
|
103 |
<?php endif; ?>
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
<
|
108 |
-
<
|
109 |
-
<
|
110 |
-
|
111 |
-
|
112 |
-
for ( $i = 0; $i < count($themes); $i++ ) {
|
113 |
-
if ( $themes[$i]['template'] == get_site_option( 'active-member-theme' ) ) {
|
114 |
-
$selected = ' selected="selected"';
|
115 |
-
} else {
|
116 |
-
$selected = '';
|
117 |
-
}
|
118 |
-
?>
|
119 |
-
<option<?php echo $selected ?> value="<?php echo $themes[$i]['template'] ?>"><?php echo $themes[$i]['name'] ?> (<?php echo $themes[$i]['version'] ?>)</option>
|
120 |
-
<?php } ?>
|
121 |
-
</select>
|
122 |
-
</td>
|
123 |
-
</tr>
|
124 |
-
<?php else : ?>
|
125 |
-
<?php if ( '' == locate_template( array( 'registration/register.php' ), false ) && $current_blog->blog_id == BP_ROOT_BLOG ) : ?>
|
126 |
-
<div class="error">
|
127 |
-
<p><?php _e( '<strong>Your currently active theme is not BuddyPress enabled.</strong><p style="margin: 2px 0">Visit <a href="http://buddypress.org/extend/themes/">http://buddypress.org/extend/themes/</a> to browse themes that include support for BuddyPress features.</p>', 'buddypress' ) ?></p>
|
128 |
-
</div>
|
129 |
-
<?php endif; ?>
|
130 |
<?php endif; ?>
|
131 |
|
132 |
<tr>
|
@@ -170,7 +143,7 @@ function bp_core_admin_component_setup() {
|
|
170 |
return false;
|
171 |
|
172 |
// Settings form submitted, now save the settings.
|
173 |
-
foreach ( $_POST['bp_components'] as $key => $value ) {
|
174 |
if ( !(int) $value )
|
175 |
$disabled[$key] = 1;
|
176 |
}
|
@@ -190,14 +163,7 @@ function bp_core_admin_component_setup() {
|
|
190 |
|
191 |
<form action="" method="post" id="bp-admin-component-form">
|
192 |
|
193 |
-
<p>
|
194 |
-
<?php _e(
|
195 |
-
'By default, all BuddyPress components are enabled. You can selectively disable any of the
|
196 |
-
components by using the form below. Your BuddyPress installation will continue to function, however
|
197 |
-
the features of the disabled components will no longer be accessible to
|
198 |
-
anyone using the site.
|
199 |
-
', 'buddypress' )?>
|
200 |
-
</p>
|
201 |
|
202 |
<?php $disabled_components = get_site_option( 'bp-deactivated-components' ); ?>
|
203 |
|
@@ -205,14 +171,14 @@ function bp_core_admin_component_setup() {
|
|
205 |
<tbody>
|
206 |
<?php if ( file_exists( BP_PLUGIN_DIR . '/bp-activity.php') ) : ?>
|
207 |
<tr>
|
208 |
-
<td><h3><?php _e( 'Activity Streams', 'buddypress' ) ?></h3><p><?php _e( '
|
209 |
<td>
|
210 |
<input type="radio" name="bp_components[bp-activity.php]" value="1"<?php if ( !isset( $disabled_components['bp-activity.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Enabled', 'buddypress' ) ?>
|
211 |
<input type="radio" name="bp_components[bp-activity.php]" value="0"<?php if ( isset( $disabled_components['bp-activity.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Disabled', 'buddypress' ) ?>
|
212 |
</td>
|
213 |
</tr>
|
214 |
<?php endif; ?>
|
215 |
-
<?php if ( file_exists( BP_PLUGIN_DIR . '/bp-blogs.php') ) : ?>
|
216 |
<tr>
|
217 |
<td><h3><?php _e( 'Blog Tracking', 'buddypress' ) ?></h3><p><?php _e( 'Tracks blogs, blog posts and blogs comments for a user across a WPMU installation.', 'buddypress' ) ?></p></td>
|
218 |
<td>
|
@@ -257,15 +223,6 @@ function bp_core_admin_component_setup() {
|
|
257 |
</td>
|
258 |
</tr>
|
259 |
<?php endif; ?>
|
260 |
-
<?php if ( file_exists( BP_PLUGIN_DIR . '/bp-wire.php') ) : ?>
|
261 |
-
<tr>
|
262 |
-
<td><h3><?php _e( 'Comment Wire', 'buddypress' ) ?></h3><p><?php _e( 'Let users leave a comment on groups, profiles and custom components.', 'buddypress' ) ?></p></td>
|
263 |
-
<td>
|
264 |
-
<input type="radio" name="bp_components[bp-wire.php]" value="1"<?php if ( !isset( $disabled_components['bp-wire.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Enabled', 'buddypress' ) ?>
|
265 |
-
<input type="radio" name="bp_components[bp-wire.php]" value="0"<?php if ( isset( $disabled_components['bp-wire.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Disabled', 'buddypress' ) ?>
|
266 |
-
</td>
|
267 |
-
</tr>
|
268 |
-
<?php endif; ?>
|
269 |
<?php if ( file_exists( BP_PLUGIN_DIR . '/bp-xprofile.php') ) : ?>
|
270 |
<tr>
|
271 |
<td><h3><?php _e( 'Extended Profiles', 'buddypress' ) ?></h3><p><?php _e( 'Activates customizable profiles and avatars for site users.', 'buddypress' ) ?></p></td>
|
@@ -275,15 +232,6 @@ function bp_core_admin_component_setup() {
|
|
275 |
</td>
|
276 |
</tr>
|
277 |
<?php endif; ?>
|
278 |
-
<?php if ( file_exists( BP_PLUGIN_DIR . '/bp-status.php') ) : ?>
|
279 |
-
<tr>
|
280 |
-
<td><h3><?php _e( 'Status Updates', 'buddypress' ) ?></h3><p><?php _e( 'Allow users to post status updates.', 'buddypress' ) ?></p></td>
|
281 |
-
<td width="45%">
|
282 |
-
<input type="radio" name="bp_components[bp-status.php]" value="1"<?php if ( !isset( $disabled_components['bp-status.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Enabled', 'buddypress' ) ?>
|
283 |
-
<input type="radio" name="bp_components[bp-status.php]" value="0"<?php if ( isset( $disabled_components['bp-status.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Disabled', 'buddypress' ) ?>
|
284 |
-
</td>
|
285 |
-
</tr>
|
286 |
-
<?php endif; ?>
|
287 |
</tbody>
|
288 |
</table>
|
289 |
|
10 |
return false;
|
11 |
|
12 |
// Settings form submitted, now save the settings.
|
13 |
+
foreach ( (array)$_POST['bp-admin'] as $key => $value ) {
|
14 |
|
15 |
if ( function_exists( 'xprofile_install' ) ) {
|
16 |
if ( 'bp-xprofile-base-group-name' == $key ) {
|
17 |
+
$wpdb->query( $wpdb->prepare( "UPDATE {$bp->profile->table_name_groups} SET name = %s WHERE id = 1", $value ) );
|
18 |
}
|
19 |
|
20 |
if ( 'bp-xprofile-fullname-field-name' == $key ) {
|
21 |
+
$wpdb->query( $wpdb->prepare( "UPDATE {$bp->profile->table_name_fields} SET name = %s WHERE group_id = 1 AND id = 1", $value ) );
|
22 |
}
|
23 |
}
|
24 |
|
76 |
<input type="radio" name="bp-admin[bp-disable-avatar-uploads]"<?php if ( !(int)get_site_option( 'bp-disable-avatar-uploads' ) ) : ?> checked="checked"<?php endif; ?> id="bp-admin-disable-avatar-uploads-no" value="0" /> <?php _e( 'No', 'buddypress' ) ?>
|
77 |
</td>
|
78 |
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
<tr>
|
80 |
<th scope="row"><?php _e( 'Disable user account deletion?', 'buddypress' ) ?>:</th>
|
81 |
<td>
|
82 |
<input type="radio" name="bp-admin[bp-disable-account-deletion]"<?php if ( (int)get_site_option( 'bp-disable-account-deletion' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-account-deletion" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?>
|
83 |
+
<input type="radio" name="bp-admin[bp-disable-account-deletion]"<?php if ( !(int)get_site_option( 'bp-disable-account-deletion' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-account-deletion" value="0" /> <?php _e( 'No', 'buddypress' ) ?>
|
84 |
</td>
|
85 |
</tr>
|
86 |
<?php if ( function_exists( 'bp_forums_setup') ) : ?>
|
88 |
<th scope="row"><?php _e( 'Disable global forum directory?', 'buddypress' ) ?>:</th>
|
89 |
<td>
|
90 |
<input type="radio" name="bp-admin[bp-disable-forum-directory]"<?php if ( (int)get_site_option( 'bp-disable-forum-directory' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-forum-directory" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?>
|
91 |
+
<input type="radio" name="bp-admin[bp-disable-forum-directory]"<?php if ( !(int)get_site_option( 'bp-disable-forum-directory' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-forum-directory" value="0" /> <?php _e( 'No', 'buddypress' ) ?>
|
92 |
</td>
|
93 |
</tr>
|
94 |
<?php endif; ?>
|
95 |
+
<?php if ( function_exists( 'bp_activity_install') ) : ?>
|
96 |
+
<tr>
|
97 |
+
<th scope="row"><?php _e( 'Disable activity stream commenting on blog and forum posts?', 'buddypress' ) ?>:</th>
|
98 |
+
<td>
|
99 |
+
<input type="radio" name="bp-admin[bp-disable-blogforum-comments]"<?php if ( (int)get_site_option( 'bp-disable-blogforum-comments' ) || false === get_site_option( 'bp-disable-blogforum-comments' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-blogforum-comments" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?>
|
100 |
+
<input type="radio" name="bp-admin[bp-disable-blogforum-comments]"<?php if ( !(int)get_site_option( 'bp-disable-blogforum-comments' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-blogforum-comments" value="0" /> <?php _e( 'No', 'buddypress' ) ?>
|
101 |
+
</td>
|
102 |
+
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
103 |
<?php endif; ?>
|
104 |
|
105 |
<tr>
|
143 |
return false;
|
144 |
|
145 |
// Settings form submitted, now save the settings.
|
146 |
+
foreach ( (array)$_POST['bp_components'] as $key => $value ) {
|
147 |
if ( !(int) $value )
|
148 |
$disabled[$key] = 1;
|
149 |
}
|
163 |
|
164 |
<form action="" method="post" id="bp-admin-component-form">
|
165 |
|
166 |
+
<p><?php _e('By default, all BuddyPress components are enabled. You can selectively disable any of the components by using the form below. Your BuddyPress installation will continue to function, however the features of the disabled components will no longer be accessible to anyone using the site.', 'buddypress' ) ?></p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
167 |
|
168 |
<?php $disabled_components = get_site_option( 'bp-deactivated-components' ); ?>
|
169 |
|
171 |
<tbody>
|
172 |
<?php if ( file_exists( BP_PLUGIN_DIR . '/bp-activity.php') ) : ?>
|
173 |
<tr>
|
174 |
+
<td><h3><?php _e( 'Activity Streams', 'buddypress' ) ?></h3><p><?php _e( 'Allow users to post activity updates and track all activity across the entire site.', 'buddypress' ) ?></p></td>
|
175 |
<td>
|
176 |
<input type="radio" name="bp_components[bp-activity.php]" value="1"<?php if ( !isset( $disabled_components['bp-activity.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Enabled', 'buddypress' ) ?>
|
177 |
<input type="radio" name="bp_components[bp-activity.php]" value="0"<?php if ( isset( $disabled_components['bp-activity.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Disabled', 'buddypress' ) ?>
|
178 |
</td>
|
179 |
</tr>
|
180 |
<?php endif; ?>
|
181 |
+
<?php if ( file_exists( BP_PLUGIN_DIR . '/bp-blogs.php') && bp_core_is_multisite() ) : ?>
|
182 |
<tr>
|
183 |
<td><h3><?php _e( 'Blog Tracking', 'buddypress' ) ?></h3><p><?php _e( 'Tracks blogs, blog posts and blogs comments for a user across a WPMU installation.', 'buddypress' ) ?></p></td>
|
184 |
<td>
|
223 |
</td>
|
224 |
</tr>
|
225 |
<?php endif; ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
226 |
<?php if ( file_exists( BP_PLUGIN_DIR . '/bp-xprofile.php') ) : ?>
|
227 |
<tr>
|
228 |
<td><h3><?php _e( 'Extended Profiles', 'buddypress' ) ?></h3><p><?php _e( 'Activates customizable profiles and avatars for site users.', 'buddypress' ) ?></p></td>
|
232 |
</td>
|
233 |
</tr>
|
234 |
<?php endif; ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
235 |
</tbody>
|
236 |
</table>
|
237 |
|
bp-core/bp-core-adminbar.php
CHANGED
@@ -1,17 +1,17 @@
|
|
1 |
<?php
|
2 |
|
3 |
function bp_core_admin_bar() {
|
4 |
-
global $bp, $wpdb, $current_blog
|
5 |
|
6 |
if ( defined( 'BP_DISABLE_ADMIN_BAR' ) )
|
7 |
return false;
|
8 |
|
9 |
-
$
|
10 |
-
|
11 |
-
if ( (int)get_site_option( 'hide-loggedout-adminbar' ) && !is_user_logged_in() )
|
12 |
return false;
|
13 |
|
14 |
-
|
|
|
|
|
15 |
|
16 |
// **** Do bp-adminbar-logo Actions ********
|
17 |
do_action( 'bp_adminbar_logo' );
|
@@ -22,7 +22,9 @@ function bp_core_admin_bar() {
|
|
22 |
do_action( 'bp_adminbar_menus' );
|
23 |
|
24 |
echo '</ul>';
|
25 |
-
echo
|
|
|
|
|
26 |
}
|
27 |
|
28 |
// **** Default BuddyPress admin bar logo ********
|
@@ -36,213 +38,179 @@ function bp_adminbar_logo() {
|
|
36 |
function bp_adminbar_login_menu() {
|
37 |
global $bp;
|
38 |
|
39 |
-
if (
|
40 |
-
|
41 |
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
|
|
46 |
}
|
47 |
}
|
48 |
|
|
|
49 |
// **** "My Account" Menu ******
|
50 |
function bp_adminbar_account_menu() {
|
51 |
global $bp;
|
52 |
|
53 |
-
if ( !$bp->bp_nav )
|
54 |
return false;
|
55 |
|
56 |
-
|
57 |
|
58 |
-
|
|
|
59 |
|
60 |
-
|
61 |
-
|
|
|
|
|
62 |
|
63 |
-
|
64 |
-
$
|
65 |
-
foreach( $bp->bp_nav as $nav_item ) {
|
66 |
-
$alt = ( 0 == $counter % 2 ) ? ' class="alt"' : '';
|
67 |
|
68 |
-
|
69 |
-
echo '<
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
$
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
$sub_counter++;
|
79 |
-
}
|
80 |
-
echo '</ul>';
|
81 |
}
|
82 |
-
|
83 |
-
echo '</li>';
|
84 |
-
|
85 |
-
$counter++;
|
86 |
-
}
|
87 |
-
|
88 |
-
$alt = ( 0 == $counter % 2 ) ? ' class="alt"' : '';
|
89 |
-
|
90 |
-
if ( function_exists('wp_logout_url') ) {
|
91 |
-
echo '<li' . $alt . '><a id="bp-admin-logout" href="' . wp_logout_url(site_url()) . '">' . __( 'Log Out', 'buddypress' ) . '</a></li>';
|
92 |
-
} else {
|
93 |
-
echo '<li' . $alt . '><a id="bp-admin-logout" href="' . site_url() . '/wp-login.php?action=logout&redirect_to=' . site_url() . '">' . __( 'Log Out', 'buddypress' ) . '</a></li>';
|
94 |
}
|
95 |
|
96 |
-
echo '</ul>';
|
97 |
echo '</li>';
|
|
|
|
|
98 |
}
|
99 |
-
}
|
100 |
|
101 |
-
|
102 |
-
function get_blog_role_for_user( $user, $blog ) {
|
103 |
-
|
104 |
-
// If the user is a site admin, just display admin.
|
105 |
-
if ( is_site_admin() )
|
106 |
-
return __( 'Admin', 'buddypress');
|
107 |
-
|
108 |
-
$roles = get_usermeta( $user, 'wp_' . $blog . '_capabilities' );
|
109 |
-
|
110 |
-
if ( isset( $roles['subscriber'] ) )
|
111 |
-
$role = __( 'Subscriber', 'buddypress' );
|
112 |
-
elseif ( isset( $roles['contributor'] ) )
|
113 |
-
$role = __( 'Contributor', 'buddypress' );
|
114 |
-
elseif ( isset( $roles['author'] ) )
|
115 |
-
$role = __( 'Author', 'buddypress' );
|
116 |
-
elseif ( isset( $roles['editor'] ) )
|
117 |
-
$role = __( 'Editor', 'buddypress' );
|
118 |
-
elseif ( isset( $roles['administrator'] ) )
|
119 |
-
$role = __( 'Admin', 'buddypress' );
|
120 |
-
else
|
121 |
-
return false;
|
122 |
|
123 |
-
|
|
|
|
|
124 |
}
|
125 |
|
126 |
// *** "My Blogs" Menu ********
|
127 |
function bp_adminbar_blogs_menu() {
|
128 |
-
|
129 |
-
global $bp;
|
130 |
-
|
131 |
-
if ( function_exists('bp_blogs_install') ) {
|
132 |
|
133 |
-
|
134 |
-
|
135 |
-
wp_cache_set( 'bp_blogs_of_user_' . $bp->loggedin_user->id, $blogs, 'bp' );
|
136 |
-
}
|
137 |
|
138 |
-
|
|
|
|
|
|
|
139 |
|
140 |
-
|
141 |
|
142 |
-
|
143 |
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
$counter = 0;
|
148 |
-
foreach( $blogs as $blog ) {
|
149 |
-
$role = get_blog_role_for_user( $bp->loggedin_user->id, $blog->userblog_id );
|
150 |
-
|
151 |
-
$alt = ( 0 == $counter % 2 ) ? ' class="alt"' : '';
|
152 |
-
echo '<li' . $alt . '>';
|
153 |
-
echo '<a href="' . $blog->siteurl . '">' . $blog->blogname . ' (' . $role . ')</a>';
|
154 |
-
if ( !( 'Subscriber' == $role ) ) { // then they have something to display on the flyout menu
|
155 |
-
echo '<ul>';
|
156 |
-
echo '<li class="alt"><a href="' . $blog->siteurl . '/wp-admin/">' . __('Dashboard', 'buddypress') . '</a></li>';
|
157 |
-
echo '<li><a href="' . $blog->siteurl . '/wp-admin/post-new.php">' . __('New Post', 'buddypress') . '</a></li>';
|
158 |
-
echo '<li class="alt"><a href="' . $blog->siteurl . '/wp-admin/edit.php">' . __('Manage Posts', 'buddypress') . '</a></li>';
|
159 |
-
echo '<li><a href="' . $blog->siteurl . '/wp-admin/edit-comments.php">' . __('Manage Comments', 'buddypress') . '</a></li>';
|
160 |
-
if ( 'Admin' == $role ) {
|
161 |
-
echo '<li class="alt"><a href="' . $blog->siteurl . '/wp-admin/themes.php">' . __('Switch Theme', 'buddypress') . '</a></li>';
|
162 |
-
}
|
163 |
-
echo '</ul>';
|
164 |
-
}
|
165 |
-
echo '</li>';
|
166 |
-
$counter++;
|
167 |
-
}
|
168 |
-
}
|
169 |
|
|
|
|
|
|
|
170 |
$alt = ( 0 == $counter % 2 ) ? ' class="alt"' : '';
|
171 |
|
172 |
-
|
173 |
-
|
174 |
-
echo '<a href="' . $bp->loggedin_user->domain . $bp->blogs->slug . '/create-a-blog">' . __('Create a Blog!', 'buddypress') . '</a>';
|
175 |
-
echo '</li>';
|
176 |
-
}
|
177 |
|
|
|
|
|
|
|
|
|
|
|
178 |
echo '</ul>';
|
|
|
179 |
echo '</li>';
|
|
|
180 |
}
|
181 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
182 |
}
|
183 |
|
184 |
// **** "Notifications" Menu *********
|
185 |
function bp_adminbar_notifications_menu() {
|
186 |
-
|
187 |
-
global $bp;
|
188 |
|
189 |
-
|
190 |
-
|
191 |
|
192 |
-
|
193 |
-
|
194 |
-
<?php
|
195 |
-
}
|
196 |
|
197 |
-
|
198 |
-
echo
|
199 |
-
|
200 |
-
|
201 |
-
<?php $counter = 0; ?>
|
202 |
-
<?php for ( $i = 0; $i < count($notifications); $i++ ) { ?>
|
203 |
-
<?php $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : ''; ?>
|
204 |
-
<li<?php echo $alt ?>><?php echo $notifications[$i] ?></li>
|
205 |
-
<?php $counter++; ?>
|
206 |
-
<?php } ?>
|
207 |
-
<?php } else { ?>
|
208 |
-
<li><a href="<?php echo $bp->loggedin_user->domain ?>"><?php _e( 'No new notifications.', 'buddypress' ); ?></a></li>
|
209 |
-
<?php
|
210 |
-
}
|
211 |
|
212 |
-
|
213 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
214 |
}
|
|
|
|
|
|
|
215 |
}
|
216 |
|
217 |
// **** "Blog Authors" Menu (visible when not logged in) ********
|
218 |
function bp_adminbar_authors_menu() {
|
219 |
-
global $current_blog;
|
220 |
-
|
221 |
-
if ( $current_blog->blog_id
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
echo '</ul>';
|
244 |
echo '</li>';
|
245 |
}
|
|
|
|
|
246 |
}
|
247 |
}
|
248 |
|
@@ -258,7 +226,7 @@ function bp_adminbar_random_menu() {
|
|
258 |
<li class="alt"><a href="<?php echo $bp->root_domain . '/' . $bp->groups->slug . '/?random-group' ?>"><?php _e( 'Random Group', 'buddypress' ) ?></a></li>
|
259 |
<?php endif; ?>
|
260 |
|
261 |
-
<?php if ( function_exists('bp_blogs_install') ) : ?>
|
262 |
<li><a href="<?php echo $bp->root_domain . '/' . $bp->blogs->slug . '/?random-blog' ?>"><?php _e( 'Random Blog', 'buddypress' ) ?></a></li>
|
263 |
|
264 |
<?php endif; ?>
|
@@ -267,17 +235,20 @@ function bp_adminbar_random_menu() {
|
|
267 |
</ul>
|
268 |
</li>
|
269 |
<?php
|
270 |
-
|
271 |
-
$doing_admin_bar = false;
|
272 |
}
|
273 |
|
274 |
-
|
275 |
add_action( 'bp_adminbar_logo', 'bp_adminbar_logo' );
|
276 |
add_action( 'bp_adminbar_menus', 'bp_adminbar_login_menu', 2 );
|
277 |
add_action( 'bp_adminbar_menus', 'bp_adminbar_account_menu', 4 );
|
278 |
-
|
|
|
|
|
|
|
279 |
add_action( 'bp_adminbar_menus', 'bp_adminbar_notifications_menu', 8 );
|
280 |
-
|
|
|
|
|
|
|
281 |
add_action( 'bp_adminbar_menus', 'bp_adminbar_random_menu', 100 );
|
282 |
|
283 |
add_action( 'wp_footer', 'bp_core_admin_bar', 8 );
|
1 |
<?php
|
2 |
|
3 |
function bp_core_admin_bar() {
|
4 |
+
global $bp, $wpdb, $current_blog;
|
5 |
|
6 |
if ( defined( 'BP_DISABLE_ADMIN_BAR' ) )
|
7 |
return false;
|
8 |
|
9 |
+
if ( (int)$bp->site_options['hide-loggedout-adminbar'] && !is_user_logged_in() )
|
|
|
|
|
10 |
return false;
|
11 |
|
12 |
+
$bp->doing_admin_bar = true;
|
13 |
+
|
14 |
+
echo '<div id="wp-admin-bar"><div class="padder">';
|
15 |
|
16 |
// **** Do bp-adminbar-logo Actions ********
|
17 |
do_action( 'bp_adminbar_logo' );
|
22 |
do_action( 'bp_adminbar_menus' );
|
23 |
|
24 |
echo '</ul>';
|
25 |
+
echo "</div></div><!-- #wp-admin-bar -->\n\n";
|
26 |
+
|
27 |
+
$bp->doing_admin_bar = false;
|
28 |
}
|
29 |
|
30 |
// **** Default BuddyPress admin bar logo ********
|
38 |
function bp_adminbar_login_menu() {
|
39 |
global $bp;
|
40 |
|
41 |
+
if ( is_user_logged_in() )
|
42 |
+
return false;
|
43 |
|
44 |
+
echo '<li class="bp-login no-arrow"><a href="' . $bp->root_domain . '/wp-login.php?redirect_to=' . urlencode( $bp->root_domain ) . '">' . __( 'Log In', 'buddypress' ) . '</a></li>';
|
45 |
+
|
46 |
+
// Show "Sign Up" link if user registrations are allowed
|
47 |
+
if ( bp_get_signup_allowed() ) {
|
48 |
+
echo '<li class="bp-signup no-arrow"><a href="' . bp_get_signup_page(false) . '">' . __( 'Sign Up', 'buddypress' ) . '</a></li>';
|
49 |
}
|
50 |
}
|
51 |
|
52 |
+
|
53 |
// **** "My Account" Menu ******
|
54 |
function bp_adminbar_account_menu() {
|
55 |
global $bp;
|
56 |
|
57 |
+
if ( !$bp->bp_nav || !is_user_logged_in() )
|
58 |
return false;
|
59 |
|
60 |
+
echo '<li id="bp-adminbar-account-menu"><a href="' . bp_loggedin_user_domain() . '">';
|
61 |
|
62 |
+
echo __( 'My Account', 'buddypress' ) . '</a>';
|
63 |
+
echo '<ul>';
|
64 |
|
65 |
+
/* Loop through each navigation item */
|
66 |
+
$counter = 0;
|
67 |
+
foreach( (array)$bp->bp_nav as $nav_item ) {
|
68 |
+
$alt = ( 0 == $counter % 2 ) ? ' class="alt"' : '';
|
69 |
|
70 |
+
echo '<li' . $alt . '>';
|
71 |
+
echo '<a id="bp-admin-' . $nav_item['css_id'] . '" href="' . $nav_item['link'] . '">' . $nav_item['name'] . '</a>';
|
|
|
|
|
72 |
|
73 |
+
if ( is_array( $bp->bp_options_nav[$nav_item['slug']] ) ) {
|
74 |
+
echo '<ul>';
|
75 |
+
$sub_counter = 0;
|
76 |
+
|
77 |
+
foreach( (array)$bp->bp_options_nav[$nav_item['slug']] as $subnav_item ) {
|
78 |
+
$link = str_replace( $bp->displayed_user->domain, $bp->loggedin_user->domain, $subnav_item['link'] );
|
79 |
+
$name = str_replace( $bp->displayed_user->userdata->user_login, $bp->loggedin_user->userdata->user_login, $subnav_item['name'] );
|
80 |
+
$alt = ( 0 == $sub_counter % 2 ) ? ' class="alt"' : '';
|
81 |
+
echo '<li' . $alt . '><a id="bp-admin-' . $subnav_item['css_id'] . '" href="' . $link . '">' . $name . '</a></li>';
|
82 |
+
$sub_counter++;
|
|
|
|
|
|
|
83 |
}
|
84 |
+
echo '</ul>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
}
|
86 |
|
|
|
87 |
echo '</li>';
|
88 |
+
|
89 |
+
$counter++;
|
90 |
}
|
|
|
91 |
|
92 |
+
$alt = ( 0 == $counter % 2 ) ? ' class="alt"' : '';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
|
94 |
+
echo '<li' . $alt . '><a id="bp-admin-logout" class="logout" href="' . wp_logout_url(site_url()) . '">' . __( 'Log Out', 'buddypress' ) . '</a></li>';
|
95 |
+
echo '</ul>';
|
96 |
+
echo '</li>';
|
97 |
}
|
98 |
|
99 |
// *** "My Blogs" Menu ********
|
100 |
function bp_adminbar_blogs_menu() {
|
101 |
+
global $bp;
|
|
|
|
|
|
|
102 |
|
103 |
+
if ( !is_user_logged_in() || !function_exists('bp_blogs_install') )
|
104 |
+
return false;
|
|
|
|
|
105 |
|
106 |
+
if ( !$blogs = wp_cache_get( 'bp_blogs_of_user_' . $bp->loggedin_user->id . '_inc_hidden', 'bp' ) ) {
|
107 |
+
$blogs = bp_blogs_get_blogs_for_user( $bp->loggedin_user->id, true );
|
108 |
+
wp_cache_set( 'bp_blogs_of_user_' . $bp->loggedin_user->id . '_inc_hidden', $blogs, 'bp' );
|
109 |
+
}
|
110 |
|
111 |
+
echo '<li id="bp-adminbar-blogs-menu"><a href="' . $bp->loggedin_user->domain . $bp->blogs->slug . '/my-blogs">';
|
112 |
|
113 |
+
_e( 'My Blogs', 'buddypress' );
|
114 |
|
115 |
+
echo '</a>';
|
116 |
+
echo '<ul>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
117 |
|
118 |
+
if ( is_array( $blogs['blogs'] ) && (int)$blogs['count'] ) {
|
119 |
+
$counter = 0;
|
120 |
+
foreach ( (array)$blogs['blogs'] as $blog ) {
|
121 |
$alt = ( 0 == $counter % 2 ) ? ' class="alt"' : '';
|
122 |
|
123 |
+
echo '<li' . $alt . '>';
|
124 |
+
echo '<a href="' . esc_attr( $blog->siteurl ) . '">' . esc_html( $blog->name ) . '</a>';
|
|
|
|
|
|
|
125 |
|
126 |
+
echo '<ul>';
|
127 |
+
echo '<li class="alt"><a href="' . esc_attr( $blog->siteurl ) . 'wp-admin/">' . __( 'Dashboard', 'buddypress' ) . '</a></li>';
|
128 |
+
echo '<li><a href="' . esc_attr( $blog->siteurl ) . 'wp-admin/post-new.php">' . __( 'New Post', 'buddypress' ) . '</a></li>';
|
129 |
+
echo '<li class="alt"><a href="' . esc_attr( $blog->siteurl ) . 'wp-admin/edit.php">' . __( 'Manage Posts', 'buddypress' ) . '</a></li>';
|
130 |
+
echo '<li><a href="' . esc_attr( $blog->siteurl ) . 'wp-admin/edit-comments.php">' . __( 'Manage Comments', 'buddypress' ) . '</a></li>';
|
131 |
echo '</ul>';
|
132 |
+
|
133 |
echo '</li>';
|
134 |
+
$counter++;
|
135 |
}
|
136 |
}
|
137 |
+
|
138 |
+
$alt = ( 0 == $counter % 2 ) ? ' class="alt"' : '';
|
139 |
+
|
140 |
+
if ( bp_blog_signup_enabled() ) {
|
141 |
+
echo '<li' . $alt . '>';
|
142 |
+
echo '<a href="' . $bp->root_domain . '/' . $bp->blogs->slug . '/create/">' . __( 'Create a Blog!', 'buddypress' ) . '</a>';
|
143 |
+
echo '</li>';
|
144 |
+
}
|
145 |
+
|
146 |
+
echo '</ul>';
|
147 |
+
echo '</li>';
|
148 |
}
|
149 |
|
150 |
// **** "Notifications" Menu *********
|
151 |
function bp_adminbar_notifications_menu() {
|
152 |
+
global $bp;
|
|
|
153 |
|
154 |
+
if ( !is_user_logged_in() )
|
155 |
+
return false;
|
156 |
|
157 |
+
echo '<li id="bp-adminbar-notifications-menu"><a href="' . $bp->loggedin_user->domain . '">';
|
158 |
+
_e( 'Notifications', 'buddypress' );
|
|
|
|
|
159 |
|
160 |
+
if ( $notifications = bp_core_get_notifications_for_user( $bp->loggedin_user->id ) ) { ?>
|
161 |
+
<span><?php echo count($notifications) ?></span>
|
162 |
+
<?php
|
163 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
164 |
|
165 |
+
echo '</a>';
|
166 |
+
echo '<ul>';
|
167 |
+
|
168 |
+
if ( $notifications ) { ?>
|
169 |
+
<?php $counter = 0; ?>
|
170 |
+
<?php for ( $i = 0; $i < count($notifications); $i++ ) { ?>
|
171 |
+
<?php $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : ''; ?>
|
172 |
+
<li<?php echo $alt ?>><?php echo $notifications[$i] ?></li>
|
173 |
+
<?php $counter++; ?>
|
174 |
+
<?php } ?>
|
175 |
+
<?php } else { ?>
|
176 |
+
<li><a href="<?php echo $bp->loggedin_user->domain ?>"><?php _e( 'No new notifications.', 'buddypress' ); ?></a></li>
|
177 |
+
<?php
|
178 |
}
|
179 |
+
|
180 |
+
echo '</ul>';
|
181 |
+
echo '</li>';
|
182 |
}
|
183 |
|
184 |
// **** "Blog Authors" Menu (visible when not logged in) ********
|
185 |
function bp_adminbar_authors_menu() {
|
186 |
+
global $bp, $current_blog, $wpdb;
|
187 |
+
|
188 |
+
if ( $current_blog->blog_id == BP_ROOT_BLOG || !function_exists( 'bp_blogs_install' ) )
|
189 |
+
return false;
|
190 |
+
|
191 |
+
$blog_prefix = $wpdb->get_blog_prefix( $current_blog->id );
|
192 |
+
$authors = $wpdb->get_results( "SELECT user_id, user_login, user_nicename, display_name, user_email, meta_value as caps FROM $wpdb->users u, $wpdb->usermeta um WHERE u.ID = um.user_id AND meta_key = '{$blog_prefix}capabilities' ORDER BY um.user_id" );
|
193 |
+
|
194 |
+
if ( !empty( $authors ) ) {
|
195 |
+
/* This is a blog, render a menu with links to all authors */
|
196 |
+
echo '<li id="bp-adminbar-authors-menu"><a href="/">';
|
197 |
+
_e('Blog Authors', 'buddypress');
|
198 |
+
echo '</a>';
|
199 |
+
|
200 |
+
echo '<ul class="author-list">';
|
201 |
+
foreach( (array)$authors as $author ) {
|
202 |
+
$caps = maybe_unserialize( $author->caps );
|
203 |
+
if ( isset( $caps['subscriber'] ) || isset( $caps['contributor'] ) ) continue;
|
204 |
+
|
205 |
+
echo '<li>';
|
206 |
+
echo '<a href="' . bp_core_get_user_domain( $author->user_id, $author->user_nicename, $author->user_login ) . '">';
|
207 |
+
echo bp_core_fetch_avatar( array( 'item_id' => $author->user_id, 'email' => $author->user_email, 'width' => 15, 'height' => 15 ) ) ;
|
208 |
+
echo ' ' . $author->display_name . '</a>';
|
209 |
+
echo '<div class="admin-bar-clear"></div>';
|
|
|
210 |
echo '</li>';
|
211 |
}
|
212 |
+
echo '</ul>';
|
213 |
+
echo '</li>';
|
214 |
}
|
215 |
}
|
216 |
|
226 |
<li class="alt"><a href="<?php echo $bp->root_domain . '/' . $bp->groups->slug . '/?random-group' ?>"><?php _e( 'Random Group', 'buddypress' ) ?></a></li>
|
227 |
<?php endif; ?>
|
228 |
|
229 |
+
<?php if ( function_exists('bp_blogs_install') && bp_core_is_multisite() ) : ?>
|
230 |
<li><a href="<?php echo $bp->root_domain . '/' . $bp->blogs->slug . '/?random-blog' ?>"><?php _e( 'Random Blog', 'buddypress' ) ?></a></li>
|
231 |
|
232 |
<?php endif; ?>
|
235 |
</ul>
|
236 |
</li>
|
237 |
<?php
|
|
|
|
|
238 |
}
|
239 |
|
|
|
240 |
add_action( 'bp_adminbar_logo', 'bp_adminbar_logo' );
|
241 |
add_action( 'bp_adminbar_menus', 'bp_adminbar_login_menu', 2 );
|
242 |
add_action( 'bp_adminbar_menus', 'bp_adminbar_account_menu', 4 );
|
243 |
+
|
244 |
+
if ( bp_core_is_multisite() )
|
245 |
+
add_action( 'bp_adminbar_menus', 'bp_adminbar_blogs_menu', 6 );
|
246 |
+
|
247 |
add_action( 'bp_adminbar_menus', 'bp_adminbar_notifications_menu', 8 );
|
248 |
+
|
249 |
+
if ( bp_core_is_multisite() )
|
250 |
+
add_action( 'bp_adminbar_menus', 'bp_adminbar_authors_menu', 12 );
|
251 |
+
|
252 |
add_action( 'bp_adminbar_menus', 'bp_adminbar_random_menu', 100 );
|
253 |
|
254 |
add_action( 'wp_footer', 'bp_core_admin_bar', 8 );
|
bp-core/bp-core-avatars.php
CHANGED
@@ -7,30 +7,44 @@
|
|
7 |
/***
|
8 |
* Set up the constants we need for avatar support
|
9 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
-
if ( !defined( 'BP_AVATAR_THUMB_WIDTH' ) )
|
12 |
-
|
13 |
|
14 |
-
if ( !defined( 'BP_AVATAR_THUMB_HEIGHT' ) )
|
15 |
-
|
16 |
|
17 |
-
if ( !defined( 'BP_AVATAR_FULL_WIDTH' ) )
|
18 |
-
|
19 |
|
20 |
-
if ( !defined( 'BP_AVATAR_FULL_HEIGHT' ) )
|
21 |
-
|
22 |
|
23 |
-
if ( !defined( 'BP_AVATAR_ORIGINAL_MAX_WIDTH' ) )
|
24 |
-
|
25 |
|
26 |
-
if ( !defined( 'BP_AVATAR_ORIGINAL_MAX_FILESIZE' ) )
|
27 |
-
|
|
|
|
|
|
|
|
|
28 |
|
29 |
-
if ( !defined( 'BP_AVATAR_DEFAULT' ) )
|
30 |
-
|
31 |
|
32 |
-
if ( !defined( 'BP_AVATAR_DEFAULT_THUMB' ) )
|
33 |
-
|
|
|
|
|
34 |
|
35 |
function bp_core_fetch_avatar( $args = '' ) {
|
36 |
global $bp, $current_blog;
|
@@ -45,6 +59,7 @@ function bp_core_fetch_avatar( $args = '' ) {
|
|
45 |
'class' => 'avatar',
|
46 |
'css_id' => false,
|
47 |
'alt' => __( 'Avatar Image', 'buddypress' ),
|
|
|
48 |
'no_grav' => false // If there is no avatar found, return false instead of a grav?
|
49 |
);
|
50 |
|
@@ -93,8 +108,8 @@ function bp_core_fetch_avatar( $args = '' ) {
|
|
93 |
else
|
94 |
$html_height = ( 'thumb' == $type ) ? ' height="' . BP_AVATAR_THUMB_HEIGHT . '"' : ' height="' . BP_AVATAR_FULL_HEIGHT . '"';
|
95 |
|
96 |
-
$avatar_folder_url = apply_filters( 'bp_core_avatar_folder_url',
|
97 |
-
$avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir',
|
98 |
|
99 |
/****
|
100 |
* Look for uploaded avatar first. Use it if it exists.
|
@@ -123,7 +138,7 @@ function bp_core_fetch_avatar( $args = '' ) {
|
|
123 |
if ( empty( $bp->grav_default->{$object} ) )
|
124 |
$default_grav = 'wavatar';
|
125 |
else if ( 'mystery' == $bp->grav_default->{$object} )
|
126 |
-
$default_grav = BP_PLUGIN_URL . '/bp-core/images/mystery-man.jpg';
|
127 |
else
|
128 |
$default_grav = $bp->grav_default->{$object};
|
129 |
|
@@ -131,15 +146,16 @@ function bp_core_fetch_avatar( $args = '' ) {
|
|
131 |
else if ( 'full' == $type ) $grav_size = BP_AVATAR_FULL_WIDTH;
|
132 |
else if ( 'thumb' == $type ) $grav_size = BP_AVATAR_THUMB_WIDTH;
|
133 |
|
134 |
-
if (
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
|
|
139 |
}
|
140 |
|
141 |
-
$
|
142 |
-
$gravatar = apply_filters( 'bp_gravatar_url', 'http://www.gravatar.com/avatar/' ) . md5( $
|
143 |
|
144 |
return apply_filters( 'bp_core_fetch_avatar', "<img src='{$gravatar}' alt='{$alt}' class='{$class}'{$css_id}{$html_width}{$html_height} />", $params );
|
145 |
|
@@ -186,26 +202,18 @@ function bp_core_delete_existing_avatar( $args = '' ) {
|
|
186 |
if ( !$avatar_dir ) return false;
|
187 |
}
|
188 |
|
189 |
-
|
190 |
-
/* Delete any legacy meta entries if this is a user avatar */
|
191 |
-
delete_usermeta( $item_id, 'bp_core_avatar_v1_path' );
|
192 |
-
delete_usermeta( $item_id, 'bp_core_avatar_v1' );
|
193 |
-
delete_usermeta( $item_id, 'bp_core_avatar_v2_path' );
|
194 |
-
delete_usermeta( $item_id, 'bp_core_avatar_v2' );
|
195 |
-
}
|
196 |
-
|
197 |
-
$avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', WP_CONTENT_DIR . '/blogs.dir/' . BP_ROOT_BLOG . '/files/' . $avatar_dir . '/' . $item_id, $item_id, $object, $avatar_dir );
|
198 |
|
199 |
if ( !file_exists( $avatar_folder_dir ) )
|
200 |
return false;
|
201 |
|
202 |
if ( $av_dir = opendir( $avatar_folder_dir ) ) {
|
203 |
-
|
204 |
if ( ( preg_match( "/-bpfull/", $avatar_file ) || preg_match( "/-bpthumb/", $avatar_file ) ) && '.' != $avatar_file && '..' != $avatar_file )
|
205 |
@unlink( $avatar_folder_dir . '/' . $avatar_file );
|
206 |
}
|
207 |
}
|
208 |
-
|
209 |
|
210 |
@rmdir( $avatar_folder_dir );
|
211 |
|
@@ -244,25 +252,24 @@ function bp_core_avatar_handle_upload( $file, $upload_dir_filter ) {
|
|
244 |
return false;
|
245 |
}
|
246 |
|
247 |
-
|
248 |
add_filter( 'upload_dir', $upload_dir_filter, 10, 0 );
|
249 |
|
250 |
$bp->avatar_admin->original = wp_handle_upload( $file['file'], array( 'action'=> 'bp_avatar_upload' ) );
|
251 |
|
252 |
-
|
253 |
if ( !empty( $bp->avatar_admin->original['error'] ) ) {
|
254 |
bp_core_add_message( sprintf( __( 'Upload Failed! Error was: %s', 'buddypress' ), $bp->avatar_admin->original['error'] ), 'error' );
|
255 |
return false;
|
256 |
}
|
257 |
|
258 |
-
|
259 |
-
if ( getimagesize( $bp->avatar_admin->original['file'] ) > BP_AVATAR_ORIGINAL_MAX_WIDTH )
|
260 |
$bp->avatar_admin->resized = wp_create_thumbnail( $bp->avatar_admin->original['file'], BP_AVATAR_ORIGINAL_MAX_WIDTH );
|
261 |
-
}
|
262 |
|
263 |
$bp->avatar_admin->image = new stdClass;
|
264 |
|
265 |
-
|
266 |
if ( empty( $bp->avatar_admin->resized ) )
|
267 |
$bp->avatar_admin->image->dir = $bp->avatar_admin->original['file'];
|
268 |
else {
|
@@ -270,14 +277,8 @@ function bp_core_avatar_handle_upload( $file, $upload_dir_filter ) {
|
|
270 |
@unlink( $bp->avatar_admin->original['file'] );
|
271 |
}
|
272 |
|
273 |
-
/* Check for WP_Error on what should be an image */
|
274 |
-
if ( is_wp_error( $bp->avatar_admin->image->dir ) ) {
|
275 |
-
bp_core_add_message( sprintf( __( 'Upload failed! Error was: %s', 'buddypress' ), $bp->avatar_admin->image->dir->get_error_message() ), 'error' );
|
276 |
-
return false;
|
277 |
-
}
|
278 |
-
|
279 |
/* Set the url value for the image */
|
280 |
-
$bp->avatar_admin->image->url = str_replace( WP_CONTENT_DIR,
|
281 |
|
282 |
return true;
|
283 |
}
|
@@ -308,7 +309,7 @@ function bp_core_avatar_handle_crop( $args = '' ) {
|
|
308 |
if ( !$item_id )
|
309 |
$avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', WP_CONTENT_DIR . dirname( $original_file ), $item_id, $object, $avatar_dir );
|
310 |
else
|
311 |
-
$avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir',
|
312 |
|
313 |
if ( !file_exists( $avatar_folder_dir ) )
|
314 |
return false;
|
@@ -341,11 +342,20 @@ function bp_core_avatar_handle_crop( $args = '' ) {
|
|
341 |
}
|
342 |
|
343 |
// Override internal "get_avatar()" function to use our own where possible
|
344 |
-
function bp_core_fetch_avatar_filter( $avatar, $
|
345 |
-
|
346 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
347 |
|
348 |
-
|
|
|
|
|
|
|
349 |
|
350 |
return ( !$bp_avatar ) ? $avatar : $bp_avatar;
|
351 |
}
|
@@ -372,4 +382,22 @@ function bp_core_check_avatar_type($file) {
|
|
372 |
return true;
|
373 |
}
|
374 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
375 |
?>
|
7 |
/***
|
8 |
* Set up the constants we need for avatar support
|
9 |
*/
|
10 |
+
function bp_core_set_avatar_constants() {
|
11 |
+
global $bp;
|
12 |
+
|
13 |
+
if ( !defined( 'BP_AVATAR_UPLOAD_PATH' ) )
|
14 |
+
define( 'BP_AVATAR_UPLOAD_PATH', bp_core_avatar_upload_path() );
|
15 |
+
|
16 |
+
if ( !defined( 'BP_AVATAR_URL' ) )
|
17 |
+
define( 'BP_AVATAR_URL', bp_core_avatar_url() );
|
18 |
|
19 |
+
if ( !defined( 'BP_AVATAR_THUMB_WIDTH' ) )
|
20 |
+
define( 'BP_AVATAR_THUMB_WIDTH', 50 );
|
21 |
|
22 |
+
if ( !defined( 'BP_AVATAR_THUMB_HEIGHT' ) )
|
23 |
+
define( 'BP_AVATAR_THUMB_HEIGHT', 50 );
|
24 |
|
25 |
+
if ( !defined( 'BP_AVATAR_FULL_WIDTH' ) )
|
26 |
+
define( 'BP_AVATAR_FULL_WIDTH', 150 );
|
27 |
|
28 |
+
if ( !defined( 'BP_AVATAR_FULL_HEIGHT' ) )
|
29 |
+
define( 'BP_AVATAR_FULL_HEIGHT', 150 );
|
30 |
|
31 |
+
if ( !defined( 'BP_AVATAR_ORIGINAL_MAX_WIDTH' ) )
|
32 |
+
define( 'BP_AVATAR_ORIGINAL_MAX_WIDTH', 450 );
|
33 |
|
34 |
+
if ( !defined( 'BP_AVATAR_ORIGINAL_MAX_FILESIZE' ) ) {
|
35 |
+
if ( !$bp->site_options['fileupload_maxk'] )
|
36 |
+
define( 'BP_AVATAR_ORIGINAL_MAX_FILESIZE', 5120000 ); /* 5mb */
|
37 |
+
else
|
38 |
+
define( 'BP_AVATAR_ORIGINAL_MAX_FILESIZE', $bp->site_options['fileupload_maxk'] * 1024 );
|
39 |
+
}
|
40 |
|
41 |
+
if ( !defined( 'BP_AVATAR_DEFAULT' ) )
|
42 |
+
define( 'BP_AVATAR_DEFAULT', BP_PLUGIN_URL . '/bp-xprofile/images/none.gif' );
|
43 |
|
44 |
+
if ( !defined( 'BP_AVATAR_DEFAULT_THUMB' ) )
|
45 |
+
define( 'BP_AVATAR_DEFAULT_THUMB', BP_PLUGIN_URL . '/bp-xprofile/images/none-thumbnail.gif' );
|
46 |
+
}
|
47 |
+
add_action( 'bp_init', 'bp_core_set_avatar_constants' );
|
48 |
|
49 |
function bp_core_fetch_avatar( $args = '' ) {
|
50 |
global $bp, $current_blog;
|
59 |
'class' => 'avatar',
|
60 |
'css_id' => false,
|
61 |
'alt' => __( 'Avatar Image', 'buddypress' ),
|
62 |
+
'email' => false, // Pass the user email (for gravatar) to prevent querying the DB for it
|
63 |
'no_grav' => false // If there is no avatar found, return false instead of a grav?
|
64 |
);
|
65 |
|
108 |
else
|
109 |
$html_height = ( 'thumb' == $type ) ? ' height="' . BP_AVATAR_THUMB_HEIGHT . '"' : ' height="' . BP_AVATAR_FULL_HEIGHT . '"';
|
110 |
|
111 |
+
$avatar_folder_url = apply_filters( 'bp_core_avatar_folder_url', str_replace( WP_CONTENT_DIR, BP_AVATAR_URL, BP_AVATAR_UPLOAD_PATH ) . '/' . $avatar_dir . '/' . $item_id, $item_id, $object, $avatar_dir );
|
112 |
+
$avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', BP_AVATAR_UPLOAD_PATH . '/' . $avatar_dir . '/' . $item_id, $item_id, $object, $avatar_dir );
|
113 |
|
114 |
/****
|
115 |
* Look for uploaded avatar first. Use it if it exists.
|
138 |
if ( empty( $bp->grav_default->{$object} ) )
|
139 |
$default_grav = 'wavatar';
|
140 |
else if ( 'mystery' == $bp->grav_default->{$object} )
|
141 |
+
$default_grav = apply_filters( 'bp_core_mysteryman_src', BP_PLUGIN_URL . '/bp-core/images/mystery-man.jpg' );
|
142 |
else
|
143 |
$default_grav = $bp->grav_default->{$object};
|
144 |
|
146 |
else if ( 'full' == $type ) $grav_size = BP_AVATAR_FULL_WIDTH;
|
147 |
else if ( 'thumb' == $type ) $grav_size = BP_AVATAR_THUMB_WIDTH;
|
148 |
|
149 |
+
if ( empty( $email ) ) {
|
150 |
+
if ( 'user' == $object ) {
|
151 |
+
$email = bp_core_get_user_email( $item_id );
|
152 |
+
} else if ( 'group' == $object || 'blog' == $object ) {
|
153 |
+
$email = "{$item_id}-{$object}@{$bp->root_domain}";
|
154 |
+
}
|
155 |
}
|
156 |
|
157 |
+
$email = apply_filters( 'bp_core_gravatar_email', $email, $item_id, $object );
|
158 |
+
$gravatar = apply_filters( 'bp_gravatar_url', 'http://www.gravatar.com/avatar/' ) . md5( $email ) . '?d=' . $default_grav . '&s=' . $grav_size;
|
159 |
|
160 |
return apply_filters( 'bp_core_fetch_avatar', "<img src='{$gravatar}' alt='{$alt}' class='{$class}'{$css_id}{$html_width}{$html_height} />", $params );
|
161 |
|
202 |
if ( !$avatar_dir ) return false;
|
203 |
}
|
204 |
|
205 |
+
$avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', BP_AVATAR_UPLOAD_PATH . '/' . $avatar_dir . '/' . $item_id, $item_id, $object, $avatar_dir );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
206 |
|
207 |
if ( !file_exists( $avatar_folder_dir ) )
|
208 |
return false;
|
209 |
|
210 |
if ( $av_dir = opendir( $avatar_folder_dir ) ) {
|
211 |
+
while ( false !== ( $avatar_file = readdir($av_dir) ) ) {
|
212 |
if ( ( preg_match( "/-bpfull/", $avatar_file ) || preg_match( "/-bpthumb/", $avatar_file ) ) && '.' != $avatar_file && '..' != $avatar_file )
|
213 |
@unlink( $avatar_folder_dir . '/' . $avatar_file );
|
214 |
}
|
215 |
}
|
216 |
+
closedir($av_dir);
|
217 |
|
218 |
@rmdir( $avatar_folder_dir );
|
219 |
|
252 |
return false;
|
253 |
}
|
254 |
|
255 |
+
/* Filter the upload location */
|
256 |
add_filter( 'upload_dir', $upload_dir_filter, 10, 0 );
|
257 |
|
258 |
$bp->avatar_admin->original = wp_handle_upload( $file['file'], array( 'action'=> 'bp_avatar_upload' ) );
|
259 |
|
260 |
+
/* Move the file to the correct upload location. */
|
261 |
if ( !empty( $bp->avatar_admin->original['error'] ) ) {
|
262 |
bp_core_add_message( sprintf( __( 'Upload Failed! Error was: %s', 'buddypress' ), $bp->avatar_admin->original['error'] ), 'error' );
|
263 |
return false;
|
264 |
}
|
265 |
|
266 |
+
/* Resize the image down to something manageable and then delete the original */
|
267 |
+
if ( getimagesize( $bp->avatar_admin->original['file'] ) > BP_AVATAR_ORIGINAL_MAX_WIDTH )
|
268 |
$bp->avatar_admin->resized = wp_create_thumbnail( $bp->avatar_admin->original['file'], BP_AVATAR_ORIGINAL_MAX_WIDTH );
|
|
|
269 |
|
270 |
$bp->avatar_admin->image = new stdClass;
|
271 |
|
272 |
+
/* We only want to handle one image after resize. */
|
273 |
if ( empty( $bp->avatar_admin->resized ) )
|
274 |
$bp->avatar_admin->image->dir = $bp->avatar_admin->original['file'];
|
275 |
else {
|
277 |
@unlink( $bp->avatar_admin->original['file'] );
|
278 |
}
|
279 |
|
|
|
|
|
|
|
|
|
|
|
|
|
280 |
/* Set the url value for the image */
|
281 |
+
$bp->avatar_admin->image->url = str_replace( WP_CONTENT_DIR, BP_AVATAR_URL, $bp->avatar_admin->image->dir );
|
282 |
|
283 |
return true;
|
284 |
}
|
309 |
if ( !$item_id )
|
310 |
$avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', WP_CONTENT_DIR . dirname( $original_file ), $item_id, $object, $avatar_dir );
|
311 |
else
|
312 |
+
$avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', BP_AVATAR_UPLOAD_PATH . '/' . $avatar_dir . '/' . $item_id, $item_id, $object, $avatar_dir );
|
313 |
|
314 |
if ( !file_exists( $avatar_folder_dir ) )
|
315 |
return false;
|
342 |
}
|
343 |
|
344 |
// Override internal "get_avatar()" function to use our own where possible
|
345 |
+
function bp_core_fetch_avatar_filter( $avatar, $user, $size, $default, $alt ) {
|
346 |
+
global $authordata;
|
347 |
+
|
348 |
+
if ( is_object( $user ) )
|
349 |
+
$id = $user->user_id;
|
350 |
+
else if ( is_numeric( $user ) )
|
351 |
+
$id = $user;
|
352 |
+
else
|
353 |
+
$id = $authordata->ID;
|
354 |
|
355 |
+
if ( empty( $id ) )
|
356 |
+
return $avatar;
|
357 |
+
|
358 |
+
$bp_avatar = bp_core_fetch_avatar( array( 'item_id' => $id, 'width' => $size, 'height' => $size, 'alt' => $alt ) );
|
359 |
|
360 |
return ( !$bp_avatar ) ? $avatar : $bp_avatar;
|
361 |
}
|
382 |
return true;
|
383 |
}
|
384 |
|
385 |
+
function bp_core_avatar_upload_path() {
|
386 |
+
if ( bp_core_is_multisite() )
|
387 |
+
$path = ABSPATH . get_blog_option( BP_ROOT_BLOG, 'upload_path' );
|
388 |
+
else {
|
389 |
+
if ( !$path = get_option( 'upload_path' ) )
|
390 |
+
$path = WP_CONTENT_DIR . '/uploads';
|
391 |
+
}
|
392 |
+
|
393 |
+
return apply_filters( 'bp_core_avatar_upload_path', $path );
|
394 |
+
}
|
395 |
+
|
396 |
+
function bp_core_avatar_url() {
|
397 |
+
if ( !bp_core_is_multisite() )
|
398 |
+
return WP_CONTENT_URL;
|
399 |
+
|
400 |
+
return apply_filters( 'bp_core_avatar_url', get_blog_option( BP_ROOT_BLOG, 'siteurl' ) );
|
401 |
+
}
|
402 |
+
|
403 |
?>
|
bp-core/bp-core-catchuri.php
CHANGED
@@ -32,7 +32,7 @@ function bp_core_set_uri_globals() {
|
|
32 |
global $bp_unfiltered_uri;
|
33 |
global $bp, $current_blog;
|
34 |
|
35 |
-
if ( !defined( 'BP_ENABLE_MULTIBLOG' ) ) {
|
36 |
/* Only catch URI's on the root blog if we are not running BP on multiple blogs */
|
37 |
if ( BP_ROOT_BLOG != (int) $current_blog->blog_id )
|
38 |
return false;
|
@@ -213,9 +213,7 @@ function bp_core_do_catch_uri() {
|
|
213 |
if ( !$bp_no_status_set ) {
|
214 |
status_header( 200 );
|
215 |
$wp_query->is_404 = false;
|
216 |
-
|
217 |
-
if ( $bp->current_component != BP_HOME_BLOG_SLUG )
|
218 |
-
$wp_query->is_page = true;
|
219 |
}
|
220 |
|
221 |
foreach ( (array)$templates as $template )
|
@@ -253,6 +251,10 @@ function bp_core_catch_no_access() {
|
|
253 |
if ( !$bp->displayed_user->id && $bp_unfiltered_uri[0] == BP_MEMBERS_SLUG && isset($bp_unfiltered_uri[1]) )
|
254 |
bp_core_redirect( $bp->root_domain );
|
255 |
|
|
|
|
|
|
|
|
|
256 |
if ( !$bp_path && !bp_is_blog_page() ) {
|
257 |
if ( is_user_logged_in() ) {
|
258 |
wp_redirect( $bp->root_domain );
|
@@ -274,7 +276,7 @@ function bp_core_catch_profile_uri() {
|
|
274 |
global $bp;
|
275 |
|
276 |
if ( !function_exists('xprofile_install') )
|
277 |
-
bp_core_load_template( apply_filters( 'bp_core_template_display_profile', '
|
278 |
}
|
279 |
|
280 |
?>
|
32 |
global $bp_unfiltered_uri;
|
33 |
global $bp, $current_blog;
|
34 |
|
35 |
+
if ( !defined( 'BP_ENABLE_MULTIBLOG' ) && bp_core_is_multisite() ) {
|
36 |
/* Only catch URI's on the root blog if we are not running BP on multiple blogs */
|
37 |
if ( BP_ROOT_BLOG != (int) $current_blog->blog_id )
|
38 |
return false;
|
213 |
if ( !$bp_no_status_set ) {
|
214 |
status_header( 200 );
|
215 |
$wp_query->is_404 = false;
|
216 |
+
$wp_query->is_page = true;
|
|
|
|
|
217 |
}
|
218 |
|
219 |
foreach ( (array)$templates as $template )
|
251 |
if ( !$bp->displayed_user->id && $bp_unfiltered_uri[0] == BP_MEMBERS_SLUG && isset($bp_unfiltered_uri[1]) )
|
252 |
bp_core_redirect( $bp->root_domain );
|
253 |
|
254 |
+
// If the template file doesn't exist, redirect to the root domain.
|
255 |
+
if ( !bp_is_blog_page() && !file_exists( apply_filters( 'bp_located_template', locate_template( array( $bp_path . '.php' ), false ), array( $bp_path . '.php' ) ) ) )
|
256 |
+
bp_core_redirect( $bp->root_domain );
|
257 |
+
|
258 |
if ( !$bp_path && !bp_is_blog_page() ) {
|
259 |
if ( is_user_logged_in() ) {
|
260 |
wp_redirect( $bp->root_domain );
|
276 |
global $bp;
|
277 |
|
278 |
if ( !function_exists('xprofile_install') )
|
279 |
+
bp_core_load_template( apply_filters( 'bp_core_template_display_profile', 'members/single/home' ) );
|
280 |
}
|
281 |
|
282 |
?>
|
bp-core/bp-core-classes.php
CHANGED
@@ -24,7 +24,6 @@ class BP_Core_User {
|
|
24 |
var $user_link;
|
25 |
|
26 |
var $last_active;
|
27 |
-
var $profile_last_updated;
|
28 |
|
29 |
/* Extras */
|
30 |
var $total_friends;
|
@@ -56,199 +55,343 @@ class BP_Core_User {
|
|
56 |
* @uses bp_profile_last_updated_date() Returns the last updated date for a user.
|
57 |
*/
|
58 |
function populate() {
|
59 |
-
|
60 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
|
62 |
-
|
63 |
-
|
64 |
-
|
|
|
65 |
|
66 |
$this->avatar = bp_core_fetch_avatar( array( 'item_id' => $this->id, 'type' => 'full' ) );
|
67 |
$this->avatar_thumb = bp_core_fetch_avatar( array( 'item_id' => $this->id, 'type' => 'thumb' ) );
|
68 |
$this->avatar_mini = bp_core_fetch_avatar( array( 'item_id' => $this->id, 'type' => 'thumb', 'width' => 30, 'height' => 30 ) );
|
|
|
|
|
69 |
}
|
70 |
|
71 |
function populate_extras() {
|
72 |
global $bp;
|
73 |
|
74 |
-
if ( function_exists('friends_install') )
|
75 |
-
$this->total_friends = BP_Friends_Friendship::
|
76 |
-
|
77 |
-
if ( $this->total_friends ) {
|
78 |
-
if ( 1 == $this->total_friends )
|
79 |
-
$this->total_friends .= ' ' . __( 'friend', 'buddypress' );
|
80 |
-
else
|
81 |
-
$this->total_friends .= ' ' . __( 'friends', 'buddypress' );
|
82 |
-
|
83 |
-
$this->total_friends = '<a href="' . $this->user_url . $bp->friends->slug . '" title="' . sprintf( __( "%s's friend list", 'buddypress' ), $this->fullname ) . '">' . $this->total_friends . '</a>';
|
84 |
-
}
|
85 |
-
}
|
86 |
-
|
87 |
-
if ( function_exists('bp_blogs_install') ) {
|
88 |
-
if ( $this->total_blogs ) {
|
89 |
-
if ( 1 == $this->total_blogs )
|
90 |
-
$this->total_blogs .= ' ' . __( 'blog', 'buddypress' );
|
91 |
-
else
|
92 |
-
$this->total_blogs .= ' ' . __( 'blogs', 'buddypress' );
|
93 |
-
|
94 |
-
$this->total_blogs = '<a href="' . $this->user_url . $bp->blogs->slug . '" title="' . sprintf( __( "%s's blog list", 'buddypress' ), $this->fullname ) . '">' . $this->total_blogs . '</a>';
|
95 |
-
}
|
96 |
-
}
|
97 |
|
98 |
if ( function_exists('groups_install') ) {
|
99 |
-
$this->total_groups = BP_Groups_Member::
|
100 |
|
101 |
if ( $this->total_groups ) {
|
102 |
if ( 1 == $this->total_groups )
|
103 |
$this->total_groups .= ' ' . __( 'group', 'buddypress' );
|
104 |
else
|
105 |
$this->total_groups .= ' ' . __( 'groups', 'buddypress' );
|
106 |
-
|
107 |
-
$this->total_groups = '<a href="' . $this->user_url . $bp->groups->slug . '" title="' . sprintf( __( "%s's group list", 'buddypress' ), $this->fullname ) . '">' . $this->total_groups . '</a>';
|
108 |
}
|
109 |
}
|
110 |
}
|
111 |
|
|
|
|
|
|
|
|
|
112 |
/* Static Functions */
|
113 |
|
114 |
-
function
|
115 |
-
global $wpdb;
|
116 |
|
117 |
-
|
118 |
-
$pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
|
119 |
|
120 |
-
$
|
121 |
-
$paged_users_sql = apply_filters( 'bp_core_newest_users_sql', "SELECT DISTINCT ID as user_id, DATE_ADD( user_registered, INTERVAL " . get_option('gmt_offset') . " HOUR ) as user_registered FROM " . CUSTOM_USER_TABLE . " WHERE spam = 0 AND deleted = 0 AND user_status = 0 ORDER BY user_registered DESC{$pag_sql}", $pag_sql );
|
122 |
|
123 |
-
|
124 |
-
|
125 |
|
126 |
-
|
127 |
-
|
128 |
|
129 |
-
|
130 |
-
|
131 |
|
132 |
-
|
133 |
-
$pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
|
134 |
|
135 |
-
$
|
136 |
-
|
137 |
|
138 |
-
$
|
139 |
-
$paged_users = $wpdb->get_results( $paged_users_sql );
|
140 |
|
141 |
-
|
142 |
-
|
143 |
|
144 |
-
|
145 |
-
|
146 |
|
147 |
-
if (
|
148 |
-
|
149 |
|
150 |
-
if (
|
151 |
-
$
|
152 |
|
153 |
-
|
154 |
-
|
|
|
155 |
|
156 |
-
|
157 |
-
|
|
|
|
|
|
|
|
|
|
|
158 |
|
159 |
-
|
160 |
-
|
|
|
|
|
161 |
|
162 |
-
|
163 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
164 |
|
165 |
if ( $limit && $page )
|
166 |
-
$
|
167 |
|
168 |
-
|
169 |
-
$
|
170 |
|
171 |
-
|
172 |
-
|
173 |
|
174 |
-
|
175 |
-
|
176 |
|
177 |
-
|
178 |
-
|
179 |
|
180 |
-
if (
|
181 |
-
|
182 |
|
183 |
-
|
184 |
-
|
185 |
|
186 |
-
$
|
187 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
188 |
|
189 |
return array( 'users' => $paged_users, 'total' => $total_users );
|
190 |
}
|
191 |
|
192 |
-
function
|
193 |
global $wpdb, $bp;
|
194 |
|
195 |
-
if ( !function_exists( 'xprofile_install' ) )
|
196 |
-
return BP_Core_User::get_active_users( $limit, $page );
|
197 |
-
|
198 |
if ( $limit && $page )
|
199 |
$pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
|
200 |
|
201 |
-
|
202 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
203 |
|
204 |
$total_users = $wpdb->get_var( $total_users_sql );
|
205 |
$paged_users = $wpdb->get_results( $paged_users_sql );
|
206 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
207 |
return array( 'users' => $paged_users, 'total' => $total_users );
|
208 |
}
|
209 |
|
210 |
-
function
|
211 |
global $wpdb, $bp;
|
212 |
|
213 |
-
if ( !function_exists('xprofile_install') )
|
214 |
-
return BP_Core_User::get_active_users( $limit, $page );
|
215 |
-
|
216 |
if ( $limit && $page )
|
217 |
$pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
|
218 |
|
219 |
-
|
220 |
-
|
221 |
|
222 |
-
$
|
223 |
-
|
224 |
-
$total_users_sql = apply_filters( 'bp_core_users_by_letter_count_sql', $wpdb->prepare( "SELECT COUNT(DISTINCT u.ID) FROM " . CUSTOM_USER_TABLE . " u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id LEFT JOIN {$bp->profile->table_name_fields} pf ON pd.field_id = pf.id WHERE u.spam = 0 AND u.deleted = 0 AND u.user_status = 0 AND pf.name = %s AND pd.value LIKE '$letter%%' ORDER BY pd.value ASC", BP_XPROFILE_FULLNAME_FIELD_NAME ), $letter );
|
225 |
-
$paged_users_sql = apply_filters( 'bp_core_users_by_letter_sql', $wpdb->prepare( "SELECT DISTINCT u.ID as user_id FROM " . CUSTOM_USER_TABLE . " u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id LEFT JOIN {$bp->profile->table_name_fields} pf ON pd.field_id = pf.id WHERE u.spam = 0 AND u.deleted = 0 AND u.user_status = 0 AND pf.name = %s AND pd.value LIKE '$letter%%' ORDER BY pd.value ASC{$pag_sql}", BP_XPROFILE_FULLNAME_FIELD_NAME ), $letter, $pag_sql );
|
226 |
|
227 |
$total_users = $wpdb->get_var( $total_users_sql );
|
228 |
$paged_users = $wpdb->get_results( $paged_users_sql );
|
229 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
230 |
return array( 'users' => $paged_users, 'total' => $total_users );
|
231 |
}
|
232 |
|
233 |
-
function search_users( $search_terms, $limit = null, $page = 1 ) {
|
234 |
global $wpdb, $bp;
|
235 |
|
236 |
-
if ( !function_exists('xprofile_install') )
|
237 |
-
return BP_Core_User::get_active_users( $limit, $page );
|
238 |
-
|
239 |
if ( $limit && $page )
|
240 |
$pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
|
241 |
|
242 |
$search_terms = like_escape( $wpdb->escape( $search_terms ) );
|
|
|
243 |
|
244 |
-
$total_users_sql = apply_filters( 'bp_core_search_users_count_sql', "SELECT COUNT(DISTINCT u.ID) as
|
245 |
-
$paged_users_sql = apply_filters( 'bp_core_search_users_sql', "SELECT DISTINCT u.ID as
|
246 |
|
247 |
$total_users = $wpdb->get_var( $total_users_sql );
|
248 |
$paged_users = $wpdb->get_results( $paged_users_sql );
|
249 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
250 |
return array( 'users' => $paged_users, 'total' => $total_users );
|
251 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
252 |
}
|
253 |
|
254 |
|
24 |
var $user_link;
|
25 |
|
26 |
var $last_active;
|
|
|
27 |
|
28 |
/* Extras */
|
29 |
var $total_friends;
|
55 |
* @uses bp_profile_last_updated_date() Returns the last updated date for a user.
|
56 |
*/
|
57 |
function populate() {
|
58 |
+
if ( function_exists( 'xprofile_install' ) )
|
59 |
+
$this->profile_data = $this->get_profile_data();
|
60 |
+
|
61 |
+
if ( $this->profile_data ) {
|
62 |
+
$this->user_url = bp_core_get_user_domain( $this->id, $this->profile_data['user_nicename'], $this->profile_data['user_login'] );
|
63 |
+
$this->fullname = attribute_escape( $this->profile_data[BP_XPROFILE_FULLNAME_FIELD_NAME]['field_data'] );
|
64 |
+
$this->user_link = "<a href='{$this->user_url}' title='{$this->fullname}'>{$this->fullname}</a>";
|
65 |
+
$this->email = attribute_escape( $this->profile_data['user_email'] );
|
66 |
+
} else {
|
67 |
+
$this->user_url = bp_core_get_user_domain( $this->id );
|
68 |
+
$this->user_link = bp_core_get_userlink( $this->id );
|
69 |
+
$this->fullname = attribute_escape( bp_core_get_user_displayname( $this->id ) );
|
70 |
+
$this->email = attribute_escape( bp_core_get_user_email( $this->id ) );
|
71 |
+
}
|
72 |
|
73 |
+
/* Cache a few things that are fetched often */
|
74 |
+
wp_cache_set( 'bp_user_fullname_' . $this->id, $this->fullname, 'bp' );
|
75 |
+
wp_cache_set( 'bp_user_email_' . $this->id, $this->email, 'bp' );
|
76 |
+
wp_cache_set( 'bp_user_url_' . $this->id, $this->user_url, 'bp' );
|
77 |
|
78 |
$this->avatar = bp_core_fetch_avatar( array( 'item_id' => $this->id, 'type' => 'full' ) );
|
79 |
$this->avatar_thumb = bp_core_fetch_avatar( array( 'item_id' => $this->id, 'type' => 'thumb' ) );
|
80 |
$this->avatar_mini = bp_core_fetch_avatar( array( 'item_id' => $this->id, 'type' => 'thumb', 'width' => 30, 'height' => 30 ) );
|
81 |
+
|
82 |
+
$this->last_active = bp_core_get_last_activity( get_usermeta( $this->id, 'last_activity' ), __( 'active %s ago', 'buddypress' ) );
|
83 |
}
|
84 |
|
85 |
function populate_extras() {
|
86 |
global $bp;
|
87 |
|
88 |
+
if ( function_exists('friends_install') )
|
89 |
+
$this->total_friends = BP_Friends_Friendship::total_friend_count( $this->id );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
90 |
|
91 |
if ( function_exists('groups_install') ) {
|
92 |
+
$this->total_groups = BP_Groups_Member::total_group_count( $this->id );
|
93 |
|
94 |
if ( $this->total_groups ) {
|
95 |
if ( 1 == $this->total_groups )
|
96 |
$this->total_groups .= ' ' . __( 'group', 'buddypress' );
|
97 |
else
|
98 |
$this->total_groups .= ' ' . __( 'groups', 'buddypress' );
|
|
|
|
|
99 |
}
|
100 |
}
|
101 |
}
|
102 |
|
103 |
+
function get_profile_data() {
|
104 |
+
return BP_XProfile_ProfileData::get_all_for_user( $this->id );
|
105 |
+
}
|
106 |
+
|
107 |
/* Static Functions */
|
108 |
|
109 |
+
function get_users( $type, $limit = null, $page = 1, $user_id = false, $search_terms = false, $populate_extras = true ) {
|
110 |
+
global $wpdb, $bp;
|
111 |
|
112 |
+
$sql = array();
|
|
|
113 |
|
114 |
+
$sql['select_main'] = "SELECT DISTINCT u.ID as id, u.user_registered, u.user_nicename, u.user_login, u.display_name, u.user_email";
|
|
|
115 |
|
116 |
+
if ( 'active' == $type || 'online' == $type )
|
117 |
+
$sql['select_active'] = ", um.meta_value as last_activity";
|
118 |
|
119 |
+
if ( 'popular' == $type )
|
120 |
+
$sql['select_popular'] = ", um.meta_value as total_friend_count";
|
121 |
|
122 |
+
if ( 'alphabetical' == $type )
|
123 |
+
$sql['select_alpha'] = ", pd.value as fullname";
|
124 |
|
125 |
+
$sql['from'] = "FROM " . CUSTOM_USER_TABLE . " u LEFT JOIN " . CUSTOM_USER_META_TABLE . " um ON um.user_id = u.ID";
|
|
|
126 |
|
127 |
+
if ( $search_terms && function_exists( 'xprofile_install' ) || 'alphabetical' == $type )
|
128 |
+
$sql['join_profiledata'] = "LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id";
|
129 |
|
130 |
+
$sql['where'] = 'WHERE ' . bp_core_get_status_sql( 'u.' );
|
|
|
131 |
|
132 |
+
if ( 'active' == $type || 'online' == $type )
|
133 |
+
$sql['where_active'] = "AND um.meta_key = 'last_activity'";
|
134 |
|
135 |
+
if ( 'popular' == $type )
|
136 |
+
$sql['where_popular'] = "AND um.meta_key = 'total_friend_count'";
|
137 |
|
138 |
+
if ( 'online' == $type )
|
139 |
+
$sql['where_online'] = "AND DATE_ADD( um.meta_value, INTERVAL 5 MINUTE ) >= NOW()";
|
140 |
|
141 |
+
if ( 'alphabetical' == $type )
|
142 |
+
$sql['where_alpha'] = "AND pd.field_id = 1";
|
143 |
|
144 |
+
if ( $user_id && function_exists( 'friends_install' ) ) {
|
145 |
+
$friend_ids = friends_get_friend_user_ids( $user_id );
|
146 |
+
$friend_ids = $wpdb->escape( implode( ',', (array)$friend_ids ) );
|
147 |
|
148 |
+
if ( !empty( $friend_ids ) )
|
149 |
+
$sql['where_friends'] = "AND u.ID IN ({$friend_ids})";
|
150 |
+
else {
|
151 |
+
/* User has no friends, return false since there will be no users to fetch. */
|
152 |
+
return false;
|
153 |
+
}
|
154 |
+
}
|
155 |
|
156 |
+
if ( $search_terms && function_exists( 'xprofile_install' ) ) {
|
157 |
+
$search_terms = like_escape( $wpdb->escape( $search_terms ) );
|
158 |
+
$sql['where_searchterms'] = "AND pd.value LIKE '%%$search_terms%%'";
|
159 |
+
}
|
160 |
|
161 |
+
switch ( $type ) {
|
162 |
+
case 'active': case 'online': default:
|
163 |
+
$sql[] = "ORDER BY um.meta_value DESC";
|
164 |
+
break;
|
165 |
+
case 'newest':
|
166 |
+
$sql[] = "ORDER BY u.user_registered DESC";
|
167 |
+
break;
|
168 |
+
case 'alphabetical':
|
169 |
+
$sql[] = "ORDER BY pd.value ASC";
|
170 |
+
break;
|
171 |
+
case 'random':
|
172 |
+
$sql[] = "ORDER BY rand()";
|
173 |
+
break;
|
174 |
+
case 'popular':
|
175 |
+
$sql[] = "ORDER BY CONVERT(um.meta_value, SIGNED) DESC";
|
176 |
+
break;
|
177 |
+
}
|
178 |
|
179 |
if ( $limit && $page )
|
180 |
+
$sql['pagination'] = $wpdb->prepare( "LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
|
181 |
|
182 |
+
/* Get paginated results */
|
183 |
+
$paged_users = $wpdb->get_results( join( ' ', (array)$sql ) );
|
184 |
|
185 |
+
/* Re-jig the SQL so we can get the total user count */
|
186 |
+
unset( $sql['select_main'] );
|
187 |
|
188 |
+
if ( !empty( $sql['select_active'] ) )
|
189 |
+
unset( $sql['select_active'] );
|
190 |
|
191 |
+
if ( !empty( $sql['select_popular'] ) )
|
192 |
+
unset( $sql['select_popular'] );
|
193 |
|
194 |
+
if ( !empty( $sql['select_alpha'] ) )
|
195 |
+
unset( $sql['select_alpha'] );
|
196 |
|
197 |
+
if ( !empty( $sql['pagination'] ) )
|
198 |
+
unset( $sql['pagination'] );
|
199 |
|
200 |
+
array_unshift( $sql, "SELECT COUNT(DISTINCT u.ID)" );
|
201 |
+
|
202 |
+
/* Get total user results */
|
203 |
+
$total_users = $wpdb->get_var( join( ' ', (array)$sql ) );
|
204 |
+
|
205 |
+
/***
|
206 |
+
* Lets fetch some other useful data in a separate queries, this will be faster than querying the data for every user in a list.
|
207 |
+
* We can't add these to the main query above since only users who have this information will be returned (since the much of the data is in usermeta and won't support any type of directional join)
|
208 |
+
*/
|
209 |
+
if ( $populate_extras ) {
|
210 |
+
foreach ( (array)$paged_users as $user )
|
211 |
+
$user_ids[] = $user->id;
|
212 |
+
|
213 |
+
$user_ids = $wpdb->escape( join( ',', (array)$user_ids ) );
|
214 |
+
|
215 |
+
/* Add additional data to the returned results */
|
216 |
+
$paged_users = BP_Core_User::get_user_extras( &$paged_users, $user_ids, $type );
|
217 |
+
}
|
218 |
|
219 |
return array( 'users' => $paged_users, 'total' => $total_users );
|
220 |
}
|
221 |
|
222 |
+
function get_users_by_letter( $letter, $limit = null, $page = 1, $populate_extras = true ) {
|
223 |
global $wpdb, $bp;
|
224 |
|
|
|
|
|
|
|
225 |
if ( $limit && $page )
|
226 |
$pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
|
227 |
|
228 |
+
if ( strlen($letter) > 1 || is_numeric($letter) || !$letter )
|
229 |
+
return false;
|
230 |
+
|
231 |
+
$letter = like_escape( $wpdb->escape( $letter ) );
|
232 |
+
$status_sql = bp_core_get_status_sql( 'u.' );
|
233 |
+
|
234 |
+
$total_users_sql = apply_filters( 'bp_core_users_by_letter_count_sql', $wpdb->prepare( "SELECT COUNT(DISTINCT u.ID) FROM " . CUSTOM_USER_TABLE . " u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id LEFT JOIN {$bp->profile->table_name_fields} pf ON pd.field_id = pf.id WHERE {$status_sql} AND pf.name = %s AND pd.value LIKE '$letter%%' ORDER BY pd.value ASC", BP_XPROFILE_FULLNAME_FIELD_NAME ), $letter );
|
235 |
+
$paged_users_sql = apply_filters( 'bp_core_users_by_letter_sql', $wpdb->prepare( "SELECT DISTINCT u.ID as id, u.user_registered, u.user_nicename, u.user_login, u.user_email FROM " . CUSTOM_USER_TABLE . " u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id LEFT JOIN {$bp->profile->table_name_fields} pf ON pd.field_id = pf.id WHERE {$status_sql} AND pf.name = %s AND pd.value LIKE '$letter%%' ORDER BY pd.value ASC{$pag_sql}", BP_XPROFILE_FULLNAME_FIELD_NAME ), $letter, $pag_sql );
|
236 |
|
237 |
$total_users = $wpdb->get_var( $total_users_sql );
|
238 |
$paged_users = $wpdb->get_results( $paged_users_sql );
|
239 |
|
240 |
+
/***
|
241 |
+
* Lets fetch some other useful data in a separate queries, this will be faster than querying the data for every user in a list.
|
242 |
+
* We can't add these to the main query above since only users who have this information will be returned (since the much of the data is in usermeta and won't support any type of directional join)
|
243 |
+
*/
|
244 |
+
foreach ( (array)$paged_users as $user )
|
245 |
+
$user_ids[] = $user->id;
|
246 |
+
|
247 |
+
$user_ids = $wpdb->escape( join( ',', (array)$user_ids ) );
|
248 |
+
|
249 |
+
/* Add additional data to the returned results */
|
250 |
+
if ( $populate_extras )
|
251 |
+
$paged_users = BP_Core_User::get_user_extras( &$paged_users, &$user_ids );
|
252 |
+
|
253 |
return array( 'users' => $paged_users, 'total' => $total_users );
|
254 |
}
|
255 |
|
256 |
+
function get_specific_users( $user_ids, $limit = null, $page = 1, $populate_extras = true ) {
|
257 |
global $wpdb, $bp;
|
258 |
|
|
|
|
|
|
|
259 |
if ( $limit && $page )
|
260 |
$pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
|
261 |
|
262 |
+
$user_sql = " AND user_id IN ( " . $wpdb->escape( $user_ids ) . " ) ";
|
263 |
+
$status_sql = bp_core_get_status_sql();
|
264 |
|
265 |
+
$total_users_sql = apply_filters( 'bp_core_get_specific_users_count_sql', $wpdb->prepare( "SELECT COUNT(DISTINCT ID) FROM " . CUSTOM_USER_TABLE . " WHERE {$status_sql} AND ID IN ( " . $wpdb->escape( $user_ids ) . " ) " ), $wpdb->escape( $user_ids ) );
|
266 |
+
$paged_users_sql = apply_filters( 'bp_core_get_specific_users_count_sql', $wpdb->prepare( "SELECT DISTINCT ID as id, user_registered, user_nicename, user_login, user_email FROM " . CUSTOM_USER_TABLE . " WHERE {$status_sql} AND ID IN ( " . $wpdb->escape( $user_ids ) . " ) {$pag_sql}" ), $wpdb->escape( $user_ids ) );
|
|
|
|
|
267 |
|
268 |
$total_users = $wpdb->get_var( $total_users_sql );
|
269 |
$paged_users = $wpdb->get_results( $paged_users_sql );
|
270 |
|
271 |
+
/***
|
272 |
+
* Lets fetch some other useful data in a separate queries, this will be faster than querying the data for every user in a list.
|
273 |
+
* We can't add these to the main query above since only users who have this information will be returned (since the much of the data is in usermeta and won't support any type of directional join)
|
274 |
+
*/
|
275 |
+
|
276 |
+
/* Add additional data to the returned results */
|
277 |
+
if ( $populate_extras )
|
278 |
+
$paged_users = BP_Core_User::get_user_extras( &$paged_users, &$user_ids );
|
279 |
+
|
280 |
+
|
281 |
return array( 'users' => $paged_users, 'total' => $total_users );
|
282 |
}
|
283 |
|
284 |
+
function search_users( $search_terms, $limit = null, $page = 1, $populate_extras = true ) {
|
285 |
global $wpdb, $bp;
|
286 |
|
|
|
|
|
|
|
287 |
if ( $limit && $page )
|
288 |
$pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
|
289 |
|
290 |
$search_terms = like_escape( $wpdb->escape( $search_terms ) );
|
291 |
+
$status_sql = bp_core_get_status_sql( 'u.' );
|
292 |
|
293 |
+
$total_users_sql = apply_filters( 'bp_core_search_users_count_sql', "SELECT COUNT(DISTINCT u.ID) as id FROM " . CUSTOM_USER_TABLE . " u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id WHERE {$status_sql} AND pd.value LIKE '%%$search_terms%%' ORDER BY pd.value ASC", $search_terms );
|
294 |
+
$paged_users_sql = apply_filters( 'bp_core_search_users_sql', "SELECT DISTINCT u.ID as id, u.user_registered, u.user_nicename, u.user_login, u.user_email FROM " . CUSTOM_USER_TABLE . " u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id WHERE {$status_sql} AND pd.value LIKE '%%$search_terms%%' ORDER BY pd.value ASC{$pag_sql}", $search_terms, $pag_sql );
|
295 |
|
296 |
$total_users = $wpdb->get_var( $total_users_sql );
|
297 |
$paged_users = $wpdb->get_results( $paged_users_sql );
|
298 |
|
299 |
+
/***
|
300 |
+
* Lets fetch some other useful data in a separate queries, this will be faster than querying the data for every user in a list.
|
301 |
+
* We can't add these to the main query above since only users who have this information will be returned (since the much of the data is in usermeta and won't support any type of directional join)
|
302 |
+
*/
|
303 |
+
foreach ( (array)$paged_users as $user )
|
304 |
+
$user_ids[] = $user->id;
|
305 |
+
|
306 |
+
$user_ids = $wpdb->escape( join( ',', (array)$user_ids ) );
|
307 |
+
|
308 |
+
/* Add additional data to the returned results */
|
309 |
+
if ( $populate_extras )
|
310 |
+
$paged_users = BP_Core_User::get_user_extras( &$paged_users, &$user_ids );
|
311 |
+
|
312 |
return array( 'users' => $paged_users, 'total' => $total_users );
|
313 |
}
|
314 |
+
|
315 |
+
function get_user_extras( $paged_users, $user_ids, $type = false ) {
|
316 |
+
global $bp, $wpdb;
|
317 |
+
|
318 |
+
if ( empty( $user_ids ) )
|
319 |
+
return $paged_users;
|
320 |
+
|
321 |
+
/* Fetch the user's full name */
|
322 |
+
if ( function_exists( 'xprofile_install' ) && 'alphabetical' != $type ) {
|
323 |
+
$names = $wpdb->get_results( $wpdb->prepare( "SELECT pd.user_id as id, pd.value as fullname FROM {$bp->profile->table_name_fields} pf, {$bp->profile->table_name_data} pd WHERE pf.id = pd.field_id AND pf.name = %s AND pd.user_id IN ( {$user_ids} )", BP_XPROFILE_FULLNAME_FIELD_NAME ) );
|
324 |
+
for ( $i = 0; $i < count( $paged_users ); $i++ ) {
|
325 |
+
foreach ( (array)$names as $name ) {
|
326 |
+
if ( $name->id == $paged_users[$i]->id )
|
327 |
+
$paged_users[$i]->fullname = $name->fullname;
|
328 |
+
}
|
329 |
+
}
|
330 |
+
}
|
331 |
+
|
332 |
+
/* Fetch the user's total friend count */
|
333 |
+
if ( 'popular' != $type ) {
|
334 |
+
$friend_count = $wpdb->get_results( "SELECT user_id as id, meta_value as total_friend_count FROM " . CUSTOM_USER_META_TABLE . " WHERE meta_key = 'total_friend_count' AND user_id IN ( {$user_ids} )" );
|
335 |
+
for ( $i = 0; $i < count( $paged_users ); $i++ ) {
|
336 |
+
foreach ( (array)$friend_count as $count ) {
|
337 |
+
if ( $count->id == $paged_users[$i]->id )
|
338 |
+
$paged_users[$i]->total_friend_count = (int)$count->total_friend_count;
|
339 |
+
}
|
340 |
+
}
|
341 |
+
}
|
342 |
+
|
343 |
+
/* Fetch whether or not the user is a friend */
|
344 |
+
if ( function_exists( 'friends_install' ) ) {
|
345 |
+
$friend_status = $wpdb->get_results( $wpdb->prepare( "SELECT initiator_user_id, friend_user_id, is_confirmed FROM {$bp->friends->table_name} WHERE (initiator_user_id = %d AND friend_user_id IN ( {$user_ids} ) ) OR (initiator_user_id IN ( {$user_ids} ) AND friend_user_id = %d )", $bp->loggedin_user->id, $bp->loggedin_user->id ) );
|
346 |
+
for ( $i = 0; $i < count( $paged_users ); $i++ ) {
|
347 |
+
foreach ( (array)$friend_status as $status ) {
|
348 |
+
if ( $status->initiator_user_id == $paged_users[$i]->id || $status->friend_user_id == $paged_users[$i]->id )
|
349 |
+
$paged_users[$i]->is_friend = $status->is_confirmed;
|
350 |
+
}
|
351 |
+
}
|
352 |
+
}
|
353 |
+
|
354 |
+
if ( 'active' != $type ) {
|
355 |
+
$user_activity = $wpdb->get_results( "SELECT user_id as id, meta_value as last_activity FROM " . CUSTOM_USER_META_TABLE . " WHERE meta_key = 'last_activity' AND user_id IN ( {$user_ids} )" );
|
356 |
+
for ( $i = 0; $i < count( $paged_users ); $i++ ) {
|
357 |
+
foreach ( (array)$user_activity as $activity ) {
|
358 |
+
if ( $activity->id == $paged_users[$i]->id )
|
359 |
+
$paged_users[$i]->last_activity = $activity->last_activity;
|
360 |
+
}
|
361 |
+
}
|
362 |
+
}
|
363 |
+
|
364 |
+
/* Fetch the user's last_activity */
|
365 |
+
if ( 'active' != $type ) {
|
366 |
+
$user_activity = $wpdb->get_results( "SELECT user_id as id, meta_value as last_activity FROM " . CUSTOM_USER_META_TABLE . " WHERE meta_key = 'last_activity' AND user_id IN ( {$user_ids} )" );
|
367 |
+
for ( $i = 0; $i < count( $paged_users ); $i++ ) {
|
368 |
+
foreach ( (array)$user_activity as $activity ) {
|
369 |
+
if ( $activity->id == $paged_users[$i]->id )
|
370 |
+
$paged_users[$i]->last_activity = $activity->last_activity;
|
371 |
+
}
|
372 |
+
}
|
373 |
+
}
|
374 |
+
|
375 |
+
/* Fetch the user's latest update */
|
376 |
+
$user_update = $wpdb->get_results( "SELECT user_id as id, meta_value as latest_update FROM " . CUSTOM_USER_META_TABLE . " WHERE meta_key = 'bp_latest_update' AND user_id IN ( {$user_ids} )" );
|
377 |
+
for ( $i = 0; $i < count( $paged_users ); $i++ ) {
|
378 |
+
foreach ( (array)$user_update as $update ) {
|
379 |
+
if ( $update->id == $paged_users[$i]->id )
|
380 |
+
$paged_users[$i]->latest_update = $update->latest_update;
|
381 |
+
}
|
382 |
+
}
|
383 |
+
|
384 |
+
return $paged_users;
|
385 |
+
}
|
386 |
+
|
387 |
+
function get_core_userdata( $user_id ) {
|
388 |
+
global $wpdb;
|
389 |
+
|
390 |
+
if ( !$user = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->users WHERE ID = %d LIMIT 1", $user_id ) ) )
|
391 |
+
return false;
|
392 |
+
|
393 |
+
return $user;
|
394 |
+
}
|
395 |
}
|
396 |
|
397 |
|
bp-core/bp-core-cssjs.php
CHANGED
@@ -9,37 +9,21 @@
|
|
9 |
* @uses get_option() Selects a site setting from the DB.
|
10 |
*/
|
11 |
function bp_core_add_admin_bar_css() {
|
12 |
-
global $current_blog;
|
13 |
|
14 |
if ( defined( 'BP_DISABLE_ADMIN_BAR' ) )
|
15 |
return false;
|
16 |
|
17 |
-
|
18 |
-
|
19 |
-
$admin_bar_css = WP_CONTENT_URL . '/themes/' . get_blog_option( BP_ROOT_BLOG, 'stylesheet' ) . '/_inc/css/adminbar.css';
|
20 |
-
else if ( file_exists( WP_CONTENT_DIR . '/' . get_blog_option( BP_ROOT_BLOG, 'template' ) . '/_inc/css/adminbar.css' ) )
|
21 |
-
$admin_bar_css = WP_CONTENT_URL . '/themes/' . get_blog_option( BP_ROOT_BLOG, 'template' ) . '/_inc/css/adminbar.css';
|
22 |
-
else
|
23 |
-
$admin_bar_css = BP_PLUGIN_URL . '/bp-core/deprecated/css/admin-bar.css';
|
24 |
|
25 |
-
|
|
|
|
|
|
|
|
|
26 |
}
|
27 |
-
add_action( '
|
28 |
-
add_action( 'template_redirect', 'bp_core_add_admin_bar_css' );
|
29 |
-
|
30 |
-
/**
|
31 |
-
* bp_core_add_admin_bar_js()
|
32 |
-
*
|
33 |
-
* Add the minor JS needed for the admin bar.
|
34 |
-
*
|
35 |
-
* @package BuddyPress Core
|
36 |
-
* @uses get_option() Selects a site setting from the DB.
|
37 |
-
*/
|
38 |
-
function bp_core_add_admin_bar_js() {
|
39 |
-
wp_enqueue_script( 'bp-admin-bar-js', BP_PLUGIN_URL . '/bp-core/js/admin-bar.js', array( 'jquery' ) );
|
40 |
-
}
|
41 |
-
add_action( 'admin_menu', 'bp_core_add_admin_bar_js' );
|
42 |
-
add_action( 'wp', 'bp_core_add_admin_bar_js' );
|
43 |
|
44 |
/**
|
45 |
* bp_core_admin_menu_icon_css()
|
@@ -61,6 +45,10 @@ function bp_core_admin_menu_icon_css() {
|
|
61 |
add_action( 'admin_head', 'bp_core_admin_menu_icon_css' );
|
62 |
|
63 |
function bp_core_confirmation_js() {
|
|
|
|
|
|
|
|
|
64 |
?>
|
65 |
<script type="text/javascript"> jQuery(document).ready( function() { jQuery("a.confirm").click( function() { if ( confirm( '<?php _e( 'Are you sure?', 'buddypress' ) ?>' ) ) return true; else return false; }); });</script>
|
66 |
<?php
|
@@ -91,7 +79,6 @@ function bp_core_add_cropper_inline_js() {
|
|
91 |
global $bp;
|
92 |
|
93 |
$image = apply_filters( 'bp_inline_cropper_image', getimagesize( $bp->avatar_admin->image->dir ) );
|
94 |
-
|
95 |
$aspect_ratio = 1;
|
96 |
|
97 |
/* Calculate Aspect Ratio */
|
@@ -105,7 +92,7 @@ function bp_core_add_cropper_inline_js() {
|
|
105 |
onSelect: showPreview,
|
106 |
onSelect: updateCoords,
|
107 |
aspectRatio: <?php echo $aspect_ratio ?>,
|
108 |
-
setSelect: [ 50, 50,
|
109 |
});
|
110 |
});
|
111 |
|
@@ -172,7 +159,7 @@ function bp_core_add_ajax_url_js() {
|
|
172 |
global $bp;
|
173 |
|
174 |
echo
|
175 |
-
'<script type="text/javascript">var ajaxurl = "' .
|
176 |
';
|
177 |
}
|
178 |
add_action( 'wp_head', 'bp_core_add_ajax_url_js' );
|
@@ -185,7 +172,9 @@ add_action( 'wp_head', 'bp_core_add_ajax_url_js' );
|
|
185 |
* @package BuddyPress Core
|
186 |
*/
|
187 |
function bp_core_override_adminbar_css() {
|
188 |
-
|
|
|
|
|
189 |
?>
|
190 |
<style type="text/css">body { padding-top: 0 !important; } #wp-admin-bar { display: none; }</style>
|
191 |
<?php }
|
9 |
* @uses get_option() Selects a site setting from the DB.
|
10 |
*/
|
11 |
function bp_core_add_admin_bar_css() {
|
12 |
+
global $bp, $current_blog;
|
13 |
|
14 |
if ( defined( 'BP_DISABLE_ADMIN_BAR' ) )
|
15 |
return false;
|
16 |
|
17 |
+
if ( ( bp_core_is_multisite() && $current_blog->blog_id != BP_ROOT_BLOG ) || is_admin() ) {
|
18 |
+
$stylesheet = get_blog_option( BP_ROOT_BLOG, 'stylesheet' );
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
+
if ( file_exists( WP_CONTENT_DIR . '/themes/' . $stylesheet . '/_inc/css/adminbar.css' ) )
|
21 |
+
wp_enqueue_style( 'bp-admin-bar', apply_filters( 'bp_core_admin_bar_css', WP_CONTENT_URL . '/themes/' . $stylesheet . '/_inc/css/adminbar.css' ) );
|
22 |
+
else
|
23 |
+
wp_enqueue_style( 'bp-admin-bar', apply_filters( 'bp_core_admin_bar_css', BP_PLUGIN_URL . '/bp-themes/bp-default/_inc/css/adminbar.css' ) );
|
24 |
+
}
|
25 |
}
|
26 |
+
add_action( 'init', 'bp_core_add_admin_bar_css' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
|
28 |
/**
|
29 |
* bp_core_admin_menu_icon_css()
|
45 |
add_action( 'admin_head', 'bp_core_admin_menu_icon_css' );
|
46 |
|
47 |
function bp_core_confirmation_js() {
|
48 |
+
global $current_blog;
|
49 |
+
|
50 |
+
if ( $current_blog->blog_id != BP_ROOT_BLOG )
|
51 |
+
return false;
|
52 |
?>
|
53 |
<script type="text/javascript"> jQuery(document).ready( function() { jQuery("a.confirm").click( function() { if ( confirm( '<?php _e( 'Are you sure?', 'buddypress' ) ?>' ) ) return true; else return false; }); });</script>
|
54 |
<?php
|
79 |
global $bp;
|
80 |
|
81 |
$image = apply_filters( 'bp_inline_cropper_image', getimagesize( $bp->avatar_admin->image->dir ) );
|
|
|
82 |
$aspect_ratio = 1;
|
83 |
|
84 |
/* Calculate Aspect Ratio */
|
92 |
onSelect: showPreview,
|
93 |
onSelect: updateCoords,
|
94 |
aspectRatio: <?php echo $aspect_ratio ?>,
|
95 |
+
setSelect: [ 50, 50, <?php echo $image[0] / 2 ?>, <?php echo $image[1] / 2 ?> ]
|
96 |
});
|
97 |
});
|
98 |
|
159 |
global $bp;
|
160 |
|
161 |
echo
|
162 |
+
'<script type="text/javascript">var ajaxurl = "' . site_url( 'wp-load.php' ) . '";</script>
|
163 |
';
|
164 |
}
|
165 |
add_action( 'wp_head', 'bp_core_add_ajax_url_js' );
|
172 |
* @package BuddyPress Core
|
173 |
*/
|
174 |
function bp_core_override_adminbar_css() {
|
175 |
+
global $bp;
|
176 |
+
|
177 |
+
if ( defined( 'BP_DISABLE_ADMIN_BAR' ) || ( $bp->site_options['hide-loggedout-adminbar'] && !is_user_logged_in() ) ) {
|
178 |
?>
|
179 |
<style type="text/css">body { padding-top: 0 !important; } #wp-admin-bar { display: none; }</style>
|
180 |
<?php }
|
bp-core/bp-core-notifications.php
CHANGED
@@ -50,11 +50,11 @@ function bp_core_get_notifications_for_user( $user_id ) {
|
|
50 |
return false;
|
51 |
|
52 |
/* Calculated a renderable outcome for each notification type */
|
53 |
-
foreach ( $grouped_notifications as $component_name => $action_arrays ) {
|
54 |
if ( !$action_arrays )
|
55 |
continue;
|
56 |
|
57 |
-
foreach ( $action_arrays as $component_action_name => $component_action_items ) {
|
58 |
$action_item_count = count($component_action_items);
|
59 |
|
60 |
if ( $action_item_count < 1 )
|
50 |
return false;
|
51 |
|
52 |
/* Calculated a renderable outcome for each notification type */
|
53 |
+
foreach ( (array)$grouped_notifications as $component_name => $action_arrays ) {
|
54 |
if ( !$action_arrays )
|
55 |
continue;
|
56 |
|
57 |
+
foreach ( (array)$action_arrays as $component_action_name => $component_action_items ) {
|
58 |
$action_item_count = count($component_action_items);
|
59 |
|
60 |
if ( $action_item_count < 1 )
|
bp-core/bp-core-settings.php
CHANGED
@@ -16,13 +16,13 @@ function bp_core_add_settings_nav() {
|
|
16 |
/* Add the settings navigation item */
|
17 |
bp_core_new_nav_item( array( 'name' => __('Settings', 'buddypress'), 'slug' => $bp->settings->slug, 'position' => 100, 'show_for_displayed_user' => false, 'screen_function' => 'bp_core_screen_general_settings', 'default_subnav_slug' => 'general' ) );
|
18 |
|
19 |
-
$settings_link = $bp->loggedin_user->domain .
|
20 |
|
21 |
-
bp_core_new_subnav_item( array( 'name' => __( 'General', 'buddypress' ), 'slug' => 'general', 'parent_url' => $settings_link, 'parent_slug' => $bp->settings->slug, 'screen_function' => 'bp_core_screen_general_settings', 'position' => 10, 'user_has_access' =>
|
22 |
-
bp_core_new_subnav_item( array( 'name' => __( 'Notifications', 'buddypress' ), 'slug' => 'notifications', 'parent_url' => $settings_link, 'parent_slug' => $bp->settings->slug, 'screen_function' => 'bp_core_screen_notification_settings', 'position' => 20, 'user_has_access' =>
|
23 |
|
24 |
-
if ( !is_site_admin() && !(int)
|
25 |
-
bp_core_new_subnav_item( array( 'name' => __( 'Delete Account', 'buddypress' ), 'slug' => 'delete-account', 'parent_url' => $settings_link, 'parent_slug' => $bp->settings->slug, 'screen_function' => 'bp_core_screen_delete_account', 'position' => 90, 'user_has_access' =>
|
26 |
}
|
27 |
add_action( 'wp', 'bp_core_add_settings_nav', 2 );
|
28 |
add_action( 'admin_menu', 'bp_core_add_settings_nav', 2 );
|
@@ -63,7 +63,7 @@ function bp_core_screen_general_settings() {
|
|
63 |
add_action( 'bp_template_title', 'bp_core_screen_general_settings_title' );
|
64 |
add_action( 'bp_template_content', 'bp_core_screen_general_settings_content' );
|
65 |
|
66 |
-
bp_core_load_template( apply_filters( 'bp_core_template_plugin', '
|
67 |
}
|
68 |
|
69 |
function bp_core_screen_general_settings_title() {
|
@@ -85,7 +85,7 @@ function bp_core_screen_general_settings_content() {
|
|
85 |
</div>
|
86 |
<?php } ?>
|
87 |
|
88 |
-
<form action="<?php echo $bp->loggedin_user->domain .
|
89 |
<label for="email"><?php _e( 'Account Email', 'buddypress' ) ?></label>
|
90 |
<input type="text" name="email" id="email" value="<?php echo attribute_escape( $current_user->user_email ); ?>" class="settings-input" />
|
91 |
|
@@ -93,7 +93,10 @@ function bp_core_screen_general_settings_content() {
|
|
93 |
<input type="password" name="pass1" id="pass1" size="16" value="" class="settings-input small" /> <?php _e( 'New Password', 'buddypress' ) ?><br />
|
94 |
<input type="password" name="pass2" id="pass2" size="16" value="" class="settings-input small" /> <?php _e( 'Repeat New Password', 'buddypress' ) ?>
|
95 |
|
96 |
-
<
|
|
|
|
|
|
|
97 |
<?php wp_nonce_field('bp_settings_general') ?>
|
98 |
</form>
|
99 |
<?php
|
@@ -110,7 +113,7 @@ function bp_core_screen_notification_settings() {
|
|
110 |
check_admin_referer('bp_settings_notifications');
|
111 |
|
112 |
if ( $_POST['notifications'] ) {
|
113 |
-
foreach ( $_POST['notifications'] as $key => $value ) {
|
114 |
update_usermeta( (int)$current_user->id, $key, $value );
|
115 |
}
|
116 |
}
|
@@ -121,7 +124,7 @@ function bp_core_screen_notification_settings() {
|
|
121 |
add_action( 'bp_template_title', 'bp_core_screen_notification_settings_title' );
|
122 |
add_action( 'bp_template_content', 'bp_core_screen_notification_settings_content' );
|
123 |
|
124 |
-
bp_core_load_template( apply_filters( 'bp_core_template_plugin', '
|
125 |
}
|
126 |
|
127 |
function bp_core_screen_notification_settings_title() {
|
@@ -137,13 +140,15 @@ function bp_core_screen_notification_settings_content() {
|
|
137 |
</div>
|
138 |
<?php } ?>
|
139 |
|
140 |
-
<form action="<?php echo $bp->loggedin_user->domain .
|
141 |
<h3><?php _e( 'Email Notifications', 'buddypress' ) ?></h3>
|
142 |
<p><?php _e( 'Send a notification by email when:', 'buddypress' ) ?></p>
|
143 |
|
144 |
<?php do_action( 'bp_notification_settings' ) ?>
|
145 |
|
146 |
-
<
|
|
|
|
|
147 |
|
148 |
<?php wp_nonce_field('bp_settings_notifications') ?>
|
149 |
|
@@ -165,7 +170,7 @@ function bp_core_screen_delete_account() {
|
|
165 |
add_action( 'bp_template_title', 'bp_core_screen_delete_account_title' );
|
166 |
add_action( 'bp_template_content', 'bp_core_screen_delete_account_content' );
|
167 |
|
168 |
-
bp_core_load_template( apply_filters( 'bp_core_template_plugin', '
|
169 |
}
|
170 |
|
171 |
function bp_core_screen_delete_account_title() {
|
@@ -175,14 +180,18 @@ function bp_core_screen_delete_account_title() {
|
|
175 |
function bp_core_screen_delete_account_content() {
|
176 |
global $bp, $current_user, $bp_settings_updated, $pass_error; ?>
|
177 |
|
178 |
-
<form action="<?php echo $bp->loggedin_user->domain .
|
179 |
|
180 |
<div id="message" class="info">
|
181 |
<p><?php _e( 'WARNING: Deleting your account will completely remove ALL content associated with it. There is no way back, please be careful with this option.', 'buddypress' ); ?></p>
|
182 |
</div>
|
183 |
|
184 |
<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' ); ?>
|
185 |
-
|
|
|
|
|
|
|
|
|
186 |
<?php wp_nonce_field('delete-account') ?>
|
187 |
</form>
|
188 |
<?php
|
16 |
/* Add the settings navigation item */
|
17 |
bp_core_new_nav_item( array( 'name' => __('Settings', 'buddypress'), 'slug' => $bp->settings->slug, 'position' => 100, 'show_for_displayed_user' => false, 'screen_function' => 'bp_core_screen_general_settings', 'default_subnav_slug' => 'general' ) );
|
18 |
|
19 |
+
$settings_link = $bp->loggedin_user->domain . $bp->settings->slug . '/';
|
20 |
|
21 |
+
bp_core_new_subnav_item( array( 'name' => __( 'General', 'buddypress' ), 'slug' => 'general', 'parent_url' => $settings_link, 'parent_slug' => $bp->settings->slug, 'screen_function' => 'bp_core_screen_general_settings', 'position' => 10, 'user_has_access' => bp_is_my_profile() ) );
|
22 |
+
bp_core_new_subnav_item( array( 'name' => __( 'Notifications', 'buddypress' ), 'slug' => 'notifications', 'parent_url' => $settings_link, 'parent_slug' => $bp->settings->slug, 'screen_function' => 'bp_core_screen_notification_settings', 'position' => 20, 'user_has_access' => bp_is_my_profile() ) );
|
23 |
|
24 |
+
if ( !is_site_admin() && !(int) $bp->site_options['bp-disable-account-deletion'] )
|
25 |
+
bp_core_new_subnav_item( array( 'name' => __( 'Delete Account', 'buddypress' ), 'slug' => 'delete-account', 'parent_url' => $settings_link, 'parent_slug' => $bp->settings->slug, 'screen_function' => 'bp_core_screen_delete_account', 'position' => 90, 'user_has_access' => bp_is_my_profile() ) );
|
26 |
}
|
27 |
add_action( 'wp', 'bp_core_add_settings_nav', 2 );
|
28 |
add_action( 'admin_menu', 'bp_core_add_settings_nav', 2 );
|
63 |
add_action( 'bp_template_title', 'bp_core_screen_general_settings_title' );
|
64 |
add_action( 'bp_template_content', 'bp_core_screen_general_settings_content' );
|
65 |
|
66 |
+
bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) );
|
67 |
}
|
68 |
|
69 |
function bp_core_screen_general_settings_title() {
|
85 |
</div>
|
86 |
<?php } ?>
|
87 |
|
88 |
+
<form action="<?php echo $bp->loggedin_user->domain . BP_SETTINGS_SLUG . '/general' ?>" method="post" class="standard-form" id="settings-form">
|
89 |
<label for="email"><?php _e( 'Account Email', 'buddypress' ) ?></label>
|
90 |
<input type="text" name="email" id="email" value="<?php echo attribute_escape( $current_user->user_email ); ?>" class="settings-input" />
|
91 |
|
93 |
<input type="password" name="pass1" id="pass1" size="16" value="" class="settings-input small" /> <?php _e( 'New Password', 'buddypress' ) ?><br />
|
94 |
<input type="password" name="pass2" id="pass2" size="16" value="" class="settings-input small" /> <?php _e( 'Repeat New Password', 'buddypress' ) ?>
|
95 |
|
96 |
+
<div class="submit">
|
97 |
+
<input type="submit" name="submit" value="<?php _e( 'Save Changes', 'buddypress' ) ?>" id="submit" class="auto"/></p>
|
98 |
+
</div>
|
99 |
+
|
100 |
<?php wp_nonce_field('bp_settings_general') ?>
|
101 |
</form>
|
102 |
<?php
|
113 |
check_admin_referer('bp_settings_notifications');
|
114 |
|
115 |
if ( $_POST['notifications'] ) {
|
116 |
+
foreach ( (array)$_POST['notifications'] as $key => $value ) {
|
117 |
update_usermeta( (int)$current_user->id, $key, $value );
|
118 |
}
|
119 |
}
|
124 |
add_action( 'bp_template_title', 'bp_core_screen_notification_settings_title' );
|
125 |
add_action( 'bp_template_content', 'bp_core_screen_notification_settings_content' );
|
126 |
|
127 |
+
bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) );
|
128 |
}
|
129 |
|
130 |
function bp_core_screen_notification_settings_title() {
|
140 |
</div>
|
141 |
<?php } ?>
|
142 |
|
143 |
+
<form action="<?php echo $bp->loggedin_user->domain . BP_SETTINGS_SLUG . '/notifications' ?>" method="post" id="settings-form">
|
144 |
<h3><?php _e( 'Email Notifications', 'buddypress' ) ?></h3>
|
145 |
<p><?php _e( 'Send a notification by email when:', 'buddypress' ) ?></p>
|
146 |
|
147 |
<?php do_action( 'bp_notification_settings' ) ?>
|
148 |
|
149 |
+
<div class="submit">
|
150 |
+
<input type="submit" name="submit" value="<?php _e( 'Save Changes', 'buddypress' ) ?>" id="submit" class="auto"/></p>
|
151 |
+
</div>
|
152 |
|
153 |
<?php wp_nonce_field('bp_settings_notifications') ?>
|
154 |
|
170 |
add_action( 'bp_template_title', 'bp_core_screen_delete_account_title' );
|
171 |
add_action( 'bp_template_content', 'bp_core_screen_delete_account_content' );
|
172 |
|
173 |
+
bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) );
|
174 |
}
|
175 |
|
176 |
function bp_core_screen_delete_account_title() {
|
180 |
function bp_core_screen_delete_account_content() {
|
181 |
global $bp, $current_user, $bp_settings_updated, $pass_error; ?>
|
182 |
|
183 |
+
<form action="<?php echo $bp->loggedin_user->domain . BP_SETTINGS_SLUG . '/delete-account'; ?>" name="account-delete-form" id="account-delete-form" class="standard-form" method="post">
|
184 |
|
185 |
<div id="message" class="info">
|
186 |
<p><?php _e( 'WARNING: Deleting your account will completely remove ALL content associated with it. There is no way back, please be careful with this option.', 'buddypress' ); ?></p>
|
187 |
</div>
|
188 |
|
189 |
<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' ); ?>
|
190 |
+
|
191 |
+
<div class="submit">
|
192 |
+
<input type="submit" disabled="disabled" value="<?php _e( 'Delete My Account', 'buddypress' ) ?> →" id="delete-account-button" name="delete-account-button" /></p>
|
193 |
+
</div>
|
194 |
+
|
195 |
<?php wp_nonce_field('delete-account') ?>
|
196 |
</form>
|
197 |
<?php
|
bp-core/bp-core-signup.php
CHANGED
@@ -18,7 +18,7 @@ function bp_core_screen_signup() {
|
|
18 |
return false;
|
19 |
|
20 |
/* If signups are disabled, just re-direct */
|
21 |
-
if (
|
22 |
bp_core_redirect( $bp->root_domain );
|
23 |
|
24 |
$bp->signup->step = 'request-details';
|
@@ -32,7 +32,7 @@ function bp_core_screen_signup() {
|
|
32 |
require_once( ABSPATH . WPINC . '/registration.php' );
|
33 |
|
34 |
/* Check the base account details for problems */
|
35 |
-
$account_details = wpmu_validate_user_signup( $_POST['signup_username']
|
36 |
|
37 |
/* If there are errors with account details, set them for display */
|
38 |
if ( !empty( $account_details['errors']->errors['user_name'] ) )
|
@@ -49,23 +49,28 @@ function bp_core_screen_signup() {
|
|
49 |
if ( ( !empty( $_POST['signup_password'] ) && !empty( $_POST['signup_password_confirm'] ) ) && $_POST['signup_password'] != $_POST['signup_password_confirm'] )
|
50 |
$bp->signup->errors['signup_password'] = __( 'The passwords you entered do not match.', 'buddypress' );
|
51 |
|
52 |
-
|
53 |
-
$
|
54 |
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
|
|
|
|
|
|
|
|
61 |
|
62 |
-
|
63 |
-
|
|
|
64 |
}
|
65 |
|
66 |
/* Finally, let's check the blog details, if the user wants a blog and blog creation is enabled */
|
67 |
if ( isset( $_POST['signup_with_blog'] ) ) {
|
68 |
-
$active_signup =
|
69 |
|
70 |
if ( 'blog' == $active_signup || 'all' == $active_signup ) {
|
71 |
$blog_details = wpmu_validate_blog_signup( $_POST['signup_blog_url'], $_POST['signup_blog_title'] );
|
@@ -83,13 +88,13 @@ function bp_core_screen_signup() {
|
|
83 |
|
84 |
/* Add any errors to the action for the field in the template for display. */
|
85 |
if ( !empty( $bp->signup->errors ) ) {
|
86 |
-
foreach ( $bp->signup->errors as $fieldname => $error_message )
|
87 |
add_action( 'bp_' . $fieldname . '_errors', create_function( '', 'echo "<div class=\"error\">' . $error_message . '</div>";' ) );
|
88 |
} else {
|
89 |
$bp->signup->step = 'save-details';
|
90 |
|
91 |
/* No errors! Let's register those deets. */
|
92 |
-
$active_signup =
|
93 |
|
94 |
if ( 'none' != $active_signup ) {
|
95 |
|
@@ -121,10 +126,11 @@ function bp_core_screen_signup() {
|
|
121 |
$usermeta = apply_filters( 'bp_signup_usermeta', $usermeta );
|
122 |
|
123 |
/* Finally, sign up the user and/or blog*/
|
124 |
-
if ( isset( $_POST['signup_with_blog'] ) )
|
125 |
wpmu_signup_blog( $blog_details['domain'], $blog_details['path'], $blog_details['blog_title'], $_POST['signup_username'], $_POST['signup_email'], $usermeta );
|
126 |
-
else
|
127 |
-
|
|
|
128 |
|
129 |
$bp->signup->step = 'completed-confirmation';
|
130 |
}
|
@@ -144,20 +150,23 @@ function bp_core_screen_signup() {
|
|
144 |
|
145 |
$bp->signup->step = 'completed-confirmation';
|
146 |
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
|
|
|
|
|
|
|
|
153 |
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
|
158 |
-
|
159 |
-
|
160 |
-
}
|
161 |
}
|
162 |
}
|
163 |
|
@@ -176,40 +185,110 @@ function bp_core_screen_signup() {
|
|
176 |
else
|
177 |
bp_core_add_message( __( 'Your new avatar was uploaded successfully', 'buddypress' ) );
|
178 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
179 |
}
|
180 |
bp_core_load_template( 'registration/register' );
|
181 |
}
|
182 |
add_action( 'wp', 'bp_core_screen_signup', 3 );
|
183 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
184 |
function bp_core_signup_avatar_upload_dir() {
|
185 |
global $bp;
|
186 |
|
187 |
if ( !$bp->signup->avatar_dir )
|
188 |
return false;
|
189 |
|
190 |
-
$path
|
191 |
-
$
|
192 |
-
$newdir .= '/avatars/signups/' . $bp->signup->avatar_dir;
|
193 |
|
194 |
-
$
|
|
|
195 |
|
196 |
-
|
197 |
-
@wp_mkdir_p( $newdir );
|
198 |
-
|
199 |
-
$newurl = WP_CONTENT_URL . '/blogs.dir/' . BP_ROOT_BLOG . '/files/avatars/signups/' . $bp->signup->avatar_dir;
|
200 |
$newburl = $newurl;
|
201 |
$newsubdir = '/avatars/signups/' . $bp->signup->avatar_dir;
|
202 |
|
203 |
-
return apply_filters( 'bp_core_signup_avatar_upload_dir', array( 'path' => $
|
204 |
}
|
205 |
|
206 |
/* Kill the wp-signup.php if custom registration signup templates are present */
|
207 |
function bp_core_wpsignup_redirect() {
|
208 |
-
if ( false === strpos( $_SERVER['SCRIPT_NAME'], 'wp-signup.php') )
|
209 |
return false;
|
210 |
|
211 |
if ( locate_template( array( 'registration/register.php' ), false ) || locate_template( array( 'register.php' ), false ) )
|
212 |
-
wp_redirect(
|
213 |
}
|
214 |
-
|
|
|
|
|
|
|
|
|
215 |
?>
|
18 |
return false;
|
19 |
|
20 |
/* If signups are disabled, just re-direct */
|
21 |
+
if ( !bp_get_signup_allowed() )
|
22 |
bp_core_redirect( $bp->root_domain );
|
23 |
|
24 |
$bp->signup->step = 'request-details';
|
32 |
require_once( ABSPATH . WPINC . '/registration.php' );
|
33 |
|
34 |
/* Check the base account details for problems */
|
35 |
+
$account_details = wpmu_validate_user_signup( $_POST['signup_username'], $_POST['signup_email'] );
|
36 |
|
37 |
/* If there are errors with account details, set them for display */
|
38 |
if ( !empty( $account_details['errors']->errors['user_name'] ) )
|
49 |
if ( ( !empty( $_POST['signup_password'] ) && !empty( $_POST['signup_password_confirm'] ) ) && $_POST['signup_password'] != $_POST['signup_password_confirm'] )
|
50 |
$bp->signup->errors['signup_password'] = __( 'The passwords you entered do not match.', 'buddypress' );
|
51 |
|
52 |
+
$bp->signup->username = $_POST['signup_username'];
|
53 |
+
$bp->signup->email = $_POST['signup_email'];
|
54 |
|
55 |
+
if ( !empty( $_POST['signup_profile_field_ids'] ) && function_exists( 'xprofile_check_is_required_field' ) ) {
|
56 |
+
/* Now we've checked account details, we can check profile information */
|
57 |
+
$profile_field_ids = explode( ',', $_POST['signup_profile_field_ids'] );
|
58 |
+
|
59 |
+
/* Loop through the posted fields formatting any datebox values then validate the field */
|
60 |
+
foreach ( (array) $profile_field_ids as $field_id ) {
|
61 |
+
if ( !isset( $_POST['field_' . $field_id] ) ) {
|
62 |
+
if ( isset( $_POST['field_' . $field_id . '_day'] ) )
|
63 |
+
$_POST['field_' . $field_id] = strtotime( $_POST['field_' . $field_id . '_day'] . $_POST['field_' . $field_id . '_month'] . $_POST['field_' . $field_id . '_year'] );
|
64 |
+
}
|
65 |
|
66 |
+
if ( xprofile_check_is_required_field( $field_id ) && empty( $_POST['field_' . $field_id] ) )
|
67 |
+
$bp->signup->errors['field_' . $field_id] = __( 'This is a required field', 'buddypress' );
|
68 |
+
}
|
69 |
}
|
70 |
|
71 |
/* Finally, let's check the blog details, if the user wants a blog and blog creation is enabled */
|
72 |
if ( isset( $_POST['signup_with_blog'] ) ) {
|
73 |
+
$active_signup = $bp->site_options['registration'];
|
74 |
|
75 |
if ( 'blog' == $active_signup || 'all' == $active_signup ) {
|
76 |
$blog_details = wpmu_validate_blog_signup( $_POST['signup_blog_url'], $_POST['signup_blog_title'] );
|
88 |
|
89 |
/* Add any errors to the action for the field in the template for display. */
|
90 |
if ( !empty( $bp->signup->errors ) ) {
|
91 |
+
foreach ( (array)$bp->signup->errors as $fieldname => $error_message )
|
92 |
add_action( 'bp_' . $fieldname . '_errors', create_function( '', 'echo "<div class=\"error\">' . $error_message . '</div>";' ) );
|
93 |
} else {
|
94 |
$bp->signup->step = 'save-details';
|
95 |
|
96 |
/* No errors! Let's register those deets. */
|
97 |
+
$active_signup = $bp->site_options['registration'];
|
98 |
|
99 |
if ( 'none' != $active_signup ) {
|
100 |
|
126 |
$usermeta = apply_filters( 'bp_signup_usermeta', $usermeta );
|
127 |
|
128 |
/* Finally, sign up the user and/or blog*/
|
129 |
+
if ( isset( $_POST['signup_with_blog'] ) && bp_core_is_multisite() )
|
130 |
wpmu_signup_blog( $blog_details['domain'], $blog_details['path'], $blog_details['blog_title'], $_POST['signup_username'], $_POST['signup_email'], $usermeta );
|
131 |
+
else {
|
132 |
+
bp_core_signup_user( $_POST['signup_username'], $_POST['signup_password'], $_POST['signup_email'], $usermeta );
|
133 |
+
}
|
134 |
|
135 |
$bp->signup->step = 'completed-confirmation';
|
136 |
}
|
150 |
|
151 |
$bp->signup->step = 'completed-confirmation';
|
152 |
|
153 |
+
if ( bp_core_is_multisite() ) {
|
154 |
+
/* Get the activation key */
|
155 |
+
if ( !$bp->signup->key = $wpdb->get_var( $wpdb->prepare( "SELECT activation_key FROM {$wpdb->signups} WHERE user_login = %s AND user_email = %s", $_POST[ 'signup_username' ], $_POST[ 'signup_email' ] ) ) ) {
|
156 |
+
bp_core_add_message( __( 'There was a problem uploading your avatar, please try uploading it again', 'buddypress' ) );
|
157 |
+
} else {
|
158 |
+
/* Hash the key to create the upload folder (added security so people don't sniff the activation key) */
|
159 |
+
$bp->signup->avatar_dir = wp_hash( $bp->signup->key );
|
160 |
+
}
|
161 |
+
} else
|
162 |
+
$bp->signup->avatar_dir = wp_hash( $bp->signup->username );
|
163 |
|
164 |
+
/* Pass the file to the avatar upload handler */
|
165 |
+
if ( bp_core_avatar_handle_upload( $_FILES, 'bp_core_signup_avatar_upload_dir' ) ) {
|
166 |
+
$bp->avatar_admin->step = 'crop-image';
|
167 |
|
168 |
+
/* Make sure we include the jQuery jCrop file for image cropping */
|
169 |
+
add_action( 'wp', 'bp_core_add_jquery_cropper' );
|
|
|
170 |
}
|
171 |
}
|
172 |
|
185 |
else
|
186 |
bp_core_add_message( __( 'Your new avatar was uploaded successfully', 'buddypress' ) );
|
187 |
|
188 |
+
/* If this is a single WP install, move the avatar to the user's folder since there is no activation process to move it. */
|
189 |
+
if ( !bp_core_is_multisite() ) {
|
190 |
+
$user_id = bp_core_get_userid( $_POST['signup_username'] );
|
191 |
+
|
192 |
+
if ( !empty( $user_id ) && file_exists( BP_AVATAR_UPLOAD_PATH . '/avatars/signups/' . $_POST['signup_avatar_dir'] ) ) {
|
193 |
+
@rename( BP_AVATAR_UPLOAD_PATH . '/avatars/signups/' . $_POST['signup_avatar_dir'], BP_AVATAR_UPLOAD_PATH . '/avatars/' . $user_id );
|
194 |
+
}
|
195 |
+
}
|
196 |
}
|
197 |
bp_core_load_template( 'registration/register' );
|
198 |
}
|
199 |
add_action( 'wp', 'bp_core_screen_signup', 3 );
|
200 |
|
201 |
+
function bp_core_signup_user( $user_login, $user_password, $user_email, $usermeta ) {
|
202 |
+
global $bp;
|
203 |
+
|
204 |
+
if ( bp_core_is_multisite() )
|
205 |
+
return wpmu_signup_user( $user_login, $user_email, $usermeta );
|
206 |
+
|
207 |
+
$errors = new WP_Error();
|
208 |
+
|
209 |
+
$user_id = wp_create_user( $user_login, $user_password, $user_email );
|
210 |
+
if ( !$user_id ) {
|
211 |
+
$errors->add('registerfail', sprintf(__('<strong>ERROR</strong>: Couldn’t register you... please contact the <a href="mailto:%s">webmaster</a> !'), get_option('admin_email')));
|
212 |
+
return $errors;
|
213 |
+
}
|
214 |
+
|
215 |
+
/* Set any profile data */
|
216 |
+
if ( function_exists( 'xprofile_set_field_data' ) ) {
|
217 |
+
if ( !empty( $usermeta['profile_field_ids'] ) ) {
|
218 |
+
$profile_field_ids = explode( ',', $usermeta['profile_field_ids'] );
|
219 |
+
|
220 |
+
foreach( (array)$profile_field_ids as $field_id ) {
|
221 |
+
$current_field = $usermeta["field_{$field_id}"];
|
222 |
+
|
223 |
+
if ( !empty( $current_field ) )
|
224 |
+
xprofile_set_field_data( $field_id, $user_id, $current_field );
|
225 |
+
}
|
226 |
+
}
|
227 |
+
}
|
228 |
+
|
229 |
+
/* Add a last active entry */
|
230 |
+
update_usermeta( $user_id, 'last_activity', gmdate( "Y-m-d H:i:s" ) );
|
231 |
+
|
232 |
+
wp_new_user_notification( $user_id, $user_pass );
|
233 |
+
wp_cache_delete( 'bp_total_member_count', 'bp' );
|
234 |
+
|
235 |
+
$bp->signup->username = $user_login;
|
236 |
+
|
237 |
+
return $user_id;
|
238 |
+
}
|
239 |
+
|
240 |
+
function bp_core_map_user_registration( $user_id ) {
|
241 |
+
/* Only map data when the site admin is adding users, not on registration. */
|
242 |
+
if ( !is_admin() )
|
243 |
+
return false;
|
244 |
+
|
245 |
+
/* Add a last active entry */
|
246 |
+
update_usermeta( $user_id, 'last_activity', gmdate( "Y-m-d H:i:s" ) );
|
247 |
+
|
248 |
+
/* Add the user's fullname to Xprofile */
|
249 |
+
if ( function_exists( 'xprofile_set_field_data' ) ) {
|
250 |
+
$firstname = get_usermeta( $user_id, 'first_name' );
|
251 |
+
$lastname = ' ' . get_usermeta( $user_id, 'last_name' );
|
252 |
+
$name = $firstname . $lastname;
|
253 |
+
|
254 |
+
if ( empty( $name ) || ' ' == $name )
|
255 |
+
$name = get_usermeta( $user_id, 'nickname' );
|
256 |
+
|
257 |
+
xprofile_set_field_data( 1, $user_id, $name );
|
258 |
+
}
|
259 |
+
}
|
260 |
+
add_action( 'user_register', 'bp_core_map_user_registration' );
|
261 |
+
|
262 |
function bp_core_signup_avatar_upload_dir() {
|
263 |
global $bp;
|
264 |
|
265 |
if ( !$bp->signup->avatar_dir )
|
266 |
return false;
|
267 |
|
268 |
+
$path = BP_AVATAR_UPLOAD_PATH . '/avatars/signups/' . $bp->signup->avatar_dir;
|
269 |
+
$newbdir = $path;
|
|
|
270 |
|
271 |
+
if ( !file_exists( $path ) )
|
272 |
+
@wp_mkdir_p( $path );
|
273 |
|
274 |
+
$newurl = str_replace( BP_AVATAR_UPLOAD_PATH, BP_AVATAR_URL, $path );
|
|
|
|
|
|
|
275 |
$newburl = $newurl;
|
276 |
$newsubdir = '/avatars/signups/' . $bp->signup->avatar_dir;
|
277 |
|
278 |
+
return apply_filters( 'bp_core_signup_avatar_upload_dir', array( 'path' => $path, 'url' => $newurl, 'subdir' => $newsubdir, 'basedir' => $newbdir, 'baseurl' => $newburl, 'error' => false ) );
|
279 |
}
|
280 |
|
281 |
/* Kill the wp-signup.php if custom registration signup templates are present */
|
282 |
function bp_core_wpsignup_redirect() {
|
283 |
+
if ( false === strpos( $_SERVER['SCRIPT_NAME'], 'wp-signup.php') && $_GET['action'] != 'register' )
|
284 |
return false;
|
285 |
|
286 |
if ( locate_template( array( 'registration/register.php' ), false ) || locate_template( array( 'register.php' ), false ) )
|
287 |
+
wp_redirect( bp_get_root_domain() . '/' . BP_REGISTER_SLUG . '/' );
|
288 |
}
|
289 |
+
if ( bp_core_is_multisite() )
|
290 |
+
add_action( 'wp', 'bp_core_wpsignup_redirect' );
|
291 |
+
else
|
292 |
+
add_action( 'init', 'bp_core_wpsignup_redirect' );
|
293 |
+
|
294 |
?>
|
bp-core/bp-core-templatetags.php
CHANGED
@@ -1,4 +1,409 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
/**
|
3 |
* bp_get_nav()
|
4 |
* TEMPLATE TAG
|
@@ -22,7 +427,7 @@ function bp_get_loggedin_user_nav() {
|
|
22 |
foreach( (array) $bp->bp_nav as $nav_item ) {
|
23 |
/* If the current component matches the nav item id, then add a highlight CSS class. */
|
24 |
if ( $bp->active_components[$bp->current_component] == $nav_item['css_id'] ) {
|
25 |
-
$selected = ' class="current"';
|
26 |
} else {
|
27 |
$selected = '';
|
28 |
}
|
@@ -30,13 +435,13 @@ function bp_get_loggedin_user_nav() {
|
|
30 |
/* If we are viewing another person (current_userid does not equal loggedin_user->id)
|
31 |
then check to see if the two users are friends. if they are, add a highlight CSS class
|
32 |
to the friends nav item if it exists. */
|
33 |
-
if ( !
|
34 |
$selected = '';
|
35 |
|
36 |
if ( function_exists('friends_install') ) {
|
37 |
if ( $nav_item['css_id'] == $bp->friends->id ) {
|
38 |
if ( friends_check_friendship( $bp->loggedin_user->id, $bp->displayed_user->id ) )
|
39 |
-
$selected = ' class="current"';
|
40 |
}
|
41 |
}
|
42 |
}
|
@@ -54,8 +459,6 @@ function bp_get_loggedin_user_nav() {
|
|
54 |
|
55 |
echo apply_filters( 'bp_logout_nav_link', $logout_link );
|
56 |
}
|
57 |
-
/* DEPRECATED - use bp_get_loggedin_user_nav() */
|
58 |
-
function bp_get_nav() { bp_get_loggedin_user_nav(); }
|
59 |
|
60 |
/**
|
61 |
* bp_get_displayed_user_nav()
|
@@ -70,12 +473,12 @@ function bp_get_loggedin_user_nav() {
|
|
70 |
function bp_get_displayed_user_nav() {
|
71 |
global $bp;
|
72 |
|
73 |
-
foreach ( $bp->bp_nav as $user_nav_item ) {
|
74 |
-
if ( !$user_nav_item['show_for_displayed_user'] )
|
75 |
continue;
|
76 |
|
77 |
-
if ( $bp->current_component == $user_nav_item['
|
78 |
-
$selected = ' class="current"';
|
79 |
else
|
80 |
$selected = '';
|
81 |
|
@@ -84,11 +487,9 @@ function bp_get_displayed_user_nav() {
|
|
84 |
else
|
85 |
$link = $bp->displayed_user->domain . $user_nav_item['link'];
|
86 |
|
87 |
-
echo apply_filters( 'bp_get_displayed_user_nav_' . $user_nav_item['css_id'], '<li id="
|
88 |
}
|
89 |
}
|
90 |
-
/* DEPRECATED - use bp_get_displayed_user_nav() */
|
91 |
-
function bp_get_user_nav() { bp_get_displayed_user_nav(); }
|
92 |
|
93 |
/**
|
94 |
* bp_get_options_nav()
|
@@ -110,32 +511,23 @@ function bp_get_displayed_user_nav() {
|
|
110 |
function bp_get_options_nav() {
|
111 |
global $bp;
|
112 |
|
113 |
-
|
114 |
-
|
115 |
-
* menus for something like a group, or event.
|
116 |
-
*/
|
117 |
-
if ( bp_is_home() || $bp->is_single_item ) {
|
118 |
-
if ( count( $bp->bp_options_nav[$bp->current_component] ) < 1 )
|
119 |
-
return false;
|
120 |
-
|
121 |
-
/* Loop through each navigation item */
|
122 |
-
foreach ( $bp->bp_options_nav[$bp->current_component] as $subnav_item ) {
|
123 |
-
if ( !$subnav_item['user_has_access'] )
|
124 |
-
continue;
|
125 |
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
$selected = '';
|
131 |
-
}
|
132 |
|
133 |
-
|
134 |
-
|
|
|
|
|
|
|
135 |
}
|
136 |
-
|
137 |
-
/*
|
138 |
-
|
139 |
}
|
140 |
}
|
141 |
|
@@ -269,7 +661,7 @@ function bp_site_name() {
|
|
269 |
echo apply_filters( 'bp_site_name', get_blog_option( BP_ROOT_BLOG, 'blogname' ) );
|
270 |
}
|
271 |
|
272 |
-
function
|
273 |
global $bp;
|
274 |
|
275 |
if ( is_user_logged_in() && $bp->loggedin_user->id == $bp->displayed_user->id )
|
@@ -277,6 +669,7 @@ function bp_is_home() {
|
|
277 |
|
278 |
return false;
|
279 |
}
|
|
|
280 |
|
281 |
function bp_last_activity( $user_id = false, $echo = true ) {
|
282 |
global $bp;
|
@@ -292,6 +685,20 @@ function bp_last_activity( $user_id = false, $echo = true ) {
|
|
292 |
return apply_filters( 'bp_last_activity', $last_activity );
|
293 |
}
|
294 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
295 |
function bp_user_link() {
|
296 |
global $bp;
|
297 |
|
@@ -418,7 +825,8 @@ function bp_word_or_name( $youtext, $nametext, $capitalize = true, $echo = true
|
|
418 |
else
|
419 |
return apply_filters( 'bp_word_or_name', $youtext );
|
420 |
} else {
|
421 |
-
$
|
|
|
422 |
if ( $echo )
|
423 |
echo apply_filters( 'bp_word_or_name', $nametext );
|
424 |
else
|
@@ -458,12 +866,12 @@ function bp_get_plugin_sidebar() {
|
|
458 |
}
|
459 |
|
460 |
function bp_is_blog_page() {
|
461 |
-
global $bp, $is_member_page;
|
462 |
|
463 |
-
if ( $
|
464 |
return true;
|
465 |
|
466 |
-
if ( !$
|
467 |
return true;
|
468 |
|
469 |
return false;
|
@@ -476,30 +884,38 @@ function bp_page_title() {
|
|
476 |
function bp_get_page_title() {
|
477 |
global $bp, $post, $wp_query, $current_blog;
|
478 |
|
479 |
-
if ( is_home() && bp_is_page( 'home' ) ) {
|
480 |
$title = __( 'Home', 'buddypress' );
|
|
|
481 |
} else if ( bp_is_blog_page() ) {
|
482 |
if ( is_single() ) {
|
483 |
-
$title = __( 'Blog &#
|
484 |
} else if ( is_category() ) {
|
485 |
-
$title = __( 'Blog &#
|
486 |
} else if ( is_tag() ) {
|
487 |
-
$title = __( 'Blog &#
|
|
|
|
|
488 |
} else
|
489 |
$title = __( 'Blog', 'buddypress' );
|
490 |
|
491 |
} else if ( !empty( $bp->displayed_user->fullname ) ) {
|
492 |
-
|
|
|
493 |
} else if ( $bp->is_single_item ) {
|
494 |
-
$title = ucwords( $bp->current_component ) . ' &#
|
|
|
495 |
} else if ( $bp->is_directory ) {
|
496 |
if ( !$bp->current_component )
|
497 |
$title = sprintf( __( '%s Directory', 'buddypress' ), ucwords( BP_MEMBERS_SLUG ) );
|
498 |
else
|
499 |
$title = sprintf( __( '%s Directory', 'buddypress' ), ucwords( $bp->current_component ) );
|
500 |
-
|
501 |
-
|
502 |
-
$title =
|
|
|
|
|
|
|
503 |
}
|
504 |
|
505 |
if ( defined( 'BP_ENABLE_MULTIBLOG' ) ) {
|
@@ -508,7 +924,7 @@ function bp_get_page_title() {
|
|
508 |
$blog_title = get_blog_option( BP_ROOT_BLOG, 'blogname' );
|
509 |
}
|
510 |
|
511 |
-
return apply_filters( 'bp_page_title', $blog_title . ' &#
|
512 |
}
|
513 |
|
514 |
function bp_styles() {
|
@@ -516,74 +932,52 @@ function bp_styles() {
|
|
516 |
wp_print_styles();
|
517 |
}
|
518 |
|
519 |
-
function bp_is_page($page) {
|
520 |
-
global $bp;
|
521 |
-
|
522 |
-
if ( $bp->displayed_user->id || $bp->is_single_item )
|
523 |
-
return false;
|
524 |
-
|
525 |
-
if ( $page == $bp->current_component || ( is_home() && $page == 'home' && $bp->current_component == $bp->default_component ) || ( $page == BP_MEMBERS_SLUG && !$bp->current_component ) )
|
526 |
-
return true;
|
527 |
-
|
528 |
-
return false;
|
529 |
-
}
|
530 |
-
|
531 |
function bp_has_custom_signup_page() {
|
532 |
-
if (
|
533 |
-
return true;
|
534 |
-
|
535 |
-
if ( file_exists( WP_CONTENT_DIR . '/themes/' . get_blog_option( BP_ROOT_BLOG, 'template') . '/registration/register.php') )
|
536 |
return true;
|
537 |
|
538 |
return false;
|
539 |
}
|
540 |
|
541 |
-
function bp_signup_page(
|
542 |
-
|
543 |
-
return bp_get_signup_page();
|
544 |
-
else
|
545 |
-
echo bp_get_signup_page();
|
546 |
}
|
547 |
function bp_get_signup_page() {
|
548 |
global $bp;
|
549 |
|
550 |
-
if ( bp_has_custom_signup_page() )
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
|
|
555 |
}
|
556 |
|
557 |
function bp_has_custom_activation_page() {
|
558 |
-
if (
|
559 |
-
return true;
|
560 |
-
|
561 |
-
if ( file_exists( WP_CONTENT_DIR . '/themes/' . get_blog_option( BP_ROOT_BLOG, 'template') . '/registration/activate.php') )
|
562 |
return true;
|
563 |
|
564 |
return false;
|
565 |
}
|
566 |
|
567 |
-
function bp_activation_page(
|
568 |
-
|
|
|
|
|
|
|
569 |
|
570 |
-
|
571 |
-
|
572 |
-
echo $bp->root_domain . '/' . BP_ACTIVATION_SLUG;
|
573 |
-
else
|
574 |
-
return $bp->root_domain . '/' . BP_ACTIVATION_SLUG;
|
575 |
-
} else {
|
576 |
-
if ( $echo )
|
577 |
-
echo $bp->root_domain . '/wp-activate.php';
|
578 |
else
|
579 |
-
|
|
|
|
|
580 |
}
|
581 |
-
}
|
582 |
|
583 |
function bp_search_form_action() {
|
584 |
global $bp;
|
585 |
|
586 |
-
return apply_filters( 'bp_search_form_action', $bp->root_domain . '/
|
587 |
}
|
588 |
|
589 |
function bp_search_form_type_select() {
|
@@ -598,11 +992,11 @@ function bp_search_form_type_select() {
|
|
598 |
$selection_box .= '<option value="groups">' . __( 'Groups', 'buddypress' ) . '</option>';
|
599 |
}
|
600 |
|
601 |
-
if ( function_exists( 'bp_forums_setup' ) && !(int)
|
602 |
$selection_box .= '<option value="forums">' . __( 'Forums', 'buddypress' ) . '</option>';
|
603 |
}
|
604 |
|
605 |
-
if ( function_exists( 'bp_blogs_install' ) ) {
|
606 |
$selection_box .= '<option value="blogs">' . __( 'Blogs', 'buddypress' ) . '</option>';
|
607 |
}
|
608 |
|
@@ -635,41 +1029,6 @@ function bp_log_out_link() {
|
|
635 |
echo apply_filters( 'bp_logout_link', $logout_link );
|
636 |
}
|
637 |
|
638 |
-
function bp_profile_wire_can_post() {
|
639 |
-
global $bp;
|
640 |
-
|
641 |
-
if ( bp_is_home() )
|
642 |
-
return true;
|
643 |
-
|
644 |
-
if ( function_exists('friends_install') ) {
|
645 |
-
if ( friends_check_friendship( $bp->loggedin_user->id, $bp->displayed_user->id ) )
|
646 |
-
return true;
|
647 |
-
else
|
648 |
-
return false;
|
649 |
-
}
|
650 |
-
|
651 |
-
return true;
|
652 |
-
}
|
653 |
-
|
654 |
-
function bp_nav_items() {
|
655 |
-
global $bp;
|
656 |
-
// This is deprecated, you should put these navigation items in your template header.php for easy editing.
|
657 |
-
?>
|
658 |
-
<li<?php if ( bp_is_page( 'home' ) ) {?> class="selected"<?php } ?>><a href="<?php echo get_option('home') ?>" title="<?php _e( 'Home', 'buddypress' ) ?>"><?php _e( 'Home', 'buddypress' ) ?></a></li>
|
659 |
-
<li<?php if ( bp_is_page( BP_HOME_BLOG_SLUG ) ) {?> class="selected"<?php } ?>><a href="<?php echo get_option('home') ?>/<?php echo BP_HOME_BLOG_SLUG ?>" title="<?php _e( 'Blog', 'buddypress' ) ?>"><?php _e( 'Blog', 'buddypress' ) ?></a></li>
|
660 |
-
<li<?php if ( bp_is_page( BP_MEMBERS_SLUG ) ) {?> class="selected"<?php } ?>><a href="<?php echo get_option('home') ?>/<?php echo BP_MEMBERS_SLUG ?>" title="<?php _e( 'Members', 'buddypress' ) ?>"><?php _e( 'Members', 'buddypress' ) ?></a></li>
|
661 |
-
|
662 |
-
<?php if ( function_exists( 'groups_install' ) ) { ?>
|
663 |
-
<li<?php if ( bp_is_page( $bp->groups->slug ) ) {?> class="selected"<?php } ?>><a href="<?php echo get_option('home') ?>/<?php echo $bp->groups->slug ?>" title="<?php _e( 'Groups', 'buddypress' ) ?>"><?php _e( 'Groups', 'buddypress' ) ?></a></li>
|
664 |
-
<?php } ?>
|
665 |
-
|
666 |
-
<?php if ( function_exists( 'bp_blogs_install' ) ) { ?>
|
667 |
-
<li<?php if ( bp_is_page( $bp->blogs->slug ) ) {?> class="selected"<?php } ?>><a href="<?php echo get_option('home') ?>/<?php echo $bp->blogs->slug ?>" title="<?php _e( 'Blogs', 'buddypress' ) ?>"><?php _e( 'Blogs', 'buddypress' ) ?></a></li>
|
668 |
-
<?php } ?>
|
669 |
-
<?php
|
670 |
-
do_action( 'bp_nav_items' );
|
671 |
-
}
|
672 |
-
|
673 |
function bp_custom_profile_boxes() {
|
674 |
do_action( 'bp_custom_profile_boxes' );
|
675 |
}
|
@@ -678,506 +1037,254 @@ function bp_custom_profile_sidebar_boxes() {
|
|
678 |
do_action( 'bp_custom_profile_sidebar_boxes' );
|
679 |
}
|
680 |
|
681 |
-
function bp_is_directory() {
|
682 |
-
global $bp;
|
683 |
-
|
684 |
-
return $bp->is_directory;
|
685 |
-
}
|
686 |
-
|
687 |
-
/**
|
688 |
-
* bp_create_excerpt()
|
689 |
-
*
|
690 |
-
* Fakes an excerpt on any content. Will not truncate words.
|
691 |
-
*
|
692 |
-
* @package BuddyPress Core
|
693 |
-
* @param $text str The text to create the excerpt from
|
694 |
-
* @uses $excerpt_length The maximum length in characters of the excerpt.
|
695 |
-
* @return str The excerpt text
|
696 |
-
*/
|
697 |
-
function bp_create_excerpt( $text, $excerpt_length = 55, $filter_shortcodes = true ) { // Fakes an excerpt if needed
|
698 |
-
$text = str_replace(']]>', ']]>', $text);
|
699 |
-
|
700 |
-
if ( $filter_shortcodes )
|
701 |
-
$text = preg_replace( '|\[(.+?)\](.+?\[/\\1\])?|s', '', $text );
|
702 |
-
|
703 |
-
$words = explode(' ', $text, $excerpt_length + 1);
|
704 |
-
if (count($words) > $excerpt_length) {
|
705 |
-
array_pop($words);
|
706 |
-
array_push($words, '[...]');
|
707 |
-
$text = implode(' ', $words);
|
708 |
-
}
|
709 |
-
|
710 |
-
return apply_filters( 'bp_create_excerpt', $text );
|
711 |
-
}
|
712 |
-
add_filter( 'bp_create_excerpt', 'wptexturize' );
|
713 |
-
add_filter( 'bp_create_excerpt', 'convert_smilies' );
|
714 |
-
add_filter( 'bp_create_excerpt', 'convert_chars' );
|
715 |
-
add_filter( 'bp_create_excerpt', 'wpautop' );
|
716 |
-
add_filter( 'bp_create_excerpt', 'wp_trim_excerpt' );
|
717 |
-
add_filter( 'bp_create_excerpt', 'stripslashes_deep' );
|
718 |
-
add_filter( 'bp_create_excerpt', 'force_balance_tags' );
|
719 |
-
|
720 |
-
/**
|
721 |
-
* bp_is_serialized()
|
722 |
-
*
|
723 |
-
* Checks to see if the data passed has been serialized.
|
724 |
-
*
|
725 |
-
* @package BuddyPress Core
|
726 |
-
* @param $data str The data that will be checked
|
727 |
-
* @return bool false if the data is not serialized
|
728 |
-
* @return bool true if the data is serialized
|
729 |
-
*/
|
730 |
-
function bp_is_serialized( $data ) {
|
731 |
-
if ( '' == trim($data) ) {
|
732 |
-
return false;
|
733 |
-
}
|
734 |
-
|
735 |
-
if ( preg_match( "/^(i|s|a|o|d)(.*);/si", $data ) ) {
|
736 |
-
return true;
|
737 |
-
}
|
738 |
-
|
739 |
-
return false;
|
740 |
-
}
|
741 |
-
|
742 |
-
/*** Signup form template tags **********************/
|
743 |
-
|
744 |
-
function bp_signup_username_value() {
|
745 |
-
echo bp_get_signup_username_value();
|
746 |
-
}
|
747 |
-
function bp_get_signup_username_value() {
|
748 |
-
return apply_filters( 'bp_get_signup_username_value', $_POST['signup_username'] );
|
749 |
-
}
|
750 |
-
|
751 |
-
function bp_signup_email_value() {
|
752 |
-
echo bp_get_signup_email_value();
|
753 |
-
}
|
754 |
-
function bp_get_signup_email_value() {
|
755 |
-
return apply_filters( 'bp_get_signup_email_value', $_POST['signup_email'] );
|
756 |
-
}
|
757 |
-
|
758 |
-
function bp_signup_with_blog_value() {
|
759 |
-
echo bp_get_signup_with_blog_value();
|
760 |
-
}
|
761 |
-
function bp_get_signup_with_blog_value() {
|
762 |
-
return apply_filters( 'bp_get_signup_with_blog_value', $_POST['signup_with_blog'] );
|
763 |
-
}
|
764 |
-
|
765 |
-
function bp_signup_blog_url_value() {
|
766 |
-
echo bp_get_signup_blog_url_value();
|
767 |
-
}
|
768 |
-
function bp_get_signup_blog_url_value() {
|
769 |
-
return apply_filters( 'bp_get_signup_blog_url_value', $_POST['signup_blog_url'] );
|
770 |
-
}
|
771 |
-
|
772 |
-
function bp_signup_blog_title_value() {
|
773 |
-
echo bp_get_signup_blog_title_value();
|
774 |
-
}
|
775 |
-
function bp_get_signup_blog_title_value() {
|
776 |
-
return apply_filters( 'bp_get_signup_blog_title_value', $_POST['signup_blog_title'] );
|
777 |
-
}
|
778 |
-
|
779 |
-
function bp_signup_blog_privacy_value() {
|
780 |
-
echo bp_get_signup_blog_privacy_value();
|
781 |
-
}
|
782 |
-
function bp_get_signup_blog_privacy_value() {
|
783 |
-
return apply_filters( 'bp_get_signup_blog_privacy_value', $_POST['signup_blog_privacy'] );
|
784 |
-
}
|
785 |
-
|
786 |
-
function bp_signup_avatar_dir_value() {
|
787 |
-
echo bp_get_signup_avatar_dir_value();
|
788 |
-
}
|
789 |
-
function bp_get_signup_avatar_dir_value() {
|
790 |
-
global $bp;
|
791 |
-
|
792 |
-
return apply_filters( 'bp_get_signup_avatar_dir_value', $bp->signup->avatar_dir );
|
793 |
-
}
|
794 |
-
|
795 |
-
function bp_current_signup_step() {
|
796 |
-
echo bp_get_current_signup_step();
|
797 |
-
}
|
798 |
-
function bp_get_current_signup_step() {
|
799 |
-
global $bp;
|
800 |
-
|
801 |
-
return $bp->signup->step;
|
802 |
-
}
|
803 |
-
|
804 |
-
function bp_signup_avatar( $args = '' ) {
|
805 |
-
echo bp_get_signup_avatar( $args = '' );
|
806 |
-
}
|
807 |
-
function bp_get_signup_avatar( $args = '' ) {
|
808 |
-
global $bp;
|
809 |
-
|
810 |
-
$defaults = array(
|
811 |
-
'size' => BP_AVATAR_FULL_WIDTH,
|
812 |
-
'class' => 'avatar',
|
813 |
-
'alt' => __( 'Your Avatar', 'buddypress' )
|
814 |
-
);
|
815 |
-
|
816 |
-
$r = wp_parse_args( $args, $defaults );
|
817 |
-
extract( $r, EXTR_SKIP );
|
818 |
-
|
819 |
-
$signup_avatar_dir = ( !empty( $_POST['signup_avatar_dir'] ) ) ? $_POST['signup_avatar_dir'] : $bp->signup->avatar_dir;
|
820 |
-
|
821 |
-
if ( empty( $signup_avatar_dir ) ) {
|
822 |
-
if ( empty( $bp->grav_default->user ) ) {
|
823 |
-
$default_grav = 'wavatar';
|
824 |
-
} else if ( 'mystery' == $bp->grav_default->user ) {
|
825 |
-
$default_grav = BP_PLUGIN_URL . '/bp-core/images/mystery-man.jpg';
|
826 |
-
} else {
|
827 |
-
$default_grav = $bp->grav_default->user;
|
828 |
-
}
|
829 |
-
|
830 |
-
$gravatar_url = apply_filters( 'bp_gravatar_url', 'http://www.gravatar.com/avatar/' );
|
831 |
-
return apply_filters( 'bp_get_signup_avatar', '<img src="' . $gravatar_url . md5( $_POST['signup_email'] ) . '?d=' . $default_grav . '&s=' . $size ) . '" width="' . $size . '" height="' . $size . '" alt="' . $alt . '" class="' . $class . '" />';
|
832 |
-
} else {
|
833 |
-
return apply_filters( 'bp_get_signup_avatar', bp_core_fetch_avatar( array( 'item_id' => $signup_avatar_dir, 'object' => 'signup', 'avatar_dir' => 'avatars/signups', 'type' => 'full', 'width' => $size, 'height' => $size, 'alt' => $alt, 'class' => $class ) ) );
|
834 |
-
}
|
835 |
-
}
|
836 |
-
|
837 |
-
function bp_signup_allowed() {
|
838 |
-
echo bp_get_signup_allowed();
|
839 |
-
}
|
840 |
-
function bp_get_signup_allowed() {
|
841 |
-
return get_site_option( 'registration' );
|
842 |
-
}
|
843 |
-
|
844 |
-
function bp_account_was_activated() {
|
845 |
-
global $bp;
|
846 |
-
|
847 |
-
return $bp->activation_complete;
|
848 |
-
}
|
849 |
-
|
850 |
-
|
851 |
-
/*** CUSTOM LOOP TEMPLATE CLASSES *******************/
|
852 |
-
|
853 |
-
class BP_Core_Members_Template {
|
854 |
-
var $current_member = -1;
|
855 |
-
var $member_count;
|
856 |
-
var $members;
|
857 |
-
var $member;
|
858 |
-
|
859 |
-
var $in_the_loop;
|
860 |
-
|
861 |
-
var $pag_page;
|
862 |
-
var $pag_num;
|
863 |
-
var $pag_links;
|
864 |
-
var $total_member_count;
|
865 |
-
|
866 |
-
function bp_core_members_template( $type, $per_page, $max ) {
|
867 |
-
global $bp, $bp_the_member_query;
|
868 |
-
|
869 |
-
$this->pag_page = isset( $_REQUEST['upage'] ) ? intval( $_REQUEST['upage'] ) : 1;
|
870 |
-
$this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
|
871 |
-
|
872 |
-
if ( isset( $_REQUEST['s'] ) && '' != $_REQUEST['s'] && $type != 'random' ) {
|
873 |
-
$this->members = BP_Core_User::search_users( $_REQUEST['s'], $this->pag_num, $this->pag_page );
|
874 |
-
} else if ( isset( $_REQUEST['letter'] ) && '' != $_REQUEST['letter'] ) {
|
875 |
-
$this->members = BP_Core_User::get_users_by_letter( $_REQUEST['letter'], $this->pag_num, $this->pag_page );
|
876 |
-
} else {
|
877 |
-
switch ( $type ) {
|
878 |
-
case 'random':
|
879 |
-
$this->members = BP_Core_User::get_random_users( $this->pag_num, $this->pag_page );
|
880 |
-
break;
|
881 |
-
|
882 |
-
case 'newest':
|
883 |
-
$this->members = BP_Core_User::get_newest_users( $this->pag_num, $this->pag_page );
|
884 |
-
break;
|
885 |
-
|
886 |
-
case 'popular':
|
887 |
-
$this->members = BP_Core_User::get_popular_users( $this->pag_num, $this->pag_page );
|
888 |
-
break;
|
889 |
-
|
890 |
-
case 'online':
|
891 |
-
$this->members = BP_Core_User::get_online_users( $this->pag_num, $this->pag_page );
|
892 |
-
break;
|
893 |
-
|
894 |
-
case 'alphabetical':
|
895 |
-
$this->members = BP_Core_User::get_alphabetical_users( $this->pag_num, $this->pag_page );
|
896 |
-
break;
|
897 |
-
|
898 |
-
case 'active': default:
|
899 |
-
$this->members = BP_Core_User::get_active_users( $this->pag_num, $this->pag_page );
|
900 |
-
break;
|
901 |
-
}
|
902 |
-
}
|
903 |
-
|
904 |
-
if ( !$max || $max >= (int)$this->members['total'] )
|
905 |
-
$this->total_member_count = (int)$this->members['total'];
|
906 |
-
else
|
907 |
-
$this->total_member_count = (int)$max;
|
908 |
-
|
909 |
-
$this->members = $this->members['users'];
|
910 |
-
|
911 |
-
if ( $max ) {
|
912 |
-
if ( $max >= count($this->members) )
|
913 |
-
$this->member_count = count($this->members);
|
914 |
-
else
|
915 |
-
$this->member_count = (int)$max;
|
916 |
-
} else {
|
917 |
-
$this->member_count = count($this->members);
|
918 |
-
}
|
919 |
-
|
920 |
-
if ( (int) $this->total_member_count && (int) $this->pag_num ) {
|
921 |
-
$this->pag_links = paginate_links( array(
|
922 |
-
'base' => add_query_arg( 'upage', '%#%' ),
|
923 |
-
'format' => '',
|
924 |
-
'total' => ceil( (int) $this->total_member_count / (int) $this->pag_num ),
|
925 |
-
'current' => (int) $this->pag_page,
|
926 |
-
'prev_text' => '«',
|
927 |
-
'next_text' => '»',
|
928 |
-
'mid_size' => 1
|
929 |
-
));
|
930 |
-
}
|
931 |
-
}
|
932 |
-
|
933 |
-
function has_members() {
|
934 |
-
if ( $this->member_count )
|
935 |
-
return true;
|
936 |
-
|
937 |
-
return false;
|
938 |
-
}
|
939 |
-
|
940 |
-
function next_member() {
|
941 |
-
$this->current_member++;
|
942 |
-
$this->member = $this->members[$this->current_member];
|
943 |
-
|
944 |
-
return $this->member;
|
945 |
-
}
|
946 |
-
|
947 |
-
function rewind_members() {
|
948 |
-
$this->current_member = -1;
|
949 |
-
if ( $this->member_count > 0 ) {
|
950 |
-
$this->member = $this->members[0];
|
951 |
-
}
|
952 |
-
}
|
953 |
-
|
954 |
-
function site_members() {
|
955 |
-
if ( $this->current_member + 1 < $this->member_count ) {
|
956 |
-
return true;
|
957 |
-
} elseif ( $this->current_member + 1 == $this->member_count ) {
|
958 |
-
do_action('loop_end');
|
959 |
-
// Do some cleaning up after the loop
|
960 |
-
$this->rewind_members();
|
961 |
-
}
|
962 |
-
|
963 |
-
$this->in_the_loop = false;
|
964 |
-
return false;
|
965 |
-
}
|
966 |
-
|
967 |
-
function the_member() {
|
968 |
-
global $member, $bp;
|
969 |
-
|
970 |
-
$this->in_the_loop = true;
|
971 |
-
$this->member = $this->next_member();
|
972 |
-
$user_id = $this->member->user_id;
|
973 |
-
$user_registered = $this->member->user_registered;
|
974 |
-
|
975 |
-
if ( !$this->member = wp_cache_get( 'bp_user_' . $user_id, 'bp' ) ) {
|
976 |
-
$this->member = new BP_Core_User( $user_id );
|
977 |
-
wp_cache_set( 'bp_user_' . $user_id, $this->member, 'bp' );
|
978 |
-
}
|
979 |
-
|
980 |
-
if ( $user_registered )
|
981 |
-
$this->member->user_registered = $user_registered;
|
982 |
-
|
983 |
-
if ( 0 == $this->current_member ) // loop has just started
|
984 |
-
do_action('loop_start');
|
985 |
-
}
|
986 |
-
}
|
987 |
-
|
988 |
-
function bp_rewind_site_members() {
|
989 |
-
global $site_members_template;
|
990 |
|
991 |
-
return $
|
992 |
}
|
993 |
|
994 |
-
|
995 |
-
|
996 |
-
|
997 |
-
|
998 |
-
|
999 |
-
|
1000 |
-
|
1001 |
-
|
|
|
|
|
|
|
|
|
1002 |
|
1003 |
-
|
1004 |
-
|
1005 |
|
1006 |
-
|
|
|
|
|
|
|
|
|
|
|
1007 |
|
1008 |
-
if ( $
|
1009 |
-
|
1010 |
-
|
|
|
1011 |
}
|
1012 |
|
1013 |
-
|
1014 |
-
|
1015 |
-
return $site_members_template->has_members();
|
1016 |
}
|
|
|
|
|
|
|
1017 |
|
1018 |
-
|
1019 |
-
|
1020 |
-
|
1021 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1022 |
|
1023 |
-
|
1024 |
-
|
1025 |
-
|
|
|
1026 |
}
|
1027 |
|
1028 |
-
function
|
1029 |
-
|
|
|
|
|
|
|
|
|
|
|
1030 |
|
1031 |
-
|
1032 |
-
$to_num = ( $from_num + ( $site_members_template->pag_num - 1 ) > $site_members_template->total_member_count ) ? $site_members_template->total_member_count : $from_num + ( $site_members_template->pag_num - 1) ;
|
1033 |
|
1034 |
-
|
1035 |
-
|
1036 |
}
|
|
|
|
|
|
|
1037 |
|
1038 |
-
function
|
1039 |
-
echo
|
1040 |
}
|
1041 |
-
function
|
1042 |
-
|
1043 |
-
|
1044 |
-
return apply_filters( 'bp_get_site_members_pagination_links', $site_members_template->pag_links );
|
1045 |
}
|
1046 |
|
1047 |
-
function
|
1048 |
-
echo
|
1049 |
}
|
1050 |
-
function
|
1051 |
-
|
1052 |
-
|
1053 |
-
return apply_filters( 'bp_get_the_site_member_user_id', $site_members_template->member->id );
|
1054 |
}
|
1055 |
|
1056 |
-
function
|
1057 |
-
echo
|
1058 |
}
|
1059 |
-
function
|
1060 |
-
|
1061 |
-
|
1062 |
-
return apply_filters( 'bp_get_the_site_member_avatar', $site_members_template->member->avatar_thumb );
|
1063 |
}
|
1064 |
|
1065 |
-
function
|
1066 |
-
echo
|
1067 |
}
|
1068 |
-
function
|
1069 |
-
|
|
|
1070 |
|
1071 |
-
|
|
|
|
|
|
|
|
|
1072 |
}
|
1073 |
|
1074 |
-
function
|
1075 |
-
echo
|
1076 |
}
|
1077 |
-
function
|
1078 |
-
global $
|
1079 |
|
1080 |
-
return apply_filters( '
|
1081 |
}
|
1082 |
-
add_filter( 'bp_get_the_site_member_name', 'wp_filter_kses' );
|
1083 |
-
add_filter( 'bp_get_the_site_member_name', 'stripslashes' );
|
1084 |
|
1085 |
-
function
|
1086 |
-
echo
|
1087 |
}
|
1088 |
-
function
|
1089 |
-
global $
|
1090 |
|
1091 |
-
return
|
1092 |
}
|
1093 |
|
1094 |
-
function
|
1095 |
-
echo
|
1096 |
}
|
1097 |
-
function
|
1098 |
-
global $
|
1099 |
|
1100 |
-
|
1101 |
-
|
|
|
|
|
|
|
1102 |
|
1103 |
-
|
1104 |
-
|
1105 |
|
1106 |
-
|
1107 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1108 |
}
|
1109 |
-
}
|
1110 |
|
1111 |
-
function
|
1112 |
-
|
|
|
|
|
|
|
1113 |
|
1114 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
1115 |
return false;
|
|
|
1116 |
|
1117 |
-
|
|
|
1118 |
}
|
1119 |
-
function
|
1120 |
-
global $
|
1121 |
|
1122 |
-
if ( !(
|
1123 |
return false;
|
1124 |
|
1125 |
-
|
1126 |
-
|
1127 |
-
|
1128 |
-
|
|
|
1129 |
}
|
1130 |
|
1131 |
-
function
|
1132 |
-
global $
|
|
|
|
|
|
|
1133 |
|
1134 |
-
|
1135 |
-
|
1136 |
-
<strong><?php echo wp_filter_kses( $random_data[0]->name ) ?></strong>
|
1137 |
-
<?php echo wp_filter_kses( $random_data[0]->value ) ?>
|
1138 |
-
<?php }
|
1139 |
}
|
1140 |
|
1141 |
-
function
|
1142 |
-
|
1143 |
-
|
1144 |
-
|
|
|
|
|
1145 |
|
1146 |
-
|
1147 |
-
echo '<input type="hidden" id="selected_letter" value="' . attribute_escape( $_REQUEST['letter'] ) . '" name="selected_letter" />';
|
1148 |
}
|
1149 |
|
1150 |
-
|
1151 |
-
|
1152 |
-
}
|
1153 |
-
}
|
1154 |
|
1155 |
-
|
1156 |
-
global $bp; ?>
|
1157 |
-
<form action="" method="get" id="search-members-form">
|
1158 |
-
<label><input type="text" name="s" id="members_search" value="<?php if ( isset( $_GET['s'] ) ) { echo attribute_escape( $_GET['s'] ); } else { _e( 'Search anything...', 'buddypress' ); } ?>" onfocus="if (this.value == '<?php _e( 'Search anything...', 'buddypress' ) ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php _e( 'Search anything...', 'buddypress' ) ?>';}" /></label>
|
1159 |
-
<input type="submit" id="members_search_submit" name="members_search_submit" value="<?php _e( 'Search', 'buddypress' ) ?>" />
|
1160 |
-
<?php wp_nonce_field( 'directory_members', '_wpnonce-member-filter' ) ?>
|
1161 |
-
</form>
|
1162 |
-
<?php
|
1163 |
}
|
1164 |
|
1165 |
-
|
1166 |
-
|
1167 |
-
|
1168 |
-
|
1169 |
-
|
1170 |
-
|
1171 |
-
|
1172 |
-
|
|
|
|
|
|
|
|
|
1173 |
|
1174 |
-
|
1175 |
-
|
1176 |
-
else
|
1177 |
-
echo $bp->root_domain;
|
1178 |
}
|
1179 |
|
1180 |
|
|
|
|
|
|
|
1181 |
/* Template functions for fetching globals, without querying the DB again
|
1182 |
also means we dont have to use the $bp variable in the template (looks messy) */
|
1183 |
|
@@ -1202,13 +1309,16 @@ function bp_loggedin_user_domain() {
|
|
1202 |
return apply_filters( 'bp_loggedin_user_domain', $bp->loggedin_user->domain );
|
1203 |
}
|
1204 |
|
1205 |
-
function
|
1206 |
-
|
1207 |
-
echo apply_filters( 'bp_user_fullname', $bp->displayed_user->fullname );
|
1208 |
}
|
1209 |
-
function
|
1210 |
-
|
|
|
|
|
1211 |
}
|
|
|
|
|
1212 |
|
1213 |
function bp_loggedin_user_fullname() {
|
1214 |
echo bp_get_loggedin_user_fullname();
|
@@ -1218,6 +1328,22 @@ function bp_loggedin_user_fullname() {
|
|
1218 |
return apply_filters( 'bp_get_loggedin_user_fullname', $bp->loggedin_user->fullname );
|
1219 |
}
|
1220 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1221 |
function bp_current_component() {
|
1222 |
global $bp;
|
1223 |
return apply_filters( 'bp_current_component', $bp->current_component );
|
@@ -1249,37 +1375,62 @@ function bp_root_domain() {
|
|
1249 |
|
1250 |
/* Template is_() functions to determine the current page */
|
1251 |
|
1252 |
-
function
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1253 |
global $bp;
|
1254 |
|
1255 |
-
if (
|
1256 |
return true;
|
1257 |
|
|
|
|
|
|
|
1258 |
return false;
|
1259 |
}
|
1260 |
|
1261 |
-
function
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1262 |
global $bp;
|
1263 |
|
1264 |
-
if (
|
1265 |
return true;
|
1266 |
|
1267 |
return false;
|
1268 |
}
|
1269 |
|
1270 |
-
function
|
1271 |
global $bp;
|
1272 |
|
1273 |
-
if (
|
1274 |
return true;
|
1275 |
|
1276 |
return false;
|
1277 |
}
|
1278 |
|
1279 |
-
function
|
1280 |
global $bp;
|
1281 |
|
1282 |
-
if (
|
1283 |
return true;
|
1284 |
|
1285 |
return false;
|
@@ -1321,10 +1472,19 @@ function bp_is_settings_component() {
|
|
1321 |
return false;
|
1322 |
}
|
1323 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1324 |
function bp_is_user_activity() {
|
1325 |
global $bp;
|
1326 |
|
1327 |
-
if ( BP_ACTIVITY_SLUG == $bp->current_component
|
1328 |
return true;
|
1329 |
|
1330 |
return false;
|
@@ -1339,10 +1499,19 @@ function bp_is_user_friends_activity() {
|
|
1339 |
return false;
|
1340 |
}
|
1341 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1342 |
function bp_is_user_profile() {
|
1343 |
global $bp;
|
1344 |
|
1345 |
-
if ( BP_XPROFILE_SLUG == $bp->current_component )
|
1346 |
return true;
|
1347 |
|
1348 |
return false;
|
@@ -1366,19 +1535,19 @@ function bp_is_change_avatar() {
|
|
1366 |
return false;
|
1367 |
}
|
1368 |
|
1369 |
-
function
|
1370 |
global $bp;
|
1371 |
|
1372 |
-
if (
|
1373 |
return true;
|
1374 |
|
1375 |
return false;
|
1376 |
}
|
1377 |
|
1378 |
-
function
|
1379 |
global $bp;
|
1380 |
|
1381 |
-
if ( BP_GROUPS_SLUG == $bp->current_component &&
|
1382 |
return true;
|
1383 |
|
1384 |
return false;
|
@@ -1412,28 +1581,28 @@ function bp_is_group_admin_page() {
|
|
1412 |
return false;
|
1413 |
}
|
1414 |
|
1415 |
-
function
|
1416 |
global $bp;
|
1417 |
|
1418 |
-
if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item && '
|
1419 |
return true;
|
1420 |
|
1421 |
return false;
|
1422 |
}
|
1423 |
|
1424 |
-
function
|
1425 |
global $bp;
|
1426 |
|
1427 |
-
if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item && 'forum' == $bp->current_action )
|
1428 |
return true;
|
1429 |
|
1430 |
return false;
|
1431 |
}
|
1432 |
|
1433 |
-
function
|
1434 |
global $bp;
|
1435 |
|
1436 |
-
if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item && 'forum' == $bp->current_action && 'topic' == $bp->action_variables[0] )
|
1437 |
return true;
|
1438 |
|
1439 |
return false;
|
@@ -1451,7 +1620,16 @@ function bp_is_group_members() {
|
|
1451 |
function bp_is_group_invites() {
|
1452 |
global $bp;
|
1453 |
|
1454 |
-
if ( BP_GROUPS_SLUG == $bp->current_component && 'invites' == $bp->current_action )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1455 |
return true;
|
1456 |
|
1457 |
return false;
|
@@ -1478,7 +1656,7 @@ function bp_is_group_single() {
|
|
1478 |
function bp_is_user_blogs() {
|
1479 |
global $bp;
|
1480 |
|
1481 |
-
if ( BP_BLOGS_SLUG == $bp->current_component
|
1482 |
return true;
|
1483 |
|
1484 |
return false;
|
@@ -1514,7 +1692,7 @@ function bp_is_create_blog() {
|
|
1514 |
function bp_is_user_friends() {
|
1515 |
global $bp;
|
1516 |
|
1517 |
-
if ( BP_FRIENDS_SLUG == $bp->current_component
|
1518 |
return true;
|
1519 |
|
1520 |
return false;
|
@@ -1529,6 +1707,15 @@ function bp_is_friend_requests() {
|
|
1529 |
return false;
|
1530 |
}
|
1531 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1532 |
function bp_is_messages_inbox() {
|
1533 |
global $bp;
|
1534 |
|
@@ -1602,30 +1789,21 @@ function bp_the_body_class() {
|
|
1602 |
function bp_get_the_body_class( $wp_classes, $custom_classes = false ) {
|
1603 |
global $bp;
|
1604 |
|
1605 |
-
if (
|
1606 |
$bp_classes[] = 'home-page';
|
1607 |
|
1608 |
-
if ( bp_is_blog_page() || bp_is_register_page() || bp_is_activation_page() )
|
1609 |
-
$bp_classes[] = 'blog-page';
|
1610 |
-
|
1611 |
-
if ( !bp_is_blog_page() && !bp_is_register_page() && !bp_is_activation_page() )
|
1612 |
-
$bp_classes[] = 'internal-page';
|
1613 |
-
|
1614 |
if ( bp_is_directory() )
|
1615 |
$bp_classes[] = 'directory';
|
1616 |
|
1617 |
if ( bp_is_user_profile() && !bp_is_blog_page() )
|
1618 |
$bp_classes[] = 'profile';
|
1619 |
|
1620 |
-
if ( bp_is_activity_component() && !bp_is_blog_page()
|
1621 |
$bp_classes[] = 'activity';
|
1622 |
|
1623 |
if ( bp_is_blogs_component() && !bp_is_blog_page() )
|
1624 |
$bp_classes[] = 'blogs';
|
1625 |
|
1626 |
-
if ( bp_is_wire_component() && !bp_is_blog_page() )
|
1627 |
-
$bp_classes[] = 'wire';
|
1628 |
-
|
1629 |
if ( bp_is_messages_component() && !bp_is_blog_page() )
|
1630 |
$bp_classes[] = 'messages';
|
1631 |
|
@@ -1686,12 +1864,12 @@ function bp_the_body_class() {
|
|
1686 |
if ( bp_is_group_forum_topic() )
|
1687 |
$bp_classes[] = 'group-forum-topic';
|
1688 |
|
|
|
|
|
|
|
1689 |
if ( bp_is_group_forum() )
|
1690 |
$bp_classes[] = 'group-forum';
|
1691 |
|
1692 |
-
if ( bp_is_group_wire() )
|
1693 |
-
$bp_classes[] = 'group-wire';
|
1694 |
-
|
1695 |
if ( bp_is_group_admin_page() )
|
1696 |
$bp_classes[] = 'group-admin';
|
1697 |
|
@@ -1701,9 +1879,6 @@ function bp_the_body_class() {
|
|
1701 |
if ( bp_is_group_home() )
|
1702 |
$bp_classes[] = 'group-home';
|
1703 |
|
1704 |
-
if ( bp_is_profile_wire() )
|
1705 |
-
$bp_classes[] = 'profile-wire';
|
1706 |
-
|
1707 |
if ( bp_is_change_avatar() )
|
1708 |
$bp_classes[] = 'change-avatar';
|
1709 |
|
@@ -1713,9 +1888,12 @@ function bp_the_body_class() {
|
|
1713 |
if ( bp_is_user_friends_activity() )
|
1714 |
$bp_classes[] = 'friends-activity';
|
1715 |
|
1716 |
-
if ( bp_is_user_activity() )
|
1717 |
$bp_classes[] = 'my-activity';
|
1718 |
|
|
|
|
|
|
|
1719 |
if ( bp_is_register_page() )
|
1720 |
$bp_classes[] = 'registration';
|
1721 |
|
1 |
<?php
|
2 |
+
/***
|
3 |
+
* Members template loop that will allow you to loop all members or friends of a member
|
4 |
+
* if you pass a user_id.
|
5 |
+
*/
|
6 |
+
|
7 |
+
class BP_Core_Members_Template {
|
8 |
+
var $current_member = -1;
|
9 |
+
var $member_count;
|
10 |
+
var $members;
|
11 |
+
var $member;
|
12 |
+
|
13 |
+
var $in_the_loop;
|
14 |
+
|
15 |
+
var $pag_page;
|
16 |
+
var $pag_num;
|
17 |
+
var $pag_links;
|
18 |
+
var $total_member_count;
|
19 |
+
|
20 |
+
function bp_core_members_template( $type, $page_number, $per_page, $max, $user_id, $search_terms, $include, $populate_extras ) {
|
21 |
+
global $bp;
|
22 |
+
|
23 |
+
$this->pag_page = isset( $_REQUEST['upage'] ) ? intval( $_REQUEST['upage'] ) : $page_number;
|
24 |
+
$this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
|
25 |
+
$this->type = $type;
|
26 |
+
|
27 |
+
if ( isset( $_REQUEST['letter'] ) && '' != $_REQUEST['letter'] ) {
|
28 |
+
$this->members = BP_Core_User::get_users_by_letter( $_REQUEST['letter'], $this->pag_num, $this->pag_page, $populate_extras );
|
29 |
+
}
|
30 |
+
else if ( false !== $include ) {
|
31 |
+
$this->members = BP_Core_User::get_specific_users( $include, $this->pag_num, $this->pag_page, $populate_extras );
|
32 |
+
}
|
33 |
+
else {
|
34 |
+
$this->members = bp_core_get_users( array( 'type' => $this->type, 'per_page' => $this->pag_num, 'page' => $this->pag_page, 'user_id' => $user_id, 'search_terms' => $search_terms, 'populate_extras' => $populate_extras ) );
|
35 |
+
}
|
36 |
+
|
37 |
+
if ( !$max || $max >= (int)$this->members['total'] )
|
38 |
+
$this->total_member_count = (int)$this->members['total'];
|
39 |
+
else
|
40 |
+
$this->total_member_count = (int)$max;
|
41 |
+
|
42 |
+
$this->members = $this->members['users'];
|
43 |
+
|
44 |
+
if ( $max ) {
|
45 |
+
if ( $max >= count($this->members) )
|
46 |
+
$this->member_count = count($this->members);
|
47 |
+
else
|
48 |
+
$this->member_count = (int)$max;
|
49 |
+
} else {
|
50 |
+
$this->member_count = count($this->members);
|
51 |
+
}
|
52 |
+
|
53 |
+
if ( (int) $this->total_member_count && (int) $this->pag_num ) {
|
54 |
+
$this->pag_links = paginate_links( array(
|
55 |
+
'base' => add_query_arg( 'upage', '%#%' ),
|
56 |
+
'format' => '',
|
57 |
+
'total' => ceil( (int) $this->total_member_count / (int) $this->pag_num ),
|
58 |
+
'current' => (int) $this->pag_page,
|
59 |
+
'prev_text' => '←',
|
60 |
+
'next_text' => '→',
|
61 |
+
'mid_size' => 1
|
62 |
+
));
|
63 |
+
}
|
64 |
+
}
|
65 |
+
|
66 |
+
function has_members() {
|
67 |
+
if ( $this->member_count )
|
68 |
+
return true;
|
69 |
+
|
70 |
+
return false;
|
71 |
+
}
|
72 |
+
|
73 |
+
function next_member() {
|
74 |
+
$this->current_member++;
|
75 |
+
$this->member = $this->members[$this->current_member];
|
76 |
+
|
77 |
+
return $this->member;
|
78 |
+
}
|
79 |
+
|
80 |
+
function rewind_members() {
|
81 |
+
$this->current_member = -1;
|
82 |
+
if ( $this->member_count > 0 ) {
|
83 |
+
$this->member = $this->members[0];
|
84 |
+
}
|
85 |
+
}
|
86 |
+
|
87 |
+
function members() {
|
88 |
+
if ( $this->current_member + 1 < $this->member_count ) {
|
89 |
+
return true;
|
90 |
+
} elseif ( $this->current_member + 1 == $this->member_count ) {
|
91 |
+
do_action('loop_end');
|
92 |
+
// Do some cleaning up after the loop
|
93 |
+
$this->rewind_members();
|
94 |
+
}
|
95 |
+
|
96 |
+
$this->in_the_loop = false;
|
97 |
+
return false;
|
98 |
+
}
|
99 |
+
|
100 |
+
function the_member() {
|
101 |
+
global $member, $bp;
|
102 |
+
|
103 |
+
$this->in_the_loop = true;
|
104 |
+
$this->member = $this->next_member();
|
105 |
+
|
106 |
+
if ( 0 == $this->current_member ) // loop has just started
|
107 |
+
do_action('loop_start');
|
108 |
+
}
|
109 |
+
}
|
110 |
+
|
111 |
+
function bp_rewind_members() {
|
112 |
+
global $members_template;
|
113 |
+
|
114 |
+
return $members_template->rewind_members();
|
115 |
+
}
|
116 |
+
|
117 |
+
function bp_has_members( $args = '' ) {
|
118 |
+
global $bp, $members_template;
|
119 |
+
|
120 |
+
/***
|
121 |
+
* Set the defaults based on the current page. Any of these will be overridden
|
122 |
+
* if arguments are directly passed into the loop. Custom plugins should always
|
123 |
+
* pass their parameters directly to the loop.
|
124 |
+
*/
|
125 |
+
$type = 'active';
|
126 |
+
$user_id = false;
|
127 |
+
$page = 1;
|
128 |
+
$search_terms = false;
|
129 |
+
|
130 |
+
/* User filtering */
|
131 |
+
if ( !empty( $bp->displayed_user->id ) )
|
132 |
+
$user_id = $bp->displayed_user->id;
|
133 |
+
|
134 |
+
/* Pass a filter if ?s= is set. */
|
135 |
+
if ( $_REQUEST['s'] )
|
136 |
+
$search_terms = $_REQUEST['s'];
|
137 |
+
|
138 |
+
// type: active ( default ) | random | newest | popular | online | alphabetical
|
139 |
+
$defaults = array(
|
140 |
+
'type' => $type,
|
141 |
+
'page' => $page,
|
142 |
+
'per_page' => 20,
|
143 |
+
'max' => false,
|
144 |
+
|
145 |
+
'include' => false, // Pass a user_id or comma separated list of user_ids to only show these users
|
146 |
+
|
147 |
+
'user_id' => $user_id, // Pass a user_id to only show friends of this user
|
148 |
+
'search_terms' => $search_terms, // Pass search_terms to filter users by their profile data
|
149 |
+
|
150 |
+
'populate_extras' => true // Fetch usermeta? Friend count, last active etc.
|
151 |
+
);
|
152 |
+
|
153 |
+
$r = wp_parse_args( $args, $defaults );
|
154 |
+
extract( $r );
|
155 |
+
|
156 |
+
if ( $max ) {
|
157 |
+
if ( $per_page > $max )
|
158 |
+
$per_page = $max;
|
159 |
+
}
|
160 |
+
|
161 |
+
$members_template = new BP_Core_Members_Template( $type, $page, $per_page, $max, $user_id, $search_terms, $include, (bool)$populate_extras );
|
162 |
+
|
163 |
+
return $members_template->has_members();
|
164 |
+
}
|
165 |
+
|
166 |
+
function bp_the_member() {
|
167 |
+
global $members_template;
|
168 |
+
return $members_template->the_member();
|
169 |
+
}
|
170 |
+
|
171 |
+
function bp_members() {
|
172 |
+
global $members_template;
|
173 |
+
return $members_template->members();
|
174 |
+
}
|
175 |
+
|
176 |
+
function bp_members_pagination_count() {
|
177 |
+
global $bp, $members_template;
|
178 |
+
|
179 |
+
$from_num = bp_core_number_format( intval( ( $members_template->pag_page - 1 ) * $members_template->pag_num ) + 1 );
|
180 |
+
$to_num = bp_core_number_format( ( $from_num + ( $members_template->pag_num - 1 ) > $members_template->total_member_count ) ? $members_template->total_member_count : $from_num + ( $members_template->pag_num - 1) );
|
181 |
+
$total = bp_core_number_format( $members_template->total_member_count );
|
182 |
+
|
183 |
+
if ( 'active' == $members_template->type )
|
184 |
+
echo sprintf( __( 'Viewing member %s to %s (of %s active members)', 'buddypress' ), $from_num, $to_num, $total );
|
185 |
+
else if ( 'popular' == $members_template->type )
|
186 |
+
echo sprintf( __( 'Viewing member %s to %s (of %s members with friends)', 'buddypress' ), $from_num, $to_num, $total );
|
187 |
+
else if ( 'online' == $members_template->type )
|
188 |
+
echo sprintf( __( 'Viewing member %s to %s (of %s members online)', 'buddypress' ), $from_num, $to_num, $total );
|
189 |
+
else
|
190 |
+
echo sprintf( __( 'Viewing member %s to %s (of %s members)', 'buddypress' ), $from_num, $to_num, $total );
|
191 |
+
|
192 |
+
?><span class="ajax-loader"></span><?php
|
193 |
+
}
|
194 |
+
|
195 |
+
function bp_members_pagination_links() {
|
196 |
+
echo bp_get_members_pagination_links();
|
197 |
+
}
|
198 |
+
function bp_get_members_pagination_links() {
|
199 |
+
global $members_template;
|
200 |
+
|
201 |
+
return apply_filters( 'bp_get_members_pagination_links', $members_template->pag_links );
|
202 |
+
}
|
203 |
+
|
204 |
+
function bp_member_user_id() {
|
205 |
+
echo bp_get_member_user_id();
|
206 |
+
}
|
207 |
+
function bp_get_member_user_id() {
|
208 |
+
global $members_template;
|
209 |
+
|
210 |
+
return apply_filters( 'bp_get_member_user_id', $members_template->member->id );
|
211 |
+
}
|
212 |
+
|
213 |
+
function bp_member_avatar( $args = '' ) {
|
214 |
+
echo apply_filters( 'bp_member_avatar', bp_get_member_avatar( $args ) );
|
215 |
+
}
|
216 |
+
function bp_get_member_avatar( $args = '' ) {
|
217 |
+
global $bp, $members_template;
|
218 |
+
|
219 |
+
$defaults = array(
|
220 |
+
'type' => 'thumb',
|
221 |
+
'width' => false,
|
222 |
+
'height' => false,
|
223 |
+
'class' => 'avatar',
|
224 |
+
'id' => false,
|
225 |
+
'alt' => __( 'Member avatar', 'buddypress' )
|
226 |
+
);
|
227 |
+
|
228 |
+
$r = wp_parse_args( $args, $defaults );
|
229 |
+
extract( $r, EXTR_SKIP );
|
230 |
+
|
231 |
+
return apply_filters( 'bp_get_member_avatar', bp_core_fetch_avatar( array( 'item_id' => $members_template->member->id, 'type' => $type, 'alt' => $alt, 'css_id' => $id, 'class' => $class, 'width' => $width, 'height' => $height, 'email' => $members_template->member->user_email ) ) );
|
232 |
+
}
|
233 |
+
|
234 |
+
function bp_member_permalink() {
|
235 |
+
echo bp_get_member_permalink();
|
236 |
+
}
|
237 |
+
function bp_get_member_permalink() {
|
238 |
+
global $members_template;
|
239 |
+
|
240 |
+
return apply_filters( 'bp_get_member_permalink', bp_core_get_user_domain( $members_template->member->id, $members_template->member->user_nicename, $members_template->member->user_login ) );
|
241 |
+
}
|
242 |
+
function bp_member_link() { echo bp_get_member_permalink(); }
|
243 |
+
function bp_get_member_link() { return bp_get_member_permalink(); }
|
244 |
+
|
245 |
+
function bp_member_name() {
|
246 |
+
echo apply_filters( 'bp_member_name', bp_get_member_name() );
|
247 |
+
}
|
248 |
+
function bp_get_member_name() {
|
249 |
+
global $members_template;
|
250 |
+
|
251 |
+
if ( empty($members_template->member->fullname) )
|
252 |
+
$members_template->member->fullname = $members_template->member->display_name;
|
253 |
+
|
254 |
+
return apply_filters( 'bp_get_member_name', $members_template->member->fullname );
|
255 |
+
}
|
256 |
+
add_filter( 'bp_get_member_name', 'wp_filter_kses' );
|
257 |
+
add_filter( 'bp_get_member_name', 'stripslashes' );
|
258 |
+
add_filter( 'bp_get_member_name', 'strip_tags' );
|
259 |
+
|
260 |
+
function bp_member_last_active() {
|
261 |
+
echo bp_get_member_last_active();
|
262 |
+
}
|
263 |
+
function bp_get_member_last_active() {
|
264 |
+
global $members_template;
|
265 |
+
|
266 |
+
$last_activity = bp_core_get_last_activity( $members_template->member->last_activity, __( 'active %s ago', 'buddypress' ) );
|
267 |
+
|
268 |
+
return apply_filters( 'bp_member_last_active', $last_activity );
|
269 |
+
}
|
270 |
+
|
271 |
+
function bp_member_latest_update( $args = '' ) {
|
272 |
+
echo bp_get_member_latest_update( $args );
|
273 |
+
}
|
274 |
+
function bp_get_member_latest_update( $args = '' ) {
|
275 |
+
global $members_template, $bp;
|
276 |
+
|
277 |
+
$defaults = array(
|
278 |
+
'length' => 15
|
279 |
+
);
|
280 |
+
|
281 |
+
$r = wp_parse_args( $args, $defaults );
|
282 |
+
extract( $r, EXTR_SKIP );
|
283 |
+
|
284 |
+
if ( !$update = maybe_unserialize( $members_template->member->latest_update ) )
|
285 |
+
return false;
|
286 |
+
|
287 |
+
$update_content = apply_filters( 'bp_get_activity_latest_update', strip_tags( bp_create_excerpt( $update['content'], $length ) ) );
|
288 |
+
|
289 |
+
if ( !empty( $update['id'] ) )
|
290 |
+
$update_content .= ' · <a href="' . $bp->root_domain . '/' . BP_ACTIVITY_SLUG . '/p/' . $update['id'] . '">' . __( 'View', 'buddypress' ) . '</a>';
|
291 |
+
|
292 |
+
return apply_filters( 'bp_get_member_latest_update', $update_content );
|
293 |
+
}
|
294 |
+
|
295 |
+
function bp_member_profile_data( $args = '' ) {
|
296 |
+
echo bp_get_member_profile_data( $args );
|
297 |
+
}
|
298 |
+
function bp_get_member_profile_data( $args = '' ) {
|
299 |
+
global $members_template;
|
300 |
+
|
301 |
+
if ( !function_exists( 'xprofile_install' ) )
|
302 |
+
return false;
|
303 |
+
|
304 |
+
$defaults = array(
|
305 |
+
'field' => false, // Field name
|
306 |
+
);
|
307 |
+
|
308 |
+
$r = wp_parse_args( $args, $defaults );
|
309 |
+
extract( $r, EXTR_SKIP );
|
310 |
+
|
311 |
+
// Populate the user if it hasn't been already.
|
312 |
+
if ( empty( $members_template->member->profile_data ) )
|
313 |
+
$members_template->member = new BP_Core_User( $members_template->member->id );
|
314 |
+
|
315 |
+
$data = xprofile_format_profile_field( $members_template->member->profile_data[$field]['field_type'], $members_template->member->profile_data[$field]['field_data'] );
|
316 |
+
|
317 |
+
return apply_filters( 'bp_get_member_profile_data', $data );
|
318 |
+
}
|
319 |
+
|
320 |
+
function bp_member_registered() {
|
321 |
+
echo bp_get_member_registered();
|
322 |
+
}
|
323 |
+
function bp_get_member_registered() {
|
324 |
+
global $members_template;
|
325 |
+
|
326 |
+
$registered = attribute_escape( bp_core_get_last_activity( $members_template->member->user_registered, __( 'registered %s ago', 'buddypress' ) ) );
|
327 |
+
|
328 |
+
return apply_filters( 'bp_member_last_active', $registered );
|
329 |
+
}
|
330 |
+
|
331 |
+
function bp_member_add_friend_button() {
|
332 |
+
global $members_template;
|
333 |
+
|
334 |
+
if ( function_exists( 'bp_add_friend_button' ) ) {
|
335 |
+
if ( null === $members_template->member->is_friend )
|
336 |
+
$friend_status = 'not_friends';
|
337 |
+
else
|
338 |
+
$friend_status = ( 0 == $members_template->member->is_friend ) ? 'pending' : 'is_friend';
|
339 |
+
|
340 |
+
echo bp_add_friend_button( $members_template->member->id, $friend_status );
|
341 |
+
}
|
342 |
+
}
|
343 |
+
|
344 |
+
function bp_member_total_friend_count() {
|
345 |
+
global $members_template;
|
346 |
+
|
347 |
+
echo bp_get_member_total_friend_count();
|
348 |
+
}
|
349 |
+
function bp_get_member_total_friend_count() {
|
350 |
+
global $members_template;
|
351 |
+
|
352 |
+
if ( 1 == (int) $members_template->member->total_friend_count )
|
353 |
+
return apply_filters( 'bp_get_member_total_friend_count', sprintf( __( '%d friend', 'buddypress' ), (int) $members_template->member->total_friend_count ) );
|
354 |
+
else
|
355 |
+
return apply_filters( 'bp_get_member_total_friend_count', sprintf( __( '%d friends', 'buddypress' ), (int) $members_template->member->total_friend_count ) );
|
356 |
+
}
|
357 |
+
|
358 |
+
function bp_member_random_profile_data() {
|
359 |
+
global $members_template;
|
360 |
+
|
361 |
+
if ( function_exists( 'xprofile_get_random_profile_data' ) ) { ?>
|
362 |
+
<?php $random_data = xprofile_get_random_profile_data( $members_template->member->id, true ); ?>
|
363 |
+
<strong><?php echo wp_filter_kses( $random_data[0]->name ) ?></strong>
|
364 |
+
<?php echo wp_filter_kses( $random_data[0]->value ) ?>
|
365 |
+
<?php }
|
366 |
+
}
|
367 |
+
|
368 |
+
function bp_member_hidden_fields() {
|
369 |
+
if ( isset( $_REQUEST['s'] ) ) {
|
370 |
+
echo '<input type="hidden" id="search_terms" value="' . attribute_escape( $_REQUEST['s'] ) . '" name="search_terms" />';
|
371 |
+
}
|
372 |
+
|
373 |
+
if ( isset( $_REQUEST['letter'] ) ) {
|
374 |
+
echo '<input type="hidden" id="selected_letter" value="' . attribute_escape( $_REQUEST['letter'] ) . '" name="selected_letter" />';
|
375 |
+
}
|
376 |
+
|
377 |
+
if ( isset( $_REQUEST['members_search'] ) ) {
|
378 |
+
echo '<input type="hidden" id="search_terms" value="' . attribute_escape( $_REQUEST['members_search'] ) . '" name="search_terms" />';
|
379 |
+
}
|
380 |
+
}
|
381 |
+
|
382 |
+
function bp_directory_members_search_form() {
|
383 |
+
global $bp;
|
384 |
+
|
385 |
+
$search_value = __( 'Search anything...', 'buddypress' );
|
386 |
+
if ( !empty( $_GET['s'] ) )
|
387 |
+
$search_value = $_GET['s'];
|
388 |
+
|
389 |
+
?>
|
390 |
+
<form action="" method="get" id="search-members-form">
|
391 |
+
<label><input type="text" name="s" id="members_search" value="<?php echo attribute_escape( $search_value ) ?>" onfocus="if (this.value == '<?php _e( 'Search anything...', 'buddypress' ) ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php _e( 'Search anything...', 'buddypress' ) ?>';}" /></label>
|
392 |
+
<input type="submit" id="members_search_submit" name="members_search_submit" value="<?php _e( 'Search', 'buddypress' ) ?>" />
|
393 |
+
</form>
|
394 |
+
<?php
|
395 |
+
}
|
396 |
+
|
397 |
+
function bp_total_site_member_count() {
|
398 |
+
echo bp_get_total_site_member_count();
|
399 |
+
}
|
400 |
+
function bp_get_total_site_member_count() {
|
401 |
+
return apply_filters( 'bp_get_total_site_member_count', bp_core_number_format( bp_core_get_total_member_count() ) );
|
402 |
+
}
|
403 |
+
|
404 |
+
|
405 |
+
/** Navigation and other misc template tags **/
|
406 |
+
|
407 |
/**
|
408 |
* bp_get_nav()
|
409 |
* TEMPLATE TAG
|
427 |
foreach( (array) $bp->bp_nav as $nav_item ) {
|
428 |
/* If the current component matches the nav item id, then add a highlight CSS class. */
|
429 |
if ( $bp->active_components[$bp->current_component] == $nav_item['css_id'] ) {
|
430 |
+
$selected = ' class="current selected"';
|
431 |
} else {
|
432 |
$selected = '';
|
433 |
}
|
435 |
/* If we are viewing another person (current_userid does not equal loggedin_user->id)
|
436 |
then check to see if the two users are friends. if they are, add a highlight CSS class
|
437 |
to the friends nav item if it exists. */
|
438 |
+
if ( !bp_is_my_profile() && $bp->displayed_user->id ) {
|
439 |
$selected = '';
|
440 |
|
441 |
if ( function_exists('friends_install') ) {
|
442 |
if ( $nav_item['css_id'] == $bp->friends->id ) {
|
443 |
if ( friends_check_friendship( $bp->loggedin_user->id, $bp->displayed_user->id ) )
|
444 |
+
$selected = ' class="current selected"';
|
445 |
}
|
446 |
}
|
447 |
}
|
459 |
|
460 |
echo apply_filters( 'bp_logout_nav_link', $logout_link );
|
461 |
}
|
|
|
|
|
462 |
|
463 |
/**
|
464 |
* bp_get_displayed_user_nav()
|
473 |
function bp_get_displayed_user_nav() {
|
474 |
global $bp;
|
475 |
|
476 |
+
foreach ( (array)$bp->bp_nav as $user_nav_item ) {
|
477 |
+
if ( !$user_nav_item['show_for_displayed_user'] && !bp_is_my_profile() )
|
478 |
continue;
|
479 |
|
480 |
+
if ( $bp->current_component == $user_nav_item['slug'] )
|
481 |
+
$selected = ' class="current selected"';
|
482 |
else
|
483 |
$selected = '';
|
484 |
|
487 |
else
|
488 |
$link = $bp->displayed_user->domain . $user_nav_item['link'];
|
489 |
|
490 |
+
echo apply_filters( 'bp_get_displayed_user_nav_' . $user_nav_item['css_id'], '<li id="' . $user_nav_item['css_id'] . '-personal-li" ' . $selected . '><a id="user-' . $user_nav_item['css_id'] . '" href="' . $link . '">' . $user_nav_item['name'] . '</a></li>', &$user_nav_item );
|
491 |
}
|
492 |
}
|
|
|
|
|
493 |
|
494 |
/**
|
495 |
* bp_get_options_nav()
|
511 |
function bp_get_options_nav() {
|
512 |
global $bp;
|
513 |
|
514 |
+
if ( count( $bp->bp_options_nav[$bp->current_component] ) < 1 )
|
515 |
+
return false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
516 |
|
517 |
+
/* Loop through each navigation item */
|
518 |
+
foreach ( (array)$bp->bp_options_nav[$bp->current_component] as $subnav_item ) {
|
519 |
+
if ( !$subnav_item['user_has_access'] )
|
520 |
+
continue;
|
|
|
|
|
521 |
|
522 |
+
/* If the current action or an action variable matches the nav item id, then add a highlight CSS class. */
|
523 |
+
if ( $subnav_item['slug'] == $bp->current_action ) {
|
524 |
+
$selected = ' class="current selected"';
|
525 |
+
} else {
|
526 |
+
$selected = '';
|
527 |
}
|
528 |
+
|
529 |
+
/* echo out the final list item */
|
530 |
+
echo apply_filters( 'bp_get_options_nav_' . $subnav_item['css_id'], '<li id="' . $subnav_item['css_id'] . '-personal-li" ' . $selected . '><a id="' . $subnav_item['css_id'] . '" href="' . $subnav_item['link'] . '">' . $subnav_item['name'] . '</a></li>', $subnav_item );
|
531 |
}
|
532 |
}
|
533 |
|
661 |
echo apply_filters( 'bp_site_name', get_blog_option( BP_ROOT_BLOG, 'blogname' ) );
|
662 |
}
|
663 |
|
664 |
+
function bp_is_my_profile() {
|
665 |
global $bp;
|
666 |
|
667 |
if ( is_user_logged_in() && $bp->loggedin_user->id == $bp->displayed_user->id )
|
669 |
|
670 |
return false;
|
671 |
}
|
672 |
+
function bp_is_home() { return bp_is_my_profile(); }
|
673 |
|
674 |
function bp_last_activity( $user_id = false, $echo = true ) {
|
675 |
global $bp;
|
685 |
return apply_filters( 'bp_last_activity', $last_activity );
|
686 |
}
|
687 |
|
688 |
+
function bp_user_firstname() {
|
689 |
+
echo bp_get_user_firstname();
|
690 |
+
}
|
691 |
+
function bp_get_user_firstname( $name = false ) {
|
692 |
+
global $bp;
|
693 |
+
|
694 |
+
if ( !$name )
|
695 |
+
$name = $bp->loggedin_user->fullname;
|
696 |
+
|
697 |
+
$fullname = (array)explode( ' ', $name );
|
698 |
+
|
699 |
+
return apply_filters( 'bp_get_user_firstname', $fullname[0], $fullname );
|
700 |
+
}
|
701 |
+
|
702 |
function bp_user_link() {
|
703 |
global $bp;
|
704 |
|
825 |
else
|
826 |
return apply_filters( 'bp_word_or_name', $youtext );
|
827 |
} else {
|
828 |
+
$fullname = (array)explode( ' ', $bp->displayed_user->fullname );
|
829 |
+
$nametext = sprintf( $nametext, $fullname[0] );
|
830 |
if ( $echo )
|
831 |
echo apply_filters( 'bp_word_or_name', $nametext );
|
832 |
else
|
866 |
}
|
867 |
|
868 |
function bp_is_blog_page() {
|
869 |
+
global $bp, $is_member_page, $wp_query;
|
870 |
|
871 |
+
if ( $wp_query->is_home && !$bp->is_directory )
|
872 |
return true;
|
873 |
|
874 |
+
if ( !$bp->displayed_user->id && !$bp->is_single_item && !$bp->is_directory && !bp_core_is_root_component( $bp->current_component ) )
|
875 |
return true;
|
876 |
|
877 |
return false;
|
884 |
function bp_get_page_title() {
|
885 |
global $bp, $post, $wp_query, $current_blog;
|
886 |
|
887 |
+
if ( is_front_page() || !bp_current_component() || ( is_home() && bp_is_page( 'home' ) ) ) {
|
888 |
$title = __( 'Home', 'buddypress' );
|
889 |
+
|
890 |
} else if ( bp_is_blog_page() ) {
|
891 |
if ( is_single() ) {
|
892 |
+
$title = __( 'Blog | ' . $post->post_title, 'buddypress' );
|
893 |
} else if ( is_category() ) {
|
894 |
+
$title = __( 'Blog | Categories | ' . ucwords( $wp_query->query_vars['category_name'] ), 'buddypress' );
|
895 |
} else if ( is_tag() ) {
|
896 |
+
$title = __( 'Blog | Tags | ' . ucwords( $wp_query->query_vars['tag'] ), 'buddypress' );
|
897 |
+
} else if ( is_page() ){
|
898 |
+
$title = $post->post_title;
|
899 |
} else
|
900 |
$title = __( 'Blog', 'buddypress' );
|
901 |
|
902 |
} else if ( !empty( $bp->displayed_user->fullname ) ) {
|
903 |
+
$title = strip_tags( $bp->displayed_user->fullname . ' | ' . ucwords( $bp->current_component ) );
|
904 |
+
|
905 |
} else if ( $bp->is_single_item ) {
|
906 |
+
$title = ucwords( $bp->current_component ) . ' | ' . $bp->bp_options_title . ' | ' . $bp->bp_options_nav[$bp->current_component][$bp->current_action]['name'];
|
907 |
+
|
908 |
} else if ( $bp->is_directory ) {
|
909 |
if ( !$bp->current_component )
|
910 |
$title = sprintf( __( '%s Directory', 'buddypress' ), ucwords( BP_MEMBERS_SLUG ) );
|
911 |
else
|
912 |
$title = sprintf( __( '%s Directory', 'buddypress' ), ucwords( $bp->current_component ) );
|
913 |
+
|
914 |
+
} else if ( bp_is_register_page() ) {
|
915 |
+
$title = __( 'Create an Account', 'buddypress' );
|
916 |
+
|
917 |
+
} else if ( bp_is_activation_page() ) {
|
918 |
+
$title = __( 'Activate your Account', 'buddypress' );
|
919 |
}
|
920 |
|
921 |
if ( defined( 'BP_ENABLE_MULTIBLOG' ) ) {
|
924 |
$blog_title = get_blog_option( BP_ROOT_BLOG, 'blogname' );
|
925 |
}
|
926 |
|
927 |
+
return apply_filters( 'bp_page_title', $blog_title . ' | ' . esc_attr( $title ), esc_attr( $title ) );
|
928 |
}
|
929 |
|
930 |
function bp_styles() {
|
932 |
wp_print_styles();
|
933 |
}
|
934 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
935 |
function bp_has_custom_signup_page() {
|
936 |
+
if ( locate_template( array( 'register.php' ), false ) || locate_template( array( '/registration/register.php' ), false ) )
|
|
|
|
|
|
|
937 |
return true;
|
938 |
|
939 |
return false;
|
940 |
}
|
941 |
|
942 |
+
function bp_signup_page() {
|
943 |
+
echo bp_get_signup_page();
|
|
|
|
|
|
|
944 |
}
|
945 |
function bp_get_signup_page() {
|
946 |
global $bp;
|
947 |
|
948 |
+
if ( bp_has_custom_signup_page() )
|
949 |
+
$page = $bp->root_domain . '/' . BP_REGISTER_SLUG;
|
950 |
+
else
|
951 |
+
$page = $bp->root_domain . '/wp-signup.php';
|
952 |
+
|
953 |
+
return apply_filters( 'bp_get_signup_page', $page );
|
954 |
}
|
955 |
|
956 |
function bp_has_custom_activation_page() {
|
957 |
+
if ( locate_template( array( 'activate.php' ), false ) || locate_template( array( '/registration/activate.php' ), false ) )
|
|
|
|
|
|
|
958 |
return true;
|
959 |
|
960 |
return false;
|
961 |
}
|
962 |
|
963 |
+
function bp_activation_page() {
|
964 |
+
echo bp_get_activation_page();
|
965 |
+
}
|
966 |
+
function bp_get_activation_page() {
|
967 |
+
global $bp;
|
968 |
|
969 |
+
if ( bp_has_custom_activation_page() )
|
970 |
+
$page = $bp->root_domain . '/' . BP_ACTIVATION_SLUG;
|
|
|
|
|
|
|
|
|
|
|
|
|
971 |
else
|
972 |
+
$page = $bp->root_domain . '/wp-activate.php';
|
973 |
+
|
974 |
+
return apply_filters( 'bp_get_activation_page', $page );
|
975 |
}
|
|
|
976 |
|
977 |
function bp_search_form_action() {
|
978 |
global $bp;
|
979 |
|
980 |
+
return apply_filters( 'bp_search_form_action', $bp->root_domain . '/' . BP_SEARCH_SLUG );
|
981 |
}
|
982 |
|
983 |
function bp_search_form_type_select() {
|
992 |
$selection_box .= '<option value="groups">' . __( 'Groups', 'buddypress' ) . '</option>';
|
993 |
}
|
994 |
|
995 |
+
if ( function_exists( 'bp_forums_setup' ) && !(int) $bp->site_options['bp-disable-forum-directory'] ) {
|
996 |
$selection_box .= '<option value="forums">' . __( 'Forums', 'buddypress' ) . '</option>';
|
997 |
}
|
998 |
|
999 |
+
if ( function_exists( 'bp_blogs_install' ) && bp_core_is_multisite() ) {
|
1000 |
$selection_box .= '<option value="blogs">' . __( 'Blogs', 'buddypress' ) . '</option>';
|
1001 |
}
|
1002 |
|
1029 |
echo apply_filters( 'bp_logout_link', $logout_link );
|
1030 |
}
|
1031 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1032 |
function bp_custom_profile_boxes() {
|
1033 |
do_action( 'bp_custom_profile_boxes' );
|
1034 |
}
|
1037 |
do_action( 'bp_custom_profile_sidebar_boxes' );
|
1038 |
}
|
1039 |
|
1040 |
+
function bp_is_directory() {
|
1041 |
+
global $bp;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1042 |
|
1043 |
+
return $bp->is_directory;
|
1044 |
}
|
1045 |
|
1046 |
+
/**
|
1047 |
+
* bp_create_excerpt()
|
1048 |
+
*
|
1049 |
+
* Fakes an excerpt on any content. Will not truncate words.
|
1050 |
+
*
|
1051 |
+
* @package BuddyPress Core
|
1052 |
+
* @param $text str The text to create the excerpt from
|
1053 |
+
* @uses $excerpt_length The maximum length in characters of the excerpt.
|
1054 |
+
* @return str The excerpt text
|
1055 |
+
*/
|
1056 |
+
function bp_create_excerpt( $text, $excerpt_length = 55, $filter_shortcodes = true ) { // Fakes an excerpt if needed
|
1057 |
+
$text = str_replace(']]>', ']]>', $text);
|
1058 |
|
1059 |
+
if ( $filter_shortcodes )
|
1060 |
+
$text = preg_replace( '|\[(.+?)\](.+?\[/\\1\])?|s', '', $text );
|
1061 |
|
1062 |
+
$words = preg_split(
|
1063 |
+
"%\s*((?:<[^>]+>)+\S*)\s*|\s+%s",
|
1064 |
+
$text,
|
1065 |
+
$excerpt_length + 1,
|
1066 |
+
PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE
|
1067 |
+
);
|
1068 |
|
1069 |
+
if (count($words) > $excerpt_length) {
|
1070 |
+
array_pop($words);
|
1071 |
+
array_push($words, '[...]');
|
1072 |
+
$text = implode(' ', $words);
|
1073 |
}
|
1074 |
|
1075 |
+
return apply_filters( 'bp_create_excerpt', $text );
|
|
|
|
|
1076 |
}
|
1077 |
+
add_filter( 'bp_create_excerpt', 'wp_trim_excerpt' );
|
1078 |
+
add_filter( 'bp_create_excerpt', 'stripslashes_deep' );
|
1079 |
+
add_filter( 'bp_create_excerpt', 'force_balance_tags' );
|
1080 |
|
1081 |
+
/**
|
1082 |
+
* bp_is_serialized()
|
1083 |
+
*
|
1084 |
+
* Checks to see if the data passed has been serialized.
|
1085 |
+
*
|
1086 |
+
* @package BuddyPress Core
|
1087 |
+
* @param $data str The data that will be checked
|
1088 |
+
* @return bool false if the data is not serialized
|
1089 |
+
* @return bool true if the data is serialized
|
1090 |
+
*/
|
1091 |
+
function bp_is_serialized( $data ) {
|
1092 |
+
if ( '' == trim($data) )
|
1093 |
+
return false;
|
1094 |
|
1095 |
+
if ( preg_match( "/^(i|s|a|o|d)(.*);/si", $data ) )
|
1096 |
+
return true;
|
1097 |
+
|
1098 |
+
return false;
|
1099 |
}
|
1100 |
|
1101 |
+
function bp_total_member_count() {
|
1102 |
+
echo bp_get_total_member_count();
|
1103 |
+
}
|
1104 |
+
function bp_get_total_member_count() {
|
1105 |
+
return apply_filters( 'bp_get_total_member_count', bp_core_get_total_member_count() );
|
1106 |
+
}
|
1107 |
+
add_filter( 'bp_get_total_member_count', 'bp_core_number_format' );
|
1108 |
|
1109 |
+
/*** Signup form template tags **********************/
|
|
|
1110 |
|
1111 |
+
function bp_signup_username_value() {
|
1112 |
+
echo bp_get_signup_username_value();
|
1113 |
}
|
1114 |
+
function bp_get_signup_username_value() {
|
1115 |
+
return apply_filters( 'bp_get_signup_username_value', $_POST['signup_username'] );
|
1116 |
+
}
|
1117 |
|
1118 |
+
function bp_signup_email_value() {
|
1119 |
+
echo bp_get_signup_email_value();
|
1120 |
}
|
1121 |
+
function bp_get_signup_email_value() {
|
1122 |
+
return apply_filters( 'bp_get_signup_email_value', $_POST['signup_email'] );
|
|
|
|
|
1123 |
}
|
1124 |
|
1125 |
+
function bp_signup_with_blog_value() {
|
1126 |
+
echo bp_get_signup_with_blog_value();
|
1127 |
}
|
1128 |
+
function bp_get_signup_with_blog_value() {
|
1129 |
+
return apply_filters( 'bp_get_signup_with_blog_value', $_POST['signup_with_blog'] );
|
|
|
|
|
1130 |
}
|
1131 |
|
1132 |
+
function bp_signup_blog_url_value() {
|
1133 |
+
echo bp_get_signup_blog_url_value();
|
1134 |
}
|
1135 |
+
function bp_get_signup_blog_url_value() {
|
1136 |
+
return apply_filters( 'bp_get_signup_blog_url_value', $_POST['signup_blog_url'] );
|
|
|
|
|
1137 |
}
|
1138 |
|
1139 |
+
function bp_signup_blog_title_value() {
|
1140 |
+
echo bp_get_signup_blog_title_value();
|
1141 |
}
|
1142 |
+
function bp_get_signup_blog_title_value() {
|
1143 |
+
return apply_filters( 'bp_get_signup_blog_title_value', $_POST['signup_blog_title'] );
|
1144 |
+
}
|
1145 |
|
1146 |
+
function bp_signup_blog_privacy_value() {
|
1147 |
+
echo bp_get_signup_blog_privacy_value();
|
1148 |
+
}
|
1149 |
+
function bp_get_signup_blog_privacy_value() {
|
1150 |
+
return apply_filters( 'bp_get_signup_blog_privacy_value', $_POST['signup_blog_privacy'] );
|
1151 |
}
|
1152 |
|
1153 |
+
function bp_signup_avatar_dir_value() {
|
1154 |
+
echo bp_get_signup_avatar_dir_value();
|
1155 |
}
|
1156 |
+
function bp_get_signup_avatar_dir_value() {
|
1157 |
+
global $bp;
|
1158 |
|
1159 |
+
return apply_filters( 'bp_get_signup_avatar_dir_value', $bp->signup->avatar_dir );
|
1160 |
}
|
|
|
|
|
1161 |
|
1162 |
+
function bp_current_signup_step() {
|
1163 |
+
echo bp_get_current_signup_step();
|
1164 |
}
|
1165 |
+
function bp_get_current_signup_step() {
|
1166 |
+
global $bp;
|
1167 |
|
1168 |
+
return $bp->signup->step;
|
1169 |
}
|
1170 |
|
1171 |
+
function bp_signup_avatar( $args = '' ) {
|
1172 |
+
echo bp_get_signup_avatar( $args = '' );
|
1173 |
}
|
1174 |
+
function bp_get_signup_avatar( $args = '' ) {
|
1175 |
+
global $bp;
|
1176 |
|
1177 |
+
$defaults = array(
|
1178 |
+
'size' => BP_AVATAR_FULL_WIDTH,
|
1179 |
+
'class' => 'avatar',
|
1180 |
+
'alt' => __( 'Your Avatar', 'buddypress' )
|
1181 |
+
);
|
1182 |
|
1183 |
+
$r = wp_parse_args( $args, $defaults );
|
1184 |
+
extract( $r, EXTR_SKIP );
|
1185 |
|
1186 |
+
if ( !bp_core_is_multisite() && !empty( $_POST['signup_username'] ) ) {
|
1187 |
+
$user_id = bp_core_get_userid( $_POST['signup_username'] );
|
1188 |
+
return apply_filters( 'bp_get_signup_avatar', bp_core_fetch_avatar( array( 'item_id' => $user_id, 'type' => 'full', 'width' => $size, 'height' => $size, 'alt' => $alt, 'class' => $class ) ) );
|
1189 |
+
} else {
|
1190 |
+
$signup_avatar_dir = ( !empty( $_POST['signup_avatar_dir'] ) ) ? $_POST['signup_avatar_dir'] : $bp->signup->avatar_dir;
|
1191 |
+
|
1192 |
+
if ( empty( $signup_avatar_dir ) ) {
|
1193 |
+
if ( empty( $bp->grav_default->user ) ) {
|
1194 |
+
$default_grav = 'wavatar';
|
1195 |
+
} else if ( 'mystery' == $bp->grav_default->user ) {
|
1196 |
+
$default_grav = BP_PLUGIN_URL . '/bp-core/images/mystery-man.jpg';
|
1197 |
+
} else {
|
1198 |
+
$default_grav = $bp->grav_default->user;
|
1199 |
+
}
|
1200 |
+
|
1201 |
+
$gravatar_url = apply_filters( 'bp_gravatar_url', 'http://www.gravatar.com/avatar/' );
|
1202 |
+
return apply_filters( 'bp_get_signup_avatar', '<img src="' . $gravatar_url . md5( $_POST['signup_email'] ) . '?d=' . $default_grav . '&s=' . $size ) . '" width="' . $size . '" height="' . $size . '" alt="' . $alt . '" class="' . $class . '" />';
|
1203 |
+
} else {
|
1204 |
+
return apply_filters( 'bp_get_signup_avatar', bp_core_fetch_avatar( array( 'item_id' => $signup_avatar_dir, 'object' => 'signup', 'avatar_dir' => 'avatars/signups', 'type' => 'full', 'width' => $size, 'height' => $size, 'alt' => $alt, 'class' => $class ) ) );
|
1205 |
+
}
|
1206 |
+
}
|
1207 |
}
|
|
|
1208 |
|
1209 |
+
function bp_signup_allowed() {
|
1210 |
+
echo bp_get_signup_allowed();
|
1211 |
+
}
|
1212 |
+
function bp_get_signup_allowed() {
|
1213 |
+
global $bp;
|
1214 |
|
1215 |
+
if ( bp_core_is_multisite() ) {
|
1216 |
+
if ( in_array( $bp->site_options['registration'], array( 'all', 'user' ) ) )
|
1217 |
+
return true;
|
1218 |
+
} else {
|
1219 |
+
if ( (int)get_option( 'users_can_register') )
|
1220 |
+
return true;
|
1221 |
+
}
|
1222 |
return false;
|
1223 |
+
}
|
1224 |
|
1225 |
+
function bp_blog_signup_allowed() {
|
1226 |
+
echo bp_get_blog_signup_allowed();
|
1227 |
}
|
1228 |
+
function bp_get_blog_signup_allowed() {
|
1229 |
+
global $bp;
|
1230 |
|
1231 |
+
if ( !bp_core_is_multisite() )
|
1232 |
return false;
|
1233 |
|
1234 |
+
$status = $bp->site_options['registration'];
|
1235 |
+
if ( 'none' != $status && 'user' != $status )
|
1236 |
+
return true;
|
1237 |
+
|
1238 |
+
return false;
|
1239 |
}
|
1240 |
|
1241 |
+
function bp_account_was_activated() {
|
1242 |
+
global $bp;
|
1243 |
+
|
1244 |
+
return $bp->activation_complete;
|
1245 |
+
}
|
1246 |
|
1247 |
+
function bp_registration_needs_activation() {
|
1248 |
+
return apply_filters( 'bp_registration_needs_activation', bp_core_is_multisite() );
|
|
|
|
|
|
|
1249 |
}
|
1250 |
|
1251 |
+
function bp_mentioned_user_display_name( $user_id_or_username ) {
|
1252 |
+
echo bp_get_mentioned_user_display_name( $user_id_or_username );
|
1253 |
+
}
|
1254 |
+
function bp_get_mentioned_user_display_name( $user_id_or_username ) {
|
1255 |
+
if ( !$name = bp_core_get_user_displayname( $user_id_or_username ) )
|
1256 |
+
$name = __( 'a user' );
|
1257 |
|
1258 |
+
return apply_filters( 'bp_get_mentioned_user_display_name', $name, $user_id_or_username );
|
|
|
1259 |
}
|
1260 |
|
1261 |
+
function bp_get_option( $option_name ) {
|
1262 |
+
global $bp;
|
|
|
|
|
1263 |
|
1264 |
+
return apply_filters( 'bp_get_option', $bp->site_options[$option_name] );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1265 |
}
|
1266 |
|
1267 |
+
/**
|
1268 |
+
* Allow templates to pass parameters directly into the template loops via AJAX
|
1269 |
+
*
|
1270 |
+
* For the most part this will be filtered in a theme's functions.php for example
|
1271 |
+
* in the default theme it is filtered via bp_dtheme_ajax_querystring()
|
1272 |
+
*
|
1273 |
+
* By using this template tag in the templates it will stop them from showing errors
|
1274 |
+
* if someone copies the templates from the default theme into another WordPress theme
|
1275 |
+
* without coping the functions from functions.php.
|
1276 |
+
*/
|
1277 |
+
function bp_ajax_querystring( $object = false ) {
|
1278 |
+
global $bp;
|
1279 |
|
1280 |
+
$bp->ajax_querystring = apply_filters( 'bp_ajax_querystring', $query_string, $object );
|
1281 |
+
return $bp->ajax_querystring;
|
|
|
|
|
1282 |
}
|
1283 |
|
1284 |
|
1285 |
+
/*** CUSTOM LOOP TEMPLATE CLASSES *******************/
|
1286 |
+
|
1287 |
+
|
1288 |
/* Template functions for fetching globals, without querying the DB again
|
1289 |
also means we dont have to use the $bp variable in the template (looks messy) */
|
1290 |
|
1309 |
return apply_filters( 'bp_loggedin_user_domain', $bp->loggedin_user->domain );
|
1310 |
}
|
1311 |
|
1312 |
+
function bp_displayed_user_fullname() {
|
1313 |
+
echo bp_get_displayed_user_fullname();
|
|
|
1314 |
}
|
1315 |
+
function bp_get_displayed_user_fullname() {
|
1316 |
+
global $bp;
|
1317 |
+
|
1318 |
+
return apply_filters( 'bp_displayed_user_fullname', $bp->displayed_user->fullname );
|
1319 |
}
|
1320 |
+
function bp_user_fullname() { echo bp_get_displayed_user_fullname(); }
|
1321 |
+
|
1322 |
|
1323 |
function bp_loggedin_user_fullname() {
|
1324 |
echo bp_get_loggedin_user_fullname();
|
1328 |
return apply_filters( 'bp_get_loggedin_user_fullname', $bp->loggedin_user->fullname );
|
1329 |
}
|
1330 |
|
1331 |
+
function bp_displayed_user_username() {
|
1332 |
+
echo bp_get_displayed_user_username();
|
1333 |
+
}
|
1334 |
+
function bp_get_displayed_user_username() {
|
1335 |
+
global $bp;
|
1336 |
+
return apply_filters( 'bp_get_displayed_user_username', bp_core_get_username( $bp->displayed_user->id, $bp->displayed_user->userdata->user_nicename, $bp->displayed_user->userdata->user_login ) );
|
1337 |
+
}
|
1338 |
+
|
1339 |
+
function bp_loggedin_user_username() {
|
1340 |
+
echo bp_get_loggedin_user_username();
|
1341 |
+
}
|
1342 |
+
function bp_get_loggedin_user_username() {
|
1343 |
+
global $bp;
|
1344 |
+
return apply_filters( 'bp_get_loggedin_user_username', bp_core_get_username( $bp->loggedin_user->id, $bp->loggedin_user->userdata->user_nicename, $bp->loggedin_user->userdata->user_login ) );
|
1345 |
+
}
|
1346 |
+
|
1347 |
function bp_current_component() {
|
1348 |
global $bp;
|
1349 |
return apply_filters( 'bp_current_component', $bp->current_component );
|
1375 |
|
1376 |
/* Template is_() functions to determine the current page */
|
1377 |
|
1378 |
+
function bp_is_front_page() {
|
1379 |
+
if ( 'posts' == get_option('show_on_front') && is_home() )
|
1380 |
+
return true;
|
1381 |
+
else if ( bp_is_activity_front_page() )
|
1382 |
+
return true;
|
1383 |
+
else
|
1384 |
+
return is_front_page();
|
1385 |
+
}
|
1386 |
+
|
1387 |
+
function bp_is_activity_front_page() {
|
1388 |
+
return ( 'page' == get_option('show_on_front') && 'activity' == get_option('page_on_front') && $_SERVER['REQUEST_URI'] == bp_core_get_site_path() );
|
1389 |
+
}
|
1390 |
+
|
1391 |
+
function bp_is_page($page) {
|
1392 |
global $bp;
|
1393 |
|
1394 |
+
if ( !$bp->displayed_user->id && $bp->current_component == $page )
|
1395 |
return true;
|
1396 |
|
1397 |
+
if ( 'home' == $page )
|
1398 |
+
return bp_is_front_page();
|
1399 |
+
|
1400 |
return false;
|
1401 |
}
|
1402 |
|
1403 |
+
function bp_is_active( $component ) {
|
1404 |
+
global $bp_deactivated;
|
1405 |
+
|
1406 |
+
if ( !isset( $bp_deactivated[ 'bp-' . $component . '.php' ] ) )
|
1407 |
+
return true;
|
1408 |
+
|
1409 |
+
return false;
|
1410 |
+
}
|
1411 |
+
|
1412 |
+
function bp_is_profile_component() {
|
1413 |
global $bp;
|
1414 |
|
1415 |
+
if ( BP_XPROFILE_SLUG == $bp->current_component )
|
1416 |
return true;
|
1417 |
|
1418 |
return false;
|
1419 |
}
|
1420 |
|
1421 |
+
function bp_is_activity_component() {
|
1422 |
global $bp;
|
1423 |
|
1424 |
+
if ( BP_ACTIVITY_SLUG == $bp->current_component )
|
1425 |
return true;
|
1426 |
|
1427 |
return false;
|
1428 |
}
|
1429 |
|
1430 |
+
function bp_is_blogs_component() {
|
1431 |
global $bp;
|
1432 |
|
1433 |
+
if ( BP_BLOGS_SLUG == $bp->current_component )
|
1434 |
return true;
|
1435 |
|
1436 |
return false;
|
1472 |
return false;
|
1473 |
}
|
1474 |
|
1475 |
+
function bp_is_member() {
|
1476 |
+
global $bp;
|
1477 |
+
|
1478 |
+
if ( $bp->displayed_user->id )
|
1479 |
+
return true;
|
1480 |
+
|
1481 |
+
return false;
|
1482 |
+
}
|
1483 |
+
|
1484 |
function bp_is_user_activity() {
|
1485 |
global $bp;
|
1486 |
|
1487 |
+
if ( BP_ACTIVITY_SLUG == $bp->current_component )
|
1488 |
return true;
|
1489 |
|
1490 |
return false;
|
1499 |
return false;
|
1500 |
}
|
1501 |
|
1502 |
+
function bp_is_activity_permalink() {
|
1503 |
+
global $bp;
|
1504 |
+
|
1505 |
+
if ( BP_ACTIVITY_SLUG == $bp->current_component && is_numeric( $bp->current_action ) )
|
1506 |
+
return true;
|
1507 |
+
|
1508 |
+
return false;
|
1509 |
+
}
|
1510 |
+
|
1511 |
function bp_is_user_profile() {
|
1512 |
global $bp;
|
1513 |
|
1514 |
+
if ( BP_XPROFILE_SLUG == $bp->current_component || $bp->core->profile->slug == $bp->current_component )
|
1515 |
return true;
|
1516 |
|
1517 |
return false;
|
1535 |
return false;
|
1536 |
}
|
1537 |
|
1538 |
+
function bp_is_user_groups() {
|
1539 |
global $bp;
|
1540 |
|
1541 |
+
if ( BP_GROUPS_SLUG == $bp->current_component )
|
1542 |
return true;
|
1543 |
|
1544 |
return false;
|
1545 |
}
|
1546 |
|
1547 |
+
function bp_is_group() {
|
1548 |
global $bp;
|
1549 |
|
1550 |
+
if ( BP_GROUPS_SLUG == $bp->current_component && $bp->groups->current_group )
|
1551 |
return true;
|
1552 |
|
1553 |
return false;
|
1581 |
return false;
|
1582 |
}
|
1583 |
|
1584 |
+
function bp_is_group_forum() {
|
1585 |
global $bp;
|
1586 |
|
1587 |
+
if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item && 'forum' == $bp->current_action )
|
1588 |
return true;
|
1589 |
|
1590 |
return false;
|
1591 |
}
|
1592 |
|
1593 |
+
function bp_is_group_forum_topic() {
|
1594 |
global $bp;
|
1595 |
|
1596 |
+
if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item && 'forum' == $bp->current_action && 'topic' == $bp->action_variables[0] )
|
1597 |
return true;
|
1598 |
|
1599 |
return false;
|
1600 |
}
|
1601 |
|
1602 |
+
function bp_is_group_forum_topic_edit() {
|
1603 |
global $bp;
|
1604 |
|
1605 |
+
if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item && 'forum' == $bp->current_action && 'topic' == $bp->action_variables[0] && 'edit' == $bp->action_variables[2] )
|
1606 |
return true;
|
1607 |
|
1608 |
return false;
|
1620 |
function bp_is_group_invites() {
|
1621 |
global $bp;
|
1622 |
|
1623 |
+
if ( BP_GROUPS_SLUG == $bp->current_component && 'send-invites' == $bp->current_action )
|
1624 |
+
return true;
|
1625 |
+
|
1626 |
+
return false;
|
1627 |
+
}
|
1628 |
+
|
1629 |
+
function bp_is_group_membership_request() {
|
1630 |
+
global $bp;
|
1631 |
+
|
1632 |
+
if ( BP_GROUPS_SLUG == $bp->current_component && 'request-membership' == $bp->current_action )
|
1633 |
return true;
|
1634 |
|
1635 |
return false;
|
1656 |
function bp_is_user_blogs() {
|
1657 |
global $bp;
|
1658 |
|
1659 |
+
if ( BP_BLOGS_SLUG == $bp->current_component )
|
1660 |
return true;
|
1661 |
|
1662 |
return false;
|
1692 |
function bp_is_user_friends() {
|
1693 |
global $bp;
|
1694 |
|
1695 |
+
if ( BP_FRIENDS_SLUG == $bp->current_component )
|
1696 |
return true;
|
1697 |
|
1698 |
return false;
|
1707 |
return false;
|
1708 |
}
|
1709 |
|
1710 |
+
function bp_is_user_messages() {
|
1711 |
+
global $bp;
|
1712 |
+
|
1713 |
+
if ( BP_MESSAGES_SLUG == $bp->current_component )
|
1714 |
+
return true;
|
1715 |
+
|
1716 |
+
return false;
|
1717 |
+
}
|
1718 |
+
|
1719 |
function bp_is_messages_inbox() {
|
1720 |
global $bp;
|
1721 |
|
1789 |
function bp_get_the_body_class( $wp_classes, $custom_classes = false ) {
|
1790 |
global $bp;
|
1791 |
|
1792 |
+
if ( bp_is_front_page() )
|
1793 |
$bp_classes[] = 'home-page';
|
1794 |
|
|
|
|
|
|
|
|
|
|
|
|
|
1795 |
if ( bp_is_directory() )
|
1796 |
$bp_classes[] = 'directory';
|
1797 |
|
1798 |
if ( bp_is_user_profile() && !bp_is_blog_page() )
|
1799 |
$bp_classes[] = 'profile';
|
1800 |
|
1801 |
+
if ( bp_is_activity_component() && !bp_is_blog_page() || ( bp_is_activity_front_page() && bp_is_front_page() ) )
|
1802 |
$bp_classes[] = 'activity';
|
1803 |
|
1804 |
if ( bp_is_blogs_component() && !bp_is_blog_page() )
|
1805 |
$bp_classes[] = 'blogs';
|
1806 |
|
|
|
|
|
|
|
1807 |
if ( bp_is_messages_component() && !bp_is_blog_page() )
|
1808 |
$bp_classes[] = 'messages';
|
1809 |
|
1864 |
if ( bp_is_group_forum_topic() )
|
1865 |
$bp_classes[] = 'group-forum-topic';
|
1866 |
|
1867 |
+
if ( bp_is_group_forum_topic_edit() )
|
1868 |
+
$bp_classes[] = 'group-forum-topic-edit';
|
1869 |
+
|
1870 |
if ( bp_is_group_forum() )
|
1871 |
$bp_classes[] = 'group-forum';
|
1872 |
|
|
|
|
|
|
|
1873 |
if ( bp_is_group_admin_page() )
|
1874 |
$bp_classes[] = 'group-admin';
|
1875 |
|
1879 |
if ( bp_is_group_home() )
|
1880 |
$bp_classes[] = 'group-home';
|
1881 |
|
|
|
|
|
|
|
1882 |
if ( bp_is_change_avatar() )
|
1883 |
$bp_classes[] = 'change-avatar';
|
1884 |
|
1888 |
if ( bp_is_user_friends_activity() )
|
1889 |
$bp_classes[] = 'friends-activity';
|
1890 |
|
1891 |
+
if ( bp_is_user_activity() && !bp_is_directory() )
|
1892 |
$bp_classes[] = 'my-activity';
|
1893 |
|
1894 |
+
if ( bp_is_activity_permalink() )
|
1895 |
+
$bp_classes[] = 'activity-permalink';
|
1896 |
+
|
1897 |
if ( bp_is_register_page() )
|
1898 |
$bp_classes[] = 'registration';
|
1899 |
|
bp-core/bp-core-widgets.php
CHANGED
@@ -2,69 +2,11 @@
|
|
2 |
|
3 |
/* Register widgets for the core component */
|
4 |
function bp_core_register_widgets() {
|
5 |
-
add_action('widgets_init', create_function('', 'return register_widget("BP_Core_Welcome_Widget");') );
|
6 |
add_action('widgets_init', create_function('', 'return register_widget("BP_Core_Members_Widget");') );
|
7 |
add_action('widgets_init', create_function('', 'return register_widget("BP_Core_Whos_Online_Widget");') );
|
8 |
add_action('widgets_init', create_function('', 'return register_widget("BP_Core_Recently_Active_Widget");') );
|
9 |
}
|
10 |
-
add_action( '
|
11 |
-
|
12 |
-
/*** WELCOME WIDGET *****************/
|
13 |
-
|
14 |
-
class BP_Core_Welcome_Widget extends WP_Widget {
|
15 |
-
function bp_core_welcome_widget() {
|
16 |
-
parent::WP_Widget( false, $name = __( 'Welcome', 'buddypress' ) );
|
17 |
-
}
|
18 |
-
|
19 |
-
function widget($args, $instance) {
|
20 |
-
extract( $args );
|
21 |
-
?>
|
22 |
-
<?php echo $before_widget; ?>
|
23 |
-
<?php echo $before_title
|
24 |
-
. $instance['title']
|
25 |
-
. $after_title; ?>
|
26 |
-
|
27 |
-
<?php if ( $instance['title'] ) : ?><h3><?php echo attribute_escape( stripslashes( $instance['title'] ) ) ?></h3><?php endif; ?>
|
28 |
-
<?php if ( $instance['text'] ) : ?><p><?php echo apply_filters( 'bp_core_welcome_widget_text', $instance['text'] ) ?></p><?php endif; ?>
|
29 |
-
|
30 |
-
<?php if ( !is_user_logged_in() ) { ?>
|
31 |
-
<div class="create-account"><div class="visit generic-button"><a href="<?php bp_signup_page() ?>" title="<?php _e('Create Account', 'buddypress') ?>"><?php _e('Create Account', 'buddypress') ?></a></div></div>
|
32 |
-
<?php } ?>
|
33 |
-
|
34 |
-
<?php echo $after_widget; ?>
|
35 |
-
<?php
|
36 |
-
}
|
37 |
-
|
38 |
-
function update( $new_instance, $old_instance ) {
|
39 |
-
$instance = $old_instance;
|
40 |
-
$instance['title'] = strip_tags( $new_instance['title'] );
|
41 |
-
$instance['text'] = strip_tags( wp_filter_post_kses( $new_instance['text'] ) );
|
42 |
-
|
43 |
-
return $instance;
|
44 |
-
}
|
45 |
-
|
46 |
-
function form( $instance ) {
|
47 |
-
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'text' => '' ) );
|
48 |
-
$title = strip_tags( $instance['title'] );
|
49 |
-
$text = strip_tags( $instance['text'] );
|
50 |
-
?>
|
51 |
-
<p><label for="bp-widget-welcome-title"><?php _e('Title:', 'buddypress'); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo attribute_escape( stripslashes( $title ) ); ?>" /></label></p>
|
52 |
-
<p>
|
53 |
-
<label for="bp-widget-welcome-text"><?php _e( 'Welcome Text:' , 'buddypress'); ?>
|
54 |
-
<textarea id="<?php echo $this->get_field_id( 'text' ); ?>" name="<?php echo $this->get_field_name( 'text' ); ?>" class="widefat" style="height: 100px"><?php echo attribute_escape( stripslashes( $text ) ); ?></textarea>
|
55 |
-
</label>
|
56 |
-
</p>
|
57 |
-
<?php
|
58 |
-
}
|
59 |
-
}
|
60 |
-
add_filter( 'bp_core_welcome_widget_text', 'attribute_escape' );
|
61 |
-
add_filter( 'bp_core_welcome_widget_text', 'wptexturize' );
|
62 |
-
add_filter( 'bp_core_welcome_widget_text', 'convert_smilies' );
|
63 |
-
add_filter( 'bp_core_welcome_widget_text', 'convert_chars' );
|
64 |
-
add_filter( 'bp_core_welcome_widget_text', 'stripslashes' );
|
65 |
-
add_filter( 'bp_core_welcome_widget_text', 'wpautop' );
|
66 |
-
add_filter( 'bp_core_welcome_widget_text', 'force_balance_tags' );
|
67 |
-
|
68 |
|
69 |
/*** MEMBERS WIDGET *****************/
|
70 |
|
@@ -73,7 +15,7 @@ class BP_Core_Members_Widget extends WP_Widget {
|
|
73 |
parent::WP_Widget( false, $name = __( 'Members', 'buddypress' ) );
|
74 |
|
75 |
if ( is_active_widget( false, false, $this->id_base ) )
|
76 |
-
wp_enqueue_script( 'bp_core_widget_members-js', BP_PLUGIN_URL . '/bp-core/js/widget-members.js', array('jquery'
|
77 |
}
|
78 |
|
79 |
function widget($args, $instance) {
|
@@ -86,7 +28,7 @@ class BP_Core_Members_Widget extends WP_Widget {
|
|
86 |
. $widget_name
|
87 |
. $after_title; ?>
|
88 |
|
89 |
-
<?php if (
|
90 |
<div class="item-options" id="members-list-options">
|
91 |
<span class="ajax-loader" id="ajax-loader-members"></span>
|
92 |
<a href="<?php echo site_url() . '/' . BP_MEMBERS_SLUG ?>" id="newest-members" class="selected"><?php _e( 'Newest', 'buddypress' ) ?></a> |
|
@@ -95,15 +37,15 @@ class BP_Core_Members_Widget extends WP_Widget {
|
|
95 |
</div>
|
96 |
|
97 |
<ul id="members-list" class="item-list">
|
98 |
-
<?php while (
|
99 |
<li class="vcard">
|
100 |
<div class="item-avatar">
|
101 |
-
<a href="<?php
|
102 |
</div>
|
103 |
|
104 |
<div class="item">
|
105 |
-
<div class="item-title fn"><a href="<?php
|
106 |
-
<div class="item-meta"><span class="activity"><?php
|
107 |
</div>
|
108 |
</li>
|
109 |
|
@@ -158,11 +100,11 @@ class BP_Core_Whos_Online_Widget extends WP_Widget {
|
|
158 |
. $widget_name
|
159 |
. $after_title; ?>
|
160 |
|
161 |
-
<?php if (
|
162 |
<div class="avatar-block">
|
163 |
-
<?php while (
|
164 |
<div class="item-avatar">
|
165 |
-
<a href="<?php
|
166 |
</div>
|
167 |
<?php endwhile; ?>
|
168 |
</div>
|
@@ -212,11 +154,11 @@ class BP_Core_Recently_Active_Widget extends WP_Widget {
|
|
212 |
. $widget_name
|
213 |
. $after_title; ?>
|
214 |
|
215 |
-
<?php if (
|
216 |
<div class="avatar-block">
|
217 |
-
<?php while (
|
218 |
<div class="item-avatar">
|
219 |
-
<a href="<?php
|
220 |
</div>
|
221 |
<?php endwhile; ?>
|
222 |
</div>
|
@@ -254,66 +196,48 @@ class BP_Core_Recently_Active_Widget extends WP_Widget {
|
|
254 |
function bp_core_ajax_widget_members() {
|
255 |
global $bp;
|
256 |
|
257 |
-
check_ajax_referer('bp_core_widget_members');
|
258 |
|
259 |
switch ( $_POST['filter'] ) {
|
260 |
case 'newest-members':
|
261 |
-
|
262 |
-
$users = BP_Core_User::get_newest_users( $_POST['max-members'], 1 );
|
263 |
-
wp_cache_set( 'newest_users', $users, 'bp' );
|
264 |
-
}
|
265 |
break;
|
266 |
case 'recently-active-members':
|
267 |
-
|
268 |
-
$users = BP_Core_User::get_active_users( $_POST['max-members'], 1 );
|
269 |
-
wp_cache_set( 'active_users', $users, 'bp' );
|
270 |
-
}
|
271 |
break;
|
272 |
case 'popular-members':
|
273 |
-
|
274 |
-
$users = BP_Core_User::get_popular_users( $_POST['max-members'], 1 );
|
275 |
-
wp_cache_set( 'popular_users', $users, 'bp' );
|
276 |
-
}
|
277 |
break;
|
278 |
}
|
279 |
|
280 |
-
if ( $
|
281 |
-
echo '0[[SPLIT]]'; // return valid result.
|
|
|
|
|
|
|
|
|
|
|
|
|
282 |
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
<div class="item">
|
291 |
-
<div class="item-title"><?php echo bp_core_get_userlink( $user->user_id ) ?></div>
|
292 |
-
<div class="item-meta">
|
293 |
-
<span class="activity">
|
294 |
-
<?php
|
295 |
-
if ( 'newest-members' == $_POST['filter'] ) {
|
296 |
-
echo bp_core_get_last_activity( $user->user_registered, __( 'registered %s ago', 'buddypress' ) );
|
297 |
-
} else if ( 'recently-active-members' == $_POST['filter'] ) {
|
298 |
-
echo bp_core_get_last_activity( get_usermeta( $user->user_id, 'last_activity' ), __( 'active %s ago', 'buddypress' ) );
|
299 |
-
} else if ( 'popular-members' == $_POST['filter'] ) {
|
300 |
-
if ( 1 == get_usermeta( $user->user_id, 'total_friend_count' ) )
|
301 |
-
echo get_usermeta( $user->user_id, 'total_friend_count' ) . __(' friend', 'buddypress');
|
302 |
-
else
|
303 |
-
echo get_usermeta( $user->user_id, 'total_friend_count' ) . __(' friends', 'buddypress');
|
304 |
-
}
|
305 |
-
?>
|
306 |
-
</span>
|
307 |
</div>
|
308 |
-
</
|
309 |
-
|
310 |
-
<?php
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
|
|
|
|
|
|
315 |
}
|
316 |
add_action( 'wp_ajax_widget_members', 'bp_core_ajax_widget_members' );
|
317 |
|
318 |
-
|
319 |
?>
|
2 |
|
3 |
/* Register widgets for the core component */
|
4 |
function bp_core_register_widgets() {
|
|
|
5 |
add_action('widgets_init', create_function('', 'return register_widget("BP_Core_Members_Widget");') );
|
6 |
add_action('widgets_init', create_function('', 'return register_widget("BP_Core_Whos_Online_Widget");') );
|
7 |
add_action('widgets_init', create_function('', 'return register_widget("BP_Core_Recently_Active_Widget");') );
|
8 |
}
|
9 |
+
add_action( 'bp_register_widgets', 'bp_core_register_widgets' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
/*** MEMBERS WIDGET *****************/
|
12 |
|
15 |
parent::WP_Widget( false, $name = __( 'Members', 'buddypress' ) );
|
16 |
|
17 |
if ( is_active_widget( false, false, $this->id_base ) )
|
18 |
+
wp_enqueue_script( 'bp_core_widget_members-js', BP_PLUGIN_URL . '/bp-core/js/widget-members.js', array('jquery') );
|
19 |
}
|
20 |
|
21 |
function widget($args, $instance) {
|
28 |
. $widget_name
|
29 |
. $after_title; ?>
|
30 |
|
31 |
+
<?php if ( bp_has_members( 'user_id=0&type=newest&max=' . $instance['max_members'] . '&populate_extras=0' ) ) : ?>
|
32 |
<div class="item-options" id="members-list-options">
|
33 |
<span class="ajax-loader" id="ajax-loader-members"></span>
|
34 |
<a href="<?php echo site_url() . '/' . BP_MEMBERS_SLUG ?>" id="newest-members" class="selected"><?php _e( 'Newest', 'buddypress' ) ?></a> |
|
37 |
</div>
|
38 |
|
39 |
<ul id="members-list" class="item-list">
|
40 |
+
<?php while ( bp_members() ) : bp_the_member(); ?>
|
41 |
<li class="vcard">
|
42 |
<div class="item-avatar">
|
43 |
+
<a href="<?php bp_member_permalink() ?>"><?php bp_member_avatar() ?></a>
|
44 |
</div>
|
45 |
|
46 |
<div class="item">
|
47 |
+
<div class="item-title fn"><a href="<?php bp_member_permalink() ?>" title="<?php bp_member_name() ?>"><?php bp_member_name() ?></a></div>
|
48 |
+
<div class="item-meta"><span class="activity"><?php bp_member_registered() ?></span></div>
|
49 |
</div>
|
50 |
</li>
|
51 |
|
100 |
. $widget_name
|
101 |
. $after_title; ?>
|
102 |
|
103 |
+
<?php if ( bp_has_members( 'user_id=0&type=online&per_page=' . $instance['max_members'] . '&max=' . $instance['max_members'] . '&populate_extras=0' ) ) : ?>
|
104 |
<div class="avatar-block">
|
105 |
+
<?php while ( bp_members() ) : bp_the_member(); ?>
|
106 |
<div class="item-avatar">
|
107 |
+
<a href="<?php bp_member_permalink() ?>"><?php bp_member_avatar() ?></a>
|
108 |
</div>
|
109 |
<?php endwhile; ?>
|
110 |
</div>
|
154 |
. $widget_name
|
155 |
. $after_title; ?>
|
156 |
|
157 |
+
<?php if ( bp_has_members( 'user_id=0&type=active&per_page=' . $instance['max_members'] . '&max=' . $instance['max_members'] . '&populate_extras=0' ) ) : ?>
|
158 |
<div class="avatar-block">
|
159 |
+
<?php while ( bp_members() ) : bp_the_member(); ?>
|
160 |
<div class="item-avatar">
|
161 |
+
<a href="<?php bp_member_permalink() ?>"><?php bp_member_avatar() ?></a>
|
162 |
</div>
|
163 |
<?php endwhile; ?>
|
164 |
</div>
|
196 |
function bp_core_ajax_widget_members() {
|
197 |
global $bp;
|
198 |
|
199 |
+
check_ajax_referer( 'bp_core_widget_members' );
|
200 |
|
201 |
switch ( $_POST['filter'] ) {
|
202 |
case 'newest-members':
|
203 |
+
$type = 'newest';
|
|
|
|
|
|
|
204 |
break;
|
205 |
case 'recently-active-members':
|
206 |
+
$type = 'active';
|
|
|
|
|
|
|
207 |
break;
|
208 |
case 'popular-members':
|
209 |
+
$type = 'popular';
|
|
|
|
|
|
|
210 |
break;
|
211 |
}
|
212 |
|
213 |
+
if ( bp_has_members( 'user_id=0&type=' . $type . '&per_page=' . $_POST['max-members'] . '&max=' . $_POST['max-members'] . '&populate_extras=0' ) ) : ?>
|
214 |
+
<?php echo '0[[SPLIT]]'; // return valid result. TODO: remove this. ?>
|
215 |
+
<div class="avatar-block">
|
216 |
+
<?php while ( bp_members() ) : bp_the_member(); ?>
|
217 |
+
<li class="vcard">
|
218 |
+
<div class="item-avatar">
|
219 |
+
<a href="<?php bp_member_permalink() ?>"><?php bp_member_avatar() ?></a>
|
220 |
+
</div>
|
221 |
|
222 |
+
<div class="item">
|
223 |
+
<div class="item-title fn"><a href="<?php bp_member_permalink() ?>" title="<?php bp_member_name() ?>"><?php bp_member_name() ?></a></div>
|
224 |
+
<?php if ( 'active' == $type || 'newest' == $type ) : ?>
|
225 |
+
<div class="item-meta"><span class="activity"><?php bp_member_last_active() ?></span></div>
|
226 |
+
<?php else : ?>
|
227 |
+
<div class="item-meta"><span class="activity"><?php bp_member_total_friend_count() ?></span></div>
|
228 |
+
<?php endif; ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
229 |
</div>
|
230 |
+
</li>
|
231 |
+
|
232 |
+
<?php endwhile; ?>
|
233 |
+
</div>
|
234 |
+
|
235 |
+
<?php else: ?>
|
236 |
+
<?php echo "-1[[SPLIT]]<li>"; ?>
|
237 |
+
<?php _e( 'There were no members found, please try another filter.', 'buddypress' ) ?>
|
238 |
+
<?php echo "</li>"; ?>
|
239 |
+
<?php endif;
|
240 |
}
|
241 |
add_action( 'wp_ajax_widget_members', 'bp_core_ajax_widget_members' );
|
242 |
|
|
|
243 |
?>
|
bp-core/bp-core-wpabstraction.php
ADDED
@@ -0,0 +1,157 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*****
|
3 |
+
* WordPress Abstraction
|
4 |
+
*
|
5 |
+
* The functions within this file will detect the version of WordPress you are running
|
6 |
+
* and will alter the environment so BuddyPress can run regardless.
|
7 |
+
*
|
8 |
+
* The code below mostly contains function mappings. This code is subject to change once
|
9 |
+
* the 3.0 WordPress version merge takes place.
|
10 |
+
*/
|
11 |
+
|
12 |
+
if ( !bp_core_is_multisite() ) {
|
13 |
+
$wpdb->base_prefix = $wpdb->prefix;
|
14 |
+
$wpdb->blogid = 1;
|
15 |
+
}
|
16 |
+
|
17 |
+
function bp_core_is_multisite() {
|
18 |
+
if ( function_exists( 'is_multisite' ) )
|
19 |
+
return is_multisite();
|
20 |
+
|
21 |
+
if ( !function_exists( 'wpmu_signup_blog' ) )
|
22 |
+
return false;
|
23 |
+
|
24 |
+
return true;
|
25 |
+
}
|
26 |
+
|
27 |
+
function bp_core_get_status_sql( $prefix = false ) {
|
28 |
+
if ( !bp_core_is_multisite() )
|
29 |
+
return "{$prefix}user_status = 0";
|
30 |
+
else
|
31 |
+
return "{$prefix}spam = 0 AND {$prefix}deleted = 0 AND {$prefix}user_status = 0";
|
32 |
+
}
|
33 |
+
|
34 |
+
if ( !function_exists( 'get_blog_option' ) ) {
|
35 |
+
function get_blog_option( $blog_id, $option_name, $default = false ) {
|
36 |
+
return get_option( $option_name, $default );
|
37 |
+
}
|
38 |
+
}
|
39 |
+
|
40 |
+
if ( !function_exists( 'add_blog_option' ) ) {
|
41 |
+
function add_blog_option( $blog_id, $option_name, $option_value ) {
|
42 |
+
return add_option( $option_name, $option_value );
|
43 |
+
}
|
44 |
+
}
|
45 |
+
|
46 |
+
if ( !function_exists( 'update_blog_option' ) ) {
|
47 |
+
function update_blog_option( $blog_id, $option_name, $option_value ) {
|
48 |
+
return update_option( $option_name, $option_value );
|
49 |
+
}
|
50 |
+
}
|
51 |
+
|
52 |
+
if ( !function_exists( 'switch_to_blog' ) ) {
|
53 |
+
function switch_to_blog() {
|
54 |
+
return 1;
|
55 |
+
}
|
56 |
+
}
|
57 |
+
|
58 |
+
if ( !function_exists( 'restore_current_blog' ) ) {
|
59 |
+
function restore_current_blog() {
|
60 |
+
return 1;
|
61 |
+
}
|
62 |
+
}
|
63 |
+
|
64 |
+
if ( !function_exists( 'get_blogs_of_user' ) ) {
|
65 |
+
function get_blogs_of_user() {
|
66 |
+
return false;
|
67 |
+
}
|
68 |
+
}
|
69 |
+
|
70 |
+
if ( !function_exists( 'is_site_admin' ) ) {
|
71 |
+
function is_site_admin() {
|
72 |
+
if ( current_user_can( 'manage_options' ) )
|
73 |
+
return true;
|
74 |
+
|
75 |
+
return false;
|
76 |
+
}
|
77 |
+
}
|
78 |
+
|
79 |
+
if ( !function_exists( 'get_current_user_id' ) ) {
|
80 |
+
function get_current_user_id() {
|
81 |
+
global $current_user;
|
82 |
+
get_currentuserinfo();
|
83 |
+
return $current_user->data->ID;
|
84 |
+
}
|
85 |
+
}
|
86 |
+
|
87 |
+
if ( !function_exists( 'update_blog_status' ) ) {
|
88 |
+
function update_blog_status() {
|
89 |
+
return true;
|
90 |
+
}
|
91 |
+
}
|
92 |
+
|
93 |
+
if ( !function_exists( 'wpmu_validate_user_signup' ) ) {
|
94 |
+
function wpmu_validate_user_signup( $user_name, $user_email ) {
|
95 |
+
global $wpdb;
|
96 |
+
|
97 |
+
$errors = new WP_Error();
|
98 |
+
|
99 |
+
$user_name = preg_replace( "/\s+/", '', sanitize_user( $user_name, true ) );
|
100 |
+
$user_email = sanitize_email( $user_email );
|
101 |
+
|
102 |
+
if ( empty( $user_name ) )
|
103 |
+
$errors->add('user_name', __("Please enter a username"));
|
104 |
+
|
105 |
+
$maybe = array();
|
106 |
+
preg_match( "/[a-z0-9]+/", $user_name, $maybe );
|
107 |
+
|
108 |
+
if( $user_name != $maybe[0] ) {
|
109 |
+
$errors->add('user_name', __("Only lowercase letters and numbers allowed"));
|
110 |
+
}
|
111 |
+
|
112 |
+
$illegal_names = get_site_option( "illegal_names" );
|
113 |
+
if( is_array( $illegal_names ) == false ) {
|
114 |
+
$illegal_names = array( "www", "web", "root", "admin", "main", "invite", "administrator" );
|
115 |
+
add_site_option( "illegal_names", $illegal_names );
|
116 |
+
}
|
117 |
+
if( in_array( $user_name, $illegal_names ) == true ) {
|
118 |
+
$errors->add('user_name', __("That username is not allowed"));
|
119 |
+
}
|
120 |
+
|
121 |
+
if( strlen( $user_name ) < 4 ) {
|
122 |
+
$errors->add('user_name', __("Username must be at least 4 characters"));
|
123 |
+
}
|
124 |
+
|
125 |
+
if ( strpos( " " . $user_name, "_" ) != false )
|
126 |
+
$errors->add('user_name', __("Sorry, usernames may not contain the character '_'!"));
|
127 |
+
|
128 |
+
// all numeric?
|
129 |
+
$match = array();
|
130 |
+
preg_match( '/[0-9]*/', $user_name, $match );
|
131 |
+
if ( $match[0] == $user_name )
|
132 |
+
$errors->add('user_name', __("Sorry, usernames must have letters too!"));
|
133 |
+
|
134 |
+
if ( !is_email( $user_email ) )
|
135 |
+
$errors->add('user_email', __("Please check your email address."));
|
136 |
+
|
137 |
+
$limited_email_domains = get_site_option( 'limited_email_domains' );
|
138 |
+
if ( is_array( $limited_email_domains ) && empty( $limited_email_domains ) == false ) {
|
139 |
+
$emaildomain = substr( $user_email, 1 + strpos( $user_email, '@' ) );
|
140 |
+
if( in_array( $emaildomain, $limited_email_domains ) == false ) {
|
141 |
+
$errors->add('user_email', __("Sorry, that email address is not allowed!"));
|
142 |
+
}
|
143 |
+
}
|
144 |
+
|
145 |
+
// Check if the username has been used already.
|
146 |
+
if ( username_exists($user_name) )
|
147 |
+
$errors->add('user_name', __("Sorry, that username already exists!"));
|
148 |
+
|
149 |
+
// Check if the email address has been used already.
|
150 |
+
if ( email_exists($user_email) )
|
151 |
+
$errors->add('user_email', __("Sorry, that email address is already used!"));
|
152 |
+
|
153 |
+
$result = array('user_name' => $user_name, 'user_email' => $user_email, 'errors' => $errors);
|
154 |
+
|
155 |
+
return apply_filters('wpmu_validate_user_signup', $result);
|
156 |
+
}
|
157 |
+
}
|
bp-core/css/widget-members.css
CHANGED
File without changes
|
bp-core/deprecated/bp-core-deprecated.php
DELETED
@@ -1,965 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/***
|
3 |
-
* Deprecated Core Functionality
|
4 |
-
*
|
5 |
-
* This file contains functions that are deprecated.
|
6 |
-
* You should not under any circumstance use these functions as they are
|
7 |
-
* either no longer valid, or have been replaced with something much more awesome.
|
8 |
-
*
|
9 |
-
* If you are using functions in this file you should slap the back of your head
|
10 |
-
* and then use the functions or solutions that have replaced them.
|
11 |
-
* Most functions contain a note telling you what you should be doing or using instead.
|
12 |
-
*
|
13 |
-
* Of course, things will still work if you use these functions but you will
|
14 |
-
* be the laughing stock of the BuddyPress community. We will all point and laugh at
|
15 |
-
* you. You'll also be making things harder for yourself in the long run,
|
16 |
-
* and you will miss out on lovely performance and functionality improvements.
|
17 |
-
*
|
18 |
-
* If you've checked you are not using any deprecated functions and finished your little
|
19 |
-
* dance, you can add the following line to your wp-config.php file to prevent any of
|
20 |
-
* these old functions from being loaded:
|
21 |
-
*
|
22 |
-
* define( 'BP_IGNORE_DEPRECATED', true );
|
23 |
-
*/
|
24 |
-
|
25 |
-
function bp_core_deprecated_globals() {
|
26 |
-
global $bp;
|
27 |
-
|
28 |
-
/* If we are using a BuddyPress 1.1+ theme ignore this. */
|
29 |
-
if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
|
30 |
-
return false;
|
31 |
-
|
32 |
-
$bp->core->image_base = BP_PLUGIN_URL . '/bp-core/deprecated/images';
|
33 |
-
}
|
34 |
-
add_action( 'plugins_loaded', 'bp_core_deprecated_globals', 3 );
|
35 |
-
add_action( '_admin_menu', 'bp_core_deprecated_globals', 3 ); // must be _admin_menu hook.
|
36 |
-
|
37 |
-
|
38 |
-
/*** BEGIN DEPRECATED SIGNUP FUNCTIONS **********/
|
39 |
-
|
40 |
-
/***
|
41 |
-
* Instead of duplicating the WPMU signup functions as in previous versions
|
42 |
-
* of BuddyPress, all signup functionality is now in the template for easier
|
43 |
-
* customization. Check out the default theme in the file 'register.php'.
|
44 |
-
*/
|
45 |
-
|
46 |
-
function bp_core_signup_set_headers() {
|
47 |
-
add_action( 'wp_head', 'bp_core_signup_register_headers' ) ;
|
48 |
-
require_once( ABSPATH . WPINC . '/registration.php' );
|
49 |
-
|
50 |
-
if( is_array( get_site_option( 'illegal_names' )) && $_GET[ 'new' ] != '' && in_array( $_GET[ 'new' ], get_site_option( 'illegal_names' ) ) == true ) {
|
51 |
-
wp_redirect( "http://{$current_site->domain}{$current_site->path}" );
|
52 |
-
die();
|
53 |
-
}
|
54 |
-
}
|
55 |
-
|
56 |
-
function bp_core_signup_do_headers() {
|
57 |
-
do_action("signup_header");
|
58 |
-
}
|
59 |
-
add_action( 'wp_head', 'bp_core_signup_do_headers' );
|
60 |
-
|
61 |
-
function bp_core_signup_register_headers() {
|
62 |
-
echo "<meta name='robots' content='noindex,nofollow' />\n";
|
63 |
-
}
|
64 |
-
|
65 |
-
function bp_core_signup_show_blog_form( $blogname = '', $blog_title = '', $errors = '' ) {
|
66 |
-
global $current_site;
|
67 |
-
|
68 |
-
?>
|
69 |
-
<h3><?php _e( 'Blog Details', 'buddypress' ) ?></h3>
|
70 |
-
<p id="blog-details-help">
|
71 |
-
<?php _e( "To register your first blog, just fill in the details below and your registration is complete.", 'buddypress' ) ?>
|
72 |
-
</p>
|
73 |
-
|
74 |
-
<div id="blog-details-fields">
|
75 |
-
<?php
|
76 |
-
|
77 |
-
// Blog name
|
78 |
-
if ( 'no' == constant( "VHOST" ) )
|
79 |
-
echo '<label for="blogname">' . __('Blog Name:', 'buddypress') . '</label>';
|
80 |
-
else
|
81 |
-
echo '<label for="blogname">' . __('Blog Domain:', 'buddypress') . '</label>';
|
82 |
-
|
83 |
-
if ( $errmsg = $errors->get_error_message('blogname') ) { ?>
|
84 |
-
<p class="error"><?php echo $errmsg ?></p>
|
85 |
-
<?php }
|
86 |
-
|
87 |
-
if ( 'no' == constant( "VHOST" ) ) {
|
88 |
-
echo '<span class="prefix_address">' . $current_site->domain . $current_site->path . '</span><input name="blogname" type="text" id="blogname" value="'.$blogname.'" maxlength="50" /><br />';
|
89 |
-
} else {
|
90 |
-
echo '<input name="blogname" type="text" id="blogname" value="'.$blogname.'" maxlength="50" /><span class="suffix_address">.' . $current_site->domain . $current_site->path . '</span><br />';
|
91 |
-
}
|
92 |
-
|
93 |
-
if ( !is_user_logged_in() ) {
|
94 |
-
echo '<p class="help-text">';
|
95 |
-
print '(<strong>' . __( 'Your address will be ', 'buddypress' );
|
96 |
-
if( 'no' == constant( "VHOST" ) ) {
|
97 |
-
print $current_site->domain . $current_site->path . __( 'blogname', 'buddypress' );
|
98 |
-
} else {
|
99 |
-
print __( 'domain.', 'buddypress' ) . $current_site->domain . $current_site->path;
|
100 |
-
}
|
101 |
-
echo '</strong>. ' . __( 'Must be at least 4 characters, letters and numbers only. It cannot be changed so choose carefully!)', 'buddypress' ) . '</p>';
|
102 |
-
echo '</p>';
|
103 |
-
}
|
104 |
-
|
105 |
-
// Blog Title
|
106 |
-
?>
|
107 |
-
<label for="blog_title"><?php _e( 'Blog Title:', 'buddypress' ) ?></label>
|
108 |
-
<?php if ( $errmsg = $errors->get_error_message('blog_title') ) { ?>
|
109 |
-
<p class="error"><?php echo $errmsg ?></p>
|
110 |
-
<?php }
|
111 |
-
echo '<input name="blog_title" type="text" id="blog_title" value="'.wp_specialchars($blog_title, 1).'" /></p>';
|
112 |
-
?>
|
113 |
-
|
114 |
-
<p>
|
115 |
-
<label for="blog_public_on"><?php _e( 'Privacy:', 'buddypress' ) ?></label>
|
116 |
-
<?php _e( 'I would like my blog to appear in search engines like Google and Technorati, and in public listings around this site.', 'buddypress' ); ?>
|
117 |
-
<label class="checkbox" for="blog_public_on">
|
118 |
-
<input type="radio" id="blog_public_on" name="blog_public" value="1" <?php if( !isset( $_POST['blog_public'] ) || '1' == $_POST['blog_public'] ) { ?>checked="checked"<?php } ?> />
|
119 |
-
<?php _e( 'Yes', 'buddypress' ); ?>
|
120 |
-
</label>
|
121 |
-
<label class="checkbox" for="blog_public_off">
|
122 |
-
<input type="radio" id="blog_public_off" name="blog_public" value="0" <?php if( isset( $_POST['blog_public'] ) && '0' == $_POST['blog_public'] ) { ?>checked="checked"<?php } ?> />
|
123 |
-
<?php _e( 'No', 'buddypress' ); ?>
|
124 |
-
</label>
|
125 |
-
</p>
|
126 |
-
</div>
|
127 |
-
<?php
|
128 |
-
do_action('signup_blogform', $errors);
|
129 |
-
}
|
130 |
-
|
131 |
-
function bp_core_signup_validate_blog_form() {
|
132 |
-
$user = '';
|
133 |
-
if ( is_user_logged_in() )
|
134 |
-
$user = wp_get_current_user();
|
135 |
-
|
136 |
-
return wpmu_validate_blog_signup($_POST['blogname'], $_POST['blog_title'], $user);
|
137 |
-
}
|
138 |
-
|
139 |
-
function bp_core_signup_show_user_form($user_name = '', $user_email = '', $errors = '') {
|
140 |
-
// User name
|
141 |
-
echo '<div id="account-fields">';
|
142 |
-
echo '<label for="user_name">' . __( 'Username:', 'buddypress' ) . '</label>';
|
143 |
-
if ( $errmsg = $errors->get_error_message('user_name') ) {
|
144 |
-
echo '<p class="error">'.$errmsg.'</p>';
|
145 |
-
}
|
146 |
-
echo '<input name="user_name" type="text" id="user_name" value="'.$user_name.'" maxlength="50" />';
|
147 |
-
echo '<p class="help-text">';
|
148 |
-
_e( '(Must be at least 4 characters, letters and numbers only.)', 'buddypress' );
|
149 |
-
echo '</p>'
|
150 |
-
?>
|
151 |
-
|
152 |
-
<label for="user_email"><?php _e( 'Email Address:', 'buddypress' ) ?></label>
|
153 |
-
<?php if ( $errmsg = $errors->get_error_message('user_email') ) { ?>
|
154 |
-
<p class="error"><?php echo $errmsg ?></p>
|
155 |
-
<?php } ?>
|
156 |
-
<input name="user_email" type="text" id="user_email" value="<?php echo wp_specialchars($user_email, 1) ?>" maxlength="200" /><p class="help-text"><?php _e( '(We’ll send your password to this address, so <strong>triple-check it</strong>.)', 'buddypress' ) ?></p>
|
157 |
-
<?php
|
158 |
-
if ( $errmsg = $errors->get_error_message('generic') ) {
|
159 |
-
echo '<p class="error">'.$errmsg.'</p>';
|
160 |
-
}
|
161 |
-
echo '</div>';
|
162 |
-
|
163 |
-
echo '<div id="extra-fields">';
|
164 |
-
do_action( 'signup_extra_fields', $errors );
|
165 |
-
echo '</div>';
|
166 |
-
}
|
167 |
-
|
168 |
-
function bp_core_signup_validate_user_form() {
|
169 |
-
return wpmu_validate_user_signup($_POST['user_name'], $_POST['user_email']);
|
170 |
-
}
|
171 |
-
|
172 |
-
function bp_core_signup_signup_another_blog($blogname = '', $blog_title = '', $errors = '') {
|
173 |
-
global $current_user, $current_site;
|
174 |
-
|
175 |
-
if ( ! is_wp_error($errors) ) {
|
176 |
-
$errors = new WP_Error();
|
177 |
-
}
|
178 |
-
|
179 |
-
// allow definition of default variables
|
180 |
-
$filtered_results = apply_filters('signup_another_blog_init', array('blogname' => $blogname, 'blog_title' => $blog_title, 'errors' => $errors ));
|
181 |
-
$blogname = $filtered_results['blogname'];
|
182 |
-
$blog_title = $filtered_results['blog_title'];
|
183 |
-
$errors = $filtered_results['errors'];
|
184 |
-
|
185 |
-
?>
|
186 |
-
<h3><?php _e( "You're already registered!", 'buddypress' )?></h3>
|
187 |
-
<p><?php _e( 'You can still create another blog however. Fill in the form below to add another blog to your account.', 'buddypress' ) ?>
|
188 |
-
|
189 |
-
|
190 |
-
<p><?php _e( "There is no limit to the number of blogs you can have, so create to your heart's content, but blog responsibly. If you’re not going to use a great blog domain, leave it for a new user. Now have at it!", 'buddypress' ) ?></p>
|
191 |
-
|
192 |
-
<form id="setupform" method="post" action="<?php echo site_url(BP_REGISTER_SLUG) ?>">
|
193 |
-
<input type="hidden" name="stage" value="gimmeanotherblog" />
|
194 |
-
<?php do_action( "signup_hidden_fields" ); ?>
|
195 |
-
<?php bp_core_signup_show_blog_form($blogname, $blog_title, $errors); ?>
|
196 |
-
<p>
|
197 |
-
<input id="submit" type="submit" name="submit" class="submit" value="<?php _e('Create Blog »') ?>"/>
|
198 |
-
</p>
|
199 |
-
</form>
|
200 |
-
<?php
|
201 |
-
}
|
202 |
-
|
203 |
-
function bp_core_signup_validate_another_blog_signup() {
|
204 |
-
global $wpdb, $current_user, $blogname, $blog_title, $errors, $domain, $path;
|
205 |
-
$current_user = wp_get_current_user();
|
206 |
-
if( !is_user_logged_in() )
|
207 |
-
die();
|
208 |
-
|
209 |
-
$result = bp_core_signup_validate_blog_form();
|
210 |
-
extract($result);
|
211 |
-
|
212 |
-
if ( $errors->get_error_code() ) {
|
213 |
-
bp_core_signup_signup_another_blog($blogname, $blog_title, $errors);
|
214 |
-
return false;
|
215 |
-
}
|
216 |
-
|
217 |
-
$public = (int) $_POST['blog_public'];
|
218 |
-
$meta = apply_filters('signup_create_blog_meta', array ('lang_id' => 1, 'public' => $public)); // depreciated
|
219 |
-
$meta = apply_filters( "add_signup_meta", $meta );
|
220 |
-
|
221 |
-
wpmu_create_blog( $domain, $path, $blog_title, $current_user->id, $meta, $wpdb->siteid );
|
222 |
-
bp_core_signup_confirm_another_blog_signup($domain, $path, $blog_title, $current_user->user_login, $current_user->user_email, $meta);
|
223 |
-
return true;
|
224 |
-
}
|
225 |
-
|
226 |
-
function bp_core_signup_confirm_another_blog_signup($domain, $path, $blog_title, $user_name, $user_email = '', $meta = '') {
|
227 |
-
?>
|
228 |
-
<h2><?php printf( __( 'The blog %s is yours.', 'buddypress' ), "<a href='http://{$domain}{$path}'>{$blog_title}</a>" ) ?></h2>
|
229 |
-
<p>
|
230 |
-
<?php printf( __( '<a href="http://%1$s">http://%2$s</a> is your new blog. <a href="%3$s">Login</a> as "%4$s" using your existing password.', 'buddypress' ), $domain.$path, $domain.$path, "http://" . $domain.$path . "/wp-login.php", $user_name) ?>
|
231 |
-
</p>
|
232 |
-
<?php
|
233 |
-
do_action('signup_finished');
|
234 |
-
}
|
235 |
-
|
236 |
-
function bp_core_signup_signup_user($user_name = '', $user_email = '', $errors = '') {
|
237 |
-
global $current_site, $active_signup;
|
238 |
-
|
239 |
-
$active_signup = get_site_option( 'registration' );
|
240 |
-
|
241 |
-
if ( !is_wp_error($errors) )
|
242 |
-
$errors = new WP_Error();
|
243 |
-
if( isset( $_POST[ 'signup_for' ] ) ) {
|
244 |
-
$signup[ wp_specialchars( $_POST[ 'signup_for' ] ) ] = 'checked="checked"';
|
245 |
-
} else {
|
246 |
-
$signup[ 'blog' ] = 'checked="checked"';
|
247 |
-
}
|
248 |
-
|
249 |
-
// allow definition of default variables
|
250 |
-
$filtered_results = apply_filters('signup_user_init', array('user_name' => $user_name, 'user_email' => $user_email, 'errors' => $errors ));
|
251 |
-
$user_name = $filtered_results['user_name'];
|
252 |
-
$user_email = $filtered_results['user_email'];
|
253 |
-
$errors = $filtered_results['errors'];
|
254 |
-
|
255 |
-
?>
|
256 |
-
|
257 |
-
<form id="setupform" method="post" action="<?php echo site_url(BP_REGISTER_SLUG) ?>">
|
258 |
-
<p id="intro-text"><?php _e( 'Registering for a new account is easy, just fill in the form below and you\'ll be a new member in no time at all.', 'buddypress' ) ?></p>
|
259 |
-
<input type="hidden" name="stage" value="validate-user-signup" />
|
260 |
-
<?php do_action( "signup_hidden_fields" ); ?>
|
261 |
-
|
262 |
-
<?php bp_core_signup_show_user_form($user_name, $user_email, $errors); ?>
|
263 |
-
|
264 |
-
<?php if( 'blog' == $active_signup ) { ?>
|
265 |
-
<input id="signupblog" type="hidden" name="signup_for" value="blog" />
|
266 |
-
<?php } elseif( 'user' == $active_signup ) { ?>
|
267 |
-
<input id="signupblog" type="hidden" name="signup_for" value="user" />
|
268 |
-
<?php } else { ?>
|
269 |
-
<div id="blog-or-username">
|
270 |
-
<h3><?php _e( 'Create a Blog?', 'buddypress' ) ?></h3>
|
271 |
-
<p id="blog-help-text"><?php _e( 'If you want to create your first blog, select the option below and you\'ll be asked for a few more details.', 'buddypress' ) ?></p>
|
272 |
-
|
273 |
-
<div id="blog-or-username-fields">
|
274 |
-
<p>
|
275 |
-
<input id="signupblog" type="radio" name="signup_for" value="blog" <?php echo $signup['blog'] ?> />
|
276 |
-
<label class="checkbox" for="signupblog"><?php _e( 'Gimme a blog!', 'buddypress' ) ?></label>
|
277 |
-
</p>
|
278 |
-
|
279 |
-
<p>
|
280 |
-
<input id="signupuser" type="radio" name="signup_for" value="user" <?php echo $signup['user'] ?> />
|
281 |
-
<label class="checkbox" for="signupuser"><?php _e( 'Just a username, please.', 'buddypress' ) ?></label>
|
282 |
-
</p>
|
283 |
-
</div>
|
284 |
-
</div>
|
285 |
-
<?php } ?>
|
286 |
-
|
287 |
-
<input id="submit" type="submit" name="submit" class="submit" value="<?php _e('Next »') ?>"/>
|
288 |
-
</form>
|
289 |
-
<?php
|
290 |
-
}
|
291 |
-
|
292 |
-
function bp_core_signup_validate_user_signup() {
|
293 |
-
$result = bp_core_signup_validate_user_form();
|
294 |
-
extract($result);
|
295 |
-
|
296 |
-
if ( $errors->get_error_code() ) {
|
297 |
-
bp_core_signup_signup_user($user_name, $user_email, $errors);
|
298 |
-
return false;
|
299 |
-
}
|
300 |
-
|
301 |
-
if ( 'blog' == $_POST['signup_for'] ) {
|
302 |
-
bp_core_signup_signup_blog($user_name, $user_email);
|
303 |
-
return false;
|
304 |
-
}
|
305 |
-
|
306 |
-
wpmu_signup_user($user_name, $user_email, apply_filters( "add_signup_meta", array() ) );
|
307 |
-
|
308 |
-
bp_core_signup_confirm_user_signup($user_name, $user_email);
|
309 |
-
return true;
|
310 |
-
}
|
311 |
-
|
312 |
-
function bp_core_signup_confirm_user_signup($user_name, $user_email) {
|
313 |
-
?>
|
314 |
-
<h3><?php _e( 'Congratulations, you are now registered!', 'buddypress' ) ?></h3>
|
315 |
-
<p><?php printf(__('Your new username is: %s', 'buddypress' ), $user_name) ?></p>
|
316 |
-
<p> </p>
|
317 |
-
<p><?php printf(__('Before you can start using your new username, <strong>you must activate it</strong>. Check your inbox at <strong>%1$s</strong> and click the link given.', 'buddypress' ), $user_email) ?></p>
|
318 |
-
<p><?php _e('If you do not activate your username within two days, you will have to sign up again.', 'buddypress' ); ?></p>
|
319 |
-
<?php
|
320 |
-
do_action('signup_finished');
|
321 |
-
}
|
322 |
-
|
323 |
-
function bp_core_signup_signup_blog($user_name = '', $user_email = '', $blogname = '', $blog_title = '', $errors = '') {
|
324 |
-
if ( !is_wp_error($errors) )
|
325 |
-
$errors = new WP_Error();
|
326 |
-
|
327 |
-
// allow definition of default variables
|
328 |
-
$filtered_results = apply_filters('signup_blog_init', array('user_name' => $user_name, 'user_email' => $user_email, 'blogname' => $blogname, 'blog_title' => $blog_title, 'errors' => $errors ));
|
329 |
-
$user_name = $filtered_results['user_name'];
|
330 |
-
$user_email = $filtered_results['user_email'];
|
331 |
-
$blogname = $filtered_results['blogname'];
|
332 |
-
$blog_title = $filtered_results['blog_title'];
|
333 |
-
$errors = $filtered_results['errors'];
|
334 |
-
|
335 |
-
if ( empty($blogname) )
|
336 |
-
$blogname = $user_name;
|
337 |
-
?>
|
338 |
-
<form id="setupform" method="post" action="<?php echo site_url(BP_REGISTER_SLUG) ?>">
|
339 |
-
<input type="hidden" name="stage" value="validate-blog-signup" />
|
340 |
-
<input type="hidden" name="user_name" value="<?php echo $user_name ?>" />
|
341 |
-
<input type="hidden" name="user_email" value="<?php echo $user_email ?>" />
|
342 |
-
<?php do_action( "signup_hidden_fields" ); ?>
|
343 |
-
<?php bp_core_signup_show_blog_form($blogname, $blog_title, $errors); ?>
|
344 |
-
<p>
|
345 |
-
<input id="submit" type="submit" name="submit" class="submit" value="<?php _e('Signup »') ?>"/></p>
|
346 |
-
</form>
|
347 |
-
<?php
|
348 |
-
}
|
349 |
-
|
350 |
-
function bp_core_signup_validate_blog_signup() {
|
351 |
-
// Re-validate user info.
|
352 |
-
$result = wpmu_validate_user_signup($_POST['user_name'], $_POST['user_email']);
|
353 |
-
extract($result);
|
354 |
-
|
355 |
-
if ( $errors->get_error_code() ) {
|
356 |
-
bp_core_signup_signup_user($user_name, $user_email, $errors);
|
357 |
-
return false;
|
358 |
-
}
|
359 |
-
|
360 |
-
$result = wpmu_validate_blog_signup($_POST['blogname'], $_POST['blog_title']);
|
361 |
-
extract($result);
|
362 |
-
|
363 |
-
if ( $errors->get_error_code() ) {
|
364 |
-
bp_core_signup_signup_blog($user_name, $user_email, $blogname, $blog_title, $errors);
|
365 |
-
return false;
|
366 |
-
}
|
367 |
-
|
368 |
-
$public = (int) $_POST['blog_public'];
|
369 |
-
$meta = array ('lang_id' => 1, 'public' => $public);
|
370 |
-
$meta = apply_filters( "add_signup_meta", $meta );
|
371 |
-
|
372 |
-
wpmu_signup_blog($domain, $path, $blog_title, $user_name, $user_email, $meta);
|
373 |
-
bp_core_signup_confirm_blog_signup($domain, $path, $blog_title, $user_name, $user_email, $meta);
|
374 |
-
return true;
|
375 |
-
}
|
376 |
-
|
377 |
-
function bp_core_signup_confirm_blog_signup($domain, $path, $blog_title, $user_name = '', $user_email = '', $meta) {
|
378 |
-
?>
|
379 |
-
<h3><?php _e('Congratulations, You are now registered!', 'buddypress' ) ?></h3>
|
380 |
-
|
381 |
-
<p><?php printf( __('But, before you can start using your blog, <strong>you must activate it</strong>. Check your inbox at <strong>%s</strong> and click the link given. It should arrive within 30 minutes.', 'buddypress' ), $user_email) ?></p>
|
382 |
-
<p> </p>
|
383 |
-
|
384 |
-
<h3><?php _e( 'Still waiting for your email?', 'buddypress' ); ?></h3>
|
385 |
-
<p>
|
386 |
-
<?php _e( "If you haven't received your email yet, there are a number of things you can do:", 'buddypress' ) ?>
|
387 |
-
<ul>
|
388 |
-
<li><p><strong><?php _e( 'Wait a little longer. Sometimes delivery of email can be delayed by processes outside of our control.', 'buddypress' ) ?></strong></p></li>
|
389 |
-
<li><p><?php _e( 'Check the junk email or spam folder of your email client. Sometime emails wind up there by mistake.', 'buddypress' ) ?></p></li>
|
390 |
-
<li><?php printf( __( "Have you entered your email correctly? We think it's %s but if you've entered it incorrectly, you won't receive it.", 'buddypress' ), $user_email) ?></li>
|
391 |
-
</ul>
|
392 |
-
</p>
|
393 |
-
<?php
|
394 |
-
do_action('signup_finished');
|
395 |
-
}
|
396 |
-
|
397 |
-
function bp_core_signup_do_signup() {
|
398 |
-
// Main
|
399 |
-
$active_signup = get_site_option( 'registration' );
|
400 |
-
if( !$active_signup )
|
401 |
-
$active_signup = 'all';
|
402 |
-
|
403 |
-
$active_signup = apply_filters( 'wpmu_active_signup', $active_signup ); // return "all", "none", "blog" or "user"
|
404 |
-
|
405 |
-
if( is_site_admin() )
|
406 |
-
echo '<div class="mu_alert">' . sprintf( __( "Greetings Site Administrator! You are currently allowing '%s' registrations. To change or disable registration go to your <a href='wp-admin/wpmu-options.php'>Options page</a>.", 'buddypress' ), $active_signup ) . '</div>';
|
407 |
-
|
408 |
-
$newblogname = isset($_GET['new']) ? strtolower(preg_replace('/^-|-$|[^-a-zA-Z0-9]/', '', $_GET['new'])) : null;
|
409 |
-
|
410 |
-
$current_user = wp_get_current_user();
|
411 |
-
if( $active_signup == "none" ) {
|
412 |
-
_e( "Registration has been disabled.", 'buddypress' );
|
413 |
-
} elseif( $active_signup == 'blog' && !is_user_logged_in() ){
|
414 |
-
if( is_ssl() ) {
|
415 |
-
$proto = 'https://';
|
416 |
-
} else {
|
417 |
-
$proto = 'http://';
|
418 |
-
}
|
419 |
-
$login_url = site_url( 'wp-login.php?redirect_to=' . site_url(BP_REGISTER_SLUG) );
|
420 |
-
echo sprintf( __( "You must first <a href=\"%s\">login</a>, and then you can create a new blog.", 'buddypress' ), $login_url );
|
421 |
-
} else {
|
422 |
-
switch ($_POST['stage']) {
|
423 |
-
case 'validate-user-signup' :
|
424 |
-
if( $active_signup == 'all' || $_POST[ 'signup_for' ] == 'blog' && $active_signup == 'blog' || $_POST[ 'signup_for' ] == 'user' && $active_signup == 'user' )
|
425 |
-
bp_core_signup_validate_user_signup();
|
426 |
-
else
|
427 |
-
_e( "User registration has been disabled.", 'buddypress' );
|
428 |
-
break;
|
429 |
-
case 'validate-blog-signup':
|
430 |
-
if( $active_signup == 'all' || $active_signup == 'blog' )
|
431 |
-
bp_core_signup_validate_blog_signup();
|
432 |
-
else
|
433 |
-
_e( "Blog registration has been disabled.", 'buddypress' );
|
434 |
-
break;
|
435 |
-
case 'gimmeanotherblog':
|
436 |
-
bp_core_signup_validate_another_blog_signup();
|
437 |
-
break;
|
438 |
-
default :
|
439 |
-
$user_email = $_POST[ 'user_email' ];
|
440 |
-
do_action( "preprocess_signup_form" ); // populate the form from invites, elsewhere?
|
441 |
-
if ( is_user_logged_in() && ( $active_signup == 'all' || $active_signup == 'blog' ) ) {
|
442 |
-
bp_core_signup_signup_another_blog($newblogname);
|
443 |
-
} elseif( is_user_logged_in() == false && ( $active_signup == 'all' || $active_signup == 'user' ) ) {
|
444 |
-
bp_core_signup_signup_user( $newblogname, $user_email );
|
445 |
-
} elseif( is_user_logged_in() == false && ( $active_signup == 'blog' ) ) {
|
446 |
-
_e( "I'm sorry. We're not accepting new registrations at this time.", 'buddypress' );
|
447 |
-
} else {
|
448 |
-
_e( "You're logged in already. No need to register again!", 'buddypress' );
|
449 |
-
}
|
450 |
-
if ($newblogname) {
|
451 |
-
if( constant( "VHOST" ) == 'no' )
|
452 |
-
$newblog = 'http://' . $current_site->domain . $current_site->path . $newblogname . '/';
|
453 |
-
else
|
454 |
-
$newblog = 'http://' . $newblogname . '.' . $current_site->domain . $current_site->path;
|
455 |
-
if ($active_signup == 'blog' || $active_signup == 'all')
|
456 |
-
printf( __( "<p><em>The blog you were looking for, <strong>%s</strong> doesn't exist but you can create it now!</em></p>", 'buddypress' ), $newblog );
|
457 |
-
else
|
458 |
-
printf( __( "<p><em>The blog you were looking for, <strong>%s</strong> doesn't exist.</em></p>", 'buddypress' ), $newblog );
|
459 |
-
}
|
460 |
-
break;
|
461 |
-
}
|
462 |
-
}
|
463 |
-
}
|
464 |
-
|
465 |
-
function bp_core_activation_set_headers() {
|
466 |
-
global $wp_object_cache;
|
467 |
-
|
468 |
-
define( "WP_INSTALLING", true );
|
469 |
-
|
470 |
-
require_once( ABSPATH . WPINC . '/registration.php');
|
471 |
-
|
472 |
-
if( is_object( $wp_object_cache ) )
|
473 |
-
$wp_object_cache->cache_enabled = false;
|
474 |
-
|
475 |
-
do_action("activate_header");
|
476 |
-
}
|
477 |
-
|
478 |
-
function bp_core_activation_do_activation() {
|
479 |
-
global $current_site, $blog_id, $user_id; ?>
|
480 |
-
|
481 |
-
<?php if ( empty( $_GET['key'] ) && empty( $_POST['key'] ) ) { ?>
|
482 |
-
|
483 |
-
<h3><?php _e( 'Activation Key Required', 'buddypress' ) ?></h3>
|
484 |
-
|
485 |
-
<p id="intro-text"><?php _e( 'This is the key contained in the email you were sent after registering for this site.', 'buddypress' ) ?></p>
|
486 |
-
|
487 |
-
<div class="field-box">
|
488 |
-
<form name="activateform" id="activateform" method="post" action="<?php echo 'http://' . $current_site->domain . $current_site->path ?>wp-activate.php">
|
489 |
-
<p>
|
490 |
-
<label for="key"><?php _e('Activation Key:', 'buddypress' ) ?></label>
|
491 |
-
<br /><input type="text" name="key" id="key" value="" size="50" />
|
492 |
-
</p>
|
493 |
-
<p class="submit">
|
494 |
-
<input id="submit" type="submit" name="Submit" class="submit" value="<?php _e('Activate »', 'buddypress' ) ?>"/>
|
495 |
-
</p>
|
496 |
-
</form>
|
497 |
-
</div>
|
498 |
-
|
499 |
-
<?php } else {
|
500 |
-
|
501 |
-
$key = !empty($_GET['key']) ? $_GET['key'] : $_POST['key'];
|
502 |
-
$result = wpmu_activate_signup($key);
|
503 |
-
|
504 |
-
if ( is_wp_error($result) ) {
|
505 |
-
if ( 'already_active' == $result->get_error_code() || 'blog_taken' == $result->get_error_code() ) {
|
506 |
-
$signup = $result->get_error_data();
|
507 |
-
?>
|
508 |
-
|
509 |
-
<h3><?php _e('Your account is now active!', 'buddypress' ); ?></h3>
|
510 |
-
|
511 |
-
<?php
|
512 |
-
_e( 'Your account has already been activated. You can now log in with the account details that were emailed to you.' );
|
513 |
-
|
514 |
-
} else {
|
515 |
-
?>
|
516 |
-
<h2><?php _e('An error occurred during the activation', 'buddypress' ); ?></h2>
|
517 |
-
<?php
|
518 |
-
echo '<p>'.$result->get_error_message().'</p>';
|
519 |
-
}
|
520 |
-
} else {
|
521 |
-
extract($result);
|
522 |
-
|
523 |
-
$user = new WP_User( (int) $user_id);
|
524 |
-
|
525 |
-
?>
|
526 |
-
|
527 |
-
<h3><?php _e('Your account is now active!', 'buddypress' ); ?></h3>
|
528 |
-
|
529 |
-
<p class="view"><?php printf( __( 'Your account is now activated. <a href="%1$s">Login</a> or go back to the <a href="%2$s">homepage</a>.', 'buddypress' ), site_url( 'wp-login.php?redirect_to=' . site_url() ), site_url() ); ?></p>
|
530 |
-
|
531 |
-
<div class="field-box" id="signup-welcome">
|
532 |
-
<p><span class="label"><?php _e( 'Username:', 'buddypress' ); ?></span> <?php echo $user->user_login ?></p>
|
533 |
-
<p><span class="label"><?php _e( 'Password:', 'buddypress' ); ?></span> <?php echo $password; ?></p>
|
534 |
-
</div>
|
535 |
-
|
536 |
-
<?php
|
537 |
-
do_action( 'bp_activation_extras', $user_id, $meta );
|
538 |
-
}
|
539 |
-
}
|
540 |
-
}
|
541 |
-
|
542 |
-
/*** END DEPRECATED SIGNUP FUNCTIONS **********/
|
543 |
-
|
544 |
-
|
545 |
-
/* DEPRECATED - use bp_core_new_nav_item() as it's more friendly and allows ordering */
|
546 |
-
function bp_core_add_nav_item( $name, $slug, $css_id = false, $show_for_displayed_user = true ) {
|
547 |
-
bp_core_new_nav_item( array( 'name' => $name, 'slug' => $slug, 'item_css_id' => $css_id, 'show_for_displayed_user' => $show_for_displayed_user ) );
|
548 |
-
}
|
549 |
-
|
550 |
-
/* DEPRECATED - use bp_core_new_subnav_item() as it's more friendly and allows ordering. */
|
551 |
-
function bp_core_add_subnav_item( $parent_id, $slug, $name, $link, $function, $css_id = false, $user_has_access = true, $admin_only = false ) {
|
552 |
-
bp_core_new_subnav_item( array( 'name' => $name, 'slug' => $slug, 'parent_slug' => $parent_id, 'parent_url' => $link, 'item_css_id' => $css_id, 'user_has_access' => $user_has_access, 'site_admin_only' => $admin_only, 'screen_function' => $function ) );
|
553 |
-
}
|
554 |
-
|
555 |
-
/* DEPRECATED - use bp_core_get_userid() */
|
556 |
-
function bp_core_get_userid_from_user_login( $deprecated ) {
|
557 |
-
return bp_core_get_userid( $deprecated );
|
558 |
-
}
|
559 |
-
|
560 |
-
/* DEPRECATED - use bp_core_get_user_displayname() */
|
561 |
-
function bp_core_global_user_fullname( $user_id ) { return bp_core_get_user_displayname( $user_id ); }
|
562 |
-
|
563 |
-
/* DEPRECATED use bp_core_fetch_avatar() */
|
564 |
-
function bp_core_get_avatar( $user, $version = 1, $width = null, $height = null, $no_tag = false ) {
|
565 |
-
$type = ( 2 == $version ) ? 'full' : 'thumb';
|
566 |
-
return bp_core_fetch_avatar( array( 'item_id' => $user, 'type' => $type, 'width' => $width, 'height' => $height ) );
|
567 |
-
}
|
568 |
-
|
569 |
-
/* DEPRECATED - use bp_displayed_user_avatar( 'size=full' ) */
|
570 |
-
function bp_the_avatar() {
|
571 |
-
global $bp;
|
572 |
-
echo apply_filters( 'bp_the_avatar', bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'full' ) ) );
|
573 |
-
}
|
574 |
-
|
575 |
-
/* DEPRECATED - use bp_displayed_user_avatar( 'size=thumb' ) */
|
576 |
-
function bp_the_avatar_thumbnail() {
|
577 |
-
global $bp;
|
578 |
-
echo apply_filters( 'bp_the_avatar_thumbnail', bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb' ) ) );
|
579 |
-
}
|
580 |
-
|
581 |
-
/* DEPRECATED - use bp_loggedin_user_avatar( 'type=full' ); */
|
582 |
-
function bp_loggedinuser_avatar( $width = false, $height = false ) {
|
583 |
-
global $bp;
|
584 |
-
|
585 |
-
echo apply_filters( 'bp_loggedinuser_avatar', bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb', 'width' => $width, 'height' => $height ) ) );
|
586 |
-
}
|
587 |
-
|
588 |
-
/* DEPRECATED - use bp_loggedin_user_avatar( 'type=thumb' ); */
|
589 |
-
function bp_loggedinuser_avatar_thumbnail( $width = false, $height = false ) {
|
590 |
-
global $bp;
|
591 |
-
|
592 |
-
echo apply_filters( 'bp_get_options_avatar', bp_core_fetch_avatar( array( 'item_id' => $bp->loggedin_user->id, 'type' => 'thumb', 'width' => $width, 'height' => $height ) ) );
|
593 |
-
}
|
594 |
-
|
595 |
-
/* DEPRECATED - use bp_core_get_user_displayname( $user_id ) */
|
596 |
-
function bp_fetch_user_fullname( $user_id, $echo = true ) {
|
597 |
-
if ( $echo )
|
598 |
-
echo apply_filters( 'bp_fetch_user_fullname', bp_core_get_user_displayname( $user_id ) );
|
599 |
-
else
|
600 |
-
return apply_filters( 'bp_fetch_user_fullname', bp_core_get_user_displayname( $user_id ) );
|
601 |
-
}
|
602 |
-
|
603 |
-
/*** BEGIN OLD AVATAR CROPPING SUPPORT ****************************************/
|
604 |
-
|
605 |
-
/* DEPRECATED - constant values that are no longer used. */
|
606 |
-
define( 'CORE_AVATAR_V1_W', apply_filters( 'bp_core_avatar_v1_w', 50 ) );
|
607 |
-
define( 'CORE_AVATAR_V1_H', apply_filters( 'bp_core_avatar_v1_h', 50 ) );
|
608 |
-
define( 'CORE_AVATAR_V2_W', apply_filters( 'bp_core_avatar_v2_w', 150 ) );
|
609 |
-
define( 'CORE_AVATAR_V2_H', apply_filters( 'bp_core_avatar_v2_h', 150 ) );
|
610 |
-
define( 'CORE_CROPPING_CANVAS_MAX', apply_filters( 'bp_core_avatar_cropping_canvas_max', 450 ) );
|
611 |
-
define( 'CORE_MAX_FILE_SIZE', get_site_option('fileupload_maxk') * 1024 );
|
612 |
-
define( 'CORE_DEFAULT_AVATAR', apply_filters( 'bp_core_avatar_default_src', BP_PLUGIN_URL . '/bp-xprofile/images/none.gif' ) );
|
613 |
-
define( 'CORE_DEFAULT_AVATAR_THUMB', apply_filters( 'bp_core_avatar_default_thumb_src', BP_PLUGIN_URL . '/bp-xprofile/images/none-thumbnail.gif' ) );
|
614 |
-
|
615 |
-
/* DEPRECATED - this is handled via a screen function. See xprofile_screen_change_avatar() */
|
616 |
-
function bp_core_avatar_admin( $message = null, $action, $delete_action) { ?>
|
617 |
-
<p><?php _e('Your avatar will be used on your profile and throughout the site.', 'buddypress') ?></p>
|
618 |
-
<p><?php _e( 'Click below to select a JPG, GIF or PNG format photo from your computer and then click \'Upload Photo\' to proceed.', 'buddypress' ) ?></p>
|
619 |
-
|
620 |
-
<form action="" method="post" id="avatar-upload-form" enctype="multipart/form-data">
|
621 |
-
|
622 |
-
<?php if ( 'upload-image' == bp_get_avatar_admin_step() ) : ?>
|
623 |
-
|
624 |
-
<h3><?php _e( 'Your Current Avatar', 'buddypress' ) ?></h3>
|
625 |
-
|
626 |
-
<?php bp_displayed_user_avatar( 'type=full') ?>
|
627 |
-
<?php bp_displayed_user_avatar( 'type=thumb' ) ?>
|
628 |
-
|
629 |
-
<p>
|
630 |
-
<input type="file" name="file" id="file" />
|
631 |
-
<input type="submit" name="upload" id="upload" value="<?php _e( 'Upload Image', 'buddypress' ) ?>" />
|
632 |
-
<input type="hidden" name="action" id="action" value="bp_avatar_upload" />
|
633 |
-
</p>
|
634 |
-
|
635 |
-
<?php wp_nonce_field( 'bp_avatar_upload' ) ?>
|
636 |
-
|
637 |
-
<?php endif; ?>
|
638 |
-
|
639 |
-
<?php if ( 'crop-image' == bp_get_avatar_admin_step() ) : ?>
|
640 |
-
|
641 |
-
<h3><?php _e( 'Crop Your New Avatar', 'buddypress' ) ?></h3>
|
642 |
-
|
643 |
-
<img src="<?php bp_avatar_to_crop() ?>" id="avatar-to-crop" class="avatar" alt="<?php _e( 'Avatar to crop', 'buddypress' ) ?>" />
|
644 |
-
|
645 |
-
<div id="avatar-crop-pane" style="width:100px;height:100px;overflow:hidden;">
|
646 |
-
<img src="<?php bp_avatar_to_crop() ?>" id="avatar-crop-preview" class="avatar" alt="<?php _e( 'Avatar preview', 'buddypress' ) ?>" />
|
647 |
-
</div>
|
648 |
-
|
649 |
-
<input type="submit" name="avatar-crop-submit" id="avatar-crop-submit" value="<?php _e( 'Crop Image', 'buddypress' ) ?>" />
|
650 |
-
|
651 |
-
<input type="hidden" name="image_src" id="image_src" value="<?php bp_avatar_to_crop_src() ?>" />
|
652 |
-
<input type="hidden" id="x" name="x" />
|
653 |
-
<input type="hidden" id="y" name="y" />
|
654 |
-
<input type="hidden" id="w" name="w" />
|
655 |
-
<input type="hidden" id="h" name="h" />
|
656 |
-
|
657 |
-
<?php wp_nonce_field( 'bp_avatar_cropstore' ) ?>
|
658 |
-
|
659 |
-
<?php endif; ?>
|
660 |
-
|
661 |
-
</form> <?php
|
662 |
-
}
|
663 |
-
|
664 |
-
function bp_core_handle_avatar_upload($file) {
|
665 |
-
global $wp_upload_error;
|
666 |
-
|
667 |
-
require_once( ABSPATH . '/wp-admin/includes/file.php' );
|
668 |
-
|
669 |
-
// Change the upload file location to /avatars/user_id
|
670 |
-
add_filter( 'upload_dir', 'xprofile_avatar_upload_dir' );
|
671 |
-
|
672 |
-
$res = wp_handle_upload( $file['file'], array('action'=>'slick_avatars') );
|
673 |
-
|
674 |
-
if ( !in_array('error', array_keys($res) ) ) {
|
675 |
-
return $res['file'];
|
676 |
-
} else {
|
677 |
-
$wp_upload_error = $res['error'];
|
678 |
-
return false;
|
679 |
-
}
|
680 |
-
}
|
681 |
-
|
682 |
-
function bp_core_resize_avatar( $file, $size = false ) {
|
683 |
-
require_once( ABSPATH . '/wp-admin/includes/image.php' );
|
684 |
-
|
685 |
-
if ( !$size )
|
686 |
-
$size = CORE_CROPPING_CANVAS_MAX;
|
687 |
-
|
688 |
-
$canvas = wp_create_thumbnail( $file, $size );
|
689 |
-
|
690 |
-
if ( $canvas->errors )
|
691 |
-
return false;
|
692 |
-
|
693 |
-
return $canvas = str_replace( '//', '/', $canvas );
|
694 |
-
}
|
695 |
-
|
696 |
-
/*** END OLD AVATAR CROPPING SUPPORT **************************/
|
697 |
-
|
698 |
-
|
699 |
-
/*** BEGIN DEPRECATED OLD BUDDYPRESS THEME SUPPORT ************/
|
700 |
-
|
701 |
-
/***
|
702 |
-
* In older versions of BuddyPress, BuddyPress templates were in a separate theme.
|
703 |
-
* The child theme setup makes upgrades and extending themes much easier, so the
|
704 |
-
* old method was deprecated.
|
705 |
-
*/
|
706 |
-
|
707 |
-
function bp_core_get_buddypress_themes() {
|
708 |
-
global $wp_themes;
|
709 |
-
|
710 |
-
/* If we are using a BuddyPress 1.1+ theme ignore this. */
|
711 |
-
if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
|
712 |
-
return false;
|
713 |
-
|
714 |
-
/* Remove the cached WP themes first */
|
715 |
-
$wp_existing_themes = &$wp_themes;
|
716 |
-
$wp_themes = null;
|
717 |
-
|
718 |
-
add_filter( 'theme_root', 'bp_core_filter_buddypress_theme_root' );
|
719 |
-
$themes = get_themes();
|
720 |
-
|
721 |
-
if ( $themes ) {
|
722 |
-
foreach ( $themes as $name => $values ) {
|
723 |
-
if ( $name == 'BuddyPress Default Home Theme' )
|
724 |
-
continue;
|
725 |
-
|
726 |
-
$member_themes[] = array(
|
727 |
-
'name' => $name,
|
728 |
-
'template' => $values['Template'],
|
729 |
-
'version' => $values['Version']
|
730 |
-
);
|
731 |
-
}
|
732 |
-
}
|
733 |
-
|
734 |
-
/* Restore the cached WP themes */
|
735 |
-
$wp_themes = $wp_existing_themes;
|
736 |
-
|
737 |
-
return $member_themes;
|
738 |
-
}
|
739 |
-
function bp_core_get_member_themes() { return bp_core_get_buddypress_themes(); } // DEPRECATED
|
740 |
-
|
741 |
-
function bp_get_buddypress_theme_uri() {
|
742 |
-
return apply_filters( 'bp_get_buddypress_theme_uri', WP_CONTENT_URL . '/bp-themes/' . get_site_option( 'active-member-theme' ) );
|
743 |
-
}
|
744 |
-
|
745 |
-
function bp_get_buddypress_theme_path() {
|
746 |
-
return apply_filters( 'bp_get_buddypress_theme_path', WP_CONTENT_DIR . '/bp-themes/' . get_site_option( 'active-member-theme' ) );
|
747 |
-
}
|
748 |
-
|
749 |
-
function bp_core_filter_buddypress_theme_root() {
|
750 |
-
return apply_filters( 'bp_core_filter_buddypress_theme_root', WP_CONTENT_DIR . "/bp-themes" );
|
751 |
-
}
|
752 |
-
|
753 |
-
function bp_core_filter_buddypress_theme_root_uri() {
|
754 |
-
return apply_filters( 'bp_core_filter_buddypress_theme_root_uri', WP_CONTENT_URL . '/bp-themes' );
|
755 |
-
}
|
756 |
-
|
757 |
-
function bp_core_force_buddypress_theme( $template ) {
|
758 |
-
global $is_member_page, $bp;
|
759 |
-
|
760 |
-
/* If we are using a BuddyPress 1.1+ theme ignore this. */
|
761 |
-
if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
|
762 |
-
return $template;
|
763 |
-
|
764 |
-
if ( $is_member_page ) {
|
765 |
-
$member_theme = get_site_option( 'active-member-theme' );
|
766 |
-
|
767 |
-
if ( empty( $member_theme ) )
|
768 |
-
$member_theme = 'bpmember';
|
769 |
-
|
770 |
-
add_filter( 'theme_root', 'bp_core_filter_buddypress_theme_root' );
|
771 |
-
add_filter( 'theme_root_uri', 'bp_core_filter_buddypress_theme_root_uri' );
|
772 |
-
|
773 |
-
return $member_theme;
|
774 |
-
} else {
|
775 |
-
return $template;
|
776 |
-
}
|
777 |
-
}
|
778 |
-
add_filter( 'template', 'bp_core_force_buddypress_theme' );
|
779 |
-
|
780 |
-
function bp_core_force_buddypress_stylesheet( $stylesheet ) {
|
781 |
-
global $is_member_page;
|
782 |
-
|
783 |
-
/* If we are using a BuddyPress 1.1+ theme ignore this. */
|
784 |
-
if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
|
785 |
-
return $stylesheet;
|
786 |
-
|
787 |
-
$member_theme = get_site_option( 'active-member-theme' );
|
788 |
-
|
789 |
-
if ( empty( $member_theme ) )
|
790 |
-
$member_theme = 'bpmember';
|
791 |
-
|
792 |
-
if ( $is_member_page ) {
|
793 |
-
add_filter( 'theme_root', 'bp_core_filter_buddypress_theme_root' );
|
794 |
-
add_filter( 'theme_root_uri', 'bp_core_filter_buddypress_theme_root_uri' );
|
795 |
-
|
796 |
-
return $member_theme;
|
797 |
-
} else {
|
798 |
-
return $stylesheet;
|
799 |
-
}
|
800 |
-
}
|
801 |
-
add_filter( 'stylesheet', 'bp_core_force_buddypress_stylesheet' );
|
802 |
-
|
803 |
-
|
804 |
-
/* DEPRECATED - All CSS is in the theme in BP 1.1+ */
|
805 |
-
function bp_core_add_structure_css() {
|
806 |
-
/* If we are using a BuddyPress 1.1+ theme ignore this. */
|
807 |
-
if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
|
808 |
-
return false;
|
809 |
-
|
810 |
-
/* Enqueue the structure CSS file to give basic positional formatting for components */
|
811 |
-
wp_enqueue_style( 'bp-core-structure', BP_PLUGIN_URL . '/bp-core/deprecated/css/structure.css' );
|
812 |
-
}
|
813 |
-
add_action( 'bp_styles', 'bp_core_add_structure_css' );
|
814 |
-
|
815 |
-
/* DEPRECATED - All CSS is now in the theme */
|
816 |
-
function bp_core_add_css() {
|
817 |
-
/* If we are using a BuddyPress 1.1+ theme ignore this. */
|
818 |
-
if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
|
819 |
-
return false;
|
820 |
-
|
821 |
-
// Enable a sitewide CSS file that will apply styles to both the home blog theme
|
822 |
-
// and the member theme.
|
823 |
-
if ( file_exists( WP_CONTENT_DIR . '/themes/' . get_blog_option( BP_ROOT_BLOG, 'stylesheet' ) . '/css/site-wide.css' ) )
|
824 |
-
wp_enqueue_style( 'site-wide-styles', WP_CONTENT_URL . '/themes/' . get_blog_option( BP_ROOT_BLOG, 'stylesheet' ) . '/css/site-wide.css' );
|
825 |
-
|
826 |
-
wp_print_styles();
|
827 |
-
}
|
828 |
-
add_action( 'wp_head', 'bp_core_add_css', 2 );
|
829 |
-
|
830 |
-
/* DEPRECATED - Admin bar CSS is now in the theme */
|
831 |
-
function bp_core_admin_bar_css() {
|
832 |
-
/* If we are using a BuddyPress 1.1+ theme ignore this. */
|
833 |
-
if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
|
834 |
-
return false;
|
835 |
-
|
836 |
-
if ( defined( 'BP_DISABLE_ADMIN_BAR') )
|
837 |
-
return false;
|
838 |
-
|
839 |
-
if ( is_user_logged_in() || ( !(int)get_site_option( 'hide-loggedout-adminbar' ) && !is_user_logged_in() ) ) {
|
840 |
-
wp_enqueue_style( 'bp-admin-bar', apply_filters( 'bp_core_admin_bar_css', BP_PLUGIN_URL . '/bp-core/deprecated/css/admin-bar.css' ) );
|
841 |
-
|
842 |
-
if ( 'rtl' == get_bloginfo('text_direction') && file_exists( BP_PLUGIN_DIR . '/bp-core/deprecated/css/admin-bar-rtl.css' ) )
|
843 |
-
wp_enqueue_style( 'bp-admin-bar-rtl', BP_PLUGIN_URL . '/bp-core/deprecated/css/admin-bar-rtl.css' );
|
844 |
-
}
|
845 |
-
}
|
846 |
-
add_action( 'wp_head', 'bp_core_admin_bar_css' );
|
847 |
-
add_action( 'admin_menu', 'bp_core_admin_bar_css' );
|
848 |
-
|
849 |
-
/* DEPRECATED - Javascript is added by the theme on a per-theme basis. */
|
850 |
-
function bp_core_add_js() {
|
851 |
-
/* If we are using a BuddyPress 1.1+ theme ignore this. */
|
852 |
-
if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
|
853 |
-
return $template;
|
854 |
-
|
855 |
-
wp_enqueue_script( 'jquery' );
|
856 |
-
wp_enqueue_script( 'jquery-livequery-pack', BP_PLUGIN_URL . '/bp-core/deprecated/js/jquery/jquery.livequery.pack.js', 'jquery' );
|
857 |
-
wp_enqueue_script( 'bp-general-js', BP_PLUGIN_URL . '/bp-core/deprecated/js/general.js' );
|
858 |
-
}
|
859 |
-
add_action( 'wp', 'bp_core_add_js' );
|
860 |
-
add_action( 'admin_menu', 'bp_core_add_js' );
|
861 |
-
|
862 |
-
function bp_core_directory_members_js() {
|
863 |
-
/* If we are using a BuddyPress 1.1+ theme ignore this. */
|
864 |
-
if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
|
865 |
-
return $template;
|
866 |
-
|
867 |
-
wp_enqueue_script( 'bp-core-directory-members', BP_PLUGIN_URL . '/bp-core/deprecated/js/directory-members.js', array( 'jquery', 'jquery-livequery-pack' ) );
|
868 |
-
}
|
869 |
-
add_action( 'bp_core_action_directory_members', 'bp_core_directory_members_js' );
|
870 |
-
|
871 |
-
/*** END DEPRECATED OLD BUDDYPRESS THEME SUPPORT ************/
|
872 |
-
|
873 |
-
function bp_core_ajax_directory_members() {
|
874 |
-
/* If we are using a BuddyPress 1.1+ theme ignore this. */
|
875 |
-
if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
|
876 |
-
return false;
|
877 |
-
|
878 |
-
check_ajax_referer('directory_members');
|
879 |
-
|
880 |
-
locate_template( array( 'directories/members/members-loop.php' ), true );
|
881 |
-
}
|
882 |
-
add_action( 'wp_ajax_directory_members', 'bp_core_ajax_directory_members' );
|
883 |
-
|
884 |
-
/* DEPRECATED -- This should now be directly in the template */
|
885 |
-
function bp_login_bar() {
|
886 |
-
global $bp;
|
887 |
-
|
888 |
-
if ( !is_user_logged_in() ) : ?>
|
889 |
-
|
890 |
-
<form name="login-form" id="login-form" action="<?php echo $bp->root_domain . '/wp-login.php' ?>" method="post">
|
891 |
-
<input type="text" name="log" id="user_login" value="<?php _e( 'Username', 'buddypress' ) ?>" onfocus="if (this.value == '<?php _e( 'Username', 'buddypress' ) ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php _e( 'Username', 'buddypress' ) ?>';}" />
|
892 |
-
<input type="password" name="pwd" id="user_pass" class="input" value="" />
|
893 |
-
|
894 |
-
<input type="checkbox" name="rememberme" id="rememberme" value="forever" title="<?php _e( 'Remember Me', 'buddypress' ) ?>" />
|
895 |
-
|
896 |
-
<input type="submit" name="wp-submit" id="wp-submit" value="<?php _e( 'Log In', 'buddypress' ) ?>"/>
|
897 |
-
<input type="button" name="signup-submit" id="signup-submit" value="<?php _e( 'Sign Up', 'buddypress' ) ?>" onclick="location.href='<?php echo bp_signup_page() ?>'" />
|
898 |
-
|
899 |
-
<input type="hidden" name="redirect_to" value="http://<?php echo $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'] ?>" />
|
900 |
-
<input type="hidden" name="testcookie" value="1" />
|
901 |
-
|
902 |
-
<?php do_action( 'bp_login_bar_logged_out' ) ?>
|
903 |
-
</form>
|
904 |
-
|
905 |
-
<?php else : ?>
|
906 |
-
|
907 |
-
<div id="logout-link">
|
908 |
-
<?php bp_loggedinuser_avatar_thumbnail( 20, 20 ) ?>
|
909 |
-
<?php bp_loggedinuser_link() ?>
|
910 |
-
<?php
|
911 |
-
if ( function_exists('wp_logout_url') ) {
|
912 |
-
$logout_link = '/ <a href="' . wp_logout_url( $bp->root_domain ) . '">' . __( 'Log Out', 'buddypress' ) . '</a>';
|
913 |
-
} else {
|
914 |
-
$logout_link = '/ <a href="' . $bp->root_domain . '/wp-login.php?action=logout&redirect_to=' . $bp->root_domain . '">' . __( 'Log Out', 'buddypress' ) . '</a>';
|
915 |
-
}
|
916 |
-
|
917 |
-
echo apply_filters( 'bp_logout_link', $logout_link );
|
918 |
-
?>
|
919 |
-
|
920 |
-
<?php do_action( 'bp_login_bar_logged_in' ) ?>
|
921 |
-
</div>
|
922 |
-
|
923 |
-
<?php endif;
|
924 |
-
}
|
925 |
-
|
926 |
-
/* DEPRECATED - use the param 'default_subnav_slug' in bp_core_new_nav_item() OR bp_core_new_nav_default() */
|
927 |
-
function bp_core_add_nav_default( $parent_id, $function, $slug = false, $user_has_access = true, $admin_only = false ) {
|
928 |
-
global $bp;
|
929 |
-
|
930 |
-
if ( !$user_has_access && !bp_is_home() )
|
931 |
-
return false;
|
932 |
-
|
933 |
-
if ( $admin_only && !is_site_admin() )
|
934 |
-
return false;
|
935 |
-
|
936 |
-
if ( $bp->current_component == $parent_id && !$bp->current_action ) {
|
937 |
-
if ( function_exists($function) ) {
|
938 |
-
add_action( 'wp', $function, 3 );
|
939 |
-
}
|
940 |
-
|
941 |
-
if ( $slug )
|
942 |
-
$bp->current_action = $slug;
|
943 |
-
}
|
944 |
-
}
|
945 |
-
|
946 |
-
/* DEPRECATED - use <?php locate_template( array( 'userbar.php' ), true ) ?> */
|
947 |
-
function bp_get_userbar( $hide_on_directory = true ) {
|
948 |
-
global $bp;
|
949 |
-
|
950 |
-
if ( $hide_on_directory && $bp->is_directory )
|
951 |
-
return false;
|
952 |
-
|
953 |
-
load_template( TEMPLATEPATH . '/userbar.php' );
|
954 |
-
}
|
955 |
-
|
956 |
-
/* DEPRECATED - use <?php locate_template( array( 'optionsbar.php' ), true ) ?> */
|
957 |
-
function bp_get_optionsbar( $hide_on_directory = true ) {
|
958 |
-
global $bp;
|
959 |
-
|
960 |
-
if ( $hide_on_directory && $bp->is_directory )
|
961 |
-
return false;
|
962 |
-
|
963 |
-
load_template( TEMPLATEPATH . '/optionsbar.php' );
|
964 |
-
}
|
965 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bp-core/deprecated/css/admin-bar.css
DELETED
@@ -1,239 +0,0 @@
|
|
1 |
-
body { padding-top: 28px !important; }
|
2 |
-
|
3 |
-
#wp-admin-bar {
|
4 |
-
position: absolute !important;
|
5 |
-
top: 0 !important;
|
6 |
-
left: 0 !important;
|
7 |
-
width: 100% !important;
|
8 |
-
z-index: 1001 !important;
|
9 |
-
height: 28px !important;
|
10 |
-
color: #fff !important;
|
11 |
-
text-align: left !important;
|
12 |
-
background:url(../images/admin_bar_back.gif) #818181 repeat-x !important;
|
13 |
-
font: 12px normal "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", Tahoma, Verdana, Arial, sans-serif !important;
|
14 |
-
font-weight: normal !important;
|
15 |
-
}
|
16 |
-
|
17 |
-
#wp-admin-bar * { z-index: 999 !important; }
|
18 |
-
|
19 |
-
#wp-admin-bar a#admin-bar-logo {
|
20 |
-
position: absolute !important;
|
21 |
-
top: 8px;
|
22 |
-
left: 10px;
|
23 |
-
background: url( ../images/admin_bar_logo.gif) top left no-repeat;
|
24 |
-
text-indent: -999em;
|
25 |
-
width: 61px;
|
26 |
-
height: 14px;
|
27 |
-
overflow: hidden;
|
28 |
-
}
|
29 |
-
|
30 |
-
#wp-admin-bar a img {
|
31 |
-
border: none !important;
|
32 |
-
}
|
33 |
-
|
34 |
-
#wp-admin-bar li {
|
35 |
-
list-style: none !important;
|
36 |
-
margin: 0 !important;
|
37 |
-
}
|
38 |
-
|
39 |
-
#wp-admin-bar li * {
|
40 |
-
font: 12px normal "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", Tahoma, Verdana, Arial, sans-serif !important;
|
41 |
-
font-weight: normal !important;
|
42 |
-
background-image: none !important;
|
43 |
-
}
|
44 |
-
|
45 |
-
#wp-admin-bar li a {
|
46 |
-
padding: 5px 25px 7px 15px !important;
|
47 |
-
font: 12px normal "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", Tahoma, Verdana, Arial, sans-serif !important;
|
48 |
-
font-weight: normal !important;
|
49 |
-
}
|
50 |
-
#wp-admin-bar li.no-arrow a {
|
51 |
-
padding-right: 15px !important;
|
52 |
-
}
|
53 |
-
|
54 |
-
#wp-admin-bar li:hover, #wp-admin-bar li.hover {
|
55 |
-
position: static;
|
56 |
-
}
|
57 |
-
|
58 |
-
/*******************/
|
59 |
-
|
60 |
-
#wp-admin-bar ul { /* all lists */
|
61 |
-
margin: 0 !important;
|
62 |
-
list-style: none !important;
|
63 |
-
line-height: 1 !important;
|
64 |
-
cursor: pointer !important;
|
65 |
-
height: auto !important;
|
66 |
-
padding: 0 !important;
|
67 |
-
}
|
68 |
-
|
69 |
-
#wp-admin-bar ul {
|
70 |
-
margin-left: 80px !important;
|
71 |
-
}
|
72 |
-
|
73 |
-
#wp-admin-bar ul li { /* all list items */
|
74 |
-
padding: 0 !important;
|
75 |
-
float: left !important;
|
76 |
-
background: url( ../images/admin-menu-arrow.gif ) 88% 53% no-repeat;
|
77 |
-
position: relative;
|
78 |
-
}
|
79 |
-
#wp-admin-bar ul li.no-arrow {
|
80 |
-
background: none;
|
81 |
-
}
|
82 |
-
|
83 |
-
#wp-admin-bar ul li ul a {
|
84 |
-
color: #666 !important;
|
85 |
-
}
|
86 |
-
|
87 |
-
#wp-admin-bar ul li.align-right {
|
88 |
-
position: absolute;
|
89 |
-
right: 0;
|
90 |
-
}
|
91 |
-
|
92 |
-
#wp-admin-bar ul li a {
|
93 |
-
display: block !important;
|
94 |
-
font-size: 12px !important;
|
95 |
-
font-family: "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", Tahoma, Verdana, Arial, sans-serif !important;
|
96 |
-
text-decoration: none !important;
|
97 |
-
color: #fff !important;
|
98 |
-
}
|
99 |
-
|
100 |
-
#wp-admin-bar ul.main-nav li:hover, #wp-admin-bar ul.main-nav li.sfhover, #wp-admin-bar ul.main-nav li ul li.sfhover {
|
101 |
-
background-color: #666 !important;
|
102 |
-
}
|
103 |
-
|
104 |
-
#wp-admin-bar ul.main-nav li ul li:hover a, #wp-admin-bar ul.main-nav li ul li.sfhover a {
|
105 |
-
background-color: #888 !important;
|
106 |
-
color: #fff !important;
|
107 |
-
}
|
108 |
-
|
109 |
-
#wp-admin-bar ul.main-nav li ul li:hover ul li.alt a {
|
110 |
-
background-color: #fafafa !important;
|
111 |
-
color: #666 !important;
|
112 |
-
}
|
113 |
-
|
114 |
-
#wp-admin-bar ul.main-nav li ul li:hover ul li a {
|
115 |
-
background-color: #f4f4f4 !important;
|
116 |
-
color: #666 !important;
|
117 |
-
}
|
118 |
-
|
119 |
-
#wp-admin-bar ul.main-nav li ul li:hover ul li:hover a {
|
120 |
-
background-color: #888 !important;
|
121 |
-
color: white !important;
|
122 |
-
}
|
123 |
-
|
124 |
-
#wp-admin-bar ul.main-nav li ul li ul li:hover a, #wp-admin-bar ul.main-nav li ul li ul li.sfhover a {
|
125 |
-
color: #fff !important;
|
126 |
-
}
|
127 |
-
|
128 |
-
/* second-level lists */
|
129 |
-
|
130 |
-
#wp-admin-bar ul li ul {
|
131 |
-
position: absolute !important;
|
132 |
-
width: 185px !important;
|
133 |
-
left: -999em !important;
|
134 |
-
margin-left: 0 !important;
|
135 |
-
}
|
136 |
-
|
137 |
-
#wp-admin-bar ul li ul li {
|
138 |
-
float: left !important;
|
139 |
-
width: 183px;
|
140 |
-
margin: 0 !important;
|
141 |
-
border: none !important;
|
142 |
-
border-bottom: 1px solid #f4f4f4 !important;
|
143 |
-
background-color: #f4f4f4 !important;
|
144 |
-
border-left: 1px solid #ccc !important;
|
145 |
-
border-right: 1px solid #ccc !important;
|
146 |
-
margin-top: -1px !important;
|
147 |
-
}
|
148 |
-
|
149 |
-
#wp-admin-bar ul li ul li.alt {
|
150 |
-
background-color: #fafafa !important;
|
151 |
-
border-bottom: 1px solid #fafafa !important;
|
152 |
-
}
|
153 |
-
|
154 |
-
#wp-admin-bar ul li ul li:last-child {
|
155 |
-
border-bottom: 1px solid #ccc !important;
|
156 |
-
-moz-border-radius-bottomleft: 4px !important;
|
157 |
-
-khtml-border-bottom-left-radius: 4px !important;
|
158 |
-
-webkit-border-bottom-left-radius: 4px !important;
|
159 |
-
border-bottom-left-radius: 4px !important;
|
160 |
-
-moz-border-radius-bottomright: 4px !important;
|
161 |
-
-khtml-border-bottom-right-radius: 4px !important;
|
162 |
-
-webkit-border-bottom-right-radius: 4px !important;
|
163 |
-
border-bottom-right-radius: 4px !important;
|
164 |
-
}
|
165 |
-
|
166 |
-
#wp-admin-bar ul.main-nav li ul li a:hover, #wp-admin-bar ul.main-nav li.sfhover ul li a:hover {
|
167 |
-
background-color: #888 !important;
|
168 |
-
}
|
169 |
-
|
170 |
-
#wp-admin-bar ul li div.admin-bar-clear {
|
171 |
-
clear: both !important;
|
172 |
-
background-color: #eee !important;
|
173 |
-
border-bottom: 3px solid #eee !important;
|
174 |
-
}
|
175 |
-
|
176 |
-
/* third-and-above-level lists */
|
177 |
-
|
178 |
-
#wp-admin-bar ul li ul ul {
|
179 |
-
margin: -28px 0 0 183px !important;
|
180 |
-
}
|
181 |
-
|
182 |
-
#wp-admin-bar ul li:hover ul, #wp-admin-bar ul li li:hover ul, #wp-admin-bar ul li.sfhover ul, #wp-admin-bar ul li ul li.sfhover ul { /* lists nested under hovered list items */
|
183 |
-
left: auto !important;
|
184 |
-
}
|
185 |
-
|
186 |
-
#wp-admin-bar ul li.align-right:hover ul {
|
187 |
-
right: 0 !important;
|
188 |
-
}
|
189 |
-
|
190 |
-
#wp-admin-bar ul li:hover ul ul, #wp-admin-bar li.sfhover ul li ul {
|
191 |
-
left: -999em !important;
|
192 |
-
}
|
193 |
-
|
194 |
-
#wp-admin-bar ul li ul li ul li:first-child {
|
195 |
-
border-top: 1px solid #ccc !important;
|
196 |
-
-moz-border-radius-topright: 4px !important;
|
197 |
-
-khtml-border-top-right-radius: 4px !important;
|
198 |
-
-webkit-border-top-right-radius: 4px !important;
|
199 |
-
border-top-right-radius: 4px !important;
|
200 |
-
margin-top: -2px !important;
|
201 |
-
}
|
202 |
-
|
203 |
-
/* Menu item css */
|
204 |
-
|
205 |
-
#wp-admin-bar img.avatar {
|
206 |
-
float: left !important;
|
207 |
-
border: 2px solid #fff !important;
|
208 |
-
margin-right: 8px !important;
|
209 |
-
}
|
210 |
-
|
211 |
-
#wp-admin-bar span.activity {
|
212 |
-
display: block !important;
|
213 |
-
color: #888 !important;
|
214 |
-
margin-left: 34px !important;
|
215 |
-
font-size: 10px !important;
|
216 |
-
background: none !important;
|
217 |
-
border: none !important;
|
218 |
-
padding: 0 !important;
|
219 |
-
}
|
220 |
-
|
221 |
-
#wp-admin-bar li a:hover span.activity {
|
222 |
-
color: #ccc !important;
|
223 |
-
}
|
224 |
-
|
225 |
-
#wp-admin-bar ul.author-list li {
|
226 |
-
height: 55px !important;
|
227 |
-
}
|
228 |
-
|
229 |
-
#wp-admin-bar ul li#bp-adminbar-notifications-menu a span {
|
230 |
-
background: #fff !important;
|
231 |
-
padding: 0 6px !important;
|
232 |
-
color: #555 !important;
|
233 |
-
font-weight: bold !important;
|
234 |
-
font-size: 0.8em !important;
|
235 |
-
-moz-border-radius: 2px !important;
|
236 |
-
-khtml-border-radius: 2px !important;
|
237 |
-
-webkit-border-radius: 2px !important;
|
238 |
-
margin-left: 2px !important;
|
239 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bp-core/deprecated/css/structure.css
DELETED
@@ -1,322 +0,0 @@
|
|
1 |
-
/*
|
2 |
-
Basic layout structure styles for BuddyPress. Formats BuddyPress pages within any WordPress theme.
|
3 |
-
No colors, fonts or pretty stuff.
|
4 |
-
|
5 |
-
These structure styles can be overridden by the theme CSS file if needed.
|
6 |
-
*/
|
7 |
-
|
8 |
-
/***
|
9 |
-
* Mini reset
|
10 |
-
*/
|
11 |
-
|
12 |
-
#main #content { background: none; }
|
13 |
-
|
14 |
-
.main-column ul, .left-menu ul, #userbar ul, #optionsbar ul, #wrap ul {
|
15 |
-
list-style: none;
|
16 |
-
padding: 0;
|
17 |
-
margin: 0;
|
18 |
-
}
|
19 |
-
|
20 |
-
/***
|
21 |
-
* Userbar
|
22 |
-
*/
|
23 |
-
|
24 |
-
#userbar {
|
25 |
-
margin-bottom: 15px;
|
26 |
-
}
|
27 |
-
#userbar ul li {
|
28 |
-
float: left;
|
29 |
-
margin-right: 10px;
|
30 |
-
}
|
31 |
-
|
32 |
-
#userbar img.avatar {
|
33 |
-
float: left;
|
34 |
-
margin-right: 8px;
|
35 |
-
margin-top: 2px;
|
36 |
-
}
|
37 |
-
|
38 |
-
/***
|
39 |
-
* Options bar
|
40 |
-
*/
|
41 |
-
|
42 |
-
#optionsbar {
|
43 |
-
margin-bottom: 15px;
|
44 |
-
}
|
45 |
-
#optionsbar ul li {
|
46 |
-
float: left;
|
47 |
-
margin-right: 10px;
|
48 |
-
}
|
49 |
-
|
50 |
-
#optionsbar img.avatar {
|
51 |
-
float: left;
|
52 |
-
margin-right: 8px;
|
53 |
-
margin-top: 2px;
|
54 |
-
}
|
55 |
-
|
56 |
-
#userbar li.current a, #optionsbar li.current a, .content-header-nav li.current a {
|
57 |
-
font-weight: bold;
|
58 |
-
}
|
59 |
-
|
60 |
-
/***
|
61 |
-
* Main Column & Info Groups
|
62 |
-
*/
|
63 |
-
|
64 |
-
|
65 |
-
.main-column {
|
66 |
-
margin-left: 200px;
|
67 |
-
}
|
68 |
-
.main-column h1, #blog-info h1 {
|
69 |
-
margin-bottom: 0.3em;
|
70 |
-
}
|
71 |
-
.main-column p.status, #blog-info p.desc {
|
72 |
-
margin: 0 0 1.2em 0;
|
73 |
-
}
|
74 |
-
|
75 |
-
div.info-group {
|
76 |
-
margin-bottom: 2em;
|
77 |
-
}
|
78 |
-
div.info-group h4 {
|
79 |
-
height: 30px;
|
80 |
-
padding: 3px 10px;
|
81 |
-
margin-bottom: 0.5em;
|
82 |
-
position: relative;
|
83 |
-
}
|
84 |
-
.left-menu div.info-group {
|
85 |
-
margin-top: 1.5em;
|
86 |
-
}
|
87 |
-
|
88 |
-
div.info-group h4 a {
|
89 |
-
position: absolute;
|
90 |
-
top: 0.31em;
|
91 |
-
right: 1em;
|
92 |
-
font-weight: normal;
|
93 |
-
}
|
94 |
-
|
95 |
-
.left-menu div.info-group img.avatar {
|
96 |
-
float: left;
|
97 |
-
margin-right: 1em;
|
98 |
-
}
|
99 |
-
|
100 |
-
.horiz-gallery li {
|
101 |
-
float: left;
|
102 |
-
margin: 0 1.5em 0 0;
|
103 |
-
width: 15%;
|
104 |
-
text-align: center;
|
105 |
-
}
|
106 |
-
|
107 |
-
/***
|
108 |
-
* Left Menu
|
109 |
-
*/
|
110 |
-
|
111 |
-
.left-menu, .page-menu {
|
112 |
-
position: relative;
|
113 |
-
float: left;
|
114 |
-
width: 158px;
|
115 |
-
}
|
116 |
-
|
117 |
-
/***
|
118 |
-
* Pagination
|
119 |
-
*/
|
120 |
-
|
121 |
-
.pagination-links {
|
122 |
-
margin-top: -3.7em;
|
123 |
-
float: right;
|
124 |
-
}
|
125 |
-
.pagination-links .page-numbers {
|
126 |
-
padding: 0.65em 0.7em;
|
127 |
-
height: 24px;
|
128 |
-
}
|
129 |
-
.pagination-links .current {
|
130 |
-
padding: 0.5em 0.7em;
|
131 |
-
}
|
132 |
-
|
133 |
-
div.info-group .pagination-links {
|
134 |
-
margin: 0 0 5px 0;
|
135 |
-
float: none;
|
136 |
-
text-align: right;
|
137 |
-
}
|
138 |
-
|
139 |
-
.pag-count {
|
140 |
-
margin-bottom: -20px;
|
141 |
-
}
|
142 |
-
|
143 |
-
|
144 |
-
/***
|
145 |
-
* Item lists
|
146 |
-
*/
|
147 |
-
|
148 |
-
ul.item-list li {
|
149 |
-
position: relative;
|
150 |
-
padding: 1em;
|
151 |
-
min-height: 60px;
|
152 |
-
}
|
153 |
-
|
154 |
-
ul.item-list li img.avatar {
|
155 |
-
float: left;
|
156 |
-
margin: 0 1em 0 0;
|
157 |
-
}
|
158 |
-
|
159 |
-
ul.item-list p.desc {
|
160 |
-
margin-left: 70px;
|
161 |
-
}
|
162 |
-
|
163 |
-
.item-list .action {
|
164 |
-
position: absolute;
|
165 |
-
top: 30%;
|
166 |
-
right: 1em;
|
167 |
-
}
|
168 |
-
|
169 |
-
/***
|
170 |
-
* Form Styles & Misc
|
171 |
-
*/
|
172 |
-
|
173 |
-
.standard-form label {
|
174 |
-
display: block;
|
175 |
-
padding: 0 0 0.3em 0;
|
176 |
-
margin: 1em 0 0 0;
|
177 |
-
}
|
178 |
-
|
179 |
-
.standard-form input, .standard-form select, .standard-form textarea {
|
180 |
-
font-size: 1.3em;
|
181 |
-
font-family: inherit;
|
182 |
-
width: 65%;
|
183 |
-
padding: 0.2em;
|
184 |
-
}
|
185 |
-
|
186 |
-
.standard-form textarea {
|
187 |
-
height: 100px;
|
188 |
-
}
|
189 |
-
|
190 |
-
.standard-form input[type="submit"], .standard-form input#save {
|
191 |
-
width: auto;
|
192 |
-
}
|
193 |
-
|
194 |
-
a#accept, a#reject {
|
195 |
-
float: right;
|
196 |
-
margin-left: 10px;
|
197 |
-
}
|
198 |
-
|
199 |
-
|
200 |
-
form#settings-form h3 {
|
201 |
-
margin-bottom: 10px !important;
|
202 |
-
}
|
203 |
-
|
204 |
-
form#settings-form label {
|
205 |
-
display: block;
|
206 |
-
margin-bottom: 3px;
|
207 |
-
}
|
208 |
-
form#settings-form label span {
|
209 |
-
color: #888;
|
210 |
-
font-size: 0.9em;
|
211 |
-
}
|
212 |
-
|
213 |
-
|
214 |
-
/***
|
215 |
-
* Settings Screens
|
216 |
-
*/
|
217 |
-
|
218 |
-
input.settings-input {
|
219 |
-
padding: 0.2em;
|
220 |
-
width: 65%;
|
221 |
-
margin-bottom: 15px;
|
222 |
-
}
|
223 |
-
input.small { width: 45%; }
|
224 |
-
input.auto { width: auto; }
|
225 |
-
|
226 |
-
table.notification-settings {
|
227 |
-
width: 80%;
|
228 |
-
margin-bottom: 20px;
|
229 |
-
}
|
230 |
-
table.notification-settings td {
|
231 |
-
padding: 3px 0;
|
232 |
-
}
|
233 |
-
|
234 |
-
table.notification-settings th.icon {
|
235 |
-
width: 35px;
|
236 |
-
}
|
237 |
-
|
238 |
-
table.notification-settings th.title {
|
239 |
-
width: 80%;
|
240 |
-
}
|
241 |
-
|
242 |
-
table.notification-settings .yes, table.notification-settings .no {
|
243 |
-
width: 40px;
|
244 |
-
}
|
245 |
-
|
246 |
-
/* Buttons */
|
247 |
-
|
248 |
-
.friendship-button {
|
249 |
-
background: url(../../../bp-core/deprecated/images/button_back.gif) top left no-repeat;
|
250 |
-
display: inline-block;
|
251 |
-
margin-bottom: 10px;
|
252 |
-
margin-left: -6px;
|
253 |
-
margin-right: 5px;
|
254 |
-
}
|
255 |
-
|
256 |
-
.friendship-button a {
|
257 |
-
display: block;
|
258 |
-
height: 19px;
|
259 |
-
color: #777;
|
260 |
-
font-size: 11px;
|
261 |
-
padding: 0 33px 0 11px;
|
262 |
-
text-shadow: 0 1px 0 #fff;
|
263 |
-
text-decoration: none;
|
264 |
-
margin-right: -7px;
|
265 |
-
}
|
266 |
-
.friendship-button a:hover {
|
267 |
-
color: #555;
|
268 |
-
text-decoration: none;
|
269 |
-
}
|
270 |
-
|
271 |
-
.friendship-button a.add {
|
272 |
-
background: url(../../../bp-core/deprecated/images/add_button_side.gif) top right no-repeat;
|
273 |
-
}
|
274 |
-
|
275 |
-
.friendship-button a.remove {
|
276 |
-
background: url(../../../bp-core/deprecated/images/remove_button_side.gif) top right no-repeat;
|
277 |
-
}
|
278 |
-
|
279 |
-
.friendship-button a.requested {
|
280 |
-
background: url(../../../bp-core/deprecated/images/check_button_side.gif) top right no-repeat;
|
281 |
-
}
|
282 |
-
|
283 |
-
.loading a {
|
284 |
-
background: url(../../../bp-core/deprecated/images/loading_button_side.gif) top right no-repeat !important;
|
285 |
-
}
|
286 |
-
|
287 |
-
.button-block {
|
288 |
-
text-align: right;
|
289 |
-
margin: 1em 2px;
|
290 |
-
}
|
291 |
-
|
292 |
-
.generic-button {
|
293 |
-
background: url(../../../bp-core/deprecated/images/button_back.gif) top left no-repeat;
|
294 |
-
display: inline-block;
|
295 |
-
margin: 0 5px 8px 0;
|
296 |
-
}
|
297 |
-
|
298 |
-
.generic-button a {
|
299 |
-
display: block;
|
300 |
-
height: 19px;
|
301 |
-
color: #777;
|
302 |
-
font-size: 11px;
|
303 |
-
padding: 0 33px 0 11px;
|
304 |
-
margin-right: -7px;
|
305 |
-
text-shadow: 0 1px 0 #fff;
|
306 |
-
text-decoration: none;
|
307 |
-
background: url(../../../bp-core/deprecated/images/view_button_side.gif) top right no-repeat;
|
308 |
-
}
|
309 |
-
.accept a { background-image: url(../../../bp-core/deprecated/images/accept_button_side.gif); }
|
310 |
-
.reject a { background-image: url(../../../bp-core/deprecated/images/reject_button_side.gif); }
|
311 |
-
|
312 |
-
.generic-button a:hover {
|
313 |
-
color: #555;
|
314 |
-
text-decoration: none;
|
315 |
-
}
|
316 |
-
|
317 |
-
.button-block div {
|
318 |
-
margin-bottom: 15px;
|
319 |
-
}
|
320 |
-
|
321 |
-
|
322 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bp-core/deprecated/images/accept_button_side.gif
DELETED
Binary file
|
bp-core/deprecated/images/add_button_side.gif
DELETED
Binary file
|
bp-core/deprecated/images/add_friend_button.gif
DELETED
Binary file
|
bp-core/deprecated/images/admin-menu-arrow.gif
DELETED
Binary file
|
bp-core/deprecated/images/admin_bar_back.gif
DELETED
Binary file
|
bp-core/deprecated/images/admin_bar_logo.gif
DELETED
Binary file
|
bp-core/deprecated/images/ajax-loader.gif
DELETED
Binary file
|
bp-core/deprecated/images/blog.png
DELETED
Binary file
|
bp-core/deprecated/images/button_back.gif
DELETED
Binary file
|
bp-core/deprecated/images/check_button_side.gif
DELETED
Binary file
|
bp-core/deprecated/images/loading_button_side.gif
DELETED
Binary file
|
bp-core/deprecated/images/logout_bullet.gif
DELETED
Binary file
|
bp-core/deprecated/images/member.png
DELETED
Binary file
|
bp-core/deprecated/images/nav_bullet.gif
DELETED
Binary file
|
bp-core/deprecated/images/reject_button_side.gif
DELETED
Binary file
|
bp-core/deprecated/images/remove_button_side.gif
DELETED
Binary file
|
bp-core/deprecated/images/remove_friend_button.gif
DELETED
Binary file
|
bp-core/deprecated/images/requested_friend_button.gif
DELETED
Binary file
|
bp-core/deprecated/images/view_button_side.gif
DELETED
Binary file
|
bp-core/deprecated/js/directory-members.js
DELETED
@@ -1,111 +0,0 @@
|
|
1 |
-
jQuery(document).ready( function() {
|
2 |
-
jQuery("ul#letter-list li a").livequery('click',
|
3 |
-
function() {
|
4 |
-
jQuery('#ajax-loader-members').toggle();
|
5 |
-
|
6 |
-
jQuery("div#members-list-options a").removeClass("selected");
|
7 |
-
jQuery(this).addClass('selected');
|
8 |
-
jQuery("input#members_search").val('');
|
9 |
-
|
10 |
-
var letter = jQuery(this).attr('id')
|
11 |
-
letter = letter.split('-');
|
12 |
-
|
13 |
-
var page = ( jQuery('input#members-page-num').val() ) ? jQuery('input#members-page-num').val() : 1;
|
14 |
-
|
15 |
-
jQuery.post( ajaxurl, {
|
16 |
-
action: 'directory_members',
|
17 |
-
'cookie': encodeURIComponent(document.cookie),
|
18 |
-
'_wpnonce': jQuery("input#_wpnonce-member-filter").val(),
|
19 |
-
'letter': letter[1],
|
20 |
-
'page': page
|
21 |
-
},
|
22 |
-
function(response)
|
23 |
-
{
|
24 |
-
response = response.substr(0, response.length-1);
|
25 |
-
|
26 |
-
jQuery("#member-dir-list").fadeOut(200,
|
27 |
-
function() {
|
28 |
-
jQuery('#ajax-loader-members').toggle();
|
29 |
-
jQuery("#member-dir-list").html(response);
|
30 |
-
jQuery("#member-dir-list").fadeIn(200);
|
31 |
-
}
|
32 |
-
);
|
33 |
-
});
|
34 |
-
|
35 |
-
return false;
|
36 |
-
}
|
37 |
-
);
|
38 |
-
|
39 |
-
jQuery("form#search-members-form").submit( function() {
|
40 |
-
jQuery('#ajax-loader-members').toggle();
|
41 |
-
|
42 |
-
var page = ( jQuery('input#members-page-num').val() ) ? jQuery('input#members-page-num').val() : 1;
|
43 |
-
|
44 |
-
jQuery.post( ajaxurl, {
|
45 |
-
action: 'directory_members',
|
46 |
-
'cookie': encodeURIComponent(document.cookie),
|
47 |
-
'_wpnonce': jQuery("input#_wpnonce-member-filter").val(),
|
48 |
-
's': jQuery("input#members_search").val(),
|
49 |
-
'page': page
|
50 |
-
},
|
51 |
-
function(response)
|
52 |
-
{
|
53 |
-
response = response.substr(0, response.length-1);
|
54 |
-
|
55 |
-
jQuery("#member-dir-list").fadeOut(200,
|
56 |
-
function() {
|
57 |
-
jQuery('#ajax-loader-members').toggle();
|
58 |
-
jQuery("#member-dir-list").html(response);
|
59 |
-
jQuery("#member-dir-list").fadeIn(200);
|
60 |
-
}
|
61 |
-
);
|
62 |
-
});
|
63 |
-
|
64 |
-
return false;
|
65 |
-
}
|
66 |
-
);
|
67 |
-
|
68 |
-
jQuery("div#member-dir-pag a").livequery('click',
|
69 |
-
function() {
|
70 |
-
jQuery('#ajax-loader-members').toggle();
|
71 |
-
|
72 |
-
var page = jQuery(this).attr('href');
|
73 |
-
page = page.split('upage=');
|
74 |
-
|
75 |
-
if ( !jQuery("input#selected_letter").val() )
|
76 |
-
var letter = '';
|
77 |
-
else
|
78 |
-
var letter = jQuery("input#selected_letter").val();
|
79 |
-
|
80 |
-
if ( !jQuery("input#search_terms").val() )
|
81 |
-
var search_terms = '';
|
82 |
-
else
|
83 |
-
var search_terms = jQuery("input#search_terms").val();
|
84 |
-
|
85 |
-
jQuery.post( ajaxurl, {
|
86 |
-
action: 'directory_members',
|
87 |
-
'cookie': encodeURIComponent(document.cookie),
|
88 |
-
'_wpnonce': jQuery("input#_wpnonce").val(),
|
89 |
-
'upage': page[1],
|
90 |
-
'_wpnonce': jQuery("input#_wpnonce-member-filter").val(),
|
91 |
-
|
92 |
-
'letter': letter,
|
93 |
-
's': search_terms
|
94 |
-
},
|
95 |
-
function(response)
|
96 |
-
{
|
97 |
-
response = response.substr(0, response.length-1);
|
98 |
-
|
99 |
-
jQuery("#member-dir-list").fadeOut(200,
|
100 |
-
function() {
|
101 |
-
jQuery('#ajax-loader-members').toggle();
|
102 |
-
jQuery("#member-dir-list").html(response);
|
103 |
-
jQuery("#member-dir-list").fadeIn(200);
|
104 |
-
}
|
105 |
-
);
|
106 |
-
});
|
107 |
-
|
108 |
-
return false;
|
109 |
-
}
|
110 |
-
);
|
111 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bp-core/deprecated/js/general.js
DELETED
@@ -1,100 +0,0 @@
|
|
1 |
-
jQuery(document).ready( function() {
|
2 |
-
jQuery("div.friendship-button a").livequery('click',
|
3 |
-
function() {
|
4 |
-
jQuery(this).parent().addClass('loading');
|
5 |
-
|
6 |
-
var fid = jQuery(this).attr('id');
|
7 |
-
fid = fid.split('-');
|
8 |
-
fid = fid[1];
|
9 |
-
|
10 |
-
var nonce = jQuery(this).attr('href');
|
11 |
-
nonce = nonce.split('?_wpnonce=');
|
12 |
-
nonce = nonce[1].split('&');
|
13 |
-
nonce = nonce[0];
|
14 |
-
|
15 |
-
var thelink = jQuery(this);
|
16 |
-
|
17 |
-
jQuery.post( ajaxurl, {
|
18 |
-
action: 'addremove_friend',
|
19 |
-
'cookie': encodeURIComponent(document.cookie),
|
20 |
-
'fid': fid,
|
21 |
-
'_wpnonce': nonce
|
22 |
-
},
|
23 |
-
function(response)
|
24 |
-
{
|
25 |
-
response = response.substr(0, response.length-1);
|
26 |
-
|
27 |
-
var action = thelink.attr('rel');
|
28 |
-
var parentdiv = thelink.parent();
|
29 |
-
|
30 |
-
if ( action == 'add' ) {
|
31 |
-
jQuery(parentdiv).fadeOut(200,
|
32 |
-
function() {
|
33 |
-
parentdiv.removeClass('add_friend');
|
34 |
-
parentdiv.removeClass('loading');
|
35 |
-
parentdiv.addClass('pending');
|
36 |
-
parentdiv.fadeIn(200).html(response);
|
37 |
-
}
|
38 |
-
);
|
39 |
-
|
40 |
-
} else if ( action == 'remove' ) {
|
41 |
-
jQuery(parentdiv).fadeOut(200,
|
42 |
-
function() {
|
43 |
-
parentdiv.removeClass('remove_friend');
|
44 |
-
parentdiv.removeClass('loading');
|
45 |
-
parentdiv.addClass('add');
|
46 |
-
parentdiv.fadeIn(200).html(response);
|
47 |
-
}
|
48 |
-
);
|
49 |
-
}
|
50 |
-
});
|
51 |
-
return false;
|
52 |
-
}
|
53 |
-
);
|
54 |
-
});
|
55 |
-
|
56 |
-
jQuery("div#wire-pagination a").livequery('click',
|
57 |
-
function() {
|
58 |
-
jQuery('#ajax-loader').toggle();
|
59 |
-
|
60 |
-
var fpage = jQuery(this).attr('href');
|
61 |
-
fpage = fpage.split('=');
|
62 |
-
|
63 |
-
jQuery.post( ajaxurl, {
|
64 |
-
action: 'get_wire_posts',
|
65 |
-
'cookie': encodeURIComponent(document.cookie),
|
66 |
-
'_wpnonce': jQuery("input#_wpnonce").val(),
|
67 |
-
'wpage': fpage[1],
|
68 |
-
'bp_wire_item_id': jQuery("input#bp_wire_item_id").val()
|
69 |
-
},
|
70 |
-
function(response)
|
71 |
-
{
|
72 |
-
jQuery('#ajax-loader').toggle();
|
73 |
-
|
74 |
-
response = response.substr(0, response.length-1);
|
75 |
-
|
76 |
-
jQuery("form#wire-post-list-form").fadeOut(200,
|
77 |
-
function() {
|
78 |
-
jQuery("form#wire-post-list-form").html(response);
|
79 |
-
jQuery("form#wire-post-list-form").fadeIn(200);
|
80 |
-
}
|
81 |
-
);
|
82 |
-
|
83 |
-
return false;
|
84 |
-
});
|
85 |
-
|
86 |
-
return false;
|
87 |
-
}
|
88 |
-
);
|
89 |
-
|
90 |
-
function clear(container) {
|
91 |
-
if(!document.getElementById(container)) return false;
|
92 |
-
|
93 |
-
var container = document.getElementById(container);
|
94 |
-
|
95 |
-
radioButtons = container.getElementsByTagName('INPUT');
|
96 |
-
|
97 |
-
for(var i=0; i<radioButtons.length; i++) {
|
98 |
-
radioButtons[i].checked = false;
|
99 |
-
}
|
100 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bp-core/deprecated/js/jquery/jquery.livequery.pack.js
DELETED
@@ -1,9 +0,0 @@
|
|
1 |
-
/* Copyright (c) 2007 Brandon Aaron (brandon.aaron@gmail.com || http://brandonaaron.net)
|
2 |
-
* Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
|
3 |
-
* and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
|
4 |
-
*
|
5 |
-
* Version: 1.0.2
|
6 |
-
* Requires jQuery 1.1.3+
|
7 |
-
* Docs: http://docs.jquery.com/Plugins/livequery
|
8 |
-
*/
|
9 |
-
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(4($){$.R($.7,{3:4(c,b,d){9 e=2,q;5($.O(c))d=b,b=c,c=z;$.h($.3.j,4(i,a){5(e.8==a.8&&e.g==a.g&&c==a.m&&(!b||b.$6==a.7.$6)&&(!d||d.$6==a.o.$6))l(q=a)&&v});q=q||Y $.3(2.8,2.g,c,b,d);q.u=v;$.3.s(q.F);l 2},T:4(c,b,d){9 e=2;5($.O(c))d=b,b=c,c=z;$.h($.3.j,4(i,a){5(e.8==a.8&&e.g==a.g&&(!c||c==a.m)&&(!b||b.$6==a.7.$6)&&(!d||d.$6==a.o.$6)&&!2.u)$.3.y(a.F)});l 2}});$.3=4(e,c,a,b,d){2.8=e;2.g=c||S;2.m=a;2.7=b;2.o=d;2.t=[];2.u=v;2.F=$.3.j.K(2)-1;b.$6=b.$6||$.3.I++;5(d)d.$6=d.$6||$.3.I++;l 2};$.3.p={y:4(){9 b=2;5(2.m)2.t.16(2.m,2.7);E 5(2.o)2.t.h(4(i,a){b.o.x(a)});2.t=[];2.u=Q},s:4(){5(2.u)l;9 b=2;9 c=2.t,w=$(2.8,2.g),H=w.11(c);2.t=w;5(2.m){H.10(2.m,2.7);5(c.C>0)$.h(c,4(i,a){5($.B(a,w)<0)$.Z.P(a,b.m,b.7)})}E{H.h(4(){b.7.x(2)});5(2.o&&c.C>0)$.h(c,4(i,a){5($.B(a,w)<0)b.o.x(a)})}}};$.R($.3,{I:0,j:[],k:[],A:v,D:X,N:4(){5($.3.A&&$.3.k.C){9 a=$.3.k.C;W(a--)$.3.j[$.3.k.V()].s()}},U:4(){$.3.A=v},M:4(){$.3.A=Q;$.3.s()},L:4(){$.h(G,4(i,n){5(!$.7[n])l;9 a=$.7[n];$.7[n]=4(){9 r=a.x(2,G);$.3.s();l r}})},s:4(b){5(b!=z){5($.B(b,$.3.k)<0)$.3.k.K(b)}E $.h($.3.j,4(a){5($.B(a,$.3.k)<0)$.3.k.K(a)});5($.3.D)1j($.3.D);$.3.D=1i($.3.N,1h)},y:4(b){5(b!=z)$.3.j[b].y();E $.h($.3.j,4(a){$.3.j[a].y()})}});$.3.L(\'1g\',\'1f\',\'1e\',\'1b\',\'1a\',\'19\',\'18\',\'17\',\'1c\',\'15\',\'1d\',\'P\');$(4(){$.3.M()});9 f=$.p.J;$.p.J=4(a,c){9 r=f.x(2,G);5(a&&a.8)r.g=a.g,r.8=a.8;5(14 a==\'13\')r.g=c||S,r.8=a;l r};$.p.J.p=$.p})(12);',62,82,'||this|livequery|function|if|lqguid|fn|selector|var|||||||context|each||queries|queue|return|type||fn2|prototype|||run|elements|stopped|false|els|apply|stop|undefined|running|inArray|length|timeout|else|id|arguments|nEls|guid|init|push|registerPlugin|play|checkQueue|isFunction|remove|true|extend|document|expire|pause|shift|while|null|new|event|bind|not|jQuery|string|typeof|toggleClass|unbind|addClass|removeAttr|attr|wrap|before|removeClass|empty|after|prepend|append|20|setTimeout|clearTimeout'.split('|'),0,{}))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bp-core/deprecated/js/jquery/jquery.tablednd.js
DELETED
@@ -1,314 +0,0 @@
|
|
1 |
-
/**
|
2 |
-
* TableDnD plug-in for JQuery, allows you to drag and drop table rows
|
3 |
-
* You can set up various options to control how the system will work
|
4 |
-
* Copyright � Denis Howlett <denish@isocra.com>
|
5 |
-
* Licensed like jQuery, see http://docs.jquery.com/License.
|
6 |
-
*
|
7 |
-
* Configuration options:
|
8 |
-
*
|
9 |
-
* onDragStyle
|
10 |
-
* This is the style that is assigned to the row during drag. There are limitations to the styles that can be
|
11 |
-
* associated with a row (such as you can't assign a border—well you can, but it won't be
|
12 |
-
* displayed). (So instead consider using onDragClass.) The CSS style to apply is specified as
|
13 |
-
* a map (as used in the jQuery css(...) function).
|
14 |
-
* onDropStyle
|
15 |
-
* This is the style that is assigned to the row when it is dropped. As for onDragStyle, there are limitations
|
16 |
-
* to what you can do. Also this replaces the original style, so again consider using onDragClass which
|
17 |
-
* is simply added and then removed on drop.
|
18 |
-
* onDragClass
|
19 |
-
* This class is added for the duration of the drag and then removed when the row is dropped. It is more
|
20 |
-
* flexible than using onDragStyle since it can be inherited by the row cells and other content. The default
|
21 |
-
* is class is tDnD_whileDrag. So to use the default, simply customise this CSS class in your
|
22 |
-
* stylesheet.
|
23 |
-
* onDrop
|
24 |
-
* Pass a function that will be called when the row is dropped. The function takes 2 parameters: the table
|
25 |
-
* and the row that was dropped. You can work out the new order of the rows by using
|
26 |
-
* table.rows.
|
27 |
-
* onDragStart
|
28 |
-
* Pass a function that will be called when the user starts dragging. The function takes 2 parameters: the
|
29 |
-
* table and the row which the user has started to drag.
|
30 |
-
* onAllowDrop
|
31 |
-
* Pass a function that will be called as a row is over another row. If the function returns true, allow
|
32 |
-
* dropping on that row, otherwise not. The function takes 2 parameters: the dragged row and the row under
|
33 |
-
* the cursor. It returns a boolean: true allows the drop, false doesn't allow it.
|
34 |
-
* scrollAmount
|
35 |
-
* This is the number of pixels to scroll if the user moves the mouse cursor to the top or bottom of the
|
36 |
-
* window. The page should automatically scroll up or down as appropriate (tested in IE6, IE7, Safari, FF2,
|
37 |
-
* FF3 beta)
|
38 |
-
*
|
39 |
-
* Other ways to control behaviour:
|
40 |
-
*
|
41 |
-
* Add class="nodrop" to any rows for which you don't want to allow dropping, and class="nodrag" to any rows
|
42 |
-
* that you don't want to be draggable.
|
43 |
-
*
|
44 |
-
* Inside the onDrop method you can also call $.tableDnD.serialize() this returns a string of the form
|
45 |
-
* <tableID>[]=<rowID1>&<tableID>[]=<rowID2> so that you can send this back to the server. The table must have
|
46 |
-
* an ID as must all the rows.
|
47 |
-
*
|
48 |
-
* Known problems:
|
49 |
-
* - Auto-scoll has some problems with IE7 (it scrolls even when it shouldn't), work-around: set scrollAmount to 0
|
50 |
-
*
|
51 |
-
* Version 0.2: 2008-02-20 First public version
|
52 |
-
* Version 0.3: 2008-02-07 Added onDragStart option
|
53 |
-
* Made the scroll amount configurable (default is 5 as before)
|
54 |
-
* Version 0.4: 2008-03-15 Changed the noDrag/noDrop attributes to nodrag/nodrop classes
|
55 |
-
* Added onAllowDrop to control dropping
|
56 |
-
* Fixed a bug which meant that you couldn't set the scroll amount in both directions
|
57 |
-
* Added serialise method
|
58 |
-
*/
|
59 |
-
jQuery.tableDnD = {
|
60 |
-
/** Keep hold of the current table being dragged */
|
61 |
-
currentTable : null,
|
62 |
-
/** Keep hold of the current drag object if any */
|
63 |
-
dragObject: null,
|
64 |
-
/** The current mouse offset */
|
65 |
-
mouseOffset: null,
|
66 |
-
/** Remember the old value of Y so that we don't do too much processing */
|
67 |
-
oldY: 0,
|
68 |
-
|
69 |
-
/** Actually build the structure */
|
70 |
-
build: function(options) {
|
71 |
-
// Make sure options exists
|
72 |
-
options = options || {};
|
73 |
-
// Set up the defaults if any
|
74 |
-
|
75 |
-
this.each(function() {
|
76 |
-
// Remember the options
|
77 |
-
this.tableDnDConfig = {
|
78 |
-
onDragStyle: options.onDragStyle,
|
79 |
-
onDropStyle: options.onDropStyle,
|
80 |
-
// Add in the default class for whileDragging
|
81 |
-
onDragClass: options.onDragClass ? options.onDragClass : "tDnD_whileDrag",
|
82 |
-
onDrop: options.onDrop,
|
83 |
-
onDragStart: options.onDragStart,
|
84 |
-
scrollAmount: options.scrollAmount ? options.scrollAmount : 5
|
85 |
-
};
|
86 |
-
// Now make the rows draggable
|
87 |
-
jQuery.tableDnD.makeDraggable(this);
|
88 |
-
});
|
89 |
-
|
90 |
-
// Now we need to capture the mouse up and mouse move event
|
91 |
-
// We can use bind so that we don't interfere with other event handlers
|
92 |
-
jQuery(document)
|
93 |
-
.bind('mousemove', jQuery.tableDnD.mousemove)
|
94 |
-
.bind('mouseup', jQuery.tableDnD.mouseup);
|
95 |
-
|
96 |
-
// Don't break the chain
|
97 |
-
return this;
|
98 |
-
},
|
99 |
-
|
100 |
-
/** This function makes all the rows on the table draggable apart from those marked as "NoDrag" */
|
101 |
-
makeDraggable: function(table) {
|
102 |
-
// Now initialise the rows
|
103 |
-
var rows = table.rows; //getElementsByTagName("tr")
|
104 |
-
var config = table.tableDnDConfig;
|
105 |
-
for (var i=0; i<rows.length; i++) {
|
106 |
-
// To make non-draggable rows, add the nodrag class (eg for Category and Header rows)
|
107 |
-
// inspired by John Tarr and Famic
|
108 |
-
var nodrag = jQuery(rows[i]).hasClass("nodrag");
|
109 |
-
if (! nodrag) { //There is no NoDnD attribute on rows I want to drag
|
110 |
-
jQuery(rows[i]).mousedown(function(ev) {
|
111 |
-
if (ev.target.tagName == "TD") {
|
112 |
-
jQuery.tableDnD.dragObject = this;
|
113 |
-
jQuery.tableDnD.currentTable = table;
|
114 |
-
jQuery.tableDnD.mouseOffset = jQuery.tableDnD.getMouseOffset(this, ev);
|
115 |
-
if (config.onDragStart) {
|
116 |
-
// Call the onDrop method if there is one
|
117 |
-
config.onDragStart(table, this);
|
118 |
-
}
|
119 |
-
return false;
|
120 |
-
}
|
121 |
-
}).css("cursor", "move"); // Store the tableDnD object
|
122 |
-
}
|
123 |
-
}
|
124 |
-
},
|
125 |
-
|
126 |
-
/** Get the mouse coordinates from the event (allowing for browser differences) */
|
127 |
-
mouseCoords: function(ev){
|
128 |
-
if(ev.pageX || ev.pageY){
|
129 |
-
return {x:ev.pageX, y:ev.pageY};
|
130 |
-
}
|
131 |
-
return {
|
132 |
-
x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,
|
133 |
-
y:ev.clientY + document.body.scrollTop - document.body.clientTop
|
134 |
-
};
|
135 |
-
},
|
136 |
-
|
137 |
-
/** Given a target element and a mouse event, get the mouse offset from that element.
|
138 |
-
To do this we need the element's position and the mouse position */
|
139 |
-
getMouseOffset: function(target, ev) {
|
140 |
-
ev = ev || window.event;
|
141 |
-
|
142 |
-
var docPos = this.getPosition(target);
|
143 |
-
var mousePos = this.mouseCoords(ev);
|
144 |
-
return {x:mousePos.x - docPos.x, y:mousePos.y - docPos.y};
|
145 |
-
},
|
146 |
-
|
147 |
-
/** Get the position of an element by going up the DOM tree and adding up all the offsets */
|
148 |
-
getPosition: function(e){
|
149 |
-
var left = 0;
|
150 |
-
var top = 0;
|
151 |
-
/** Safari fix -- thanks to Luis Chato for this! */
|
152 |
-
if (e.offsetHeight == 0) {
|
153 |
-
/** Safari 2 doesn't correctly grab the offsetTop of a table row
|
154 |
-
this is detailed here:
|
155 |
-
http://jacob.peargrove.com/blog/2006/technical/table-row-offsettop-bug-in-safari/
|
156 |
-
the solution is likewise noted there, grab the offset of a table cell in the row - the firstChild.
|
157 |
-
note that firefox will return a text node as a first child, so designing a more thorough
|
158 |
-
solution may need to take that into account, for now this seems to work in firefox, safari, ie */
|
159 |
-
e = e.firstChild; // a table cell
|
160 |
-
}
|
161 |
-
|
162 |
-
while (e.offsetParent){
|
163 |
-
left += e.offsetLeft;
|
164 |
-
top += e.offsetTop;
|
165 |
-
e = e.offsetParent;
|
166 |
-
}
|
167 |
-
|
168 |
-
left += e.offsetLeft;
|
169 |
-
top += e.offsetTop;
|
170 |
-
|
171 |
-
return {x:left, y:top};
|
172 |
-
},
|
173 |
-
|
174 |
-
mousemove: function(ev) {
|
175 |
-
if (jQuery.tableDnD.dragObject == null) {
|
176 |
-
return;
|
177 |
-
}
|
178 |
-
|
179 |
-
var dragObj = jQuery(jQuery.tableDnD.dragObject);
|
180 |
-
var config = jQuery.tableDnD.currentTable.tableDnDConfig;
|
181 |
-
var mousePos = jQuery.tableDnD.mouseCoords(ev);
|
182 |
-
var y = mousePos.y - jQuery.tableDnD.mouseOffset.y;
|
183 |
-
//auto scroll the window
|
184 |
-
var yOffset = window.pageYOffset;
|
185 |
-
if (document.all) {
|
186 |
-
// Windows version
|
187 |
-
//yOffset=document.body.scrollTop;
|
188 |
-
if (typeof document.compatMode != 'undefined' &&
|
189 |
-
document.compatMode != 'BackCompat') {
|
190 |
-
yOffset = document.documentElement.scrollTop;
|
191 |
-
}
|
192 |
-
else if (typeof document.body != 'undefined') {
|
193 |
-
yOffset=document.body.scrollTop;
|
194 |
-
}
|
195 |
-
|
196 |
-
}
|
197 |
-
|
198 |
-
if (mousePos.y-yOffset < config.scrollAmount) {
|
199 |
-
window.scrollBy(0, -config.scrollAmount);
|
200 |
-
} else {
|
201 |
-
var windowHeight = window.innerHeight ? window.innerHeight
|
202 |
-
: document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight;
|
203 |
-
if (windowHeight-(mousePos.y-yOffset) < config.scrollAmount) {
|
204 |
-
window.scrollBy(0, config.scrollAmount);
|
205 |
-
}
|
206 |
-
}
|
207 |
-
|
208 |
-
|
209 |
-
if (y != jQuery.tableDnD.oldY) {
|
210 |
-
// work out if we're going up or down...
|
211 |
-
var movingDown = y > jQuery.tableDnD.oldY;
|
212 |
-
// update the old value
|
213 |
-
jQuery.tableDnD.oldY = y;
|
214 |
-
// update the style to show we're dragging
|
215 |
-
if (config.onDragClass) {
|
216 |
-
dragObj.addClass(config.onDragClass);
|
217 |
-
} else {
|
218 |
-
dragObj.css(config.onDragStyle);
|
219 |
-
}
|
220 |
-
// If we're over a row then move the dragged row to there so that the user sees the
|
221 |
-
// effect dynamically
|
222 |
-
var currentRow = jQuery.tableDnD.findDropTargetRow(dragObj, y);
|
223 |
-
if (currentRow) {
|
224 |
-
// TODO worry about what happens when there are multiple TBODIES
|
225 |
-
if (movingDown && jQuery.tableDnD.dragObject != currentRow) {
|
226 |
-
jQuery.tableDnD.dragObject.parentNode.insertBefore(jQuery.tableDnD.dragObject, currentRow.nextSibling);
|
227 |
-
} else if (! movingDown && jQuery.tableDnD.dragObject != currentRow) {
|
228 |
-
jQuery.tableDnD.dragObject.parentNode.insertBefore(jQuery.tableDnD.dragObject, currentRow);
|
229 |
-
}
|
230 |
-
}
|
231 |
-
}
|
232 |
-
|
233 |
-
return false;
|
234 |
-
},
|
235 |
-
|
236 |
-
/** We're only worried about the y position really, because we can only move rows up and down */
|
237 |
-
findDropTargetRow: function(draggedRow, y) {
|
238 |
-
var rows = jQuery.tableDnD.currentTable.rows;
|
239 |
-
for (var i=0; i<rows.length; i++) {
|
240 |
-
var row = rows[i];
|
241 |
-
var rowY = this.getPosition(row).y;
|
242 |
-
var rowHeight = parseInt(row.offsetHeight)/2;
|
243 |
-
if (row.offsetHeight == 0) {
|
244 |
-
rowY = this.getPosition(row.firstChild).y;
|
245 |
-
rowHeight = parseInt(row.firstChild.offsetHeight)/2;
|
246 |
-
}
|
247 |
-
// Because we always have to insert before, we need to offset the height a bit
|
248 |
-
if ((y > rowY - rowHeight) && (y < (rowY + rowHeight))) {
|
249 |
-
// that's the row we're over
|
250 |
-
// If it's the same as the current row, ignore it
|
251 |
-
if (row == draggedRow) {return null;}
|
252 |
-
var config = jQuery.tableDnD.currentTable.tableDnDConfig;
|
253 |
-
if (config.onAllowDrop) {
|
254 |
-
if (config.onAllowDrop(draggedRow, row)) {
|
255 |
-
return row;
|
256 |
-
} else {
|
257 |
-
return null;
|
258 |
-
}
|
259 |
-
} else {
|
260 |
-
// If a row has nodrop class, then don't allow dropping (inspired by John Tarr and Famic)
|
261 |
-
var nodrop = jQuery(row).hasClass("nodrop");
|
262 |
-
if (! nodrop) {
|
263 |
-
return row;
|
264 |
-
} else {
|
265 |
-
return null;
|
266 |
-
}
|
267 |
-
}
|
268 |
-
return row;
|
269 |
-
}
|
270 |
-
}
|
271 |
-
return null;
|
272 |
-
},
|
273 |
-
|
274 |
-
mouseup: function(e) {
|
275 |
-
if (jQuery.tableDnD.currentTable && jQuery.tableDnD.dragObject) {
|
276 |
-
var droppedRow = jQuery.tableDnD.dragObject;
|
277 |
-
var config = jQuery.tableDnD.currentTable.tableDnDConfig;
|
278 |
-
// If we have a dragObject, then we need to release it,
|
279 |
-
// The row will already have been moved to the right place so we just reset stuff
|
280 |
-
if (config.onDragClass) {
|
281 |
-
jQuery(droppedRow).removeClass(config.onDragClass);
|
282 |
-
} else {
|
283 |
-
jQuery(droppedRow).css(config.onDropStyle);
|
284 |
-
}
|
285 |
-
jQuery.tableDnD.dragObject = null;
|
286 |
-
if (config.onDrop) {
|
287 |
-
// Call the onDrop method if there is one
|
288 |
-
config.onDrop(jQuery.tableDnD.currentTable, droppedRow);
|
289 |
-
}
|
290 |
-
jQuery.tableDnD.currentTable = null; // let go of the table too
|
291 |
-
}
|
292 |
-
},
|
293 |
-
|
294 |
-
serialize: function() {
|
295 |
-
if (jQuery.tableDnD.currentTable) {
|
296 |
-
var result = "";
|
297 |
-
var tableId = jQuery.tableDnD.currentTable.id;
|
298 |
-
var rows = jQuery.tableDnD.currentTable.rows;
|
299 |
-
for (var i=0; i<rows.length; i++) {
|
300 |
-
if (result.length > 0) result += "&";
|
301 |
-
result += tableId + '[]=' + rows[i].id;
|
302 |
-
}
|
303 |
-
return result;
|
304 |
-
} else {
|
305 |
-
return "Error: No Table id set, you need to set an id on your table and every row";
|
306 |
-
}
|
307 |
-
}
|
308 |
-
}
|
309 |
-
|
310 |
-
jQuery.fn.extend(
|
311 |
-
{
|
312 |
-
tableDnD : jQuery.tableDnD.build
|
313 |
-
}
|
314 |
-
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bp-core/images/Jcrop.gif
CHANGED
File without changes
|
bp-core/images/admin_menu_icon.png
CHANGED
File without changes
|
bp-core/images/mystery-man.jpg
CHANGED
File without changes
|
bp-core/js/admin-bar.js
CHANGED
@@ -1,9 +0,0 @@
|
|
1 |
-
jQuery(document).ready( function() {
|
2 |
-
jQuery("#wp-admin-bar ul.main-nav li").mouseover( function() {
|
3 |
-
jQuery(this).addClass('sfhover');
|
4 |
-
});
|
5 |
-
|
6 |
-
jQuery("#wp-admin-bar ul.main-nav li").mouseout( function() {
|
7 |
-
jQuery(this).removeClass('sfhover');
|
8 |
-
});
|
9 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bp-core/js/widget-members.js
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
jQuery(document).ready( function() {
|
2 |
-
jQuery("div#members-list-options a").
|
3 |
-
function() {
|
4 |
jQuery('#ajax-loader-members').toggle();
|
5 |
|
6 |
-
jQuery("div#members-list-options a").removeClass("selected");
|
7 |
jQuery(this).addClass('selected');
|
8 |
|
9 |
jQuery.post( ajaxurl, {
|
@@ -14,11 +14,11 @@ jQuery(document).ready( function() {
|
|
14 |
'filter': jQuery(this).attr('id')
|
15 |
},
|
16 |
function(response)
|
17 |
-
{
|
18 |
jQuery('#ajax-loader-members').toggle();
|
19 |
member_wiget_response(response);
|
20 |
});
|
21 |
-
|
22 |
return false;
|
23 |
}
|
24 |
);
|
@@ -29,19 +29,19 @@ function member_wiget_response(response) {
|
|
29 |
response = response.split('[[SPLIT]]');
|
30 |
|
31 |
if ( response[0] != "-1" ) {
|
32 |
-
jQuery("ul#members-list").fadeOut(200,
|
33 |
function() {
|
34 |
-
jQuery("ul#members-list").html(response[1]);
|
35 |
-
jQuery("ul#members-list").fadeIn(200);
|
36 |
}
|
37 |
);
|
38 |
|
39 |
-
} else {
|
40 |
-
jQuery("ul#members-list").fadeOut(200,
|
41 |
function() {
|
42 |
var message = '<p>' + response[1] + '</p>';
|
43 |
-
jQuery("ul#members-list").html(message);
|
44 |
-
jQuery("ul#members-list").fadeIn(200);
|
45 |
}
|
46 |
);
|
47 |
}
|
1 |
jQuery(document).ready( function() {
|
2 |
+
jQuery(".widget div#members-list-options a").live('click',
|
3 |
+
function() {
|
4 |
jQuery('#ajax-loader-members').toggle();
|
5 |
|
6 |
+
jQuery(".widget div#members-list-options a").removeClass("selected");
|
7 |
jQuery(this).addClass('selected');
|
8 |
|
9 |
jQuery.post( ajaxurl, {
|
14 |
'filter': jQuery(this).attr('id')
|
15 |
},
|
16 |
function(response)
|
17 |
+
{
|
18 |
jQuery('#ajax-loader-members').toggle();
|
19 |
member_wiget_response(response);
|
20 |
});
|
21 |
+
|
22 |
return false;
|
23 |
}
|
24 |
);
|
29 |
response = response.split('[[SPLIT]]');
|
30 |
|
31 |
if ( response[0] != "-1" ) {
|
32 |
+
jQuery(".widget ul#members-list").fadeOut(200,
|
33 |
function() {
|
34 |
+
jQuery(".widget ul#members-list").html(response[1]);
|
35 |
+
jQuery(".widget ul#members-list").fadeIn(200);
|
36 |
}
|
37 |
);
|
38 |
|
39 |
+
} else {
|
40 |
+
jQuery(".widget ul#members-list").fadeOut(200,
|
41 |
function() {
|
42 |
var message = '<p>' + response[1] + '</p>';
|
43 |
+
jQuery(".widget ul#members-list").html(message);
|
44 |
+
jQuery(".widget ul#members-list").fadeIn(200);
|
45 |
}
|
46 |
);
|
47 |
}
|
bp-forums.php
CHANGED
@@ -20,7 +20,7 @@ function bp_forums_setup() {
|
|
20 |
$bp->forums->id = 'forums';
|
21 |
|
22 |
$bp->forums->image_base = BP_PLUGIN_URL . '/bp-forums/images';
|
23 |
-
$bp->forums->bbconfig =
|
24 |
$bp->forums->slug = BP_FORUMS_SLUG;
|
25 |
|
26 |
/* Register this in the active components array */
|
@@ -28,8 +28,7 @@ function bp_forums_setup() {
|
|
28 |
|
29 |
do_action( 'bp_forums_setup' );
|
30 |
}
|
31 |
-
add_action( '
|
32 |
-
add_action( 'admin_head', 'bp_forums_setup', 2 );
|
33 |
|
34 |
function bp_forums_is_installed_correctly() {
|
35 |
global $bp;
|
@@ -44,13 +43,13 @@ function bp_forums_setup_root_component() {
|
|
44 |
/* Register 'forums' as a root component */
|
45 |
bp_core_add_root_component( BP_FORUMS_SLUG );
|
46 |
}
|
47 |
-
add_action( '
|
48 |
|
49 |
function bp_forums_directory_forums_setup() {
|
50 |
global $bp;
|
51 |
|
52 |
if ( $bp->current_component == $bp->forums->slug ) {
|
53 |
-
if ( (int)
|
54 |
return false;
|
55 |
|
56 |
if ( !bp_forums_is_installed_correctly() ) {
|
@@ -61,8 +60,31 @@ function bp_forums_directory_forums_setup() {
|
|
61 |
$bp->is_directory = true;
|
62 |
|
63 |
do_action( 'bbpress_init' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
do_action( 'bp_forums_directory_forums_setup' );
|
65 |
-
|
|
|
66 |
}
|
67 |
}
|
68 |
add_action( 'wp', 'bp_forums_directory_forums_setup', 2 );
|
@@ -104,15 +126,6 @@ function bp_forums_new_forum( $args = '' ) {
|
|
104 |
return bb_new_forum( array( 'forum_name' => stripslashes( $forum_name ), 'forum_desc' => stripslashes( $forum_desc ), 'forum_parent' => $forum_parent_id, 'forum_order' => $forum_order, 'forum_is_category' => $forum_is_category ) );
|
105 |
}
|
106 |
|
107 |
-
function bp_forums_get_forum_topicpost_count( $forum_id ) {
|
108 |
-
global $wpdb, $bbdb;
|
109 |
-
|
110 |
-
do_action( 'bbpress_init' );
|
111 |
-
|
112 |
-
/* Need to find a bbPress function that does this */
|
113 |
-
return $wpdb->get_results( $wpdb->prepare( "SELECT topics, posts from {$bbdb->forums} WHERE forum_id = %d", $forum_id ) );
|
114 |
-
}
|
115 |
-
|
116 |
/* Topic Functions */
|
117 |
|
118 |
function bp_forums_get_forum_topics( $args = '' ) {
|
@@ -123,6 +136,7 @@ function bp_forums_get_forum_topics( $args = '' ) {
|
|
123 |
$defaults = array(
|
124 |
'type' => 'newest',
|
125 |
'forum_id' => false,
|
|
|
126 |
'page' => 1,
|
127 |
'per_page' => 15,
|
128 |
'exclude' => false,
|
@@ -135,27 +149,22 @@ function bp_forums_get_forum_topics( $args = '' ) {
|
|
135 |
|
136 |
switch ( $type ) {
|
137 |
case 'newest':
|
138 |
-
$query = new BB_Query( 'topic', array( 'forum_id' => $forum_id, 'per_page' => $per_page, 'page' => $page, 'number' => $per_page, 'exclude' => $exclude, 'topic_title' => $filter, 'sticky' => $show_stickies ), 'get_latest_topics' );
|
139 |
-
$topics
|
140 |
break;
|
141 |
|
142 |
case 'popular':
|
143 |
-
$query = new BB_Query( 'topic', array( 'forum_id' => $forum_id, 'per_page' => $per_page, 'page' => $page, 'order_by' => 't.topic_posts', 'topic_title' => $filter, 'sticky' => $show_stickies ) );
|
144 |
$topics =& $query->results;
|
145 |
break;
|
146 |
|
147 |
case 'unreplied':
|
148 |
-
$query = new BB_Query( 'topic', array( 'forum_id' => $forum_id, 'post_count' => 1, 'per_page' => $per_page, 'page' => $page, 'order_by' => 't.topic_time', 'topic_title' => $filter, 'sticky' => $show_stickies ) );
|
149 |
-
$topics =& $query->results;
|
150 |
-
break;
|
151 |
-
|
152 |
-
case 'personal':
|
153 |
-
$query = new BB_Query( 'topic', array( 'forum_id' => $forum_id, 'per_page' => $per_page, 'page' => $page, 'topic_author_id' => $bp->loggedin_user->id, 'order_by' => 't.topic_time', 'topic_title' => $filter, 'sticky' => $show_stickies ), 'get_recent_user_threads' );
|
154 |
$topics =& $query->results;
|
155 |
break;
|
156 |
|
157 |
-
case '
|
158 |
-
$query = new BB_Query( 'topic', array( 'forum_id' => $forum_id, 'tag' => $filter, 'per_page' => $per_page, 'page' => $page, 'order_by' => 't.topic_time', 'sticky' => $show_stickies ) );
|
159 |
$topics =& $query->results;
|
160 |
break;
|
161 |
}
|
@@ -184,6 +193,7 @@ function bp_forums_new_topic( $args = '' ) {
|
|
184 |
$defaults = array(
|
185 |
'topic_title' => '',
|
186 |
'topic_slug' => '',
|
|
|
187 |
'topic_poster' => $bp->loggedin_user->id, // accepts ids
|
188 |
'topic_poster_name' => $bp->loggedin_user->fullname, // accept names
|
189 |
'topic_last_poster' => $bp->loggedin_user->id, // accepts ids
|
@@ -198,6 +208,11 @@ function bp_forums_new_topic( $args = '' ) {
|
|
198 |
$r = wp_parse_args( $args, $defaults );
|
199 |
extract( $r, EXTR_SKIP );
|
200 |
|
|
|
|
|
|
|
|
|
|
|
201 |
if ( empty( $topic_slug ) )
|
202 |
$topic_slug = sanitize_title( $topic_title );
|
203 |
|
@@ -208,6 +223,8 @@ function bp_forums_new_topic( $args = '' ) {
|
|
208 |
if ( !bp_forums_insert_post( array( 'topic_id' => $topic_id, 'post_text' => $topic_text, 'post_time' => $topic_time, 'poster_id' => $topic_poster ) ) )
|
209 |
return false;
|
210 |
|
|
|
|
|
211 |
return $topic_id;
|
212 |
}
|
213 |
|
@@ -232,7 +249,7 @@ function bp_forums_update_topic( $args = '' ) {
|
|
232 |
return false;
|
233 |
|
234 |
/* Update the first post */
|
235 |
-
if ( !$post =
|
236 |
return false;
|
237 |
|
238 |
return bp_forums_get_topic_details( $topic_id );
|
@@ -295,6 +312,68 @@ function bp_forums_delete_topic( $args = '' ) {
|
|
295 |
return bb_delete_topic( $topic_id, 1 );
|
296 |
}
|
297 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
298 |
/* Post Functions */
|
299 |
|
300 |
function bp_forums_get_topic_posts( $args = '' ) {
|
@@ -310,7 +389,7 @@ function bp_forums_get_topic_posts( $args = '' ) {
|
|
310 |
$args = wp_parse_args( $args, $defaults );
|
311 |
|
312 |
$query = new BB_Query( 'post', $args, 'get_thread' );
|
313 |
-
return $query->results;
|
314 |
}
|
315 |
|
316 |
function bp_forums_get_post( $post_id ) {
|
@@ -367,13 +446,62 @@ function bp_forums_insert_post( $args = '' ) {
|
|
367 |
if ( !isset( $post_position ) )
|
368 |
$post_position = $post->post_position;
|
369 |
|
370 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
371 |
}
|
372 |
|
373 |
-
// List actions to clear super cached pages on, if super cache is installed
|
374 |
-
add_action( 'bp_forums_new_forum', 'bp_core_clear_cache' );
|
375 |
-
add_action( 'bp_forums_new_topic', 'bp_core_clear_cache' );
|
376 |
-
add_action( 'bp_forums_new_post', 'bp_core_clear_cache' );
|
377 |
|
378 |
function bp_forums_filter_caps( $allcaps ) {
|
379 |
global $bp, $wp_roles, $bb_table_prefix;
|
@@ -390,4 +518,18 @@ function bp_forums_filter_caps( $allcaps ) {
|
|
390 |
return array_merge( (array) $allcaps, (array) $bb_cap );
|
391 |
}
|
392 |
add_filter( 'user_has_cap', 'bp_forums_filter_caps' );
|
393 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
$bp->forums->id = 'forums';
|
21 |
|
22 |
$bp->forums->image_base = BP_PLUGIN_URL . '/bp-forums/images';
|
23 |
+
$bp->forums->bbconfig = $bp->site_options['bb-config-location'];
|
24 |
$bp->forums->slug = BP_FORUMS_SLUG;
|
25 |
|
26 |
/* Register this in the active components array */
|
28 |
|
29 |
do_action( 'bp_forums_setup' );
|
30 |
}
|
31 |
+
add_action( 'bp_setup_globals', 'bp_forums_setup' );
|
|
|
32 |
|
33 |
function bp_forums_is_installed_correctly() {
|
34 |
global $bp;
|
43 |
/* Register 'forums' as a root component */
|
44 |
bp_core_add_root_component( BP_FORUMS_SLUG );
|
45 |
}
|
46 |
+
add_action( 'bp_setup_root_components', 'bp_forums_setup_root_component' );
|
47 |
|
48 |
function bp_forums_directory_forums_setup() {
|
49 |
global $bp;
|
50 |
|
51 |
if ( $bp->current_component == $bp->forums->slug ) {
|
52 |
+
if ( (int) $bp->site_options['bp-disable-forum-directory'] || !function_exists( 'groups_install' ) )
|
53 |
return false;
|
54 |
|
55 |
if ( !bp_forums_is_installed_correctly() ) {
|
60 |
$bp->is_directory = true;
|
61 |
|
62 |
do_action( 'bbpress_init' );
|
63 |
+
|
64 |
+
/* Check to see if the user has posted a new topic from the forums page. */
|
65 |
+
if ( isset( $_POST['submit_topic'] ) && function_exists( 'bp_forums_new_topic' ) ) {
|
66 |
+
/* Check the nonce */
|
67 |
+
check_admin_referer( 'bp_forums_new_topic' );
|
68 |
+
|
69 |
+
if ( $bp->groups->current_group = groups_get_group( array( 'group_id' => $_POST['topic_group_id'] ) ) ) {
|
70 |
+
/* Auto join this user if they are not yet a member of this group */
|
71 |
+
if ( !is_site_admin() && 'public' == $bp->groups->current_group->status && !groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) )
|
72 |
+
groups_join_group( $bp->groups->current_group->id, $bp->groups->current_group->id );
|
73 |
+
|
74 |
+
if ( $forum_id = groups_get_groupmeta( $bp->groups->current_group->id, 'forum_id' ) ) {
|
75 |
+
if ( !$topic = groups_new_group_forum_topic( $_POST['topic_title'], $_POST['topic_text'], $_POST['topic_tags'], $forum_id ) )
|
76 |
+
bp_core_add_message( __( 'There was an error when creating the topic', 'buddypress'), 'error' );
|
77 |
+
else
|
78 |
+
bp_core_add_message( __( 'The topic was created successfully', 'buddypress') );
|
79 |
+
|
80 |
+
bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/forum/topic/' . $topic->topic_slug . '/' );
|
81 |
+
}
|
82 |
+
}
|
83 |
+
}
|
84 |
+
|
85 |
do_action( 'bp_forums_directory_forums_setup' );
|
86 |
+
|
87 |
+
bp_core_load_template( apply_filters( 'bp_forums_template_directory_forums_setup', 'forums/index' ) );
|
88 |
}
|
89 |
}
|
90 |
add_action( 'wp', 'bp_forums_directory_forums_setup', 2 );
|
126 |
return bb_new_forum( array( 'forum_name' => stripslashes( $forum_name ), 'forum_desc' => stripslashes( $forum_desc ), 'forum_parent' => $forum_parent_id, 'forum_order' => $forum_order, 'forum_is_category' => $forum_is_category ) );
|
127 |
}
|
128 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
129 |
/* Topic Functions */
|
130 |
|
131 |
function bp_forums_get_forum_topics( $args = '' ) {
|
136 |
$defaults = array(
|
137 |
'type' => 'newest',
|
138 |
'forum_id' => false,
|
139 |
+
'user_id' => false,
|
140 |
'page' => 1,
|
141 |
'per_page' => 15,
|
142 |
'exclude' => false,
|
149 |
|
150 |
switch ( $type ) {
|
151 |
case 'newest':
|
152 |
+
$query = new BB_Query( 'topic', array( 'forum_id' => $forum_id, 'topic_author_id' => $user_id, 'per_page' => $per_page, 'page' => $page, 'number' => $per_page, 'exclude' => $exclude, 'topic_title' => $filter, 'sticky' => $show_stickies ), 'get_latest_topics' );
|
153 |
+
$topics =& $query->results;
|
154 |
break;
|
155 |
|
156 |
case 'popular':
|
157 |
+
$query = new BB_Query( 'topic', array( 'forum_id' => $forum_id, 'topic_author_id' => $user_id, 'per_page' => $per_page, 'page' => $page, 'order_by' => 't.topic_posts', 'topic_title' => $filter, 'sticky' => $show_stickies ) );
|
158 |
$topics =& $query->results;
|
159 |
break;
|
160 |
|
161 |
case 'unreplied':
|
162 |
+
$query = new BB_Query( 'topic', array( 'forum_id' => $forum_id, 'topic_author_id' => $user_id, 'post_count' => 1, 'per_page' => $per_page, 'page' => $page, 'order_by' => 't.topic_time', 'topic_title' => $filter, 'sticky' => $show_stickies ) );
|
|
|
|
|
|
|
|
|
|
|
163 |
$topics =& $query->results;
|
164 |
break;
|
165 |
|
166 |
+
case 'tags':
|
167 |
+
$query = new BB_Query( 'topic', array( 'forum_id' => $forum_id, 'topic_author_id' => $user_id, 'tag' => $filter, 'per_page' => $per_page, 'page' => $page, 'order_by' => 't.topic_time', 'sticky' => $show_stickies ) );
|
168 |
$topics =& $query->results;
|
169 |
break;
|
170 |
}
|
193 |
$defaults = array(
|
194 |
'topic_title' => '',
|
195 |
'topic_slug' => '',
|
196 |
+
'topic_text' => '',
|
197 |
'topic_poster' => $bp->loggedin_user->id, // accepts ids
|
198 |
'topic_poster_name' => $bp->loggedin_user->fullname, // accept names
|
199 |
'topic_last_poster' => $bp->loggedin_user->id, // accepts ids
|
208 |
$r = wp_parse_args( $args, $defaults );
|
209 |
extract( $r, EXTR_SKIP );
|
210 |
|
211 |
+
$topic_title = strip_tags( $topic_title );
|
212 |
+
|
213 |
+
if ( empty( $topic_title ) || !strlen( trim( $topic_title ) ) )
|
214 |
+
return false;
|
215 |
+
|
216 |
if ( empty( $topic_slug ) )
|
217 |
$topic_slug = sanitize_title( $topic_title );
|
218 |
|
223 |
if ( !bp_forums_insert_post( array( 'topic_id' => $topic_id, 'post_text' => $topic_text, 'post_time' => $topic_time, 'poster_id' => $topic_poster ) ) )
|
224 |
return false;
|
225 |
|
226 |
+
do_action( 'bp_forums_new_topic', $topic_id );
|
227 |
+
|
228 |
return $topic_id;
|
229 |
}
|
230 |
|
249 |
return false;
|
250 |
|
251 |
/* Update the first post */
|
252 |
+
if ( !$post = bp_forums_insert_post( array( 'post_id' => $post->post_id, 'topic_id' => $topic_id, 'post_text' => $topic_text, 'post_time' => $post->post_time, 'poster_id' => $post->poster_id, 'poster_ip' => $post->poster_ip, 'post_status' => $post->post_status, 'post_position' => $post->post_position ) ) )
|
253 |
return false;
|
254 |
|
255 |
return bp_forums_get_topic_details( $topic_id );
|
312 |
return bb_delete_topic( $topic_id, 1 );
|
313 |
}
|
314 |
|
315 |
+
function bp_forums_total_topic_count() {
|
316 |
+
do_action( 'bbpress_init' );
|
317 |
+
|
318 |
+
$query = new BB_Query( 'topic', array( 'page' => 1, 'per_page' => -1, 'count' => true ) );
|
319 |
+
$count = $query->count;
|
320 |
+
$query = null;
|
321 |
+
|
322 |
+
return $count;
|
323 |
+
}
|
324 |
+
|
325 |
+
function bp_forums_total_topic_count_for_user( $user_id = false ) {
|
326 |
+
global $bp;
|
327 |
+
|
328 |
+
do_action( 'bbpress_init' );
|
329 |
+
|
330 |
+
if ( !$user_id )
|
331 |
+
$user_id = ( $bp->displayed_user->id ) ? $bp->displayed_user->id : $bp->loggedin_user->id;
|
332 |
+
|
333 |
+
$query = new BB_Query( 'topic', array( 'topic_author_id' => $user_id, 'page' => 1, 'per_page' => -1, 'count' => true ) );
|
334 |
+
$count = $query->count;
|
335 |
+
$query = null;
|
336 |
+
|
337 |
+
return $count;
|
338 |
+
}
|
339 |
+
|
340 |
+
function bp_forums_get_topic_extras( $topics ) {
|
341 |
+
global $bp, $wpdb, $bbdb;
|
342 |
+
|
343 |
+
if ( empty( $topics ) )
|
344 |
+
return $topics;
|
345 |
+
|
346 |
+
/* Get the topic ids */
|
347 |
+
foreach ( (array)$topics as $topic ) $topic_ids[] = $topic->topic_id;
|
348 |
+
$topic_ids = $wpdb->escape( join( ',', (array)$topic_ids ) );
|
349 |
+
|
350 |
+
/* Fetch the topic's last poster details */
|
351 |
+
$poster_details = $wpdb->get_results( $wpdb->prepare( "SELECT t.topic_id, t.topic_last_poster, u.user_login, u.user_nicename, u.user_email, u.display_name FROM {$wpdb->users} u, {$bbdb->topics} t WHERE u.ID = t.topic_last_poster AND t.topic_id IN ( {$topic_ids} )" ) );
|
352 |
+
for ( $i = 0; $i < count( $topics ); $i++ ) {
|
353 |
+
foreach ( (array)$poster_details as $poster ) {
|
354 |
+
if ( $poster->topic_id == $topics[$i]->topic_id ) {
|
355 |
+
$topics[$i]->topic_last_poster_email = $poster->user_email;
|
356 |
+
$topics[$i]->topic_last_poster_nicename = $poster->user_nicename;
|
357 |
+
$topics[$i]->topic_last_poster_login = $poster->user_login;
|
358 |
+
$topics[$i]->topic_last_poster_displayname = $poster->display_name;
|
359 |
+
}
|
360 |
+
}
|
361 |
+
}
|
362 |
+
|
363 |
+
/* Fetch fullname for the topic's last poster */
|
364 |
+
if ( function_exists( 'xprofile_install' ) ) {
|
365 |
+
$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} )" ) );
|
366 |
+
for ( $i = 0; $i < count( $topics ); $i++ ) {
|
367 |
+
foreach ( (array)$poster_names as $name ) {
|
368 |
+
if ( $name->topic_id == $topics[$i]->topic_id )
|
369 |
+
$topics[$i]->topic_last_poster_displayname = $name->value;
|
370 |
+
}
|
371 |
+
}
|
372 |
+
}
|
373 |
+
|
374 |
+
return $topics;
|
375 |
+
}
|
376 |
+
|
377 |
/* Post Functions */
|
378 |
|
379 |
function bp_forums_get_topic_posts( $args = '' ) {
|
389 |
$args = wp_parse_args( $args, $defaults );
|
390 |
|
391 |
$query = new BB_Query( 'post', $args, 'get_thread' );
|
392 |
+
return bp_forums_get_post_extras( $query->results );
|
393 |
}
|
394 |
|
395 |
function bp_forums_get_post( $post_id ) {
|
446 |
if ( !isset( $post_position ) )
|
447 |
$post_position = $post->post_position;
|
448 |
|
449 |
+
$post = bb_insert_post( array( 'post_id' => $post_id, 'topic_id' => $topic_id, 'post_text' => stripslashes( trim( $post_text ) ), 'post_time' => $post_time, 'poster_id' => $poster_id, 'poster_ip' => $poster_ip, 'post_status' => $post_status, 'post_position' => $post_position ) );
|
450 |
+
|
451 |
+
if ( $post )
|
452 |
+
do_action( 'bp_forums_new_post', $post_id );
|
453 |
+
|
454 |
+
return $post;
|
455 |
+
}
|
456 |
+
|
457 |
+
function bp_forums_get_post_extras( $posts ) {
|
458 |
+
global $bp, $wpdb;
|
459 |
+
|
460 |
+
if ( empty( $posts ) )
|
461 |
+
return $posts;
|
462 |
+
|
463 |
+
/* Get the user ids */
|
464 |
+
foreach ( (array)$posts as $post ) $user_ids[] = $post->poster_id;
|
465 |
+
$user_ids = $wpdb->escape( join( ',', (array)$user_ids ) );
|
466 |
+
|
467 |
+
/* Fetch the poster's user_email, user_nicename and user_login */
|
468 |
+
$poster_details = $wpdb->get_results( $wpdb->prepare( "SELECT u.ID as user_id, u.user_login, u.user_nicename, u.user_email, u.display_name FROM {$wpdb->users} u WHERE u.ID IN ( {$user_ids} )" ) );
|
469 |
+
|
470 |
+
for ( $i = 0; $i < count( $posts ); $i++ ) {
|
471 |
+
foreach ( (array)$poster_details as $poster ) {
|
472 |
+
if ( $poster->user_id == $posts[$i]->poster_id ) {
|
473 |
+
$posts[$i]->poster_email = $poster->user_email;
|
474 |
+
$posts[$i]->poster_login = $poster->user_nicename;
|
475 |
+
$posts[$i]->poster_nicename = $poster->user_login;
|
476 |
+
$posts[$i]->poster_name = $poster->display_name;
|
477 |
+
}
|
478 |
+
}
|
479 |
+
}
|
480 |
+
|
481 |
+
/* Fetch fullname for each poster. */
|
482 |
+
if ( function_exists( 'xprofile_install' ) ) {
|
483 |
+
$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} )" ) );
|
484 |
+
for ( $i = 0; $i < count( $posts ); $i++ ) {
|
485 |
+
foreach ( (array)$poster_names as $name ) {
|
486 |
+
if ( $name->user_id == $topics[$i]->user_id )
|
487 |
+
$posts[$i]->poster_name = $poster->value;
|
488 |
+
}
|
489 |
+
}
|
490 |
+
}
|
491 |
+
|
492 |
+
return $posts;
|
493 |
+
}
|
494 |
+
|
495 |
+
|
496 |
+
function bp_forums_get_forum_topicpost_count( $forum_id ) {
|
497 |
+
global $wpdb, $bbdb;
|
498 |
+
|
499 |
+
do_action( 'bbpress_init' );
|
500 |
+
|
501 |
+
/* Need to find a bbPress function that does this */
|
502 |
+
return $wpdb->get_results( $wpdb->prepare( "SELECT topics, posts from {$bbdb->forums} WHERE forum_id = %d", $forum_id ) );
|
503 |
}
|
504 |
|
|
|
|
|
|
|
|
|
505 |
|
506 |
function bp_forums_filter_caps( $allcaps ) {
|
507 |
global $bp, $wp_roles, $bb_table_prefix;
|
518 |
return array_merge( (array) $allcaps, (array) $bb_cap );
|
519 |
}
|
520 |
add_filter( 'user_has_cap', 'bp_forums_filter_caps' );
|
521 |
+
|
522 |
+
|
523 |
+
/********************************************************************************
|
524 |
+
* Caching
|
525 |
+
*
|
526 |
+
* Caching functions handle the clearing of cached objects and pages on specific
|
527 |
+
* actions throughout BuddyPress.
|
528 |
+
*/
|
529 |
+
|
530 |
+
// List actions to clear super cached pages on, if super cache is installed
|
531 |
+
add_action( 'bp_forums_new_forum', 'bp_core_clear_cache' );
|
532 |
+
add_action( 'bp_forums_new_topic', 'bp_core_clear_cache' );
|
533 |
+
add_action( 'bp_forums_new_post', 'bp_core_clear_cache' );
|
534 |
+
|
535 |
+
?>
|
bp-forums/bb-config.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* This file will stop people from accessing your bbPress installation directly.
|
5 |
* It is very important from a security standpoint that this file is not moved.
|
6 |
* Your actual bb-config.php file will be installed in the root of your WordPress
|
7 |
-
* installation once you set up the forums component in BuddyPress.
|
8 |
*/
|
9 |
|
10 |
header("HTTP/1.0 403 Forbidden"); die;
|
4 |
* This file will stop people from accessing your bbPress installation directly.
|
5 |
* It is very important from a security standpoint that this file is not moved.
|
6 |
* Your actual bb-config.php file will be installed in the root of your WordPress
|
7 |
+
* installation once you have set up the forums component in BuddyPress.
|
8 |
*/
|
9 |
|
10 |
header("HTTP/1.0 403 Forbidden"); die;
|
bp-forums/bp-forums-admin.php
CHANGED
@@ -136,10 +136,10 @@ function bp_forums_bbpress_install() {
|
|
136 |
"define( 'BBDB_HOST'," => array( "'localhost'", "'" . DB_HOST . "'" ),
|
137 |
"define( 'BBDB_CHARSE" => array( "'utf8'", "'" . DB_CHARSET . "'" ),
|
138 |
"define( 'BBDB_COLLAT" => array( "''", "'" . DB_COLLATE . "'" ),
|
139 |
-
"define( 'BB_AUTH_KEY" => array( "'put your unique phrase here'", "'" . AUTH_KEY . "'" ),
|
140 |
-
"define( 'BB_SECURE_A" => array( "'put your unique phrase here'", "'" . SECURE_AUTH_KEY . "'" ),
|
141 |
-
"define( 'BB_LOGGED_I" => array( "'put your unique phrase here'", "'" . LOGGED_IN_KEY . "'" ),
|
142 |
-
"define( 'BB_NONCE_KE" => array( "'put your unique phrase here'", "'" . NONCE_KEY . "'" ),
|
143 |
"\$bb_table_prefix = '" => array( "'bb_'", "'" . $wpdb->base_prefix . "bb_'" ),
|
144 |
"define( 'BB_LANG', '" => array( "''", "'" . WPLANG . "'" )
|
145 |
)
|
@@ -157,10 +157,19 @@ function bp_forums_bbpress_install() {
|
|
157 |
$file .= "\n" . '$bb->custom_user_meta_table = "' . $wpdb->usermeta . '";';
|
158 |
$file .= "\n\n" . '$bb->uri = "' . BP_PLUGIN_URL . '/bp-forums/bbpress/";';
|
159 |
$file .= "\n" . '$bb->name = "' . get_blog_option( BP_ROOT_BLOG, 'name' ) . ' ' . __( 'Forums', 'buddypress' ) . '";';
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
164 |
$file .= "\n\n" . 'define(\'WP_AUTH_COOKIE_VERSION\', 2);';
|
165 |
$file .= "\n\n" . '?>';
|
166 |
|
@@ -196,7 +205,7 @@ function bp_forums_bbpress_write( $file_source, $file_target, $alterations ) {
|
|
196 |
$modified_lines = array();
|
197 |
|
198 |
// Loop through the lines and modify them
|
199 |
-
foreach ( $lines as $line ) {
|
200 |
if ( isset( $alterations[substr( $line, 0, 20 )] ) ) {
|
201 |
$alteration = $alterations[substr( $line, 0, 20 )];
|
202 |
$modified_lines[] = str_replace( $alteration[0], $alteration[1], $line );
|
@@ -229,7 +238,7 @@ function bp_forums_bbpress_write( $file_source, $file_target, $alterations ) {
|
|
229 |
$file_handle = fopen( $file_target, 'w' );
|
230 |
|
231 |
// Write lines one by one to avoid OS specific newline hassles
|
232 |
-
foreach ( $modified_lines as $modified_line ) {
|
233 |
if ( false !== strpos( $modified_line, '?>' ) ) {
|
234 |
$modified_line = '?>';
|
235 |
}
|
136 |
"define( 'BBDB_HOST'," => array( "'localhost'", "'" . DB_HOST . "'" ),
|
137 |
"define( 'BBDB_CHARSE" => array( "'utf8'", "'" . DB_CHARSET . "'" ),
|
138 |
"define( 'BBDB_COLLAT" => array( "''", "'" . DB_COLLATE . "'" ),
|
139 |
+
"define( 'BB_AUTH_KEY" => array( "'put your unique phrase here'", "'" . addslashes( AUTH_KEY ) . "'" ),
|
140 |
+
"define( 'BB_SECURE_A" => array( "'put your unique phrase here'", "'" . addslashes( SECURE_AUTH_KEY ) . "'" ),
|
141 |
+
"define( 'BB_LOGGED_I" => array( "'put your unique phrase here'", "'" . addslashes( LOGGED_IN_KEY ) . "'" ),
|
142 |
+
"define( 'BB_NONCE_KE" => array( "'put your unique phrase here'", "'" . addslashes( NONCE_KEY ) . "'" ),
|
143 |
"\$bb_table_prefix = '" => array( "'bb_'", "'" . $wpdb->base_prefix . "bb_'" ),
|
144 |
"define( 'BB_LANG', '" => array( "''", "'" . WPLANG . "'" )
|
145 |
)
|
157 |
$file .= "\n" . '$bb->custom_user_meta_table = "' . $wpdb->usermeta . '";';
|
158 |
$file .= "\n\n" . '$bb->uri = "' . BP_PLUGIN_URL . '/bp-forums/bbpress/";';
|
159 |
$file .= "\n" . '$bb->name = "' . get_blog_option( BP_ROOT_BLOG, 'name' ) . ' ' . __( 'Forums', 'buddypress' ) . '";';
|
160 |
+
|
161 |
+
if ( bp_core_is_multisite() )
|
162 |
+
$file .= "\n" . '$bb->wordpress_mu_primary_blog_id = ' . BP_ROOT_BLOG . ';';
|
163 |
+
|
164 |
+
if ( defined( 'AUTH_SALT' ) )
|
165 |
+
$file .= "\n\n" . 'define(\'BB_AUTH_SALT\', "' . addslashes( AUTH_SALT ) . '");';
|
166 |
+
|
167 |
+
if ( defined( 'LOGGED_IN_SALT' ) )
|
168 |
+
$file .= "\n" . 'define(\'BB_LOGGED_IN_SALT\', "' . addslashes( LOGGED_IN_SALT ) . '");';
|
169 |
+
|
170 |
+
if ( defined( 'SECURE_AUTH_SALT' ) )
|
171 |
+
$file .= "\n" . 'define(\'BB_SECURE_AUTH_SALT\', "' . addslashes( SECURE_AUTH_SALT ) . '");';
|
172 |
+
|
173 |
$file .= "\n\n" . 'define(\'WP_AUTH_COOKIE_VERSION\', 2);';
|
174 |
$file .= "\n\n" . '?>';
|
175 |
|
205 |
$modified_lines = array();
|
206 |
|
207 |
// Loop through the lines and modify them
|
208 |
+
foreach ( (array)$lines as $line ) {
|
209 |
if ( isset( $alterations[substr( $line, 0, 20 )] ) ) {
|
210 |
$alteration = $alterations[substr( $line, 0, 20 )];
|
211 |
$modified_lines[] = str_replace( $alteration[0], $alteration[1], $line );
|
238 |
$file_handle = fopen( $file_target, 'w' );
|
239 |
|
240 |
// Write lines one by one to avoid OS specific newline hassles
|
241 |
+
foreach ( (array)$modified_lines as $modified_line ) {
|
242 |
if ( false !== strpos( $modified_line, '?>' ) ) {
|
243 |
$modified_line = '?>';
|
244 |
}
|
bp-forums/bp-forums-bbpress.php
CHANGED
@@ -94,7 +94,8 @@ function bp_forums_load_bbpress() {
|
|
94 |
if ( !$tables_installed ) {
|
95 |
require_once( BB_PATH . 'bb-admin/includes/defaults.bb-schema.php' );
|
96 |
|
97 |
-
dbDelta
|
|
|
98 |
|
99 |
require_once( BB_PATH . 'bb-admin/includes/functions.bb-upgrade.php' );
|
100 |
bb_update_db_version();
|
94 |
if ( !$tables_installed ) {
|
95 |
require_once( BB_PATH . 'bb-admin/includes/defaults.bb-schema.php' );
|
96 |
|
97 |
+
/* Backticks and "IF NOT EXISTS" break the dbDelta function. */
|
98 |
+
dbDelta( str_replace( ' IF NOT EXISTS', '', str_replace( '`', '', $bb_queries ) ) );
|
99 |
|
100 |
require_once( BB_PATH . 'bb-admin/includes/functions.bb-upgrade.php' );
|
101 |
bb_update_db_version();
|
bp-forums/bp-forums-filters.php
CHANGED
@@ -5,11 +5,8 @@ add_filter( 'bp_forums_bbconfig_location', 'wp_filter_kses', 1 );
|
|
5 |
add_filter( 'bp_forums_bbconfig_location', 'attribute_escape', 1 );
|
6 |
|
7 |
add_filter( 'bp_get_the_topic_title', 'wp_filter_kses', 1 );
|
8 |
-
add_filter( 'bp_get_the_topic_latest_post_excerpt', '
|
9 |
-
add_filter( 'bp_get_the_topic_post_content', '
|
10 |
-
|
11 |
-
add_filter( 'bp_get_the_topic_title', 'attribute_escape' );
|
12 |
-
add_filter( 'bp_get_the_topic_post_content', 'attribute_escape' );
|
13 |
|
14 |
add_filter( 'bp_get_the_topic_title', 'wptexturize' );
|
15 |
add_filter( 'bp_get_the_topic_poster_name', 'wptexturize' );
|
@@ -34,13 +31,36 @@ add_filter( 'bp_get_the_topic_latest_post_excerpt', 'stripslashes_deep' );
|
|
34 |
|
35 |
add_filter( 'bp_get_the_topic_post_content', 'make_clickable' );
|
36 |
|
37 |
-
|
38 |
-
|
39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
|
41 |
-
|
|
|
42 |
}
|
43 |
-
add_filter( 'edit_allowedtags', 'bp_forums_add_allowed_tags' );
|
44 |
|
45 |
function bp_forums_filter_tag_link( $link, $tag, $page, $context ) {
|
46 |
global $bp;
|
5 |
add_filter( 'bp_forums_bbconfig_location', 'attribute_escape', 1 );
|
6 |
|
7 |
add_filter( 'bp_get_the_topic_title', 'wp_filter_kses', 1 );
|
8 |
+
add_filter( 'bp_get_the_topic_latest_post_excerpt', 'bp_forums_filter_kses', 1 );
|
9 |
+
add_filter( 'bp_get_the_topic_post_content', 'bp_forums_filter_kses', 1 );
|
|
|
|
|
|
|
10 |
|
11 |
add_filter( 'bp_get_the_topic_title', 'wptexturize' );
|
12 |
add_filter( 'bp_get_the_topic_poster_name', 'wptexturize' );
|
31 |
|
32 |
add_filter( 'bp_get_the_topic_post_content', 'make_clickable' );
|
33 |
|
34 |
+
add_filter( 'bp_get_forum_topic_count_for_user', 'bp_core_number_format' );
|
35 |
+
add_filter( 'bp_get_forum_topic_count', 'bp_core_number_format' );
|
36 |
+
|
37 |
+
|
38 |
+
function bp_forums_filter_kses( $content ) {
|
39 |
+
global $allowedtags;
|
40 |
+
|
41 |
+
$forums_allowedtags = $allowedtags;
|
42 |
+
$forums_allowedtags['span'] = array();
|
43 |
+
$forums_allowedtags['span']['class'] = array();
|
44 |
+
$forums_allowedtags['div'] = array();
|
45 |
+
$forums_allowedtags['div']['class'] = array();
|
46 |
+
$forums_allowedtags['div']['id'] = array();
|
47 |
+
$forums_allowedtags['a']['class'] = array();
|
48 |
+
$forums_allowedtags['img'] = array();
|
49 |
+
$forums_allowedtags['br'] = array();
|
50 |
+
$forums_allowedtags['p'] = array();
|
51 |
+
$forums_allowedtags['img']['src'] = array();
|
52 |
+
$forums_allowedtags['img']['alt'] = array();
|
53 |
+
$forums_allowedtags['img']['class'] = array();
|
54 |
+
$forums_allowedtags['img']['width'] = array();
|
55 |
+
$forums_allowedtags['img']['height'] = array();
|
56 |
+
$forums_allowedtags['img']['class'] = array();
|
57 |
+
$forums_allowedtags['img']['id'] = array();
|
58 |
+
$forums_allowedtags['code'] = array();
|
59 |
+
$forums_allowedtags['blockquote'] = array();
|
60 |
|
61 |
+
$forums_allowedtags = apply_filters( 'bp_forums_allowed_tags', $forums_allowedtags );
|
62 |
+
return wp_kses( $content, $forums_allowedtags );
|
63 |
}
|
|
|
64 |
|
65 |
function bp_forums_filter_tag_link( $link, $tag, $page, $context ) {
|
66 |
global $bp;
|
bp-forums/bp-forums-templatetags.php
CHANGED
@@ -18,35 +18,29 @@ class BP_Forums_Template_Forum {
|
|
18 |
var $sort_by;
|
19 |
var $order;
|
20 |
|
21 |
-
function BP_Forums_Template_Forum( $type, $forum_id, $per_page, $max, $no_stickies, $
|
22 |
global $bp;
|
23 |
|
24 |
-
$this->pag_page = isset( $_REQUEST['p'] ) ? intval( $_REQUEST['p'] ) :
|
25 |
$this->pag_num = isset( $_REQUEST['n'] ) ? intval( $_REQUEST['n'] ) : $per_page;
|
26 |
-
|
27 |
-
|
28 |
-
if ( $no_stickies )
|
29 |
-
$show_stickies = 'no'; // bbPress needs str 'no'
|
30 |
|
31 |
switch ( $type ) {
|
32 |
case 'newest': default:
|
33 |
-
$this->topics = bp_forums_get_forum_topics( array( 'forum_id' => $forum_id, 'filter' => $
|
34 |
break;
|
35 |
|
36 |
case 'popular':
|
37 |
-
$this->topics = bp_forums_get_forum_topics( array( 'type' => 'popular', 'filter' => $
|
38 |
break;
|
39 |
|
40 |
case 'unreplied':
|
41 |
-
$this->topics = bp_forums_get_forum_topics( array( 'type' => 'unreplied', 'filter' => $
|
42 |
-
break;
|
43 |
-
|
44 |
-
case 'personal':
|
45 |
-
$this->topics = bp_forums_get_forum_topics( array( 'type' => 'personal', 'filter' => $filter, 'forum_id' => $forum_id, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'show_stickies' => $show_stickies ) );
|
46 |
break;
|
47 |
|
48 |
-
case '
|
49 |
-
$this->topics = bp_forums_get_forum_topics( array( 'type' => '
|
50 |
break;
|
51 |
}
|
52 |
|
@@ -94,13 +88,16 @@ class BP_Forums_Template_Forum {
|
|
94 |
$this->topics = array_merge( (array)$stickies, (array)$standard );
|
95 |
}
|
96 |
|
|
|
|
|
|
|
97 |
$this->pag_links = paginate_links( array(
|
98 |
'base' => add_query_arg( array( 'p' => '%#%', 'n' => $this->pag_num ) ),
|
99 |
'format' => '',
|
100 |
'total' => ceil($this->total_topic_count / $this->pag_num),
|
101 |
'current' => $this->pag_page,
|
102 |
-
'prev_text' => '&
|
103 |
-
'next_text' => '&
|
104 |
'mid_size' => 1
|
105 |
));
|
106 |
}
|
@@ -154,55 +151,73 @@ class BP_Forums_Template_Forum {
|
|
154 |
function bp_has_forum_topics( $args = '' ) {
|
155 |
global $forum_template, $bp;
|
156 |
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
$
|
167 |
-
|
|
|
|
|
|
|
168 |
|
169 |
/* If we're in a single group, set this group's forum_id */
|
170 |
if ( !$forum_id && $bp->groups->current_group ) {
|
171 |
-
$forum_id = groups_get_groupmeta( $bp->groups->current_group->id, 'forum_id' );
|
172 |
|
173 |
/* If it turns out there is no forum for this group, return false so we don't fetch all global topics */
|
174 |
-
if ( !$forum_id )
|
175 |
return false;
|
176 |
-
}
|
177 |
|
178 |
-
|
179 |
-
|
180 |
-
$filter = $bp->action_variables[0];
|
181 |
|
182 |
-
/* If $_GET['
|
183 |
if ( $bp->is_directory && !empty( $_GET['fs'] ) )
|
184 |
-
$
|
185 |
|
186 |
-
|
|
|
|
|
187 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
188 |
return apply_filters( 'bp_has_topics', $forum_template->has_topics(), &$forum_template );
|
189 |
}
|
190 |
-
/* DEPRECATED use bp_has_forum_topics() */
|
191 |
-
function bp_has_topics( $args = '' ) { return bp_has_forum_topics( $args ); }
|
192 |
|
193 |
function bp_forum_topics() {
|
194 |
global $forum_template;
|
195 |
return $forum_template->user_topics();
|
196 |
}
|
197 |
-
/* DEPRECATED use bp_has_forum_topics() */
|
198 |
-
function bp_topics() { return bp_forum_topics(); }
|
199 |
|
200 |
function bp_the_forum_topic() {
|
201 |
global $forum_template;
|
202 |
return $forum_template->the_topic();
|
203 |
}
|
204 |
-
/* DEPRECATED use bp_the_forum_topic() */
|
205 |
-
function bp_the_topic() { return bp_the_forum_topic(); }
|
206 |
|
207 |
function bp_the_topic_id() {
|
208 |
echo bp_get_the_topic_id();
|
@@ -274,7 +289,10 @@ function bp_the_topic_poster_name() {
|
|
274 |
function bp_get_the_topic_poster_name() {
|
275 |
global $forum_template;
|
276 |
|
277 |
-
|
|
|
|
|
|
|
278 |
}
|
279 |
|
280 |
function bp_the_topic_object_id() {
|
@@ -320,7 +338,10 @@ function bp_the_topic_last_poster_name() {
|
|
320 |
function bp_get_the_topic_last_poster_name() {
|
321 |
global $forum_template;
|
322 |
|
323 |
-
|
|
|
|
|
|
|
324 |
}
|
325 |
|
326 |
function bp_the_topic_object_avatar( $args = '' ) {
|
@@ -356,7 +377,7 @@ function bp_the_topic_last_poster_avatar( $args = '' ) {
|
|
356 |
$r = wp_parse_args( $args, $defaults );
|
357 |
extract( $r, EXTR_SKIP );
|
358 |
|
359 |
-
return apply_filters( 'bp_get_the_topic_last_poster_avatar', bp_core_fetch_avatar( array( 'item_id' => $forum_template->topic->topic_last_poster, 'type' => $type, 'width' => $width, 'height' => $height ) ) );
|
360 |
}
|
361 |
|
362 |
function bp_the_topic_start_time() {
|
@@ -495,13 +516,10 @@ function bp_the_topic_latest_post_excerpt( $args = '' ) {
|
|
495 |
return apply_filters( 'bp_get_the_topic_latest_post_excerpt', $post );
|
496 |
}
|
497 |
|
498 |
-
function bp_the_topic_time_since_last_post(
|
499 |
global $forum_template;
|
500 |
|
501 |
-
|
502 |
-
return bp_get_the_topic_time_since_last_post();
|
503 |
-
else
|
504 |
-
echo bp_get_the_topic_time_since_last_post();
|
505 |
}
|
506 |
function bp_get_the_topic_time_since_last_post() {
|
507 |
global $forum_template;
|
@@ -531,20 +549,20 @@ function bp_the_topic_admin_links( $args = '' ) {
|
|
531 |
$r = wp_parse_args( $args, $defaults );
|
532 |
extract( $r, EXTR_SKIP );
|
533 |
|
534 |
-
$links[] = '<a href="' . wp_nonce_url( bp_get_the_topic_permalink() . 'edit', 'bp_forums_edit_topic' ) . '">' . __( 'Edit', 'buddypress' ) . '</a>';
|
535 |
|
536 |
if ( $bp->is_item_admin || $bp->is_item_mod || is_site_admin() ) {
|
537 |
if ( 0 == (int)$forum_template->topic->topic_sticky )
|
538 |
-
$links[] = '<a href="' . wp_nonce_url( bp_get_the_topic_permalink() . 'stick', 'bp_forums_stick_topic' ) . '">' . __( 'Sticky', 'buddypress' ) . '</a>';
|
539 |
else
|
540 |
-
$links[] = '<a href="' . wp_nonce_url( bp_get_the_topic_permalink() . 'unstick', 'bp_forums_unstick_topic' ) . '">' . __( 'Un-stick', 'buddypress' ) . '</a>';
|
541 |
|
542 |
if ( 0 == (int)$forum_template->topic->topic_open )
|
543 |
-
$links[] = '<a href="' . wp_nonce_url( bp_get_the_topic_permalink() . 'open', 'bp_forums_open_topic' ) . '">' . __( 'Open', 'buddypress' ) . '</a>';
|
544 |
else
|
545 |
-
$links[] = '<a href="' . wp_nonce_url( bp_get_the_topic_permalink() . 'close', 'bp_forums_close_topic' ) . '">' . __( 'Close', 'buddypress' ) . '</a>';
|
546 |
|
547 |
-
$links[] = '<a class="confirm" id="topic-delete-link" href="' . wp_nonce_url( bp_get_the_topic_permalink() . 'delete', 'bp_forums_delete_topic' ) . '">' . __( 'Delete', 'buddypress' ) . '</a>';
|
548 |
}
|
549 |
|
550 |
return implode( ' ' . $seperator . ' ', (array) $links );
|
@@ -643,10 +661,15 @@ function bp_forum_pagination() {
|
|
643 |
function bp_forum_pagination_count() {
|
644 |
global $bp, $forum_template;
|
645 |
|
646 |
-
$from_num = intval( ( $forum_template->pag_page - 1 ) * $forum_template->pag_num ) + 1;
|
647 |
-
$to_num = ( $from_num + ( $forum_template->pag_num - 1 ) > $forum_template->total_topic_count ) ? $forum_template->total_topic_count : $from_num + ( $forum_template->pag_num - 1 );
|
|
|
|
|
|
|
|
|
|
|
648 |
|
649 |
-
echo apply_filters( 'bp_forum_pagination_count', sprintf( __( 'Viewing topic %
|
650 |
?>
|
651 |
<span class="ajax-loader"></span>
|
652 |
<?php
|
@@ -718,10 +741,11 @@ class BP_Forums_Template_Topic {
|
|
718 |
'format' => '',
|
719 |
'total' => ceil($this->total_post_count / $this->pag_num),
|
720 |
'current' => $this->pag_page,
|
721 |
-
'prev_text' => '&
|
722 |
-
'next_text' => '&
|
723 |
'mid_size' => 1
|
724 |
));
|
|
|
725 |
}
|
726 |
|
727 |
function has_posts() {
|
@@ -792,22 +816,16 @@ function bp_has_forum_topic_posts( $args = '' ) {
|
|
792 |
|
793 |
return apply_filters( 'bp_has_topic_posts', $topic_template->has_posts(), &$topic_template );
|
794 |
}
|
795 |
-
/* DEPRECATED use bp_has_forum_topic_posts() */
|
796 |
-
function bp_has_topic_posts() { return bp_has_forum_topic_posts( $args ); }
|
797 |
|
798 |
function bp_forum_topic_posts() {
|
799 |
global $topic_template;
|
800 |
return $topic_template->user_posts();
|
801 |
}
|
802 |
-
/* DEPRECATED use bp_forum_topic_posts() */
|
803 |
-
function bp_topic_posts() { return bp_forum_topic_posts(); }
|
804 |
|
805 |
function bp_the_forum_topic_post() {
|
806 |
global $topic_template;
|
807 |
return $topic_template->the_post();
|
808 |
}
|
809 |
-
/* DEPRECATED use bp_the_forum_topic_post() */
|
810 |
-
function bp_the_topic_post() { return bp_the_forum_topic_post(); }
|
811 |
|
812 |
function bp_the_topic_post_id() {
|
813 |
echo bp_get_the_topic_post_id();
|
@@ -845,23 +863,29 @@ function bp_the_topic_post_poster_avatar( $args = '' ) {
|
|
845 |
return apply_filters( 'bp_get_the_topic_post_poster_avatar', bp_core_fetch_avatar( array( 'item_id' => $topic_template->post->poster_id, 'type' => $type, 'width' => $width, 'height' => $height ) ) );
|
846 |
}
|
847 |
|
848 |
-
function bp_the_topic_post_poster_name(
|
849 |
-
|
850 |
-
return bp_get_the_topic_post_poster_name();
|
851 |
-
else
|
852 |
-
echo bp_get_the_topic_post_poster_name();
|
853 |
}
|
854 |
function bp_get_the_topic_post_poster_name() {
|
855 |
global $topic_template;
|
856 |
|
857 |
-
|
|
|
|
|
|
|
858 |
}
|
859 |
|
860 |
-
function
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
865 |
}
|
866 |
function bp_get_the_topic_post_time_since() {
|
867 |
global $topic_template;
|
@@ -885,7 +909,7 @@ function bp_the_topic_post_admin_links( $args = '' ) {
|
|
885 |
global $topic_template;
|
886 |
|
887 |
/* Never show for the first post in a topic. */
|
888 |
-
if ( 0 == $topic_template->current_post )
|
889 |
return;
|
890 |
|
891 |
$defaults = array(
|
@@ -895,8 +919,11 @@ function bp_the_topic_post_admin_links( $args = '' ) {
|
|
895 |
$r = wp_parse_args( $args, $defaults );
|
896 |
extract( $r, EXTR_SKIP );
|
897 |
|
898 |
-
|
899 |
-
|
|
|
|
|
|
|
900 |
|
901 |
return $links;
|
902 |
}
|
@@ -932,15 +959,29 @@ function bp_the_topic_pagination_count() {
|
|
932 |
<?php
|
933 |
}
|
934 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
935 |
function bp_directory_forums_search_form() {
|
936 |
-
global $bp;
|
937 |
-
|
938 |
-
|
939 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
940 |
</form>
|
941 |
<?php
|
942 |
}
|
943 |
-
|
944 |
function bp_forum_permalink() {
|
945 |
echo bp_get_forum_permalink();
|
946 |
}
|
@@ -996,4 +1037,17 @@ function bp_forum_topic_action() {
|
|
996 |
return apply_filters( 'bp_get_forum_topic_action', $bp->root_domain . attribute_escape( $_SERVER['REQUEST_URI'] ) );
|
997 |
}
|
998 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
999 |
?>
|
18 |
var $sort_by;
|
19 |
var $order;
|
20 |
|
21 |
+
function BP_Forums_Template_Forum( $type, $forum_id, $user_id, $page, $per_page, $max, $no_stickies, $search_terms ) {
|
22 |
global $bp;
|
23 |
|
24 |
+
$this->pag_page = isset( $_REQUEST['p'] ) ? intval( $_REQUEST['p'] ) : $page;
|
25 |
$this->pag_num = isset( $_REQUEST['n'] ) ? intval( $_REQUEST['n'] ) : $per_page;
|
26 |
+
$this->type = $type;
|
27 |
+
$this->search_terms = $search_terms;
|
|
|
|
|
28 |
|
29 |
switch ( $type ) {
|
30 |
case 'newest': default:
|
31 |
+
$this->topics = bp_forums_get_forum_topics( array( 'user_id' => $user_id, 'forum_id' => $forum_id, 'filter' => $search_terms, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'show_stickies' => $no_stickies ) );
|
32 |
break;
|
33 |
|
34 |
case 'popular':
|
35 |
+
$this->topics = bp_forums_get_forum_topics( array( 'user_id' => $user_id, 'type' => 'popular', 'filter' => $search_terms, 'forum_id' => $forum_id, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'show_stickies' => $no_stickies ) );
|
36 |
break;
|
37 |
|
38 |
case 'unreplied':
|
39 |
+
$this->topics = bp_forums_get_forum_topics( array( 'user_id' => $user_id, 'type' => 'unreplied', 'filter' => $search_terms, 'forum_id' => $forum_id, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'show_stickies' => $no_stickies ) );
|
|
|
|
|
|
|
|
|
40 |
break;
|
41 |
|
42 |
+
case 'tags':
|
43 |
+
$this->topics = bp_forums_get_forum_topics( array( 'user_id' => $user_id, 'type' => 'tags', 'filter' => $search_terms, 'forum_id' => $forum_id, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'show_stickies' => $no_stickies ) );
|
44 |
break;
|
45 |
}
|
46 |
|
88 |
$this->topics = array_merge( (array)$stickies, (array)$standard );
|
89 |
}
|
90 |
|
91 |
+
/* Fetch extra information for topics, so we don't have to query inside the loop */
|
92 |
+
$this->topics = bp_forums_get_topic_extras( &$this->topics );
|
93 |
+
|
94 |
$this->pag_links = paginate_links( array(
|
95 |
'base' => add_query_arg( array( 'p' => '%#%', 'n' => $this->pag_num ) ),
|
96 |
'format' => '',
|
97 |
'total' => ceil($this->total_topic_count / $this->pag_num),
|
98 |
'current' => $this->pag_page,
|
99 |
+
'prev_text' => '←',
|
100 |
+
'next_text' => '→',
|
101 |
'mid_size' => 1
|
102 |
));
|
103 |
}
|
151 |
function bp_has_forum_topics( $args = '' ) {
|
152 |
global $forum_template, $bp;
|
153 |
|
154 |
+
/***
|
155 |
+
* Set the defaults based on the current page. Any of these will be overridden
|
156 |
+
* if arguments are directly passed into the loop. Custom plugins should always
|
157 |
+
* pass their parameters directly to the loop.
|
158 |
+
*/
|
159 |
+
$type = 'newest';
|
160 |
+
$user_id = false;
|
161 |
+
$forum_id = false;
|
162 |
+
$search_terms = false;
|
163 |
+
$no_stickies = 'all';
|
164 |
+
|
165 |
+
/* User filtering */
|
166 |
+
if ( !empty( $bp->displayed_user->id ) )
|
167 |
+
$user_id = $bp->displayed_user->id;
|
168 |
|
169 |
/* If we're in a single group, set this group's forum_id */
|
170 |
if ( !$forum_id && $bp->groups->current_group ) {
|
171 |
+
$bp->groups->current_group->forum_id = groups_get_groupmeta( $bp->groups->current_group->id, 'forum_id' );
|
172 |
|
173 |
/* If it turns out there is no forum for this group, return false so we don't fetch all global topics */
|
174 |
+
if ( !$bp->groups->current_group->forum_id )
|
175 |
return false;
|
|
|
176 |
|
177 |
+
$forum_id = $bp->groups->current_group->forum_id;
|
178 |
+
}
|
|
|
179 |
|
180 |
+
/* If $_GET['fs'] is set, let's auto populate the search_terms var */
|
181 |
if ( $bp->is_directory && !empty( $_GET['fs'] ) )
|
182 |
+
$search_terms = $_GET['fs'];
|
183 |
|
184 |
+
/* Show stickies on a group forum */
|
185 |
+
if ( $bp->groups->current_group )
|
186 |
+
$no_stickies = null;
|
187 |
|
188 |
+
$defaults = array(
|
189 |
+
'type' => $type,
|
190 |
+
'forum_id' => $forum_id,
|
191 |
+
'user_id' => $user_id,
|
192 |
+
'page' => 1,
|
193 |
+
'per_page' => 20,
|
194 |
+
'max' => false,
|
195 |
+
'no_stickies' => $no_stickies,
|
196 |
+
'search_terms' => $search_terms
|
197 |
+
);
|
198 |
+
|
199 |
+
$r = wp_parse_args( $args, $defaults );
|
200 |
+
extract( $r );
|
201 |
+
|
202 |
+
/* If we're viewing a tag URL in the directory, let's override the type and set it to tags and the filter to the tag name */
|
203 |
+
if ( 'tag' == $bp->current_action && !empty( $bp->action_variables[0] ) ) {
|
204 |
+
$search_terms = $bp->action_variables[0];
|
205 |
+
$type = 'tags';
|
206 |
+
}
|
207 |
+
|
208 |
+
$forum_template = new BP_Forums_Template_Forum( $type, $forum_id, $user_id, $page, $per_page, $max, $no_stickies, $search_terms );
|
209 |
return apply_filters( 'bp_has_topics', $forum_template->has_topics(), &$forum_template );
|
210 |
}
|
|
|
|
|
211 |
|
212 |
function bp_forum_topics() {
|
213 |
global $forum_template;
|
214 |
return $forum_template->user_topics();
|
215 |
}
|
|
|
|
|
216 |
|
217 |
function bp_the_forum_topic() {
|
218 |
global $forum_template;
|
219 |
return $forum_template->the_topic();
|
220 |
}
|
|
|
|
|
221 |
|
222 |
function bp_the_topic_id() {
|
223 |
echo bp_get_the_topic_id();
|
289 |
function bp_get_the_topic_poster_name() {
|
290 |
global $forum_template;
|
291 |
|
292 |
+
if ( !$name = bp_core_get_userlink( $forum_template->topic->poster_id ) )
|
293 |
+
return __( 'Deleted User', 'buddypress' );
|
294 |
+
|
295 |
+
return apply_filters( 'bp_get_the_topic_poster_name', $name );
|
296 |
}
|
297 |
|
298 |
function bp_the_topic_object_id() {
|
338 |
function bp_get_the_topic_last_poster_name() {
|
339 |
global $forum_template;
|
340 |
|
341 |
+
if ( !$domain = bp_core_get_user_domain( $forum_template->topic->topic_last_poster, $forum_template->topic->topic_last_poster_nicename, $forum_template->topic->topic_last_poster_login ) )
|
342 |
+
return __( 'Deleted User', 'buddypress' );
|
343 |
+
|
344 |
+
return apply_filters( 'bp_get_the_topic_last_poster_name', '<a href="' . $domain . '">' . $forum_template->topic->topic_last_poster_displayname . '</a>' );
|
345 |
}
|
346 |
|
347 |
function bp_the_topic_object_avatar( $args = '' ) {
|
377 |
$r = wp_parse_args( $args, $defaults );
|
378 |
extract( $r, EXTR_SKIP );
|
379 |
|
380 |
+
return apply_filters( 'bp_get_the_topic_last_poster_avatar', bp_core_fetch_avatar( array( 'email' => $forum_template->topic->topic_last_poster_email, 'item_id' => $forum_template->topic->topic_last_poster, 'type' => $type, 'width' => $width, 'height' => $height ) ) );
|
381 |
}
|
382 |
|
383 |
function bp_the_topic_start_time() {
|
516 |
return apply_filters( 'bp_get_the_topic_latest_post_excerpt', $post );
|
517 |
}
|
518 |
|
519 |
+
function bp_the_topic_time_since_last_post() {
|
520 |
global $forum_template;
|
521 |
|
522 |
+
echo bp_get_the_topic_time_since_last_post();
|
|
|
|
|
|
|
523 |
}
|
524 |
function bp_get_the_topic_time_since_last_post() {
|
525 |
global $forum_template;
|
549 |
$r = wp_parse_args( $args, $defaults );
|
550 |
extract( $r, EXTR_SKIP );
|
551 |
|
552 |
+
$links[] = '<a href="' . wp_nonce_url( bp_get_the_topic_permalink() . 'edit', 'bp_forums_edit_topic' ) . '">' . __( 'Edit Topic', 'buddypress' ) . '</a>';
|
553 |
|
554 |
if ( $bp->is_item_admin || $bp->is_item_mod || is_site_admin() ) {
|
555 |
if ( 0 == (int)$forum_template->topic->topic_sticky )
|
556 |
+
$links[] = '<a href="' . wp_nonce_url( bp_get_the_topic_permalink() . 'stick', 'bp_forums_stick_topic' ) . '">' . __( 'Sticky Topic', 'buddypress' ) . '</a>';
|
557 |
else
|
558 |
+
$links[] = '<a href="' . wp_nonce_url( bp_get_the_topic_permalink() . 'unstick', 'bp_forums_unstick_topic' ) . '">' . __( 'Un-stick Topic', 'buddypress' ) . '</a>';
|
559 |
|
560 |
if ( 0 == (int)$forum_template->topic->topic_open )
|
561 |
+
$links[] = '<a href="' . wp_nonce_url( bp_get_the_topic_permalink() . 'open', 'bp_forums_open_topic' ) . '">' . __( 'Open Topic', 'buddypress' ) . '</a>';
|
562 |
else
|
563 |
+
$links[] = '<a href="' . wp_nonce_url( bp_get_the_topic_permalink() . 'close', 'bp_forums_close_topic' ) . '">' . __( 'Close Topic', 'buddypress' ) . '</a>';
|
564 |
|
565 |
+
$links[] = '<a class="confirm" id="topic-delete-link" href="' . wp_nonce_url( bp_get_the_topic_permalink() . 'delete', 'bp_forums_delete_topic' ) . '">' . __( 'Delete Topic', 'buddypress' ) . '</a>';
|
566 |
}
|
567 |
|
568 |
return implode( ' ' . $seperator . ' ', (array) $links );
|
661 |
function bp_forum_pagination_count() {
|
662 |
global $bp, $forum_template;
|
663 |
|
664 |
+
$from_num = bp_core_number_format( intval( ( $forum_template->pag_page - 1 ) * $forum_template->pag_num ) + 1 );
|
665 |
+
$to_num = bp_core_number_format( ( $from_num + ( $forum_template->pag_num - 1 ) > $forum_template->total_topic_count ) ? $forum_template->total_topic_count : $from_num + ( $forum_template->pag_num - 1 ) );
|
666 |
+
$total = bp_core_number_format( $forum_template->total_topic_count );
|
667 |
+
|
668 |
+
$pag_filter = false;
|
669 |
+
if ( 'tags' == $forum_template->type && !empty( $forum_template->search_terms ) )
|
670 |
+
$pag_filter = sprintf( __( ' matching tag "%s"', 'buddypress' ), $forum_template->search_terms );
|
671 |
|
672 |
+
echo apply_filters( 'bp_forum_pagination_count', sprintf( __( 'Viewing topic %s to %s (%s total topics%s)', 'buddypress' ), $from_num, $to_num, $total, $pag_filter ) );
|
673 |
?>
|
674 |
<span class="ajax-loader"></span>
|
675 |
<?php
|
741 |
'format' => '',
|
742 |
'total' => ceil($this->total_post_count / $this->pag_num),
|
743 |
'current' => $this->pag_page,
|
744 |
+
'prev_text' => '←',
|
745 |
+
'next_text' => '→',
|
746 |
'mid_size' => 1
|
747 |
));
|
748 |
+
$this->pag->total_pages = ceil($this->total_post_count / $this->pag_num);
|
749 |
}
|
750 |
|
751 |
function has_posts() {
|
816 |
|
817 |
return apply_filters( 'bp_has_topic_posts', $topic_template->has_posts(), &$topic_template );
|
818 |
}
|
|
|
|
|
819 |
|
820 |
function bp_forum_topic_posts() {
|
821 |
global $topic_template;
|
822 |
return $topic_template->user_posts();
|
823 |
}
|
|
|
|
|
824 |
|
825 |
function bp_the_forum_topic_post() {
|
826 |
global $topic_template;
|
827 |
return $topic_template->the_post();
|
828 |
}
|
|
|
|
|
829 |
|
830 |
function bp_the_topic_post_id() {
|
831 |
echo bp_get_the_topic_post_id();
|
863 |
return apply_filters( 'bp_get_the_topic_post_poster_avatar', bp_core_fetch_avatar( array( 'item_id' => $topic_template->post->poster_id, 'type' => $type, 'width' => $width, 'height' => $height ) ) );
|
864 |
}
|
865 |
|
866 |
+
function bp_the_topic_post_poster_name() {
|
867 |
+
echo bp_get_the_topic_post_poster_name();
|
|
|
|
|
|
|
868 |
}
|
869 |
function bp_get_the_topic_post_poster_name() {
|
870 |
global $topic_template;
|
871 |
|
872 |
+
if ( !$link = bp_core_get_user_domain( $topic_template->post->poster_id, $topic_template->post->poster_nicename, $topic_template->post->poster_login ) )
|
873 |
+
return __( 'Deleted User', 'buddypress' );
|
874 |
+
|
875 |
+
return apply_filters( 'bp_get_the_topic_post_poster_name', '<a href="' . $link . '" title="' . $topic_template->post->poster_name . '">' . $topic_template->post->poster_name . '</a>' );
|
876 |
}
|
877 |
|
878 |
+
function bp_the_topic_post_poster_link() {
|
879 |
+
echo bp_get_the_topic_post_poster_link();
|
880 |
+
}
|
881 |
+
function bp_get_the_topic_post_poster_link() {
|
882 |
+
global $topic_template;
|
883 |
+
|
884 |
+
return apply_filters( 'bp_get_the_topic_post_poster_name', bp_core_get_user_domain( $topic_template->post->poster_id, $topic_template->post->poster_nicename, $topic_template->post->poster_login ) );
|
885 |
+
}
|
886 |
+
|
887 |
+
function bp_the_topic_post_time_since() {
|
888 |
+
echo bp_get_the_topic_post_time_since();
|
889 |
}
|
890 |
function bp_get_the_topic_post_time_since() {
|
891 |
global $topic_template;
|
909 |
global $topic_template;
|
910 |
|
911 |
/* Never show for the first post in a topic. */
|
912 |
+
if ( 0 == $topic_template->current_post && $topic_template->pag_page == 1 )
|
913 |
return;
|
914 |
|
915 |
$defaults = array(
|
919 |
$r = wp_parse_args( $args, $defaults );
|
920 |
extract( $r, EXTR_SKIP );
|
921 |
|
922 |
+
if ( $_SERVER['QUERY_STRING'] )
|
923 |
+
$query_vars = '?' . $_SERVER['QUERY_STRING'];
|
924 |
+
|
925 |
+
$links = '<a href="' . wp_nonce_url( bp_get_the_topic_permalink() . $topic_template->post->id . 'edit/post/' . $topic_template->post->post_id . '/' . $query_vars, 'bp_forums_edit_post' ) . '">' . __( 'Edit', 'buddypress' ) . '</a> ' . $seperator . ' ';
|
926 |
+
$links .= '<a class="confirm" id="post-delete-link" href="' . wp_nonce_url( bp_get_the_topic_permalink() . 'delete/post/' . $topic_template->post->post_id, 'bp_forums_delete_post' ) . '">' . __( 'Delete', 'buddypress' ) . '</a> | ';
|
927 |
|
928 |
return $links;
|
929 |
}
|
959 |
<?php
|
960 |
}
|
961 |
|
962 |
+
function bp_the_topic_is_last_page() {
|
963 |
+
echo bp_get_the_topic_is_last_page();
|
964 |
+
}
|
965 |
+
function bp_get_the_topic_is_last_page() {
|
966 |
+
global $topic_template;
|
967 |
+
|
968 |
+
return apply_filters( 'bp_get_the_topic_is_last_page', $topic_template->pag_page == $topic_template->pag->total_pages );
|
969 |
+
}
|
970 |
+
|
971 |
function bp_directory_forums_search_form() {
|
972 |
+
global $bp;
|
973 |
+
|
974 |
+
$search_value = __( 'Search anything...', 'buddypress' );
|
975 |
+
if ( !empty( $_REQUEST['fs'] ) )
|
976 |
+
$search_value = $_REQUEST['fs'];
|
977 |
+
|
978 |
+
?>
|
979 |
+
<form action="" method="get" id="search-forums-form">
|
980 |
+
<label><input type="text" name="s" id="forums_search" value="<?php echo attribute_escape($search_value) ?>" onfocus="if (this.value == '<?php _e( 'Search anything...', 'buddypress' ) ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php _e( 'Search anything...', 'buddypress' ) ?>';}" /></label>
|
981 |
+
<input type="submit" id="forums_search_submit" name="forums_search_submit" value="<?php _e( 'Search', 'buddypress' ) ?>" />
|
982 |
</form>
|
983 |
<?php
|
984 |
}
|
|
|
985 |
function bp_forum_permalink() {
|
986 |
echo bp_get_forum_permalink();
|
987 |
}
|
1037 |
return apply_filters( 'bp_get_forum_topic_action', $bp->root_domain . attribute_escape( $_SERVER['REQUEST_URI'] ) );
|
1038 |
}
|
1039 |
|
1040 |
+
function bp_forum_topic_count_for_user( $user_id = false ) {
|
1041 |
+
echo bp_get_forum_topic_count_for_user( $user_id );
|
1042 |
+
}
|
1043 |
+
function bp_get_forum_topic_count_for_user( $user_id = false ) {
|
1044 |
+
return apply_filters( 'bp_get_forum_topic_count_for_user', bp_forums_total_topic_count_for_user( $user_id ) );
|
1045 |
+
}
|
1046 |
+
|
1047 |
+
function bp_forum_topic_count( $user_id = false ) {
|
1048 |
+
echo bp_get_forum_topic_count( $user_id );
|
1049 |
+
}
|
1050 |
+
function bp_get_forum_topic_count( $user_id = false ) {
|
1051 |
+
return apply_filters( 'bp_get_forum_topic_count', bp_forums_total_topic_count( $user_id ) );
|
1052 |
+
}
|
1053 |
?>
|
bp-forums/deprecated/images/closed.png
DELETED
Binary file
|
bp-friends.php
CHANGED
@@ -9,10 +9,6 @@ if ( !defined( 'BP_FRIENDS_SLUG' ) )
|
|
9 |
require ( BP_PLUGIN_DIR . '/bp-friends/bp-friends-classes.php' );
|
10 |
require ( BP_PLUGIN_DIR . '/bp-friends/bp-friends-templatetags.php' );
|
11 |
|
12 |
-
/* Include deprecated functions if settings allow */
|
13 |
-
if ( !defined( 'BP_IGNORE_DEPRECATED' ) )
|
14 |
-
require ( BP_PLUGIN_DIR . '/bp-friends/deprecated/bp-friends-deprecated.php' );
|
15 |
-
|
16 |
function friends_install() {
|
17 |
global $wpdb, $bp;
|
18 |
|
@@ -51,8 +47,7 @@ function friends_setup_globals() {
|
|
51 |
|
52 |
do_action( 'friends_setup_globals' );
|
53 |
}
|
54 |
-
add_action( '
|
55 |
-
add_action( 'admin_menu', 'friends_setup_globals', 2 );
|
56 |
|
57 |
function friends_check_installed() {
|
58 |
global $wpdb, $bp;
|
@@ -61,7 +56,7 @@ function friends_check_installed() {
|
|
61 |
return false;
|
62 |
|
63 |
/* Need to check db tables exist, activate hook no-worky in mu-plugins folder. */
|
64 |
-
if (
|
65 |
friends_install();
|
66 |
}
|
67 |
add_action( 'admin_menu', 'friends_check_installed' );
|
@@ -70,16 +65,16 @@ function friends_setup_nav() {
|
|
70 |
global $bp;
|
71 |
|
72 |
/* Add 'Friends' to the main navigation */
|
73 |
-
bp_core_new_nav_item( array( 'name' => __('Friends', 'buddypress'), 'slug' => $bp->friends->slug, 'position' => 60, 'screen_function' => 'friends_screen_my_friends', 'default_subnav_slug' => 'my-friends', 'item_css_id' => $bp->friends->id ) );
|
74 |
|
75 |
$friends_link = $bp->loggedin_user->domain . $bp->friends->slug . '/';
|
76 |
|
77 |
/* Add the subnav items to the friends nav item */
|
78 |
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' ) );
|
79 |
-
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' =>
|
80 |
|
81 |
if ( $bp->current_component == $bp->friends->slug ) {
|
82 |
-
if (
|
83 |
$bp->bp_options_title = __( 'My Friends', 'buddypress' );
|
84 |
} else {
|
85 |
$bp->bp_options_avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb' ) );
|
@@ -109,7 +104,7 @@ function friends_screen_my_friends() {
|
|
109 |
|
110 |
do_action( 'friends_screen_my_friends' );
|
111 |
|
112 |
-
bp_core_load_template( apply_filters( 'friends_template_my_friends', '
|
113 |
}
|
114 |
|
115 |
function friends_screen_requests() {
|
@@ -130,7 +125,6 @@ function friends_screen_requests() {
|
|
130 |
/* Check the nonce */
|
131 |
check_admin_referer( 'friends_reject_friendship' );
|
132 |
|
133 |
-
|
134 |
if ( friends_reject_friendship( $bp->action_variables[1] ) ) {
|
135 |
bp_core_add_message( __( 'Friendship rejected', 'buddypress' ) );
|
136 |
} else {
|
@@ -141,12 +135,7 @@ function friends_screen_requests() {
|
|
141 |
|
142 |
do_action( 'friends_screen_requests' );
|
143 |
|
144 |
-
bp_core_load_template( apply_filters( 'friends_template_requests', '
|
145 |
-
}
|
146 |
-
|
147 |
-
function friends_screen_friend_finder() {
|
148 |
-
do_action( 'friends_screen_friend_finder' );
|
149 |
-
bp_core_load_template( apply_filters( 'friends_template_friend_finder', 'friends/friend-finder' ) );
|
150 |
}
|
151 |
|
152 |
function friends_screen_notification_settings() {
|
@@ -278,26 +267,27 @@ function friends_record_activity( $args = '' ) {
|
|
278 |
|
279 |
$defaults = array(
|
280 |
'user_id' => $bp->loggedin_user->id,
|
281 |
-
'
|
282 |
-
'
|
283 |
-
'
|
284 |
-
'
|
|
|
285 |
'item_id' => false,
|
286 |
'secondary_item_id' => false,
|
287 |
-
'recorded_time' =>
|
288 |
'hide_sitewide' => false
|
289 |
);
|
290 |
|
291 |
$r = wp_parse_args( $args, $defaults );
|
292 |
extract( $r, EXTR_SKIP );
|
293 |
|
294 |
-
return bp_activity_add( array( 'user_id' => $user_id, 'content' => $content, 'primary_link' => $primary_link, '
|
295 |
}
|
296 |
|
297 |
function friends_delete_activity( $args ) {
|
298 |
if ( function_exists('bp_activity_delete_by_item_id') ) {
|
299 |
extract( (array)$args );
|
300 |
-
bp_activity_delete_by_item_id( array( 'item_id' => $item_id, '
|
301 |
}
|
302 |
}
|
303 |
|
@@ -311,7 +301,7 @@ function friends_register_activity_actions() {
|
|
311 |
|
312 |
do_action( 'friends_register_activity_actions' );
|
313 |
}
|
314 |
-
add_action( '
|
315 |
|
316 |
function friends_format_notifications( $action, $item_id, $secondary_item_id, $total_items ) {
|
317 |
global $bp;
|
@@ -322,7 +312,7 @@ function friends_format_notifications( $action, $item_id, $secondary_item_id, $t
|
|
322 |
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 );
|
323 |
} else {
|
324 |
$user_fullname = bp_core_get_user_displayname( $item_id );
|
325 |
-
$user_url =
|
326 |
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 );
|
327 |
}
|
328 |
break;
|
@@ -332,7 +322,7 @@ function friends_format_notifications( $action, $item_id, $secondary_item_id, $t
|
|
332 |
return apply_filters( 'bp_friends_multiple_friendship_request_notification', '<a href="' . $bp->loggedin_user->domain . $bp->friends->slug . '/requests" title="' . __( 'Friendship requests', 'buddypress' ) . '">' . sprintf( __('You have %d pending friendship requests', 'buddypress' ), (int)$total_items ) . '</a>', $total_items );
|
333 |
} else {
|
334 |
$user_fullname = bp_core_get_user_displayname( $item_id );
|
335 |
-
$user_url =
|
336 |
return apply_filters( 'bp_friends_single_friendship_request_notification', '<a href="' . $bp->loggedin_user->domain . $bp->friends->slug . '/requests" title="' . __( 'Friendship requests', 'buddypress' ) . '">' . sprintf( __('You have a friendship request from %s', 'buddypress' ), $user_fullname ) . '</a>', $user_fullname );
|
337 |
}
|
338 |
break;
|
@@ -353,206 +343,6 @@ function friends_format_notifications( $action, $item_id, $secondary_item_id, $t
|
|
353 |
* true or false on success or failure.
|
354 |
*/
|
355 |
|
356 |
-
function friends_check_user_has_friends( $user_id ) {
|
357 |
-
$friend_count = get_usermeta( $user_id, 'total_friend_count');
|
358 |
-
|
359 |
-
if ( empty( $friend_count ) )
|
360 |
-
return false;
|
361 |
-
|
362 |
-
if ( !(int)$friend_count )
|
363 |
-
return false;
|
364 |
-
|
365 |
-
return true;
|
366 |
-
}
|
367 |
-
|
368 |
-
function friends_get_friend_user_ids( $user_id, $friend_requests_only = false, $assoc_arr = false, $filter = false ) {
|
369 |
-
return BP_Friends_Friendship::get_friend_user_ids( $user_id, $friend_requests_only, $assoc_arr, $filter );
|
370 |
-
}
|
371 |
-
|
372 |
-
function friends_get_friendship_ids( $user_id, $friend_requests_only = false ) {
|
373 |
-
return BP_Friends_Friendship::get_friendship_ids( $user_id, $friend_requests_only );
|
374 |
-
}
|
375 |
-
|
376 |
-
function friends_search_friends( $search_terms, $user_id, $pag_num = 10, $pag_page = 1 ) {
|
377 |
-
return BP_Friends_Friendship::search_friends( $search_terms, $user_id, $pag_num, $pag_page );
|
378 |
-
}
|
379 |
-
|
380 |
-
function friends_get_friendship_requests( $user_id ) {
|
381 |
-
$fship_ids = friends_get_friendship_ids( $user_id, true );
|
382 |
-
|
383 |
-
return array( 'requests' => $fship_ids, 'total' => count($fship_ids) );
|
384 |
-
}
|
385 |
-
|
386 |
-
function friends_get_recently_active( $user_id, $pag_num = false, $pag_page = false, $filter = false ) {
|
387 |
-
if ( $filter )
|
388 |
-
$friend_ids = friends_search_friends( $filter, $user_id, false );
|
389 |
-
else
|
390 |
-
$friend_ids = friends_get_friend_user_ids( $user_id );
|
391 |
-
|
392 |
-
if ( !$friend_ids )
|
393 |
-
return false;
|
394 |
-
|
395 |
-
if ( $filter )
|
396 |
-
$friend_ids = $friend_ids['friends'];
|
397 |
-
|
398 |
-
$ids_and_activity = friends_get_bulk_last_active( implode( ',', (array)$friend_ids ) );
|
399 |
-
|
400 |
-
if ( !$ids_and_activity )
|
401 |
-
return false;
|
402 |
-
|
403 |
-
$total_friends = count( $ids_and_activity );
|
404 |
-
|
405 |
-
if ( $pag_num && $pag_page )
|
406 |
-
return array( 'friends' => array_slice( $ids_and_activity, intval( ( $pag_page - 1 ) * $pag_num), intval( $pag_num ) ), 'total' => $total_friends );
|
407 |
-
else
|
408 |
-
return array( 'friends' => $ids_and_activity, 'total' => $total_friends );
|
409 |
-
}
|
410 |
-
|
411 |
-
function friends_get_alphabetically( $user_id, $pag_num = false, $pag_page = false, $filter = false ) {
|
412 |
-
if ( $filter )
|
413 |
-
$friend_ids = friends_search_friends( $filter, $user_id, false );
|
414 |
-
else
|
415 |
-
$friend_ids = friends_get_friend_user_ids( $user_id );
|
416 |
-
|
417 |
-
if ( !$friend_ids )
|
418 |
-
return false;
|
419 |
-
|
420 |
-
if ( $filter )
|
421 |
-
$friend_ids = $friend_ids['friends'];
|
422 |
-
|
423 |
-
$sorted_ids = BP_Friends_Friendship::sort_by_name( implode( ',', $friend_ids ) );
|
424 |
-
|
425 |
-
if ( !$sorted_ids )
|
426 |
-
return false;
|
427 |
-
|
428 |
-
$total_friends = count( $sorted_ids );
|
429 |
-
|
430 |
-
if ( $pag_num && $pag_page )
|
431 |
-
return array( 'friends' => array_slice( $sorted_ids, intval( ( $pag_page - 1 ) * $pag_num), intval( $pag_num ) ), 'total' => $total_friends );
|
432 |
-
else
|
433 |
-
return array( 'friends' => $sorted_ids, 'total' => $total_friends );
|
434 |
-
}
|
435 |
-
|
436 |
-
function friends_get_newest( $user_id, $pag_num = false, $pag_page = false, $filter = false ) {
|
437 |
-
if ( $filter )
|
438 |
-
$friend_ids = friends_search_friends( $filter, $user_id, false );
|
439 |
-
else
|
440 |
-
$friend_ids = friends_get_friend_user_ids( $user_id );
|
441 |
-
|
442 |
-
if ( !$friend_ids )
|
443 |
-
return false;
|
444 |
-
|
445 |
-
if ( $filter )
|
446 |
-
$friend_ids = $friend_ids['friends'];
|
447 |
-
|
448 |
-
$total_friends = count( $friend_ids );
|
449 |
-
|
450 |
-
if ( $pag_num && $pag_page )
|
451 |
-
return array( 'friends' => array_slice( $friend_ids, intval( ( $pag_page - 1 ) * $pag_num), intval( $pag_num ) ), 'total' => $total_friends );
|
452 |
-
else
|
453 |
-
return array( 'friends' => $friend_ids, 'total' => $total_friends );
|
454 |
-
}
|
455 |
-
|
456 |
-
function friends_get_bulk_last_active( $friend_ids ) {
|
457 |
-
return BP_Friends_Friendship::get_bulk_last_active( $friend_ids );
|
458 |
-
}
|
459 |
-
|
460 |
-
function friends_get_friends_list( $user_id ) {
|
461 |
-
global $bp;
|
462 |
-
|
463 |
-
$friend_ids = BP_Friends_Friendship::get_friend_user_ids( $user_id );
|
464 |
-
|
465 |
-
if ( !$friend_ids )
|
466 |
-
return false;
|
467 |
-
|
468 |
-
for ( $i = 0; $i < count($friend_ids); $i++ ) {
|
469 |
-
if ( function_exists('bp_user_fullname') )
|
470 |
-
$display_name = bp_core_get_user_displayname( $friend_ids[$i] );
|
471 |
-
|
472 |
-
if ( $display_name != ' ' ) {
|
473 |
-
$friends[] = array(
|
474 |
-
'id' => $friend_ids[$i],
|
475 |
-
'full_name' => $display_name
|
476 |
-
);
|
477 |
-
}
|
478 |
-
}
|
479 |
-
|
480 |
-
if ( $friends && is_array($friends) )
|
481 |
-
usort($friends, 'friends_sort_by_name');
|
482 |
-
|
483 |
-
if ( !$friends )
|
484 |
-
return false;
|
485 |
-
|
486 |
-
return $friends;
|
487 |
-
}
|
488 |
-
|
489 |
-
function friends_sort_by_name($a, $b) {
|
490 |
-
return strcasecmp($a['full_name'], $b['full_name']);
|
491 |
-
}
|
492 |
-
|
493 |
-
function friends_get_friends_invite_list( $user_id = false, $group_id ) {
|
494 |
-
global $bp;
|
495 |
-
|
496 |
-
if ( !$user_id )
|
497 |
-
$user_id = $bp->loggedin_user->id;
|
498 |
-
|
499 |
-
$friend_ids = friends_get_alphabetically( $user_id );
|
500 |
-
|
501 |
-
if ( (int) $friend_ids['total'] < 1 )
|
502 |
-
return false;
|
503 |
-
|
504 |
-
for ( $i = 0; $i < count($friend_ids['friends']); $i++ ) {
|
505 |
-
if ( groups_check_user_has_invite( $friend_ids['friends'][$i]->user_id, $group_id ) || groups_is_user_member( $friend_ids['friends'][$i]->user_id, $group_id ) )
|
506 |
-
continue;
|
507 |
-
|
508 |
-
$display_name = bp_core_get_user_displayname( $friend_ids['friends'][$i]->user_id );
|
509 |
-
|
510 |
-
if ( $display_name != ' ' ) {
|
511 |
-
$friends[] = array(
|
512 |
-
'id' => $friend_ids['friends'][$i]->user_id,
|
513 |
-
'full_name' => $display_name
|
514 |
-
);
|
515 |
-
}
|
516 |
-
}
|
517 |
-
|
518 |
-
if ( !$friends )
|
519 |
-
return false;
|
520 |
-
|
521 |
-
return $friends;
|
522 |
-
}
|
523 |
-
|
524 |
-
function friends_count_invitable_friends( $user_id, $group_id ) {
|
525 |
-
return BP_Friends_Friendship::get_invitable_friend_count( $user_id, $group_id );
|
526 |
-
}
|
527 |
-
|
528 |
-
function friends_get_friend_count_for_user( $user_id ) {
|
529 |
-
return BP_Friends_Friendship::total_friend_count( $user_id );
|
530 |
-
}
|
531 |
-
|
532 |
-
function friends_search_users( $search_terms, $user_id, $pag_num = false, $pag_page = false ) {
|
533 |
-
global $bp;
|
534 |
-
|
535 |
-
$user_ids = BP_Friends_Friendship::search_users( $search_terms, $user_id, $pag_num, $pag_page );
|
536 |
-
|
537 |
-
if ( !$user_ids )
|
538 |
-
return false;
|
539 |
-
|
540 |
-
for ( $i = 0; $i < count($user_ids); $i++ ) {
|
541 |
-
$users[] = new BP_Core_User($user_ids[$i]);
|
542 |
-
}
|
543 |
-
|
544 |
-
return array( 'users' => $users, 'count' => BP_Friends_Friendship::search_users_count($search_terms) );
|
545 |
-
}
|
546 |
-
|
547 |
-
function friends_check_friendship( $user_id, $possible_friend_id ) {
|
548 |
-
global $bp;
|
549 |
-
|
550 |
-
if ( 'is_friend' == BP_Friends_Friendship::check_is_friend( $user_id, $possible_friend_id ) )
|
551 |
-
return true;
|
552 |
-
|
553 |
-
return false;
|
554 |
-
}
|
555 |
-
|
556 |
function friends_add_friend( $initiator_userid, $friend_userid, $force_accept = false ) {
|
557 |
global $bp;
|
558 |
|
@@ -598,7 +388,7 @@ function friends_remove_friend( $initiator_userid, $friend_userid ) {
|
|
598 |
$friendship = new BP_Friends_Friendship( $friendship_id );
|
599 |
|
600 |
// Remove the activity stream item for the user who canceled the friendship
|
601 |
-
friends_delete_activity( array( 'item_id' => $friendship_id, '
|
602 |
|
603 |
do_action( 'friends_friendship_deleted', $friendship_id, $initiator_userid, $friend_userid );
|
604 |
|
@@ -628,23 +418,19 @@ function friends_accept_friendship( $friendship_id ) {
|
|
628 |
$initiator_link = bp_core_get_userlink( $friendship->initiator_user_id );
|
629 |
$friend_link = bp_core_get_userlink( $friendship->friend_user_id );
|
630 |
|
631 |
-
$primary_link = apply_filters( 'friends_activity_friendship_accepted_primary_link', bp_core_get_userurl( $friendship->initiator_user_id ), &$friendship );
|
632 |
-
|
633 |
/* Record in activity streams for the initiator */
|
634 |
friends_record_activity( array(
|
635 |
'user_id' => $friendship->initiator_user_id,
|
636 |
-
'
|
637 |
-
'
|
638 |
-
'primary_link' => $primary_link,
|
639 |
'item_id' => $friendship_id
|
640 |
) );
|
641 |
|
642 |
/* Record in activity streams for the friend */
|
643 |
friends_record_activity( array(
|
644 |
'user_id' => $friendship->friend_user_id,
|
645 |
-
'
|
646 |
-
'
|
647 |
-
'primary_link' => $primary_link,
|
648 |
'item_id' => $friendship_id,
|
649 |
'hide_sitewide' => true /* We've already got the first entry site wide */
|
650 |
) );
|
@@ -654,7 +440,6 @@ function friends_accept_friendship( $friendship_id ) {
|
|
654 |
friends_notification_accepted_request( $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id );
|
655 |
|
656 |
do_action( 'friends_friendship_accepted', $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id );
|
657 |
-
|
658 |
return true;
|
659 |
}
|
660 |
|
@@ -675,6 +460,123 @@ function friends_reject_friendship( $friendship_id ) {
|
|
675 |
return false;
|
676 |
}
|
677 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
678 |
function friends_is_friendship_confirmed( $friendship_id ) {
|
679 |
$friendship = new BP_Friends_Friendship( $friendship_id );
|
680 |
return $friendship->is_confirmed;
|
@@ -705,18 +607,36 @@ add_action( 'wpmu_delete_user', 'friends_remove_data', 1 );
|
|
705 |
add_action( 'delete_user', 'friends_remove_data', 1 );
|
706 |
add_action( 'make_spam_user', 'friends_remove_data', 1 );
|
707 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
708 |
function friends_clear_friend_object_cache( $friendship_id ) {
|
709 |
if ( !$friendship = new BP_Friends_Friendship( $friendship_id ) )
|
710 |
return false;
|
711 |
|
712 |
wp_cache_delete( 'friends_friend_ids_' . $friendship->initiator_user_id, 'bp' );
|
713 |
wp_cache_delete( 'friends_friend_ids_' . $friendship->friend_user_id, 'bp' );
|
|
|
|
|
714 |
wp_cache_delete( 'popular_users', 'bp' );
|
715 |
|
716 |
/* Clear the sitewide activity cache */
|
717 |
wp_cache_delete( 'sitewide_activity', 'bp' );
|
718 |
}
|
719 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
720 |
// List actions to clear object caches on
|
721 |
add_action( 'friends_friendship_accepted', 'friends_clear_friend_object_cache' );
|
722 |
add_action( 'friends_friendship_deleted', 'friends_clear_friend_object_cache' );
|
9 |
require ( BP_PLUGIN_DIR . '/bp-friends/bp-friends-classes.php' );
|
10 |
require ( BP_PLUGIN_DIR . '/bp-friends/bp-friends-templatetags.php' );
|
11 |
|
|
|
|
|
|
|
|
|
12 |
function friends_install() {
|
13 |
global $wpdb, $bp;
|
14 |
|
47 |
|
48 |
do_action( 'friends_setup_globals' );
|
49 |
}
|
50 |
+
add_action( 'bp_setup_globals', 'friends_setup_globals' );
|
|
|
51 |
|
52 |
function friends_check_installed() {
|
53 |
global $wpdb, $bp;
|
56 |
return false;
|
57 |
|
58 |
/* Need to check db tables exist, activate hook no-worky in mu-plugins folder. */
|
59 |
+
if ( $bp->site_options['bp-friends-db-version'] < BP_FRIENDS_DB_VERSION )
|
60 |
friends_install();
|
61 |
}
|
62 |
add_action( 'admin_menu', 'friends_check_installed' );
|
65 |
global $bp;
|
66 |
|
67 |
/* Add 'Friends' to the main navigation */
|
68 |
+
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 ) );
|
69 |
|
70 |
$friends_link = $bp->loggedin_user->domain . $bp->friends->slug . '/';
|
71 |
|
72 |
/* Add the subnav items to the friends nav item */
|
73 |
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' ) );
|
74 |
+
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() ) );
|
75 |
|
76 |
if ( $bp->current_component == $bp->friends->slug ) {
|
77 |
+
if ( bp_is_my_profile() ) {
|
78 |
$bp->bp_options_title = __( 'My Friends', 'buddypress' );
|
79 |
} else {
|
80 |
$bp->bp_options_avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb' ) );
|
104 |
|
105 |
do_action( 'friends_screen_my_friends' );
|
106 |
|
107 |
+
bp_core_load_template( apply_filters( 'friends_template_my_friends', 'members/single/home' ) );
|
108 |
}
|
109 |
|
110 |
function friends_screen_requests() {
|
125 |
/* Check the nonce */
|
126 |
check_admin_referer( 'friends_reject_friendship' );
|
127 |
|
|
|
128 |
if ( friends_reject_friendship( $bp->action_variables[1] ) ) {
|
129 |
bp_core_add_message( __( 'Friendship rejected', 'buddypress' ) );
|
130 |
} else {
|
135 |
|
136 |
do_action( 'friends_screen_requests' );
|
137 |
|
138 |
+
bp_core_load_template( apply_filters( 'friends_template_requests', 'members/single/home' ) );
|
|
|
|
|
|
|
|
|
|
|
139 |
}
|
140 |
|
141 |
function friends_screen_notification_settings() {
|
267 |
|
268 |
$defaults = array(
|
269 |
'user_id' => $bp->loggedin_user->id,
|
270 |
+
'action' => '',
|
271 |
+
'content' => '',
|
272 |
+
'primary_link' => '',
|
273 |
+
'component' => $bp->friends->id,
|
274 |
+
'type' => false,
|
275 |
'item_id' => false,
|
276 |
'secondary_item_id' => false,
|
277 |
+
'recorded_time' => gmdate( "Y-m-d H:i:s" ),
|
278 |
'hide_sitewide' => false
|
279 |
);
|
280 |
|
281 |
$r = wp_parse_args( $args, $defaults );
|
282 |
extract( $r, EXTR_SKIP );
|
283 |
|
284 |
+
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 ) );
|
285 |
}
|
286 |
|
287 |
function friends_delete_activity( $args ) {
|
288 |
if ( function_exists('bp_activity_delete_by_item_id') ) {
|
289 |
extract( (array)$args );
|
290 |
+
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 ) );
|
291 |
}
|
292 |
}
|
293 |
|
301 |
|
302 |
do_action( 'friends_register_activity_actions' );
|
303 |
}
|
304 |
+
add_action( 'bp_register_activity_actions', 'friends_register_activity_actions' );
|
305 |
|
306 |
function friends_format_notifications( $action, $item_id, $secondary_item_id, $total_items ) {
|
307 |
global $bp;
|
312 |
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 );
|
313 |
} else {
|
314 |
$user_fullname = bp_core_get_user_displayname( $item_id );
|
315 |
+
$user_url = bp_core_get_user_domain( $item_id );
|
316 |
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 );
|
317 |
}
|
318 |
break;
|
322 |
return apply_filters( 'bp_friends_multiple_friendship_request_notification', '<a href="' . $bp->loggedin_user->domain . $bp->friends->slug . '/requests" title="' . __( 'Friendship requests', 'buddypress' ) . '">' . sprintf( __('You have %d pending friendship requests', 'buddypress' ), (int)$total_items ) . '</a>', $total_items );
|
323 |
} else {
|
324 |
$user_fullname = bp_core_get_user_displayname( $item_id );
|
325 |
+
$user_url = bp_core_get_user_domain( $item_id );
|
326 |
return apply_filters( 'bp_friends_single_friendship_request_notification', '<a href="' . $bp->loggedin_user->domain . $bp->friends->slug . '/requests" title="' . __( 'Friendship requests', 'buddypress' ) . '">' . sprintf( __('You have a friendship request from %s', 'buddypress' ), $user_fullname ) . '</a>', $user_fullname );
|
327 |
}
|
328 |
break;
|
343 |
* true or false on success or failure.
|
344 |
*/
|
345 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
346 |
function friends_add_friend( $initiator_userid, $friend_userid, $force_accept = false ) {
|
347 |
global $bp;
|
348 |
|
388 |
$friendship = new BP_Friends_Friendship( $friendship_id );
|
389 |
|
390 |
// Remove the activity stream item for the user who canceled the friendship
|
391 |
+
friends_delete_activity( array( 'item_id' => $friendship_id, 'type' => 'friendship_accepted', 'user_id' => $bp->displayed_user->id ) );
|
392 |
|
393 |
do_action( 'friends_friendship_deleted', $friendship_id, $initiator_userid, $friend_userid );
|
394 |
|
418 |
$initiator_link = bp_core_get_userlink( $friendship->initiator_user_id );
|
419 |
$friend_link = bp_core_get_userlink( $friendship->friend_user_id );
|
420 |
|
|
|
|
|
421 |
/* Record in activity streams for the initiator */
|
422 |
friends_record_activity( array(
|
423 |
'user_id' => $friendship->initiator_user_id,
|
424 |
+
'type' => 'friendship_created',
|
425 |
+
'action' => apply_filters( 'friends_activity_friendship_accepted_action', sprintf( __( '%s and %s are now friends', 'buddypress' ), $initiator_link, $friend_link ), &$friendship ),
|
|
|
426 |
'item_id' => $friendship_id
|
427 |
) );
|
428 |
|
429 |
/* Record in activity streams for the friend */
|
430 |
friends_record_activity( array(
|
431 |
'user_id' => $friendship->friend_user_id,
|
432 |
+
'type' => 'friendship_created',
|
433 |
+
'action' => apply_filters( 'friends_activity_friendship_accepted_action', sprintf( __( '%s and %s are now friends', 'buddypress' ), $friend_link, $initiator_link ), &$friendship ),
|
|
|
434 |
'item_id' => $friendship_id,
|
435 |
'hide_sitewide' => true /* We've already got the first entry site wide */
|
436 |
) );
|
440 |
friends_notification_accepted_request( $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id );
|
441 |
|
442 |
do_action( 'friends_friendship_accepted', $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id );
|
|
|
443 |
return true;
|
444 |
}
|
445 |
|
460 |
return false;
|
461 |
}
|
462 |
|
463 |
+
function friends_check_friendship( $user_id, $possible_friend_id ) {
|
464 |
+
global $bp;
|
465 |
+
|
466 |
+
if ( 'is_friend' == BP_Friends_Friendship::check_is_friend( $user_id, $possible_friend_id ) )
|
467 |
+
return true;
|
468 |
+
|
469 |
+
return false;
|
470 |
+
}
|
471 |
+
|
472 |
+
function friends_check_friendship_status( $user_id, $possible_friend_id ) {
|
473 |
+
/* Returns - 'is_friend', 'not_friends', 'pending' */
|
474 |
+
return BP_Friends_Friendship::check_is_friend( $user_id, $possible_friend_id );
|
475 |
+
}
|
476 |
+
|
477 |
+
function friends_get_total_friend_count( $user_id = false ) {
|
478 |
+
global $bp;
|
479 |
+
|
480 |
+
if ( !$user_id )
|
481 |
+
$user_id = ( $bp->displayed_user->id ) ? $bp->displayed_user->id : $bp->loggedin_user->id;
|
482 |
+
|
483 |
+
if ( !$count = wp_cache_get( 'bp_total_friend_count_' . $user_id, 'bp' ) ) {
|
484 |
+
$count = get_usermeta( $user_id, 'total_friend_count' );
|
485 |
+
if ( empty( $count ) ) $count = 0;
|
486 |
+
wp_cache_set( 'bp_total_friend_count_' . $user_id, $count, 'bp' );
|
487 |
+
}
|
488 |
+
|
489 |
+
return apply_filters( 'friends_get_total_friend_count', $count );
|
490 |
+
}
|
491 |
+
|
492 |
+
function friends_check_user_has_friends( $user_id ) {
|
493 |
+
$friend_count = friends_get_total_friend_count( $user_id );
|
494 |
+
|
495 |
+
if ( empty( $friend_count ) )
|
496 |
+
return false;
|
497 |
+
|
498 |
+
if ( !(int)$friend_count )
|
499 |
+
return false;
|
500 |
+
|
501 |
+
return true;
|
502 |
+
}
|
503 |
+
|
504 |
+
function friends_get_friendship_id( $initiator_user_id, $friend_user_id ) {
|
505 |
+
return BP_Friends_Friendship::get_friendship_id( $initiator_user_id, $friend_user_id );
|
506 |
+
}
|
507 |
+
|
508 |
+
function friends_get_friend_user_ids( $user_id, $friend_requests_only = false, $assoc_arr = false, $filter = false ) {
|
509 |
+
return BP_Friends_Friendship::get_friend_user_ids( $user_id, $friend_requests_only, $assoc_arr, $filter );
|
510 |
+
}
|
511 |
+
|
512 |
+
function friends_search_friends( $search_terms, $user_id, $pag_num = 10, $pag_page = 1 ) {
|
513 |
+
return BP_Friends_Friendship::search_friends( $search_terms, $user_id, $pag_num, $pag_page );
|
514 |
+
}
|
515 |
+
|
516 |
+
function friends_get_friendship_request_user_ids( $user_id ) {
|
517 |
+
return BP_Friends_Friendship::get_friendship_request_user_ids( $user_id );
|
518 |
+
}
|
519 |
+
|
520 |
+
function friends_get_recently_active( $user_id, $per_page = false, $page = false, $filter = false ) {
|
521 |
+
return apply_filters( 'friends_get_recently_active', BP_Core_User::get_users( 'active', $per_page, $page, $user_id, $filter ) );
|
522 |
+
}
|
523 |
+
|
524 |
+
function friends_get_alphabetically( $user_id, $per_page = false, $page = false, $filter = false ) {
|
525 |
+
return apply_filters( 'friends_get_alphabetically', BP_Core_User::get_users( 'alphabetical', $per_page, $page, $user_id, $filter ) );
|
526 |
+
}
|
527 |
+
|
528 |
+
function friends_get_newest( $user_id, $per_page = false, $page = false, $filter = false ) {
|
529 |
+
return apply_filters( 'friends_get_newest', BP_Core_User::get_users( 'newest', $per_page, $page, $user_id, $filter ) );
|
530 |
+
}
|
531 |
+
|
532 |
+
function friends_get_bulk_last_active( $friend_ids ) {
|
533 |
+
return BP_Friends_Friendship::get_bulk_last_active( $friend_ids );
|
534 |
+
}
|
535 |
+
|
536 |
+
function friends_get_friends_invite_list( $user_id = false ) {
|
537 |
+
global $bp;
|
538 |
+
|
539 |
+
if ( !$user_id )
|
540 |
+
$user_id = $bp->loggedin_user->id;
|
541 |
+
|
542 |
+
if ( bp_has_members( 'user_id=' . $user_id . '&type=alphabetical&per_page=0' ) ) {
|
543 |
+
while ( bp_members() ) : bp_the_member();
|
544 |
+
$friends[] = array(
|
545 |
+
'id' => bp_get_member_user_id(),
|
546 |
+
'full_name' => bp_get_member_name()
|
547 |
+
);
|
548 |
+
endwhile;
|
549 |
+
}
|
550 |
+
|
551 |
+
if ( empty($friends) )
|
552 |
+
return false;
|
553 |
+
|
554 |
+
return $friends;
|
555 |
+
}
|
556 |
+
|
557 |
+
function friends_count_invitable_friends( $user_id, $group_id ) {
|
558 |
+
return BP_Friends_Friendship::get_invitable_friend_count( $user_id, $group_id );
|
559 |
+
}
|
560 |
+
|
561 |
+
function friends_get_friend_count_for_user( $user_id ) {
|
562 |
+
return BP_Friends_Friendship::total_friend_count( $user_id );
|
563 |
+
}
|
564 |
+
|
565 |
+
function friends_search_users( $search_terms, $user_id, $pag_num = false, $pag_page = false ) {
|
566 |
+
global $bp;
|
567 |
+
|
568 |
+
$user_ids = BP_Friends_Friendship::search_users( $search_terms, $user_id, $pag_num, $pag_page );
|
569 |
+
|
570 |
+
if ( !$user_ids )
|
571 |
+
return false;
|
572 |
+
|
573 |
+
for ( $i = 0; $i < count($user_ids); $i++ ) {
|
574 |
+
$users[] = new BP_Core_User($user_ids[$i]);
|
575 |
+
}
|
576 |
+
|
577 |
+
return array( 'users' => $users, 'count' => BP_Friends_Friendship::search_users_count($search_terms) );
|
578 |
+
}
|
579 |
+
|
580 |
function friends_is_friendship_confirmed( $friendship_id ) {
|
581 |
$friendship = new BP_Friends_Friendship( $friendship_id );
|
582 |
return $friendship->is_confirmed;
|
607 |
add_action( 'delete_user', 'friends_remove_data', 1 );
|
608 |
add_action( 'make_spam_user', 'friends_remove_data', 1 );
|
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 |
wp_cache_delete( 'popular_users', 'bp' );
|
627 |
|
628 |
/* Clear the sitewide activity cache */
|
629 |
wp_cache_delete( 'sitewide_activity', 'bp' );
|
630 |
}
|
631 |
|
632 |
+
function friends_clear_friend_notifications() {
|
633 |
+
global $bp;
|
634 |
+
|
635 |
+
if ( isset($_GET['new']) )
|
636 |
+
bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, 'friends', 'friendship_accepted' );
|
637 |
+
}
|
638 |
+
add_action( 'bp_activity_screen_my_activity', 'friends_clear_friend_notifications' );
|
639 |
+
|
640 |
// List actions to clear object caches on
|
641 |
add_action( 'friends_friendship_accepted', 'friends_clear_friend_object_cache' );
|
642 |
add_action( 'friends_friendship_deleted', 'friends_clear_friend_object_cache' );
|
bp-friends/bp-friends-classes.php
CHANGED
@@ -103,31 +103,23 @@ class BP_Friends_Friendship {
|
|
103 |
return $fids;
|
104 |
}
|
105 |
|
106 |
-
function
|
107 |
global $wpdb, $bp;
|
108 |
|
109 |
-
|
110 |
-
$oc_sql = $wpdb->prepare( "AND is_confirmed = 0" );
|
111 |
-
$friend_sql = $wpdb->prepare ( " WHERE friend_user_id = %d", $user_id );
|
112 |
-
} else {
|
113 |
-
$oc_sql = $wpdb->prepare( "AND is_confirmed = 1" );
|
114 |
-
$friend_sql = $wpdb->prepare ( " WHERE (initiator_user_id = %d OR friend_user_id = %d)", $user_id, $user_id );
|
115 |
-
}
|
116 |
-
|
117 |
-
return $wpdb->get_col( $wpdb->prepare( "SELECT id FROM {$bp->friends->table_name} $friend_sql $oc_sql" ) );
|
118 |
}
|
119 |
|
120 |
-
function
|
121 |
global $wpdb, $bp;
|
122 |
|
123 |
-
return $wpdb->
|
124 |
}
|
125 |
|
126 |
-
function total_friend_count( $user_id = false) {
|
127 |
global $wpdb, $bp;
|
128 |
|
129 |
if ( !$user_id )
|
130 |
-
$user_id = $bp->displayed_user->id;
|
131 |
|
132 |
/* This is stored in 'total_friend_count' usermeta.
|
133 |
This function will recalculate, update and return. */
|
@@ -165,11 +157,11 @@ class BP_Friends_Friendship {
|
|
165 |
|
166 |
// filter the user_ids based on the search criteria.
|
167 |
if ( function_exists('xprofile_install') ) {
|
168 |
-
$sql =
|
169 |
-
$total_sql =
|
170 |
} else {
|
171 |
-
$sql =
|
172 |
-
$total_sql =
|
173 |
}
|
174 |
|
175 |
$filtered_friend_ids = $wpdb->get_col($sql);
|
@@ -222,6 +214,7 @@ class BP_Friends_Friendship {
|
|
222 |
global $wpdb, $bp;
|
223 |
|
224 |
$filter = like_escape( $wpdb->escape( $filter ) );
|
|
|
225 |
$usermeta_table = $wpdb->base_prefix . 'usermeta';
|
226 |
$users_table = $wpdb->base_prefix . 'users';
|
227 |
|
@@ -247,6 +240,7 @@ class BP_Friends_Friendship {
|
|
247 |
global $wpdb, $bp;
|
248 |
|
249 |
$filter = like_escape( $wpdb->escape( $filter ) );
|
|
|
250 |
$usermeta_table = $wpdb->prefix . 'usermeta';
|
251 |
$users_table = $wpdb->base_prefix . 'users';
|
252 |
|
@@ -327,6 +321,4 @@ class BP_Friends_Friendship {
|
|
327 |
}
|
328 |
}
|
329 |
|
330 |
-
|
331 |
-
|
332 |
?>
|
103 |
return $fids;
|
104 |
}
|
105 |
|
106 |
+
function get_friendship_id( $user_id, $friend_id ) {
|
107 |
global $wpdb, $bp;
|
108 |
|
109 |
+
return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->friends->table_name} WHERE ( initiator_user_id = %d AND friend_user_id = %d ) OR ( initiator_user_id = %d AND friend_user_id = %d ) AND is_confirmed = 1", $user_id, $friend_id, $friend_id, $user_id ) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
}
|
111 |
|
112 |
+
function get_friendship_request_user_ids( $user_id ) {
|
113 |
global $wpdb, $bp;
|
114 |
|
115 |
+
return $wpdb->get_col( $wpdb->prepare( "SELECT initiator_user_id FROM {$bp->friends->table_name} WHERE friend_user_id = %d AND is_confirmed = 0", $user_id ) );
|
116 |
}
|
117 |
|
118 |
+
function total_friend_count( $user_id = false ) {
|
119 |
global $wpdb, $bp;
|
120 |
|
121 |
if ( !$user_id )
|
122 |
+
$user_id = ( $bp->displayed_user->id ) ? $bp->displayed_user->id : $bp->loggedin_user->id;
|
123 |
|
124 |
/* This is stored in 'total_friend_count' usermeta.
|
125 |
This function will recalculate, update and return. */
|
157 |
|
158 |
// filter the user_ids based on the search criteria.
|
159 |
if ( function_exists('xprofile_install') ) {
|
160 |
+
$sql = "SELECT DISTINCT user_id FROM {$bp->profile->table_name_data} WHERE user_id IN ($fids) AND value LIKE '$filter%%' {$pag_sql}";
|
161 |
+
$total_sql = "SELECT COUNT(DISTINCT user_id) FROM {$bp->profile->table_name_data} WHERE user_id IN ($fids) AND value LIKE '$filter%%'";
|
162 |
} else {
|
163 |
+
$sql = "SELECT DISTINCT user_id FROM " . CUSTOM_USER_META_TABLE . " WHERE user_id IN ($fids) AND meta_key = 'nickname' AND meta_value LIKE '$filter%%' {$pag_sql}";
|
164 |
+
$total_sql = "SELECT COUNT(DISTINCT user_id) FROM " . CUSTOM_USER_META_TABLE . " WHERE user_id IN ($fids) AND meta_key = 'nickname' AND meta_value LIKE '$filter%%'";
|
165 |
}
|
166 |
|
167 |
$filtered_friend_ids = $wpdb->get_col($sql);
|
214 |
global $wpdb, $bp;
|
215 |
|
216 |
$filter = like_escape( $wpdb->escape( $filter ) );
|
217 |
+
|
218 |
$usermeta_table = $wpdb->base_prefix . 'usermeta';
|
219 |
$users_table = $wpdb->base_prefix . 'users';
|
220 |
|
240 |
global $wpdb, $bp;
|
241 |
|
242 |
$filter = like_escape( $wpdb->escape( $filter ) );
|
243 |
+
|
244 |
$usermeta_table = $wpdb->prefix . 'usermeta';
|
245 |
$users_table = $wpdb->base_prefix . 'users';
|
246 |
|
321 |
}
|
322 |
}
|
323 |
|
|
|
|
|
324 |
?>
|
bp-friends/bp-friends-notifications.php
CHANGED
@@ -11,8 +11,8 @@ function friends_notification_new_request( $friendship_id, $initiator_id, $frien
|
|
11 |
$ud = get_userdata( $friend_id );
|
12 |
$initiator_ud = get_userdata( $initiator_id );
|
13 |
|
14 |
-
$all_requests_link = bp_core_get_user_domain( $friend_id ) . '
|
15 |
-
$settings_link = bp_core_get_user_domain( $friend_id ) .
|
16 |
|
17 |
$initiator_link = bp_core_get_user_domain( $initiator_id );
|
18 |
|
@@ -32,11 +32,14 @@ To view %s's profile: %s
|
|
32 |
|
33 |
$message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
|
34 |
|
35 |
-
|
|
|
|
|
|
|
|
|
36 |
wp_mail( $to, $subject, $message );
|
37 |
}
|
38 |
|
39 |
-
|
40 |
function friends_notification_accepted_request( $friendship_id, $initiator_id, $friend_id ) {
|
41 |
global $bp;
|
42 |
|
@@ -50,7 +53,7 @@ function friends_notification_accepted_request( $friendship_id, $initiator_id, $
|
|
50 |
$ud = get_userdata( $initiator_id );
|
51 |
|
52 |
$friend_link = bp_core_get_user_domain( $friend_id );
|
53 |
-
$settings_link = bp_core_get_user_domain( $initiator_id ) .
|
54 |
|
55 |
// Set up and send the message
|
56 |
$to = $ud->user_email;
|
@@ -66,9 +69,12 @@ To view %s\'s profile: %s
|
|
66 |
|
67 |
$message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
|
68 |
|
69 |
-
|
|
|
|
|
|
|
|
|
70 |
wp_mail( $to, $subject, $message );
|
71 |
}
|
72 |
|
73 |
-
|
74 |
?>
|
11 |
$ud = get_userdata( $friend_id );
|
12 |
$initiator_ud = get_userdata( $initiator_id );
|
13 |
|
14 |
+
$all_requests_link = bp_core_get_user_domain( $friend_id ) . BP_FRIENDS_SLUG . '/requests/';
|
15 |
+
$settings_link = bp_core_get_user_domain( $friend_id ) . BP_SETTINGS_SLUG . '/notifications';
|
16 |
|
17 |
$initiator_link = bp_core_get_user_domain( $initiator_id );
|
18 |
|
32 |
|
33 |
$message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
|
34 |
|
35 |
+
/* Send the message */
|
36 |
+
$to = apply_filters( 'friends_notification_new_request_to', $to );
|
37 |
+
$subject = apply_filters( 'friends_notification_new_request_subject', $subject, $initiator_name );
|
38 |
+
$message = apply_filters( 'friends_notification_new_request_message', $message, $initiator_name, $initiator_link, $all_requests_link );
|
39 |
+
|
40 |
wp_mail( $to, $subject, $message );
|
41 |
}
|
42 |
|
|
|
43 |
function friends_notification_accepted_request( $friendship_id, $initiator_id, $friend_id ) {
|
44 |
global $bp;
|
45 |
|
53 |
$ud = get_userdata( $initiator_id );
|
54 |
|
55 |
$friend_link = bp_core_get_user_domain( $friend_id );
|
56 |
+
$settings_link = bp_core_get_user_domain( $initiator_id ) . BP_SETTINGS_SLUG . '/notifications';
|
57 |
|
58 |
// Set up and send the message
|
59 |
$to = $ud->user_email;
|
69 |
|
70 |
$message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
|
71 |
|
72 |
+
/* Send the message */
|
73 |
+
$to = apply_filters( 'friends_notification_accepted_request_to', $to );
|
74 |
+
$subject = apply_filters( 'friends_notification_accepted_request_subject', $subject, $friend_name );
|
75 |
+
$message = apply_filters( 'friends_notification_accepted_request_message', $message, $friend_name, $friend_link );
|
76 |
+
|
77 |
wp_mail( $to, $subject, $message );
|
78 |
}
|
79 |
|
|
|
80 |
?>
|
bp-friends/bp-friends-templatetags.php
CHANGED
@@ -1,381 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
class BP_Friendship_Template {
|
4 |
-
var $current_friendship = -1;
|
5 |
-
var $friendship_count;
|
6 |
-
var $friendships;
|
7 |
-
var $friendship;
|
8 |
-
|
9 |
-
var $in_the_loop;
|
10 |
-
|
11 |
-
var $pag_page;
|
12 |
-
var $pag_num;
|
13 |
-
var $pag_links;
|
14 |
-
var $total_friend_count;
|
15 |
-
|
16 |
-
function bp_friendship_template( $user_id, $type, $per_page, $max, $filter ) {
|
17 |
-
global $bp;
|
18 |
-
|
19 |
-
if ( !$user_id )
|
20 |
-
$user_id = $bp->displayed_user->id;
|
21 |
-
|
22 |
-
$this->pag_page = isset( $_REQUEST['frpage'] ) ? intval( $_REQUEST['frpage'] ) : 1;
|
23 |
-
$this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
|
24 |
-
$this->type = $type;
|
25 |
-
|
26 |
-
switch ( $type ) {
|
27 |
-
case 'newest':
|
28 |
-
$this->friendships = friends_get_newest( $user_id, $this->pag_num, $this->pag_page, $filter );
|
29 |
-
break;
|
30 |
-
|
31 |
-
case 'alphabetical':
|
32 |
-
$this->friendships = friends_get_alphabetically( $user_id, $this->pag_num, $this->pag_page, $filter );
|
33 |
-
break;
|
34 |
-
|
35 |
-
case 'requests':
|
36 |
-
$this->friendships = friends_get_friendship_requests( $user_id );
|
37 |
-
break;
|
38 |
-
|
39 |
-
case 'active': default:
|
40 |
-
$this->friendships = friends_get_recently_active( $user_id, $this->pag_num, $this->pag_page, $filter );
|
41 |
-
break;
|
42 |
-
}
|
43 |
-
|
44 |
-
if ( 'requests' == $type ) {
|
45 |
-
$this->total_friend_count = $this->friendships['total'];
|
46 |
-
$this->friendships = $this->friendships['requests'];
|
47 |
-
$this->friendship_count = count($this->friendships);
|
48 |
-
} else {
|
49 |
-
if ( !$max || $max >= (int)$this->friendships['total'] )
|
50 |
-
$this->total_friend_count = (int)$this->friendships['total'];
|
51 |
-
else
|
52 |
-
$this->total_friend_count = (int)$max;
|
53 |
-
|
54 |
-
$this->friendships = $this->friendships['friends'];
|
55 |
-
|
56 |
-
if ( $max ) {
|
57 |
-
if ( $max >= count($this->friendships) )
|
58 |
-
$this->friendship_count = count($this->friendships);
|
59 |
-
else
|
60 |
-
$this->friendship_count = (int)$max;
|
61 |
-
} else {
|
62 |
-
$this->friendship_count = count($this->friendships);
|
63 |
-
}
|
64 |
-
}
|
65 |
-
|
66 |
-
$this->pag_links = paginate_links( array(
|
67 |
-
'base' => add_query_arg( 'frpage', '%#%' ),
|
68 |
-
'format' => '',
|
69 |
-
'total' => ceil($this->total_friend_count / $this->pag_num),
|
70 |
-
'current' => $this->pag_page,
|
71 |
-
'prev_text' => '«',
|
72 |
-
'next_text' => '»',
|
73 |
-
'mid_size' => 1
|
74 |
-
));
|
75 |
-
}
|
76 |
-
|
77 |
-
function has_friendships() {
|
78 |
-
if ( $this->friendship_count )
|
79 |
-
return true;
|
80 |
-
|
81 |
-
return false;
|
82 |
-
}
|
83 |
-
|
84 |
-
function next_friendship() {
|
85 |
-
$this->current_friendship++;
|
86 |
-
$this->friendship = $this->friendships[$this->current_friendship];
|
87 |
-
|
88 |
-
return $this->friendship;
|
89 |
-
}
|
90 |
-
|
91 |
-
function rewind_friendships() {
|
92 |
-
$this->current_friendship = -1;
|
93 |
-
if ( $this->friendship_count > 0 ) {
|
94 |
-
$this->friendship = $this->friendships[0];
|
95 |
-
}
|
96 |
-
}
|
97 |
-
|
98 |
-
function user_friendships() {
|
99 |
-
if ( $this->current_friendship + 1 < $this->friendship_count ) {
|
100 |
-
return true;
|
101 |
-
} elseif ( $this->current_friendship + 1 == $this->friendship_count ) {
|
102 |
-
do_action('loop_end');
|
103 |
-
// Do some cleaning up after the loop
|
104 |
-
$this->rewind_friendships();
|
105 |
-
}
|
106 |
-
|
107 |
-
$this->in_the_loop = false;
|
108 |
-
return false;
|
109 |
-
}
|
110 |
-
|
111 |
-
function the_friendship() {
|
112 |
-
global $friendship, $bp;
|
113 |
-
|
114 |
-
$this->in_the_loop = true;
|
115 |
-
$this->friendship = $this->next_friendship();
|
116 |
-
|
117 |
-
if ( 'requests' == $this->type ) {
|
118 |
-
$this->friendship = new BP_Friends_Friendship( $this->friendship );
|
119 |
-
$this->friendship->user_id = ( $this->friendship->friend_user_id == $bp->loggedin_user->id ) ? $this->friendship->initiator_user_id : $this->friendship->friend_user_id;
|
120 |
-
} else {
|
121 |
-
if ( 'newest' == $this->type )
|
122 |
-
$user_id = $this->friendship;
|
123 |
-
else
|
124 |
-
$user_id = $this->friendship->user_id;
|
125 |
-
|
126 |
-
$this->friendship = new stdClass;
|
127 |
-
|
128 |
-
if ( !$this->friendship->friend = wp_cache_get( 'bp_user_' . $user_id, 'bp' ) ) {
|
129 |
-
$this->friendship->friend = new BP_Core_User( $user_id );
|
130 |
-
wp_cache_set( 'bp_user_' . $user_id, $this->friendship->friend, 'bp' );
|
131 |
-
}
|
132 |
-
|
133 |
-
/* Make sure the user_id is available in the friend object. */
|
134 |
-
$this->friendship->friend->user_id = $user_id;
|
135 |
-
}
|
136 |
-
|
137 |
-
if ( 0 == $this->current_friendship ) // loop has just started
|
138 |
-
do_action('loop_start');
|
139 |
-
}
|
140 |
-
}
|
141 |
-
|
142 |
-
function bp_has_friendships( $args = '' ) {
|
143 |
-
global $bp, $friends_template;
|
144 |
-
|
145 |
-
$defaults = array(
|
146 |
-
'type' => 'active',
|
147 |
-
'user_id' => false,
|
148 |
-
'per_page' => 10,
|
149 |
-
'max' => false,
|
150 |
-
'filter' => false
|
151 |
-
);
|
152 |
-
|
153 |
-
$r = wp_parse_args( $args, $defaults );
|
154 |
-
extract( $r, EXTR_SKIP );
|
155 |
-
|
156 |
-
/* The following code will auto set parameters based on the page being viewed.
|
157 |
-
* for example on example.com/members/andy/friends/my-friends/newest/
|
158 |
-
* $type = 'newest'
|
159 |
-
*/
|
160 |
-
if ( 'my-friends' == $bp->current_action ) {
|
161 |
-
$order = $bp->action_variables[0];
|
162 |
-
if ( 'newest' == $order )
|
163 |
-
$type = 'newest';
|
164 |
-
else if ( 'alphabetically' == $order )
|
165 |
-
$type = 'alphabetical';
|
166 |
-
} else if ( 'requests' == $bp->current_action ) {
|
167 |
-
$type = 'requests';
|
168 |
-
}
|
169 |
-
|
170 |
-
if ( isset( $_REQUEST['friend-search-box'] ) )
|
171 |
-
$filter = $_REQUEST['friend-search-box'];
|
172 |
-
|
173 |
-
$friends_template = new BP_Friendship_Template( $user_id, $type, $per_page, $max, $filter );
|
174 |
-
return apply_filters( 'bp_has_friendships', $friends_template->has_friendships(), &$friends_template );
|
175 |
-
}
|
176 |
-
|
177 |
-
function bp_the_friendship() {
|
178 |
-
global $friends_template;
|
179 |
-
return $friends_template->the_friendship();
|
180 |
-
}
|
181 |
-
|
182 |
-
function bp_user_friendships() {
|
183 |
-
global $friends_template;
|
184 |
-
return $friends_template->user_friendships();
|
185 |
-
}
|
186 |
-
|
187 |
-
function bp_friend_id() {
|
188 |
-
echo bp_get_friend_id();
|
189 |
-
}
|
190 |
-
function bp_get_friend_id() {
|
191 |
-
global $friends_template;
|
192 |
-
|
193 |
-
return apply_filters( 'bp_get_friend_id', $friends_template->friendship->friend->user_id );
|
194 |
-
}
|
195 |
-
|
196 |
-
function bp_friend_avatar_thumb() {
|
197 |
-
echo bp_get_friend_avatar_thumb();
|
198 |
-
}
|
199 |
-
function bp_get_friend_avatar_thumb() {
|
200 |
-
global $friends_template;
|
201 |
-
|
202 |
-
return apply_filters( 'bp_get_friend_avatar_thumb', $friends_template->friendship->friend->avatar_thumb );
|
203 |
-
}
|
204 |
-
|
205 |
-
function bp_friend_name() {
|
206 |
-
echo bp_get_friend_name();
|
207 |
-
}
|
208 |
-
function bp_get_friend_name() {
|
209 |
-
global $friends_template;
|
210 |
-
|
211 |
-
return apply_filters( 'bp_get_friend_name', strip_tags( $friends_template->friendship->friend->user_link ) );
|
212 |
-
}
|
213 |
-
|
214 |
-
function bp_friend_link() {
|
215 |
-
echo bp_get_friend_link();
|
216 |
-
}
|
217 |
-
function bp_get_friend_link() {
|
218 |
-
global $friends_template;
|
219 |
-
|
220 |
-
return apply_filters( 'bp_get_friend_link', $friends_template->friendship->friend->user_link );
|
221 |
-
}
|
222 |
-
|
223 |
-
function bp_friend_url() {
|
224 |
-
echo bp_get_friend_url();
|
225 |
-
}
|
226 |
-
function bp_get_friend_url() {
|
227 |
-
global $friends_template;
|
228 |
-
|
229 |
-
return apply_filters( 'bp_get_friend_url', $friends_template->friendship->friend->user_url );
|
230 |
-
}
|
231 |
-
|
232 |
-
function bp_friend_last_active() {
|
233 |
-
echo bp_get_friend_last_active();
|
234 |
-
}
|
235 |
-
function bp_get_friend_last_active() {
|
236 |
-
global $friends_template;
|
237 |
-
|
238 |
-
return apply_filters( 'bp_get_friend_last_active', $friends_template->friendship->friend->last_active );
|
239 |
-
}
|
240 |
-
|
241 |
-
function bp_friend_time_since_requested() {
|
242 |
-
echo bp_get_friend_time_since_requested();
|
243 |
-
}
|
244 |
-
function bp_get_friend_time_since_requested() {
|
245 |
-
global $friends_template;
|
246 |
-
|
247 |
-
if ( $friends_template->friendship->date_created != "0000-00-00 00:00:00" ) {
|
248 |
-
return apply_filters( 'bp_friend_time_since_requested', sprintf( __( 'requested %s ago', 'buddypress' ), bp_core_time_since( strtotime( $friends_template->friendship->date_created ) ) ) );
|
249 |
-
}
|
250 |
-
|
251 |
-
return false;
|
252 |
-
}
|
253 |
-
|
254 |
-
function bp_friend_accept_request_link() {
|
255 |
-
echo bp_get_friend_accept_request_link();
|
256 |
-
}
|
257 |
-
function bp_get_friend_accept_request_link() {
|
258 |
-
global $friends_template, $bp;
|
259 |
-
|
260 |
-
return apply_filters( 'bp_get_friend_accept_request_link', wp_nonce_url( $bp->loggedin_user->domain . $bp->friends->slug . '/requests/accept/' . $friends_template->friendship->id, 'friends_accept_friendship' ) );
|
261 |
-
}
|
262 |
-
|
263 |
-
function bp_friend_reject_request_link() {
|
264 |
-
echo bp_get_friend_reject_request_link();
|
265 |
-
}
|
266 |
-
function bp_get_friend_reject_request_link() {
|
267 |
-
global $friends_template, $bp;
|
268 |
-
|
269 |
-
return apply_filters( 'bp_get_friend_reject_request_link', wp_nonce_url( $bp->loggedin_user->domain . $bp->friends->slug . '/requests/reject/' . $friends_template->friendship->id, 'friends_reject_friendship' ) );
|
270 |
-
}
|
271 |
-
|
272 |
-
function bp_friend_pagination() {
|
273 |
-
echo bp_get_friend_pagination();
|
274 |
-
}
|
275 |
-
function bp_get_friend_pagination() {
|
276 |
-
global $friends_template;
|
277 |
-
|
278 |
-
return apply_filters( 'bp_friend_pagination', $friends_template->pag_links );
|
279 |
-
}
|
280 |
-
|
281 |
-
function bp_friend_pagination_count() {
|
282 |
-
global $bp, $friends_template;
|
283 |
-
|
284 |
-
$from_num = intval( ( $friends_template->pag_page - 1 ) * $friends_template->pag_num ) + 1;
|
285 |
-
$to_num = ( $from_num + ( $friends_template->pag_num - 1 ) > $friends_template->total_friend_count ) ? $friends_template->total_friend_count : $from_num + ( $friends_template->pag_num - 1) ;
|
286 |
-
|
287 |
-
echo sprintf( __( 'Viewing friend %d to %d (of %d friends)', 'buddypress' ), $from_num, $to_num, $friends_template->total_friend_count ); ?>
|
288 |
-
<span class="ajax-loader"></span><?php
|
289 |
-
}
|
290 |
-
|
291 |
-
function bp_friend_total_for_member() {
|
292 |
-
echo bp_get_friend_total_for_member();
|
293 |
-
}
|
294 |
-
function bp_get_friend_total_for_member() {
|
295 |
-
return apply_filters( 'bp_get_friend_total_for_member', BP_Friends_Friendship::total_friend_count() );
|
296 |
-
}
|
297 |
-
|
298 |
-
function bp_friend_search_form() {
|
299 |
-
global $friends_template, $bp;
|
300 |
-
|
301 |
-
$action = $bp->displayed_user->domain . $bp->friends->slug . '/my-friends/search/';
|
302 |
-
$label = __( 'Filter Friends', 'buddypress' );
|
303 |
-
?>
|
304 |
-
<form action="<?php echo $action ?>" id="friend-search-form" method="post">
|
305 |
-
|
306 |
-
<label for="friend-search-box" id="friend-search-label"><?php echo $label ?></label>
|
307 |
-
<input type="search" name="friend-search-box" id="friend-search-box" value="<?php echo $value ?>"<?php echo $disabled ?> />
|
308 |
-
|
309 |
-
<?php wp_nonce_field( 'friends_search', '_wpnonce_friend_search' ) ?>
|
310 |
-
<input type="hidden" name="initiator" id="initiator" value="<?php echo attribute_escape( $bp->displayed_user->id ) ?>" />
|
311 |
-
|
312 |
-
</form>
|
313 |
-
<?php
|
314 |
-
}
|
315 |
-
|
316 |
-
function bp_friends_is_filtered() {
|
317 |
-
if ( isset( $_POST['friend-search-box'] ) )
|
318 |
-
return true;
|
319 |
-
|
320 |
-
return false;
|
321 |
-
}
|
322 |
-
|
323 |
-
function bp_friend_all_friends_link() {
|
324 |
-
global $bp;
|
325 |
-
echo apply_filters( 'bp_friend_all_friends_link', $bp->displayed_user->domain . 'my-friends/all-friends' );
|
326 |
-
}
|
327 |
-
|
328 |
-
function bp_friend_latest_update_link() {
|
329 |
-
global $bp;
|
330 |
-
echo apply_filters( 'bp_friend_latest_update_link', $bp->displayed_user->domain . 'my-friends/last-updated' );
|
331 |
-
}
|
332 |
-
|
333 |
-
function bp_friend_recent_activity_link() {
|
334 |
-
global $bp;
|
335 |
-
echo apply_filters( 'bp_friend_recent_activity_link', $bp->displayed_user->domain . 'my-friends/recently-active' );
|
336 |
-
}
|
337 |
-
|
338 |
-
function bp_friend_recent_status_link() {
|
339 |
-
global $bp;
|
340 |
-
echo apply_filters( 'bp_friend_recent_status_link', $bp->displayed_user->domain . 'my-friends/status-updates' );
|
341 |
-
}
|
342 |
-
|
343 |
-
function bp_add_friend_button( $potential_friend_id = false ) {
|
344 |
-
echo bp_get_add_friend_button( $potential_friend_id );
|
345 |
-
}
|
346 |
-
function bp_get_add_friend_button( $potential_friend_id = false ) {
|
347 |
-
global $bp, $friends_template;
|
348 |
-
|
349 |
-
$button = false;
|
350 |
-
|
351 |
-
if ( is_user_logged_in() ) {
|
352 |
-
|
353 |
-
if ( !$potential_friend_id && $friends_template->friendship->friend )
|
354 |
-
$potential_friend_id = $friends_template->friendship->friend->id;
|
355 |
-
else if ( !$potential_friend_id && !$friends_template->friendship->friend )
|
356 |
-
$potential_friend_id = $bp->displayed_user->id;
|
357 |
-
|
358 |
-
if ( $bp->loggedin_user->id == $potential_friend_id )
|
359 |
-
return false;
|
360 |
-
|
361 |
-
$friend_status = BP_Friends_Friendship::check_is_friend( $bp->loggedin_user->id, $potential_friend_id );
|
362 |
-
|
363 |
-
$button = '<div class="generic-button friendship-button ' . $friend_status . '" id="friendship-button-' . $potential_friend_id . '">';
|
364 |
-
if ( 'pending' == $friend_status ) {
|
365 |
-
$button .= '<a class="requested" href="' . $bp->loggedin_user->domain . $bp->friends->slug . '">' . __( 'Friendship Requested', 'buddypress' ) . '</a>';
|
366 |
-
} else if ( 'is_friend' == $friend_status ) {
|
367 |
-
$button .= '<a href="' . wp_nonce_url( $bp->loggedin_user->domain . $bp->friends->slug . '/remove-friend/' . $potential_friend_id, 'friends_remove_friend' ) . '" title="' . __('Cancel Friendship', 'buddypress') . '" id="friend-' . $potential_friend_id . '" rel="remove" class="remove">' . __('Cancel Friendship', 'buddypress') . '</a>';
|
368 |
-
} else {
|
369 |
-
$button .= '<a href="' . wp_nonce_url( $bp->loggedin_user->domain . $bp->friends->slug . '/add-friend/' . $potential_friend_id, 'friends_add_friend' ) . '" title="' . __('Add Friend', 'buddypress') . '" id="friend-' . $potential_friend_id . '" rel="add" class="add">' . __('Add Friend', 'buddypress') . '</a>';
|
370 |
-
}
|
371 |
-
$button .= '</div>';
|
372 |
-
}
|
373 |
-
|
374 |
-
return apply_filters( 'bp_get_add_friend_button', $button );
|
375 |
-
}
|
376 |
-
|
377 |
function bp_friends_header_tabs() {
|
378 |
-
global $bp
|
379 |
?>
|
380 |
<li<?php if ( !isset($bp->action_variables[0]) || 'recently-active' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->friends->slug ?>/my-friends/recently-active"><?php _e( 'Recently Active', 'buddypress' ) ?></a></li>
|
381 |
<li<?php if ( 'newest' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->friends->slug ?>/my-friends/newest"><?php _e( 'Newest', 'buddypress' ) ?></a></li>
|
@@ -411,13 +37,13 @@ function bp_friends_random_friends() {
|
|
411 |
}
|
412 |
?>
|
413 |
<div class="info-group">
|
414 |
-
<h4><?php bp_word_or_name( __( "My Friends", 'buddypress' ), __( "%s's Friends", 'buddypress' ) ) ?> (<?php echo BP_Friends_Friendship::total_friend_count( $bp->displayed_user->id ) ?>) <span><a href="<?php echo $bp->displayed_user->domain . $bp->friends->slug ?>"><?php _e('See All', 'buddypress') ?> &
|
415 |
|
416 |
<?php if ( $friend_ids ) { ?>
|
417 |
<ul class="horiz-gallery">
|
418 |
<?php for ( $i = 0; $i < count( $friend_ids ); $i++ ) { ?>
|
419 |
<li>
|
420 |
-
<a href="<?php echo
|
421 |
<h5><?php echo bp_core_get_userlink($friend_ids[$i]) ?></h5>
|
422 |
</li>
|
423 |
<?php } ?>
|
@@ -436,7 +62,7 @@ function bp_friends_random_members( $total_members = 5 ) {
|
|
436 |
global $bp;
|
437 |
|
438 |
if ( !$user_ids = wp_cache_get( 'friends_random_users', 'bp' ) ) {
|
439 |
-
$user_ids = BP_Core_User::
|
440 |
wp_cache_set( 'friends_random_users', $user_ids, 'bp' );
|
441 |
}
|
442 |
?>
|
@@ -444,8 +70,8 @@ function bp_friends_random_members( $total_members = 5 ) {
|
|
444 |
<ul class="item-list" id="random-members-list">
|
445 |
<?php for ( $i = 0; $i < count( $user_ids['users'] ); $i++ ) { ?>
|
446 |
<li>
|
447 |
-
<a href="<?php echo
|
448 |
-
<h5><?php echo bp_core_get_userlink($user_ids['users'][$i]->user_id) ?></h5>
|
449 |
<?php if ( function_exists( 'xprofile_get_random_profile_data' ) ) { ?>
|
450 |
<?php $random_data = xprofile_get_random_profile_data( $user_ids['users'][$i]->user_id, true ); ?>
|
451 |
<div class="profile-data">
|
@@ -470,4 +96,135 @@ function bp_friends_random_members( $total_members = 5 ) {
|
|
470 |
<?php
|
471 |
}
|
472 |
|
473 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<?php
|
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
function bp_friends_header_tabs() {
|
4 |
+
global $bp;
|
5 |
?>
|
6 |
<li<?php if ( !isset($bp->action_variables[0]) || 'recently-active' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->friends->slug ?>/my-friends/recently-active"><?php _e( 'Recently Active', 'buddypress' ) ?></a></li>
|
7 |
<li<?php if ( 'newest' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->friends->slug ?>/my-friends/newest"><?php _e( 'Newest', 'buddypress' ) ?></a></li>
|
37 |
}
|
38 |
?>
|
39 |
<div class="info-group">
|
40 |
+
<h4><?php bp_word_or_name( __( "My Friends", 'buddypress' ), __( "%s's Friends", 'buddypress' ) ) ?> (<?php echo BP_Friends_Friendship::total_friend_count( $bp->displayed_user->id ) ?>) <span><a href="<?php echo $bp->displayed_user->domain . $bp->friends->slug ?>"><?php _e('See All', 'buddypress') ?> →</a></span></h4>
|
41 |
|
42 |
<?php if ( $friend_ids ) { ?>
|
43 |
<ul class="horiz-gallery">
|
44 |
<?php for ( $i = 0; $i < count( $friend_ids ); $i++ ) { ?>
|
45 |
<li>
|
46 |
+
<a href="<?php echo bp_core_get_user_domain( $friend_ids[$i] ) ?>"><?php echo bp_core_fetch_avatar( array( 'item_id' => $friend_ids[$i], 'type' => 'thumb' ) ) ?></a>
|
47 |
<h5><?php echo bp_core_get_userlink($friend_ids[$i]) ?></h5>
|
48 |
</li>
|
49 |
<?php } ?>
|
62 |
global $bp;
|
63 |
|
64 |
if ( !$user_ids = wp_cache_get( 'friends_random_users', 'bp' ) ) {
|
65 |
+
$user_ids = BP_Core_User::get_users( 'random', $total_members );
|
66 |
wp_cache_set( 'friends_random_users', $user_ids, 'bp' );
|
67 |
}
|
68 |
?>
|
70 |
<ul class="item-list" id="random-members-list">
|
71 |
<?php for ( $i = 0; $i < count( $user_ids['users'] ); $i++ ) { ?>
|
72 |
<li>
|
73 |
+
<a href="<?php echo bp_core_get_user_domain( $user_ids['users'][$i]->user_id ) ?>"><?php echo bp_core_fetch_avatar( array( 'item_id' => $user_ids['users'][$i]->user_id, 'type' => 'thumb' ) ) ?></a>
|
74 |
+
<h5><?php echo bp_core_get_userlink( $user_ids['users'][$i]->user_id ) ?></h5>
|
75 |
<?php if ( function_exists( 'xprofile_get_random_profile_data' ) ) { ?>
|
76 |
<?php $random_data = xprofile_get_random_profile_data( $user_ids['users'][$i]->user_id, true ); ?>
|
77 |
<div class="profile-data">
|
96 |
<?php
|
97 |
}
|
98 |
|
99 |
+
function bp_friend_search_form() {
|
100 |
+
global $friends_template, $bp;
|
101 |
+
|
102 |
+
$action = $bp->displayed_user->domain . $bp->friends->slug . '/my-friends/search/';
|
103 |
+
$label = __( 'Filter Friends', 'buddypress' );
|
104 |
+
?>
|
105 |
+
<form action="<?php echo $action ?>" id="friend-search-form" method="post">
|
106 |
+
|
107 |
+
<label for="friend-search-box" id="friend-search-label"><?php echo $label ?></label>
|
108 |
+
<input type="search" name="friend-search-box" id="friend-search-box" value="<?php echo $value ?>"<?php echo $disabled ?> />
|
109 |
+
|
110 |
+
<?php wp_nonce_field( 'friends_search', '_wpnonce_friend_search' ) ?>
|
111 |
+
<input type="hidden" name="initiator" id="initiator" value="<?php echo attribute_escape( $bp->displayed_user->id ) ?>" />
|
112 |
+
|
113 |
+
</form>
|
114 |
+
<?php
|
115 |
+
}
|
116 |
+
|
117 |
+
function bp_add_friend_button( $potential_friend_id = false, $friend_status = false ) {
|
118 |
+
echo bp_get_add_friend_button( $potential_friend_id, $friend_status );
|
119 |
+
}
|
120 |
+
function bp_get_add_friend_button( $potential_friend_id = false, $friend_status = false ) {
|
121 |
+
global $bp, $friends_template;
|
122 |
+
|
123 |
+
if ( !is_user_logged_in() )
|
124 |
+
return false;
|
125 |
+
|
126 |
+
if ( !$potential_friend_id && $friends_template->friendship->friend )
|
127 |
+
$potential_friend_id = $friends_template->friendship->friend->id;
|
128 |
+
else if ( !$potential_friend_id && !$friends_template->friendship->friend )
|
129 |
+
$potential_friend_id = $bp->displayed_user->id;
|
130 |
+
|
131 |
+
if ( $bp->loggedin_user->id == $potential_friend_id )
|
132 |
+
return false;
|
133 |
+
|
134 |
+
if ( empty( $friend_status ) )
|
135 |
+
$friend_status = friends_check_friendship_status( $bp->loggedin_user->id, $potential_friend_id );
|
136 |
+
|
137 |
+
$button = '<div class="generic-button friendship-button ' . $friend_status . '" id="friendship-button-' . $potential_friend_id . '">';
|
138 |
+
if ( 'pending' == $friend_status ) {
|
139 |
+
$button .= '<a class="requested" href="' . $bp->loggedin_user->domain . $bp->friends->slug . '/">' . __( 'Friendship Requested', 'buddypress' ) . '</a>';
|
140 |
+
} else if ( 'is_friend' == $friend_status ) {
|
141 |
+
$button .= '<a href="' . wp_nonce_url( $bp->loggedin_user->domain . $bp->friends->slug . '/remove-friend/' . $potential_friend_id . '/', 'friends_remove_friend' ) . '" title="' . __('Cancel Friendship', 'buddypress') . '" id="friend-' . $potential_friend_id . '" rel="remove" class="remove">' . __('Cancel Friendship', 'buddypress') . '</a>';
|
142 |
+
} else {
|
143 |
+
$button .= '<a href="' . wp_nonce_url( $bp->loggedin_user->domain . $bp->friends->slug . '/add-friend/' . $potential_friend_id . '/', 'friends_add_friend' ) . '" title="' . __('Add Friend', 'buddypress') . '" id="friend-' . $potential_friend_id . '" rel="add" class="add">' . __('Add Friend', 'buddypress') . '</a>';
|
144 |
+
}
|
145 |
+
$button .= '</div>';
|
146 |
+
|
147 |
+
return apply_filters( 'bp_get_add_friend_button', $button );
|
148 |
+
}
|
149 |
+
|
150 |
+
function bp_get_friend_ids( $user_id = false ) {
|
151 |
+
global $bp;
|
152 |
+
|
153 |
+
if ( !$user_id )
|
154 |
+
$user_id = ( $bp->displayed_user->id ) ? $bp->displayed_user->id : $bp->loggedin_user->id;
|
155 |
+
|
156 |
+
$friend_ids = friends_get_friend_user_ids( $user_id );
|
157 |
+
|
158 |
+
if ( empty( $friend_ids ) )
|
159 |
+
return false;
|
160 |
+
|
161 |
+
return implode( ',', friends_get_friend_user_ids( $user_id ) );
|
162 |
+
}
|
163 |
+
function bp_get_friendship_requests() {
|
164 |
+
global $bp;
|
165 |
+
|
166 |
+
return apply_filters( 'bp_get_friendship_requests', implode( ',', (array) friends_get_friendship_request_user_ids( $bp->loggedin_user->id ) ) );
|
167 |
+
}
|
168 |
+
|
169 |
+
function bp_friend_friendship_id() {
|
170 |
+
echo bp_get_friend_friendship_id();
|
171 |
+
}
|
172 |
+
function bp_get_friend_friendship_id() {
|
173 |
+
global $members_template, $bp;
|
174 |
+
|
175 |
+
if ( !$friendship_id = wp_cache_get( 'friendship_id_' . $members_template->member->id . '_' . $bp->loggedin_user->id ) ) {
|
176 |
+
$friendship_id = friends_get_friendship_id( $members_template->member->id, $bp->loggedin_user->id );
|
177 |
+
wp_cache_set( 'friendship_id_' . $members_template->member->id . '_' . $bp->loggedin_user->id, $friendship_id, 'bp' );
|
178 |
+
}
|
179 |
+
|
180 |
+
return apply_filters( 'bp_get_friend_friendship_id', $friendship_id );
|
181 |
+
}
|
182 |
+
|
183 |
+
function bp_friend_accept_request_link() {
|
184 |
+
echo bp_get_friend_accept_request_link();
|
185 |
+
}
|
186 |
+
function bp_get_friend_accept_request_link() {
|
187 |
+
global $members_template, $bp;
|
188 |
+
|
189 |
+
if ( !$friendship_id = wp_cache_get( 'friendship_id_' . $members_template->member->id . '_' . $bp->loggedin_user->id ) ) {
|
190 |
+
$friendship_id = friends_get_friendship_id( $members_template->member->id, $bp->loggedin_user->id );
|
191 |
+
wp_cache_set( 'friendship_id_' . $members_template->member->id . '_' . $bp->loggedin_user->id, $friendship_id, 'bp' );
|
192 |
+
}
|
193 |
+
|
194 |
+
return apply_filters( 'bp_get_friend_accept_request_link', wp_nonce_url( $bp->loggedin_user->domain . $bp->friends->slug . '/requests/accept/' . $friendship_id, 'friends_accept_friendship' ) );
|
195 |
+
}
|
196 |
+
|
197 |
+
function bp_friend_reject_request_link() {
|
198 |
+
echo bp_get_friend_reject_request_link();
|
199 |
+
}
|
200 |
+
function bp_get_friend_reject_request_link() {
|
201 |
+
global $members_template, $bp;
|
202 |
+
|
203 |
+
if ( !$friendship_id = wp_cache_get( 'friendship_id_' . $members_template->member->id . '_' . $bp->loggedin_user->id ) ) {
|
204 |
+
$friendship_id = friends_get_friendship_id( $members_template->member->id, $bp->loggedin_user->id );
|
205 |
+
wp_cache_set( 'friendship_id_' . $members_template->member->id . '_' . $bp->loggedin_user->id, $friendship_id, 'bp' );
|
206 |
+
}
|
207 |
+
|
208 |
+
return apply_filters( 'bp_get_friend_reject_request_link', wp_nonce_url( $bp->loggedin_user->domain . $bp->friends->slug . '/requests/reject/' . $friendship_id, 'friends_reject_friendship' ) );
|
209 |
+
}
|
210 |
+
|
211 |
+
function bp_total_friend_count( $user_id = false ) {
|
212 |
+
echo bp_get_total_friend_count( $user_id );
|
213 |
+
}
|
214 |
+
function bp_get_total_friend_count( $user_id = false ) {
|
215 |
+
return apply_filters( 'bp_get_total_friend_count', friends_get_total_friend_count( $user_id ) );
|
216 |
+
}
|
217 |
+
add_filter( 'bp_get_total_friend_count', 'bp_core_number_format' );
|
218 |
+
|
219 |
+
function bp_friend_total_requests_count( $user_id = false ) {
|
220 |
+
echo bp_friend_get_total_requests_count( $user_id );
|
221 |
+
}
|
222 |
+
function bp_friend_get_total_requests_count( $user_id = false ) {
|
223 |
+
global $bp;
|
224 |
+
|
225 |
+
if ( !$user_id )
|
226 |
+
$user_id = $bp->loggedin_user->id;
|
227 |
+
|
228 |
+
return apply_filters( 'bp_friend_get_total_requests_count', (int) BP_Friends_Friendship::get_friend_user_ids( $user_id, true ) );
|
229 |
+
}
|
230 |
+
?>
|
bp-friends/deprecated/bp-friends-deprecated.php
DELETED
@@ -1,102 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/***
|
3 |
-
* Deprecated Friends Functionality
|
4 |
-
*
|
5 |
-
* This file contains functions that are deprecated.
|
6 |
-
* You should not under any circumstance use these functions as they are
|
7 |
-
* either no longer valid, or have been replaced with something much more awesome.
|
8 |
-
*
|
9 |
-
* If you are using functions in this file you should slap the back of your head
|
10 |
-
* and then use the functions or solutions that have replaced them.
|
11 |
-
* Most functions contain a note telling you what you should be doing or using instead.
|
12 |
-
*
|
13 |
-
* Of course, things will still work if you use these functions but you will
|
14 |
-
* be the laughing stock of the BuddyPress community. We will all point and laugh at
|
15 |
-
* you. You'll also be making things harder for yourself in the long run,
|
16 |
-
* and you will miss out on lovely performance and functionality improvements.
|
17 |
-
*
|
18 |
-
* If you've checked you are not using any deprecated functions and finished your little
|
19 |
-
* dance, you can add the following line to your wp-config.php file to prevent any of
|
20 |
-
* these old functions from being loaded:
|
21 |
-
*
|
22 |
-
* define( 'BP_IGNORE_DEPRECATED', true );
|
23 |
-
*/
|
24 |
-
function friends_deprecated_globals() {
|
25 |
-
global $bp;
|
26 |
-
|
27 |
-
/* If we are using a BuddyPress 1.1+ theme ignore this. */
|
28 |
-
if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
|
29 |
-
return $template;
|
30 |
-
|
31 |
-
$bp->groups->image_base = BP_PLUGIN_URL . '/bp-friends/deprecated/images';
|
32 |
-
}
|
33 |
-
add_action( 'plugins_loaded', 'friends_deprecated_globals', 5 );
|
34 |
-
add_action( 'admin_menu', 'friends_deprecated_globals', 2 );
|
35 |
-
|
36 |
-
function friends_add_js() {
|
37 |
-
global $bp;
|
38 |
-
|
39 |
-
/* If we are using a BuddyPress 1.1+ theme ignore this. */
|
40 |
-
if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
|
41 |
-
return $template;
|
42 |
-
|
43 |
-
if ( $bp->current_component == $bp->friends->slug )
|
44 |
-
wp_enqueue_script( 'bp-friends-js', BP_PLUGIN_URL . '/bp-friends/deprecated/js/general.js' );
|
45 |
-
}
|
46 |
-
add_action( 'template_redirect', 'friends_add_js', 1 );
|
47 |
-
|
48 |
-
function friends_add_structure_css() {
|
49 |
-
/* If we are using a BuddyPress 1.1+ theme ignore this. */
|
50 |
-
if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
|
51 |
-
return $template;
|
52 |
-
|
53 |
-
/* Enqueue the structure CSS file to give basic positional formatting for components */
|
54 |
-
wp_enqueue_style( 'bp-friends-structure', BP_PLUGIN_URL . '/bp-friends/deprecated/css/structure.css' );
|
55 |
-
}
|
56 |
-
add_action( 'bp_styles', 'friends_add_structure_css' );
|
57 |
-
|
58 |
-
function friends_ajax_friends_search() {
|
59 |
-
/* If we are using a BuddyPress 1.1+ theme ignore this. */
|
60 |
-
if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
|
61 |
-
return false;
|
62 |
-
|
63 |
-
check_ajax_referer( 'friends_search' );
|
64 |
-
|
65 |
-
load_template( get_template_directory() . '/friends/friends-loop.php' );
|
66 |
-
}
|
67 |
-
add_action( 'wp_ajax_friends_search', 'friends_ajax_friends_search' );
|
68 |
-
|
69 |
-
function friends_ajax_addremove_friend() {
|
70 |
-
global $bp;
|
71 |
-
|
72 |
-
/* If we are using a BuddyPress 1.1+ theme ignore this. */
|
73 |
-
if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
|
74 |
-
return false;
|
75 |
-
|
76 |
-
if ( 'is_friend' == BP_Friends_Friendship::check_is_friend( $bp->loggedin_user->id, $_POST['fid'] ) ) {
|
77 |
-
|
78 |
-
check_ajax_referer('friends_remove_friend');
|
79 |
-
|
80 |
-
if ( !friends_remove_friend( $bp->loggedin_user->id, $_POST['fid'] ) ) {
|
81 |
-
echo __("Friendship could not be canceled.", 'buddypress');
|
82 |
-
} else {
|
83 |
-
echo '<a id="friend-' . $_POST['fid'] . '" class="add" rel="add" title="' . __( 'Add Friend', 'buddypress' ) . '" href="' . wp_nonce_url( $bp->loggedin_user->domain . $bp->friends->slug . '/add-friend/' . $_POST['fid'], 'friends_add_friend' ) . '">' . __( 'Add Friend', 'buddypress' ) . '</a>';
|
84 |
-
}
|
85 |
-
} else if ( 'not_friends' == BP_Friends_Friendship::check_is_friend( $bp->loggedin_user->id, $_POST['fid'] ) ) {
|
86 |
-
|
87 |
-
check_ajax_referer('friends_add_friend');
|
88 |
-
|
89 |
-
if ( !friends_add_friend( $bp->loggedin_user->id, $_POST['fid'] ) ) {
|
90 |
-
echo __("Friendship could not be requested.", 'buddypress');
|
91 |
-
} else {
|
92 |
-
echo '<a href="' . $bp->loggedin_user->domain . $bp->friends->slug . '" class="requested">' . __( 'Friendship Requested', 'buddypress' ) . '</a>';
|
93 |
-
}
|
94 |
-
} else {
|
95 |
-
echo __( 'Request Pending', 'buddypress' );
|
96 |
-
}
|
97 |
-
|
98 |
-
return false;
|
99 |
-
}
|
100 |
-
add_action( 'wp_ajax_addremove_friend', 'friends_ajax_addremove_friend' );
|
101 |
-
|
102 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bp-friends/deprecated/css/structure.css
DELETED
@@ -1,28 +0,0 @@
|
|
1 |
-
/*
|
2 |
-
Basic layout structure styles for BuddyPress Friends. Formats BuddyPress friend pages within any WordPress theme.
|
3 |
-
No colors, fonts or pretty stuff.
|
4 |
-
|
5 |
-
These structure styles can be overridden by the theme CSS file if needed.
|
6 |
-
*/
|
7 |
-
|
8 |
-
#predefined-lists {
|
9 |
-
margin: 1em 1.2em 0 0;
|
10 |
-
}
|
11 |
-
|
12 |
-
#predefined-lists li {
|
13 |
-
padding: 0.25em 0;
|
14 |
-
}
|
15 |
-
|
16 |
-
.left-menu img#ajax-loader {
|
17 |
-
position: absolute;
|
18 |
-
right: 0;
|
19 |
-
top: 7px;
|
20 |
-
}
|
21 |
-
|
22 |
-
#friend-list .friendship-button {
|
23 |
-
margin-top: -1.5em;
|
24 |
-
}
|
25 |
-
|
26 |
-
.left-menu .friendship-button {
|
27 |
-
margin-top: 1em;
|
28 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bp-friends/deprecated/images/ajax-loader.gif
DELETED
Binary file
|
bp-friends/deprecated/js/general.js
DELETED
@@ -1,73 +0,0 @@
|
|
1 |
-
|
2 |
-
jQuery(document).ready( function() {
|
3 |
-
jQuery("form#friend-search-form").submit(
|
4 |
-
function() {
|
5 |
-
return false;
|
6 |
-
}
|
7 |
-
);
|
8 |
-
|
9 |
-
jQuery("div#pag a").livequery('click',
|
10 |
-
function() {
|
11 |
-
jQuery('#ajax-loader').toggle();
|
12 |
-
|
13 |
-
var frpage = jQuery(this).attr('href');
|
14 |
-
frpage = frpage.split('=');
|
15 |
-
|
16 |
-
jQuery.post( ajaxurl, {
|
17 |
-
action: 'friends_search',
|
18 |
-
'cookie': encodeURIComponent(document.cookie),
|
19 |
-
'_wpnonce': jQuery("input#_wpnonce_friend_search").val(),
|
20 |
-
'initiator_id': jQuery("input#initiator").val(),
|
21 |
-
'frpage': frpage[1],
|
22 |
-
|
23 |
-
'friend-search-box': jQuery("#friend-search-box").val()
|
24 |
-
},
|
25 |
-
function(response)
|
26 |
-
{
|
27 |
-
response = response.substr( 0, response.length - 1 );
|
28 |
-
|
29 |
-
jQuery("div#friends-loop").fadeOut(200,
|
30 |
-
function() {
|
31 |
-
jQuery('#ajax-loader').toggle();
|
32 |
-
jQuery("div#friends-loop").html(response);
|
33 |
-
jQuery("div#friends-loop").fadeIn(200);
|
34 |
-
}
|
35 |
-
);
|
36 |
-
});
|
37 |
-
|
38 |
-
return false;
|
39 |
-
}
|
40 |
-
);
|
41 |
-
|
42 |
-
jQuery("input#friend-search-box").keyup(
|
43 |
-
|
44 |
-
function(e) {
|
45 |
-
if ( e.which == 13 ) {
|
46 |
-
jQuery('#ajax-loader').toggle();
|
47 |
-
|
48 |
-
jQuery.post( ajaxurl, {
|
49 |
-
action: 'friends_search',
|
50 |
-
'cookie': encodeURIComponent(document.cookie),
|
51 |
-
'_wpnonce': jQuery("input#_wpnonce_friend_search").val(),
|
52 |
-
|
53 |
-
'friend-search-box': jQuery("#friend-search-box").val()
|
54 |
-
},
|
55 |
-
function(response)
|
56 |
-
{
|
57 |
-
response = response.substr( 0, response.length - 1 );
|
58 |
-
|
59 |
-
jQuery("div#friends-loop").fadeOut(200,
|
60 |
-
function() {
|
61 |
-
jQuery('#ajax-loader').toggle();
|
62 |
-
jQuery("div#friends-loop").html(response);
|
63 |
-
jQuery("div#friends-loop").fadeIn(200);
|
64 |
-
}
|
65 |
-
);
|
66 |
-
|
67 |
-
});
|
68 |
-
|
69 |
-
return false;
|
70 |
-
}
|
71 |
-
}
|
72 |
-
);
|
73 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bp-groups.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
define ( 'BP_GROUPS_DB_VERSION', '
|
4 |
|
5 |
/* Define the slug for the component */
|
6 |
if ( !defined( 'BP_GROUPS_SLUG' ) )
|
@@ -11,10 +11,6 @@ require ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-templatetags.php' );
|
|
11 |
require ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-widgets.php' );
|
12 |
require ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-filters.php' );
|
13 |
|
14 |
-
/* Include deprecated functions if settings allow */
|
15 |
-
if ( !defined( 'BP_IGNORE_DEPRECATED' ) )
|
16 |
-
require ( BP_PLUGIN_DIR . '/bp-groups/deprecated/bp-groups-deprecated.php' );
|
17 |
-
|
18 |
function groups_install() {
|
19 |
global $wpdb, $bp;
|
20 |
|
@@ -27,9 +23,7 @@ function groups_install() {
|
|
27 |
name varchar(100) NOT NULL,
|
28 |
slug varchar(100) NOT NULL,
|
29 |
description longtext NOT NULL,
|
30 |
-
news longtext NOT NULL,
|
31 |
status varchar(10) NOT NULL DEFAULT 'public',
|
32 |
-
enable_wire tinyint(1) NOT NULL DEFAULT '1',
|
33 |
enable_forum tinyint(1) NOT NULL DEFAULT '1',
|
34 |
date_created datetime NOT NULL,
|
35 |
KEY creator_id (creator_id),
|
@@ -69,56 +63,11 @@ function groups_install() {
|
|
69 |
require_once(ABSPATH . 'wp-admin/upgrade-functions.php');
|
70 |
dbDelta($sql);
|
71 |
|
72 |
-
|
73 |
-
$groups = groups_get_all();
|
74 |
-
|
75 |
-
foreach ( $groups as $group ) {
|
76 |
-
/* Don't fetch and move gravs, default images or empties */
|
77 |
-
if ( empty($group->avatar_thumb) || strpos( $group->avatar_thumb, 'gravatar.com' ) || strpos( $group->avatar_thumb, 'identicon' ) || strpos( $group->avatar_thumb, 'none-thumbnail' ) )
|
78 |
-
continue;
|
79 |
-
|
80 |
-
$start = strpos( $group->avatar_thumb, 'blogs.dir' );
|
81 |
-
|
82 |
-
if ( false !== $start ) {
|
83 |
-
$avatar_thumb = WP_CONTENT_DIR . '/' . substr( $group->avatar_thumb, $start, strlen( $group->avatar_thumb ) );
|
84 |
-
$avatar_full = WP_CONTENT_DIR . '/' . substr( $group->avatar_full, $start, strlen( $group->avatar_full ) );
|
85 |
-
|
86 |
-
if ( !file_exists( $avatar_thumb ) || !file_exists( $avatar_full ) )
|
87 |
-
continue;
|
88 |
-
|
89 |
-
$upload_dir = groups_avatar_upload_dir( $group->id );
|
90 |
-
|
91 |
-
copy( $avatar_thumb, $upload_dir['path'] . '/' . basename($avatar_thumb) );
|
92 |
-
copy( $avatar_full, $upload_dir['path'] . '/' . basename($avatar_full) );
|
93 |
-
}
|
94 |
-
}
|
95 |
-
|
96 |
-
if ( function_exists('bp_wire_install') )
|
97 |
-
groups_wire_install();
|
98 |
|
99 |
update_site_option( 'bp-groups-db-version', BP_GROUPS_DB_VERSION );
|
100 |
}
|
101 |
|
102 |
-
function groups_wire_install() {
|
103 |
-
global $wpdb, $bp;
|
104 |
-
|
105 |
-
if ( !empty($wpdb->charset) )
|
106 |
-
$charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
|
107 |
-
|
108 |
-
$sql[] = "CREATE TABLE {$bp->groups->table_name_wire} (
|
109 |
-
id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
110 |
-
item_id bigint(20) NOT NULL,
|
111 |
-
user_id bigint(20) NOT NULL,
|
112 |
-
content longtext NOT NULL,
|
113 |
-
date_posted datetime NOT NULL,
|
114 |
-
KEY item_id (item_id),
|
115 |
-
KEY user_id (user_id)
|
116 |
-
) {$charset_collate};";
|
117 |
-
|
118 |
-
require_once(ABSPATH . 'wp-admin/upgrade-functions.php');
|
119 |
-
dbDelta($sql);
|
120 |
-
}
|
121 |
-
|
122 |
function groups_setup_globals() {
|
123 |
global $bp, $wpdb;
|
124 |
|
@@ -134,61 +83,44 @@ function groups_setup_globals() {
|
|
134 |
/* Register this in the active components array */
|
135 |
$bp->active_components[$bp->groups->slug] = $bp->groups->id;
|
136 |
|
137 |
-
|
138 |
-
$bp->groups->table_name_wire = $wpdb->base_prefix . 'bp_groups_wire';
|
139 |
-
|
140 |
-
$bp->groups->forbidden_names = apply_filters( 'groups_forbidden_names', array( 'my-groups', 'group-finder', 'create', 'invites', 'delete', 'add', 'admin', 'request-membership' ) );
|
141 |
|
142 |
$bp->groups->group_creation_steps = apply_filters( 'groups_create_group_steps', array(
|
143 |
-
'group-details' => array( 'name' => __( '
|
144 |
-
'group-settings' => array( 'name' => __( '
|
145 |
-
'group-avatar' => array( 'name' => __( '
|
146 |
-
'group-invites' => array( 'name' => __( 'Group Invites', 'buddypress' ), 'position' => 30 )
|
147 |
) );
|
148 |
|
|
|
|
|
|
|
149 |
$bp->groups->valid_status = apply_filters( 'groups_valid_status', array( 'public', 'private', 'hidden' ) );
|
150 |
|
151 |
do_action( 'groups_setup_globals' );
|
152 |
}
|
153 |
-
add_action( '
|
154 |
-
add_action( 'admin_menu', 'groups_setup_globals', 2 );
|
155 |
|
156 |
function groups_setup_root_component() {
|
157 |
/* Register 'groups' as a root component */
|
158 |
bp_core_add_root_component( BP_GROUPS_SLUG );
|
159 |
}
|
160 |
-
add_action( '
|
161 |
|
162 |
function groups_check_installed() {
|
163 |
-
global $wpdb, $bp;
|
164 |
-
|
165 |
-
require ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-admin.php' );
|
166 |
-
|
167 |
/* Need to check db tables exist, activate hook no-worky in mu-plugins folder. */
|
168 |
-
if (
|
169 |
groups_install();
|
170 |
}
|
171 |
add_action( 'admin_menu', 'groups_check_installed' );
|
172 |
|
173 |
-
function groups_add_admin_menu() {
|
174 |
-
global $wpdb, $bp;
|
175 |
-
|
176 |
-
if ( !is_site_admin() )
|
177 |
-
return false;
|
178 |
-
|
179 |
-
/* Add the administration tab under the "Site Admin" tab for site administrators */
|
180 |
-
add_submenu_page( 'wpmu-admin.php', __("Groups", 'buddypress'), __("Groups", 'buddypress'), 1, "groups_admin_settings", "groups_admin_settings" );
|
181 |
-
}
|
182 |
-
add_action( 'admin_menu', 'groups_add_admin_menu' );
|
183 |
-
|
184 |
function groups_setup_nav() {
|
185 |
-
global $bp
|
186 |
|
187 |
if ( $group_id = BP_Groups_Group::group_exists($bp->current_action) ) {
|
188 |
|
189 |
/* This is a single group page. */
|
190 |
$bp->is_single_item = true;
|
191 |
-
$bp->groups->current_group =
|
192 |
|
193 |
/* Using "item" not "group" for generic support in other components. */
|
194 |
if ( is_site_admin() )
|
@@ -205,28 +137,24 @@ function groups_setup_nav() {
|
|
205 |
|
206 |
/* Should this group be visible to the logged in user? */
|
207 |
$bp->groups->current_group->is_group_visible_to_member = ( 'public' == $bp->groups->current_group->status || $is_member ) ? true : false;
|
208 |
-
|
209 |
-
/* Pre 1.1 backwards compatibility - use $bp->groups->current_group instead */
|
210 |
-
$group_obj = &$bp->groups->current_group;
|
211 |
}
|
212 |
|
213 |
/* Add 'Groups' to the main navigation */
|
214 |
-
bp_core_new_nav_item( array( 'name' => __('Groups', 'buddypress'), 'slug' => $bp->groups->slug, 'position' => 70, 'screen_function' => 'groups_screen_my_groups', 'default_subnav_slug' => 'my-groups', 'item_css_id' => $bp->groups->id ) );
|
215 |
|
216 |
$groups_link = $bp->loggedin_user->domain . $bp->groups->slug . '/';
|
217 |
|
218 |
/* Add the subnav items to the groups nav item */
|
219 |
bp_core_new_subnav_item( array( 'name' => __( 'My Groups', 'buddypress' ), 'slug' => 'my-groups', 'parent_url' => $groups_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_my_groups', 'position' => 10, 'item_css_id' => 'groups-my-groups' ) );
|
220 |
-
bp_core_new_subnav_item( array( 'name' => __( '
|
221 |
-
bp_core_new_subnav_item( array( 'name' => __( 'Invites', 'buddypress' ), 'slug' => 'invites', 'parent_url' => $groups_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_invites', 'position' => 30, 'user_has_access' => bp_is_home() ) );
|
222 |
|
223 |
if ( $bp->current_component == $bp->groups->slug ) {
|
224 |
|
225 |
-
if (
|
226 |
|
227 |
$bp->bp_options_title = __( 'My Groups', 'buddypress' );
|
228 |
|
229 |
-
} else if ( !
|
230 |
|
231 |
$bp->bp_options_avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb' ) );
|
232 |
$bp->bp_options_title = $bp->displayed_user->fullname;
|
@@ -250,7 +178,7 @@ function groups_setup_nav() {
|
|
250 |
|
251 |
// If this is a private or hidden group, does the user have access?
|
252 |
if ( 'private' == $bp->groups->current_group->status || 'hidden' == $bp->groups->current_group->status ) {
|
253 |
-
if ( $bp->groups->current_group->is_user_member && is_user_logged_in() )
|
254 |
$bp->groups->current_group->user_has_access = true;
|
255 |
else
|
256 |
$bp->groups->current_group->user_has_access = false;
|
@@ -265,36 +193,31 @@ function groups_setup_nav() {
|
|
265 |
bp_core_new_nav_default( array( 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_home', 'subnav_slug' => 'home' ) );
|
266 |
|
267 |
/* Add the "Home" subnav item, as this will always be present */
|
268 |
-
bp_core_new_subnav_item( array( 'name' => __( 'Home', 'buddypress' ), 'slug' => 'home', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_home', 'position' => 10, 'item_css_id' => '
|
269 |
|
270 |
/* If the user is a group mod or more, then show the group admin nav item */
|
271 |
if ( $bp->is_item_mod || $bp->is_item_admin )
|
272 |
-
bp_core_new_subnav_item( array( 'name' => __( 'Admin', 'buddypress' ), 'slug' => 'admin', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_admin', 'position' => 20, 'user_has_access' => ( $bp->is_item_admin + (int)$bp->is_item_mod ), 'item_css_id' => '
|
273 |
|
274 |
// If this is a private group, and the user is not a member, show a "Request Membership" nav item.
|
275 |
-
if ( is_user_logged_in() && !$bp->groups->current_group->is_user_member && !groups_check_for_membership_request( $bp->loggedin_user->id, $bp->groups->current_group->id ) && $bp->groups->current_group->status == 'private' )
|
276 |
bp_core_new_subnav_item( array( 'name' => __( 'Request Membership', 'buddypress' ), 'slug' => 'request-membership', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_request_membership', 'position' => 30 ) );
|
277 |
|
278 |
if ( $bp->groups->current_group->enable_forum && function_exists('bp_forums_setup') )
|
279 |
-
bp_core_new_subnav_item( array( 'name' => __( 'Forum', 'buddypress' ), 'slug' => 'forum', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_forum', 'position' => 40, 'user_has_access' => $bp->groups->current_group->user_has_access, 'item_css_id' => '
|
280 |
|
281 |
-
|
282 |
-
bp_core_new_subnav_item( array( 'name' => __( 'Wire', 'buddypress' ), 'slug' => BP_WIRE_SLUG, 'parent_url' => $group_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_wire', 'position' => 50, 'user_has_access' => $bp->groups->current_group->user_has_access, 'item_css_id' => 'group-wire' ) );
|
283 |
-
|
284 |
-
bp_core_new_subnav_item( array( 'name' => __( 'Members', 'buddypress' ), 'slug' => 'members', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_members', 'position' => 60, 'user_has_access' => $bp->groups->current_group->user_has_access, 'item_css_id' => 'group-members' ) );
|
285 |
|
286 |
if ( is_user_logged_in() && groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) {
|
287 |
if ( function_exists('friends_install') )
|
288 |
-
bp_core_new_subnav_item( array( 'name' => __( 'Send Invites', 'buddypress' ), 'slug' => 'send-invites', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_invite', 'item_css_id' => '
|
289 |
-
|
290 |
-
bp_core_new_subnav_item( array( 'name' => __( 'Leave Group', 'buddypress' ), 'slug' => 'leave-group', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_leave', 'item_css_id' => 'group-leave', 'position' => 110, 'user_has_access' => $bp->groups->current_group->user_has_access ) );
|
291 |
}
|
292 |
}
|
293 |
}
|
294 |
|
295 |
do_action( 'groups_setup_nav', $bp->groups->current_group->user_has_access );
|
296 |
}
|
297 |
-
add_action( '
|
298 |
add_action( 'admin_menu', 'groups_setup_nav' );
|
299 |
|
300 |
function groups_directory_groups_setup() {
|
@@ -304,7 +227,7 @@ function groups_directory_groups_setup() {
|
|
304 |
$bp->is_directory = true;
|
305 |
|
306 |
do_action( 'groups_directory_groups_setup' );
|
307 |
-
bp_core_load_template( apply_filters( 'groups_template_directory_groups', '
|
308 |
}
|
309 |
}
|
310 |
add_action( 'wp', 'groups_directory_groups_setup', 2 );
|
@@ -323,7 +246,7 @@ function groups_setup_adminbar_menu() {
|
|
323 |
<a href=""><?php _e( 'Admin Options', 'buddypress' ) ?></a>
|
324 |
|
325 |
<ul>
|
326 |
-
<li><a class="confirm" href="<?php echo wp_nonce_url( bp_get_group_permalink( $bp->groups->current_group ) . '
|
327 |
|
328 |
<?php do_action( 'groups_adminbar_menu_items' ) ?>
|
329 |
</ul>
|
@@ -344,12 +267,17 @@ add_action( 'bp_adminbar_menus', 'groups_setup_adminbar_menu', 20 );
|
|
344 |
function groups_screen_my_groups() {
|
345 |
global $bp;
|
346 |
|
347 |
-
|
348 |
-
|
|
|
|
|
|
|
|
|
|
|
349 |
|
350 |
do_action( 'groups_screen_my_groups' );
|
351 |
|
352 |
-
bp_core_load_template( apply_filters( 'groups_template_my_groups', '
|
353 |
}
|
354 |
|
355 |
function groups_screen_group_invites() {
|
@@ -368,12 +296,11 @@ function groups_screen_group_invites() {
|
|
368 |
bp_core_add_message( __('Group invite accepted', 'buddypress') );
|
369 |
|
370 |
/* Record this in activity streams */
|
371 |
-
$group = new BP_Groups_Group( $group_id
|
372 |
|
373 |
groups_record_activity( array(
|
374 |
-
'
|
375 |
-
'
|
376 |
-
'component_action' => 'joined_group',
|
377 |
'item_id' => $group->id
|
378 |
) );
|
379 |
}
|
@@ -399,190 +326,14 @@ function groups_screen_group_invites() {
|
|
399 |
|
400 |
do_action( 'groups_screen_group_invites', $group_id );
|
401 |
|
402 |
-
|
403 |
-
bp_core_load_template( apply_filters( 'groups_template_group_invites', 'groups/invites' ) );
|
404 |
-
else
|
405 |
-
bp_core_load_template( apply_filters( 'groups_template_group_invites', 'groups/list-invites' ) );
|
406 |
-
}
|
407 |
-
|
408 |
-
function groups_screen_create_group() {
|
409 |
-
global $bp;
|
410 |
-
|
411 |
-
/* Initial check of action variable[0] to prevent conflicts */
|
412 |
-
if ( !empty( $bp->action_variables[0] ) && $bp->action_variables[0] != 'step' )
|
413 |
-
return false;
|
414 |
-
|
415 |
-
/* If no current step is set, reset everything so we can start a fresh group creation */
|
416 |
-
if ( !$bp->groups->current_create_step = $bp->action_variables[1] ) {
|
417 |
-
|
418 |
-
unset( $bp->groups->current_create_step );
|
419 |
-
unset( $bp->groups->completed_create_steps );
|
420 |
-
|
421 |
-
setcookie( 'bp_new_group_id', false, time() - 1000, COOKIEPATH );
|
422 |
-
setcookie( 'bp_completed_create_steps', false, time() - 1000, COOKIEPATH );
|
423 |
-
|
424 |
-
$reset_steps = true;
|
425 |
-
bp_core_redirect( $bp->loggedin_user->domain . $bp->groups->slug . '/create/step/' . array_shift( array_keys( $bp->groups->group_creation_steps ) ) );
|
426 |
-
}
|
427 |
-
|
428 |
-
/* If this is a creation step that is not recognized, just redirect them back to the first screen */
|
429 |
-
if ( $bp->action_variables[1] && !$bp->groups->group_creation_steps[$bp->action_variables[1]] ) {
|
430 |
-
bp_core_add_message( __('There was an error saving group details. Please try again.', 'buddypress'), 'error' );
|
431 |
-
bp_core_redirect( $bp->loggedin_user->domain . $bp->groups->slug . '/create' );
|
432 |
-
}
|
433 |
-
|
434 |
-
/* Fetch the currently completed steps variable */
|
435 |
-
if ( isset( $_COOKIE['bp_completed_create_steps'] ) && !$reset_steps )
|
436 |
-
$bp->groups->completed_create_steps = unserialize( stripslashes( $_COOKIE['bp_completed_create_steps'] ) );
|
437 |
-
|
438 |
-
/* Set the ID of the new group, if it has already been created in a previous step */
|
439 |
-
if ( isset( $_COOKIE['bp_new_group_id'] ) ) {
|
440 |
-
$bp->groups->new_group_id = $_COOKIE['bp_new_group_id'];
|
441 |
-
$bp->groups->current_group = new BP_Groups_Group( $bp->groups->new_group_id, false, false );
|
442 |
-
}
|
443 |
-
|
444 |
-
/* If the save, upload or skip button is hit, lets calculate what we need to save */
|
445 |
-
if ( isset( $_POST['save'] ) ) {
|
446 |
-
|
447 |
-
/* Check the nonce */
|
448 |
-
check_admin_referer( 'groups_create_save_' . $bp->groups->current_create_step );
|
449 |
-
|
450 |
-
if ( 'group-details' == $bp->groups->current_create_step ) {
|
451 |
-
if ( empty( $_POST['group-name'] ) || empty( $_POST['group-desc'] ) ) {
|
452 |
-
bp_core_add_message( __( 'Please fill in all of the required fields', 'buddypress' ), 'error' );
|
453 |
-
bp_core_redirect( $bp->loggedin_user->domain . $bp->groups->slug . '/create/step/' . $bp->groups->current_create_step );
|
454 |
-
}
|
455 |
-
|
456 |
-
if ( !$bp->groups->new_group_id = groups_create_group( array( 'group_id' => $bp->groups->new_group_id, 'name' => $_POST['group-name'], 'description' => $_POST['group-desc'], 'news' => $_POST['group-news'], 'slug' => groups_check_slug( sanitize_title($_POST['group-name']) ), 'date_created' => time() ) ) ) {
|
457 |
-
bp_core_add_message( __( 'There was an error saving group details, please try again.', 'buddypress' ), 'error' );
|
458 |
-
bp_core_redirect( $bp->loggedin_user->domain . $bp->groups->slug . '/create/step/' . $bp->groups->current_create_step );
|
459 |
-
}
|
460 |
-
|
461 |
-
groups_update_groupmeta( $bp->groups->new_group_id, 'total_member_count', 1 );
|
462 |
-
groups_update_groupmeta( $bp->groups->new_group_id, 'last_activity', time() );
|
463 |
-
groups_update_groupmeta( $bp->groups->new_group_id, 'theme', 'buddypress' );
|
464 |
-
groups_update_groupmeta( $bp->groups->new_group_id, 'stylesheet', 'buddypress' );
|
465 |
-
}
|
466 |
-
|
467 |
-
if ( 'group-settings' == $bp->groups->current_create_step ) {
|
468 |
-
$group_status = 'public';
|
469 |
-
$group_enable_wire = 1;
|
470 |
-
$group_enable_forum = 1;
|
471 |
-
|
472 |
-
if ( !isset($_POST['group-show-wire']) )
|
473 |
-
$group_enable_wire = 0;
|
474 |
-
|
475 |
-
if ( !isset($_POST['group-show-forum']) ) {
|
476 |
-
$group_enable_forum = 0;
|
477 |
-
} else {
|
478 |
-
/* Create the forum if enable_forum = 1 */
|
479 |
-
if ( function_exists( 'bp_forums_setup' ) && '' == groups_get_groupmeta( $bp->groups->new_group_id, 'forum_id' ) ) {
|
480 |
-
groups_new_group_forum();
|
481 |
-
}
|
482 |
-
}
|
483 |
-
|
484 |
-
if ( 'private' == $_POST['group-status'] )
|
485 |
-
$group_status = 'private';
|
486 |
-
else if ( 'hidden' == $_POST['group-status'] )
|
487 |
-
$group_status = 'hidden';
|
488 |
-
|
489 |
-
if ( !$bp->groups->new_group_id = groups_create_group( array( 'group_id' => $bp->groups->new_group_id, 'status' => $group_status, 'enable_wire' => $group_enable_wire, 'enable_forum' => $group_enable_forum ) ) ) {
|
490 |
-
bp_core_add_message( __( 'There was an error saving group details, please try again.', 'buddypress' ), 'error' );
|
491 |
-
bp_core_redirect( $bp->loggedin_user->domain . $bp->groups->slug . '/create/step/' . $bp->groups->current_create_step );
|
492 |
-
}
|
493 |
-
}
|
494 |
-
|
495 |
-
if ( 'group-invites' == $bp->groups->current_create_step ) {
|
496 |
-
groups_send_invites( $bp->groups->new_group_id, $bp->loggedin_user->id );
|
497 |
-
}
|
498 |
-
|
499 |
-
do_action( 'groups_create_group_step_save_' . $bp->groups->current_create_step );
|
500 |
-
do_action( 'groups_create_group_step_complete' ); // Mostly for clearing cache on a generic action name
|
501 |
-
|
502 |
-
/**
|
503 |
-
* Once we have successfully saved the details for this step of the creation process
|
504 |
-
* we need to add the current step to the array of completed steps, then update the cookies
|
505 |
-
* holding the information
|
506 |
-
*/
|
507 |
-
if ( !in_array( $bp->groups->current_create_step, (array)$bp->groups->completed_create_steps ) )
|
508 |
-
$bp->groups->completed_create_steps[] = $bp->groups->current_create_step;
|
509 |
-
|
510 |
-
/* Reset cookie info */
|
511 |
-
setcookie( 'bp_new_group_id', $bp->groups->new_group_id, time()+60*60*24, COOKIEPATH );
|
512 |
-
setcookie( 'bp_completed_create_steps', serialize( $bp->groups->completed_create_steps ), time()+60*60*24, COOKIEPATH );
|
513 |
-
|
514 |
-
/* If we have completed all steps and hit done on the final step we can redirect to the completed group */
|
515 |
-
if ( count( $bp->groups->completed_create_steps ) == count( $bp->groups->group_creation_steps ) && $bp->groups->current_create_step == array_pop( array_keys( $bp->groups->group_creation_steps ) ) ) {
|
516 |
-
unset( $bp->groups->current_create_step );
|
517 |
-
unset( $bp->groups->completed_create_steps );
|
518 |
-
|
519 |
-
/* Once we compelete all steps, record the group creation in the activity stream. */
|
520 |
-
groups_record_activity( array(
|
521 |
-
'content' => apply_filters( 'groups_activity_created_group', sprintf( __( '%s created the group %s', 'buddypress'), bp_core_get_userlink( $bp->loggedin_user->id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . attribute_escape( $bp->groups->current_group->name ) . '</a>' ) ),
|
522 |
-
'primary_link' => apply_filters( 'groups_activity_created_group_primary_link', bp_get_group_permalink( $bp->groups->current_group ) ),
|
523 |
-
'component_action' => 'created_group',
|
524 |
-
'item_id' => $bp->groups->new_group_id
|
525 |
-
) );
|
526 |
-
|
527 |
-
do_action( 'groups_group_create_complete', $bp->groups->new_group_id );
|
528 |
-
|
529 |
-
bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) );
|
530 |
-
} else {
|
531 |
-
/**
|
532 |
-
* Since we don't know what the next step is going to be (any plugin can insert steps)
|
533 |
-
* we need to loop the step array and fetch the next step that way.
|
534 |
-
*/
|
535 |
-
foreach ( $bp->groups->group_creation_steps as $key => $value ) {
|
536 |
-
if ( $key == $bp->groups->current_create_step ) {
|
537 |
-
$next = 1;
|
538 |
-
continue;
|
539 |
-
}
|
540 |
-
|
541 |
-
if ( $next ) {
|
542 |
-
$next_step = $key;
|
543 |
-
break;
|
544 |
-
}
|
545 |
-
}
|
546 |
-
|
547 |
-
bp_core_redirect( $bp->loggedin_user->domain . $bp->groups->slug . '/create/step/' . $next_step );
|
548 |
-
}
|
549 |
-
}
|
550 |
-
|
551 |
-
/* Group avatar is handled separately */
|
552 |
-
if ( 'group-avatar' == $bp->groups->current_create_step && isset( $_POST['upload'] ) ) {
|
553 |
-
if ( !empty( $_FILES ) && isset( $_POST['upload'] ) ) {
|
554 |
-
/* Normally we would check a nonce here, but the group save nonce is used instead */
|
555 |
-
|
556 |
-
/* Pass the file to the avatar upload handler */
|
557 |
-
if ( bp_core_avatar_handle_upload( $_FILES, 'groups_avatar_upload_dir' ) ) {
|
558 |
-
$bp->avatar_admin->step = 'crop-image';
|
559 |
-
|
560 |
-
/* Make sure we include the jQuery jCrop file for image cropping */
|
561 |
-
add_action( 'wp', 'bp_core_add_jquery_cropper' );
|
562 |
-
}
|
563 |
-
}
|
564 |
-
|
565 |
-
/* If the image cropping is done, crop the image and save a full/thumb version */
|
566 |
-
if ( isset( $_POST['avatar-crop-submit'] ) && isset( $_POST['upload'] ) ) {
|
567 |
-
/* Normally we would check a nonce here, but the group save nonce is used instead */
|
568 |
-
|
569 |
-
if ( !bp_core_avatar_handle_crop( array( 'object' => 'group', 'avatar_dir' => 'group-avatars', 'item_id' => $bp->groups->current_group->id, 'original_file' => $_POST['image_src'], 'crop_x' => $_POST['x'], 'crop_y' => $_POST['y'], 'crop_w' => $_POST['w'], 'crop_h' => $_POST['h'] ) ) )
|
570 |
-
bp_core_add_message( __( 'There was an error saving the group avatar, please try uploading again.', 'buddypress' ), 'error' );
|
571 |
-
else
|
572 |
-
bp_core_add_message( __( 'The group avatar was uploaded successfully!', 'buddypress' ) );
|
573 |
-
}
|
574 |
-
}
|
575 |
-
|
576 |
-
bp_core_load_template( apply_filters( 'groups_template_create_group', 'groups/create' ) );
|
577 |
}
|
578 |
|
579 |
-
|
580 |
function groups_screen_group_home() {
|
581 |
global $bp;
|
582 |
|
583 |
if ( $bp->is_single_item ) {
|
584 |
-
|
585 |
-
if ( isset($_GET['new']) ) {
|
586 |
// Delete group request notifications for the user
|
587 |
bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->slug, 'membership_request_accepted' );
|
588 |
bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->slug, 'membership_request_rejected' );
|
@@ -592,10 +343,7 @@ function groups_screen_group_home() {
|
|
592 |
|
593 |
do_action( 'groups_screen_group_home' );
|
594 |
|
595 |
-
|
596 |
-
bp_core_load_template( apply_filters( 'groups_template_group_home', 'groups/single/home' ) );
|
597 |
-
else
|
598 |
-
bp_core_load_template( apply_filters( 'groups_template_group_home', 'groups/group-home' ) );
|
599 |
}
|
600 |
}
|
601 |
|
@@ -620,7 +368,7 @@ function groups_screen_group_forum() {
|
|
620 |
if ( !is_site_admin() && 'public' == $bp->groups->current_group->status && !groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) )
|
621 |
groups_join_group( $bp->groups->current_group->id, $bp->loggedin_user->id );
|
622 |
|
623 |
-
if (
|
624 |
bp_core_add_message( __( 'There was an error when replying to that topic', 'buddypress'), 'error' );
|
625 |
else
|
626 |
bp_core_add_message( __( 'Your reply was posted successfully', 'buddypress') );
|
@@ -628,7 +376,7 @@ function groups_screen_group_forum() {
|
|
628 |
if ( $_SERVER['QUERY_STRING'] )
|
629 |
$query_vars = '?' . $_SERVER['QUERY_STRING'];
|
630 |
|
631 |
-
bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '
|
632 |
}
|
633 |
|
634 |
/* Sticky a topic */
|
@@ -727,10 +475,10 @@ function groups_screen_group_forum() {
|
|
727 |
bp_core_add_message( __( 'The topic was edited successfully', 'buddypress') );
|
728 |
|
729 |
do_action( 'groups_edit_forum_topic', $topic_id );
|
730 |
-
bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '
|
731 |
}
|
732 |
|
733 |
-
bp_core_load_template( apply_filters( 'groups_template_group_forum_topic_edit', 'groups/single/
|
734 |
}
|
735 |
|
736 |
/* Delete a post */
|
@@ -767,24 +515,24 @@ function groups_screen_group_forum() {
|
|
767 |
/* Check the nonce */
|
768 |
check_admin_referer( 'bp_forums_edit_post' );
|
769 |
|
770 |
-
if (
|
771 |
bp_core_add_message( __( 'There was an error when editing that post', 'buddypress'), 'error' );
|
772 |
else
|
773 |
bp_core_add_message( __( 'The post was edited successfully', 'buddypress') );
|
774 |
|
|
|
|
|
|
|
775 |
do_action( 'groups_edit_forum_post', $post_id );
|
776 |
-
bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '
|
777 |
}
|
778 |
|
779 |
-
bp_core_load_template( apply_filters( 'groups_template_group_forum_topic_edit', 'groups/single/
|
780 |
}
|
781 |
|
782 |
/* Standard topic display */
|
783 |
else {
|
784 |
-
|
785 |
-
bp_core_load_template( apply_filters( 'groups_template_group_forum_topic', 'groups/single/forum/topic' ) );
|
786 |
-
else
|
787 |
-
bp_core_load_template( apply_filters( 'groups_template_group_forum_topic', 'groups/forum/topic' ) );
|
788 |
}
|
789 |
|
790 |
} else {
|
@@ -803,67 +551,12 @@ function groups_screen_group_forum() {
|
|
803 |
else
|
804 |
bp_core_add_message( __( 'The topic was created successfully', 'buddypress') );
|
805 |
|
806 |
-
bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '
|
807 |
}
|
808 |
|
809 |
do_action( 'groups_screen_group_forum', $topic_id, $forum_id );
|
810 |
|
811 |
-
|
812 |
-
bp_core_load_template( apply_filters( 'groups_template_group_forum', 'groups/single/forum/index' ) );
|
813 |
-
else
|
814 |
-
bp_core_load_template( apply_filters( 'groups_template_group_forum', 'groups/forum/index' ) );
|
815 |
-
}
|
816 |
-
}
|
817 |
-
}
|
818 |
-
|
819 |
-
function groups_screen_group_wire() {
|
820 |
-
global $bp;
|
821 |
-
|
822 |
-
$wire_action = $bp->action_variables[0];
|
823 |
-
|
824 |
-
if ( $bp->is_single_item ) {
|
825 |
-
if ( 'post' == $wire_action && ( is_site_admin() || groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) ) {
|
826 |
-
/* Check the nonce first. */
|
827 |
-
if ( !check_admin_referer( 'bp_wire_post' ) )
|
828 |
-
return false;
|
829 |
-
|
830 |
-
if ( !groups_new_wire_post( $bp->groups->current_group->id, $_POST['wire-post-textarea'] ) )
|
831 |
-
bp_core_add_message( __('Wire message could not be posted.', 'buddypress'), 'error' );
|
832 |
-
else
|
833 |
-
bp_core_add_message( __('Wire message successfully posted.', 'buddypress') );
|
834 |
-
|
835 |
-
if ( !strpos( wp_get_referer(), $bp->wire->slug ) )
|
836 |
-
bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) );
|
837 |
-
else
|
838 |
-
bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/' . $bp->wire->slug );
|
839 |
-
|
840 |
-
} else if ( 'delete' == $wire_action && ( is_site_admin() || groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) ) {
|
841 |
-
$wire_message_id = $bp->action_variables[1];
|
842 |
-
|
843 |
-
/* Check the nonce first. */
|
844 |
-
if ( !check_admin_referer( 'bp_wire_delete_link' ) )
|
845 |
-
return false;
|
846 |
-
|
847 |
-
if ( !groups_delete_wire_post( $wire_message_id, $bp->groups->table_name_wire ) )
|
848 |
-
bp_core_add_message( __('There was an error deleting the wire message.', 'buddypress'), 'error' );
|
849 |
-
else
|
850 |
-
bp_core_add_message( __('Wire message successfully deleted.', 'buddypress') );
|
851 |
-
|
852 |
-
if ( !strpos( wp_get_referer(), $bp->wire->slug ) )
|
853 |
-
bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) );
|
854 |
-
else
|
855 |
-
bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/' . $bp->wire->slug );
|
856 |
-
|
857 |
-
} else if ( ( !$wire_action || 'latest' == $bp->action_variables[1] ) ) {
|
858 |
-
if ( '' != locate_template( array( 'groups/single/wire.php' ), false ) )
|
859 |
-
bp_core_load_template( apply_filters( 'groups_template_group_wire', 'groups/single/wire' ) );
|
860 |
-
else
|
861 |
-
bp_core_load_template( apply_filters( 'groups_template_group_wire', 'groups/wire' ) );
|
862 |
-
} else {
|
863 |
-
if ( '' != locate_template( array( 'groups/single/home.php' ), false ) )
|
864 |
-
bp_core_load_template( apply_filters( 'groups_template_group_home', 'groups/single/home' ) );
|
865 |
-
else
|
866 |
-
bp_core_load_template( apply_filters( 'groups_template_group_home', 'groups/group-home' ) );
|
867 |
}
|
868 |
}
|
869 |
}
|
@@ -873,11 +566,7 @@ function groups_screen_group_members() {
|
|
873 |
|
874 |
if ( $bp->is_single_item ) {
|
875 |
do_action( 'groups_screen_group_members', $bp->groups->current_group->id );
|
876 |
-
|
877 |
-
if ( '' != locate_template( array( 'groups/single/members.php' ), false ) )
|
878 |
-
bp_core_load_template( apply_filters( 'groups_template_group_forum', 'groups/single/members' ) );
|
879 |
-
else
|
880 |
-
bp_core_load_template( apply_filters( 'groups_template_group_forum', 'groups/list-members' ) );
|
881 |
}
|
882 |
}
|
883 |
|
@@ -900,49 +589,7 @@ function groups_screen_group_invite() {
|
|
900 |
bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) );
|
901 |
} else {
|
902 |
// Show send invite page
|
903 |
-
|
904 |
-
bp_core_load_template( apply_filters( 'groups_template_group_invite', 'groups/single/send-invite' ) );
|
905 |
-
else
|
906 |
-
bp_core_load_template( apply_filters( 'groups_template_group_invite', 'groups/send-invite' ) );
|
907 |
-
}
|
908 |
-
}
|
909 |
-
}
|
910 |
-
|
911 |
-
function groups_screen_group_leave() {
|
912 |
-
global $bp;
|
913 |
-
|
914 |
-
if ( $bp->is_single_item ) {
|
915 |
-
if ( isset($bp->action_variables) && 'yes' == $bp->action_variables[0] ) {
|
916 |
-
// Check if the user is the group admin first.
|
917 |
-
if ( count( groups_get_group_admins( $bp->groups->current_group->id ) ) < 2 ) {
|
918 |
-
if ( groups_is_user_admin( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) {
|
919 |
-
bp_core_add_message( __('As the only group administrator, you cannot leave this group.', 'buddypress'), 'error' );
|
920 |
-
bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) );
|
921 |
-
}
|
922 |
-
}
|
923 |
-
|
924 |
-
// remove the user from the group.
|
925 |
-
if ( !groups_leave_group( $bp->groups->current_group->id ) ) {
|
926 |
-
bp_core_add_message( __('There was an error leaving the group. Please try again.', 'buddypress'), 'error' );
|
927 |
-
bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) );
|
928 |
-
} else {
|
929 |
-
bp_core_add_message( __('You left the group successfully.', 'buddypress') );
|
930 |
-
bp_core_redirect( $bp->loggedin_user->domain . $bp->groups->slug );
|
931 |
-
}
|
932 |
-
|
933 |
-
} else if ( isset($bp->action_variables) && 'no' == $bp->action_variables[0] ) {
|
934 |
-
|
935 |
-
bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) );
|
936 |
-
|
937 |
-
} else {
|
938 |
-
|
939 |
-
do_action( 'groups_screen_group_leave', $bp->groups->current_group->id );
|
940 |
-
|
941 |
-
// Show leave group page
|
942 |
-
if ( '' != locate_template( array( 'groups/single/leave-confirm.php' ), false ) )
|
943 |
-
bp_core_load_template( apply_filters( 'groups_template_group_leave', 'groups/single/leave-confirm' ) );
|
944 |
-
else
|
945 |
-
bp_core_load_template( apply_filters( 'groups_template_group_leave', 'groups/leave-group-confirm' ) );
|
946 |
}
|
947 |
}
|
948 |
}
|
@@ -970,13 +617,22 @@ function groups_screen_group_request_membership() {
|
|
970 |
|
971 |
do_action( 'groups_screen_group_request_membership', $bp->groups->current_group->id );
|
972 |
|
973 |
-
|
974 |
-
bp_core_load_template( apply_filters( 'groups_template_group_request_membership', 'groups/single/request-membership' ) );
|
975 |
-
else
|
976 |
-
bp_core_load_template( apply_filters( 'groups_template_group_request_membership', 'groups/request-membership' ) );
|
977 |
}
|
978 |
}
|
979 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
980 |
function groups_screen_group_admin() {
|
981 |
global $bp;
|
982 |
|
@@ -986,7 +642,7 @@ function groups_screen_group_admin() {
|
|
986 |
if ( !empty( $bp->action_variables[0] ) )
|
987 |
return false;
|
988 |
|
989 |
-
bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '
|
990 |
}
|
991 |
|
992 |
function groups_screen_group_admin_edit_details() {
|
@@ -1002,7 +658,7 @@ function groups_screen_group_admin_edit_details() {
|
|
1002 |
if ( !check_admin_referer( 'groups_edit_group_details' ) )
|
1003 |
return false;
|
1004 |
|
1005 |
-
if ( !groups_edit_base_group_details( $_POST['group-id'], $_POST['group-name'], $_POST['group-desc'],
|
1006 |
bp_core_add_message( __( 'There was an error updating group details, please try again.', 'buddypress' ), 'error' );
|
1007 |
} else {
|
1008 |
bp_core_add_message( __( 'Group details were successfully updated.', 'buddypress' ) );
|
@@ -1010,15 +666,12 @@ function groups_screen_group_admin_edit_details() {
|
|
1010 |
|
1011 |
do_action( 'groups_group_details_edited', $bp->groups->current_group->id );
|
1012 |
|
1013 |
-
bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '
|
1014 |
}
|
1015 |
|
1016 |
do_action( 'groups_screen_group_admin_edit_details', $bp->groups->current_group->id );
|
1017 |
|
1018 |
-
|
1019 |
-
bp_core_load_template( apply_filters( 'groups_template_group_admin', 'groups/single/admin' ) );
|
1020 |
-
else
|
1021 |
-
bp_core_load_template( apply_filters( 'groups_template_group_admin', 'groups/admin/edit-details' ) );
|
1022 |
}
|
1023 |
}
|
1024 |
}
|
@@ -1034,10 +687,7 @@ function groups_screen_group_admin_settings() {
|
|
1034 |
|
1035 |
// If the edit form has been submitted, save the edited details
|
1036 |
if ( isset( $_POST['save'] ) ) {
|
1037 |
-
$enable_wire = ( isset($_POST['group-show-wire'] ) ) ? 1 : 0;
|
1038 |
$enable_forum = ( isset($_POST['group-show-forum'] ) ) ? 1 : 0;
|
1039 |
-
$enable_photos = ( isset($_POST['group-show-photos'] ) ) ? 1 : 0;
|
1040 |
-
$photos_admin_only = ( $_POST['group-photos-status'] != 'all' ) ? 1 : 0;
|
1041 |
|
1042 |
$allowed_status = apply_filters( 'groups_allowed_status', array( 'public', 'private', 'hidden' ) );
|
1043 |
$status = ( in_array( $_POST['group-status'], (array)$allowed_status ) ) ? $_POST['group-status'] : 'public';
|
@@ -1046,7 +696,7 @@ function groups_screen_group_admin_settings() {
|
|
1046 |
if ( !check_admin_referer( 'groups_edit_group_settings' ) )
|
1047 |
return false;
|
1048 |
|
1049 |
-
if ( !groups_edit_group_settings( $_POST['group-id'], $
|
1050 |
bp_core_add_message( __( 'There was an error updating group settings, please try again.', 'buddypress' ), 'error' );
|
1051 |
} else {
|
1052 |
bp_core_add_message( __( 'Group settings were successfully updated.', 'buddypress' ) );
|
@@ -1054,15 +704,12 @@ function groups_screen_group_admin_settings() {
|
|
1054 |
|
1055 |
do_action( 'groups_group_settings_edited', $bp->groups->current_group->id );
|
1056 |
|
1057 |
-
bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '
|
1058 |
}
|
1059 |
|
1060 |
do_action( 'groups_screen_group_admin_settings', $bp->groups->current_group->id );
|
1061 |
|
1062 |
-
|
1063 |
-
bp_core_load_template( apply_filters( 'groups_template_group_admin_settings', 'groups/single/admin' ) );
|
1064 |
-
else
|
1065 |
-
bp_core_load_template( apply_filters( 'groups_template_group_admin_settings', 'groups/admin/group-settings' ) );
|
1066 |
}
|
1067 |
}
|
1068 |
add_action( 'wp', 'groups_screen_group_admin_settings', 4 );
|
@@ -1120,10 +767,7 @@ function groups_screen_group_admin_avatar() {
|
|
1120 |
|
1121 |
do_action( 'groups_screen_group_admin_avatar', $bp->groups->current_group->id );
|
1122 |
|
1123 |
-
|
1124 |
-
bp_core_load_template( apply_filters( 'groups_template_group_admin_avatar', 'groups/single/admin' ) );
|
1125 |
-
else
|
1126 |
-
bp_core_load_template( apply_filters( 'groups_template_group_admin_avatar', 'groups/admin/group-avatar' ) );
|
1127 |
}
|
1128 |
}
|
1129 |
add_action( 'wp', 'groups_screen_group_admin_avatar', 4 );
|
@@ -1153,7 +797,7 @@ function groups_screen_group_admin_manage_members() {
|
|
1153 |
|
1154 |
do_action( 'groups_promoted_member', $user_id, $bp->groups->current_group->id );
|
1155 |
|
1156 |
-
bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '
|
1157 |
}
|
1158 |
|
1159 |
if ( 'demote' == $bp->action_variables[1] && is_numeric( $bp->action_variables[2] ) ) {
|
@@ -1172,7 +816,7 @@ function groups_screen_group_admin_manage_members() {
|
|
1172 |
|
1173 |
do_action( 'groups_demoted_member', $user_id, $bp->groups->current_group->id );
|
1174 |
|
1175 |
-
bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '
|
1176 |
}
|
1177 |
|
1178 |
if ( 'ban' == $bp->action_variables[1] && is_numeric( $bp->action_variables[2] ) ) {
|
@@ -1191,7 +835,7 @@ function groups_screen_group_admin_manage_members() {
|
|
1191 |
|
1192 |
do_action( 'groups_banned_member', $user_id, $bp->groups->current_group->id );
|
1193 |
|
1194 |
-
bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '
|
1195 |
}
|
1196 |
|
1197 |
if ( 'unban' == $bp->action_variables[1] && is_numeric( $bp->action_variables[2] ) ) {
|
@@ -1210,15 +854,12 @@ function groups_screen_group_admin_manage_members() {
|
|
1210 |
|
1211 |
do_action( 'groups_unbanned_member', $user_id, $bp->groups->current_group->id );
|
1212 |
|
1213 |
-
bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '
|
1214 |
}
|
1215 |
|
1216 |
do_action( 'groups_screen_group_admin_manage_members', $bp->groups->current_group->id );
|
1217 |
|
1218 |
-
|
1219 |
-
bp_core_load_template( apply_filters( 'groups_template_group_admin_manage_members', 'groups/single/admin' ) );
|
1220 |
-
else
|
1221 |
-
bp_core_load_template( apply_filters( 'groups_template_group_admin_manage_members', 'groups/admin/manage-members' ) );
|
1222 |
}
|
1223 |
}
|
1224 |
add_action( 'wp', 'groups_screen_group_admin_manage_members', 4 );
|
@@ -1267,15 +908,12 @@ function groups_screen_group_admin_requests() {
|
|
1267 |
|
1268 |
do_action( 'groups_group_request_managed', $bp->groups->current_group->id, $request_action, $membership_id );
|
1269 |
|
1270 |
-
bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '
|
1271 |
}
|
1272 |
|
1273 |
do_action( 'groups_screen_group_admin_requests', $bp->groups->current_group->id );
|
1274 |
|
1275 |
-
|
1276 |
-
bp_core_load_template( apply_filters( 'groups_template_group_admin_requests', 'groups/single/admin' ) );
|
1277 |
-
else
|
1278 |
-
bp_core_load_template( apply_filters( 'groups_template_group_admin_requests', 'groups/admin/membership-requests' ) );
|
1279 |
}
|
1280 |
}
|
1281 |
add_action( 'wp', 'groups_screen_group_admin_requests', 4 );
|
@@ -1309,10 +947,7 @@ function groups_screen_group_admin_delete_group() {
|
|
1309 |
|
1310 |
do_action( 'groups_screen_group_admin_delete_group', $bp->groups->current_group->id );
|
1311 |
|
1312 |
-
|
1313 |
-
bp_core_load_template( apply_filters( 'groups_template_group_admin_delete_group', 'groups/single/admin' ) );
|
1314 |
-
else
|
1315 |
-
bp_core_load_template( apply_filters( 'groups_template_group_admin_delete_group', 'groups/admin/delete-group' ) );
|
1316 |
}
|
1317 |
}
|
1318 |
add_action( 'wp', 'groups_screen_group_admin_delete_group', 4 );
|
@@ -1338,14 +973,6 @@ function groups_screen_notification_settings() {
|
|
1338 |
<td class="yes"><input type="radio" name="notifications[notification_groups_group_updated]" value="yes" <?php if ( !get_usermeta( $current_user->id, 'notification_groups_group_updated') || 'yes' == get_usermeta( $current_user->id, 'notification_groups_group_updated') ) { ?>checked="checked" <?php } ?>/></td>
|
1339 |
<td class="no"><input type="radio" name="notifications[notification_groups_group_updated]" value="no" <?php if ( 'no' == get_usermeta( $current_user->id, 'notification_groups_group_updated') ) { ?>checked="checked" <?php } ?>/></td>
|
1340 |
</tr>
|
1341 |
-
<?php if ( function_exists('bp_wire_install') ) { ?>
|
1342 |
-
<tr>
|
1343 |
-
<td></td>
|
1344 |
-
<td><?php _e( 'A member posts on the wire of a group you belong to', 'buddypress' ) ?></td>
|
1345 |
-
<td class="yes"><input type="radio" name="notifications[notification_groups_wire_post]" value="yes" <?php if ( !get_usermeta( $current_user->id, 'notification_groups_wire_post') || 'yes' == get_usermeta( $current_user->id, 'notification_groups_wire_post') ) { ?>checked="checked" <?php } ?>/></td>
|
1346 |
-
<td class="no"><input type="radio" name="notifications[notification_groups_wire_post]" value="no" <?php if ( 'no' == get_usermeta( $current_user->id, 'notification_groups_wire_post') ) { ?>checked="checked" <?php } ?>/></td>
|
1347 |
-
</tr>
|
1348 |
-
<?php } ?>
|
1349 |
<tr>
|
1350 |
<td></td>
|
1351 |
<td><?php _e( 'You are promoted to a group administrator or moderator', 'buddypress' ) ?></td>
|
@@ -1359,20 +986,191 @@ function groups_screen_notification_settings() {
|
|
1359 |
<td class="no"><input type="radio" name="notifications[notification_groups_membership_request]" value="no" <?php if ( 'no' == get_usermeta( $current_user->id, 'notification_groups_membership_request') ) { ?>checked="checked" <?php } ?>/></td>
|
1360 |
</tr>
|
1361 |
|
1362 |
-
<?php do_action( 'groups_screen_notification_settings' ); ?>
|
1363 |
-
</table>
|
1364 |
-
<?php
|
1365 |
-
}
|
1366 |
-
add_action( 'bp_notification_settings', 'groups_screen_notification_settings' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1367 |
|
|
|
|
|
|
|
1368 |
|
1369 |
-
|
1370 |
-
|
1371 |
-
|
1372 |
-
|
1373 |
-
|
1374 |
-
|
1375 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1376 |
|
1377 |
function groups_action_join_group() {
|
1378 |
global $bp;
|
@@ -1390,10 +1188,7 @@ function groups_action_join_group() {
|
|
1390 |
bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) );
|
1391 |
}
|
1392 |
|
1393 |
-
|
1394 |
-
bp_core_load_template( apply_filters( 'groups_template_group_home', 'groups/single/home' ) );
|
1395 |
-
else
|
1396 |
-
bp_core_load_template( apply_filters( 'groups_template_group_home', 'groups/group-home' ) );
|
1397 |
}
|
1398 |
add_action( 'wp', 'groups_action_join_group', 3 );
|
1399 |
|
@@ -1406,28 +1201,50 @@ function groups_action_sort_creation_steps() {
|
|
1406 |
if ( !is_array( $bp->groups->group_creation_steps ) )
|
1407 |
return false;
|
1408 |
|
1409 |
-
foreach ( $bp->groups->group_creation_steps as $slug => $step )
|
|
|
|
|
|
|
1410 |
$temp[$step['position']] = array( 'name' => $step['name'], 'slug' => $slug );
|
|
|
1411 |
|
1412 |
/* Sort the steps by their position key */
|
1413 |
ksort($temp);
|
1414 |
unset($bp->groups->group_creation_steps);
|
1415 |
|
1416 |
-
foreach( $temp as $position => $step )
|
1417 |
$bp->groups->group_creation_steps[$step['slug']] = array( 'name' => $step['name'], 'position' => $position );
|
1418 |
}
|
1419 |
-
add_action( 'wp', 'groups_action_sort_creation_steps', 3 );
|
1420 |
|
1421 |
-
function
|
1422 |
global $bp, $wpdb;
|
1423 |
|
1424 |
if ( $bp->current_component == $bp->groups->slug && isset( $_GET['random-group'] ) ) {
|
1425 |
-
$group =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1426 |
|
1427 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1428 |
}
|
|
|
|
|
|
|
1429 |
}
|
1430 |
-
add_action( 'wp', '
|
1431 |
|
1432 |
|
1433 |
/********************************************************************************
|
@@ -1445,13 +1262,12 @@ function groups_register_activity_actions() {
|
|
1445 |
|
1446 |
bp_activity_set_action( $bp->groups->id, 'created_group', __( 'Created a group', 'buddypress' ) );
|
1447 |
bp_activity_set_action( $bp->groups->id, 'joined_group', __( 'Joined a group', 'buddypress' ) );
|
1448 |
-
bp_activity_set_action( $bp->groups->id, 'new_wire_post', __( 'New group wire post', 'buddypress' ) );
|
1449 |
bp_activity_set_action( $bp->groups->id, 'new_forum_topic', __( 'New group forum topic', 'buddypress' ) );
|
1450 |
bp_activity_set_action( $bp->groups->id, 'new_forum_post', __( 'New group forum post', 'buddypress' ) );
|
1451 |
|
1452 |
do_action( 'groups_register_activity_actions' );
|
1453 |
}
|
1454 |
-
add_action( '
|
1455 |
|
1456 |
function groups_record_activity( $args = '' ) {
|
1457 |
global $bp;
|
@@ -1459,33 +1275,35 @@ function groups_record_activity( $args = '' ) {
|
|
1459 |
if ( !function_exists( 'bp_activity_add' ) )
|
1460 |
return false;
|
1461 |
|
1462 |
-
/* If the group is not public,
|
1463 |
-
if ( 'public'
|
1464 |
-
|
|
|
|
|
1465 |
|
1466 |
$defaults = array(
|
|
|
1467 |
'user_id' => $bp->loggedin_user->id,
|
1468 |
-
'
|
1469 |
-
'
|
1470 |
-
'
|
1471 |
-
'
|
|
|
1472 |
'item_id' => false,
|
1473 |
'secondary_item_id' => false,
|
1474 |
-
'recorded_time' =>
|
1475 |
-
'hide_sitewide' =>
|
1476 |
);
|
1477 |
|
1478 |
$r = wp_parse_args( $args, $defaults );
|
1479 |
extract( $r, EXTR_SKIP );
|
1480 |
|
1481 |
-
return bp_activity_add( array( 'user_id' => $user_id, 'content' => $content, 'primary_link' => $primary_link, '
|
1482 |
}
|
1483 |
|
1484 |
function groups_update_last_activity( $group_id ) {
|
1485 |
-
groups_update_groupmeta( $group_id, 'last_activity',
|
1486 |
}
|
1487 |
-
add_action( 'groups_deleted_wire_post', 'groups_update_last_activity' );
|
1488 |
-
add_action( 'groups_new_wire_post', 'groups_update_last_activity' );
|
1489 |
add_action( 'groups_joined_group', 'groups_update_last_activity' );
|
1490 |
add_action( 'groups_leave_group', 'groups_update_last_activity' );
|
1491 |
add_action( 'groups_created_group', 'groups_update_last_activity' );
|
@@ -1500,41 +1318,41 @@ function groups_format_notifications( $action, $item_id, $secondary_item_id, $to
|
|
1500 |
$group_id = $secondary_item_id;
|
1501 |
$requesting_user_id = $item_id;
|
1502 |
|
1503 |
-
$group = new BP_Groups_Group( $group_id
|
1504 |
|
1505 |
$group_link = bp_get_group_permalink( $group );
|
1506 |
|
1507 |
if ( (int)$total_items > 1 ) {
|
1508 |
-
return apply_filters( 'bp_groups_multiple_new_membership_requests_notification', '<a href="' . $group_link . '/admin/membership-requests
|
1509 |
} else {
|
1510 |
$user_fullname = bp_core_get_user_displayname( $requesting_user_id );
|
1511 |
-
return apply_filters( 'bp_groups_single_new_membership_request_notification', '<a href="' . $group_link . '
|
1512 |
}
|
1513 |
break;
|
1514 |
|
1515 |
case 'membership_request_accepted':
|
1516 |
$group_id = $item_id;
|
1517 |
|
1518 |
-
$group = new BP_Groups_Group( $group_id
|
1519 |
-
$group_link = bp_get_group_permalink( $group )
|
1520 |
|
1521 |
if ( (int)$total_items > 1 ) {
|
1522 |
-
return apply_filters( 'bp_groups_multiple_membership_request_accepted_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __('%d accepted group membership requests', 'buddypress' ), (int)$total_items, $group->name ) . '</a>', $total_items, $group_name );
|
1523 |
} else {
|
1524 |
-
return apply_filters( 'bp_groups_single_membership_request_accepted_notification', '<a href="' . $group_link . '">' . sprintf( __('Membership for group "%s" accepted'), $group->name ) . '</a>', $group_link, $group->name );
|
1525 |
}
|
1526 |
break;
|
1527 |
|
1528 |
case 'membership_request_rejected':
|
1529 |
$group_id = $item_id;
|
1530 |
|
1531 |
-
$group = new BP_Groups_Group( $group_id
|
1532 |
-
$group_link = bp_get_group_permalink( $group )
|
1533 |
|
1534 |
if ( (int)$total_items > 1 ) {
|
1535 |
-
return apply_filters( 'bp_groups_multiple_membership_request_rejected_notification', '<a href="' . site_url() . '/' . BP_MEMBERS_SLUG . '/' . $bp->groups->slug . '" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __('%d rejected group membership requests', 'buddypress' ), (int)$total_items, $group->name ) . '</a>', $total_items, $group->name );
|
1536 |
} else {
|
1537 |
-
return apply_filters( 'bp_groups_single_membership_request_rejected_notification', '<a href="' . $group_link . '">' . sprintf( __('Membership for group "%s" rejected'), $group->name ) . '</a>', $group_link, $group->name );
|
1538 |
}
|
1539 |
|
1540 |
break;
|
@@ -1542,39 +1360,39 @@ function groups_format_notifications( $action, $item_id, $secondary_item_id, $to
|
|
1542 |
case 'member_promoted_to_admin':
|
1543 |
$group_id = $item_id;
|
1544 |
|
1545 |
-
$group = new BP_Groups_Group( $group_id
|
1546 |
-
$group_link = bp_get_group_permalink( $group )
|
1547 |
|
1548 |
if ( (int)$total_items > 1 ) {
|
1549 |
-
return apply_filters( 'bp_groups_multiple_member_promoted_to_admin_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __('You were promoted to an admin in %d groups', 'buddypress' ), (int)$total_items ) . '</a>', $total_items );
|
1550 |
} else {
|
1551 |
-
return apply_filters( 'bp_groups_single_member_promoted_to_admin_notification', '<a href="' . $group_link . '">' . sprintf( __('You were promoted to an admin in the group %s'), $group->name ) . '</a>', $group_link, $group->name );
|
1552 |
}
|
1553 |
break;
|
1554 |
|
1555 |
case 'member_promoted_to_mod':
|
1556 |
$group_id = $item_id;
|
1557 |
|
1558 |
-
$group = new BP_Groups_Group( $group_id
|
1559 |
-
$group_link = bp_get_group_permalink( $group )
|
1560 |
|
1561 |
if ( (int)$total_items > 1 ) {
|
1562 |
-
return apply_filters( 'bp_groups_multiple_member_promoted_to_mod_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __('You were promoted to a mod in %d groups', 'buddypress' ), (int)$total_items ) . '</a>', $total_items );
|
1563 |
} else {
|
1564 |
-
return apply_filters( 'bp_groups_single_member_promoted_to_mod_notification', '<a href="' . $group_link . '">' . sprintf( __('You were promoted to a mod in the group %s'), $group->name ) . '</a>', $group_link, $group->name );
|
1565 |
}
|
1566 |
break;
|
1567 |
|
1568 |
case 'group_invite':
|
1569 |
$group_id = $item_id;
|
1570 |
|
1571 |
-
$group = new BP_Groups_Group( $group_id
|
1572 |
-
$user_url =
|
1573 |
|
1574 |
if ( (int)$total_items > 1 ) {
|
1575 |
-
return apply_filters( 'bp_groups_multiple_group_invite_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '/invites" title="' . __( 'Group Invites', 'buddypress' ) . '">' . sprintf( __('You have %d new group invitations', 'buddypress' ), (int)$total_items ) . '</a>', $total_items );
|
1576 |
} else {
|
1577 |
-
return apply_filters( 'bp_groups_single_group_invite_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '/invites" title="' . __( 'Group Invites', 'buddypress' ) . '">' . sprintf( __('You have an invitation to the group: %s', 'buddypress' ), $group->name ) . '</a>', $group->name );
|
1578 |
}
|
1579 |
break;
|
1580 |
}
|
@@ -1594,6 +1412,18 @@ function groups_format_notifications( $action, $item_id, $secondary_item_id, $to
|
|
1594 |
* true or false on success or failure.
|
1595 |
*/
|
1596 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1597 |
/*** Group Creation, Editing & Deletion *****************************************/
|
1598 |
|
1599 |
function groups_create_group( $args = '' ) {
|
@@ -1607,10 +1437,8 @@ function groups_create_group( $args = '' ) {
|
|
1607 |
* 'creator_id'
|
1608 |
* 'name'
|
1609 |
* 'description'
|
1610 |
-
* 'news'
|
1611 |
* 'slug'
|
1612 |
* 'status'
|
1613 |
-
* 'enable_wire'
|
1614 |
* 'enable_forum'
|
1615 |
* 'date_created'
|
1616 |
*/
|
@@ -1620,11 +1448,10 @@ function groups_create_group( $args = '' ) {
|
|
1620 |
else
|
1621 |
$group = new BP_Groups_Group;
|
1622 |
|
1623 |
-
if ( $creator_id )
|
1624 |
$group->creator_id = $creator_id;
|
1625 |
-
|
1626 |
$group->creator_id = $bp->loggedin_user->id;
|
1627 |
-
}
|
1628 |
|
1629 |
if ( isset( $name ) )
|
1630 |
$group->name = $name;
|
@@ -1632,9 +1459,6 @@ function groups_create_group( $args = '' ) {
|
|
1632 |
if ( isset( $description ) )
|
1633 |
$group->description = $description;
|
1634 |
|
1635 |
-
if ( isset( $news ) )
|
1636 |
-
$group->news = $news;
|
1637 |
-
|
1638 |
if ( isset( $slug ) && groups_check_slug( $slug ) )
|
1639 |
$group->slug = $slug;
|
1640 |
|
@@ -1643,11 +1467,6 @@ function groups_create_group( $args = '' ) {
|
|
1643 |
$group->status = $status;
|
1644 |
}
|
1645 |
|
1646 |
-
if ( isset( $enable_wire ) )
|
1647 |
-
$group->enable_wire = $enable_wire;
|
1648 |
-
else if ( !$group_id && !isset( $enable_wire ) )
|
1649 |
-
$group->enable_wire = 1;
|
1650 |
-
|
1651 |
if ( isset( $enable_forum ) )
|
1652 |
$group->enable_forum = $enable_forum;
|
1653 |
else if ( !$group_id && !isset( $enable_forum ) )
|
@@ -1667,23 +1486,25 @@ function groups_create_group( $args = '' ) {
|
|
1667 |
$member->is_admin = 1;
|
1668 |
$member->user_title = __( 'Group Admin', 'buddypress' );
|
1669 |
$member->is_confirmed = 1;
|
|
|
1670 |
|
1671 |
$member->save();
|
1672 |
}
|
1673 |
|
|
|
|
|
1674 |
return $group->id;
|
1675 |
}
|
1676 |
|
1677 |
-
function groups_edit_base_group_details( $group_id, $group_name, $group_desc, $
|
1678 |
global $bp;
|
1679 |
|
1680 |
if ( empty( $group_name ) || empty( $group_desc ) )
|
1681 |
return false;
|
1682 |
|
1683 |
-
$group = new BP_Groups_Group( $group_id
|
1684 |
$group->name = $group_name;
|
1685 |
$group->description = $group_desc;
|
1686 |
-
$group->news = $group_news;
|
1687 |
|
1688 |
if ( !$group->save() )
|
1689 |
return false;
|
@@ -1698,14 +1519,11 @@ function groups_edit_base_group_details( $group_id, $group_name, $group_desc, $g
|
|
1698 |
return true;
|
1699 |
}
|
1700 |
|
1701 |
-
function groups_edit_group_settings( $group_id, $
|
1702 |
global $bp;
|
1703 |
|
1704 |
-
$group = new BP_Groups_Group( $group_id
|
1705 |
-
$group->enable_wire = $enable_wire;
|
1706 |
$group->enable_forum = $enable_forum;
|
1707 |
-
$group->enable_photos = $enable_photos;
|
1708 |
-
$group->photos_admin_only = $photos_admin_only;
|
1709 |
|
1710 |
/***
|
1711 |
* Before we potentially switch the group status, if it has been changed to public
|
@@ -1747,7 +1565,7 @@ function groups_delete_group( $group_id ) {
|
|
1747 |
|
1748 |
/* Delete all group activity from activity streams */
|
1749 |
if ( function_exists( 'bp_activity_delete_by_item_id' ) ) {
|
1750 |
-
bp_activity_delete_by_item_id( array( 'item_id' => $group_id, '
|
1751 |
}
|
1752 |
|
1753 |
// Remove all outstanding invites for this group
|
@@ -1788,7 +1606,7 @@ function groups_check_slug( $slug ) {
|
|
1788 |
}
|
1789 |
|
1790 |
function groups_get_slug( $group_id ) {
|
1791 |
-
$group = new BP_Groups_Group( $group_id
|
1792 |
return $group->slug;
|
1793 |
}
|
1794 |
|
@@ -1800,15 +1618,36 @@ function groups_leave_group( $group_id, $user_id = false ) {
|
|
1800 |
if ( !$user_id )
|
1801 |
$user_id = $bp->loggedin_user->id;
|
1802 |
|
1803 |
-
|
1804 |
-
if (
|
1805 |
-
|
|
|
|
|
|
|
|
|
1806 |
|
1807 |
-
|
|
|
|
|
|
|
|
|
1808 |
|
1809 |
/* Modify group member count */
|
1810 |
groups_update_groupmeta( $group_id, 'total_member_count', (int) groups_get_groupmeta( $group_id, 'total_member_count') - 1 );
|
1811 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1812 |
return true;
|
1813 |
}
|
1814 |
|
@@ -1818,11 +1657,20 @@ function groups_join_group( $group_id, $user_id = false ) {
|
|
1818 |
if ( !$user_id )
|
1819 |
$user_id = $bp->loggedin_user->id;
|
1820 |
|
|
|
1821 |
if ( groups_check_user_has_invite( $user_id, $group_id ) )
|
1822 |
groups_delete_invite( $user_id, $group_id );
|
1823 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1824 |
if ( !$bp->groups->current_group )
|
1825 |
-
$bp->groups->current_group = new BP_Groups_Group( $group_id
|
1826 |
|
1827 |
$new_member = new BP_Groups_Member;
|
1828 |
$new_member->group_id = $group_id;
|
@@ -1830,7 +1678,7 @@ function groups_join_group( $group_id, $user_id = false ) {
|
|
1830 |
$new_member->inviter_id = 0;
|
1831 |
$new_member->is_admin = 0;
|
1832 |
$new_member->user_title = '';
|
1833 |
-
$new_member->date_modified =
|
1834 |
$new_member->is_confirmed = 1;
|
1835 |
|
1836 |
if ( !$new_member->save() )
|
@@ -1838,15 +1686,14 @@ function groups_join_group( $group_id, $user_id = false ) {
|
|
1838 |
|
1839 |
/* Record this in activity streams */
|
1840 |
groups_record_activity( array(
|
1841 |
-
'
|
1842 |
-
'
|
1843 |
-
'component_action' => 'joined_group',
|
1844 |
'item_id' => $group_id
|
1845 |
) );
|
1846 |
|
1847 |
/* Modify group meta */
|
1848 |
groups_update_groupmeta( $group_id, 'total_member_count', (int) groups_get_groupmeta( $group_id, 'total_member_count') + 1 );
|
1849 |
-
groups_update_groupmeta( $group_id, 'last_activity',
|
1850 |
|
1851 |
do_action( 'groups_join_group', $group_id, $user_id );
|
1852 |
|
@@ -1873,36 +1720,56 @@ function groups_get_group_members( $group_id, $limit = false, $page = false ) {
|
|
1873 |
|
1874 |
/*** Group Fetching, Filtering & Searching *************************************/
|
1875 |
|
1876 |
-
function
|
1877 |
-
|
1878 |
-
}
|
1879 |
-
|
1880 |
-
function groups_get_newest( $limit = null, $page = 1 ) {
|
1881 |
-
return BP_Groups_Group::get_newest( $limit, $page );
|
1882 |
-
}
|
1883 |
|
1884 |
-
|
1885 |
-
|
1886 |
-
|
|
|
1887 |
|
1888 |
-
|
1889 |
-
|
1890 |
-
|
|
|
1891 |
|
1892 |
-
|
1893 |
-
|
1894 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1895 |
|
1896 |
-
|
1897 |
-
return BP_Groups_Group::get_alphabetically( $limit, $page );
|
1898 |
}
|
1899 |
|
1900 |
-
function
|
1901 |
-
|
1902 |
-
|
|
|
|
|
1903 |
|
1904 |
-
|
1905 |
-
return BP_Groups_Group::get_by_most_forum_posts( $limit, $page );
|
1906 |
}
|
1907 |
|
1908 |
function groups_get_user_groups( $user_id = false, $pag_num = false, $pag_page = false ) {
|
@@ -1914,86 +1781,18 @@ function groups_get_user_groups( $user_id = false, $pag_num = false, $pag_page =
|
|
1914 |
return BP_Groups_Member::get_group_ids( $user_id, $pag_num, $pag_page );
|
1915 |
}
|
1916 |
|
1917 |
-
/* TODO: These user group functions could be merged with the above with an optional user ID param */
|
1918 |
-
|
1919 |
-
function groups_get_recently_joined_for_user( $user_id = false, $pag_num = false, $pag_page = false, $filter = false ) {
|
1920 |
-
global $bp;
|
1921 |
-
|
1922 |
-
if ( !$user_id )
|
1923 |
-
$user_id = $bp->displayed_user->id;
|
1924 |
-
|
1925 |
-
return BP_Groups_Member::get_recently_joined( $user_id, $pag_num, $pag_page, $filter );
|
1926 |
-
}
|
1927 |
-
|
1928 |
-
function groups_get_most_popular_for_user( $user_id = false, $pag_num = false, $pag_page = false, $filter = false ) {
|
1929 |
-
global $bp;
|
1930 |
-
|
1931 |
-
if ( !$user_id )
|
1932 |
-
$user_id = $bp->displayed_user->id;
|
1933 |
-
|
1934 |
-
return BP_Groups_Member::get_most_popular( $user_id, $pag_num, $pag_page, $filter );
|
1935 |
-
}
|
1936 |
-
|
1937 |
-
function groups_get_recently_active_for_user( $user_id = false, $pag_num = false, $pag_page = false, $filter = false ) {
|
1938 |
-
global $bp;
|
1939 |
-
|
1940 |
-
if ( !$user_id )
|
1941 |
-
$user_id = $bp->displayed_user->id;
|
1942 |
-
|
1943 |
-
return BP_Groups_Member::get_recently_active( $user_id, $pag_num, $pag_page, $filter );
|
1944 |
-
}
|
1945 |
-
|
1946 |
-
function groups_get_alphabetically_for_user( $user_id = false, $pag_num = false, $pag_page = false, $filter = false ) {
|
1947 |
-
global $bp;
|
1948 |
-
|
1949 |
-
if ( !$user_id )
|
1950 |
-
$user_id = $bp->displayed_user->id;
|
1951 |
-
|
1952 |
-
return BP_Groups_Member::get_alphabetically( $user_id, $pag_num, $pag_page, $filter );
|
1953 |
-
}
|
1954 |
-
|
1955 |
-
function groups_get_user_is_admin_of( $user_id = false, $pag_num = false, $pag_page = false, $filter = false ) {
|
1956 |
-
global $bp;
|
1957 |
-
|
1958 |
-
if ( !$user_id )
|
1959 |
-
$user_id = $bp->displayed_user->id;
|
1960 |
-
|
1961 |
-
return BP_Groups_Member::get_is_admin_of( $user_id, $pag_num, $pag_page, $filter );
|
1962 |
-
}
|
1963 |
-
|
1964 |
-
function groups_get_user_is_mod_of( $user_id = false, $pag_num = false, $pag_page = false, $filter = false ) {
|
1965 |
-
global $bp;
|
1966 |
-
|
1967 |
-
if ( !$user_id )
|
1968 |
-
$user_id = $bp->displayed_user->id;
|
1969 |
-
|
1970 |
-
return BP_Groups_Member::get_is_mod_of( $user_id, $pag_num, $pag_page, $filter );
|
1971 |
-
}
|
1972 |
-
|
1973 |
function groups_total_groups_for_user( $user_id = false ) {
|
1974 |
global $bp;
|
1975 |
|
1976 |
if ( !$user_id )
|
1977 |
-
$user_id = $bp->displayed_user->id;
|
1978 |
-
|
1979 |
-
return BP_Groups_Member::total_group_count( $user_id );
|
1980 |
-
}
|
1981 |
-
|
1982 |
-
function groups_get_random_groups_for_user( $user_id = false, $total_groups = 5 ) {
|
1983 |
-
global $bp;
|
1984 |
-
|
1985 |
-
if ( !$user_id )
|
1986 |
-
$user_id = $bp->displayed_user->id;
|
1987 |
-
|
1988 |
-
return BP_Groups_Member::get_random_groups( $user_id, $total_groups );
|
1989 |
-
}
|
1990 |
|
1991 |
-
|
1992 |
-
|
1993 |
-
|
|
|
1994 |
|
1995 |
-
|
1996 |
-
return BP_Groups_Group::filter_user_groups( $filter, $user_id, $order, $pag_num_per_page, $pag_page );
|
1997 |
}
|
1998 |
|
1999 |
/*** Group Avatars *************************************************************/
|
@@ -2004,20 +1803,17 @@ function groups_avatar_upload_dir( $group_id = false ) {
|
|
2004 |
if ( !$group_id )
|
2005 |
$group_id = $bp->groups->current_group->id;
|
2006 |
|
2007 |
-
$path
|
2008 |
-
$
|
2009 |
-
$newdir .= '/group-avatars/' . $group_id;
|
2010 |
|
2011 |
-
$
|
|
|
2012 |
|
2013 |
-
|
2014 |
-
@wp_mkdir_p( $newdir );
|
2015 |
-
|
2016 |
-
$newurl = WP_CONTENT_URL . '/blogs.dir/' . BP_ROOT_BLOG . '/files/group-avatars/' . $group_id;
|
2017 |
$newburl = $newurl;
|
2018 |
$newsubdir = '/group-avatars/' . $group_id;
|
2019 |
|
2020 |
-
return apply_filters( 'groups_avatar_upload_dir', array( 'path' => $
|
2021 |
}
|
2022 |
|
2023 |
/*** Group Member Status Checks ************************************************/
|
@@ -2038,52 +1834,48 @@ function groups_is_user_banned( $user_id, $group_id ) {
|
|
2038 |
return BP_Groups_Member::check_is_banned( $user_id, $group_id );
|
2039 |
}
|
2040 |
|
2041 |
-
/*** Group
|
2042 |
|
2043 |
-
function
|
2044 |
global $bp;
|
2045 |
|
2046 |
-
|
2047 |
-
|
2048 |
-
|
2049 |
-
|
2050 |
-
|
2051 |
-
/* Post an email notification if settings allow */
|
2052 |
-
require_once ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-notifications.php' );
|
2053 |
-
groups_notification_new_wire_post( $group_id, $wire_post->id );
|
2054 |
|
2055 |
-
|
2056 |
-
|
2057 |
-
$activity_content .= '<blockquote>' . bp_create_excerpt( attribute_escape( $content ) ) . '</blockquote>';
|
2058 |
|
2059 |
-
|
2060 |
-
|
2061 |
-
'primary_link' => apply_filters( 'groups_activity_new_wire_post_primary_link', bp_get_group_permalink( $bp->groups->current_group ) ),
|
2062 |
-
'component_action' => 'new_wire_post',
|
2063 |
-
'item_id' => $bp->groups->current_group->id,
|
2064 |
-
'secondary_item_id' => $wire_post->item_id
|
2065 |
-
) );
|
2066 |
|
2067 |
-
|
2068 |
|
2069 |
-
|
2070 |
-
|
|
|
2071 |
|
2072 |
-
|
2073 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2074 |
|
2075 |
-
|
2076 |
-
|
2077 |
-
/* Delete the activity stream item */
|
2078 |
-
if ( function_exists( 'bp_activity_delete_by_item_id' ) ) {
|
2079 |
-
bp_activity_delete_by_item_id( array( 'item_id' => $wire_post_id, 'component_name' => 'groups', 'component_action' => 'new_wire_post' ) );
|
2080 |
-
}
|
2081 |
|
2082 |
-
|
2083 |
-
|
2084 |
-
}
|
2085 |
|
2086 |
-
return
|
2087 |
}
|
2088 |
|
2089 |
/*** Group Forums **************************************************************/
|
@@ -2107,30 +1899,38 @@ function groups_new_group_forum( $group_id = false, $group_name = false, $group_
|
|
2107 |
do_action( 'groups_new_group_forum', $forum, $group_id );
|
2108 |
}
|
2109 |
|
2110 |
-
function groups_new_group_forum_post( $post_text, $topic_id ) {
|
2111 |
global $bp;
|
2112 |
|
2113 |
if ( empty( $post_text ) )
|
2114 |
return false;
|
2115 |
|
2116 |
-
|
|
|
|
|
|
|
2117 |
$topic = bp_forums_get_topic_details( $topic_id );
|
2118 |
|
2119 |
-
$
|
2120 |
-
$activity_content
|
|
|
|
|
|
|
|
|
2121 |
|
2122 |
/* Record this in activity streams */
|
2123 |
groups_record_activity( array(
|
2124 |
-
'
|
2125 |
-
'
|
2126 |
-
'
|
|
|
2127 |
'item_id' => $bp->groups->current_group->id,
|
2128 |
-
'secondary_item_id' => $
|
2129 |
) );
|
2130 |
|
2131 |
-
do_action( 'groups_new_forum_topic_post', $bp->groups->current_group->id, $
|
2132 |
|
2133 |
-
return $
|
2134 |
}
|
2135 |
|
2136 |
return false;
|
@@ -2142,17 +1942,23 @@ function groups_new_group_forum_topic( $topic_title, $topic_text, $topic_tags, $
|
|
2142 |
if ( empty( $topic_title ) || empty( $topic_text ) )
|
2143 |
return false;
|
2144 |
|
|
|
|
|
|
|
|
|
|
|
2145 |
if ( $topic_id = bp_forums_new_topic( array( 'topic_title' => $topic_title, 'topic_text' => $topic_text, 'topic_tags' => $topic_tags, 'forum_id' => $forum_id ) ) ) {
|
2146 |
$topic = bp_forums_get_topic_details( $topic_id );
|
2147 |
|
2148 |
-
$
|
2149 |
-
$activity_content
|
2150 |
|
2151 |
/* Record this in activity streams */
|
2152 |
groups_record_activity( array(
|
2153 |
-
'
|
2154 |
-
'
|
2155 |
-
'
|
|
|
2156 |
'item_id' => $bp->groups->current_group->id,
|
2157 |
'secondary_item_id' => $topic->topic_id
|
2158 |
) );
|
@@ -2168,62 +1974,75 @@ function groups_new_group_forum_topic( $topic_title, $topic_text, $topic_tags, $
|
|
2168 |
function groups_update_group_forum_topic( $topic_id, $topic_title, $topic_text ) {
|
2169 |
global $bp;
|
2170 |
|
|
|
|
|
|
|
2171 |
if ( $topic = bp_forums_update_topic( array( 'topic_title' => $topic_title, 'topic_text' => $topic_text, 'topic_id' => $topic_id ) ) ) {
|
2172 |
/* Update the activity stream item */
|
2173 |
if ( function_exists( 'bp_activity_delete_by_item_id' ) )
|
2174 |
-
bp_activity_delete_by_item_id( array( 'item_id' => $bp->groups->current_group->id, 'secondary_item_id' => $topic_id, '
|
2175 |
|
2176 |
-
$
|
2177 |
-
$activity_content
|
2178 |
|
2179 |
/* Record this in activity streams */
|
2180 |
groups_record_activity( array(
|
2181 |
-
'
|
2182 |
-
'
|
2183 |
-
'
|
|
|
2184 |
'item_id' => (int)$bp->groups->current_group->id,
|
2185 |
'user_id' => (int)$topic->topic_poster,
|
2186 |
'secondary_item_id' => $topic->topic_id,
|
2187 |
-
'recorded_time' =>
|
2188 |
) );
|
2189 |
|
2190 |
do_action( 'groups_update_group_forum_topic', &$topic );
|
2191 |
|
2192 |
-
return
|
2193 |
}
|
2194 |
|
2195 |
return false;
|
2196 |
}
|
2197 |
|
2198 |
-
function groups_update_group_forum_post( $post_id, $post_text, $topic_id ) {
|
2199 |
global $bp;
|
2200 |
|
|
|
|
|
|
|
2201 |
$post = bp_forums_get_post( $post_id );
|
2202 |
|
2203 |
if ( $post_id = bp_forums_insert_post( array( 'post_id' => $post_id, 'post_text' => $post_text, 'post_time' => $post->post_time, 'topic_id' => $topic_id, 'poster_id' => $post->poster_id ) ) ) {
|
2204 |
$topic = bp_forums_get_topic_details( $topic_id );
|
2205 |
|
2206 |
-
|
2207 |
-
|
2208 |
-
|
2209 |
|
2210 |
-
|
2211 |
-
|
2212 |
|
2213 |
-
/*
|
|
|
|
|
|
|
|
|
2214 |
groups_record_activity( array(
|
2215 |
-
'
|
2216 |
-
'
|
2217 |
-
'
|
|
|
|
|
2218 |
'item_id' => (int)$bp->groups->current_group->id,
|
2219 |
'user_id' => (int)$post->poster_id,
|
2220 |
'secondary_item_id' => $post_id,
|
2221 |
-
'recorded_time' =>
|
2222 |
) );
|
2223 |
|
2224 |
do_action( 'groups_update_group_forum_post', &$post, &$topic );
|
2225 |
|
2226 |
-
return
|
2227 |
}
|
2228 |
|
2229 |
return false;
|
@@ -2234,9 +2053,8 @@ function groups_delete_group_forum_topic( $topic_id ) {
|
|
2234 |
|
2235 |
if ( bp_forums_delete_topic( array( 'topic_id' => $topic_id ) ) ) {
|
2236 |
/* Delete the activity stream item */
|
2237 |
-
if ( function_exists( '
|
2238 |
-
|
2239 |
-
bp_activity_delete_by_item_id( array( 'item_id' => $topic_id, 'component_name' => $bp->groups->id, 'component_action' => 'new_forum_post' ) );
|
2240 |
}
|
2241 |
|
2242 |
do_action( 'groups_delete_group_forum_topic', $topic_id );
|
@@ -2252,8 +2070,8 @@ function groups_delete_group_forum_post( $post_id, $topic_id ) {
|
|
2252 |
|
2253 |
if ( bp_forums_delete_post( array( 'post_id' => $post_id ) ) ) {
|
2254 |
/* Delete the activity stream item */
|
2255 |
-
if ( function_exists( '
|
2256 |
-
|
2257 |
}
|
2258 |
|
2259 |
do_action( 'groups_delete_group_forum_post', $post_id, $topic_id );
|
@@ -2271,13 +2089,13 @@ function groups_total_public_forum_topic_count( $type = 'newest' ) {
|
|
2271 |
|
2272 |
/*** Group Invitations *********************************************************/
|
2273 |
|
2274 |
-
function groups_get_invites_for_user( $user_id = false ) {
|
2275 |
global $bp;
|
2276 |
|
2277 |
if ( !$user_id )
|
2278 |
$user_id = $bp->loggedin_user->id;
|
2279 |
|
2280 |
-
return BP_Groups_Member::get_invites( $user_id );
|
2281 |
}
|
2282 |
|
2283 |
function groups_invite_user( $args = '' ) {
|
@@ -2287,7 +2105,7 @@ function groups_invite_user( $args = '' ) {
|
|
2287 |
'user_id' => false,
|
2288 |
'group_id' => false,
|
2289 |
'inviter_id' => $bp->loggedin_user->id,
|
2290 |
-
'date_modified' =>
|
2291 |
'is_confirmed' => 0
|
2292 |
);
|
2293 |
|
@@ -2297,20 +2115,19 @@ function groups_invite_user( $args = '' ) {
|
|
2297 |
if ( !$user_id || !$group_id )
|
2298 |
return false;
|
2299 |
|
2300 |
-
if ( groups_is_user_member( $user_id, $group_id ) )
|
2301 |
-
|
2302 |
-
|
2303 |
-
|
2304 |
-
|
2305 |
-
|
2306 |
-
|
2307 |
-
$invite->inviter_id = $inviter_id;
|
2308 |
-
$invite->is_confirmed = $is_confirmed;
|
2309 |
|
2310 |
-
|
2311 |
-
|
2312 |
|
2313 |
-
|
|
|
2314 |
|
2315 |
return true;
|
2316 |
}
|
@@ -2327,6 +2144,8 @@ function groups_uninvite_user( $user_id, $group_id ) {
|
|
2327 |
}
|
2328 |
|
2329 |
function groups_accept_invite( $user_id, $group_id ) {
|
|
|
|
|
2330 |
if ( groups_is_user_member( $user_id, $group_id ) )
|
2331 |
return false;
|
2332 |
|
@@ -2336,6 +2155,12 @@ function groups_accept_invite( $user_id, $group_id ) {
|
|
2336 |
if ( !$member->save() )
|
2337 |
return false;
|
2338 |
|
|
|
|
|
|
|
|
|
|
|
|
|
2339 |
do_action( 'groups_accept_invite', $user_id, $group_id );
|
2340 |
return true;
|
2341 |
}
|
@@ -2370,7 +2195,7 @@ function groups_send_invites( $user_id, $group_id ) {
|
|
2370 |
|
2371 |
// Send friend invites.
|
2372 |
$invited_users = groups_get_invites_for_group( $user_id, $group_id );
|
2373 |
-
$group = new BP_Groups_Group( $group_id
|
2374 |
|
2375 |
for ( $i = 0; $i < count( $invited_users ); $i++ ) {
|
2376 |
$member = new BP_Groups_Member( $invited_users[$i], $group_id );
|
@@ -2407,7 +2232,7 @@ function groups_promote_member( $user_id, $group_id, $status ) {
|
|
2407 |
|
2408 |
$member = new BP_Groups_Member( $user_id, $group_id );
|
2409 |
|
2410 |
-
do_action( 'groups_premote_member', $
|
2411 |
|
2412 |
return $member->promote( $status );
|
2413 |
}
|
@@ -2417,7 +2242,7 @@ function groups_demote_member( $user_id, $group_id ) {
|
|
2417 |
|
2418 |
$member = new BP_Groups_Member( $user_id, $group_id );
|
2419 |
|
2420 |
-
do_action( 'groups_demote_member', $
|
2421 |
|
2422 |
return $member->demote();
|
2423 |
}
|
@@ -2430,9 +2255,12 @@ function groups_ban_member( $user_id, $group_id ) {
|
|
2430 |
|
2431 |
$member = new BP_Groups_Member( $user_id, $group_id );
|
2432 |
|
2433 |
-
do_action( 'groups_ban_member', $
|
|
|
|
|
|
|
2434 |
|
2435 |
-
|
2436 |
}
|
2437 |
|
2438 |
function groups_unban_member( $user_id, $group_id ) {
|
@@ -2443,7 +2271,7 @@ function groups_unban_member( $user_id, $group_id ) {
|
|
2443 |
|
2444 |
$member = new BP_Groups_Member( $user_id, $group_id );
|
2445 |
|
2446 |
-
do_action( 'groups_unban_member', $
|
2447 |
|
2448 |
return $member->unban();
|
2449 |
}
|
@@ -2453,13 +2281,21 @@ function groups_unban_member( $user_id, $group_id ) {
|
|
2453 |
function groups_send_membership_request( $requesting_user_id, $group_id ) {
|
2454 |
global $bp;
|
2455 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2456 |
$requesting_user = new BP_Groups_Member;
|
2457 |
$requesting_user->group_id = $group_id;
|
2458 |
$requesting_user->user_id = $requesting_user_id;
|
2459 |
$requesting_user->inviter_id = 0;
|
2460 |
$requesting_user->is_admin = 0;
|
2461 |
$requesting_user->user_title = '';
|
2462 |
-
$requesting_user->date_modified =
|
2463 |
$requesting_user->is_confirmed = 0;
|
2464 |
$requesting_user->comments = $_POST['group-request-membership-comments'];
|
2465 |
|
@@ -2498,12 +2334,11 @@ function groups_accept_membership_request( $membership_id, $user_id = false, $gr
|
|
2498 |
groups_update_groupmeta( $membership->group_id, 'total_member_count', (int) groups_get_groupmeta( $membership->group_id, 'total_member_count') + 1 );
|
2499 |
|
2500 |
/* Record this in activity streams */
|
2501 |
-
$group = new BP_Groups_Group( $group_id
|
2502 |
|
2503 |
groups_record_activity( array(
|
2504 |
-
'
|
2505 |
-
'
|
2506 |
-
'component_action' => 'joined_group',
|
2507 |
'item_id' => $group->id,
|
2508 |
'user_id' => $user_id
|
2509 |
) );
|
@@ -2518,12 +2353,7 @@ function groups_accept_membership_request( $membership_id, $user_id = false, $gr
|
|
2518 |
}
|
2519 |
|
2520 |
function groups_reject_membership_request( $membership_id, $user_id = false, $group_id = false ) {
|
2521 |
-
if ( $user_id
|
2522 |
-
$membership = new BP_Groups_Member( $user_id, $group_id );
|
2523 |
-
else
|
2524 |
-
$membership = new BP_Groups_Member( false, false, $membership_id );
|
2525 |
-
|
2526 |
-
if ( !BP_Groups_Member::delete( $membership->user_id, $membership->group_id ) )
|
2527 |
return false;
|
2528 |
|
2529 |
// Send a notification to the user.
|
@@ -2535,6 +2365,18 @@ function groups_reject_membership_request( $membership_id, $user_id = false, $gr
|
|
2535 |
return true;
|
2536 |
}
|
2537 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2538 |
function groups_check_for_membership_request( $user_id, $group_id ) {
|
2539 |
return BP_Groups_Member::check_for_membership_request( $user_id, $group_id );
|
2540 |
}
|
@@ -2577,8 +2419,8 @@ function groups_delete_groupmeta( $group_id, $meta_key = false, $meta_value = fa
|
|
2577 |
$wpdb->query( $wpdb->prepare( "DELETE FROM " . $bp->groups->table_name_groupmeta . " WHERE group_id = %d AND meta_key = %s", $group_id, $meta_key ) );
|
2578 |
}
|
2579 |
|
2580 |
-
|
2581 |
-
|
2582 |
|
2583 |
return true;
|
2584 |
}
|
@@ -2594,14 +2436,10 @@ function groups_get_groupmeta( $group_id, $meta_key = '') {
|
|
2594 |
if ( !empty($meta_key) ) {
|
2595 |
$meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key);
|
2596 |
|
2597 |
-
|
2598 |
-
|
2599 |
-
|
2600 |
-
|
2601 |
-
//if ( false !== $user && isset($user->$meta_key) )
|
2602 |
-
// $metas = array($user->$meta_key);
|
2603 |
-
//else
|
2604 |
-
$metas = $wpdb->get_col( $wpdb->prepare("SELECT meta_value FROM " . $bp->groups->table_name_groupmeta . " WHERE group_id = %d AND meta_key = %s", $group_id, $meta_key) );
|
2605 |
} else {
|
2606 |
$metas = $wpdb->get_col( $wpdb->prepare("SELECT meta_value FROM " . $bp->groups->table_name_groupmeta . " WHERE group_id = %d", $group_id) );
|
2607 |
}
|
@@ -2648,8 +2486,8 @@ function groups_update_groupmeta( $group_id, $meta_key, $meta_value ) {
|
|
2648 |
return false;
|
2649 |
}
|
2650 |
|
2651 |
-
|
2652 |
-
|
2653 |
|
2654 |
return true;
|
2655 |
}
|
@@ -2665,6 +2503,14 @@ add_action( 'wpmu_delete_user', 'groups_remove_data_for_user', 1 );
|
|
2665 |
add_action( 'delete_user', 'groups_remove_data_for_user', 1 );
|
2666 |
add_action( 'make_spam_user', 'groups_remove_data_for_user', 1 );
|
2667 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2668 |
function groups_clear_group_object_cache( $group_id ) {
|
2669 |
wp_cache_delete( 'groups_group_nouserdata_' . $group_id, 'bp' );
|
2670 |
wp_cache_delete( 'groups_group_' . $group_id, 'bp' );
|
@@ -2672,17 +2518,23 @@ function groups_clear_group_object_cache( $group_id ) {
|
|
2672 |
wp_cache_delete( 'active_groups', 'bp' );
|
2673 |
wp_cache_delete( 'popular_groups', 'bp' );
|
2674 |
wp_cache_delete( 'groups_random_groups', 'bp' );
|
|
|
2675 |
}
|
2676 |
-
|
2677 |
-
// List actions to clear object caches on
|
2678 |
add_action( 'groups_group_deleted', 'groups_clear_group_object_cache' );
|
2679 |
add_action( 'groups_settings_updated', 'groups_clear_group_object_cache' );
|
2680 |
add_action( 'groups_details_updated', 'groups_clear_group_object_cache' );
|
2681 |
add_action( 'groups_group_avatar_updated', 'groups_clear_group_object_cache' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2682 |
|
2683 |
-
|
2684 |
-
add_action( 'groups_new_wire_post', 'bp_core_clear_cache' );
|
2685 |
-
add_action( 'groups_deleted_wire_post', 'bp_core_clear_cache' );
|
2686 |
add_action( 'groups_join_group', 'bp_core_clear_cache' );
|
2687 |
add_action( 'groups_leave_group', 'bp_core_clear_cache' );
|
2688 |
add_action( 'groups_accept_invite', 'bp_core_clear_cache' );
|
1 |
<?php
|
2 |
|
3 |
+
define ( 'BP_GROUPS_DB_VERSION', '1900' );
|
4 |
|
5 |
/* Define the slug for the component */
|
6 |
if ( !defined( 'BP_GROUPS_SLUG' ) )
|
11 |
require ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-widgets.php' );
|
12 |
require ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-filters.php' );
|
13 |
|
|
|
|
|
|
|
|
|
14 |
function groups_install() {
|
15 |
global $wpdb, $bp;
|
16 |
|
23 |
name varchar(100) NOT NULL,
|
24 |
slug varchar(100) NOT NULL,
|
25 |
description longtext NOT NULL,
|
|
|
26 |
status varchar(10) NOT NULL DEFAULT 'public',
|
|
|
27 |
enable_forum tinyint(1) NOT NULL DEFAULT '1',
|
28 |
date_created datetime NOT NULL,
|
29 |
KEY creator_id (creator_id),
|
63 |
require_once(ABSPATH . 'wp-admin/upgrade-functions.php');
|
64 |
dbDelta($sql);
|
65 |
|
66 |
+
do_action( 'groups_install' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
|
68 |
update_site_option( 'bp-groups-db-version', BP_GROUPS_DB_VERSION );
|
69 |
}
|
70 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
function groups_setup_globals() {
|
72 |
global $bp, $wpdb;
|
73 |
|
83 |
/* Register this in the active components array */
|
84 |
$bp->active_components[$bp->groups->slug] = $bp->groups->id;
|
85 |
|
86 |
+
$bp->groups->forbidden_names = apply_filters( 'groups_forbidden_names', array( 'my-groups', 'create', 'invites', 'send-invites', 'forum', 'delete', 'add', 'admin', 'request-membership', 'members', 'settings', 'avatar', BP_GROUPS_SLUG ) );
|
|
|
|
|
|
|
87 |
|
88 |
$bp->groups->group_creation_steps = apply_filters( 'groups_create_group_steps', array(
|
89 |
+
'group-details' => array( 'name' => __( 'Details', 'buddypress' ), 'position' => 0 ),
|
90 |
+
'group-settings' => array( 'name' => __( 'Settings', 'buddypress' ), 'position' => 10 ),
|
91 |
+
'group-avatar' => array( 'name' => __( 'Avatar', 'buddypress' ), 'position' => 20 ),
|
|
|
92 |
) );
|
93 |
|
94 |
+
if ( bp_is_active( 'friends' ) )
|
95 |
+
$bp->groups->group_creation_steps['group-invites'] = array( 'name' => __( 'Invites', 'buddypress' ), 'position' => 30 );
|
96 |
+
|
97 |
$bp->groups->valid_status = apply_filters( 'groups_valid_status', array( 'public', 'private', 'hidden' ) );
|
98 |
|
99 |
do_action( 'groups_setup_globals' );
|
100 |
}
|
101 |
+
add_action( 'bp_setup_globals', 'groups_setup_globals' );
|
|
|
102 |
|
103 |
function groups_setup_root_component() {
|
104 |
/* Register 'groups' as a root component */
|
105 |
bp_core_add_root_component( BP_GROUPS_SLUG );
|
106 |
}
|
107 |
+
add_action( 'bp_setup_root_components', 'groups_setup_root_component' );
|
108 |
|
109 |
function groups_check_installed() {
|
|
|
|
|
|
|
|
|
110 |
/* Need to check db tables exist, activate hook no-worky in mu-plugins folder. */
|
111 |
+
if ( $bp->site_options['bp-groups-db-version'] < BP_GROUPS_DB_VERSION )
|
112 |
groups_install();
|
113 |
}
|
114 |
add_action( 'admin_menu', 'groups_check_installed' );
|
115 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
116 |
function groups_setup_nav() {
|
117 |
+
global $bp;
|
118 |
|
119 |
if ( $group_id = BP_Groups_Group::group_exists($bp->current_action) ) {
|
120 |
|
121 |
/* This is a single group page. */
|
122 |
$bp->is_single_item = true;
|
123 |
+
$bp->groups->current_group = new BP_Groups_Group( $group_id );
|
124 |
|
125 |
/* Using "item" not "group" for generic support in other components. */
|
126 |
if ( is_site_admin() )
|
137 |
|
138 |
/* Should this group be visible to the logged in user? */
|
139 |
$bp->groups->current_group->is_group_visible_to_member = ( 'public' == $bp->groups->current_group->status || $is_member ) ? true : false;
|
|
|
|
|
|
|
140 |
}
|
141 |
|
142 |
/* Add 'Groups' to the main navigation */
|
143 |
+
bp_core_new_nav_item( array( 'name' => sprintf( __( 'Groups <span>(%d)</span>', 'buddypress' ), groups_total_groups_for_user() ), 'slug' => $bp->groups->slug, 'position' => 70, 'screen_function' => 'groups_screen_my_groups', 'default_subnav_slug' => 'my-groups', 'item_css_id' => $bp->groups->id ) );
|
144 |
|
145 |
$groups_link = $bp->loggedin_user->domain . $bp->groups->slug . '/';
|
146 |
|
147 |
/* Add the subnav items to the groups nav item */
|
148 |
bp_core_new_subnav_item( array( 'name' => __( 'My Groups', 'buddypress' ), 'slug' => 'my-groups', 'parent_url' => $groups_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_my_groups', 'position' => 10, 'item_css_id' => 'groups-my-groups' ) );
|
149 |
+
bp_core_new_subnav_item( array( 'name' => __( 'Invites', 'buddypress' ), 'slug' => 'invites', 'parent_url' => $groups_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_invites', 'position' => 30, 'user_has_access' => bp_is_my_profile() ) );
|
|
|
150 |
|
151 |
if ( $bp->current_component == $bp->groups->slug ) {
|
152 |
|
153 |
+
if ( bp_is_my_profile() && !$bp->is_single_item ) {
|
154 |
|
155 |
$bp->bp_options_title = __( 'My Groups', 'buddypress' );
|
156 |
|
157 |
+
} else if ( !bp_is_my_profile() && !$bp->is_single_item ) {
|
158 |
|
159 |
$bp->bp_options_avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb' ) );
|
160 |
$bp->bp_options_title = $bp->displayed_user->fullname;
|
178 |
|
179 |
// If this is a private or hidden group, does the user have access?
|
180 |
if ( 'private' == $bp->groups->current_group->status || 'hidden' == $bp->groups->current_group->status ) {
|
181 |
+
if ( $bp->groups->current_group->is_user_member && is_user_logged_in() || is_site_admin() )
|
182 |
$bp->groups->current_group->user_has_access = true;
|
183 |
else
|
184 |
$bp->groups->current_group->user_has_access = false;
|
193 |
bp_core_new_nav_default( array( 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_home', 'subnav_slug' => 'home' ) );
|
194 |
|
195 |
/* Add the "Home" subnav item, as this will always be present */
|
196 |
+
bp_core_new_subnav_item( array( 'name' => __( 'Home', 'buddypress' ), 'slug' => 'home', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_home', 'position' => 10, 'item_css_id' => 'home' ) );
|
197 |
|
198 |
/* If the user is a group mod or more, then show the group admin nav item */
|
199 |
if ( $bp->is_item_mod || $bp->is_item_admin )
|
200 |
+
bp_core_new_subnav_item( array( 'name' => __( 'Admin', 'buddypress' ), 'slug' => 'admin', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_admin', 'position' => 20, 'user_has_access' => ( $bp->is_item_admin + (int)$bp->is_item_mod ), 'item_css_id' => 'admin' ) );
|
201 |
|
202 |
// If this is a private group, and the user is not a member, show a "Request Membership" nav item.
|
203 |
+
if ( !is_site_admin() && is_user_logged_in() && !$bp->groups->current_group->is_user_member && !groups_check_for_membership_request( $bp->loggedin_user->id, $bp->groups->current_group->id ) && $bp->groups->current_group->status == 'private' )
|
204 |
bp_core_new_subnav_item( array( 'name' => __( 'Request Membership', 'buddypress' ), 'slug' => 'request-membership', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_request_membership', 'position' => 30 ) );
|
205 |
|
206 |
if ( $bp->groups->current_group->enable_forum && function_exists('bp_forums_setup') )
|
207 |
+
bp_core_new_subnav_item( array( 'name' => __( 'Forum', 'buddypress' ), 'slug' => 'forum', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_forum', 'position' => 40, 'user_has_access' => $bp->groups->current_group->user_has_access, 'item_css_id' => 'forums' ) );
|
208 |
|
209 |
+
bp_core_new_subnav_item( array( 'name' => sprintf( __( 'Members (%s)', 'buddypress' ), number_format( $bp->groups->current_group->total_member_count ) ), 'slug' => 'members', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_members', 'position' => 60, 'user_has_access' => $bp->groups->current_group->user_has_access, 'item_css_id' => 'members' ) );
|
|
|
|
|
|
|
210 |
|
211 |
if ( is_user_logged_in() && groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) {
|
212 |
if ( function_exists('friends_install') )
|
213 |
+
bp_core_new_subnav_item( array( 'name' => __( 'Send Invites', 'buddypress' ), 'slug' => 'send-invites', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_invite', 'item_css_id' => 'invite', 'position' => 70, 'user_has_access' => $bp->groups->current_group->user_has_access ) );
|
|
|
|
|
214 |
}
|
215 |
}
|
216 |
}
|
217 |
|
218 |
do_action( 'groups_setup_nav', $bp->groups->current_group->user_has_access );
|
219 |
}
|
220 |
+
add_action( 'bp_setup_nav', 'groups_setup_nav' );
|
221 |
add_action( 'admin_menu', 'groups_setup_nav' );
|
222 |
|
223 |
function groups_directory_groups_setup() {
|
227 |
$bp->is_directory = true;
|
228 |
|
229 |
do_action( 'groups_directory_groups_setup' );
|
230 |
+
bp_core_load_template( apply_filters( 'groups_template_directory_groups', 'groups/index' ) );
|
231 |
}
|
232 |
}
|
233 |
add_action( 'wp', 'groups_directory_groups_setup', 2 );
|
246 |
<a href=""><?php _e( 'Admin Options', 'buddypress' ) ?></a>
|
247 |
|
248 |
<ul>
|
249 |
+
<li><a class="confirm" href="<?php echo wp_nonce_url( bp_get_group_permalink( $bp->groups->current_group ) . 'admin/delete-group/', 'groups_delete_group' ) ?>&delete-group-button=1&delete-group-understand=1"><?php _e( "Delete Group", 'buddypress' ) ?></a></li>
|
250 |
|
251 |
<?php do_action( 'groups_adminbar_menu_items' ) ?>
|
252 |
</ul>
|
267 |
function groups_screen_my_groups() {
|
268 |
global $bp;
|
269 |
|
270 |
+
if ( isset($_GET['n']) ) {
|
271 |
+
// Delete group request notifications for the user
|
272 |
+
bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->slug, 'membership_request_accepted' );
|
273 |
+
bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->slug, 'membership_request_rejected' );
|
274 |
+
bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->slug, 'member_promoted_to_mod' );
|
275 |
+
bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->slug, 'member_promoted_to_admin' );
|
276 |
+
}
|
277 |
|
278 |
do_action( 'groups_screen_my_groups' );
|
279 |
|
280 |
+
bp_core_load_template( apply_filters( 'groups_template_my_groups', 'members/single/home' ) );
|
281 |
}
|
282 |
|
283 |
function groups_screen_group_invites() {
|
296 |
bp_core_add_message( __('Group invite accepted', 'buddypress') );
|
297 |
|
298 |
/* Record this in activity streams */
|
299 |
+
$group = new BP_Groups_Group( $group_id );
|
300 |
|
301 |
groups_record_activity( array(
|
302 |
+
'action' => apply_filters( 'groups_activity_accepted_invite_action', sprintf( __( '%s joined the group %s', 'buddypress'), bp_core_get_userlink( $bp->loggedin_user->id ), '<a href="' . bp_get_group_permalink( $group ) . '">' . attribute_escape( $group->name ) . '</a>' ), $bp->loggedin_user->id, &$group ),
|
303 |
+
'type' => 'joined_group',
|
|
|
304 |
'item_id' => $group->id
|
305 |
) );
|
306 |
}
|
326 |
|
327 |
do_action( 'groups_screen_group_invites', $group_id );
|
328 |
|
329 |
+
bp_core_load_template( apply_filters( 'groups_template_group_invites', 'members/single/home' ) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
330 |
}
|
331 |
|
|
|
332 |
function groups_screen_group_home() {
|
333 |
global $bp;
|
334 |
|
335 |
if ( $bp->is_single_item ) {
|
336 |
+
if ( isset($_GET['n']) ) {
|
|
|
337 |
// Delete group request notifications for the user
|
338 |
bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->slug, 'membership_request_accepted' );
|
339 |
bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->slug, 'membership_request_rejected' );
|
343 |
|
344 |
do_action( 'groups_screen_group_home' );
|
345 |
|
346 |
+
bp_core_load_template( apply_filters( 'groups_template_group_home', 'groups/single/home' ) );
|
|
|
|
|
|
|
347 |
}
|
348 |
}
|
349 |
|
368 |
if ( !is_site_admin() && 'public' == $bp->groups->current_group->status && !groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) )
|
369 |
groups_join_group( $bp->groups->current_group->id, $bp->loggedin_user->id );
|
370 |
|
371 |
+
if ( !$post_id = groups_new_group_forum_post( $_POST['reply_text'], $topic_id, $_GET['topic_page'] ) )
|
372 |
bp_core_add_message( __( 'There was an error when replying to that topic', 'buddypress'), 'error' );
|
373 |
else
|
374 |
bp_core_add_message( __( 'Your reply was posted successfully', 'buddypress') );
|
376 |
if ( $_SERVER['QUERY_STRING'] )
|
377 |
$query_vars = '?' . $_SERVER['QUERY_STRING'];
|
378 |
|
379 |
+
bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic_slug . '/' . $query_vars . '#post-' . $post_id );
|
380 |
}
|
381 |
|
382 |
/* Sticky a topic */
|
475 |
bp_core_add_message( __( 'The topic was edited successfully', 'buddypress') );
|
476 |
|
477 |
do_action( 'groups_edit_forum_topic', $topic_id );
|
478 |
+
bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic_slug . '/' );
|
479 |
}
|
480 |
|
481 |
+
bp_core_load_template( apply_filters( 'groups_template_group_forum_topic_edit', 'groups/single/home' ) );
|
482 |
}
|
483 |
|
484 |
/* Delete a post */
|
515 |
/* Check the nonce */
|
516 |
check_admin_referer( 'bp_forums_edit_post' );
|
517 |
|
518 |
+
if ( !$post_id = groups_update_group_forum_post( $post_id, $_POST['post_text'], $topic_id, $_GET['topic_page'] ) )
|
519 |
bp_core_add_message( __( 'There was an error when editing that post', 'buddypress'), 'error' );
|
520 |
else
|
521 |
bp_core_add_message( __( 'The post was edited successfully', 'buddypress') );
|
522 |
|
523 |
+
if ( $_SERVER['QUERY_STRING'] )
|
524 |
+
$query_vars = '?' . $_SERVER['QUERY_STRING'];
|
525 |
+
|
526 |
do_action( 'groups_edit_forum_post', $post_id );
|
527 |
+
bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic_slug . '/' . $query_vars . '#post-' . $post_id );
|
528 |
}
|
529 |
|
530 |
+
bp_core_load_template( apply_filters( 'groups_template_group_forum_topic_edit', 'groups/single/home' ) );
|
531 |
}
|
532 |
|
533 |
/* Standard topic display */
|
534 |
else {
|
535 |
+
bp_core_load_template( apply_filters( 'groups_template_group_forum_topic', 'groups/single/home' ) );
|
|
|
|
|
|
|
536 |
}
|
537 |
|
538 |
} else {
|
551 |
else
|
552 |
bp_core_add_message( __( 'The topic was created successfully', 'buddypress') );
|
553 |
|
554 |
+
bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic->topic_slug . '/' );
|
555 |
}
|
556 |
|
557 |
do_action( 'groups_screen_group_forum', $topic_id, $forum_id );
|
558 |
|
559 |
+
bp_core_load_template( apply_filters( 'groups_template_group_forum', 'groups/single/home' ) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
560 |
}
|
561 |
}
|
562 |
}
|
566 |
|
567 |
if ( $bp->is_single_item ) {
|
568 |
do_action( 'groups_screen_group_members', $bp->groups->current_group->id );
|
569 |
+
bp_core_load_template( apply_filters( 'groups_template_group_members', 'groups/single/home' ) );
|
|
|
|
|
|
|
|
|
570 |
}
|
571 |
}
|
572 |
|
589 |
bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) );
|
590 |
} else {
|
591 |
// Show send invite page
|
592 |
+
bp_core_load_template( apply_filters( 'groups_template_group_invite', 'groups/single/home' ) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
593 |
}
|
594 |
}
|
595 |
}
|
617 |
|
618 |
do_action( 'groups_screen_group_request_membership', $bp->groups->current_group->id );
|
619 |
|
620 |
+
bp_core_load_template( apply_filters( 'groups_template_group_request_membership', 'groups/single/home' ) );
|
|
|
|
|
|
|
621 |
}
|
622 |
}
|
623 |
|
624 |
+
function groups_screen_group_activity_permalink() {
|
625 |
+
global $bp;
|
626 |
+
|
627 |
+
if ( $bp->current_component != $bp->groups->slug || $bp->current_action != $bp->activity->slug || empty( $bp->action_variables[0] ) )
|
628 |
+
return false;
|
629 |
+
|
630 |
+
$bp->is_single_item = true;
|
631 |
+
|
632 |
+
bp_core_load_template( apply_filters( 'groups_template_group_home', 'groups/single/home' ) );
|
633 |
+
}
|
634 |
+
add_action( 'wp', 'groups_screen_group_activity_permalink', 3 );
|
635 |
+
|
636 |
function groups_screen_group_admin() {
|
637 |
global $bp;
|
638 |
|
642 |
if ( !empty( $bp->action_variables[0] ) )
|
643 |
return false;
|
644 |
|
645 |
+
bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . 'admin/edit-details/' );
|
646 |
}
|
647 |
|
648 |
function groups_screen_group_admin_edit_details() {
|
658 |
if ( !check_admin_referer( 'groups_edit_group_details' ) )
|
659 |
return false;
|
660 |
|
661 |
+
if ( !groups_edit_base_group_details( $_POST['group-id'], $_POST['group-name'], $_POST['group-desc'], (int)$_POST['group-notify-members'] ) ) {
|
662 |
bp_core_add_message( __( 'There was an error updating group details, please try again.', 'buddypress' ), 'error' );
|
663 |
} else {
|
664 |
bp_core_add_message( __( 'Group details were successfully updated.', 'buddypress' ) );
|
666 |
|
667 |
do_action( 'groups_group_details_edited', $bp->groups->current_group->id );
|
668 |
|
669 |
+
bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . 'admin/edit-details/' );
|
670 |
}
|
671 |
|
672 |
do_action( 'groups_screen_group_admin_edit_details', $bp->groups->current_group->id );
|
673 |
|
674 |
+
bp_core_load_template( apply_filters( 'groups_template_group_admin', 'groups/single/home' ) );
|
|
|
|
|
|
|
675 |
}
|
676 |
}
|
677 |
}
|
687 |
|
688 |
// If the edit form has been submitted, save the edited details
|
689 |
if ( isset( $_POST['save'] ) ) {
|
|
|
690 |
$enable_forum = ( isset($_POST['group-show-forum'] ) ) ? 1 : 0;
|
|
|
|
|
691 |
|
692 |
$allowed_status = apply_filters( 'groups_allowed_status', array( 'public', 'private', 'hidden' ) );
|
693 |
$status = ( in_array( $_POST['group-status'], (array)$allowed_status ) ) ? $_POST['group-status'] : 'public';
|
696 |
if ( !check_admin_referer( 'groups_edit_group_settings' ) )
|
697 |
return false;
|
698 |
|
699 |
+
if ( !groups_edit_group_settings( $_POST['group-id'], $enable_forum, $status ) ) {
|
700 |
bp_core_add_message( __( 'There was an error updating group settings, please try again.', 'buddypress' ), 'error' );
|
701 |
} else {
|
702 |
bp_core_add_message( __( 'Group settings were successfully updated.', 'buddypress' ) );
|
704 |
|
705 |
do_action( 'groups_group_settings_edited', $bp->groups->current_group->id );
|
706 |
|
707 |
+
bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . 'admin/group-settings/' );
|
708 |
}
|
709 |
|
710 |
do_action( 'groups_screen_group_admin_settings', $bp->groups->current_group->id );
|
711 |
|
712 |
+
bp_core_load_template( apply_filters( 'groups_template_group_admin_settings', 'groups/single/home' ) );
|
|
|
|
|
|
|
713 |
}
|
714 |
}
|
715 |
add_action( 'wp', 'groups_screen_group_admin_settings', 4 );
|
767 |
|
768 |
do_action( 'groups_screen_group_admin_avatar', $bp->groups->current_group->id );
|
769 |
|
770 |
+
bp_core_load_template( apply_filters( 'groups_template_group_admin_avatar', 'groups/single/home' ) );
|
|
|
|
|
|
|
771 |
}
|
772 |
}
|
773 |
add_action( 'wp', 'groups_screen_group_admin_avatar', 4 );
|
797 |
|
798 |
do_action( 'groups_promoted_member', $user_id, $bp->groups->current_group->id );
|
799 |
|
800 |
+
bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . 'admin/manage-members/' );
|
801 |
}
|
802 |
|
803 |
if ( 'demote' == $bp->action_variables[1] && is_numeric( $bp->action_variables[2] ) ) {
|
816 |
|
817 |
do_action( 'groups_demoted_member', $user_id, $bp->groups->current_group->id );
|
818 |
|
819 |
+
bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . 'admin/manage-members/' );
|
820 |
}
|
821 |
|
822 |
if ( 'ban' == $bp->action_variables[1] && is_numeric( $bp->action_variables[2] ) ) {
|
835 |
|
836 |
do_action( 'groups_banned_member', $user_id, $bp->groups->current_group->id );
|
837 |
|
838 |
+
bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . 'admin/manage-members/' );
|
839 |
}
|
840 |
|
841 |
if ( 'unban' == $bp->action_variables[1] && is_numeric( $bp->action_variables[2] ) ) {
|
854 |
|
855 |
do_action( 'groups_unbanned_member', $user_id, $bp->groups->current_group->id );
|
856 |
|
857 |
+
bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . 'admin/manage-members/' );
|
858 |
}
|
859 |
|
860 |
do_action( 'groups_screen_group_admin_manage_members', $bp->groups->current_group->id );
|
861 |
|
862 |
+
bp_core_load_template( apply_filters( 'groups_template_group_admin_manage_members', 'groups/single/home' ) );
|
|
|
|
|
|
|
863 |
}
|
864 |
}
|
865 |
add_action( 'wp', 'groups_screen_group_admin_manage_members', 4 );
|
908 |
|
909 |
do_action( 'groups_group_request_managed', $bp->groups->current_group->id, $request_action, $membership_id );
|
910 |
|
911 |
+
bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . 'admin/membership-requests/' );
|
912 |
}
|
913 |
|
914 |
do_action( 'groups_screen_group_admin_requests', $bp->groups->current_group->id );
|
915 |
|
916 |
+
bp_core_load_template( apply_filters( 'groups_template_group_admin_requests', 'groups/single/home' ) );
|
|
|
|
|
|
|
917 |
}
|
918 |
}
|
919 |
add_action( 'wp', 'groups_screen_group_admin_requests', 4 );
|
947 |
|
948 |
do_action( 'groups_screen_group_admin_delete_group', $bp->groups->current_group->id );
|
949 |
|
950 |
+
bp_core_load_template( apply_filters( 'groups_template_group_admin_delete_group', 'groups/single/home' ) );
|
|
|
|
|
|
|
951 |
}
|
952 |
}
|
953 |
add_action( 'wp', 'groups_screen_group_admin_delete_group', 4 );
|
973 |
<td class="yes"><input type="radio" name="notifications[notification_groups_group_updated]" value="yes" <?php if ( !get_usermeta( $current_user->id, 'notification_groups_group_updated') || 'yes' == get_usermeta( $current_user->id, 'notification_groups_group_updated') ) { ?>checked="checked" <?php } ?>/></td>
|
974 |
<td class="no"><input type="radio" name="notifications[notification_groups_group_updated]" value="no" <?php if ( 'no' == get_usermeta( $current_user->id, 'notification_groups_group_updated') ) { ?>checked="checked" <?php } ?>/></td>
|
975 |
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
976 |
<tr>
|
977 |
<td></td>
|
978 |
<td><?php _e( 'You are promoted to a group administrator or moderator', 'buddypress' ) ?></td>
|
986 |
<td class="no"><input type="radio" name="notifications[notification_groups_membership_request]" value="no" <?php if ( 'no' == get_usermeta( $current_user->id, 'notification_groups_membership_request') ) { ?>checked="checked" <?php } ?>/></td>
|
987 |
</tr>
|
988 |
|
989 |
+
<?php do_action( 'groups_screen_notification_settings' ); ?>
|
990 |
+
</table>
|
991 |
+
<?php
|
992 |
+
}
|
993 |
+
add_action( 'bp_notification_settings', 'groups_screen_notification_settings' );
|
994 |
+
|
995 |
+
|
996 |
+
/********************************************************************************
|
997 |
+
* Action Functions
|
998 |
+
*
|
999 |
+
* Action functions are exactly the same as screen functions, however they do not
|
1000 |
+
* have a template screen associated with them. Usually they will send the user
|
1001 |
+
* back to the default screen after execution.
|
1002 |
+
*/
|
1003 |
+
|
1004 |
+
function groups_action_create_group() {
|
1005 |
+
global $bp;
|
1006 |
+
|
1007 |
+
/* If we're not at domain.org/groups/create/ then return false */
|
1008 |
+
if ( $bp->current_component != $bp->groups->slug || 'create' != $bp->current_action )
|
1009 |
+
return false;
|
1010 |
+
|
1011 |
+
if ( !is_user_logged_in() )
|
1012 |
+
return false;
|
1013 |
+
|
1014 |
+
/* Make sure creation steps are in the right order */
|
1015 |
+
groups_action_sort_creation_steps();
|
1016 |
+
|
1017 |
+
/* If no current step is set, reset everything so we can start a fresh group creation */
|
1018 |
+
if ( !$bp->groups->current_create_step = $bp->action_variables[1] ) {
|
1019 |
+
|
1020 |
+
unset( $bp->groups->current_create_step );
|
1021 |
+
unset( $bp->groups->completed_create_steps );
|
1022 |
+
|
1023 |
+
setcookie( 'bp_new_group_id', false, time() - 1000, COOKIEPATH );
|
1024 |
+
setcookie( 'bp_completed_create_steps', false, time() - 1000, COOKIEPATH );
|
1025 |
+
|
1026 |
+
$reset_steps = true;
|
1027 |
+
bp_core_redirect( $bp->root_domain . '/' . $bp->groups->slug . '/create/step/' . array_shift( array_keys( $bp->groups->group_creation_steps ) ) . '/' );
|
1028 |
+
}
|
1029 |
+
|
1030 |
+
/* If this is a creation step that is not recognized, just redirect them back to the first screen */
|
1031 |
+
if ( $bp->action_variables[1] && !$bp->groups->group_creation_steps[$bp->action_variables[1]] ) {
|
1032 |
+
bp_core_add_message( __('There was an error saving group details. Please try again.', 'buddypress'), 'error' );
|
1033 |
+
bp_core_redirect( $bp->root_domain . '/' . $bp->groups->slug . '/create/' );
|
1034 |
+
}
|
1035 |
+
|
1036 |
+
/* Fetch the currently completed steps variable */
|
1037 |
+
if ( isset( $_COOKIE['bp_completed_create_steps'] ) && !$reset_steps )
|
1038 |
+
$bp->groups->completed_create_steps = unserialize( stripslashes( $_COOKIE['bp_completed_create_steps'] ) );
|
1039 |
+
|
1040 |
+
/* Set the ID of the new group, if it has already been created in a previous step */
|
1041 |
+
if ( isset( $_COOKIE['bp_new_group_id'] ) ) {
|
1042 |
+
$bp->groups->new_group_id = $_COOKIE['bp_new_group_id'];
|
1043 |
+
$bp->groups->current_group = new BP_Groups_Group( $bp->groups->new_group_id );
|
1044 |
+
}
|
1045 |
+
|
1046 |
+
/* If the save, upload or skip button is hit, lets calculate what we need to save */
|
1047 |
+
if ( isset( $_POST['save'] ) ) {
|
1048 |
+
|
1049 |
+
/* Check the nonce */
|
1050 |
+
check_admin_referer( 'groups_create_save_' . $bp->groups->current_create_step );
|
1051 |
+
|
1052 |
+
if ( 'group-details' == $bp->groups->current_create_step ) {
|
1053 |
+
if ( empty( $_POST['group-name'] ) || empty( $_POST['group-desc'] ) || !strlen( trim( $_POST['group-name'] ) ) || !strlen( trim( $_POST['group-desc'] ) ) ) {
|
1054 |
+
bp_core_add_message( __( 'Please fill in all of the required fields', 'buddypress' ), 'error' );
|
1055 |
+
bp_core_redirect( $bp->root_domain . '/' . $bp->groups->slug . '/create/step/' . $bp->groups->current_create_step . '/' );
|
1056 |
+
}
|
1057 |
+
|
1058 |
+
if ( !$bp->groups->new_group_id = groups_create_group( array( 'group_id' => $bp->groups->new_group_id, 'name' => $_POST['group-name'], 'description' => $_POST['group-desc'], 'slug' => groups_check_slug( sanitize_title($_POST['group-name']) ), 'date_created' => gmdate( "Y-m-d H:i:s" ), 'status' => 'public' ) ) ) {
|
1059 |
+
bp_core_add_message( __( 'There was an error saving group details, please try again.', 'buddypress' ), 'error' );
|
1060 |
+
bp_core_redirect( $bp->root_domain . '/' . $bp->groups->slug . '/create/step/' . $bp->groups->current_create_step . '/' );
|
1061 |
+
}
|
1062 |
+
|
1063 |
+
groups_update_groupmeta( $bp->groups->new_group_id, 'total_member_count', 1 );
|
1064 |
+
groups_update_groupmeta( $bp->groups->new_group_id, 'last_activity', gmdate( "Y-m-d H:i:s" ) );
|
1065 |
+
}
|
1066 |
+
|
1067 |
+
if ( 'group-settings' == $bp->groups->current_create_step ) {
|
1068 |
+
$group_status = 'public';
|
1069 |
+
$group_enable_forum = 1;
|
1070 |
+
|
1071 |
+
if ( !isset($_POST['group-show-forum']) ) {
|
1072 |
+
$group_enable_forum = 0;
|
1073 |
+
} else {
|
1074 |
+
/* Create the forum if enable_forum = 1 */
|
1075 |
+
if ( function_exists( 'bp_forums_setup' ) && '' == groups_get_groupmeta( $bp->groups->new_group_id, 'forum_id' ) ) {
|
1076 |
+
groups_new_group_forum();
|
1077 |
+
}
|
1078 |
+
}
|
1079 |
+
|
1080 |
+
if ( 'private' == $_POST['group-status'] )
|
1081 |
+
$group_status = 'private';
|
1082 |
+
else if ( 'hidden' == $_POST['group-status'] )
|
1083 |
+
$group_status = 'hidden';
|
1084 |
+
|
1085 |
+
if ( !$bp->groups->new_group_id = groups_create_group( array( 'group_id' => $bp->groups->new_group_id, 'status' => $group_status, 'enable_forum' => $group_enable_forum ) ) ) {
|
1086 |
+
bp_core_add_message( __( 'There was an error saving group details, please try again.', 'buddypress' ), 'error' );
|
1087 |
+
bp_core_redirect( $bp->root_domain . '/' . $bp->groups->slug . '/create/step/' . $bp->groups->current_create_step . '/' );
|
1088 |
+
}
|
1089 |
+
}
|
1090 |
+
|
1091 |
+
if ( 'group-invites' == $bp->groups->current_create_step ) {
|
1092 |
+
groups_send_invites( $bp->loggedin_user->id, $bp->groups->new_group_id );
|
1093 |
+
}
|
1094 |
+
|
1095 |
+
do_action( 'groups_create_group_step_save_' . $bp->groups->current_create_step );
|
1096 |
+
do_action( 'groups_create_group_step_complete' ); // Mostly for clearing cache on a generic action name
|
1097 |
+
|
1098 |
+
/**
|
1099 |
+
* Once we have successfully saved the details for this step of the creation process
|
1100 |
+
* we need to add the current step to the array of completed steps, then update the cookies
|
1101 |
+
* holding the information
|
1102 |
+
*/
|
1103 |
+
if ( !in_array( $bp->groups->current_create_step, (array)$bp->groups->completed_create_steps ) )
|
1104 |
+
$bp->groups->completed_create_steps[] = $bp->groups->current_create_step;
|
1105 |
+
|
1106 |
+
/* Reset cookie info */
|
1107 |
+
setcookie( 'bp_new_group_id', $bp->groups->new_group_id, time()+60*60*24, COOKIEPATH );
|
1108 |
+
setcookie( 'bp_completed_create_steps', serialize( $bp->groups->completed_create_steps ), time()+60*60*24, COOKIEPATH );
|
1109 |
+
|
1110 |
+
/* If we have completed all steps and hit done on the final step we can redirect to the completed group */
|
1111 |
+
if ( count( $bp->groups->completed_create_steps ) == count( $bp->groups->group_creation_steps ) && $bp->groups->current_create_step == array_pop( array_keys( $bp->groups->group_creation_steps ) ) ) {
|
1112 |
+
unset( $bp->groups->current_create_step );
|
1113 |
+
unset( $bp->groups->completed_create_steps );
|
1114 |
+
|
1115 |
+
/* Once we compelete all steps, record the group creation in the activity stream. */
|
1116 |
+
groups_record_activity( array(
|
1117 |
+
'action' => apply_filters( 'groups_activity_created_group_action', sprintf( __( '%s created the group %s', 'buddypress'), bp_core_get_userlink( $bp->loggedin_user->id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . attribute_escape( $bp->groups->current_group->name ) . '</a>' ) ),
|
1118 |
+
'type' => 'created_group',
|
1119 |
+
'item_id' => $bp->groups->new_group_id
|
1120 |
+
) );
|
1121 |
+
|
1122 |
+
do_action( 'groups_group_create_complete', $bp->groups->new_group_id );
|
1123 |
+
|
1124 |
+
bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) );
|
1125 |
+
} else {
|
1126 |
+
/**
|
1127 |
+
* Since we don't know what the next step is going to be (any plugin can insert steps)
|
1128 |
+
* we need to loop the step array and fetch the next step that way.
|
1129 |
+
*/
|
1130 |
+
foreach ( (array)$bp->groups->group_creation_steps as $key => $value ) {
|
1131 |
+
if ( $key == $bp->groups->current_create_step ) {
|
1132 |
+
$next = 1;
|
1133 |
+
continue;
|
1134 |
+
}
|
1135 |
+
|
1136 |
+
if ( $next ) {
|
1137 |
+
$next_step = $key;
|
1138 |
+
break;
|
1139 |
+
}
|
1140 |
+
}
|
1141 |
|
1142 |
+
bp_core_redirect( $bp->root_domain . '/' . $bp->groups->slug . '/create/step/' . $next_step . '/' );
|
1143 |
+
}
|
1144 |
+
}
|
1145 |
|
1146 |
+
/* Group avatar is handled separately */
|
1147 |
+
if ( 'group-avatar' == $bp->groups->current_create_step && isset( $_POST['upload'] ) ) {
|
1148 |
+
if ( !empty( $_FILES ) && isset( $_POST['upload'] ) ) {
|
1149 |
+
/* Normally we would check a nonce here, but the group save nonce is used instead */
|
1150 |
+
|
1151 |
+
/* Pass the file to the avatar upload handler */
|
1152 |
+
if ( bp_core_avatar_handle_upload( $_FILES, 'groups_avatar_upload_dir' ) ) {
|
1153 |
+
$bp->avatar_admin->step = 'crop-image';
|
1154 |
+
|
1155 |
+
/* Make sure we include the jQuery jCrop file for image cropping */
|
1156 |
+
add_action( 'wp', 'bp_core_add_jquery_cropper' );
|
1157 |
+
}
|
1158 |
+
}
|
1159 |
+
|
1160 |
+
/* If the image cropping is done, crop the image and save a full/thumb version */
|
1161 |
+
if ( isset( $_POST['avatar-crop-submit'] ) && isset( $_POST['upload'] ) ) {
|
1162 |
+
/* Normally we would check a nonce here, but the group save nonce is used instead */
|
1163 |
+
|
1164 |
+
if ( !bp_core_avatar_handle_crop( array( 'object' => 'group', 'avatar_dir' => 'group-avatars', 'item_id' => $bp->groups->current_group->id, 'original_file' => $_POST['image_src'], 'crop_x' => $_POST['x'], 'crop_y' => $_POST['y'], 'crop_w' => $_POST['w'], 'crop_h' => $_POST['h'] ) ) )
|
1165 |
+
bp_core_add_message( __( 'There was an error saving the group avatar, please try uploading again.', 'buddypress' ), 'error' );
|
1166 |
+
else
|
1167 |
+
bp_core_add_message( __( 'The group avatar was uploaded successfully!', 'buddypress' ) );
|
1168 |
+
}
|
1169 |
+
}
|
1170 |
+
|
1171 |
+
bp_core_load_template( apply_filters( 'groups_template_create_group', 'groups/create' ) );
|
1172 |
+
}
|
1173 |
+
add_action( 'wp', 'groups_action_create_group', 3 );
|
1174 |
|
1175 |
function groups_action_join_group() {
|
1176 |
global $bp;
|
1188 |
bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) );
|
1189 |
}
|
1190 |
|
1191 |
+
bp_core_load_template( apply_filters( 'groups_template_group_home', 'groups/single/home' ) );
|
|
|
|
|
|
|
1192 |
}
|
1193 |
add_action( 'wp', 'groups_action_join_group', 3 );
|
1194 |
|
1201 |
if ( !is_array( $bp->groups->group_creation_steps ) )
|
1202 |
return false;
|
1203 |
|
1204 |
+
foreach ( (array)$bp->groups->group_creation_steps as $slug => $step ) {
|
1205 |
+
while ( !empty( $temp[$step['position']] ) )
|
1206 |
+
$step['position']++;
|
1207 |
+
|
1208 |
$temp[$step['position']] = array( 'name' => $step['name'], 'slug' => $slug );
|
1209 |
+
}
|
1210 |
|
1211 |
/* Sort the steps by their position key */
|
1212 |
ksort($temp);
|
1213 |
unset($bp->groups->group_creation_steps);
|
1214 |
|
1215 |
+
foreach( (array)$temp as $position => $step )
|
1216 |
$bp->groups->group_creation_steps[$step['slug']] = array( 'name' => $step['name'], 'position' => $position );
|
1217 |
}
|
|
|
1218 |
|
1219 |
+
function groups_action_redirect_to_random_group() {
|
1220 |
global $bp, $wpdb;
|
1221 |
|
1222 |
if ( $bp->current_component == $bp->groups->slug && isset( $_GET['random-group'] ) ) {
|
1223 |
+
$group = groups_get_groups( array( 'type' => 'random', 'per_page' => 1 ) );
|
1224 |
+
|
1225 |
+
bp_core_redirect( $bp->root_domain . '/' . $bp->groups->slug . '/' . $group['groups'][0]->slug . '/' );
|
1226 |
+
}
|
1227 |
+
}
|
1228 |
+
add_action( 'wp', 'groups_action_redirect_to_random_group', 6 );
|
1229 |
+
|
1230 |
+
function groups_action_group_feed() {
|
1231 |
+
global $bp, $wp_query;
|
1232 |
|
1233 |
+
if ( $bp->current_component != $bp->groups->slug || !$bp->groups->current_group || $bp->current_action != 'feed' )
|
1234 |
+
return false;
|
1235 |
+
|
1236 |
+
$wp_query->is_404 = false;
|
1237 |
+
status_header( 200 );
|
1238 |
+
|
1239 |
+
if ( 'public' != $bp->groups->current_group->status ) {
|
1240 |
+
if ( !groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) )
|
1241 |
+
return false;
|
1242 |
}
|
1243 |
+
|
1244 |
+
include_once( 'bp-activity/feeds/bp-activity-group-feed.php' );
|
1245 |
+
die;
|
1246 |
}
|
1247 |
+
add_action( 'wp', 'groups_action_group_feed', 3 );
|
1248 |
|
1249 |
|
1250 |
/********************************************************************************
|
1262 |
|
1263 |
bp_activity_set_action( $bp->groups->id, 'created_group', __( 'Created a group', 'buddypress' ) );
|
1264 |
bp_activity_set_action( $bp->groups->id, 'joined_group', __( 'Joined a group', 'buddypress' ) );
|
|
|
1265 |
bp_activity_set_action( $bp->groups->id, 'new_forum_topic', __( 'New group forum topic', 'buddypress' ) );
|
1266 |
bp_activity_set_action( $bp->groups->id, 'new_forum_post', __( 'New group forum post', 'buddypress' ) );
|
1267 |
|
1268 |
do_action( 'groups_register_activity_actions' );
|
1269 |
}
|
1270 |
+
add_action( 'bp_register_activity_actions', 'groups_register_activity_actions' );
|
1271 |
|
1272 |
function groups_record_activity( $args = '' ) {
|
1273 |
global $bp;
|
1275 |
if ( !function_exists( 'bp_activity_add' ) )
|
1276 |
return false;
|
1277 |
|
1278 |
+
/* If the group is not public, hide the activity sitewide. */
|
1279 |
+
if ( 'public' == $bp->groups->current_group->status )
|
1280 |
+
$hide_sitewide = false;
|
1281 |
+
else
|
1282 |
+
$hide_sitewide = true;
|
1283 |
|
1284 |
$defaults = array(
|
1285 |
+
'id' => false,
|
1286 |
'user_id' => $bp->loggedin_user->id,
|
1287 |
+
'action' => '',
|
1288 |
+
'content' => '',
|
1289 |
+
'primary_link' => '',
|
1290 |
+
'component' => $bp->groups->id,
|
1291 |
+
'type' => false,
|
1292 |
'item_id' => false,
|
1293 |
'secondary_item_id' => false,
|
1294 |
+
'recorded_time' => gmdate( "Y-m-d H:i:s" ),
|
1295 |
+
'hide_sitewide' => $hide_sitewide
|
1296 |
);
|
1297 |
|
1298 |
$r = wp_parse_args( $args, $defaults );
|
1299 |
extract( $r, EXTR_SKIP );
|
1300 |
|
1301 |
+
return bp_activity_add( array( 'id' => $id, '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 ) );
|
1302 |
}
|
1303 |
|
1304 |
function groups_update_last_activity( $group_id ) {
|
1305 |
+
groups_update_groupmeta( $group_id, 'last_activity', gmdate( "Y-m-d H:i:s" ) );
|
1306 |
}
|
|
|
|
|
1307 |
add_action( 'groups_joined_group', 'groups_update_last_activity' );
|
1308 |
add_action( 'groups_leave_group', 'groups_update_last_activity' );
|
1309 |
add_action( 'groups_created_group', 'groups_update_last_activity' );
|
1318 |
$group_id = $secondary_item_id;
|
1319 |
$requesting_user_id = $item_id;
|
1320 |
|
1321 |
+
$group = new BP_Groups_Group( $group_id );
|
1322 |
|
1323 |
$group_link = bp_get_group_permalink( $group );
|
1324 |
|
1325 |
if ( (int)$total_items > 1 ) {
|
1326 |
+
return apply_filters( 'bp_groups_multiple_new_membership_requests_notification', '<a href="' . $group_link . '/admin/membership-requests/?n=1" title="' . __( 'Group Membership Requests', 'buddypress' ) . '">' . sprintf( __('%d new membership requests for the group "%s"', 'buddypress' ), (int)$total_items, $group->name ) . '</a>', $group_link, $total_items, $group->name );
|
1327 |
} else {
|
1328 |
$user_fullname = bp_core_get_user_displayname( $requesting_user_id );
|
1329 |
+
return apply_filters( 'bp_groups_single_new_membership_request_notification', '<a href="' . $group_link . 'admin/membership-requests/?n=1" title="' . $user_fullname .' requests group membership">' . sprintf( __('%s requests membership for the group "%s"', 'buddypress' ), $user_fullname, $group->name ) . '</a>', $group_link, $user_fullname, $group->name );
|
1330 |
}
|
1331 |
break;
|
1332 |
|
1333 |
case 'membership_request_accepted':
|
1334 |
$group_id = $item_id;
|
1335 |
|
1336 |
+
$group = new BP_Groups_Group( $group_id );
|
1337 |
+
$group_link = bp_get_group_permalink( $group );
|
1338 |
|
1339 |
if ( (int)$total_items > 1 ) {
|
1340 |
+
return apply_filters( 'bp_groups_multiple_membership_request_accepted_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '/?n=1" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __('%d accepted group membership requests', 'buddypress' ), (int)$total_items, $group->name ) . '</a>', $total_items, $group_name );
|
1341 |
} else {
|
1342 |
+
return apply_filters( 'bp_groups_single_membership_request_accepted_notification', '<a href="' . $group_link . '?n=1">' . sprintf( __('Membership for group "%s" accepted'), $group->name ) . '</a>', $group_link, $group->name );
|
1343 |
}
|
1344 |
break;
|
1345 |
|
1346 |
case 'membership_request_rejected':
|
1347 |
$group_id = $item_id;
|
1348 |
|
1349 |
+
$group = new BP_Groups_Group( $group_id );
|
1350 |
+
$group_link = bp_get_group_permalink( $group );
|
1351 |
|
1352 |
if ( (int)$total_items > 1 ) {
|
1353 |
+
return apply_filters( 'bp_groups_multiple_membership_request_rejected_notification', '<a href="' . site_url() . '/' . BP_MEMBERS_SLUG . '/' . $bp->groups->slug . '/?n=1" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __('%d rejected group membership requests', 'buddypress' ), (int)$total_items, $group->name ) . '</a>', $total_items, $group->name );
|
1354 |
} else {
|
1355 |
+
return apply_filters( 'bp_groups_single_membership_request_rejected_notification', '<a href="' . $group_link . '?n=1">' . sprintf( __('Membership for group "%s" rejected'), $group->name ) . '</a>', $group_link, $group->name );
|
1356 |
}
|
1357 |
|
1358 |
break;
|
1360 |
case 'member_promoted_to_admin':
|
1361 |
$group_id = $item_id;
|
1362 |
|
1363 |
+
$group = new BP_Groups_Group( $group_id );
|
1364 |
+
$group_link = bp_get_group_permalink( $group );
|
1365 |
|
1366 |
if ( (int)$total_items > 1 ) {
|
1367 |
+
return apply_filters( 'bp_groups_multiple_member_promoted_to_admin_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '/?n=1" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __('You were promoted to an admin in %d groups', 'buddypress' ), (int)$total_items ) . '</a>', $total_items );
|
1368 |
} else {
|
1369 |
+
return apply_filters( 'bp_groups_single_member_promoted_to_admin_notification', '<a href="' . $group_link . '?n=1">' . sprintf( __('You were promoted to an admin in the group %s'), $group->name ) . '</a>', $group_link, $group->name );
|
1370 |
}
|
1371 |
break;
|
1372 |
|
1373 |
case 'member_promoted_to_mod':
|
1374 |
$group_id = $item_id;
|
1375 |
|
1376 |
+
$group = new BP_Groups_Group( $group_id );
|
1377 |
+
$group_link = bp_get_group_permalink( $group );
|
1378 |
|
1379 |
if ( (int)$total_items > 1 ) {
|
1380 |
+
return apply_filters( 'bp_groups_multiple_member_promoted_to_mod_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '/?n=1" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __('You were promoted to a mod in %d groups', 'buddypress' ), (int)$total_items ) . '</a>', $total_items );
|
1381 |
} else {
|
1382 |
+
return apply_filters( 'bp_groups_single_member_promoted_to_mod_notification', '<a href="' . $group_link . '?n=1">' . sprintf( __('You were promoted to a mod in the group %s'), $group->name ) . '</a>', $group_link, $group->name );
|
1383 |
}
|
1384 |
break;
|
1385 |
|
1386 |
case 'group_invite':
|
1387 |
$group_id = $item_id;
|
1388 |
|
1389 |
+
$group = new BP_Groups_Group( $group_id );
|
1390 |
+
$user_url = bp_core_get_user_domain( $user_id );
|
1391 |
|
1392 |
if ( (int)$total_items > 1 ) {
|
1393 |
+
return apply_filters( 'bp_groups_multiple_group_invite_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '/invites/?n=1" title="' . __( 'Group Invites', 'buddypress' ) . '">' . sprintf( __('You have %d new group invitations', 'buddypress' ), (int)$total_items ) . '</a>', $total_items );
|
1394 |
} else {
|
1395 |
+
return apply_filters( 'bp_groups_single_group_invite_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '/invites/?n=1" title="' . __( 'Group Invites', 'buddypress' ) . '">' . sprintf( __('You have an invitation to the group: %s', 'buddypress' ), $group->name ) . '</a>', $group->name );
|
1396 |
}
|
1397 |
break;
|
1398 |
}
|
1412 |
* true or false on success or failure.
|
1413 |
*/
|
1414 |
|
1415 |
+
function groups_get_group( $args = '' ) {
|
1416 |
+
$defaults = array(
|
1417 |
+
'group_id' => false,
|
1418 |
+
'load_users' => false
|
1419 |
+
);
|
1420 |
+
|
1421 |
+
$args = wp_parse_args( $args, $defaults );
|
1422 |
+
extract( $args, EXTR_SKIP );
|
1423 |
+
|
1424 |
+
return apply_filters( 'groups_get_group', new BP_Groups_Group( $group_id, true, $load_users ) );
|
1425 |
+
}
|
1426 |
+
|
1427 |
/*** Group Creation, Editing & Deletion *****************************************/
|
1428 |
|
1429 |
function groups_create_group( $args = '' ) {
|
1437 |
* 'creator_id'
|
1438 |
* 'name'
|
1439 |
* 'description'
|
|
|
1440 |
* 'slug'
|
1441 |
* 'status'
|
|
|
1442 |
* 'enable_forum'
|
1443 |
* 'date_created'
|
1444 |
*/
|
1448 |
else
|
1449 |
$group = new BP_Groups_Group;
|
1450 |
|
1451 |
+
if ( $creator_id )
|
1452 |
$group->creator_id = $creator_id;
|
1453 |
+
else
|
1454 |
$group->creator_id = $bp->loggedin_user->id;
|
|
|
1455 |
|
1456 |
if ( isset( $name ) )
|
1457 |
$group->name = $name;
|
1459 |
if ( isset( $description ) )
|
1460 |
$group->description = $description;
|
1461 |
|
|
|
|
|
|
|
1462 |
if ( isset( $slug ) && groups_check_slug( $slug ) )
|
1463 |
$group->slug = $slug;
|
1464 |
|
1467 |
$group->status = $status;
|
1468 |
}
|
1469 |
|
|
|
|
|
|
|
|
|
|
|
1470 |
if ( isset( $enable_forum ) )
|
1471 |
$group->enable_forum = $enable_forum;
|
1472 |
else if ( !$group_id && !isset( $enable_forum ) )
|
1486 |
$member->is_admin = 1;
|
1487 |
$member->user_title = __( 'Group Admin', 'buddypress' );
|
1488 |
$member->is_confirmed = 1;
|
1489 |
+
$member->date_modified = gmdate( "Y-m-d H:i:s" );
|
1490 |
|
1491 |
$member->save();
|
1492 |
}
|
1493 |
|
1494 |
+
do_action( 'groups_created_group', $group->id );
|
1495 |
+
|
1496 |
return $group->id;
|
1497 |
}
|
1498 |
|
1499 |
+
function groups_edit_base_group_details( $group_id, $group_name, $group_desc, $notify_members ) {
|
1500 |
global $bp;
|
1501 |
|
1502 |
if ( empty( $group_name ) || empty( $group_desc ) )
|
1503 |
return false;
|
1504 |
|
1505 |
+
$group = new BP_Groups_Group( $group_id );
|
1506 |
$group->name = $group_name;
|
1507 |
$group->description = $group_desc;
|
|
|
1508 |
|
1509 |
if ( !$group->save() )
|
1510 |
return false;
|
1519 |
return true;
|
1520 |
}
|
1521 |
|
1522 |
+
function groups_edit_group_settings( $group_id, $enable_forum, $status ) {
|
1523 |
global $bp;
|
1524 |
|
1525 |
+
$group = new BP_Groups_Group( $group_id );
|
|
|
1526 |
$group->enable_forum = $enable_forum;
|
|
|
|
|
1527 |
|
1528 |
/***
|
1529 |
* Before we potentially switch the group status, if it has been changed to public
|
1565 |
|
1566 |
/* Delete all group activity from activity streams */
|
1567 |
if ( function_exists( 'bp_activity_delete_by_item_id' ) ) {
|
1568 |
+
bp_activity_delete_by_item_id( array( 'item_id' => $group_id, 'component' => $bp->groups->id ) );
|
1569 |
}
|
1570 |
|
1571 |
// Remove all outstanding invites for this group
|
1606 |
}
|
1607 |
|
1608 |
function groups_get_slug( $group_id ) {
|
1609 |
+
$group = new BP_Groups_Group( $group_id );
|
1610 |
return $group->slug;
|
1611 |
}
|
1612 |
|
1618 |
if ( !$user_id )
|
1619 |
$user_id = $bp->loggedin_user->id;
|
1620 |
|
1621 |
+
/* Don't let single admins leave the group. */
|
1622 |
+
if ( count( groups_get_group_admins( $group_id ) ) < 2 ) {
|
1623 |
+
if ( groups_is_user_admin( $user_id, $group_id ) ) {
|
1624 |
+
bp_core_add_message( __( 'As the only Admin, you cannot leave the group.', 'buddypress' ), 'error' );
|
1625 |
+
return false;
|
1626 |
+
}
|
1627 |
+
}
|
1628 |
|
1629 |
+
$membership = new BP_Groups_Member( $user_id, $group_id );
|
1630 |
+
|
1631 |
+
// This is exactly the same as deleting an invite, just is_confirmed = 1 NOT 0.
|
1632 |
+
if ( !groups_uninvite_user( $user_id, $group_id ) )
|
1633 |
+
return false;
|
1634 |
|
1635 |
/* Modify group member count */
|
1636 |
groups_update_groupmeta( $group_id, 'total_member_count', (int) groups_get_groupmeta( $group_id, 'total_member_count') - 1 );
|
1637 |
|
1638 |
+
/* Modify user's group memberhip count */
|
1639 |
+
update_usermeta( $user_id, 'total_group_count', (int) get_usermeta( $user_id, 'total_group_count') - 1 );
|
1640 |
+
|
1641 |
+
/* If the user joined this group less than five minutes ago, remove the joined_group activity so
|
1642 |
+
* users cannot flood the activity stream by joining/leaving the group in quick succession.
|
1643 |
+
*/
|
1644 |
+
if ( function_exists( 'bp_activity_delete' ) && gmmktime() <= strtotime( '+5 minutes', (int)strtotime( $membership->date_modified ) ) )
|
1645 |
+
bp_activity_delete( array( 'component' => $bp->groups->id, 'type' => 'joined_group', 'user_id' => $user_id, 'item_id' => $group_id ) );
|
1646 |
+
|
1647 |
+
bp_core_add_message( __( 'You successfully left the group.', 'buddypress' ) );
|
1648 |
+
|
1649 |
+
do_action( 'groups_leave_group', $group_id, $user_id );
|
1650 |
+
|
1651 |
return true;
|
1652 |
}
|
1653 |
|
1657 |
if ( !$user_id )
|
1658 |
$user_id = $bp->loggedin_user->id;
|
1659 |
|
1660 |
+
/* Check if the user has an outstanding invite, is so delete it. */
|
1661 |
if ( groups_check_user_has_invite( $user_id, $group_id ) )
|
1662 |
groups_delete_invite( $user_id, $group_id );
|
1663 |
|
1664 |
+
/* Check if the user has an outstanding request, is so delete it. */
|
1665 |
+
if ( groups_check_for_membership_request( $user_id, $group_id ) )
|
1666 |
+
groups_delete_membership_request( $user_id, $group_id );
|
1667 |
+
|
1668 |
+
/* User is already a member, just return true */
|
1669 |
+
if ( groups_is_user_member( $user_id, $group_id ) )
|
1670 |
+
return true;
|
1671 |
+
|
1672 |
if ( !$bp->groups->current_group )
|
1673 |
+
$bp->groups->current_group = new BP_Groups_Group( $group_id );
|
1674 |
|
1675 |
$new_member = new BP_Groups_Member;
|
1676 |
$new_member->group_id = $group_id;
|
1678 |
$new_member->inviter_id = 0;
|
1679 |
$new_member->is_admin = 0;
|
1680 |
$new_member->user_title = '';
|
1681 |
+
$new_member->date_modified = gmdate( "Y-m-d H:i:s" );
|
1682 |
$new_member->is_confirmed = 1;
|
1683 |
|
1684 |
if ( !$new_member->save() )
|
1686 |
|
1687 |
/* Record this in activity streams */
|
1688 |
groups_record_activity( array(
|
1689 |
+
'action' => apply_filters( 'groups_activity_joined_group', sprintf( __( '%s joined the group %s', 'buddypress'), bp_core_get_userlink( $user_id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . attribute_escape( $bp->groups->current_group->name ) . '</a>' ) ),
|
1690 |
+
'type' => 'joined_group',
|
|
|
1691 |
'item_id' => $group_id
|
1692 |
) );
|
1693 |
|
1694 |
/* Modify group meta */
|
1695 |
groups_update_groupmeta( $group_id, 'total_member_count', (int) groups_get_groupmeta( $group_id, 'total_member_count') + 1 );
|
1696 |
+
groups_update_groupmeta( $group_id, 'last_activity', gmdate( "Y-m-d H:i:s" ) );
|
1697 |
|
1698 |
do_action( 'groups_join_group', $group_id, $user_id );
|
1699 |
|
1720 |
|
1721 |
/*** Group Fetching, Filtering & Searching *************************************/
|
1722 |
|
1723 |
+
function groups_get_groups( $args = '' ) {
|
1724 |
+
global $bp;
|
|
|
|
|
|
|
|
|
|
|
1725 |
|
1726 |
+
$defaults = array(
|
1727 |
+
'type' => 'active', // active, newest, alphabetical, random, popular, most-forum-topics or most-forum-posts
|
1728 |
+
'user_id' => false, // Pass a user_id to limit to only groups that this user is a member of
|
1729 |
+
'search_terms' => false, // Limit to groups that match these search terms
|
1730 |
|
1731 |
+
'per_page' => 20, // The number of results to return per page
|
1732 |
+
'page' => 1, // The page to return if limiting per page
|
1733 |
+
'populate_extras' => true, // Fetch meta such as is_banned and is_member
|
1734 |
+
);
|
1735 |
|
1736 |
+
$params = wp_parse_args( $args, $defaults );
|
1737 |
+
extract( $params, EXTR_SKIP );
|
1738 |
+
|
1739 |
+
switch ( $type ) {
|
1740 |
+
case 'active': default:
|
1741 |
+
$groups = BP_Groups_Group::get_active( $per_page, $page, $user_id, $search_terms, $populate_extras );
|
1742 |
+
break;
|
1743 |
+
case 'newest':
|
1744 |
+
$groups = BP_Groups_Group::get_newest( $per_page, $page, $user_id, $search_terms, $populate_extras );
|
1745 |
+
break;
|
1746 |
+
case 'popular':
|
1747 |
+
$groups = BP_Groups_Group::get_popular( $per_page, $page, $user_id, $search_terms, $populate_extras );
|
1748 |
+
break;
|
1749 |
+
case 'alphabetical':
|
1750 |
+
$groups = BP_Groups_Group::get_alphabetically( $per_page, $page, $user_id, $search_terms, $populate_extras );
|
1751 |
+
break;
|
1752 |
+
case 'random':
|
1753 |
+
$groups = BP_Groups_Group::get_random( $per_page, $page, $user_id, $search_terms, $populate_extras );
|
1754 |
+
break;
|
1755 |
+
case 'most-forum-topics':
|
1756 |
+
$groups = BP_Groups_Group::get_by_most_forum_topics( $per_page, $page, $user_id, $search_terms, $populate_extras );
|
1757 |
+
break;
|
1758 |
+
case 'most-forum-posts':
|
1759 |
+
$groups = BP_Groups_Group::get_by_most_forum_posts( $per_page, $page, $user_id, $search_terms, $populate_extras );
|
1760 |
+
break;
|
1761 |
+
}
|
1762 |
|
1763 |
+
return apply_filters( 'groups_get_groups', $groups, &$params );
|
|
|
1764 |
}
|
1765 |
|
1766 |
+
function groups_get_total_group_count() {
|
1767 |
+
if ( !$count = wp_cache_get( 'bp_total_group_count', 'bp' ) ) {
|
1768 |
+
$count = BP_Groups_Group::get_total_group_count();
|
1769 |
+
wp_cache_set( 'bp_total_group_count', $count, 'bp' );
|
1770 |
+
}
|
1771 |
|
1772 |
+
return $count;
|
|
|
1773 |
}
|
1774 |
|
1775 |
function groups_get_user_groups( $user_id = false, $pag_num = false, $pag_page = false ) {
|
1781 |
return BP_Groups_Member::get_group_ids( $user_id, $pag_num, $pag_page );
|
1782 |
}
|
1783 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1784 |
function groups_total_groups_for_user( $user_id = false ) {
|
1785 |
global $bp;
|
1786 |
|
1787 |
if ( !$user_id )
|
1788 |
+
$user_id = ( $bp->displayed_user->id ) ? $bp->displayed_user->id : $bp->loggedin_user->id;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1789 |
|
1790 |
+
if ( !$count = wp_cache_get( 'bp_total_groups_for_user_' . $user_id, 'bp' ) ) {
|
1791 |
+
$count = BP_Groups_Member::total_group_count( $user_id );
|
1792 |
+
wp_cache_set( 'bp_total_groups_for_user_' . $user_id, $count, 'bp' );
|
1793 |
+
}
|
1794 |
|
1795 |
+
return $count;
|
|
|
1796 |
}
|
1797 |
|
1798 |
/*** Group Avatars *************************************************************/
|
1803 |
if ( !$group_id )
|
1804 |
$group_id = $bp->groups->current_group->id;
|
1805 |
|
1806 |
+
$path = BP_AVATAR_UPLOAD_PATH . '/group-avatars/' . $group_id;
|
1807 |
+
$newbdir = $path;
|
|
|
1808 |
|
1809 |
+
if ( !file_exists( $path ) )
|
1810 |
+
@wp_mkdir_p( $path );
|
1811 |
|
1812 |
+
$newurl = str_replace( BP_AVATAR_UPLOAD_PATH, BP_AVATAR_URL, $path );
|
|
|
|
|
|
|
1813 |
$newburl = $newurl;
|
1814 |
$newsubdir = '/group-avatars/' . $group_id;
|
1815 |
|
1816 |
+
return apply_filters( 'groups_avatar_upload_dir', array( 'path' => $path, 'url' => $newurl, 'subdir' => $newsubdir, 'basedir' => $newbdir, 'baseurl' => $newburl, 'error' => false ) );
|
1817 |
}
|
1818 |
|
1819 |
/*** Group Member Status Checks ************************************************/
|
1834 |
return BP_Groups_Member::check_is_banned( $user_id, $group_id );
|
1835 |
}
|
1836 |
|
1837 |
+
/*** Group Activity Posting **************************************************/
|
1838 |
|
1839 |
+
function groups_post_update( $args = '' ) {
|
1840 |
global $bp;
|
1841 |
|
1842 |
+
$defaults = array(
|
1843 |
+
'content' => false,
|
1844 |
+
'user_id' => $bp->loggedin_user->id,
|
1845 |
+
'group_id' => false
|
1846 |
+
);
|
|
|
|
|
|
|
1847 |
|
1848 |
+
$r = wp_parse_args( $args, $defaults );
|
1849 |
+
extract( $r, EXTR_SKIP );
|
|
|
1850 |
|
1851 |
+
if ( empty($content) || !strlen( trim( $content ) ) || empty($user_id) || empty($group_id) )
|
1852 |
+
return false;
|
|
|
|
|
|
|
|
|
|
|
1853 |
|
1854 |
+
$bp->groups->current_group = new BP_Groups_Group( $group_id );
|
1855 |
|
1856 |
+
/* Be sure the user is a member of the group before posting. */
|
1857 |
+
if ( !is_site_admin() && !groups_is_user_member( $user_id, $group_id ) )
|
1858 |
+
return false;
|
1859 |
|
1860 |
+
/* Record this in activity streams */
|
1861 |
+
$activity_action = sprintf( __( '%s posted an update in the group %s:', 'buddypress'), bp_core_get_userlink( $user_id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . attribute_escape( $bp->groups->current_group->name ) . '</a>' );
|
1862 |
+
$activity_content = $content;
|
1863 |
+
|
1864 |
+
$activity_id = groups_record_activity( array(
|
1865 |
+
'user_id' => $user_id,
|
1866 |
+
'action' => apply_filters( 'groups_activity_new_update_action', $activity_action ),
|
1867 |
+
'content' => apply_filters( 'groups_activity_new_update_content', $activity_content ),
|
1868 |
+
'type' => 'activity_update',
|
1869 |
+
'item_id' => $bp->groups->current_group->id
|
1870 |
+
) );
|
1871 |
|
1872 |
+
/* Require the notifications code so email notifications can be set on the 'bp_activity_posted_update' action. */
|
1873 |
+
require_once( BP_PLUGIN_DIR . '/bp-groups/bp-groups-notifications.php' );
|
|
|
|
|
|
|
|
|
1874 |
|
1875 |
+
groups_update_groupmeta( $group_id, 'last_activity', gmdate( "Y-m-d H:i:s" ) );
|
1876 |
+
do_action( 'bp_groups_posted_update', $content, $user_id, $group_id, $activity_id );
|
|
|
1877 |
|
1878 |
+
return $activity_id;
|
1879 |
}
|
1880 |
|
1881 |
/*** Group Forums **************************************************************/
|
1899 |
do_action( 'groups_new_group_forum', $forum, $group_id );
|
1900 |
}
|
1901 |
|
1902 |
+
function groups_new_group_forum_post( $post_text, $topic_id, $page = false ) {
|
1903 |
global $bp;
|
1904 |
|
1905 |
if ( empty( $post_text ) )
|
1906 |
return false;
|
1907 |
|
1908 |
+
$post_text = apply_filters( 'group_forum_post_text_before_save', $post_text );
|
1909 |
+
$topic_id = apply_filters( 'group_forum_post_topic_id_before_save', $topic_id );
|
1910 |
+
|
1911 |
+
if ( $post_id = bp_forums_insert_post( array( 'post_text' => $post_text, 'topic_id' => $topic_id ) ) ) {
|
1912 |
$topic = bp_forums_get_topic_details( $topic_id );
|
1913 |
|
1914 |
+
$activity_action = sprintf( __( '%s posted on the forum topic %s in the group %s:', 'buddypress'), bp_core_get_userlink( $bp->loggedin_user->id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic->topic_slug .'/">' . attribute_escape( $topic->topic_title ) . '</a>', '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . attribute_escape( $bp->groups->current_group->name ) . '</a>' );
|
1915 |
+
$activity_content = bp_create_excerpt( $post_text );
|
1916 |
+
$primary_link = bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic->topic_slug . '/';
|
1917 |
+
|
1918 |
+
if ( $page )
|
1919 |
+
$primary_link .= "?topic_page=" . $page;
|
1920 |
|
1921 |
/* Record this in activity streams */
|
1922 |
groups_record_activity( array(
|
1923 |
+
'action' => apply_filters( 'groups_activity_new_forum_post_action', $activity_action, $post_id, $post_text, &$topic ),
|
1924 |
+
'content' => apply_filters( 'groups_activity_new_forum_post_content', $activity_content, $post_id, $post_text, &$topic ),
|
1925 |
+
'primary_link' => apply_filters( 'groups_activity_new_forum_post_primary_link', "{$primary_link}#post-{$post_id}" ),
|
1926 |
+
'type' => 'new_forum_post',
|
1927 |
'item_id' => $bp->groups->current_group->id,
|
1928 |
+
'secondary_item_id' => $post_id
|
1929 |
) );
|
1930 |
|
1931 |
+
do_action( 'groups_new_forum_topic_post', $bp->groups->current_group->id, $post_id );
|
1932 |
|
1933 |
+
return $post_id;
|
1934 |
}
|
1935 |
|
1936 |
return false;
|
1942 |
if ( empty( $topic_title ) || empty( $topic_text ) )
|
1943 |
return false;
|
1944 |
|
1945 |
+
$topic_title = apply_filters( 'group_forum_topic_title_before_save', $topic_title );
|
1946 |
+
$topic_text = apply_filters( 'group_forum_topic_text_before_save', $topic_text );
|
1947 |
+
$topic_tags = apply_filters( 'group_forum_topic_tags_before_save', $topic_tags );
|
1948 |
+
$forum_id = apply_filters( 'group_forum_topic_forum_id_before_save', $forum_id );
|
1949 |
+
|
1950 |
if ( $topic_id = bp_forums_new_topic( array( 'topic_title' => $topic_title, 'topic_text' => $topic_text, 'topic_tags' => $topic_tags, 'forum_id' => $forum_id ) ) ) {
|
1951 |
$topic = bp_forums_get_topic_details( $topic_id );
|
1952 |
|
1953 |
+
$activity_action = sprintf( __( '%s started the forum topic %s in the group %s:', 'buddypress'), bp_core_get_userlink( $bp->loggedin_user->id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic->topic_slug .'/">' . attribute_escape( $topic->topic_title ) . '</a>', '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . attribute_escape( $bp->groups->current_group->name ) . '</a>' );
|
1954 |
+
$activity_content = bp_create_excerpt( $topic_text );
|
1955 |
|
1956 |
/* Record this in activity streams */
|
1957 |
groups_record_activity( array(
|
1958 |
+
'action' => apply_filters( 'groups_activity_new_forum_topic_action', $activity_action, $topic_text, &$topic ),
|
1959 |
+
'content' => apply_filters( 'groups_activity_new_forum_topic_content', $activity_content, $topic_text, &$topic ),
|
1960 |
+
'primary_link' => apply_filters( 'groups_activity_new_forum_topic_primary_link', bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic->topic_slug . '/' ),
|
1961 |
+
'type' => 'new_forum_topic',
|
1962 |
'item_id' => $bp->groups->current_group->id,
|
1963 |
'secondary_item_id' => $topic->topic_id
|
1964 |
) );
|
1974 |
function groups_update_group_forum_topic( $topic_id, $topic_title, $topic_text ) {
|
1975 |
global $bp;
|
1976 |
|
1977 |
+
$topic_title = apply_filters( 'group_forum_topic_title_before_save', $topic_title );
|
1978 |
+
$topic_text = apply_filters( 'group_forum_topic_text_before_save', $topic_text );
|
1979 |
+
|
1980 |
if ( $topic = bp_forums_update_topic( array( 'topic_title' => $topic_title, 'topic_text' => $topic_text, 'topic_id' => $topic_id ) ) ) {
|
1981 |
/* Update the activity stream item */
|
1982 |
if ( function_exists( 'bp_activity_delete_by_item_id' ) )
|
1983 |
+
bp_activity_delete_by_item_id( array( 'item_id' => $bp->groups->current_group->id, 'secondary_item_id' => $topic_id, 'component' => $bp->groups->id, 'type' => 'new_forum_topic' ) );
|
1984 |
|
1985 |
+
$activity_action = sprintf( __( '%s started the forum topic %s in the group %s:', 'buddypress'), bp_core_get_userlink( $topic->topic_poster ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic->topic_slug .'/">' . attribute_escape( $topic->topic_title ) . '</a>', '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . attribute_escape( $bp->groups->current_group->name ) . '</a>' );
|
1986 |
+
$activity_content = bp_create_excerpt( $topic_text );
|
1987 |
|
1988 |
/* Record this in activity streams */
|
1989 |
groups_record_activity( array(
|
1990 |
+
'action' => apply_filters( 'groups_activity_new_forum_topic_action', $activity_action, $topic_text, &$topic ),
|
1991 |
+
'content' => apply_filters( 'groups_activity_new_forum_topic_content', $activity_content, $topic_text, &$topic ),
|
1992 |
+
'primary_link' => apply_filters( 'groups_activity_new_forum_topic_primary_link', bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic->topic_slug . '/' ),
|
1993 |
+
'type' => 'new_forum_topic',
|
1994 |
'item_id' => (int)$bp->groups->current_group->id,
|
1995 |
'user_id' => (int)$topic->topic_poster,
|
1996 |
'secondary_item_id' => $topic->topic_id,
|
1997 |
+
'recorded_time' => $topic->topic_time
|
1998 |
) );
|
1999 |
|
2000 |
do_action( 'groups_update_group_forum_topic', &$topic );
|
2001 |
|
2002 |
+
return $topic;
|
2003 |
}
|
2004 |
|
2005 |
return false;
|
2006 |
}
|
2007 |
|
2008 |
+
function groups_update_group_forum_post( $post_id, $post_text, $topic_id, $page = false ) {
|
2009 |
global $bp;
|
2010 |
|
2011 |
+
$post_text = apply_filters( 'group_forum_post_text_before_save', $post_text );
|
2012 |
+
$topic_id = apply_filters( 'group_forum_post_topic_id_before_save', $topic_id );
|
2013 |
+
|
2014 |
$post = bp_forums_get_post( $post_id );
|
2015 |
|
2016 |
if ( $post_id = bp_forums_insert_post( array( 'post_id' => $post_id, 'post_text' => $post_text, 'post_time' => $post->post_time, 'topic_id' => $topic_id, 'poster_id' => $post->poster_id ) ) ) {
|
2017 |
$topic = bp_forums_get_topic_details( $topic_id );
|
2018 |
|
2019 |
+
$activity_action = sprintf( __( '%s posted on the forum topic %s in the group %s:', 'buddypress'), bp_core_get_userlink( $post->poster_id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic->topic_slug .'">' . attribute_escape( $topic->topic_title ) . '</a>', '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . attribute_escape( $bp->groups->current_group->name ) . '</a>' );
|
2020 |
+
$activity_content = bp_create_excerpt( $post_text );
|
2021 |
+
$primary_link = bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic->topic_slug . '/';
|
2022 |
|
2023 |
+
if ( $page )
|
2024 |
+
$primary_link .= "?topic_page=" . $page;
|
2025 |
|
2026 |
+
/* Fetch an existing entry and update if one exists. */
|
2027 |
+
if ( function_exists( 'bp_activity_get_activity_id' ) )
|
2028 |
+
$id = bp_activity_get_activity_id( array( 'user_id' => $post->poster_id, 'component' => $bp->groups->id, 'type' => 'new_forum_post', 'item_id' => $bp->groups->current_group->id, 'secondary_item_id' => $post_id ) );
|
2029 |
+
|
2030 |
+
/* Update the entry in activity streams */
|
2031 |
groups_record_activity( array(
|
2032 |
+
'id' => $id,
|
2033 |
+
'action' => apply_filters( 'groups_activity_new_forum_post_action', $activity_action, $post_text, &$topic, &$forum_post ),
|
2034 |
+
'content' => apply_filters( 'groups_activity_new_forum_post_content', $activity_content, $post_text, &$topic, &$forum_post ),
|
2035 |
+
'primary_link' => apply_filters( 'groups_activity_new_forum_post_primary_link', $primary_link . "#post-" . $post_id ),
|
2036 |
+
'type' => 'new_forum_post',
|
2037 |
'item_id' => (int)$bp->groups->current_group->id,
|
2038 |
'user_id' => (int)$post->poster_id,
|
2039 |
'secondary_item_id' => $post_id,
|
2040 |
+
'recorded_time' => $post->post_time
|
2041 |
) );
|
2042 |
|
2043 |
do_action( 'groups_update_group_forum_post', &$post, &$topic );
|
2044 |
|
2045 |
+
return $post_id;
|
2046 |
}
|
2047 |
|
2048 |
return false;
|
2053 |
|
2054 |
if ( bp_forums_delete_topic( array( 'topic_id' => $topic_id ) ) ) {
|
2055 |
/* Delete the activity stream item */
|
2056 |
+
if ( function_exists( 'bp_activity_delete' ) ) {
|
2057 |
+
bp_activity_delete( array( 'item_id' => $bp->groups->current_group->id, 'secondary_item_id' => $topic_id, 'component' => $bp->groups->id, 'type' => 'new_forum_topic' ) );
|
|
|
2058 |
}
|
2059 |
|
2060 |
do_action( 'groups_delete_group_forum_topic', $topic_id );
|
2070 |
|
2071 |
if ( bp_forums_delete_post( array( 'post_id' => $post_id ) ) ) {
|
2072 |
/* Delete the activity stream item */
|
2073 |
+
if ( function_exists( 'bp_activity_delete' ) ) {
|
2074 |
+
bp_activity_delete( array( 'item_id' => $bp->groups->current_group->id, 'secondary_item_id' => $post_id, 'component' => $bp->groups->id, 'type' => 'new_forum_post' ) );
|
2075 |
}
|
2076 |
|
2077 |
do_action( 'groups_delete_group_forum_post', $post_id, $topic_id );
|
2089 |
|
2090 |
/*** Group Invitations *********************************************************/
|
2091 |
|
2092 |
+
function groups_get_invites_for_user( $user_id = false, $limit = false, $page = false ) {
|
2093 |
global $bp;
|
2094 |
|
2095 |
if ( !$user_id )
|
2096 |
$user_id = $bp->loggedin_user->id;
|
2097 |
|
2098 |
+
return BP_Groups_Member::get_invites( $user_id, $limit, $page );
|
2099 |
}
|
2100 |
|
2101 |
function groups_invite_user( $args = '' ) {
|
2105 |
'user_id' => false,
|
2106 |
'group_id' => false,
|
2107 |
'inviter_id' => $bp->loggedin_user->id,
|
2108 |
+
'date_modified' => gmdate( "Y-m-d H:i:s" ),
|
2109 |
'is_confirmed' => 0
|
2110 |
);
|
2111 |
|
2115 |
if ( !$user_id || !$group_id )
|
2116 |
return false;
|
2117 |
|
2118 |
+
if ( !groups_is_user_member( $user_id, $group_id ) && !groups_check_user_has_invite( $user_id, $group_id ) ) {
|
2119 |
+
$invite = new BP_Groups_Member;
|
2120 |
+
$invite->group_id = $group_id;
|
2121 |
+
$invite->user_id = $user_id;
|
2122 |
+
$invite->date_modified = $date_modified;
|
2123 |
+
$invite->inviter_id = $inviter_id;
|
2124 |
+
$invite->is_confirmed = $is_confirmed;
|
|
|
|
|
2125 |
|
2126 |
+
if ( !$invite->save() )
|
2127 |
+
return false;
|
2128 |
|
2129 |
+
do_action( 'groups_invite_user', $args );
|
2130 |
+
}
|
2131 |
|
2132 |
return true;
|
2133 |
}
|
2144 |
}
|
2145 |
|
2146 |
function groups_accept_invite( $user_id, $group_id ) {
|
2147 |
+
global $bp;
|
2148 |
+
|
2149 |
if ( groups_is_user_member( $user_id, $group_id ) )
|
2150 |
return false;
|
2151 |
|
2155 |
if ( !$member->save() )
|
2156 |
return false;
|
2157 |
|
2158 |
+
/* Modify group meta */
|
2159 |
+
groups_update_groupmeta( $group_id, 'total_member_count', (int) groups_get_groupmeta( $group_id, 'total_member_count') + 1 );
|
2160 |
+
groups_update_groupmeta( $group_id, 'last_activity', gmdate( "Y-m-d H:i:s" ) );
|
2161 |
+
|
2162 |
+
bp_core_delete_notifications_for_user_by_item_id( $user_id, $group_id, $bp->groups->slug, 'group_invite' );
|
2163 |
+
|
2164 |
do_action( 'groups_accept_invite', $user_id, $group_id );
|
2165 |
return true;
|
2166 |
}
|
2195 |
|
2196 |
// Send friend invites.
|
2197 |
$invited_users = groups_get_invites_for_group( $user_id, $group_id );
|
2198 |
+
$group = new BP_Groups_Group( $group_id );
|
2199 |
|
2200 |
for ( $i = 0; $i < count( $invited_users ); $i++ ) {
|
2201 |
$member = new BP_Groups_Member( $invited_users[$i], $group_id );
|
2232 |
|
2233 |
$member = new BP_Groups_Member( $user_id, $group_id );
|
2234 |
|
2235 |
+
do_action( 'groups_premote_member', $group_id, $user_id, $status );
|
2236 |
|
2237 |
return $member->promote( $status );
|
2238 |
}
|
2242 |
|
2243 |
$member = new BP_Groups_Member( $user_id, $group_id );
|
2244 |
|
2245 |
+
do_action( 'groups_demote_member', $group_id, $user_id );
|
2246 |
|
2247 |
return $member->demote();
|
2248 |
}
|
2255 |
|
2256 |
$member = new BP_Groups_Member( $user_id, $group_id );
|
2257 |
|
2258 |
+
do_action( 'groups_ban_member', $group_id, $user_id );
|
2259 |
+
|
2260 |
+
if ( !$member->ban() )
|
2261 |
+
return false;
|
2262 |
|
2263 |
+
update_usermeta( $user_id, 'total_group_count', (int)$total_count - 1 );
|
2264 |
}
|
2265 |
|
2266 |
function groups_unban_member( $user_id, $group_id ) {
|
2271 |
|
2272 |
$member = new BP_Groups_Member( $user_id, $group_id );
|
2273 |
|
2274 |
+
do_action( 'groups_unban_member', $group_id, $user_id );
|
2275 |
|
2276 |
return $member->unban();
|
2277 |
}
|
2281 |
function groups_send_membership_request( $requesting_user_id, $group_id ) {
|
2282 |
global $bp;
|
2283 |
|
2284 |
+
/* Prevent duplicate requests */
|
2285 |
+
if ( groups_check_for_membership_request( $requesting_user_id, $group_id ) )
|
2286 |
+
return false;
|
2287 |
+
|
2288 |
+
/* Check if the user is already a member or is banned */
|
2289 |
+
if ( groups_is_user_member( $requesting_user_id, $group_id ) || groups_is_user_banned( $requesting_user_id, $group_id ) )
|
2290 |
+
return false;
|
2291 |
+
|
2292 |
$requesting_user = new BP_Groups_Member;
|
2293 |
$requesting_user->group_id = $group_id;
|
2294 |
$requesting_user->user_id = $requesting_user_id;
|
2295 |
$requesting_user->inviter_id = 0;
|
2296 |
$requesting_user->is_admin = 0;
|
2297 |
$requesting_user->user_title = '';
|
2298 |
+
$requesting_user->date_modified = gmdate( "Y-m-d H:i:s" );
|
2299 |
$requesting_user->is_confirmed = 0;
|
2300 |
$requesting_user->comments = $_POST['group-request-membership-comments'];
|
2301 |
|
2334 |
groups_update_groupmeta( $membership->group_id, 'total_member_count', (int) groups_get_groupmeta( $membership->group_id, 'total_member_count') + 1 );
|
2335 |
|
2336 |
/* Record this in activity streams */
|
2337 |
+
$group = new BP_Groups_Group( $group_id );
|
2338 |
|
2339 |
groups_record_activity( array(
|
2340 |
+
'action' => apply_filters( 'groups_activity_membership_accepted_action', sprintf( __( '%s joined the group %s', 'buddypress'), bp_core_get_userlink( $user_id ), '<a href="' . bp_get_group_permalink( $group ) . '">' . attribute_escape( $group->name ) . '</a>' ), $user_id, &$group ),
|
2341 |
+
'type' => 'joined_group',
|
|
|
2342 |
'item_id' => $group->id,
|
2343 |
'user_id' => $user_id
|
2344 |
) );
|
2353 |
}
|
2354 |
|
2355 |
function groups_reject_membership_request( $membership_id, $user_id = false, $group_id = false ) {
|
2356 |
+
if ( !$membership = groups_delete_membership_request( $membership_id, $user_id, $group_id ) )
|
|
|
|
|
|
|
|
|
|
|
2357 |
return false;
|
2358 |
|
2359 |
// Send a notification to the user.
|
2365 |
return true;
|
2366 |
}
|
2367 |
|
2368 |
+
function groups_delete_membership_request( $membership_id, $user_id = false, $group_id = false ) {
|
2369 |
+
if ( $user_id && $group_id )
|
2370 |
+
$membership = new BP_Groups_Member( $user_id, $group_id );
|
2371 |
+
else
|
2372 |
+
$membership = new BP_Groups_Member( false, false, $membership_id );
|
2373 |
+
|
2374 |
+
if ( !BP_Groups_Member::delete( $membership->user_id, $membership->group_id ) )
|
2375 |
+
return false;
|
2376 |
+
|
2377 |
+
return $membership;
|
2378 |
+
}
|
2379 |
+
|
2380 |
function groups_check_for_membership_request( $user_id, $group_id ) {
|
2381 |
return BP_Groups_Member::check_for_membership_request( $user_id, $group_id );
|
2382 |
}
|
2419 |
$wpdb->query( $wpdb->prepare( "DELETE FROM " . $bp->groups->table_name_groupmeta . " WHERE group_id = %d AND meta_key = %s", $group_id, $meta_key ) );
|
2420 |
}
|
2421 |
|
2422 |
+
/* Delete the cached object */
|
2423 |
+
wp_cache_delete( 'bp_groups_groupmeta_' . $group_id . '_' . $meta_key, 'bp' );
|
2424 |
|
2425 |
return true;
|
2426 |
}
|
2436 |
if ( !empty($meta_key) ) {
|
2437 |
$meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key);
|
2438 |
|
2439 |
+
if ( !$metas = wp_cache_get( 'bp_groups_groupmeta_' . $group_id . '_' . $meta_key, 'bp' ) ) {
|
2440 |
+
$metas = $wpdb->get_col( $wpdb->prepare("SELECT meta_value FROM " . $bp->groups->table_name_groupmeta . " WHERE group_id = %d AND meta_key = %s", $group_id, $meta_key) );
|
2441 |
+
wp_cache_set( 'bp_groups_groupmeta_' . $group_id . '_' . $meta_key, $metas, 'bp' );
|
2442 |
+
}
|
|
|
|
|
|
|
|
|
2443 |
} else {
|
2444 |
$metas = $wpdb->get_col( $wpdb->prepare("SELECT meta_value FROM " . $bp->groups->table_name_groupmeta . " WHERE group_id = %d", $group_id) );
|
2445 |
}
|
2486 |
return false;
|
2487 |
}
|
2488 |
|
2489 |
+
/* Update the cached object and recache */
|
2490 |
+
wp_cache_set( 'bp_groups_groupmeta_' . $group_id . '_' . $meta_key, $meta_value, 'bp' );
|
2491 |
|
2492 |
return true;
|
2493 |
}
|
2503 |
add_action( 'delete_user', 'groups_remove_data_for_user', 1 );
|
2504 |
add_action( 'make_spam_user', 'groups_remove_data_for_user', 1 );
|
2505 |
|
2506 |
+
|
2507 |
+
/********************************************************************************
|
2508 |
+
* Caching
|
2509 |
+
*
|
2510 |
+
* Caching functions handle the clearing of cached objects and pages on specific
|
2511 |
+
* actions throughout BuddyPress.
|
2512 |
+
*/
|
2513 |
+
|
2514 |
function groups_clear_group_object_cache( $group_id ) {
|
2515 |
wp_cache_delete( 'groups_group_nouserdata_' . $group_id, 'bp' );
|
2516 |
wp_cache_delete( 'groups_group_' . $group_id, 'bp' );
|
2518 |
wp_cache_delete( 'active_groups', 'bp' );
|
2519 |
wp_cache_delete( 'popular_groups', 'bp' );
|
2520 |
wp_cache_delete( 'groups_random_groups', 'bp' );
|
2521 |
+
wp_cache_delete( 'bp_total_group_count', 'bp' );
|
2522 |
}
|
|
|
|
|
2523 |
add_action( 'groups_group_deleted', 'groups_clear_group_object_cache' );
|
2524 |
add_action( 'groups_settings_updated', 'groups_clear_group_object_cache' );
|
2525 |
add_action( 'groups_details_updated', 'groups_clear_group_object_cache' );
|
2526 |
add_action( 'groups_group_avatar_updated', 'groups_clear_group_object_cache' );
|
2527 |
+
add_action( 'groups_create_group_step_complete', 'groups_clear_group_object_cache' );
|
2528 |
+
|
2529 |
+
function groups_clear_group_user_object_cache( $group_id, $user_id ) {
|
2530 |
+
wp_cache_delete( 'bp_total_groups_for_user_' . $user_id );
|
2531 |
+
}
|
2532 |
+
add_action( 'groups_join_group', 'groups_clear_group_user_object_cache', 10, 2 );
|
2533 |
+
add_action( 'groups_leave_group', 'groups_clear_group_user_object_cache', 10, 2 );
|
2534 |
+
add_action( 'groups_ban_member', 'groups_clear_group_user_object_cache', 10, 2 );
|
2535 |
+
add_action( 'groups_unban_member', 'groups_clear_group_user_object_cache', 10, 2 );
|
2536 |
|
2537 |
+
/* List actions to clear super cached pages on, if super cache is installed */
|
|
|
|
|
2538 |
add_action( 'groups_join_group', 'bp_core_clear_cache' );
|
2539 |
add_action( 'groups_leave_group', 'bp_core_clear_cache' );
|
2540 |
add_action( 'groups_accept_invite', 'bp_core_clear_cache' );
|
bp-groups/bp-groups-admin.php
DELETED
@@ -1,129 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
function groups_admin_settings() {
|
4 |
-
|
5 |
-
if ( isset( $_POST['groups_admin_delete']) && isset( $_POST['allgroups'] ) ) {
|
6 |
-
if ( !check_admin_referer('bp-groups-admin') )
|
7 |
-
return false;
|
8 |
-
|
9 |
-
$errors = false;
|
10 |
-
foreach ( $_POST['allgroups'] as $group_id ) {
|
11 |
-
$group = new BP_Groups_Group( $group_id );
|
12 |
-
if ( !$group->delete() ) {
|
13 |
-
$errors = true;
|
14 |
-
}
|
15 |
-
}
|
16 |
-
|
17 |
-
if ( $errors ) {
|
18 |
-
$message = __( 'There were errors when deleting groups, please try again', 'buddypress' );
|
19 |
-
$type = 'error';
|
20 |
-
} else {
|
21 |
-
$message = __( 'Groups deleted successfully', 'buddypress' );
|
22 |
-
$type = 'updated';
|
23 |
-
}
|
24 |
-
}
|
25 |
-
?>
|
26 |
-
<?php if ( isset( $message ) ) { ?>
|
27 |
-
<div id="message" class="<?php echo $type ?> fade">
|
28 |
-
<p><?php echo $message ?></p>
|
29 |
-
</div>
|
30 |
-
<?php } ?>
|
31 |
-
|
32 |
-
<div class="wrap" style="position: relative">
|
33 |
-
<h2><?php _e( 'Groups', 'buddypress' ) ?></h2>
|
34 |
-
|
35 |
-
<form id="wpmu-search" method="post" action="">
|
36 |
-
<input type="text" size="17" value="<?php echo attribute_escape( stripslashes( $_REQUEST['s'] ) ); ?>" name="s" />
|
37 |
-
<input id="post-query-submit" class="button" type="submit" value="<?php _e( 'Search Groups', 'buddypress' ) ?>" />
|
38 |
-
</form>
|
39 |
-
|
40 |
-
<?php if ( bp_has_site_groups( 'type=active&per_page=10' ) ) : ?>
|
41 |
-
<form id="bp-group-admin-list" method="post" action="">
|
42 |
-
<div class="tablenav">
|
43 |
-
<div class="tablenav-pages">
|
44 |
-
<?php bp_site_groups_pagination_count() ?> <?php bp_site_groups_pagination_links() ?>
|
45 |
-
</div>
|
46 |
-
<div class="alignleft">
|
47 |
-
<input class="button-secondary delete" type="submit" name="groups_admin_delete" value="<?php _e( 'Delete', 'buddypress' ) ?>" onclick="if ( !confirm('<?php _e( 'Are you sure?', 'buddypress' ) ?>') ) return false"/>
|
48 |
-
<?php wp_nonce_field('bp-groups-admin') ?>
|
49 |
-
<br class="clear"/>
|
50 |
-
</div>
|
51 |
-
</div>
|
52 |
-
|
53 |
-
<br class="clear"/>
|
54 |
-
|
55 |
-
<?php if ( isset( $_REQUEST['s'] ) && $_REQUEST['s'] != '' ) { ?>
|
56 |
-
<p><?php echo sprintf( __( 'Groups matching: "%s"', 'buddypress' ), $_REQUEST['s'] ) ?></p>
|
57 |
-
<?php } ?>
|
58 |
-
|
59 |
-
|
60 |
-
<table class="widefat" cellspacing="3" cellpadding="3">
|
61 |
-
<thead>
|
62 |
-
<tr>
|
63 |
-
<th class="check-column" scope="col">
|
64 |
-
<input id="group_check_all" type="checkbox" value="0" name="group_check_all" onclick="if ( jQuery(this).attr('checked') ) { jQuery('#group-list input[@type=checkbox]').attr('checked', 'checked'); } else { jQuery('#group-list input[@type=checkbox]').attr('checked', ''); }" />
|
65 |
-
</th>
|
66 |
-
<th scope="col">
|
67 |
-
</th>
|
68 |
-
<th scope="col">
|
69 |
-
ID
|
70 |
-
</th>
|
71 |
-
<th scope="col">
|
72 |
-
<?php _e( 'Name', 'buddypress' ) ?>
|
73 |
-
</th>
|
74 |
-
<th scope="col">
|
75 |
-
<?php _e( 'Description', 'buddypress' ) ?>
|
76 |
-
</th>
|
77 |
-
<th scope="col">
|
78 |
-
<?php _e( 'Type', 'buddypress' ) ?>
|
79 |
-
</th>
|
80 |
-
<th scope="col">
|
81 |
-
<?php _e( 'Members', 'buddypress' ) ?>
|
82 |
-
</th>
|
83 |
-
<th scope="col">
|
84 |
-
<?php _e( 'Created', 'buddypress' ) ?>
|
85 |
-
</th>
|
86 |
-
<th scope="col">
|
87 |
-
<?php _e( 'Last Active', 'buddypress' ) ?>
|
88 |
-
</th>
|
89 |
-
<th scope="col">
|
90 |
-
</th>
|
91 |
-
</tr>
|
92 |
-
</thead>
|
93 |
-
<tbody id="group-list" class="list:groups group-list">
|
94 |
-
<?php $counter = 0 ?>
|
95 |
-
<?php while ( bp_site_groups() ) : bp_the_site_group(); ?>
|
96 |
-
<tr<?php if ( 1 == $counter % 2 ) { ?> class="alternate"<?php }?>>
|
97 |
-
<th class="check-column" scope="row">
|
98 |
-
<input id="group_<?php bp_the_site_group_id() ?>" type="checkbox" value="<?php bp_the_site_group_id() ?>" name="allgroups[<?php bp_the_site_group_id() ?>]" />
|
99 |
-
</th>
|
100 |
-
<td><?php bp_the_site_group_avatar_mini() ?></td>
|
101 |
-
<td><?php bp_the_site_group_id() ?></td>
|
102 |
-
<td><a href="<?php bp_the_site_group_link() ?>"><?php bp_the_site_group_name() ?></a></td>
|
103 |
-
<td><?php bp_the_site_group_description_excerpt() ?></td>
|
104 |
-
<td><?php bp_the_site_group_type() ?></td>
|
105 |
-
<td><?php bp_the_site_group_member_count() ?></td>
|
106 |
-
<td><?php bp_the_site_group_date_created() ?></td>
|
107 |
-
<td><?php bp_the_site_group_last_active() ?></td>
|
108 |
-
<td><a href="<?php bp_the_site_group_link() ?>/admin"><?php _e( 'Edit', 'buddypress') ?></a></td>
|
109 |
-
</tr>
|
110 |
-
<?php $counter++ ?>
|
111 |
-
<?php endwhile; ?>
|
112 |
-
</tbody>
|
113 |
-
</table>
|
114 |
-
|
115 |
-
<?php else: ?>
|
116 |
-
|
117 |
-
<div id="message" class="info">
|
118 |
-
<p><?php _e( 'No groups found.', 'buddypress' ) ?></p>
|
119 |
-
</div>
|
120 |
-
|
121 |
-
<?php endif; ?>
|
122 |
-
|
123 |
-
<?php bp_the_site_group_hidden_fields() ?>
|
124 |
-
</form>
|
125 |
-
</div>
|
126 |
-
<?php
|
127 |
-
}
|
128 |
-
|
129 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bp-groups/bp-groups-classes.php
CHANGED
@@ -6,67 +6,47 @@ Class BP_Groups_Group {
|
|
6 |
var $name;
|
7 |
var $slug;
|
8 |
var $description;
|
9 |
-
var $news;
|
10 |
var $status;
|
11 |
-
var $enable_wire;
|
12 |
var $enable_forum;
|
13 |
var $date_created;
|
14 |
|
15 |
-
var $user_dataset;
|
16 |
-
|
17 |
var $admins;
|
18 |
var $total_member_count;
|
19 |
-
var $random_members;
|
20 |
-
var $latest_wire_posts;
|
21 |
|
22 |
-
function bp_groups_group( $id = null
|
23 |
if ( $id ) {
|
24 |
$this->id = $id;
|
25 |
-
$this->populate(
|
26 |
-
}
|
27 |
-
|
28 |
-
if ( $single ) {
|
29 |
-
$this->populate_meta();
|
30 |
}
|
31 |
}
|
32 |
|
33 |
-
function populate(
|
34 |
global $wpdb, $bp;
|
35 |
|
36 |
-
$
|
37 |
-
$group = $wpdb->get_row($sql);
|
38 |
-
|
39 |
-
if ( $group ) {
|
40 |
$this->id = $group->id;
|
41 |
$this->creator_id = $group->creator_id;
|
42 |
$this->name = stripslashes($group->name);
|
43 |
$this->slug = $group->slug;
|
44 |
$this->description = stripslashes($group->description);
|
45 |
-
$this->news = stripslashes($group->news);
|
46 |
$this->status = $group->status;
|
47 |
-
$this->enable_wire = $group->enable_wire;
|
48 |
$this->enable_forum = $group->enable_forum;
|
49 |
-
$this->date_created =
|
50 |
-
$this->
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
|
|
|
|
59 |
}
|
60 |
}
|
61 |
}
|
62 |
|
63 |
-
function populate_meta() {
|
64 |
-
if ( $this->id ) {
|
65 |
-
$this->admins = $this->get_administrators();
|
66 |
-
$this->random_members = $this->get_random_members();
|
67 |
-
}
|
68 |
-
}
|
69 |
-
|
70 |
function save() {
|
71 |
global $wpdb, $bp;
|
72 |
|
@@ -74,9 +54,7 @@ Class BP_Groups_Group {
|
|
74 |
$this->name = apply_filters( 'groups_group_name_before_save', $this->name, $this->id );
|
75 |
$this->slug = apply_filters( 'groups_group_slug_before_save', $this->slug, $this->id );
|
76 |
$this->description = apply_filters( 'groups_group_description_before_save', $this->description, $this->id );
|
77 |
-
$this->
|
78 |
-
$this->status = apply_filters( 'groups_group_status_before_save', $this->status, $this->id );
|
79 |
-
$this->enable_wire = apply_filters( 'groups_group_enable_wire_before_save', $this->enable_wire, $this->id );
|
80 |
$this->enable_forum = apply_filters( 'groups_group_enable_forum_before_save', $this->enable_forum, $this->id );
|
81 |
$this->date_created = apply_filters( 'groups_group_date_created_before_save', $this->date_created, $this->id );
|
82 |
|
@@ -89,11 +67,9 @@ Class BP_Groups_Group {
|
|
89 |
name = %s,
|
90 |
slug = %s,
|
91 |
description = %s,
|
92 |
-
news = %s,
|
93 |
status = %s,
|
94 |
-
enable_wire = %d,
|
95 |
enable_forum = %d,
|
96 |
-
date_created =
|
97 |
WHERE
|
98 |
id = %d
|
99 |
",
|
@@ -101,9 +77,7 @@ Class BP_Groups_Group {
|
|
101 |
$this->name,
|
102 |
$this->slug,
|
103 |
$this->description,
|
104 |
-
$this->news,
|
105 |
$this->status,
|
106 |
-
$this->enable_wire,
|
107 |
$this->enable_forum,
|
108 |
$this->date_created,
|
109 |
$this->id
|
@@ -115,21 +89,17 @@ Class BP_Groups_Group {
|
|
115 |
name,
|
116 |
slug,
|
117 |
description,
|
118 |
-
news,
|
119 |
status,
|
120 |
-
enable_wire,
|
121 |
enable_forum,
|
122 |
date_created
|
123 |
) VALUES (
|
124 |
-
%d, %s, %s, %s, %s, %
|
125 |
)",
|
126 |
$this->creator_id,
|
127 |
$this->name,
|
128 |
$this->slug,
|
129 |
$this->description,
|
130 |
-
$this->news,
|
131 |
$this->status,
|
132 |
-
$this->enable_wire,
|
133 |
$this->enable_forum,
|
134 |
$this->date_created
|
135 |
);
|
@@ -147,67 +117,23 @@ Class BP_Groups_Group {
|
|
147 |
return true;
|
148 |
}
|
149 |
|
150 |
-
function get_user_dataset() {
|
151 |
-
global $wpdb, $bp;
|
152 |
-
|
153 |
-
return $wpdb->get_results( $wpdb->prepare( "SELECT user_id, is_admin, inviter_id, user_title, is_mod FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 1 AND is_banned = 0 ORDER BY rand()", $this->id ) );
|
154 |
-
}
|
155 |
-
|
156 |
-
function get_administrators() {
|
157 |
-
for ( $i = 0; $i < count($this->user_dataset); $i++ ) {
|
158 |
-
if ( $this->user_dataset[$i]->is_admin )
|
159 |
-
$admins[] = new BP_Groups_Member( $this->user_dataset[$i]->user_id, $this->id );
|
160 |
-
}
|
161 |
-
|
162 |
-
return $admins;
|
163 |
-
}
|
164 |
-
|
165 |
-
function get_random_members() {
|
166 |
-
$total_randoms = ( $this->total_member_count > 5 ) ? 5 : $this->total_member_count;
|
167 |
-
|
168 |
-
for ( $i = 0; $i < $total_randoms; $i++ ) {
|
169 |
-
if ( !(int)$this->user_dataset[$i]->is_banned )
|
170 |
-
$users[] = new BP_Groups_Member( $this->user_dataset[$i]->user_id, $this->id );
|
171 |
-
}
|
172 |
-
return $users;
|
173 |
-
}
|
174 |
-
|
175 |
-
function is_member() {
|
176 |
-
global $bp;
|
177 |
-
|
178 |
-
for ( $i = 0; $i < count($this->user_dataset); $i++ ) {
|
179 |
-
if ( $this->user_dataset[$i]->user_id == $bp->loggedin_user->id ) {
|
180 |
-
return true;
|
181 |
-
}
|
182 |
-
}
|
183 |
-
|
184 |
-
return false;
|
185 |
-
}
|
186 |
-
|
187 |
function delete() {
|
188 |
global $wpdb, $bp;
|
189 |
|
190 |
-
|
191 |
groups_delete_groupmeta( $this->id );
|
192 |
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
$total_count = get_usermeta( $user->user_id, 'total_group_count' );
|
198 |
|
199 |
-
|
200 |
-
|
201 |
-
}
|
202 |
|
203 |
-
|
204 |
-
|
205 |
-
}
|
206 |
|
207 |
-
|
208 |
-
if ( function_exists('bp_wire_install') ) {
|
209 |
-
BP_Wire_Post::delete_all_for_item( $this->id, $bp->groups->table_name_wire );
|
210 |
-
}
|
211 |
|
212 |
// Finally remove the group entry from the DB
|
213 |
if ( !$wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->groups->table_name} WHERE id = %d", $this->id ) ) )
|
@@ -216,7 +142,6 @@ Class BP_Groups_Group {
|
|
216 |
return true;
|
217 |
}
|
218 |
|
219 |
-
|
220 |
/* Static Functions */
|
221 |
|
222 |
function group_exists( $slug, $table_name = false ) {
|
@@ -282,8 +207,8 @@ Class BP_Groups_Group {
|
|
282 |
if ( !is_site_admin() )
|
283 |
$hidden_sql = "AND status != 'hidden'";
|
284 |
|
285 |
-
$paged_groups = $wpdb->get_results(
|
286 |
-
$total_groups = $wpdb->get_var(
|
287 |
|
288 |
return array( 'groups' => $paged_groups, 'total' => $total_groups );
|
289 |
}
|
@@ -330,94 +255,209 @@ Class BP_Groups_Group {
|
|
330 |
return array( 'requests' => $paged_requests, 'total' => $total_requests );
|
331 |
}
|
332 |
|
333 |
-
|
|
|
|
|
334 |
global $wpdb, $bp;
|
335 |
|
336 |
if ( $limit && $page )
|
337 |
$pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
|
338 |
|
339 |
-
if ( !is_site_admin() )
|
340 |
-
$hidden_sql = "
|
341 |
|
342 |
-
|
343 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
344 |
|
345 |
return array( 'groups' => $paged_groups, 'total' => $total_groups );
|
346 |
}
|
347 |
|
348 |
-
function get_active( $limit = null, $page = null ) {
|
349 |
global $wpdb, $bp;
|
350 |
|
351 |
if ( $limit && $page )
|
352 |
$pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
|
353 |
|
354 |
-
if ( !is_site_admin() )
|
355 |
$hidden_sql = "AND g.status != 'hidden'";
|
356 |
|
357 |
-
|
358 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
359 |
|
360 |
return array( 'groups' => $paged_groups, 'total' => $total_groups );
|
361 |
}
|
362 |
|
363 |
-
function get_popular( $limit = null, $page = null ) {
|
364 |
global $wpdb, $bp;
|
365 |
|
366 |
if ( $limit && $page ) {
|
367 |
$pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
|
368 |
}
|
369 |
|
370 |
-
if ( !is_site_admin() )
|
371 |
$hidden_sql = "AND g.status != 'hidden'";
|
372 |
|
373 |
-
|
374 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
375 |
|
376 |
return array( 'groups' => $paged_groups, 'total' => $total_groups );
|
377 |
}
|
378 |
|
379 |
-
function get_alphabetically( $limit = null, $page = null ) {
|
380 |
global $wpdb, $bp;
|
381 |
|
382 |
if ( $limit && $page )
|
383 |
$pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
|
384 |
|
385 |
-
if ( !is_site_admin() )
|
386 |
-
$hidden_sql = "
|
387 |
|
388 |
-
|
389 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
390 |
|
391 |
return array( 'groups' => $paged_groups, 'total' => $total_groups );
|
392 |
}
|
393 |
|
394 |
-
function get_by_most_forum_topics( $limit = null, $page = null ) {
|
395 |
global $wpdb, $bp, $bbdb;
|
396 |
|
|
|
|
|
|
|
397 |
if ( $limit && $page ) {
|
398 |
$pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
|
399 |
}
|
400 |
|
401 |
-
|
402 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
403 |
|
404 |
return array( 'groups' => $paged_groups, 'total' => $total_groups );
|
405 |
}
|
406 |
|
407 |
-
function get_by_most_forum_posts( $limit = null, $page = null ) {
|
408 |
global $wpdb, $bp, $bbdb;
|
409 |
|
|
|
|
|
|
|
410 |
if ( $limit && $page ) {
|
411 |
$pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
|
412 |
}
|
413 |
|
414 |
-
|
415 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
416 |
|
417 |
return array( 'groups' => $paged_groups, 'total' => $total_groups );
|
418 |
}
|
419 |
|
420 |
-
|
421 |
function get_all( $limit = null, $page = null, $only_public = true, $sort_by = false, $order = false ) {
|
422 |
global $wpdb, $bp;
|
423 |
|
@@ -462,7 +502,7 @@ Class BP_Groups_Group {
|
|
462 |
return $wpdb->get_results($sql);
|
463 |
}
|
464 |
|
465 |
-
function get_by_letter( $letter, $limit = null, $page = null ) {
|
466 |
global $wpdb, $bp;
|
467 |
|
468 |
if ( strlen($letter) > 1 || is_numeric($letter) || !$letter )
|
@@ -475,36 +515,93 @@ Class BP_Groups_Group {
|
|
475 |
|
476 |
if ( $limit && $page ) {
|
477 |
$pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
|
478 |
-
$total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->groups->table_name} WHERE name LIKE '$letter%%' {$hidden_sql}
|
479 |
}
|
480 |
|
481 |
-
$paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT
|
|
|
|
|
|
|
|
|
|
|
|
|
482 |
|
483 |
return array( 'groups' => $paged_groups, 'total' => $total_groups );
|
484 |
}
|
485 |
|
486 |
-
function get_random( $limit = null, $page = null ) {
|
487 |
global $wpdb, $bp;
|
488 |
|
489 |
-
if (
|
490 |
-
$hidden_sql = $wpdb->prepare( " AND status != 'hidden'");
|
491 |
-
|
492 |
-
if ( $limit && $page ) {
|
493 |
$pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
|
494 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
495 |
}
|
496 |
|
497 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
498 |
|
499 |
return array( 'groups' => $paged_groups, 'total' => $total_groups );
|
500 |
}
|
501 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
502 |
function delete_all_invites( $group_id ) {
|
503 |
global $wpdb, $bp;
|
504 |
|
505 |
return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->groups->table_name_members} WHERE group_id = %d AND invite_sent = 1", $group_id ) );
|
506 |
}
|
507 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
508 |
function get_global_forum_topic_count( $type ) {
|
509 |
global $bbdb, $wpdb, $bp;
|
510 |
|
@@ -570,7 +667,7 @@ Class BP_Groups_Member {
|
|
570 |
$this->is_mod = $member->is_mod;
|
571 |
$this->is_banned = $member->is_banned;
|
572 |
$this->user_title = $member->user_title;
|
573 |
-
$this->date_modified =
|
574 |
$this->is_confirmed = $member->is_confirmed;
|
575 |
$this->comments = $member->comments;
|
576 |
$this->invite_sent = $member->invite_sent;
|
@@ -597,9 +694,9 @@ Class BP_Groups_Member {
|
|
597 |
do_action( 'groups_member_before_save', $this );
|
598 |
|
599 |
if ( $this->id ) {
|
600 |
-
$sql = $wpdb->prepare( "UPDATE {$bp->groups->table_name_members} SET inviter_id = %d, is_admin = %d, is_mod = %d, is_banned = %d, user_title = %s, date_modified =
|
601 |
} else {
|
602 |
-
$sql = $wpdb->prepare( "INSERT INTO {$bp->groups->table_name_members} ( user_id, group_id, inviter_id, is_admin, is_mod, is_banned, user_title, date_modified, is_confirmed, comments, invite_sent ) VALUES ( %d, %d, %d, %d, %d, %d, %s,
|
603 |
}
|
604 |
|
605 |
if ( !$wpdb->query($sql) )
|
@@ -645,6 +742,10 @@ Class BP_Groups_Member {
|
|
645 |
|
646 |
groups_update_groupmeta( $this->group_id, 'total_member_count', ( (int) groups_get_groupmeta( $this->group_id, 'total_member_count' ) - 1 ) );
|
647 |
|
|
|
|
|
|
|
|
|
648 |
return $this->save();
|
649 |
}
|
650 |
|
@@ -655,6 +756,7 @@ Class BP_Groups_Member {
|
|
655 |
$this->is_banned = 0;
|
656 |
|
657 |
groups_update_groupmeta( $this->group_id, 'total_member_count', ( (int) groups_get_groupmeta( $this->group_id, 'total_member_count' ) + 1 ) );
|
|
|
658 |
|
659 |
return $this->save();
|
660 |
}
|
@@ -662,22 +764,20 @@ Class BP_Groups_Member {
|
|
662 |
function accept_invite() {
|
663 |
$this->inviter_id = 0;
|
664 |
$this->is_confirmed = 1;
|
665 |
-
$this->date_modified =
|
666 |
}
|
667 |
|
668 |
function accept_request() {
|
669 |
$this->is_confirmed = 1;
|
670 |
-
$this->date_modified =
|
671 |
}
|
672 |
|
673 |
/* Static Functions */
|
674 |
|
675 |
-
function delete( $user_id, $group_id
|
676 |
global $wpdb, $bp;
|
677 |
|
678 |
-
|
679 |
-
|
680 |
-
return $delete_result;
|
681 |
}
|
682 |
|
683 |
function get_group_ids( $user_id, $limit = false, $page = false ) {
|
@@ -686,13 +786,13 @@ Class BP_Groups_Member {
|
|
686 |
if ( $limit && $page )
|
687 |
$pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
|
688 |
|
689 |
-
// If the user is logged in and viewing their own groups, we can show hidden and private
|
690 |
-
if (
|
691 |
-
$group_sql = $wpdb->prepare( "SELECT DISTINCT group_id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND
|
692 |
-
$total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT group_id) FROM {$bp->groups->table_name_members} WHERE user_id = %d AND
|
693 |
} else {
|
694 |
-
$group_sql = $wpdb->prepare( "SELECT DISTINCT
|
695 |
-
$total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT
|
696 |
}
|
697 |
|
698 |
$groups = $wpdb->get_col( $group_sql );
|
@@ -708,74 +808,14 @@ Class BP_Groups_Member {
|
|
708 |
|
709 |
if ( $filter ) {
|
710 |
$filter = like_escape( $wpdb->escape( $filter ) );
|
711 |
-
$filter_sql = " AND ( g.name LIKE '{$filter}%%' OR g.description LIKE '{$filter}%%' )";
|
712 |
-
}
|
713 |
-
|
714 |
-
if ( !bp_is_home() )
|
715 |
-
$hidden_sql = " AND g.status != 'hidden'";
|
716 |
-
|
717 |
-
$paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT m.group_id FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 AND m.is_confirmed = 1 ORDER BY m.date_modified DESC {$pag_sql}", $user_id ) );
|
718 |
-
$total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 AND m.is_confirmed = 1 ORDER BY m.date_modified DESC", $user_id ) );
|
719 |
-
|
720 |
-
return array( 'groups' => $paged_groups, 'total' => $total_groups );
|
721 |
-
}
|
722 |
-
|
723 |
-
function get_most_popular( $user_id, $limit = false, $page = false, $filter = false ) {
|
724 |
-
global $wpdb, $bp;
|
725 |
-
|
726 |
-
if ( $limit && $page )
|
727 |
-
$pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
|
728 |
-
|
729 |
-
if ( $filter ) {
|
730 |
-
like_escape( $wpdb->escape( $filter ) );
|
731 |
-
$filter_sql = " AND ( g.name LIKE '{$filter}%%' OR g.description LIKE '{$filter}%%' )";
|
732 |
-
}
|
733 |
-
|
734 |
-
if ( !bp_is_home() )
|
735 |
-
$hidden_sql = " AND g.status != 'hidden'";
|
736 |
-
|
737 |
-
$paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT m.group_id FROM {$bp->groups->table_name_members} m INNER JOIN {$bp->groups->table_name} g ON m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 AND m.is_confirmed = 1 LEFT JOIN {$bp->groups->table_name_groupmeta} gm ON m.group_id = gm.group_id AND gm.meta_key = 'total_member_count' ORDER BY CONVERT( gm.meta_value, SIGNED ) DESC {$pag_sql}", $user_id ) );
|
738 |
-
$total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m INNER JOIN {$bp->groups->table_name} g ON m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 AND m.is_confirmed = 1 LEFT JOIN {$bp->groups->table_name_groupmeta} gm ON m.group_id = gm.group_id AND gm.meta_key = 'total_member_count' ORDER BY CONVERT( gm.meta_value, SIGNED ) DESC", $user_id ) );
|
739 |
-
|
740 |
-
return array( 'groups' => $paged_groups, 'total' => $total_groups );
|
741 |
-
}
|
742 |
-
|
743 |
-
function get_recently_active( $user_id, $limit = false, $page = false, $filter = false ) {
|
744 |
-
global $wpdb, $bp;
|
745 |
-
|
746 |
-
if ( $limit && $page )
|
747 |
-
$pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
|
748 |
-
|
749 |
-
if ( $filter ) {
|
750 |
-
$filter = like_escape( $wpdb->escape( $filter ) );
|
751 |
-
$filter_sql = " AND ( g.name LIKE '{$filter}%%' OR g.description LIKE '{$filter}%%' )";
|
752 |
-
}
|
753 |
-
|
754 |
-
if ( !bp_is_home() )
|
755 |
-
$hidden_sql = " AND g.status != 'hidden'";
|
756 |
-
|
757 |
-
$paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT m.group_id FROM {$bp->groups->table_name_members} m LEFT JOIN {$bp->groups->table_name_groupmeta} gm ON m.group_id = gm.group_id INNER JOIN {$bp->groups->table_name} g ON m.group_id = g.id WHERE gm.meta_key = 'last_activity'{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 ORDER BY gm.meta_value DESC {$pag_sql}", $user_id ) );
|
758 |
-
$total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m LEFT JOIN {$bp->groups->table_name_groupmeta} gm ON m.group_id = gm.group_id INNER JOIN {$bp->groups->table_name} g ON m.group_id = g.id WHERE gm.meta_key = 'last_activity'{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 ORDER BY gm.meta_value DESC", $user_id ) );
|
759 |
-
|
760 |
-
return array( 'groups' => $paged_groups, 'total' => $total_groups );
|
761 |
-
}
|
762 |
-
|
763 |
-
function get_alphabetically( $user_id, $limit = false, $page = false, $filter = false ) {
|
764 |
-
global $wpdb, $bp;
|
765 |
-
|
766 |
-
if ( $limit && $page )
|
767 |
-
$pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
|
768 |
-
|
769 |
-
if ( $filter ) {
|
770 |
-
$filter = like_escape( $wpdb->escape( $filter ) );
|
771 |
-
$filter_sql = " AND ( g.name LIKE '{$filter}%%' OR g.description LIKE '{$filter}%%' )";
|
772 |
}
|
773 |
|
774 |
-
if (
|
775 |
$hidden_sql = " AND g.status != 'hidden'";
|
776 |
|
777 |
-
$paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT
|
778 |
-
$total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.
|
779 |
|
780 |
return array( 'groups' => $paged_groups, 'total' => $total_groups );
|
781 |
}
|
@@ -788,14 +828,14 @@ Class BP_Groups_Member {
|
|
788 |
|
789 |
if ( $filter ) {
|
790 |
$filter = like_escape( $wpdb->escape( $filter ) );
|
791 |
-
$filter_sql = " AND ( g.name LIKE '{$filter}%%' OR g.description LIKE '{$filter}%%' )";
|
792 |
}
|
793 |
|
794 |
-
if (
|
795 |
$hidden_sql = " AND g.status != 'hidden'";
|
796 |
|
797 |
-
$paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT
|
798 |
-
$total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.
|
799 |
|
800 |
return array( 'groups' => $paged_groups, 'total' => $total_groups );
|
801 |
}
|
@@ -808,14 +848,14 @@ Class BP_Groups_Member {
|
|
808 |
|
809 |
if ( $filter ) {
|
810 |
$filter = like_escape( $wpdb->escape( $filter ) );
|
811 |
-
$filter_sql = " AND ( g.name LIKE '{$filter}%%' OR g.description LIKE '{$filter}%%' )";
|
812 |
}
|
813 |
|
814 |
-
if (
|
815 |
$hidden_sql = " AND g.status != 'hidden'";
|
816 |
|
817 |
-
$paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT
|
818 |
-
$total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.
|
819 |
|
820 |
return array( 'groups' => $paged_groups, 'total' => $total_groups );
|
821 |
}
|
@@ -826,19 +866,23 @@ Class BP_Groups_Member {
|
|
826 |
if ( !$user_id )
|
827 |
$user_id = $bp->displayed_user->id;
|
828 |
|
829 |
-
if (
|
830 |
-
return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT group_id) FROM {$bp->groups->table_name_members} WHERE user_id = %d AND
|
831 |
} else {
|
832 |
-
return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id AND
|
833 |
}
|
834 |
}
|
835 |
|
836 |
-
function get_invites( $user_id ) {
|
837 |
global $wpdb, $bp;
|
838 |
|
839 |
-
|
|
|
|
|
|
|
|
|
840 |
|
841 |
-
return $
|
842 |
}
|
843 |
|
844 |
function check_has_invite( $user_id, $group_id ) {
|
@@ -908,13 +952,19 @@ Class BP_Groups_Member {
|
|
908 |
global $wpdb, $bp;
|
909 |
|
910 |
// If the user is logged in and viewing their random groups, we can show hidden and private groups
|
911 |
-
if (
|
912 |
return $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT group_id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND is_confirmed = 1 AND is_banned = 0 ORDER BY rand() LIMIT $total_groups", $user_id ) );
|
913 |
} else {
|
914 |
return $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT m.group_id FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id AND g.status != 'hidden' AND m.user_id = %d AND m.is_confirmed = 1 AND m.is_banned = 0 ORDER BY rand() LIMIT $total_groups", $user_id ) );
|
915 |
}
|
916 |
}
|
917 |
|
|
|
|
|
|
|
|
|
|
|
|
|
918 |
function get_group_administrator_ids( $group_id ) {
|
919 |
global $bp, $wpdb;
|
920 |
|
@@ -945,7 +995,10 @@ Class BP_Groups_Member {
|
|
945 |
if ( $exclude_banned )
|
946 |
$banned_sql = $wpdb->prepare( " AND is_banned = 0" );
|
947 |
|
948 |
-
|
|
|
|
|
|
|
949 |
|
950 |
if ( !$members )
|
951 |
return false;
|
@@ -955,9 +1008,29 @@ Class BP_Groups_Member {
|
|
955 |
else
|
956 |
$total_member_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(user_id) FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 1 {$banned_sql} {$exclude_sql}", $group_id ) );
|
957 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
958 |
return array( 'members' => $members, 'count' => $total_member_count );
|
959 |
}
|
960 |
|
|
|
|
|
|
|
|
|
|
|
|
|
961 |
function delete_all_for_user( $user_id ) {
|
962 |
global $wpdb, $bp;
|
963 |
|
@@ -996,7 +1069,7 @@ class BP_Group_Extension {
|
|
996 |
var $nav_item_name = false;
|
997 |
|
998 |
var $display_hook = 'groups_custom_group_boxes';
|
999 |
-
var $template_file = '
|
1000 |
|
1001 |
// Methods you should override
|
1002 |
|
@@ -1049,12 +1122,12 @@ class BP_Group_Extension {
|
|
1049 |
add_action( 'wp', array( &$this, 'edit_screen_save' ) );
|
1050 |
add_action( 'groups_custom_edit_steps', array( &$this, 'edit_screen' ) );
|
1051 |
|
1052 |
-
if ( '' != locate_template( array( 'groups/single/
|
1053 |
-
bp_core_load_template( apply_filters( '
|
1054 |
} else {
|
1055 |
add_action( 'bp_template_content_header', create_function( '', 'echo "<ul class=\"content-header-nav\">"; bp_group_admin_tabs(); echo "</ul>";' ) );
|
1056 |
add_action( 'bp_template_content', array( &$this, 'edit_screen' ) );
|
1057 |
-
bp_core_load_template( apply_filters( 'bp_core_template_plugin', '
|
1058 |
}
|
1059 |
}
|
1060 |
}
|
@@ -1080,7 +1153,7 @@ class BP_Group_Extension {
|
|
1080 |
|
1081 |
function _display_hook() {
|
1082 |
add_action( 'bp_template_content', array( &$this, 'display' ) );
|
1083 |
-
bp_core_load_template( $this->template_file );
|
1084 |
}
|
1085 |
}
|
1086 |
|
6 |
var $name;
|
7 |
var $slug;
|
8 |
var $description;
|
|
|
9 |
var $status;
|
|
|
10 |
var $enable_forum;
|
11 |
var $date_created;
|
12 |
|
|
|
|
|
13 |
var $admins;
|
14 |
var $total_member_count;
|
|
|
|
|
15 |
|
16 |
+
function bp_groups_group( $id = null ) {
|
17 |
if ( $id ) {
|
18 |
$this->id = $id;
|
19 |
+
$this->populate();
|
|
|
|
|
|
|
|
|
20 |
}
|
21 |
}
|
22 |
|
23 |
+
function populate() {
|
24 |
global $wpdb, $bp;
|
25 |
|
26 |
+
if ( $group = $wpdb->get_row( $wpdb->prepare( "SELECT g.*, gm.meta_value as last_activity, gm2.meta_value as total_member_count FROM {$bp->groups->table_name} g, {$bp->groups->table_name_groupmeta} gm, {$bp->groups->table_name_groupmeta} gm2 WHERE g.id = gm.group_id AND g.id = gm2.group_id AND gm.meta_key = 'last_activity' AND gm2.meta_key = 'total_member_count' AND g.id = %d", $this->id ) ) ) {
|
|
|
|
|
|
|
27 |
$this->id = $group->id;
|
28 |
$this->creator_id = $group->creator_id;
|
29 |
$this->name = stripslashes($group->name);
|
30 |
$this->slug = $group->slug;
|
31 |
$this->description = stripslashes($group->description);
|
|
|
32 |
$this->status = $group->status;
|
|
|
33 |
$this->enable_forum = $group->enable_forum;
|
34 |
+
$this->date_created = $group->date_created;
|
35 |
+
$this->last_activity = $group->last_activity;
|
36 |
+
$this->total_member_count = $group->total_member_count;
|
37 |
+
$this->is_member = BP_Groups_Member::check_is_member( $bp->loggedin_user->id, $this->id );
|
38 |
+
|
39 |
+
/* Get group admins and mods */
|
40 |
+
$admin_mods = $wpdb->get_results( $wpdb->prepare( "SELECT u.ID as user_id, u.user_login, u.user_email, u.user_nicename, m.is_admin, m.is_mod FROM {$wpdb->users} u, {$bp->groups->table_name_members} m WHERE u.ID = m.user_id AND m.group_id = %d AND ( m.is_admin = 1 OR m.is_mod = 1 )", $this->id ) );
|
41 |
+
foreach( (array)$admin_mods as $user ) {
|
42 |
+
if ( (int)$user->is_admin )
|
43 |
+
$this->admins[] = $user;
|
44 |
+
else
|
45 |
+
$this->mods[] = $user;
|
46 |
}
|
47 |
}
|
48 |
}
|
49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
function save() {
|
51 |
global $wpdb, $bp;
|
52 |
|
54 |
$this->name = apply_filters( 'groups_group_name_before_save', $this->name, $this->id );
|
55 |
$this->slug = apply_filters( 'groups_group_slug_before_save', $this->slug, $this->id );
|
56 |
$this->description = apply_filters( 'groups_group_description_before_save', $this->description, $this->id );
|
57 |
+
$this->status = apply_filters( 'groups_group_status_before_save', $this->status, $this->id );
|
|
|
|
|
58 |
$this->enable_forum = apply_filters( 'groups_group_enable_forum_before_save', $this->enable_forum, $this->id );
|
59 |
$this->date_created = apply_filters( 'groups_group_date_created_before_save', $this->date_created, $this->id );
|
60 |
|
67 |
name = %s,
|
68 |
slug = %s,
|
69 |
description = %s,
|
|
|
70 |
status = %s,
|
|
|
71 |
enable_forum = %d,
|
72 |
+
date_created = %s
|
73 |
WHERE
|
74 |
id = %d
|
75 |
",
|
77 |
$this->name,
|
78 |
$this->slug,
|
79 |
$this->description,
|
|
|
80 |
$this->status,
|
|
|
81 |
$this->enable_forum,
|
82 |
$this->date_created,
|
83 |
$this->id
|
89 |
name,
|
90 |
slug,
|
91 |
description,
|
|
|
92 |
status,
|
|
|
93 |
enable_forum,
|
94 |
date_created
|
95 |
) VALUES (
|
96 |
+
%d, %s, %s, %s, %s, %d, %s
|
97 |
)",
|
98 |
$this->creator_id,
|
99 |
$this->name,
|
100 |
$this->slug,
|
101 |
$this->description,
|
|
|
102 |
$this->status,
|
|
|
103 |
$this->enable_forum,
|
104 |
$this->date_created
|
105 |
);
|
117 |
return true;
|
118 |
}
|
119 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
function delete() {
|
121 |
global $wpdb, $bp;
|
122 |
|
123 |
+
/* Delete groupmeta for the group */
|
124 |
groups_delete_groupmeta( $this->id );
|
125 |
|
126 |
+
/* Fetch the user IDs of all the members of the group */
|
127 |
+
$user_ids = BP_Groups_Member::get_group_member_ids( $this->id );
|
128 |
+
$user_ids = implode( ',', (array)$user_ids );
|
|
|
|
|
129 |
|
130 |
+
/* Modify group count usermeta for members */
|
131 |
+
$wpdb->query( $wpdb->prepare( "UPDATE {$bp->groups->table_name_groupmeta} SET meta_value = meta_value - 1 WHERE meta_key = 'total_group_count' AND user_id IN ( {$user_ids} )" ) );
|
|
|
132 |
|
133 |
+
/* Now delete all group member entries */
|
134 |
+
BP_Groups_Member::delete_all( $this->id );
|
|
|
135 |
|
136 |
+
do_action( 'bp_groups_delete_group', $this );
|
|
|
|
|
|
|
137 |
|
138 |
// Finally remove the group entry from the DB
|
139 |
if ( !$wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->groups->table_name} WHERE id = %d", $this->id ) ) )
|
142 |
return true;
|
143 |
}
|
144 |
|
|
|
145 |
/* Static Functions */
|
146 |
|
147 |
function group_exists( $slug, $table_name = false ) {
|
207 |
if ( !is_site_admin() )
|
208 |
$hidden_sql = "AND status != 'hidden'";
|
209 |
|
210 |
+
$paged_groups = $wpdb->get_results( "SELECT id as group_id FROM {$bp->groups->table_name} WHERE ( name LIKE '%%$filter%%' OR description LIKE '%%$filter%%' ) {$hidden_sql} {$order_sql} {$pag_sql}" );
|
211 |
+
$total_groups = $wpdb->get_var( "SELECT COUNT(id) FROM {$bp->groups->table_name} WHERE ( name LIKE '%%$filter%%' OR description LIKE '%%$filter%%' ) {$hidden_sq}" );
|
212 |
|
213 |
return array( 'groups' => $paged_groups, 'total' => $total_groups );
|
214 |
}
|
255 |
return array( 'requests' => $paged_requests, 'total' => $total_requests );
|
256 |
}
|
257 |
|
258 |
+
/* TODO: Merge all these get_() functions into one. */
|
259 |
+
|
260 |
+
function get_newest( $limit = null, $page = null, $user_id = false, $search_terms = false, $populate_extras = true ) {
|
261 |
global $wpdb, $bp;
|
262 |
|
263 |
if ( $limit && $page )
|
264 |
$pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
|
265 |
|
266 |
+
if ( !is_user_logged_in() || ( !is_site_admin() && ( $user_id != $bp->loggedin_user->id ) ) )
|
267 |
+
$hidden_sql = "AND g.status != 'hidden'";
|
268 |
|
269 |
+
if ( $search_terms ) {
|
270 |
+
$search_terms = like_escape( $wpdb->escape( $search_terms ) );
|
271 |
+
$search_sql = " AND ( g.name LIKE '%%{$search_terms}%%' OR g.description LIKE '%%{$search_terms}%%' )";
|
272 |
+
}
|
273 |
+
|
274 |
+
if ( $user_id ) {
|
275 |
+
$user_id = $wpdb->escape( $user_id );
|
276 |
+
$paged_groups = $wpdb->get_results( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.is_confirmed = 1 AND m.is_banned = 0 ORDER BY g.date_created DESC {$pag_sql}" );
|
277 |
+
$total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m LEFT JOIN {$bp->groups->table_name_groupmeta} gm ON m.group_id = gm.group_id INNER JOIN {$bp->groups->table_name} g ON m.group_id = g.id WHERE gm.meta_key = 'last_activity'{$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.is_confirmed = 1 AND m.is_banned = 0" );
|
278 |
+
} else {
|
279 |
+
$paged_groups = $wpdb->get_results( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql} ORDER BY g.date_created DESC {$pag_sql}" );
|
280 |
+
$total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name_groupmeta} gm INNER JOIN {$bp->groups->table_name} g ON gm.group_id = g.id WHERE gm.meta_key = 'last_activity'{$hidden_sql} {$search_sql}" );
|
281 |
+
}
|
282 |
+
|
283 |
+
if ( !empty( $populate_extras ) ) {
|
284 |
+
foreach ( (array)$paged_groups as $group ) $group_ids[] = $group->id;
|
285 |
+
$group_ids = $wpdb->escape( join( ',', (array)$group_ids ) );
|
286 |
+
$paged_groups = BP_Groups_Group::get_group_extras( &$paged_groups, $group_ids, 'newest' );
|
287 |
+
}
|
288 |
|
289 |
return array( 'groups' => $paged_groups, 'total' => $total_groups );
|
290 |
}
|
291 |
|
292 |
+
function get_active( $limit = null, $page = null, $user_id = false, $search_terms = false, $populate_extras = true ) {
|
293 |
global $wpdb, $bp;
|
294 |
|
295 |
if ( $limit && $page )
|
296 |
$pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
|
297 |
|
298 |
+
if ( !is_user_logged_in() || ( !is_site_admin() && ( $user_id != $bp->loggedin_user->id ) ) )
|
299 |
$hidden_sql = "AND g.status != 'hidden'";
|
300 |
|
301 |
+
if ( $search_terms ) {
|
302 |
+
$search_terms = like_escape( $wpdb->escape( $search_terms ) );
|
303 |
+
$search_sql = " AND ( g.name LIKE '%%{$search_terms}%%' OR g.description LIKE '%%{$search_terms}%%' )";
|
304 |
+
}
|
305 |
+
|
306 |
+
if ( $user_id ) {
|
307 |
+
$user_id = $wpdb->escape( $user_id );
|
308 |
+
$paged_groups = $wpdb->get_results( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.is_confirmed = 1 AND m.is_banned = 0 ORDER BY last_activity DESC {$pag_sql}" );
|
309 |
+
$total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m LEFT JOIN {$bp->groups->table_name_groupmeta} gm ON m.group_id = gm.group_id INNER JOIN {$bp->groups->table_name} g ON m.group_id = g.id WHERE gm.meta_key = 'last_activity'{$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.is_confirmed = 1 AND m.is_banned = 0" );
|
310 |
+
} else {
|
311 |
+
$paged_groups = $wpdb->get_results( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql} ORDER BY last_activity DESC {$pag_sql}" );
|
312 |
+
$total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name_groupmeta} gm INNER JOIN {$bp->groups->table_name} g ON gm.group_id = g.id WHERE gm.meta_key = 'last_activity'{$hidden_sql} {$search_sql}" );
|
313 |
+
}
|
314 |
+
|
315 |
+
if ( !empty( $populate_extras ) ) {
|
316 |
+
foreach ( (array)$paged_groups as $group ) $group_ids[] = $group->id;
|
317 |
+
$group_ids = $wpdb->escape( join( ',', (array)$group_ids ) );
|
318 |
+
$paged_groups = BP_Groups_Group::get_group_extras( &$paged_groups, $group_ids, 'newest' );
|
319 |
+
}
|
320 |
|
321 |
return array( 'groups' => $paged_groups, 'total' => $total_groups );
|
322 |
}
|
323 |
|
324 |
+
function get_popular( $limit = null, $page = null, $user_id = false, $search_terms = false, $populate_extras = true ) {
|
325 |
global $wpdb, $bp;
|
326 |
|
327 |
if ( $limit && $page ) {
|
328 |
$pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
|
329 |
}
|
330 |
|
331 |
+
if ( !is_user_logged_in() || ( !is_site_admin() && ( $user_id != $bp->loggedin_user->id ) ) )
|
332 |
$hidden_sql = "AND g.status != 'hidden'";
|
333 |
|
334 |
+
if ( $search_terms ) {
|
335 |
+
$search_terms = like_escape( $wpdb->escape( $search_terms ) );
|
336 |
+
$search_sql = " AND ( g.name LIKE '%%{$search_terms}%%' OR g.description LIKE '%%{$search_terms}%%' )";
|
337 |
+
}
|
338 |
+
|
339 |
+
if ( $user_id ) {
|
340 |
+
$user_id = $wpdb->escape( $user_id );
|
341 |
+
$paged_groups = $wpdb->get_results( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.is_confirmed = 1 AND m.is_banned = 0 ORDER BY CONVERT(gm1.meta_value, SIGNED) DESC {$pag_sql}" );
|
342 |
+
$total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m LEFT JOIN {$bp->groups->table_name_groupmeta} gm ON m.group_id = gm.group_id INNER JOIN {$bp->groups->table_name} g ON m.group_id = g.id WHERE gm.meta_key = 'last_activity'{$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.is_confirmed = 1 AND m.is_banned = 0" );
|
343 |
+
} else {
|
344 |
+
$paged_groups = $wpdb->get_results( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql} ORDER BY CONVERT(gm1.meta_value, SIGNED) DESC {$pag_sql}" );
|
345 |
+
$total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql}" );
|
346 |
+
}
|
347 |
+
|
348 |
+
if ( !empty( $populate_extras ) ) {
|
349 |
+
foreach ( (array)$paged_groups as $group ) $group_ids[] = $group->id;
|
350 |
+
$group_ids = $wpdb->escape( join( ',', (array)$group_ids ) );
|
351 |
+
$paged_groups = BP_Groups_Group::get_group_extras( &$paged_groups, $group_ids, 'newest' );
|
352 |
+
}
|
353 |
|
354 |
return array( 'groups' => $paged_groups, 'total' => $total_groups );
|
355 |
}
|
356 |
|
357 |
+
function get_alphabetically( $limit = null, $page = null, $user_id = false, $search_terms = false, $populate_extras = true ) {
|
358 |
global $wpdb, $bp;
|
359 |
|
360 |
if ( $limit && $page )
|
361 |
$pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
|
362 |
|
363 |
+
if ( !is_user_logged_in() || ( !is_site_admin() && ( $user_id != $bp->loggedin_user->id ) ) )
|
364 |
+
$hidden_sql = " AND g.status != 'hidden'";
|
365 |
|
366 |
+
if ( $search_terms ) {
|
367 |
+
$search_terms = like_escape( $wpdb->escape( $search_terms ) );
|
368 |
+
$search_sql = " AND ( g.name LIKE '%%{$search_terms}%%' OR g.description LIKE '%%{$search_terms}%%' )";
|
369 |
+
}
|
370 |
+
|
371 |
+
if ( $user_id ) {
|
372 |
+
$user_id = $wpdb->escape( $user_id );
|
373 |
+
$paged_groups = $wpdb->get_results( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.is_confirmed = 1 AND m.is_banned = 0 ORDER BY g.name ASC {$pag_sql}" );
|
374 |
+
$total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m LEFT JOIN {$bp->groups->table_name_groupmeta} gm ON m.group_id = gm.group_id INNER JOIN {$bp->groups->table_name} g ON m.group_id = g.id WHERE gm.meta_key = 'last_activity' {$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.is_confirmed = 1 AND m.is_banned = 0" );
|
375 |
+
} else {
|
376 |
+
$paged_groups = $wpdb->get_results( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql} ORDER BY g.name ASC {$pag_sql}" );
|
377 |
+
$total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql}" );
|
378 |
+
}
|
379 |
+
|
380 |
+
if ( !empty( $populate_extras ) ) {
|
381 |
+
foreach ( (array)$paged_groups as $group ) $group_ids[] = $group->id;
|
382 |
+
$group_ids = $wpdb->escape( join( ',', (array)$group_ids ) );
|
383 |
+
$paged_groups = BP_Groups_Group::get_group_extras( &$paged_groups, $group_ids, 'newest' );
|
384 |
+
}
|
385 |
|
386 |
return array( 'groups' => $paged_groups, 'total' => $total_groups );
|
387 |
}
|
388 |
|
389 |
+
function get_by_most_forum_topics( $limit = null, $page = null, $user_id = false, $search_terms = false, $populate_extras = true ) {
|
390 |
global $wpdb, $bp, $bbdb;
|
391 |
|
392 |
+
if ( !$bbdb )
|
393 |
+
do_action( 'bbpress_init' );
|
394 |
+
|
395 |
if ( $limit && $page ) {
|
396 |
$pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
|
397 |
}
|
398 |
|
399 |
+
if ( !is_user_logged_in() || ( !is_site_admin() && ( $user_id != $bp->loggedin_user->id ) ) )
|
400 |
+
$hidden_sql = " AND g.status != 'hidden'";
|
401 |
+
|
402 |
+
if ( $search_terms ) {
|
403 |
+
$search_terms = like_escape( $wpdb->escape( $search_terms ) );
|
404 |
+
$search_sql = " AND ( g.name LIKE '%%{$search_terms}%%' OR g.description LIKE '%%{$search_terms}%%' )";
|
405 |
+
}
|
406 |
+
|
407 |
+
if ( $user_id ) {
|
408 |
+
$user_id = $wpdb->escape( $user_id );
|
409 |
+
$paged_groups = $wpdb->get_results( "SELECT DISTINCT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_groupmeta} gm3, {$bp->groups->table_name_members} m, {$bbdb->forums} f, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND g.id = gm3.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' AND (gm3.meta_key = 'forum_id' AND gm3.meta_value = f.forum_id) AND f.topics > 0 {$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.is_confirmed = 1 AND m.is_banned = 0 ORDER BY f.topics DESC {$pag_sql}" );
|
410 |
+
$total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_groupmeta} gm3, {$bbdb->forums} f, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND g.id = gm3.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' AND (gm3.meta_key = 'forum_id' AND gm3.meta_value = f.forum_id) AND f.topics > 0 {$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.is_confirmed = 1 AND m.is_banned = 0" );
|
411 |
+
} else {
|
412 |
+
$paged_groups = $wpdb->get_results( "SELECT DISTINCT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_groupmeta} gm3, {$bbdb->forums} f, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND g.id = gm3.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' AND (gm3.meta_key = 'forum_id' AND gm3.meta_value = f.forum_id) AND f.topics > 0 {$hidden_sql} {$search_sql} ORDER BY f.topics DESC {$pag_sql}" );
|
413 |
+
$total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_groupmeta} gm3, {$bbdb->forums} f, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND g.id = gm3.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' AND (gm3.meta_key = 'forum_id' AND gm3.meta_value = f.forum_id) AND f.topics > 0 {$hidden_sql} {$search_sql}" );
|
414 |
+
}
|
415 |
+
|
416 |
+
if ( !empty( $populate_extras ) ) {
|
417 |
+
foreach ( (array)$paged_groups as $group ) $group_ids[] = $group->id;
|
418 |
+
$group_ids = $wpdb->escape( join( ',', (array)$group_ids ) );
|
419 |
+
$paged_groups = BP_Groups_Group::get_group_extras( &$paged_groups, $group_ids, 'newest' );
|
420 |
+
}
|
421 |
|
422 |
return array( 'groups' => $paged_groups, 'total' => $total_groups );
|
423 |
}
|
424 |
|
425 |
+
function get_by_most_forum_posts( $limit = null, $page = null, $search_terms = false, $populate_extras = true ) {
|
426 |
global $wpdb, $bp, $bbdb;
|
427 |
|
428 |
+
if ( !$bbdb )
|
429 |
+
do_action( 'bbpress_init' );
|
430 |
+
|
431 |
if ( $limit && $page ) {
|
432 |
$pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
|
433 |
}
|
434 |
|
435 |
+
if ( !is_user_logged_in() || ( !is_site_admin() && ( $user_id != $bp->loggedin_user->id ) ) )
|
436 |
+
$hidden_sql = " AND g.status != 'hidden'";
|
437 |
+
|
438 |
+
if ( $search_terms ) {
|
439 |
+
$search_terms = like_escape( $wpdb->escape( $search_terms ) );
|
440 |
+
$search_sql = " AND ( g.name LIKE '%%{$search_terms}%%' OR g.description LIKE '%%{$search_terms}%%' )";
|
441 |
+
}
|
442 |
+
|
443 |
+
if ( $user_id ) {
|
444 |
+
$user_id = $wpdb->escape( $user_id );
|
445 |
+
$paged_groups = $wpdb->get_results( "SELECT DISTINCT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_groupmeta} gm3, {$bp->groups->table_name_members} m, {$bbdb->forums} f, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND g.id = gm3.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' AND (gm3.meta_key = 'forum_id' AND gm3.meta_value = f.forum_id) {$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.is_confirmed = 1 AND m.is_banned = 0 ORDER BY f.posts ASC {$pag_sql}" );
|
446 |
+
$total_groups = $wpdb->get_results( "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_groupmeta} gm3, {$bp->groups->table_name_members} m, {$bbdb->forums} f, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND g.id = gm3.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' AND (gm3.meta_key = 'forum_id' AND gm3.meta_value = f.forum_id) AND f.posts > 0 {$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.is_confirmed = 1 AND m.is_banned = 0" );
|
447 |
+
} else {
|
448 |
+
$paged_groups = $wpdb->get_results( "SELECT DISTINCT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_groupmeta} gm3, {$bbdb->forums} f, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND g.id = gm3.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' AND (gm3.meta_key = 'forum_id' AND gm3.meta_value = f.forum_id) AND f.posts > 0 {$hidden_sql} {$search_sql} ORDER BY f.posts ASC {$pag_sql}" );
|
449 |
+
$total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_groupmeta} gm3, {$bbdb->forums} f, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND g.id = gm3.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' AND (gm3.meta_key = 'forum_id' AND gm3.meta_value = f.forum_id) {$hidden_sql} {$search_sql}" );
|
450 |
+
}
|
451 |
+
|
452 |
+
if ( !empty( $populate_extras ) ) {
|
453 |
+
foreach ( (array)$paged_groups as $group ) $group_ids[] = $group->id;
|
454 |
+
$group_ids = $wpdb->escape( join( ',', (array)$group_ids ) );
|
455 |
+
$paged_groups = BP_Groups_Group::get_group_extras( &$paged_groups, $group_ids, 'newest' );
|
456 |
+
}
|
457 |
|
458 |
return array( 'groups' => $paged_groups, 'total' => $total_groups );
|
459 |
}
|
460 |
|
|
|
461 |
function get_all( $limit = null, $page = null, $only_public = true, $sort_by = false, $order = false ) {
|
462 |
global $wpdb, $bp;
|
463 |
|
502 |
return $wpdb->get_results($sql);
|
503 |
}
|
504 |
|
505 |
+
function get_by_letter( $letter, $limit = null, $page = null, $populate_extras = true ) {
|
506 |
global $wpdb, $bp;
|
507 |
|
508 |
if ( strlen($letter) > 1 || is_numeric($letter) || !$letter )
|
515 |
|
516 |
if ( $limit && $page ) {
|
517 |
$pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
|
518 |
+
$total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' AND g.name LIKE '$letter%%' {$hidden_sql} {$search_sql}" ) );
|
519 |
}
|
520 |
|
521 |
+
$paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' AND g.name LIKE '$letter%%' {$hidden_sql} {$search_sql} ORDER BY g.name ASC {$pag_sql}" ) );
|
522 |
+
|
523 |
+
if ( !empty( $populate_extras ) ) {
|
524 |
+
foreach ( (array)$paged_groups as $group ) $group_ids[] = $group->id;
|
525 |
+
$group_ids = $wpdb->escape( join( ',', (array)$group_ids ) );
|
526 |
+
$paged_groups = BP_Groups_Group::get_group_extras( &$paged_groups, $group_ids, 'newest' );
|
527 |
+
}
|
528 |
|
529 |
return array( 'groups' => $paged_groups, 'total' => $total_groups );
|
530 |
}
|
531 |
|
532 |
+
function get_random( $limit = null, $page = null, $user_id = false, $search_terms = false, $populate_extras = true ) {
|
533 |
global $wpdb, $bp;
|
534 |
|
535 |
+
if ( $limit && $page )
|
|
|
|
|
|
|
536 |
$pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
|
537 |
+
|
538 |
+
if ( !is_user_logged_in() || ( !is_site_admin() && ( $user_id != $bp->loggedin_user->id ) ) )
|
539 |
+
$hidden_sql = "AND g.status != 'hidden'";
|
540 |
+
|
541 |
+
if ( $search_terms ) {
|
542 |
+
$search_terms = like_escape( $wpdb->escape( $search_terms ) );
|
543 |
+
$search_sql = " AND ( g.name LIKE '%%{$search_terms}%%' OR g.description LIKE '%%{$search_terms}%%' )";
|
544 |
}
|
545 |
|
546 |
+
if ( $user_id ) {
|
547 |
+
$user_id = $wpdb->escape( $user_id );
|
548 |
+
$paged_groups = $wpdb->get_results( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.is_confirmed = 1 AND m.is_banned = 0 ORDER BY rand() {$pag_sql}" );
|
549 |
+
$total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m LEFT JOIN {$bp->groups->table_name_groupmeta} gm ON m.group_id = gm.group_id INNER JOIN {$bp->groups->table_name} g ON m.group_id = g.id WHERE gm.meta_key = 'last_activity'{$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.is_confirmed = 1 AND m.is_banned = 0" );
|
550 |
+
} else {
|
551 |
+
$paged_groups = $wpdb->get_results( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql} ORDER BY rand() {$pag_sql}" );
|
552 |
+
$total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name_groupmeta} gm INNER JOIN {$bp->groups->table_name} g ON gm.group_id = g.id WHERE gm.meta_key = 'last_activity'{$hidden_sql} {$search_sql}" );
|
553 |
+
}
|
554 |
+
|
555 |
+
if ( !empty( $populate_extras ) ) {
|
556 |
+
foreach ( (array)$paged_groups as $group ) $group_ids[] = $group->id;
|
557 |
+
$group_ids = $wpdb->escape( join( ',', (array)$group_ids ) );
|
558 |
+
$paged_groups = BP_Groups_Group::get_group_extras( &$paged_groups, $group_ids, 'newest' );
|
559 |
+
}
|
560 |
|
561 |
return array( 'groups' => $paged_groups, 'total' => $total_groups );
|
562 |
}
|
563 |
|
564 |
+
function get_group_extras( $paged_groups, $group_ids, $type = false ) {
|
565 |
+
global $bp, $wpdb;
|
566 |
+
|
567 |
+
if ( empty( $group_ids ) )
|
568 |
+
return $paged_groups;
|
569 |
+
|
570 |
+
/* Fetch the logged in users status within each group */
|
571 |
+
$user_status = $wpdb->get_col( $wpdb->prepare( "SELECT group_id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id IN ( {$group_ids} ) AND is_confirmed = 1 AND is_banned = 0", $bp->loggedin_user->id ) );
|
572 |
+
for ( $i = 0; $i < count( $paged_groups ); $i++ ) {
|
573 |
+
foreach ( (array)$user_status as $group_id ) {
|
574 |
+
if ( $group_id == $paged_groups[$i]->id )
|
575 |
+
$paged_groups[$i]->is_member = true;
|
576 |
+
}
|
577 |
+
}
|
578 |
+
|
579 |
+
$user_banned = $wpdb->get_col( $wpdb->prepare( "SELECT group_id FROM {$bp->groups->table_name_members} WHERE is_banned = 1 AND user_id = %d AND group_id IN ( {$group_ids} )", $bp->loggedin_user->id ) );
|
580 |
+
for ( $i = 0; $i < count( $paged_groups ); $i++ ) {
|
581 |
+
foreach ( (array)$user_banned as $group_id ) {
|
582 |
+
if ( $group_id == $paged_groups[$i]->id )
|
583 |
+
$paged_groups[$i]->is_banned = true;
|
584 |
+
}
|
585 |
+
}
|
586 |
+
|
587 |
+
return $paged_groups;
|
588 |
+
}
|
589 |
+
|
590 |
function delete_all_invites( $group_id ) {
|
591 |
global $wpdb, $bp;
|
592 |
|
593 |
return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->groups->table_name_members} WHERE group_id = %d AND invite_sent = 1", $group_id ) );
|
594 |
}
|
595 |
|
596 |
+
function get_total_group_count() {
|
597 |
+
global $wpdb, $bp;
|
598 |
+
|
599 |
+
if ( !is_site_admin() )
|
600 |
+
$hidden_sql = "WHERE status != 'hidden'";
|
601 |
+
|
602 |
+
return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->groups->table_name} {$hidden_sql}" ) );
|
603 |
+
}
|
604 |
+
|
605 |
function get_global_forum_topic_count( $type ) {
|
606 |
global $bbdb, $wpdb, $bp;
|
607 |
|
667 |
$this->is_mod = $member->is_mod;
|
668 |
$this->is_banned = $member->is_banned;
|
669 |
$this->user_title = $member->user_title;
|
670 |
+
$this->date_modified = $member->date_modified;
|
671 |
$this->is_confirmed = $member->is_confirmed;
|
672 |
$this->comments = $member->comments;
|
673 |
$this->invite_sent = $member->invite_sent;
|
694 |
do_action( 'groups_member_before_save', $this );
|
695 |
|
696 |
if ( $this->id ) {
|
697 |
+
$sql = $wpdb->prepare( "UPDATE {$bp->groups->table_name_members} SET inviter_id = %d, is_admin = %d, is_mod = %d, is_banned = %d, user_title = %s, date_modified = %s, is_confirmed = %d, comments = %s, invite_sent = %d WHERE id = %d", $this->inviter_id, $this->is_admin, $this->is_mod, $this->is_banned, $this->user_title, $this->date_modified, $this->is_confirmed, $this->comments, $this->invite_sent, $this->id );
|
698 |
} else {
|
699 |
+
$sql = $wpdb->prepare( "INSERT INTO {$bp->groups->table_name_members} ( user_id, group_id, inviter_id, is_admin, is_mod, is_banned, user_title, date_modified, is_confirmed, comments, invite_sent ) VALUES ( %d, %d, %d, %d, %d, %d, %s, %s, %d, %s, %d )", $this->user_id, $this->group_id, $this->inviter_id, $this->is_admin, $this->is_mod, $this->is_banned, $this->user_title, $this->date_modified, $this->is_confirmed, $this->comments, $this->invite_sent );
|
700 |
}
|
701 |
|
702 |
if ( !$wpdb->query($sql) )
|
742 |
|
743 |
groups_update_groupmeta( $this->group_id, 'total_member_count', ( (int) groups_get_groupmeta( $this->group_id, 'total_member_count' ) - 1 ) );
|
744 |
|
745 |
+
$group_count = get_usermeta( $this->user_id, 'total_group_count' );
|
746 |
+
if ( !empty( $group_count ) )
|
747 |
+
update_usermeta( $this->user_id, 'total_group_count', (int)$group_count - 1 );
|
748 |
+
|
749 |
return $this->save();
|
750 |
}
|
751 |
|
756 |
$this->is_banned = 0;
|
757 |
|
758 |
groups_update_groupmeta( $this->group_id, 'total_member_count', ( (int) groups_get_groupmeta( $this->group_id, 'total_member_count' ) + 1 ) );
|
759 |
+
update_usermeta( $this->user_id, 'total_group_count', (int)get_usermeta( $this->user_id, 'total_group_count' ) + 1 );
|
760 |
|
761 |
return $this->save();
|
762 |
}
|
764 |
function accept_invite() {
|
765 |
$this->inviter_id = 0;
|
766 |
$this->is_confirmed = 1;
|
767 |
+
$this->date_modified = gmdate( "Y-m-d H:i:s" );
|
768 |
}
|
769 |
|
770 |
function accept_request() {
|
771 |
$this->is_confirmed = 1;
|
772 |
+
$this->date_modified = gmdate( "Y-m-d H:i:s" );
|
773 |
}
|
774 |
|
775 |
/* Static Functions */
|
776 |
|
777 |
+
function delete( $user_id, $group_id ) {
|
778 |
global $wpdb, $bp;
|
779 |
|
780 |
+
return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d", $user_id, $group_id ) );
|
|
|
|
|
781 |
}
|
782 |
|
783 |
function get_group_ids( $user_id, $limit = false, $page = false ) {
|
786 |
if ( $limit && $page )
|
787 |
$pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
|
788 |
|
789 |
+
// If the user is logged in and viewing their own groups, we can show hidden and private groups
|
790 |
+
if ( $user_id != $bp->loggedin_user->id ) {
|
791 |
+
$group_sql = $wpdb->prepare( "SELECT DISTINCT m.group_id FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE g.status != 'hidden' AND m.user_id = %d AND m.is_confirmed = 1 AND m.is_banned = 0{$pag_sql}", $user_id );
|
792 |
+
$total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE g.status != 'hidden' AND m.user_id = %d AND m.is_confirmed = 1 AND m.is_banned = 0", $user_id ) );
|
793 |
} else {
|
794 |
+
$group_sql = $wpdb->prepare( "SELECT DISTINCT group_id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND is_confirmed = 1 AND is_banned = 0{$pag_sql}", $user_id );
|
795 |
+
$total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT group_id) FROM {$bp->groups->table_name_members} WHERE user_id = %d AND is_confirmed = 1 AND is_banned = 0", $user_id ) );
|
796 |
}
|
797 |
|
798 |
$groups = $wpdb->get_col( $group_sql );
|
808 |
|
809 |
if ( $filter ) {
|
810 |
$filter = like_escape( $wpdb->escape( $filter ) );
|
811 |
+
$filter_sql = " AND ( g.name LIKE '%%{$filter}%%' OR g.description LIKE '%%{$filter}%%' )";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
812 |
}
|
813 |
|
814 |
+
if ( $user_id != $bp->loggedin_user->id )
|
815 |
$hidden_sql = " AND g.status != 'hidden'";
|
816 |
|
817 |
+
$paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count'{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.is_confirmed = 1 AND m.is_banned = 0 ORDER BY m.date_modified DESC {$pag_sql}", $user_id ) );
|
818 |
+
$total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.is_banned = 0 AND m.is_confirmed = 1 ORDER BY m.date_modified DESC", $user_id ) );
|
819 |
|
820 |
return array( 'groups' => $paged_groups, 'total' => $total_groups );
|
821 |
}
|
828 |
|
829 |
if ( $filter ) {
|
830 |
$filter = like_escape( $wpdb->escape( $filter ) );
|
831 |
+
$filter_sql = " AND ( g.name LIKE '%%{$filter}%%' OR g.description LIKE '%%{$filter}%%' )";
|
832 |
}
|
833 |
|
834 |
+
if ( $user_id != $bp->loggedin_user->id )
|
835 |
$hidden_sql = " AND g.status != 'hidden'";
|
836 |
|
837 |
+
$paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count'{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.is_confirmed = 1 AND m.is_banned = 0 AND m.is_admin = 1 ORDER BY m.date_modified ASC {$pag_sql}", $user_id ) );
|
838 |
+
$total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.is_confirmed = 1 AND m.is_banned = 0 AND m.is_admin = 1 ORDER BY date_modified ASC", $user_id ) );
|
839 |
|
840 |
return array( 'groups' => $paged_groups, 'total' => $total_groups );
|
841 |
}
|
848 |
|
849 |
if ( $filter ) {
|
850 |
$filter = like_escape( $wpdb->escape( $filter ) );
|
851 |
+
$filter_sql = " AND ( g.name LIKE '%%{$filter}%%' OR g.description LIKE '%%{$filter}%%' )";
|
852 |
}
|
853 |
|
854 |
+
if ( $user_id != $bp->loggedin_user->id )
|
855 |
$hidden_sql = " AND g.status != 'hidden'";
|
856 |
|
857 |
+
$paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count'{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.is_confirmed = 1 AND m.is_banned = 0 AND m.is_mod = 1 ORDER BY m.date_modified ASC {$pag_sql}", $user_id ) );
|
858 |
+
$total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.is_confirmed = 1 AND m.is_banned = 0 AND m.is_mod = 1 ORDER BY date_modified ASC", $user_id ) );
|
859 |
|
860 |
return array( 'groups' => $paged_groups, 'total' => $total_groups );
|
861 |
}
|
866 |
if ( !$user_id )
|
867 |
$user_id = $bp->displayed_user->id;
|
868 |
|
869 |
+
if ( $user_id != $bp->loggedin_user->id && !is_site_admin() ) {
|
870 |
+
return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id AND g.status != 'hidden' AND m.user_id = %d AND m.is_confirmed = 1 AND m.is_banned = 0", $user_id ) );
|
871 |
} else {
|
872 |
+
return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id AND m.user_id = %d AND m.is_confirmed = 1 AND m.is_banned = 0", $user_id ) );
|
873 |
}
|
874 |
}
|
875 |
|
876 |
+
function get_invites( $user_id, $limit = false, $page = false ) {
|
877 |
global $wpdb, $bp;
|
878 |
|
879 |
+
if ( $limit && $page )
|
880 |
+
$pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
|
881 |
+
|
882 |
+
$paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' AND m.is_confirmed = 0 AND m.inviter_id != 0 AND m.invite_sent = 1 AND m.user_id = %d ORDER BY m.date_modified ASC {$pag_sql}", $user_id ) );
|
883 |
+
$total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id AND m.is_confirmed = 0 AND m.inviter_id != 0 AND m.invite_sent = 1 AND m.user_id = %d ORDER BY date_modified ASC", $user_id ) );
|
884 |
|
885 |
+
return array( 'groups' => $paged_groups, 'total' => $total_groups );
|
886 |
}
|
887 |
|
888 |
function check_has_invite( $user_id, $group_id ) {
|
952 |
global $wpdb, $bp;
|
953 |
|
954 |
// If the user is logged in and viewing their random groups, we can show hidden and private groups
|
955 |
+
if ( bp_is_my_profile() ) {
|
956 |
return $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT group_id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND is_confirmed = 1 AND is_banned = 0 ORDER BY rand() LIMIT $total_groups", $user_id ) );
|
957 |
} else {
|
958 |
return $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT m.group_id FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id AND g.status != 'hidden' AND m.user_id = %d AND m.is_confirmed = 1 AND m.is_banned = 0 ORDER BY rand() LIMIT $total_groups", $user_id ) );
|
959 |
}
|
960 |
}
|
961 |
|
962 |
+
function get_group_member_ids( $group_id ) {
|
963 |
+
global $bp, $wpdb;
|
964 |
+
|
965 |
+
return $wpdb->get_col( $wpdb->prepare( "SELECT user_id FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 1 AND is_banned = 0", $group_id ) );
|
966 |
+
}
|
967 |
+
|
968 |
function get_group_administrator_ids( $group_id ) {
|
969 |
global $bp, $wpdb;
|
970 |
|
995 |
if ( $exclude_banned )
|
996 |
$banned_sql = $wpdb->prepare( " AND is_banned = 0" );
|
997 |
|
998 |
+
if ( bp_is_active( 'xprofile' ) )
|
999 |
+
$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_sql} ORDER BY m.date_modified DESC {$pag_sql}", $group_id ) );
|
1000 |
+
else
|
1001 |
+
$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, u.display_name FROM {$bp->groups->table_name_members} m, {$wpdb->users} u WHERE u.ID = m.user_id AND group_id = %d AND is_confirmed = 1 {$banned_sql} {$exclude_sql} ORDER BY m.date_modified DESC {$pag_sql}", $group_id ) );
|
1002 |
|
1003 |
if ( !$members )
|
1004 |
return false;
|
1008 |
else
|
1009 |
$total_member_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(user_id) FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 1 {$banned_sql} {$exclude_sql}", $group_id ) );
|
1010 |
|
1011 |
+
/* Fetch whether or not the user is a friend */
|
1012 |
+
foreach ( (array)$members as $user ) $user_ids[] = $user->user_id;
|
1013 |
+
$user_ids = $wpdb->escape( join( ',', (array)$user_ids ) );
|
1014 |
+
|
1015 |
+
if ( function_exists( 'friends_install' ) ) {
|
1016 |
+
$friend_status = $wpdb->get_results( $wpdb->prepare( "SELECT initiator_user_id, friend_user_id, is_confirmed FROM {$bp->friends->table_name} WHERE (initiator_user_id = %d AND friend_user_id IN ( {$user_ids} ) ) OR (initiator_user_id IN ( {$user_ids} ) AND friend_user_id = %d )", $bp->loggedin_user->id, $bp->loggedin_user->id ) );
|
1017 |
+
for ( $i = 0; $i < count( $members ); $i++ ) {
|
1018 |
+
foreach ( (array)$friend_status as $status ) {
|
1019 |
+
if ( $status->initiator_user_id == $members[$i]->user_id || $status->friend_user_id == $members[$i]->user_id )
|
1020 |
+
$members[$i]->is_friend = $status->is_confirmed;
|
1021 |
+
}
|
1022 |
+
}
|
1023 |
+
}
|
1024 |
+
|
1025 |
return array( 'members' => $members, 'count' => $total_member_count );
|
1026 |
}
|
1027 |
|
1028 |
+
function delete_all( $group_id ) {
|
1029 |
+
global $wpdb, $bp;
|
1030 |
+
|
1031 |
+
return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->groups->table_name_members} WHERE group_id = %d", $group_id ) );
|
1032 |
+
}
|
1033 |
+
|
1034 |
function delete_all_for_user( $user_id ) {
|
1035 |
global $wpdb, $bp;
|
1036 |
|
1069 |
var $nav_item_name = false;
|
1070 |
|
1071 |
var $display_hook = 'groups_custom_group_boxes';
|
1072 |
+
var $template_file = 'groups/single/plugins';
|
1073 |
|
1074 |
// Methods you should override
|
1075 |
|
1122 |
add_action( 'wp', array( &$this, 'edit_screen_save' ) );
|
1123 |
add_action( 'groups_custom_edit_steps', array( &$this, 'edit_screen' ) );
|
1124 |
|
1125 |
+
if ( '' != locate_template( array( 'groups/single/home.php' ), false ) ) {
|
1126 |
+
bp_core_load_template( apply_filters( 'groups_template_group_home', 'groups/single/home' ) );
|
1127 |
} else {
|
1128 |
add_action( 'bp_template_content_header', create_function( '', 'echo "<ul class=\"content-header-nav\">"; bp_group_admin_tabs(); echo "</ul>";' ) );
|
1129 |
add_action( 'bp_template_content', array( &$this, 'edit_screen' ) );
|
1130 |
+
bp_core_load_template( apply_filters( 'bp_core_template_plugin', '/groups/single/plugins' ) );
|
1131 |
}
|
1132 |
}
|
1133 |
}
|
1153 |
|
1154 |
function _display_hook() {
|
1155 |
add_action( 'bp_template_content', array( &$this, 'display' ) );
|
1156 |
+
bp_core_load_template( apply_filters( 'bp_core_template_plugin', $this->template_file ) );
|
1157 |
}
|
1158 |
}
|
1159 |
|
bp-groups/bp-groups-filters.php
CHANGED
@@ -3,58 +3,59 @@
|
|
3 |
/* Apply WordPress defined filters */
|
4 |
add_filter( 'bp_get_group_description', 'wptexturize' );
|
5 |
add_filter( 'bp_get_group_description_excerpt', 'wptexturize' );
|
6 |
-
add_filter( 'bp_get_the_site_group_description', 'wptexturize' );
|
7 |
-
add_filter( 'bp_get_the_site_group_description_excerpt', 'wptexturize' );
|
8 |
-
add_filter( 'bp_get_group_news', 'wptexturize' );
|
9 |
add_filter( 'bp_get_group_name', 'wptexturize' );
|
10 |
-
add_filter( 'bp_get_the_site_group_name', 'wptexturize' );
|
11 |
|
12 |
add_filter( 'bp_get_group_description', 'convert_smilies' );
|
13 |
add_filter( 'bp_get_group_description_excerpt', 'convert_smilies' );
|
14 |
-
add_filter( 'bp_get_group_news', 'convert_smilies' );
|
15 |
-
add_filter( 'bp_get_the_site_group_description', 'convert_smilies' );
|
16 |
-
add_filter( 'bp_get_the_site_group_description_excerpt', 'convert_smilies' );
|
17 |
|
18 |
add_filter( 'bp_get_group_description', 'convert_chars' );
|
19 |
add_filter( 'bp_get_group_description_excerpt', 'convert_chars' );
|
20 |
-
add_filter( 'bp_get_group_news', 'convert_chars' );
|
21 |
add_filter( 'bp_get_group_name', 'convert_chars' );
|
22 |
-
add_filter( 'bp_get_the_site_group_name', 'convert_chars' );
|
23 |
-
add_filter( 'bp_get_the_site_group_description', 'convert_chars' );
|
24 |
-
add_filter( 'bp_get_the_site_group_description_excerpt', 'convert_chars' );
|
25 |
|
26 |
add_filter( 'bp_get_group_description', 'wpautop' );
|
27 |
add_filter( 'bp_get_group_description_excerpt', 'wpautop' );
|
28 |
-
add_filter( 'bp_get_group_news', 'wpautop' );
|
29 |
-
add_filter( 'bp_get_the_site_group_description', 'wpautop' );
|
30 |
-
add_filter( 'bp_get_the_site_group_description_excerpt', 'wpautop' );
|
31 |
|
32 |
add_filter( 'bp_get_group_description', 'make_clickable' );
|
33 |
add_filter( 'bp_get_group_description_excerpt', 'make_clickable' );
|
34 |
-
add_filter( 'bp_get_group_news', 'make_clickable' );
|
35 |
|
36 |
add_filter( 'bp_get_group_name', 'wp_filter_kses', 1 );
|
37 |
add_filter( 'bp_get_group_permalink', 'wp_filter_kses', 1 );
|
38 |
-
add_filter( 'bp_get_group_description', '
|
39 |
add_filter( 'bp_get_group_description_excerpt', 'wp_filter_kses', 1 );
|
40 |
-
add_filter( 'bp_get_group_news', 'wp_filter_kses', 1 );
|
41 |
-
add_filter( 'bp_get_the_site_group_name', 'wp_filter_kses', 1 );
|
42 |
-
add_filter( 'bp_get_the_site_group_description', 'wp_filter_kses', 1 );
|
43 |
-
add_filter( 'bp_get_the_site_group_description_excerpt', 'wp_filter_kses', 1 );
|
44 |
add_filter( 'groups_group_name_before_save', 'wp_filter_kses', 1 );
|
45 |
add_filter( 'groups_group_description_before_save', 'wp_filter_kses', 1 );
|
46 |
-
add_filter( 'groups_group_news_before_save', 'wp_filter_kses', 1 );
|
47 |
|
48 |
add_filter( 'bp_get_group_description', 'stripslashes' );
|
49 |
add_filter( 'bp_get_group_description_excerpt', 'stripslashes' );
|
50 |
-
add_filter( 'bp_get_group_news', 'stripslashes' );
|
51 |
add_filter( 'bp_get_group_name', 'stripslashes' );
|
52 |
|
53 |
add_filter( 'groups_new_group_forum_desc', 'bp_create_excerpt' );
|
54 |
|
55 |
add_filter( 'groups_group_name_before_save', 'force_balance_tags' );
|
56 |
add_filter( 'groups_group_description_before_save', 'force_balance_tags' );
|
57 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
|
59 |
/**** Filters for group forums ****/
|
60 |
|
@@ -62,7 +63,7 @@ function groups_add_forum_privacy_sql() {
|
|
62 |
global $bp;
|
63 |
|
64 |
/* Only filter the forum SQL on group pages or on the forums directory */
|
65 |
-
if ( ( $bp->groups->current_group && 'public' == $bp->groups->current_group->status ) ||
|
66 |
add_filter( 'get_topics_fields', 'groups_add_forum_fields_sql' );
|
67 |
add_filter( 'get_topics_index_hint', 'groups_add_forum_tables_sql' );
|
68 |
add_filter( 'get_topics_where', 'groups_add_forum_where_sql' );
|
3 |
/* Apply WordPress defined filters */
|
4 |
add_filter( 'bp_get_group_description', 'wptexturize' );
|
5 |
add_filter( 'bp_get_group_description_excerpt', 'wptexturize' );
|
|
|
|
|
|
|
6 |
add_filter( 'bp_get_group_name', 'wptexturize' );
|
|
|
7 |
|
8 |
add_filter( 'bp_get_group_description', 'convert_smilies' );
|
9 |
add_filter( 'bp_get_group_description_excerpt', 'convert_smilies' );
|
|
|
|
|
|
|
10 |
|
11 |
add_filter( 'bp_get_group_description', 'convert_chars' );
|
12 |
add_filter( 'bp_get_group_description_excerpt', 'convert_chars' );
|
|
|
13 |
add_filter( 'bp_get_group_name', 'convert_chars' );
|
|
|
|
|
|
|
14 |
|
15 |
add_filter( 'bp_get_group_description', 'wpautop' );
|
16 |
add_filter( 'bp_get_group_description_excerpt', 'wpautop' );
|
|
|
|
|
|
|
17 |
|
18 |
add_filter( 'bp_get_group_description', 'make_clickable' );
|
19 |
add_filter( 'bp_get_group_description_excerpt', 'make_clickable' );
|
|
|
20 |
|
21 |
add_filter( 'bp_get_group_name', 'wp_filter_kses', 1 );
|
22 |
add_filter( 'bp_get_group_permalink', 'wp_filter_kses', 1 );
|
23 |
+
add_filter( 'bp_get_group_description', 'bp_groups_filter_kses', 1 );
|
24 |
add_filter( 'bp_get_group_description_excerpt', 'wp_filter_kses', 1 );
|
|
|
|
|
|
|
|
|
25 |
add_filter( 'groups_group_name_before_save', 'wp_filter_kses', 1 );
|
26 |
add_filter( 'groups_group_description_before_save', 'wp_filter_kses', 1 );
|
|
|
27 |
|
28 |
add_filter( 'bp_get_group_description', 'stripslashes' );
|
29 |
add_filter( 'bp_get_group_description_excerpt', 'stripslashes' );
|
|
|
30 |
add_filter( 'bp_get_group_name', 'stripslashes' );
|
31 |
|
32 |
add_filter( 'groups_new_group_forum_desc', 'bp_create_excerpt' );
|
33 |
|
34 |
add_filter( 'groups_group_name_before_save', 'force_balance_tags' );
|
35 |
add_filter( 'groups_group_description_before_save', 'force_balance_tags' );
|
36 |
+
|
37 |
+
add_filter( 'bp_get_total_group_count', 'bp_core_number_format' );
|
38 |
+
add_filter( 'bp_get_group_total_for_member', 'bp_core_number_format' );
|
39 |
+
add_filter( 'bp_get_group_total_members', 'bp_core_number_format' );
|
40 |
+
|
41 |
+
function bp_groups_filter_kses( $content ) {
|
42 |
+
global $allowedtags;
|
43 |
+
|
44 |
+
$groups_allowedtags = $allowedtags;
|
45 |
+
$groups_allowedtags['a']['class'] = array();
|
46 |
+
$groups_allowedtags['img'] = array();
|
47 |
+
$groups_allowedtags['img']['src'] = array();
|
48 |
+
$groups_allowedtags['img']['alt'] = array();
|
49 |
+
$groups_allowedtags['img']['class'] = array();
|
50 |
+
$groups_allowedtags['img']['width'] = array();
|
51 |
+
$groups_allowedtags['img']['height'] = array();
|
52 |
+
$groups_allowedtags['img']['class'] = array();
|
53 |
+
$groups_allowedtags['img']['id'] = array();
|
54 |
+
$groups_allowedtags['code'] = array();
|
55 |
+
|
56 |
+
$groups_allowedtags = apply_filters( 'bp_groups_filter_kses', $groups_allowedtags );
|
57 |
+
return wp_kses( $content, $groups_allowedtags );
|
58 |
+
}
|
59 |
|
60 |
/**** Filters for group forums ****/
|
61 |
|
63 |
global $bp;
|
64 |
|
65 |
/* Only filter the forum SQL on group pages or on the forums directory */
|
66 |
+
if ( ( $bp->groups->current_group && 'public' == $bp->groups->current_group->status ) || !$bp->groups->current_group ) {
|
67 |
add_filter( 'get_topics_fields', 'groups_add_forum_fields_sql' );
|
68 |
add_filter( 'get_topics_index_hint', 'groups_add_forum_tables_sql' );
|
69 |
add_filter( 'get_topics_where', 'groups_add_forum_where_sql' );
|
bp-groups/bp-groups-notifications.php
CHANGED
@@ -1,70 +1,22 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
function groups_notification_new_wire_post( $group_id, $wire_post_id ) {
|
4 |
-
global $bp;
|
5 |
-
|
6 |
-
if ( !isset( $_POST['wire-post-email-notify'] ) )
|
7 |
-
return false;
|
8 |
-
|
9 |
-
$wire_post = new BP_Wire_Post( $bp->groups->table_name_wire, $wire_post_id );
|
10 |
-
$group = new BP_Groups_Group( $group_id, false, true );
|
11 |
-
|
12 |
-
$poster_name = bp_core_get_user_displayname( $wire_post->user_id );
|
13 |
-
$poster_profile_link = bp_core_get_user_domain( $wire_post->user_id );
|
14 |
-
|
15 |
-
$subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( 'New wire post on group: %s', 'buddypress' ), stripslashes( attribute_escape( $group->name ) ) );
|
16 |
-
|
17 |
-
foreach ( $group->user_dataset as $user ) {
|
18 |
-
if ( 'no' == get_usermeta( $user->user_id, 'notification_groups_wire_post' ) ) continue;
|
19 |
-
|
20 |
-
$ud = get_userdata( $user->user_id );
|
21 |
-
|
22 |
-
// Set up and send the message
|
23 |
-
$to = $ud->user_email;
|
24 |
-
|
25 |
-
$wire_link = site_url( $bp->groups->slug . '/' . $group->slug . '/wire/' );
|
26 |
-
$group_link = site_url( $bp->groups->slug . '/' . $group->slug . '/' );
|
27 |
-
$settings_link = bp_core_get_user_domain( $user->user_id ) . $bp->settings->slug . '/notifications/';
|
28 |
-
|
29 |
-
$message = sprintf( __(
|
30 |
-
'%s posted on the wire of the group "%s":
|
31 |
-
|
32 |
-
"%s"
|
33 |
-
|
34 |
-
To view the group wire: %s
|
35 |
-
|
36 |
-
To view the group home: %s
|
37 |
-
|
38 |
-
To view %s\'s profile page: %s
|
39 |
-
|
40 |
-
---------------------
|
41 |
-
', 'buddypress' ), $poster_name, stripslashes( attribute_escape( $group->name ) ), stripslashes($wire_post->content), $wire_link, $group_link, $poster_name, $poster_profile_link );
|
42 |
-
|
43 |
-
$message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
|
44 |
-
|
45 |
-
// Send it
|
46 |
-
wp_mail( $to, $subject, $message );
|
47 |
-
|
48 |
-
unset( $message, $to );
|
49 |
-
}
|
50 |
-
}
|
51 |
-
|
52 |
function groups_notification_group_updated( $group_id ) {
|
53 |
global $bp;
|
54 |
|
55 |
-
$group = new BP_Groups_Group( $group_id
|
56 |
$subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . __( 'Group Details Updated', 'buddypress' );
|
57 |
|
58 |
-
|
59 |
-
|
|
|
60 |
|
61 |
-
$ud =
|
62 |
|
63 |
// Set up and send the message
|
64 |
$to = $ud->user_email;
|
65 |
|
66 |
$group_link = site_url( $bp->groups->slug . '/' . $group->slug );
|
67 |
-
$settings_link = bp_core_get_user_domain( $
|
68 |
|
69 |
$message = sprintf( __(
|
70 |
'Group details for the group "%s" were updated:
|
@@ -72,11 +24,15 @@ function groups_notification_group_updated( $group_id ) {
|
|
72 |
To view the group: %s
|
73 |
|
74 |
---------------------
|
75 |
-
', 'buddypress' ),
|
76 |
|
77 |
$message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
|
78 |
|
79 |
-
|
|
|
|
|
|
|
|
|
80 |
wp_mail( $to, $subject, $message );
|
81 |
|
82 |
unset( $message, $to );
|
@@ -92,18 +48,18 @@ function groups_notification_new_membership_request( $requesting_user_id, $admin
|
|
92 |
return false;
|
93 |
|
94 |
$requesting_user_name = bp_core_get_user_displayname( $requesting_user_id );
|
95 |
-
$group = new BP_Groups_Group( $group_id
|
96 |
|
97 |
-
$ud =
|
98 |
-
$requesting_ud =
|
99 |
|
100 |
-
$group_requests = bp_get_group_permalink( $group ) . '
|
101 |
$profile_link = bp_core_get_user_domain( $requesting_user_id );
|
102 |
-
$settings_link = bp_core_get_user_domain( $requesting_user_id ) .
|
103 |
|
104 |
// Set up and send the message
|
105 |
$to = $ud->user_email;
|
106 |
-
$subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( 'Membership request for group: %s', 'buddypress' ),
|
107 |
|
108 |
$message = sprintf( __(
|
109 |
'%s wants to join the group "%s".
|
@@ -116,11 +72,15 @@ To view all pending membership requests for this group, please visit:
|
|
116 |
To view %s\'s profile: %s
|
117 |
|
118 |
---------------------
|
119 |
-
', 'buddypress' ), $requesting_user_name,
|
120 |
|
121 |
$message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
|
122 |
|
123 |
-
|
|
|
|
|
|
|
|
|
124 |
wp_mail( $to, $subject, $message );
|
125 |
}
|
126 |
|
@@ -136,40 +96,44 @@ function groups_notification_membership_request_completed( $requesting_user_id,
|
|
136 |
if ( 'no' == get_usermeta( $requesting_user_id, 'notification_membership_request_completed' ) )
|
137 |
return false;
|
138 |
|
139 |
-
$group = new BP_Groups_Group( $group_id
|
140 |
|
141 |
-
$ud =
|
142 |
|
143 |
$group_link = bp_get_group_permalink( $group );
|
144 |
-
$settings_link = bp_core_get_user_domain( $requesting_user_id ) .
|
145 |
|
146 |
// Set up and send the message
|
147 |
$to = $ud->user_email;
|
148 |
|
149 |
if ( $accepted ) {
|
150 |
-
$subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( 'Membership request for group "%s" accepted', 'buddypress' ),
|
151 |
$message = sprintf( __(
|
152 |
'Your membership request for the group "%s" has been accepted.
|
153 |
|
154 |
To view the group please login and visit: %s
|
155 |
|
156 |
---------------------
|
157 |
-
', 'buddypress' ),
|
158 |
|
159 |
} else {
|
160 |
-
$subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( 'Membership request for group "%s" rejected', 'buddypress' ),
|
161 |
$message = sprintf( __(
|
162 |
'Your membership request for the group "%s" has been rejected.
|
163 |
|
164 |
To submit another request please log in and visit: %s
|
165 |
|
166 |
---------------------
|
167 |
-
', 'buddypress' ),
|
168 |
}
|
169 |
|
170 |
$message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
|
171 |
|
172 |
-
|
|
|
|
|
|
|
|
|
173 |
wp_mail( $to, $subject, $message );
|
174 |
}
|
175 |
|
@@ -190,16 +154,16 @@ function groups_notification_promoted_member( $user_id, $group_id ) {
|
|
190 |
if ( 'no' == get_usermeta( $user_id, 'notification_groups_admin_promotion' ) )
|
191 |
return false;
|
192 |
|
193 |
-
$group = new BP_Groups_Group( $group_id
|
194 |
-
$ud =
|
195 |
|
196 |
$group_link = bp_get_group_permalink( $group );
|
197 |
-
$settings_link = bp_core_get_user_domain( $user_id ) .
|
198 |
|
199 |
// Set up and send the message
|
200 |
$to = $ud->user_email;
|
201 |
|
202 |
-
$subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( 'You have been promoted in the group: "%s"', 'buddypress' ),
|
203 |
|
204 |
$message = sprintf( __(
|
205 |
'You have been promoted to %s for the group: "%s".
|
@@ -207,11 +171,15 @@ function groups_notification_promoted_member( $user_id, $group_id ) {
|
|
207 |
To view the group please visit: %s
|
208 |
|
209 |
---------------------
|
210 |
-
', 'buddypress' ), $promoted_to,
|
211 |
|
212 |
$message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
|
213 |
|
214 |
-
|
|
|
|
|
|
|
|
|
215 |
wp_mail( $to, $subject, $message );
|
216 |
}
|
217 |
add_action( 'groups_promoted_member', 'groups_notification_promoted_member', 10, 2 );
|
@@ -219,7 +187,7 @@ add_action( 'groups_promoted_member', 'groups_notification_promoted_member', 10,
|
|
219 |
function groups_notification_group_invites( &$group, &$member, $inviter_user_id ) {
|
220 |
global $bp;
|
221 |
|
222 |
-
$inviter_ud =
|
223 |
$inviter_name = bp_core_get_userlink( $inviter_user_id, true, false, true );
|
224 |
$inviter_link = bp_core_get_user_domain( $inviter_user_id );
|
225 |
|
@@ -234,16 +202,16 @@ function groups_notification_group_invites( &$group, &$member, $inviter_user_id
|
|
234 |
if ( 'no' == get_usermeta( $invited_user_id, 'notification_groups_invite' ) )
|
235 |
return false;
|
236 |
|
237 |
-
$invited_ud =
|
238 |
|
239 |
-
$settings_link = bp_core_get_user_domain( $invited_user_id ) .
|
240 |
$invited_link = bp_core_get_user_domain( $invited_user_id );
|
241 |
$invites_link = $invited_link . $bp->groups->slug . '/invites';
|
242 |
|
243 |
// Set up and send the message
|
244 |
$to = $invited_ud->user_email;
|
245 |
|
246 |
-
$subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( 'You have an invitation to the group: "%s"', 'buddypress' ),
|
247 |
|
248 |
$message = sprintf( __(
|
249 |
'One of your friends %s has invited you to the group: "%s".
|
@@ -255,13 +223,77 @@ To view the group visit: %s
|
|
255 |
To view %s\'s profile visit: %s
|
256 |
|
257 |
---------------------
|
258 |
-
', 'buddypress' ), $inviter_name,
|
259 |
|
260 |
$message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
|
261 |
|
262 |
-
|
|
|
|
|
|
|
|
|
263 |
wp_mail( $to, $subject, $message );
|
264 |
}
|
265 |
}
|
266 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
267 |
?>
|
1 |
<?php
|
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
function groups_notification_group_updated( $group_id ) {
|
4 |
global $bp;
|
5 |
|
6 |
+
$group = new BP_Groups_Group( $group_id );
|
7 |
$subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . __( 'Group Details Updated', 'buddypress' );
|
8 |
|
9 |
+
$user_ids = BP_Groups_Member::get_group_member_ids( $group->id );
|
10 |
+
foreach ( (array)$user_ids as $user_id ) {
|
11 |
+
if ( 'no' == get_usermeta( $user_id, 'notification_groups_group_updated' ) ) continue;
|
12 |
|
13 |
+
$ud = bp_core_get_core_userdata( $user_id );
|
14 |
|
15 |
// Set up and send the message
|
16 |
$to = $ud->user_email;
|
17 |
|
18 |
$group_link = site_url( $bp->groups->slug . '/' . $group->slug );
|
19 |
+
$settings_link = bp_core_get_user_domain( $user_id ) . BP_SETTINGS_SLUG . '/notifications/';
|
20 |
|
21 |
$message = sprintf( __(
|
22 |
'Group details for the group "%s" were updated:
|
24 |
To view the group: %s
|
25 |
|
26 |
---------------------
|
27 |
+
', 'buddypress' ), $group->name, $group_link );
|
28 |
|
29 |
$message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
|
30 |
|
31 |
+
/* Send the message */
|
32 |
+
$to = apply_filters( 'groups_notification_group_updated_to', $to );
|
33 |
+
$subject = apply_filters( 'groups_notification_group_updated_subject', $subject, &$group );
|
34 |
+
$message = apply_filters( 'groups_notification_group_updated_message', $message, &$group, $group_link );
|
35 |
+
|
36 |
wp_mail( $to, $subject, $message );
|
37 |
|
38 |
unset( $message, $to );
|
48 |
return false;
|
49 |
|
50 |
$requesting_user_name = bp_core_get_user_displayname( $requesting_user_id );
|
51 |
+
$group = new BP_Groups_Group( $group_id );
|
52 |
|
53 |
+
$ud = bp_core_get_core_userdata($admin_id);
|
54 |
+
$requesting_ud = bp_core_get_core_userdata($requesting_user_id);
|
55 |
|
56 |
+
$group_requests = bp_get_group_permalink( $group ) . 'admin/membership-requests';
|
57 |
$profile_link = bp_core_get_user_domain( $requesting_user_id );
|
58 |
+
$settings_link = bp_core_get_user_domain( $requesting_user_id ) . BP_SETTINGS_SLUG . '/notifications/';
|
59 |
|
60 |
// Set up and send the message
|
61 |
$to = $ud->user_email;
|
62 |
+
$subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( 'Membership request for group: %s', 'buddypress' ), $group->name );
|
63 |
|
64 |
$message = sprintf( __(
|
65 |
'%s wants to join the group "%s".
|
72 |
To view %s\'s profile: %s
|
73 |
|
74 |
---------------------
|
75 |
+
', 'buddypress' ), $requesting_user_name, $group->name, $group_requests, $requesting_user_name, $profile_link );
|
76 |
|
77 |
$message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
|
78 |
|
79 |
+
/* Send the message */
|
80 |
+
$to = apply_filters( 'groups_notification_new_membership_request_to', $to );
|
81 |
+
$subject = apply_filters( 'groups_notification_new_membership_request_subject', $subject, &$group );
|
82 |
+
$message = apply_filters( 'groups_notification_new_membership_request_message', $message, &$group, $requesting_user_name, $profile_link, $group_requests );
|
83 |
+
|
84 |
wp_mail( $to, $subject, $message );
|
85 |
}
|
86 |
|
96 |
if ( 'no' == get_usermeta( $requesting_user_id, 'notification_membership_request_completed' ) )
|
97 |
return false;
|
98 |
|
99 |
+
$group = new BP_Groups_Group( $group_id );
|
100 |
|
101 |
+
$ud = bp_core_get_core_userdata($requesting_user_id);
|
102 |
|
103 |
$group_link = bp_get_group_permalink( $group );
|
104 |
+
$settings_link = bp_core_get_user_domain( $requesting_user_id ) . BP_SETTINGS_SLUG . '/notifications/';
|
105 |
|
106 |
// Set up and send the message
|
107 |
$to = $ud->user_email;
|
108 |
|
109 |
if ( $accepted ) {
|
110 |
+
$subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( 'Membership request for group "%s" accepted', 'buddypress' ), $group->name );
|
111 |
$message = sprintf( __(
|
112 |
'Your membership request for the group "%s" has been accepted.
|
113 |
|
114 |
To view the group please login and visit: %s
|
115 |
|
116 |
---------------------
|
117 |
+
', 'buddypress' ), $group->name, $group_link );
|
118 |
|
119 |
} else {
|
120 |
+
$subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( 'Membership request for group "%s" rejected', 'buddypress' ), $group->name );
|
121 |
$message = sprintf( __(
|
122 |
'Your membership request for the group "%s" has been rejected.
|
123 |
|
124 |
To submit another request please log in and visit: %s
|
125 |
|
126 |
---------------------
|
127 |
+
', 'buddypress' ), $group->name, $group_link );
|
128 |
}
|
129 |
|
130 |
$message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
|
131 |
|
132 |
+
/* Send the message */
|
133 |
+
$to = apply_filters( 'groups_notification_membership_request_completed_to', $to );
|
134 |
+
$subject = apply_filters( 'groups_notification_membership_request_completed_subject', $subject, &$group );
|
135 |
+
$message = apply_filters( 'groups_notification_membership_request_completed_message', $message, &$group, $group_link );
|
136 |
+
|
137 |
wp_mail( $to, $subject, $message );
|
138 |
}
|
139 |
|
154 |
if ( 'no' == get_usermeta( $user_id, 'notification_groups_admin_promotion' ) )
|
155 |
return false;
|
156 |
|
157 |
+
$group = new BP_Groups_Group( $group_id );
|
158 |
+
$ud = bp_core_get_core_userdata($user_id);
|
159 |
|
160 |
$group_link = bp_get_group_permalink( $group );
|
161 |
+
$settings_link = bp_core_get_user_domain( $user_id ) . BP_SETTINGS_SLUG . '/notifications/';
|
162 |
|
163 |
// Set up and send the message
|
164 |
$to = $ud->user_email;
|
165 |
|
166 |
+
$subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( 'You have been promoted in the group: "%s"', 'buddypress' ), $group->name );
|
167 |
|
168 |
$message = sprintf( __(
|
169 |
'You have been promoted to %s for the group: "%s".
|
171 |
To view the group please visit: %s
|
172 |
|
173 |
---------------------
|
174 |
+
', 'buddypress' ), $promoted_to, $group->name, $group_link );
|
175 |
|
176 |
$message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
|
177 |
|
178 |
+
/* Send the message */
|
179 |
+
$to = apply_filters( 'groups_notification_promoted_member_to', $to );
|
180 |
+
$subject = apply_filters( 'groups_notification_promoted_member_subject', $subject, &$group );
|
181 |
+
$message = apply_filters( 'groups_notification_promoted_member_message', $message, &$group, $promoted_to, $group_link );
|
182 |
+
|
183 |
wp_mail( $to, $subject, $message );
|
184 |
}
|
185 |
add_action( 'groups_promoted_member', 'groups_notification_promoted_member', 10, 2 );
|
187 |
function groups_notification_group_invites( &$group, &$member, $inviter_user_id ) {
|
188 |
global $bp;
|
189 |
|
190 |
+
$inviter_ud = bp_core_get_core_userdata( $inviter_user_id );
|
191 |
$inviter_name = bp_core_get_userlink( $inviter_user_id, true, false, true );
|
192 |
$inviter_link = bp_core_get_user_domain( $inviter_user_id );
|
193 |
|
202 |
if ( 'no' == get_usermeta( $invited_user_id, 'notification_groups_invite' ) )
|
203 |
return false;
|
204 |
|
205 |
+
$invited_ud = bp_core_get_core_userdata($invited_user_id);
|
206 |
|
207 |
+
$settings_link = bp_core_get_user_domain( $invited_user_id ) . BP_SETTINGS_SLUG . '/notifications/';
|
208 |
$invited_link = bp_core_get_user_domain( $invited_user_id );
|
209 |
$invites_link = $invited_link . $bp->groups->slug . '/invites';
|
210 |
|
211 |
// Set up and send the message
|
212 |
$to = $invited_ud->user_email;
|
213 |
|
214 |
+
$subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( 'You have an invitation to the group: "%s"', 'buddypress' ), $group->name );
|
215 |
|
216 |
$message = sprintf( __(
|
217 |
'One of your friends %s has invited you to the group: "%s".
|
223 |
To view %s\'s profile visit: %s
|
224 |
|
225 |
---------------------
|
226 |
+
', 'buddypress' ), $inviter_name, $group->name, $invites_link, $group_link, $inviter_name, $inviter_link );
|
227 |
|
228 |
$message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
|
229 |
|
230 |
+
/* Send the message */
|
231 |
+
$to = apply_filters( 'groups_notification_group_invites_to', $to );
|
232 |
+
$subject = apply_filters( 'groups_notification_group_invites_subject', $subject, &$group );
|
233 |
+
$message = apply_filters( 'groups_notification_group_invites_message', $message, &$group, $inviter_name, $inviter_link, $invites_link, $group_link );
|
234 |
+
|
235 |
wp_mail( $to, $subject, $message );
|
236 |
}
|
237 |
}
|
238 |
|
239 |
+
function groups_at_message_notification( $content, $poster_user_id, $group_id, $activity_id ) {
|
240 |
+
global $bp;
|
241 |
+
|
242 |
+
/* Scan for @username strings in an activity update. Notify each user. */
|
243 |
+
$pattern = '/[@]+([A-Za-z0-9-_]+)/';
|
244 |
+
preg_match_all( $pattern, $content, $usernames );
|
245 |
+
|
246 |
+
/* Make sure there's only one instance of each username */
|
247 |
+
if ( !$usernames = array_unique( $usernames[1] ) )
|
248 |
+
return false;
|
249 |
+
|
250 |
+
$group = new BP_Groups_Group( $group_id );
|
251 |
+
|
252 |
+
foreach( (array)$usernames as $username ) {
|
253 |
+
if ( !$receiver_user_id = bp_core_get_userid($username) )
|
254 |
+
continue;
|
255 |
+
|
256 |
+
/* Check the user is a member of the group before sending the update. */
|
257 |
+
if ( !groups_is_user_member( $receiver_user_id, $group_id ) )
|
258 |
+
continue;
|
259 |
+
|
260 |
+
// Now email the user with the contents of the message (if they have enabled email notifications)
|
261 |
+
if ( 'no' != get_usermeta( $user_id, 'notification_activity_new_mention' ) ) {
|
262 |
+
$poster_name = bp_core_get_user_displayname( $poster_user_id );
|
263 |
+
|
264 |
+
$message_link = bp_activity_get_permalink( $activity_id );
|
265 |
+
$settings_link = bp_core_get_user_domain( $receiver_user_id ) . BP_SETTINGS_SLUG . '/notifications/';
|
266 |
+
|
267 |
+
$poster_name = stripslashes( $poster_name );
|
268 |
+
$content = bp_groups_filter_kses( stripslashes( $content ) );
|
269 |
+
|
270 |
+
// Set up and send the message
|
271 |
+
$ud = bp_core_get_core_userdata( $receiver_user_id );
|
272 |
+
$to = $ud->user_email;
|
273 |
+
$subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( '%s mentioned you in the group "%s"', 'buddypress' ), $poster_name, $group->name );
|
274 |
+
|
275 |
+
$message = sprintf( __(
|
276 |
+
'%s mentioned you in the group "%s":
|
277 |
+
|
278 |
+
"%s"
|
279 |
+
|
280 |
+
To view and respond to the message, log in and visit: %s
|
281 |
+
|
282 |
+
---------------------
|
283 |
+
', 'buddypress' ), $poster_name, $group->name, $content, $message_link );
|
284 |
+
|
285 |
+
$message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
|
286 |
+
|
287 |
+
/* Send the message */
|
288 |
+
$to = apply_filters( 'groups_at_message_notification_to', $to );
|
289 |
+
$subject = apply_filters( 'groups_at_message_notification_subject', $subject, &$group, $poster_name );
|
290 |
+
$message = apply_filters( 'groups_at_message_notification_message', $message, &$group, $poster_name, $content, $message_link );
|
291 |
+
|
292 |
+
wp_mail( $to, $subject, $message );
|
293 |
+
}
|
294 |
+
}
|
295 |
+
}
|
296 |
+
add_action( 'bp_groups_posted_update', 'groups_at_message_notification', 10, 4 );
|
297 |
+
|
298 |
+
|
299 |
?>
|
bp-groups/bp-groups-templatetags.php
CHANGED
@@ -1,113 +1,10 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
function bp_groups_header_tabs() {
|
4 |
-
global $bp, $create_group_step, $completed_to_step;
|
5 |
-
?>
|
6 |
-
<li<?php if ( !isset($bp->action_variables[0]) || 'recently-active' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>/my-groups/recently-active"><?php _e( 'Recently Active', 'buddypress' ) ?></a></li>
|
7 |
-
<li<?php if ( 'recently-joined' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>/my-groups/recently-joined"><?php _e( 'Recently Joined', 'buddypress' ) ?></a></li>
|
8 |
-
<li<?php if ( 'most-popular' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>/my-groups/most-popular""><?php _e( 'Most Popular', 'buddypress' ) ?></a></li>
|
9 |
-
<li<?php if ( 'admin-of' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>/my-groups/admin-of""><?php _e( 'Administrator Of', 'buddypress' ) ?></a></li>
|
10 |
-
<li<?php if ( 'mod-of' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>/my-groups/mod-of""><?php _e( 'Moderator Of', 'buddypress' ) ?></a></li>
|
11 |
-
<li<?php if ( 'alphabetically' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>/my-groups/alphabetically""><?php _e( 'Alphabetically', 'buddypress' ) ?></a></li>
|
12 |
-
<?php
|
13 |
-
do_action( 'groups_header_tabs' );
|
14 |
-
}
|
15 |
-
|
16 |
-
function bp_groups_filter_title() {
|
17 |
-
global $bp;
|
18 |
-
|
19 |
-
$current_filter = $bp->action_variables[0];
|
20 |
-
|
21 |
-
switch ( $current_filter ) {
|
22 |
-
case 'recently-active': default:
|
23 |
-
_e( 'Recently Active', 'buddypress' );
|
24 |
-
break;
|
25 |
-
case 'recently-joined':
|
26 |
-
_e( 'Recently Joined', 'buddypress' );
|
27 |
-
break;
|
28 |
-
case 'most-popular':
|
29 |
-
_e( 'Most Popular', 'buddypress' );
|
30 |
-
break;
|
31 |
-
case 'admin-of':
|
32 |
-
_e( 'Administrator Of', 'buddypress' );
|
33 |
-
break;
|
34 |
-
case 'mod-of':
|
35 |
-
_e( 'Moderator Of', 'buddypress' );
|
36 |
-
break;
|
37 |
-
case 'alphabetically':
|
38 |
-
_e( 'Alphabetically', 'buddypress' );
|
39 |
-
break;
|
40 |
-
}
|
41 |
-
do_action( 'bp_groups_filter_title' );
|
42 |
-
}
|
43 |
-
|
44 |
-
function bp_is_group_admin_screen( $slug ) {
|
45 |
-
global $bp;
|
46 |
-
|
47 |
-
if ( $bp->current_component != BP_GROUPS_SLUG || 'admin' != $bp->current_action )
|
48 |
-
return false;
|
49 |
-
|
50 |
-
if ( $bp->action_variables[0] == $slug )
|
51 |
-
return true;
|
52 |
-
|
53 |
-
return false;
|
54 |
-
}
|
55 |
-
|
56 |
-
function bp_group_current_avatar() {
|
57 |
-
global $bp;
|
58 |
-
|
59 |
-
if ( $bp->groups->current_group->avatar_full ) { ?>
|
60 |
-
<img src="<?php echo attribute_escape( $bp->groups->current_group->avatar_full ) ?>" alt="<?php _e( 'Group Avatar', 'buddypress' ) ?>" class="avatar" />
|
61 |
-
<?php } else { ?>
|
62 |
-
<img src="<?php echo $bp->groups->image_base . '/none.gif' ?>" alt="<?php _e( 'No Group Avatar', 'buddypress' ) ?>" class="avatar" />
|
63 |
-
<?php }
|
64 |
-
}
|
65 |
-
|
66 |
-
|
67 |
-
function bp_get_group_has_avatar() {
|
68 |
-
global $bp;
|
69 |
-
|
70 |
-
if ( !empty( $_FILES ) || !bp_core_fetch_avatar( array( 'item_id' => $bp->groups->current_group->id, 'object' => 'group', 'no_grav' => true ) ) )
|
71 |
-
return false;
|
72 |
-
|
73 |
-
return true;
|
74 |
-
}
|
75 |
-
|
76 |
-
function bp_group_avatar_delete_link() {
|
77 |
-
echo bp_get_group_avatar_delete_link();
|
78 |
-
}
|
79 |
-
function bp_get_group_avatar_delete_link() {
|
80 |
-
global $bp;
|
81 |
-
|
82 |
-
return apply_filters( 'bp_get_group_avatar_delete_link', wp_nonce_url( bp_get_group_permalink( $bp->groups->current_group ) . '/admin/group-avatar/delete', 'bp_group_avatar_delete' ) );
|
83 |
-
}
|
84 |
-
|
85 |
-
function bp_group_avatar_edit_form() {
|
86 |
-
groups_avatar_upload();
|
87 |
-
}
|
88 |
-
|
89 |
-
function bp_custom_group_boxes() {
|
90 |
-
do_action( 'groups_custom_group_boxes' );
|
91 |
-
}
|
92 |
-
|
93 |
-
function bp_custom_group_admin_tabs() {
|
94 |
-
do_action( 'groups_custom_group_admin_tabs' );
|
95 |
-
}
|
96 |
-
|
97 |
-
function bp_custom_group_fields_editable() {
|
98 |
-
do_action( 'groups_custom_group_fields_editable' );
|
99 |
-
}
|
100 |
-
|
101 |
-
function bp_custom_group_fields() {
|
102 |
-
do_action( 'groups_custom_group_fields' );
|
103 |
-
}
|
104 |
-
|
105 |
-
|
106 |
/*****************************************************************************
|
107 |
-
*
|
108 |
**/
|
109 |
|
110 |
-
class
|
111 |
var $current_group = -1;
|
112 |
var $group_count;
|
113 |
var $groups;
|
@@ -125,54 +22,25 @@ class BP_Groups_User_Groups_Template {
|
|
125 |
var $sort_by;
|
126 |
var $order;
|
127 |
|
128 |
-
function
|
129 |
global $bp;
|
130 |
|
131 |
-
|
132 |
-
$user_id = $bp->displayed_user->id;
|
133 |
-
|
134 |
-
$this->pag_page = isset( $_REQUEST['grpage'] ) ? intval( $_REQUEST['grpage'] ) : 1;
|
135 |
$this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
|
136 |
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
case 'admin-of':
|
147 |
-
$this->groups = groups_get_user_is_admin_of( $user_id, $this->pag_num, $this->pag_page, $filter );
|
148 |
-
break;
|
149 |
-
|
150 |
-
case 'mod-of':
|
151 |
-
$this->groups = groups_get_user_is_mod_of( $user_id, $this->pag_num, $this->pag_page, $filter );
|
152 |
-
break;
|
153 |
-
|
154 |
-
case 'alphabetical':
|
155 |
-
$this->groups = groups_get_alphabetically_for_user( $user_id, $this->pag_num, $this->pag_page, $filter );
|
156 |
-
break;
|
157 |
-
|
158 |
-
case 'invites':
|
159 |
-
$this->groups = groups_get_invites_for_user();
|
160 |
-
break;
|
161 |
-
|
162 |
-
case 'single-group':
|
163 |
-
$group = new stdClass;
|
164 |
-
$group->group_id = BP_Groups_Group::get_id_from_slug($slug);
|
165 |
-
$this->groups = array( $group );
|
166 |
-
break;
|
167 |
-
|
168 |
-
case 'active': default:
|
169 |
-
$this->groups = groups_get_recently_active_for_user( $user_id, $this->pag_num, $this->pag_page, $filter );
|
170 |
-
break;
|
171 |
-
}
|
172 |
|
173 |
if ( 'invites' == $type ) {
|
174 |
-
$this->total_group_count =
|
175 |
-
$this->group_count =
|
|
|
176 |
} else if ( 'single-group' == $type ) {
|
177 |
$this->single_group = true;
|
178 |
$this->total_group_count = 1;
|
@@ -200,8 +68,8 @@ class BP_Groups_User_Groups_Template {
|
|
200 |
'format' => '',
|
201 |
'total' => ceil($this->total_group_count / $this->pag_num),
|
202 |
'current' => $this->pag_page,
|
203 |
-
'prev_text' => '&
|
204 |
-
'next_text' => '&
|
205 |
'mid_size' => 1
|
206 |
));
|
207 |
}
|
@@ -227,7 +95,7 @@ class BP_Groups_User_Groups_Template {
|
|
227 |
}
|
228 |
}
|
229 |
|
230 |
-
function
|
231 |
if ( $this->current_group + 1 < $this->group_count ) {
|
232 |
return true;
|
233 |
} elseif ( $this->current_group + 1 == $this->group_count ) {
|
@@ -246,21 +114,13 @@ class BP_Groups_User_Groups_Template {
|
|
246 |
$this->in_the_loop = true;
|
247 |
$this->group = $this->next_group();
|
248 |
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
wp_cache_set( '
|
254 |
-
}
|
255 |
-
} else {
|
256 |
-
if ( !$group = wp_cache_get( 'groups_group_nouserdata_' . $this->group->group_id, 'bp' ) ) {
|
257 |
-
$group = new BP_Groups_Group( $this->group->group_id, false, false );
|
258 |
-
wp_cache_set( 'groups_group_nouserdata_' . $this->group->group_id, $group, 'bp' );
|
259 |
-
}
|
260 |
}
|
261 |
|
262 |
-
$this->group = $group;
|
263 |
-
|
264 |
if ( 0 == $this->current_group ) // loop has just started
|
265 |
do_action('loop_start');
|
266 |
}
|
@@ -269,32 +129,24 @@ class BP_Groups_User_Groups_Template {
|
|
269 |
function bp_has_groups( $args = '' ) {
|
270 |
global $groups_template, $bp;
|
271 |
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
|
|
280 |
|
281 |
-
|
282 |
-
|
|
|
283 |
|
284 |
-
/*
|
285 |
-
* for example on example.com/members/andy/groups/my-groups/most-popular/
|
286 |
-
* $type = 'most-popular'
|
287 |
-
*/
|
288 |
if ( 'my-groups' == $bp->current_action ) {
|
289 |
-
$order
|
290 |
-
if ( 'recently-joined' == $order )
|
291 |
-
$type = 'recently-joined';
|
292 |
-
else if ( 'most-popular' == $order )
|
293 |
$type = 'popular';
|
294 |
-
else if ( 'admin-of' == $order )
|
295 |
-
$type = 'admin-of';
|
296 |
-
else if ( 'mod-of' == $order )
|
297 |
-
$type = 'mod-of';
|
298 |
else if ( 'alphabetically' == $order )
|
299 |
$type = 'alphabetical';
|
300 |
} else if ( 'invites' == $bp->current_action ) {
|
@@ -304,16 +156,32 @@ function bp_has_groups( $args = '' ) {
|
|
304 |
$slug = $bp->groups->current_group->slug;
|
305 |
}
|
306 |
|
307 |
-
if ( isset( $_REQUEST['group-filter-box'] ) )
|
308 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
309 |
|
310 |
-
$groups_template = new
|
311 |
return apply_filters( 'bp_has_groups', $groups_template->has_groups(), &$groups_template );
|
312 |
}
|
313 |
|
314 |
function bp_groups() {
|
315 |
global $groups_template;
|
316 |
-
return $groups_template->
|
317 |
}
|
318 |
|
319 |
function bp_the_group() {
|
@@ -338,25 +206,8 @@ function bp_group_is_visible( $group = false ) {
|
|
338 |
return false;
|
339 |
}
|
340 |
|
341 |
-
function
|
342 |
-
|
343 |
-
|
344 |
-
if ( !$group )
|
345 |
-
$group =& $groups_template->group;
|
346 |
-
|
347 |
-
if ( empty( $group->news ) )
|
348 |
-
return false;
|
349 |
-
|
350 |
-
return true;
|
351 |
-
}
|
352 |
-
|
353 |
-
function bp_group_id( $deprecated = true, $deprecated2 = false ) {
|
354 |
-
global $groups_template;
|
355 |
-
|
356 |
-
if ( !$deprecated )
|
357 |
-
return bp_get_group_id();
|
358 |
-
else
|
359 |
-
echo bp_get_group_id();
|
360 |
}
|
361 |
function bp_get_group_id( $group = false ) {
|
362 |
global $groups_template;
|
@@ -367,13 +218,8 @@ function bp_group_id( $deprecated = true, $deprecated2 = false ) {
|
|
367 |
return apply_filters( 'bp_get_group_id', $group->id );
|
368 |
}
|
369 |
|
370 |
-
function bp_group_name(
|
371 |
-
|
372 |
-
|
373 |
-
if ( !$deprecated )
|
374 |
-
return bp_get_group_name();
|
375 |
-
else
|
376 |
-
echo bp_get_group_name();
|
377 |
}
|
378 |
function bp_get_group_name( $group = false ) {
|
379 |
global $groups_template;
|
@@ -457,11 +303,8 @@ function bp_group_avatar_mini() {
|
|
457 |
return bp_get_group_avatar( 'type=thumb&width=30&height=30' );
|
458 |
}
|
459 |
|
460 |
-
function bp_group_last_active(
|
461 |
-
|
462 |
-
return bp_get_group_last_active();
|
463 |
-
else
|
464 |
-
echo bp_get_group_last_active();
|
465 |
}
|
466 |
function bp_get_group_last_active( $group = false ) {
|
467 |
global $groups_template;
|
@@ -469,7 +312,10 @@ function bp_group_last_active( $deprecated = true, $deprecated2 = false ) {
|
|
469 |
if ( !$group )
|
470 |
$group =& $groups_template->group;
|
471 |
|
472 |
-
$last_active =
|
|
|
|
|
|
|
473 |
|
474 |
if ( empty( $last_active ) ) {
|
475 |
return __( 'not yet active', 'buddypress' );
|
@@ -478,11 +324,8 @@ function bp_group_last_active( $deprecated = true, $deprecated2 = false ) {
|
|
478 |
}
|
479 |
}
|
480 |
|
481 |
-
function bp_group_permalink(
|
482 |
-
|
483 |
-
return bp_get_group_permalink();
|
484 |
-
else
|
485 |
-
echo bp_get_group_permalink();
|
486 |
}
|
487 |
function bp_get_group_permalink( $group = false ) {
|
488 |
global $groups_template, $bp;
|
@@ -490,14 +333,11 @@ function bp_group_permalink( $deprecated = false, $deprecated2 = true ) {
|
|
490 |
if ( !$group )
|
491 |
$group =& $groups_template->group;
|
492 |
|
493 |
-
return apply_filters( 'bp_get_group_permalink', $bp->root_domain . '/' . $bp->groups->slug . '/' . $group->slug );
|
494 |
}
|
495 |
|
496 |
-
function bp_group_admin_permalink(
|
497 |
-
|
498 |
-
return bp_get_group_admin_permalink();
|
499 |
-
else
|
500 |
-
echo bp_get_group_admin_permalink();
|
501 |
}
|
502 |
function bp_get_group_admin_permalink( $group = false ) {
|
503 |
global $groups_template, $bp;
|
@@ -520,11 +360,8 @@ function bp_group_slug() {
|
|
520 |
return apply_filters( 'bp_get_group_slug', $group->slug );
|
521 |
}
|
522 |
|
523 |
-
function bp_group_description(
|
524 |
-
|
525 |
-
return bp_get_group_description();
|
526 |
-
else
|
527 |
-
echo bp_get_group_description();
|
528 |
}
|
529 |
function bp_get_group_description( $group = false ) {
|
530 |
global $groups_template;
|
@@ -535,7 +372,7 @@ function bp_group_description( $deprecated = false, $deprecated2 = true ) {
|
|
535 |
return apply_filters( 'bp_get_group_description', stripslashes($group->description) );
|
536 |
}
|
537 |
|
538 |
-
function bp_group_description_editable(
|
539 |
echo bp_get_group_description_editable();
|
540 |
}
|
541 |
function bp_get_group_description_editable( $group = false ) {
|
@@ -547,7 +384,7 @@ function bp_group_description_editable( $deprecated = false ) {
|
|
547 |
return apply_filters( 'bp_get_group_description_editable', $group->description );
|
548 |
}
|
549 |
|
550 |
-
function bp_group_description_excerpt(
|
551 |
echo bp_get_group_description_excerpt();
|
552 |
}
|
553 |
function bp_get_group_description_excerpt( $group = false ) {
|
@@ -559,31 +396,8 @@ function bp_group_description_excerpt( $deprecated = false ) {
|
|
559 |
return apply_filters( 'bp_get_group_description_excerpt', bp_create_excerpt( $group->description, 20 ) );
|
560 |
}
|
561 |
|
562 |
-
function bp_group_news( $deprecated = false ) {
|
563 |
-
echo bp_get_group_news();
|
564 |
-
}
|
565 |
-
function bp_get_group_news( $group = false ) {
|
566 |
-
global $groups_template;
|
567 |
-
|
568 |
-
if ( !$group )
|
569 |
-
$group =& $groups_template->group;
|
570 |
-
|
571 |
-
return apply_filters( 'bp_get_group_news', stripslashes($groups_template->group->news) );
|
572 |
-
}
|
573 |
-
|
574 |
-
function bp_group_news_editable( $deprecated = false ) {
|
575 |
-
echo bp_get_group_news_editable();
|
576 |
-
}
|
577 |
-
function bp_get_group_news_editable( $group = false ) {
|
578 |
-
global $groups_template;
|
579 |
-
|
580 |
-
if ( !$group )
|
581 |
-
$group =& $groups_template->group;
|
582 |
-
|
583 |
-
return apply_filters( 'bp_get_group_news_editable', $group->news );
|
584 |
-
}
|
585 |
|
586 |
-
function bp_group_public_status(
|
587 |
echo bp_get_group_public_status();
|
588 |
}
|
589 |
function bp_get_group_public_status( $group = false ) {
|
@@ -599,7 +413,7 @@ function bp_group_public_status( $deprecated = false ) {
|
|
599 |
}
|
600 |
}
|
601 |
|
602 |
-
function bp_group_is_public(
|
603 |
echo bp_get_group_is_public();
|
604 |
}
|
605 |
function bp_get_group_is_public( $group = false ) {
|
@@ -611,7 +425,7 @@ function bp_group_is_public( $deprecated = false ) {
|
|
611 |
return apply_filters( 'bp_get_group_is_public', $group->is_public );
|
612 |
}
|
613 |
|
614 |
-
function bp_group_date_created(
|
615 |
echo bp_get_group_date_created();
|
616 |
}
|
617 |
function bp_get_group_date_created( $group = false ) {
|
@@ -620,7 +434,7 @@ function bp_group_date_created( $deprecated = false ) {
|
|
620 |
if ( !$group )
|
621 |
$group =& $groups_template->group;
|
622 |
|
623 |
-
return apply_filters( 'bp_get_group_date_created',
|
624 |
}
|
625 |
|
626 |
function bp_group_is_admin() {
|
@@ -635,81 +449,48 @@ function bp_group_is_mod() {
|
|
635 |
return $bp->is_item_mod;
|
636 |
}
|
637 |
|
638 |
-
function bp_group_list_admins( $
|
639 |
global $groups_template;
|
640 |
|
641 |
if ( !$group )
|
642 |
$group =& $groups_template->group;
|
643 |
|
644 |
-
if (
|
645 |
-
|
646 |
-
|
647 |
-
if ( $admins ) {
|
648 |
-
if ( $full_list ) { ?>
|
649 |
-
<ul id="group-admins">
|
650 |
-
<?php for ( $i = 0; $i < count($admins); $i++ ) { ?>
|
651 |
<li>
|
652 |
-
<a href="<?php echo $
|
653 |
-
<h5><?php echo $admins[$i]->user->user_link ?></h5>
|
654 |
-
<span class="activity"><?php echo $admins[$i]->user_title ?></span>
|
655 |
-
<hr />
|
656 |
</li>
|
657 |
<?php } ?>
|
658 |
-
|
659 |
-
<?php } else { ?>
|
660 |
-
<?php for ( $i = 0; $i < count($admins); $i++ ) { ?>
|
661 |
-
<?php echo $admins[$i]->user->user_link ?>
|
662 |
-
<?php } ?>
|
663 |
-
<?php } ?>
|
664 |
<?php } else { ?>
|
665 |
<span class="activity"><?php _e( 'No Admins', 'buddypress' ) ?></span>
|
666 |
<?php } ?>
|
667 |
-
|
668 |
<?php
|
669 |
}
|
670 |
|
671 |
-
function bp_group_list_mods( $
|
672 |
global $groups_template;
|
673 |
|
674 |
if ( !$group )
|
675 |
$group =& $groups_template->group;
|
676 |
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
if ( $full_list ) { ?>
|
681 |
-
<ul id="group-mods" class="mods-list">
|
682 |
-
<?php for ( $i = 0; $i < count($group_mods); $i++ ) { ?>
|
683 |
<li>
|
684 |
-
<a href="<?php echo
|
685 |
-
<h5><?php echo bp_core_get_userlink( $group_mods[$i]->user_id ) ?></h5>
|
686 |
-
<span class="activity"><?php _e( 'Group Mod', 'buddypress' ) ?></span>
|
687 |
-
<div class="clear"></div>
|
688 |
</li>
|
689 |
<?php } ?>
|
690 |
-
|
691 |
-
<?php } else { ?>
|
692 |
-
<?php for ( $i = 0; $i < count($admins); $i++ ) { ?>
|
693 |
-
<?php echo bp_core_get_userlink( $group_mods[$i]->user_id ) . ' ' ?>
|
694 |
-
<?php } ?>
|
695 |
-
<?php } ?>
|
696 |
<?php } else { ?>
|
697 |
<span class="activity"><?php _e( 'No Mods', 'buddypress' ) ?></span>
|
698 |
<?php } ?>
|
699 |
-
|
700 |
<?php
|
701 |
}
|
702 |
|
703 |
-
function bp_group_all_members_permalink(
|
704 |
-
|
705 |
-
|
706 |
-
if ( !$group )
|
707 |
-
$group =& $groups_template->group;
|
708 |
-
|
709 |
-
if ( !$deprecated )
|
710 |
-
return bp_get_group_all_members_permalink();
|
711 |
-
else
|
712 |
-
echo bp_get_group_all_members_permalink();
|
713 |
}
|
714 |
function bp_get_group_all_members_permalink( $group = false ) {
|
715 |
global $groups_template, $bp;
|
@@ -717,7 +498,7 @@ function bp_group_all_members_permalink( $deprecated = true, $deprecated2 = fals
|
|
717 |
if ( !$group )
|
718 |
$group =& $groups_template->group;
|
719 |
|
720 |
-
return apply_filters( 'bp_get_group_all_members_permalink', bp_get_group_permalink( $group ) . '
|
721 |
}
|
722 |
|
723 |
function bp_group_search_form() {
|
@@ -726,6 +507,7 @@ function bp_group_search_form() {
|
|
726 |
$action = $bp->displayed_user->domain . $bp->groups->slug . '/my-groups/search/';
|
727 |
$label = __('Filter Groups', 'buddypress');
|
728 |
$name = 'group-filter-box';
|
|
|
729 |
?>
|
730 |
<form action="<?php echo $action ?>" id="group-search-form" method="post">
|
731 |
<label for="<?php echo $name ?>" id="<?php echo $name ?>-label"><?php echo $label ?></label>
|
@@ -745,41 +527,39 @@ function bp_group_show_no_groups_message() {
|
|
745 |
return false;
|
746 |
}
|
747 |
|
748 |
-
function
|
749 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
750 |
}
|
751 |
-
function
|
752 |
global $groups_template;
|
753 |
|
754 |
-
return apply_filters( '
|
755 |
}
|
756 |
|
757 |
-
function
|
758 |
global $bp, $groups_template;
|
759 |
|
760 |
-
$from_num = intval( ( $groups_template->pag_page - 1 ) * $groups_template->pag_num ) + 1;
|
761 |
-
$to_num = ( $from_num + ( $groups_template->pag_num - 1 ) > $groups_template->total_group_count ) ? $groups_template->total_group_count : $from_num + ( $groups_template->pag_num - 1) ;
|
|
|
762 |
|
763 |
-
echo sprintf( __( 'Viewing group %
|
764 |
<span class="ajax-loader"></span><?php
|
765 |
}
|
766 |
|
767 |
-
function
|
768 |
-
echo
|
769 |
-
}
|
770 |
-
function bp_get_total_group_count() {
|
771 |
-
global $groups_template;
|
772 |
-
|
773 |
-
return apply_filters( 'bp_get_total_group_count', $groups_template->total_group_count );
|
774 |
-
}
|
775 |
-
|
776 |
-
function bp_group_total_members( $deprecated = true, $deprecated2 = false ) {
|
777 |
-
if ( !$deprecated )
|
778 |
-
return bp_get_group_total_members();
|
779 |
-
else
|
780 |
-
echo bp_get_group_total_members();
|
781 |
}
|
782 |
-
function bp_get_group_total_members( $
|
783 |
global $groups_template;
|
784 |
|
785 |
if ( !$group )
|
@@ -788,29 +568,19 @@ function bp_group_total_members( $deprecated = true, $deprecated2 = false ) {
|
|
788 |
return apply_filters( 'bp_get_group_total_members', $group->total_member_count );
|
789 |
}
|
790 |
|
791 |
-
function
|
792 |
-
|
793 |
-
|
794 |
-
if ( !$group )
|
795 |
-
$group =& $groups_template->group;
|
796 |
-
|
797 |
-
if ( $group->enable_wire )
|
798 |
-
echo ' checked="checked"';
|
799 |
}
|
|
|
|
|
800 |
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
if ( $group->enable_wire )
|
808 |
-
return true;
|
809 |
-
|
810 |
-
return false;
|
811 |
-
}
|
812 |
|
813 |
-
function bp_group_forum_permalink(
|
814 |
echo bp_get_group_forum_permalink();
|
815 |
}
|
816 |
function bp_get_group_forum_permalink( $group = false ) {
|
@@ -819,31 +589,99 @@ function bp_group_forum_permalink( $deprecated = false ) {
|
|
819 |
if ( !$group )
|
820 |
$group =& $groups_template->group;
|
821 |
|
822 |
-
return apply_filters( 'bp_get_group_forum_permalink', bp_get_group_permalink( $group ) . '
|
823 |
}
|
824 |
|
825 |
-
function
|
826 |
-
|
|
|
|
|
|
|
827 |
|
828 |
-
|
829 |
-
|
|
|
830 |
|
831 |
-
|
832 |
-
|
833 |
-
if ( $group->enable_forum )
|
834 |
-
return true;
|
835 |
|
|
|
836 |
return false;
|
837 |
-
|
|
|
838 |
return false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
839 |
}
|
|
|
|
|
840 |
}
|
841 |
|
842 |
-
|
|
|
843 |
}
|
|
|
|
|
844 |
|
845 |
-
|
846 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
847 |
|
848 |
if ( !$group )
|
849 |
$group =& $groups_template->group;
|
@@ -872,7 +710,7 @@ function bp_group_admin_memberlist( $admin_list = false, $group = false ) {
|
|
872 |
?>
|
873 |
<?php if ( $admins ) { ?>
|
874 |
<ul id="admins-list" class="item-list<?php if ( $admin_list ) { ?> single-line<?php } ?>">
|
875 |
-
<?php foreach ( $admins as $admin ) { ?>
|
876 |
<?php if ( $admin_list ) { ?>
|
877 |
<li>
|
878 |
<?php echo bp_core_fetch_avatar( array( 'item_id' => $admin->user_id, 'type' => 'thumb', 'width' => 30, 'height' => 30 ) ) ?>
|
@@ -910,7 +748,7 @@ function bp_group_mod_memberlist( $admin_list = false, $group = false ) {
|
|
910 |
?>
|
911 |
<?php if ( $group_mods ) { ?>
|
912 |
<ul id="mods-list" class="item-list<?php if ( $admin_list ) { ?> single-line<?php } ?>">
|
913 |
-
<?php foreach ( $group_mods as $mod ) { ?>
|
914 |
<?php if ( $admin_list ) { ?>
|
915 |
<li>
|
916 |
<?php echo bp_core_fetch_avatar( array( 'item_id' => $mod->user_id, 'type' => 'thumb', 'width' => 30, 'height' => 30 ) ) ?>
|
@@ -961,7 +799,7 @@ function bp_group_member_promote_mod_link( $args = '' ) {
|
|
961 |
$r = wp_parse_args( $args, $defaults );
|
962 |
extract( $r, EXTR_SKIP );
|
963 |
|
964 |
-
return apply_filters( 'bp_get_group_member_promote_mod_link', wp_nonce_url( bp_get_group_permalink( $group ) . '
|
965 |
}
|
966 |
|
967 |
function bp_group_member_promote_admin_link( $args = '' ) {
|
@@ -978,10 +816,10 @@ function bp_group_member_promote_admin_link( $args = '' ) {
|
|
978 |
$r = wp_parse_args( $args, $defaults );
|
979 |
extract( $r, EXTR_SKIP );
|
980 |
|
981 |
-
return apply_filters( 'bp_get_group_member_promote_admin_link', wp_nonce_url( bp_get_group_permalink( $group ) . '
|
982 |
}
|
983 |
|
984 |
-
function bp_group_member_demote_link( $user_id = false
|
985 |
global $members_template;
|
986 |
|
987 |
if ( !$user_id )
|
@@ -998,10 +836,10 @@ function bp_group_member_demote_link( $user_id = false, $deprecated = false ) {
|
|
998 |
if ( !$user_id )
|
999 |
$user_id = $members_template->member->user_id;
|
1000 |
|
1001 |
-
return apply_filters( 'bp_get_group_member_demote_link', wp_nonce_url( bp_get_group_permalink( $group ) . '
|
1002 |
}
|
1003 |
|
1004 |
-
function bp_group_member_ban_link( $user_id = false
|
1005 |
global $members_template;
|
1006 |
|
1007 |
if ( !$user_id )
|
@@ -1015,10 +853,10 @@ function bp_group_member_ban_link( $user_id = false, $deprecated = false ) {
|
|
1015 |
if ( !$group )
|
1016 |
$group =& $groups_template->group;
|
1017 |
|
1018 |
-
return apply_filters( 'bp_get_group_member_ban_link', wp_nonce_url( bp_get_group_permalink( $group ) . '
|
1019 |
}
|
1020 |
|
1021 |
-
function bp_group_member_unban_link( $user_id = false
|
1022 |
global $members_template;
|
1023 |
|
1024 |
if ( !$user_id )
|
@@ -1035,7 +873,7 @@ function bp_group_member_unban_link( $user_id = false, $deprecated = false ) {
|
|
1035 |
if ( !$group )
|
1036 |
$group =& $groups_template->group;
|
1037 |
|
1038 |
-
return apply_filters( 'bp_get_group_member_unban_link', wp_nonce_url( bp_get_group_permalink( $group ) . '
|
1039 |
}
|
1040 |
|
1041 |
function bp_group_admin_tabs( $group = false ) {
|
@@ -1075,7 +913,7 @@ function bp_group_total_for_member() {
|
|
1075 |
return apply_filters( 'bp_get_group_total_for_member', BP_Groups_Member::total_group_count() );
|
1076 |
}
|
1077 |
|
1078 |
-
function bp_group_form_action( $page
|
1079 |
echo bp_get_group_form_action( $page );
|
1080 |
}
|
1081 |
function bp_get_group_form_action( $page, $group = false ) {
|
@@ -1084,10 +922,10 @@ function bp_group_form_action( $page, $deprecated = false ) {
|
|
1084 |
if ( !$group )
|
1085 |
$group =& $groups_template->group;
|
1086 |
|
1087 |
-
return apply_filters( 'bp_group_form_action', bp_get_group_permalink( $group ) .
|
1088 |
}
|
1089 |
|
1090 |
-
function bp_group_admin_form_action( $page = false
|
1091 |
echo bp_get_group_admin_form_action( $page );
|
1092 |
}
|
1093 |
function bp_get_group_admin_form_action( $page = false, $group = false ) {
|
@@ -1099,7 +937,7 @@ function bp_group_admin_form_action( $page = false, $deprecated = false ) {
|
|
1099 |
if ( !$page )
|
1100 |
$page = $bp->action_variables[0];
|
1101 |
|
1102 |
-
return apply_filters( 'bp_group_admin_form_action', bp_get_group_permalink( $group ) . '
|
1103 |
}
|
1104 |
|
1105 |
function bp_group_has_requested_membership( $group = false ) {
|
@@ -1117,16 +955,19 @@ function bp_group_has_requested_membership( $group = false ) {
|
|
1117 |
function bp_group_is_member( $group = false ) {
|
1118 |
global $bp, $groups_template;
|
1119 |
|
|
|
|
|
|
|
1120 |
if ( !$group )
|
1121 |
$group =& $groups_template->group;
|
1122 |
|
1123 |
-
if (
|
1124 |
-
return
|
1125 |
|
1126 |
-
return
|
1127 |
}
|
1128 |
|
1129 |
-
function bp_group_accept_invite_link(
|
1130 |
echo bp_get_group_accept_invite_link();
|
1131 |
}
|
1132 |
function bp_get_group_accept_invite_link( $group = false ) {
|
@@ -1138,7 +979,7 @@ function bp_group_accept_invite_link( $deprecated = false ) {
|
|
1138 |
return apply_filters( 'bp_get_group_accept_invite_link', wp_nonce_url( $bp->loggedin_user->domain . $bp->groups->slug . '/invites/accept/' . $group->id, 'groups_accept_invite' ) );
|
1139 |
}
|
1140 |
|
1141 |
-
function bp_group_reject_invite_link(
|
1142 |
echo bp_get_group_reject_invite_link();
|
1143 |
}
|
1144 |
function bp_get_group_reject_invite_link( $group = false ) {
|
@@ -1150,7 +991,7 @@ function bp_group_reject_invite_link( $deprecated = false ) {
|
|
1150 |
return apply_filters( 'bp_get_group_reject_invite_link', wp_nonce_url( $bp->loggedin_user->domain . $bp->groups->slug . '/invites/reject/' . $group->id, 'groups_reject_invite' ) );
|
1151 |
}
|
1152 |
|
1153 |
-
function bp_group_leave_confirm_link(
|
1154 |
echo bp_get_group_leave_confirm_link();
|
1155 |
}
|
1156 |
function bp_get_group_leave_confirm_link( $group = false ) {
|
@@ -1159,10 +1000,10 @@ function bp_group_leave_confirm_link( $deprecated = false ) {
|
|
1159 |
if ( !$group )
|
1160 |
$group =& $groups_template->group;
|
1161 |
|
1162 |
-
return apply_filters( 'bp_group_leave_confirm_link', wp_nonce_url( bp_get_group_permalink( $group ) . '
|
1163 |
}
|
1164 |
|
1165 |
-
function bp_group_leave_reject_link(
|
1166 |
echo bp_get_group_leave_reject_link();
|
1167 |
}
|
1168 |
function bp_get_group_leave_reject_link( $group = false ) {
|
@@ -1174,7 +1015,7 @@ function bp_group_leave_reject_link( $deprecated = false ) {
|
|
1174 |
return apply_filters( 'bp_get_group_leave_reject_link', bp_get_group_permalink( $group ) );
|
1175 |
}
|
1176 |
|
1177 |
-
function bp_group_send_invite_form_action(
|
1178 |
echo bp_get_group_send_invite_form_action();
|
1179 |
}
|
1180 |
function bp_get_group_send_invite_form_action( $group = false ) {
|
@@ -1183,7 +1024,7 @@ function bp_group_send_invite_form_action( $deprecated = false ) {
|
|
1183 |
if ( !$group )
|
1184 |
$group =& $groups_template->group;
|
1185 |
|
1186 |
-
return apply_filters( 'bp_group_send_invite_form_action', bp_get_group_permalink( $group ) . '
|
1187 |
}
|
1188 |
|
1189 |
function bp_has_friends_to_invite( $group = false ) {
|
@@ -1208,32 +1049,40 @@ function bp_group_join_button( $group = false ) {
|
|
1208 |
$group =& $groups_template->group;
|
1209 |
|
1210 |
// If they're not logged in or are banned from the group, no join button.
|
1211 |
-
if ( !is_user_logged_in() ||
|
1212 |
return false;
|
1213 |
|
1214 |
if ( !$group->status )
|
1215 |
return false;
|
1216 |
|
|
|
|
|
|
|
1217 |
echo '<div class="generic-button group-button ' . $group->status . '" id="groupbutton-' . $group->id . '">';
|
1218 |
|
1219 |
switch ( $group->status ) {
|
1220 |
case 'public':
|
1221 |
-
if (
|
1222 |
-
echo '<a class="leave-group" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . '
|
1223 |
else
|
1224 |
-
echo '<a class="join-group" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . '
|
1225 |
break;
|
1226 |
|
1227 |
case 'private':
|
1228 |
-
if (
|
1229 |
-
echo '<a class="leave-group" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . '
|
1230 |
} else {
|
1231 |
if ( !bp_group_has_requested_membership( $group ) )
|
1232 |
-
echo '<a class="request-membership" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . '
|
1233 |
else
|
1234 |
echo '<a class="membership-requested" href="' . bp_get_group_permalink( $group ) . '">' . __( 'Request Sent', 'buddypress' ) . '</a>';
|
1235 |
}
|
1236 |
break;
|
|
|
|
|
|
|
|
|
|
|
1237 |
}
|
1238 |
|
1239 |
echo '</div>';
|
@@ -1258,6 +1107,34 @@ function bp_group_status_message( $group = false ) {
|
|
1258 |
}
|
1259 |
}
|
1260 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1261 |
|
1262 |
/***************************************************************************
|
1263 |
* Group Members Template Tags
|
@@ -1305,8 +1182,8 @@ class BP_Groups_Group_Members_Template {
|
|
1305 |
'format' => '',
|
1306 |
'total' => ceil( $this->total_member_count / $this->pag_num ),
|
1307 |
'current' => $this->pag_page,
|
1308 |
-
'prev_text' => '&
|
1309 |
-
'next_text' => '&
|
1310 |
'mid_size' => 1
|
1311 |
));
|
1312 |
}
|
@@ -1361,7 +1238,7 @@ function bp_group_has_members( $args = '' ) {
|
|
1361 |
|
1362 |
$defaults = array(
|
1363 |
'group_id' => $bp->groups->current_group->id,
|
1364 |
-
'per_page' =>
|
1365 |
'max' => false,
|
1366 |
'exclude_admins_mods' => 1,
|
1367 |
'exclude_banned' => 1
|
@@ -1392,7 +1269,7 @@ function bp_group_member_avatar() {
|
|
1392 |
function bp_get_group_member_avatar() {
|
1393 |
global $members_template;
|
1394 |
|
1395 |
-
return apply_filters( 'bp_get_group_member_avatar', bp_core_fetch_avatar( array( 'item_id' => $members_template->member->user_id, 'type' => 'full' ) ) );
|
1396 |
}
|
1397 |
|
1398 |
function bp_group_member_avatar_thumb() {
|
@@ -1401,7 +1278,7 @@ function bp_group_member_avatar_thumb() {
|
|
1401 |
function bp_get_group_member_avatar_thumb() {
|
1402 |
global $members_template;
|
1403 |
|
1404 |
-
return apply_filters( 'bp_get_group_member_avatar_thumb', bp_core_fetch_avatar( array( 'item_id' => $members_template->member->user_id, 'type' => 'thumb' ) ) );
|
1405 |
}
|
1406 |
|
1407 |
function bp_group_member_avatar_mini( $width = 30, $height = 30 ) {
|
@@ -1410,7 +1287,7 @@ function bp_group_member_avatar_mini( $width = 30, $height = 30 ) {
|
|
1410 |
function bp_get_group_member_avatar_mini( $width = 30, $height = 30 ) {
|
1411 |
global $members_template;
|
1412 |
|
1413 |
-
return apply_filters( 'bp_get_group_member_avatar_mini', bp_core_fetch_avatar( array( 'item_id' => $members_template->member->user_id, 'type' => 'thumb', 'width' => $width, 'height' => $height ) ) );
|
1414 |
}
|
1415 |
|
1416 |
function bp_group_member_name() {
|
@@ -1419,7 +1296,7 @@ function bp_group_member_name() {
|
|
1419 |
function bp_get_group_member_name() {
|
1420 |
global $members_template;
|
1421 |
|
1422 |
-
return apply_filters( 'bp_get_group_member_name',
|
1423 |
}
|
1424 |
|
1425 |
function bp_group_member_url() {
|
@@ -1428,7 +1305,7 @@ function bp_group_member_url() {
|
|
1428 |
function bp_get_group_member_url() {
|
1429 |
global $members_template;
|
1430 |
|
1431 |
-
return apply_filters( 'bp_get_group_member_url',
|
1432 |
}
|
1433 |
|
1434 |
function bp_group_member_link() {
|
@@ -1437,7 +1314,30 @@ function bp_group_member_link() {
|
|
1437 |
function bp_get_group_member_link() {
|
1438 |
global $members_template;
|
1439 |
|
1440 |
-
return apply_filters( 'bp_get_group_member_link',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1441 |
}
|
1442 |
|
1443 |
function bp_group_member_is_banned() {
|
@@ -1446,7 +1346,7 @@ function bp_group_member_is_banned() {
|
|
1446 |
function bp_get_group_member_is_banned() {
|
1447 |
global $members_template, $groups_template;
|
1448 |
|
1449 |
-
return apply_filters( 'bp_get_group_member_is_banned',
|
1450 |
}
|
1451 |
|
1452 |
function bp_group_member_joined_since() {
|
@@ -1455,7 +1355,7 @@ function bp_group_member_joined_since() {
|
|
1455 |
function bp_get_group_member_joined_since() {
|
1456 |
global $members_template;
|
1457 |
|
1458 |
-
return apply_filters( 'bp_get_group_member_joined_since', bp_core_get_last_activity(
|
1459 |
}
|
1460 |
|
1461 |
function bp_group_member_id() {
|
@@ -1500,10 +1400,11 @@ function bp_group_member_pagination_count() {
|
|
1500 |
function bp_get_group_member_pagination_count() {
|
1501 |
global $members_template;
|
1502 |
|
1503 |
-
$from_num = intval( ( $members_template->pag_page - 1 ) * $members_template->pag_num ) + 1;
|
1504 |
-
$to_num = ( $from_num + ( $members_template->pag_num - 1 ) > $members_template->total_member_count ) ? $members_template->total_member_count : $from_num + ( $members_template->pag_num - 1 );
|
|
|
1505 |
|
1506 |
-
return apply_filters( 'bp_get_group_member_pagination_count', sprintf( __( 'Viewing members %
|
1507 |
}
|
1508 |
|
1509 |
function bp_group_member_admin_pagination() {
|
@@ -1531,10 +1432,11 @@ function bp_group_creation_tabs() {
|
|
1531 |
$bp->groups->current_create_step = array_shift( array_keys( $bp->groups->group_creation_steps ) );
|
1532 |
|
1533 |
$counter = 1;
|
1534 |
-
|
|
|
1535 |
$is_enabled = bp_are_previous_group_creation_steps_complete( $slug ); ?>
|
1536 |
|
1537 |
-
<li<?php if ( $bp->groups->current_create_step == $slug ) : ?> class="current"<?php endif; ?>><?php if ( $is_enabled ) : ?><a href="<?php echo $bp->
|
1538 |
$counter++;
|
1539 |
}
|
1540 |
|
@@ -1558,7 +1460,7 @@ function bp_group_creation_form_action() {
|
|
1558 |
if ( empty( $bp->action_variables[1] ) )
|
1559 |
$bp->action_variables[1] = array_shift( array_keys( $bp->groups->group_creation_steps ) );
|
1560 |
|
1561 |
-
return apply_filters( 'bp_get_group_creation_form_action', $bp->
|
1562 |
}
|
1563 |
|
1564 |
function bp_is_group_creation_step( $step_slug ) {
|
@@ -1594,7 +1496,7 @@ function bp_is_group_creation_step_complete( $step_slugs ) {
|
|
1594 |
if ( is_array( $step_slugs ) ) {
|
1595 |
$found = true;
|
1596 |
|
1597 |
-
foreach ( $step_slugs as $step_slug ) {
|
1598 |
if ( !in_array( $step_slug, $bp->groups->completed_create_steps ) )
|
1599 |
$found = false;
|
1600 |
}
|
@@ -1618,7 +1520,7 @@ function bp_are_previous_group_creation_steps_complete( $step_slug ) {
|
|
1618 |
unset( $previous_steps );
|
1619 |
|
1620 |
/* Get previous steps */
|
1621 |
-
foreach ( $bp->groups->group_creation_steps as $slug => $name ) {
|
1622 |
if ( $slug == $step_slug )
|
1623 |
break;
|
1624 |
|
@@ -1652,22 +1554,6 @@ function bp_new_group_description() {
|
|
1652 |
return apply_filters( 'bp_get_new_group_description', $bp->groups->current_group->description );
|
1653 |
}
|
1654 |
|
1655 |
-
function bp_new_group_news() {
|
1656 |
-
echo bp_get_new_group_news();
|
1657 |
-
}
|
1658 |
-
function bp_get_new_group_news() {
|
1659 |
-
global $bp;
|
1660 |
-
return apply_filters( 'bp_get_new_group_news', $bp->groups->current_group->news );
|
1661 |
-
}
|
1662 |
-
|
1663 |
-
function bp_new_group_enable_wire() {
|
1664 |
-
echo bp_get_new_group_enable_wire();
|
1665 |
-
}
|
1666 |
-
function bp_get_new_group_enable_wire() {
|
1667 |
-
global $bp;
|
1668 |
-
return (int) apply_filters( 'bp_get_new_group_enable_wire', $bp->groups->current_group->enable_wire );
|
1669 |
-
}
|
1670 |
-
|
1671 |
function bp_new_group_enable_forum() {
|
1672 |
echo bp_get_new_group_enable_forum();
|
1673 |
}
|
@@ -1696,13 +1582,14 @@ function bp_new_group_avatar( $args = '' ) {
|
|
1696 |
'height' => false,
|
1697 |
'class' => 'avatar',
|
1698 |
'id' => 'avatar-crop-preview',
|
1699 |
-
'alt' => __( 'Group avatar', 'buddypress' )
|
|
|
1700 |
);
|
1701 |
|
1702 |
$r = wp_parse_args( $args, $defaults );
|
1703 |
extract( $r, EXTR_SKIP );
|
1704 |
|
1705 |
-
return apply_filters( 'bp_get_new_group_avatar', bp_core_fetch_avatar( array( 'item_id' => $bp->groups->current_group->id, 'object' => 'group', 'type' => $type, 'avatar_dir' => 'group-avatars', 'alt' => $alt, 'width' => $width, 'height' => $height, 'class' => $class ) ) );
|
1706 |
}
|
1707 |
|
1708 |
function bp_group_creation_previous_link() {
|
@@ -1711,7 +1598,7 @@ function bp_group_creation_previous_link() {
|
|
1711 |
function bp_get_group_creation_previous_link() {
|
1712 |
global $bp;
|
1713 |
|
1714 |
-
foreach ( $bp->groups->group_creation_steps as $slug => $name ) {
|
1715 |
if ( $slug == $bp->action_variables[1] )
|
1716 |
break;
|
1717 |
|
@@ -1784,417 +1671,126 @@ function bp_new_group_invite_friend_list() {
|
|
1784 |
return implode( "\n", (array)$items );
|
1785 |
}
|
1786 |
|
1787 |
-
|
1788 |
-
|
1789 |
-
**/
|
1790 |
-
|
1791 |
-
class BP_Groups_Site_Groups_Template {
|
1792 |
-
var $current_group = -1;
|
1793 |
-
var $group_count;
|
1794 |
-
var $groups;
|
1795 |
-
var $group;
|
1796 |
-
|
1797 |
-
var $in_the_loop;
|
1798 |
-
|
1799 |
-
var $pag_page;
|
1800 |
-
var $pag_num;
|
1801 |
-
var $pag_links;
|
1802 |
-
var $total_group_count;
|
1803 |
-
|
1804 |
-
function bp_groups_site_groups_template( $type, $per_page, $max ) {
|
1805 |
-
global $bp;
|
1806 |
-
|
1807 |
-
/* TODO: Move $_REQUEST vars out of here */
|
1808 |
-
|
1809 |
-
$this->pag_page = isset( $_REQUEST['gpage'] ) ? intval( $_REQUEST['gpage'] ) : 1;
|
1810 |
-
$this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
|
1811 |
-
|
1812 |
-
if ( isset( $_REQUEST['s'] ) && '' != $_REQUEST['s'] && $type != 'random' ) {
|
1813 |
-
$this->groups = BP_Groups_Group::search_groups( $_REQUEST['s'], $this->pag_num, $this->pag_page );
|
1814 |
-
} else if ( isset( $_REQUEST['letter'] ) && '' != $_REQUEST['letter'] ) {
|
1815 |
-
$this->groups = BP_Groups_Group::get_by_letter( $_REQUEST['letter'], $this->pag_num, $this->pag_page );
|
1816 |
-
|
1817 |
-
} else {
|
1818 |
-
switch ( $type ) {
|
1819 |
-
case 'active': default:
|
1820 |
-
$this->groups = groups_get_active( $this->pag_num, $this->pag_page );
|
1821 |
-
break;
|
1822 |
-
|
1823 |
-
case 'alphabetical': default:
|
1824 |
-
$this->groups = groups_get_alphabetically( $this->pag_num, $this->pag_page );
|
1825 |
-
break;
|
1826 |
-
|
1827 |
-
case 'random':
|
1828 |
-
$this->groups = groups_get_random_groups( $this->pag_num, $this->pag_page );
|
1829 |
-
break;
|
1830 |
-
|
1831 |
-
case 'newest':
|
1832 |
-
$this->groups = groups_get_newest( $this->pag_num, $this->pag_page );
|
1833 |
-
break;
|
1834 |
-
|
1835 |
-
case 'popular':
|
1836 |
-
$this->groups = groups_get_popular( $this->pag_num, $this->pag_page );
|
1837 |
-
break;
|
1838 |
-
|
1839 |
-
case 'most-forum-topics':
|
1840 |
-
$this->groups = groups_get_by_most_forum_topics( $this->pag_num, $this->pag_page );
|
1841 |
-
break;
|
1842 |
-
|
1843 |
-
case 'most-forum-posts':
|
1844 |
-
$this->groups = groups_get_by_most_forum_posts( $this->pag_num, $this->pag_page );
|
1845 |
-
break;
|
1846 |
-
}
|
1847 |
-
}
|
1848 |
-
|
1849 |
-
if ( !$max || $max >= (int)$this->groups['total'] )
|
1850 |
-
$this->total_group_count = (int)$this->groups['total'];
|
1851 |
-
else
|
1852 |
-
$this->total_group_count = (int)$max;
|
1853 |
-
|
1854 |
-
$this->groups = $this->groups['groups'];
|
1855 |
-
|
1856 |
-
if ( $max ) {
|
1857 |
-
if ( $max >= count($this->groups) )
|
1858 |
-
$this->group_count = count($this->groups);
|
1859 |
-
else
|
1860 |
-
$this->group_count = (int)$max;
|
1861 |
-
} else {
|
1862 |
-
$this->group_count = count($this->groups);
|
1863 |
-
}
|
1864 |
-
|
1865 |
-
if ( (int) $this->total_group_count && (int) $this->pag_num ) {
|
1866 |
-
$this->pag_links = paginate_links( array(
|
1867 |
-
'base' => add_query_arg( 'gpage', '%#%' ),
|
1868 |
-
'format' => '',
|
1869 |
-
'total' => ceil( (int) $this->total_group_count / (int) $this->pag_num ),
|
1870 |
-
'current' => (int) $this->pag_page,
|
1871 |
-
'prev_text' => '«',
|
1872 |
-
'next_text' => '»',
|
1873 |
-
'mid_size' => 1
|
1874 |
-
));
|
1875 |
-
}
|
1876 |
-
}
|
1877 |
-
|
1878 |
-
function has_groups() {
|
1879 |
-
if ( $this->group_count )
|
1880 |
-
return true;
|
1881 |
-
|
1882 |
-
return false;
|
1883 |
-
}
|
1884 |
-
|
1885 |
-
function next_group() {
|
1886 |
-
$this->current_group++;
|
1887 |
-
$this->group = $this->groups[$this->current_group];
|
1888 |
-
|
1889 |
-
return $this->group;
|
1890 |
-
}
|
1891 |
-
|
1892 |
-
function rewind_groups() {
|
1893 |
-
$this->current_group = -1;
|
1894 |
-
if ( $this->group_count > 0 ) {
|
1895 |
-
$this->group = $this->groups[0];
|
1896 |
-
}
|
1897 |
-
}
|
1898 |
-
|
1899 |
-
function groups() {
|
1900 |
-
if ( $this->current_group + 1 < $this->group_count ) {
|
1901 |
-
return true;
|
1902 |
-
} elseif ( $this->current_group + 1 == $this->group_count ) {
|
1903 |
-
do_action('loop_end');
|
1904 |
-
// Do some cleaning up after the loop
|
1905 |
-
$this->rewind_groups();
|
1906 |
-
}
|
1907 |
-
|
1908 |
-
$this->in_the_loop = false;
|
1909 |
-
return false;
|
1910 |
-
}
|
1911 |
-
|
1912 |
-
function the_group() {
|
1913 |
-
global $group;
|
1914 |
-
|
1915 |
-
$this->in_the_loop = true;
|
1916 |
-
$this->group = $this->next_group();
|
1917 |
-
|
1918 |
-
if ( !$group = wp_cache_get( 'groups_group_nouserdata_' . $this->group->group_id, 'bp' ) ) {
|
1919 |
-
$group = new BP_Groups_Group( $this->group->group_id, false, false );
|
1920 |
-
wp_cache_set( 'groups_group_nouserdata_' . $this->group->group_id, $group, 'bp' );
|
1921 |
-
}
|
1922 |
-
|
1923 |
-
$this->group = $group;
|
1924 |
-
|
1925 |
-
if ( 0 == $this->current_group ) // loop has just started
|
1926 |
-
do_action('loop_start');
|
1927 |
-
}
|
1928 |
-
}
|
1929 |
-
|
1930 |
-
function bp_rewind_site_groups() {
|
1931 |
-
global $site_groups_template;
|
1932 |
-
|
1933 |
-
$site_groups_template->rewind_groups();
|
1934 |
-
}
|
1935 |
-
|
1936 |
-
function bp_has_site_groups( $args = '' ) {
|
1937 |
-
global $site_groups_template;
|
1938 |
-
|
1939 |
-
$defaults = array(
|
1940 |
-
'type' => 'active',
|
1941 |
-
'per_page' => 10,
|
1942 |
-
'max' => false
|
1943 |
-
);
|
1944 |
-
|
1945 |
-
$r = wp_parse_args( $args, $defaults );
|
1946 |
-
extract( $r, EXTR_SKIP );
|
1947 |
-
|
1948 |
-
// type: active ( default ) | random | newest | popular
|
1949 |
-
|
1950 |
-
if ( $max ) {
|
1951 |
-
if ( $per_page > $max )
|
1952 |
-
$per_page = $max;
|
1953 |
-
}
|
1954 |
-
|
1955 |
-
$site_groups_template = new BP_Groups_Site_Groups_Template( $type, $per_page, $max );
|
1956 |
-
return apply_filters( 'bp_has_site_groups', $site_groups_template->has_groups(), &$site_groups_template );
|
1957 |
-
}
|
1958 |
-
|
1959 |
-
function bp_site_groups() {
|
1960 |
-
global $site_groups_template;
|
1961 |
-
|
1962 |
-
return $site_groups_template->groups();
|
1963 |
-
}
|
1964 |
-
|
1965 |
-
function bp_the_site_group() {
|
1966 |
-
global $site_groups_template;
|
1967 |
-
|
1968 |
-
return $site_groups_template->the_group();
|
1969 |
-
}
|
1970 |
-
|
1971 |
-
function bp_site_groups_pagination_count() {
|
1972 |
-
global $bp, $site_groups_template;
|
1973 |
-
|
1974 |
-
$from_num = intval( ( $site_groups_template->pag_page - 1 ) * $site_groups_template->pag_num ) + 1;
|
1975 |
-
$to_num = ( $from_num + ( $site_groups_template->pag_num - 1 ) > $site_groups_template->total_group_count ) ? $site_groups_template->total_group_count : $from_num + ( $site_groups_template->pag_num - 1) ;
|
1976 |
-
|
1977 |
-
echo sprintf( __( 'Viewing group %d to %d (of %d groups)', 'buddypress' ), $from_num, $to_num, $site_groups_template->total_group_count ); ?>
|
1978 |
-
<span class="ajax-loader"></span><?php
|
1979 |
-
}
|
1980 |
-
|
1981 |
-
function bp_site_groups_pagination_links() {
|
1982 |
-
echo bp_get_site_groups_pagination_links();
|
1983 |
-
}
|
1984 |
-
function bp_get_site_groups_pagination_links() {
|
1985 |
-
global $site_groups_template;
|
1986 |
-
|
1987 |
-
return apply_filters( 'bp_get_site_groups_pagination_links', $site_groups_template->pag_links );
|
1988 |
-
}
|
1989 |
-
|
1990 |
-
function bp_the_site_group_id() {
|
1991 |
-
echo bp_get_the_site_group_id();
|
1992 |
-
}
|
1993 |
-
function bp_get_the_site_group_id() {
|
1994 |
-
global $site_groups_template;
|
1995 |
|
1996 |
-
|
1997 |
-
|
|
|
1998 |
|
1999 |
-
|
2000 |
-
|
|
|
|
|
|
|
|
|
2001 |
}
|
2002 |
-
function bp_get_the_site_group_avatar() {
|
2003 |
-
global $site_groups_template;
|
2004 |
|
2005 |
-
|
2006 |
-
|
2007 |
-
|
2008 |
-
|
2009 |
-
echo
|
|
|
|
|
|
|
|
|
|
|
|
|
2010 |
}
|
2011 |
-
function bp_get_the_site_group_avatar_thumb() {
|
2012 |
-
global $site_groups_template;
|
2013 |
|
2014 |
-
|
2015 |
-
|
2016 |
|
2017 |
-
|
2018 |
-
echo bp_get_the_site_group_avatar_mini();
|
2019 |
-
}
|
2020 |
-
function bp_get_the_site_group_avatar_mini() {
|
2021 |
-
global $site_groups_template;
|
2022 |
|
2023 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024 |
}
|
2025 |
-
|
2026 |
-
function bp_the_site_group_link() {
|
2027 |
-
echo bp_get_the_site_group_link();
|
2028 |
}
|
2029 |
-
function bp_get_the_site_group_link() {
|
2030 |
-
global $site_groups_template;
|
2031 |
|
2032 |
-
|
2033 |
-
|
2034 |
-
|
2035 |
-
function bp_the_site_group_name() {
|
2036 |
-
echo bp_get_the_site_group_name();
|
2037 |
-
}
|
2038 |
-
function bp_get_the_site_group_name() {
|
2039 |
-
global $site_groups_template;
|
2040 |
|
2041 |
-
|
2042 |
-
|
2043 |
|
|
|
|
|
2044 |
|
2045 |
-
|
2046 |
-
echo bp_get_the_site_group_last_active();
|
2047 |
}
|
2048 |
-
function bp_get_the_site_group_last_active() {
|
2049 |
-
global $site_groups_template;
|
2050 |
|
2051 |
-
|
2052 |
-
|
|
|
2053 |
|
2054 |
-
function
|
2055 |
-
global $
|
2056 |
|
2057 |
-
|
|
|
|
|
|
|
|
|
2058 |
}
|
2059 |
|
2060 |
-
function
|
2061 |
-
|
2062 |
-
}
|
2063 |
-
function bp_get_the_site_group_description() {
|
2064 |
-
global $site_groups_template;
|
2065 |
|
2066 |
-
|
2067 |
-
|
2068 |
|
2069 |
-
|
2070 |
-
echo bp_get_the_site_group_description_excerpt();
|
2071 |
}
|
2072 |
-
function bp_get_the_site_group_description_excerpt() {
|
2073 |
-
global $site_groups_template;
|
2074 |
-
|
2075 |
-
return apply_filters( 'bp_get_the_site_group_description_excerpt', bp_create_excerpt( bp_get_group_description( $site_groups_template->group, false ), 25 ) );
|
2076 |
-
}
|
2077 |
|
2078 |
-
function
|
2079 |
-
echo
|
2080 |
}
|
2081 |
-
function
|
2082 |
-
global $
|
2083 |
|
2084 |
-
return apply_filters( '
|
2085 |
}
|
2086 |
|
2087 |
-
function
|
2088 |
-
|
2089 |
}
|
2090 |
-
function bp_get_the_site_group_member_count() {
|
2091 |
-
global $site_groups_template;
|
2092 |
-
|
2093 |
-
if ( 1 == (int) $site_groups_template->group->total_member_count )
|
2094 |
-
return apply_filters( 'bp_get_the_site_group_member_count', sprintf( __( '%d member', 'buddypress' ), (int) $site_groups_template->group->total_member_count ) );
|
2095 |
-
else
|
2096 |
-
return apply_filters( 'bp_get_the_site_group_member_count', sprintf( __( '%d members', 'buddypress' ), (int) $site_groups_template->group->total_member_count ) );
|
2097 |
-
}
|
2098 |
|
2099 |
-
function
|
2100 |
-
|
2101 |
}
|
2102 |
-
function bp_get_the_site_group_type() {
|
2103 |
-
global $site_groups_template;
|
2104 |
-
|
2105 |
-
return apply_filters( 'bp_get_the_site_group_type', bp_get_group_type( $site_groups_template->group ) );
|
2106 |
-
}
|
2107 |
|
2108 |
-
function
|
2109 |
-
|
2110 |
}
|
2111 |
-
function bp_get_the_site_group_forum_topic_count( $args = '' ) {
|
2112 |
-
global $site_groups_template;
|
2113 |
|
2114 |
-
|
2115 |
-
|
2116 |
-
);
|
2117 |
-
|
2118 |
-
$r = wp_parse_args( $args, $defaults );
|
2119 |
-
extract( $r, EXTR_SKIP );
|
2120 |
-
|
2121 |
-
if ( !$forum_id = groups_get_groupmeta( $site_groups_template->group->id, 'forum_id' ) )
|
2122 |
-
return false;
|
2123 |
-
|
2124 |
-
if ( !function_exists( 'bp_forums_get_forum_topicpost_count' ) )
|
2125 |
-
return false;
|
2126 |
-
|
2127 |
-
if ( !$site_groups_template->group->forum_counts )
|
2128 |
-
$site_groups_template->group->forum_counts = bp_forums_get_forum_topicpost_count( (int)$forum_id );
|
2129 |
-
|
2130 |
-
if ( (bool) $showtext ) {
|
2131 |
-
if ( 1 == (int) $site_groups_template->group->forum_counts[0]->topics )
|
2132 |
-
$total_topics = sprintf( __( '%d topic', 'buddypress' ), (int) $site_groups_template->group->forum_counts[0]->topics );
|
2133 |
-
else
|
2134 |
-
$total_topics = sprintf( __( '%d topics', 'buddypress' ), (int) $site_groups_template->group->forum_counts[0]->topics );
|
2135 |
-
} else {
|
2136 |
-
$total_topics = (int) $site_groups_template->group->forum_counts[0]->topics;
|
2137 |
-
}
|
2138 |
-
|
2139 |
-
return apply_filters( 'bp_get_the_site_group_forum_topic_count', $total_topics, (bool)$showtext );
|
2140 |
-
}
|
2141 |
-
|
2142 |
-
function bp_the_site_group_forum_post_count( $args = '' ) {
|
2143 |
-
echo bp_get_the_site_group_forum_post_count( $args );
|
2144 |
}
|
2145 |
-
function bp_get_the_site_group_forum_post_count( $args = '' ) {
|
2146 |
-
global $site_groups_template;
|
2147 |
-
|
2148 |
-
$defaults = array(
|
2149 |
-
'showtext' => false
|
2150 |
-
);
|
2151 |
-
|
2152 |
-
$r = wp_parse_args( $args, $defaults );
|
2153 |
-
extract( $r, EXTR_SKIP );
|
2154 |
-
|
2155 |
-
if ( !$forum_id = groups_get_groupmeta( $site_groups_template->group->id, 'forum_id' ) )
|
2156 |
-
return false;
|
2157 |
-
|
2158 |
-
if ( !function_exists( 'bp_forums_get_forum_topicpost_count' ) )
|
2159 |
-
return false;
|
2160 |
-
|
2161 |
-
if ( !$site_groups_template->group->forum_counts )
|
2162 |
-
$site_groups_template->group->forum_counts = bp_forums_get_forum_topicpost_count( (int)$forum_id );
|
2163 |
-
|
2164 |
-
if ( (bool) $showtext ) {
|
2165 |
-
if ( 1 == (int) $site_groups_template->group->forum_counts[0]->posts )
|
2166 |
-
$total_posts = sprintf( __( '%d post', 'buddypress' ), (int) $site_groups_template->group->forum_counts[0]->posts );
|
2167 |
-
else
|
2168 |
-
$total_posts = sprintf( __( '%d posts', 'buddypress' ), (int) $site_groups_template->group->forum_counts[0]->posts );
|
2169 |
-
} else {
|
2170 |
-
$total_posts = (int) $site_groups_template->group->forum_counts[0]->posts;
|
2171 |
-
}
|
2172 |
-
|
2173 |
-
return apply_filters( 'bp_get_the_site_group_forum_post_count', $total_posts, (bool)$showtext );
|
2174 |
-
}
|
2175 |
|
2176 |
-
function
|
2177 |
-
|
2178 |
-
echo '<input type="hidden" id="search_terms" value="' . attribute_escape( $_REQUEST['s'] ) . '" name="search_terms" />';
|
2179 |
-
}
|
2180 |
-
|
2181 |
-
if ( isset( $_REQUEST['letter'] ) ) {
|
2182 |
-
echo '<input type="hidden" id="selected_letter" value="' . attribute_escape( $_REQUEST['letter'] ) . '" name="selected_letter" />';
|
2183 |
-
}
|
2184 |
-
|
2185 |
-
if ( isset( $_REQUEST['groups_search'] ) ) {
|
2186 |
-
echo '<input type="hidden" id="search_terms" value="' . attribute_escape( $_REQUEST['groups_search'] ) . '" name="search_terms" />';
|
2187 |
-
}
|
2188 |
}
|
2189 |
|
2190 |
-
function bp_directory_groups_search_form() {
|
2191 |
-
global $bp; ?>
|
2192 |
-
<form action="" method="get" id="search-groups-form">
|
2193 |
-
<label><input type="text" name="s" id="groups_search" value="<?php if ( isset( $_GET['s'] ) ) { echo attribute_escape( $_GET['s'] ); } else { _e( 'Search anything...', 'buddypress' ); } ?>" onfocus="if (this.value == '<?php _e( 'Search anything...', 'buddypress' ) ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php _e( 'Search anything...', 'buddypress' ) ?>';}" /></label>
|
2194 |
-
<input type="submit" id="groups_search_submit" name="groups_search_submit" value="<?php _e( 'Search', 'buddypress' ) ?>" />
|
2195 |
-
</form>
|
2196 |
-
<?php
|
2197 |
-
}
|
2198 |
|
2199 |
/************************************************************************************
|
2200 |
* Membership Requests Template Tags
|
@@ -2242,8 +1838,8 @@ class BP_Groups_Membership_Requests_Template {
|
|
2242 |
'format' => '',
|
2243 |
'total' => ceil( $this->total_request_count / $this->pag_num ),
|
2244 |
'current' => $this->pag_page,
|
2245 |
-
'prev_text' => '&
|
2246 |
-
'next_text' => '&
|
2247 |
'mid_size' => 1
|
2248 |
));
|
2249 |
}
|
@@ -2512,4 +2108,26 @@ function bp_group_invite_user_remove_invite_url() {
|
|
2512 |
return wp_nonce_url( site_url( BP_GROUPS_SLUG . '/' . $invites_template->invite->group_id . '/invites/remove/' . $invites_template->invite->user->id ), 'groups_invite_uninvite_user' );
|
2513 |
}
|
2514 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2515 |
?>
|
1 |
<?php
|
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
/*****************************************************************************
|
4 |
+
* Groups Template Class/Tags
|
5 |
**/
|
6 |
|
7 |
+
class BP_Groups_Template {
|
8 |
var $current_group = -1;
|
9 |
var $group_count;
|
10 |
var $groups;
|
22 |
var $sort_by;
|
23 |
var $order;
|
24 |
|
25 |
+
function bp_groups_template( $user_id, $type, $page, $per_page, $max, $slug, $search_terms, $populate_extras ) {
|
26 |
global $bp;
|
27 |
|
28 |
+
$this->pag_page = isset( $_REQUEST['grpage'] ) ? intval( $_REQUEST['grpage'] ) : $page;
|
|
|
|
|
|
|
29 |
$this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
|
30 |
|
31 |
+
if ( 'invites' == $type )
|
32 |
+
$this->groups = groups_get_invites_for_user( $user_id, $this->pag_num, $this->pag_page );
|
33 |
+
else if ( 'single-group' == $type ) {
|
34 |
+
$group = new stdClass;
|
35 |
+
$group->group_id = BP_Groups_Group::get_id_from_slug($slug);
|
36 |
+
$this->groups = array( $group );
|
37 |
+
} else
|
38 |
+
$this->groups = groups_get_groups( array( 'type' => $type, 'per_page' => $this->pag_num, 'page' =>$this->pag_page, 'user_id' => $user_id, 'search_terms' => $search_terms, 'populate_extras' => $populate_extras ) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
|
40 |
if ( 'invites' == $type ) {
|
41 |
+
$this->total_group_count = (int)$this->groups['total'];
|
42 |
+
$this->group_count = (int)$this->groups['total'];
|
43 |
+
$this->groups = $this->groups['groups'];
|
44 |
} else if ( 'single-group' == $type ) {
|
45 |
$this->single_group = true;
|
46 |
$this->total_group_count = 1;
|
68 |
'format' => '',
|
69 |
'total' => ceil($this->total_group_count / $this->pag_num),
|
70 |
'current' => $this->pag_page,
|
71 |
+
'prev_text' => '←',
|
72 |
+
'next_text' => '→',
|
73 |
'mid_size' => 1
|
74 |
));
|
75 |
}
|
95 |
}
|
96 |
}
|
97 |
|
98 |
+
function groups() {
|
99 |
if ( $this->current_group + 1 < $this->group_count ) {
|
100 |
return true;
|
101 |
} elseif ( $this->current_group + 1 == $this->group_count ) {
|
114 |
$this->in_the_loop = true;
|
115 |
$this->group = $this->next_group();
|
116 |
|
117 |
+
if ( $this->single_group )
|
118 |
+
$this->group = new BP_Groups_Group( $this->group->group_id, true );
|
119 |
+
else {
|
120 |
+
if ( $this->group )
|
121 |
+
wp_cache_set( 'groups_group_nouserdata_' . $group->group_id, $this->group, 'bp' );
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
}
|
123 |
|
|
|
|
|
124 |
if ( 0 == $this->current_group ) // loop has just started
|
125 |
do_action('loop_start');
|
126 |
}
|
129 |
function bp_has_groups( $args = '' ) {
|
130 |
global $groups_template, $bp;
|
131 |
|
132 |
+
/***
|
133 |
+
* Set the defaults based on the current page. Any of these will be overridden
|
134 |
+
* if arguments are directly passed into the loop. Custom plugins should always
|
135 |
+
* pass their parameters directly to the loop.
|
136 |
+
*/
|
137 |
+
$type = 'active';
|
138 |
+
$user_id = false;
|
139 |
+
$search_terms = false;
|
140 |
+
$slug = false;
|
141 |
|
142 |
+
/* User filtering */
|
143 |
+
if ( !empty( $bp->displayed_user->id ) )
|
144 |
+
$user_id = $bp->displayed_user->id;
|
145 |
|
146 |
+
/* Type */
|
|
|
|
|
|
|
147 |
if ( 'my-groups' == $bp->current_action ) {
|
148 |
+
if ( 'most-popular' == $order )
|
|
|
|
|
|
|
149 |
$type = 'popular';
|
|
|
|
|
|
|
|
|
150 |
else if ( 'alphabetically' == $order )
|
151 |
$type = 'alphabetical';
|
152 |
} else if ( 'invites' == $bp->current_action ) {
|
156 |
$slug = $bp->groups->current_group->slug;
|
157 |
}
|
158 |
|
159 |
+
if ( isset( $_REQUEST['group-filter-box'] ) || isset( $_REQUEST['s'] ) )
|
160 |
+
$search_terms = ( isset( $_REQUEST['group-filter-box'] ) ) ? $_REQUEST['group-filter-box'] : $_REQUEST['s'];
|
161 |
+
|
162 |
+
$defaults = array(
|
163 |
+
'type' => $type,
|
164 |
+
'page' => 1,
|
165 |
+
'per_page' => 20,
|
166 |
+
'max' => false,
|
167 |
+
|
168 |
+
'user_id' => $user_id, // Pass a user ID to limit to groups this user has joined
|
169 |
+
'slug' => $slug, // Pass a group slug to only return that group
|
170 |
+
'search_terms' => $search_terms, // Pass search terms to return only matching groups
|
171 |
+
|
172 |
+
'populate_extras' => true // Get extra meta - is_member, is_banned
|
173 |
+
);
|
174 |
+
|
175 |
+
$r = wp_parse_args( $args, $defaults );
|
176 |
+
extract( $r );
|
177 |
|
178 |
+
$groups_template = new BP_Groups_Template( (int)$user_id, $type, (int)$page, (int)$per_page, (int)$max, $slug, $search_terms, (bool)$populate_extras );
|
179 |
return apply_filters( 'bp_has_groups', $groups_template->has_groups(), &$groups_template );
|
180 |
}
|
181 |
|
182 |
function bp_groups() {
|
183 |
global $groups_template;
|
184 |
+
return $groups_template->groups();
|
185 |
}
|
186 |
|
187 |
function bp_the_group() {
|
206 |
return false;
|
207 |
}
|
208 |
|
209 |
+
function bp_group_id() {
|
210 |
+
echo bp_get_group_id();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
211 |
}
|
212 |
function bp_get_group_id( $group = false ) {
|
213 |
global $groups_template;
|
218 |
return apply_filters( 'bp_get_group_id', $group->id );
|
219 |
}
|
220 |
|
221 |
+
function bp_group_name() {
|
222 |
+
echo bp_get_group_name();
|
|
|
|
|
|
|
|
|
|
|
223 |
}
|
224 |
function bp_get_group_name( $group = false ) {
|
225 |
global $groups_template;
|
303 |
return bp_get_group_avatar( 'type=thumb&width=30&height=30' );
|
304 |
}
|
305 |
|
306 |
+
function bp_group_last_active() {
|
307 |
+
echo bp_get_group_last_active();
|
|
|
|
|
|
|
308 |
}
|
309 |
function bp_get_group_last_active( $group = false ) {
|
310 |
global $groups_template;
|
312 |
if ( !$group )
|
313 |
$group =& $groups_template->group;
|
314 |
|
315 |
+
$last_active = $group->last_activity;
|
316 |
+
|
317 |
+
if ( !$last_active )
|
318 |
+
$last_active = groups_get_groupmeta( $group->id, 'last_activity' );
|
319 |
|
320 |
if ( empty( $last_active ) ) {
|
321 |
return __( 'not yet active', 'buddypress' );
|
324 |
}
|
325 |
}
|
326 |
|
327 |
+
function bp_group_permalink() {
|
328 |
+
echo bp_get_group_permalink();
|
|
|
|
|
|
|
329 |
}
|
330 |
function bp_get_group_permalink( $group = false ) {
|
331 |
global $groups_template, $bp;
|
333 |
if ( !$group )
|
334 |
$group =& $groups_template->group;
|
335 |
|
336 |
+
return apply_filters( 'bp_get_group_permalink', $bp->root_domain . '/' . $bp->groups->slug . '/' . $group->slug . '/' );
|
337 |
}
|
338 |
|
339 |
+
function bp_group_admin_permalink() {
|
340 |
+
echo bp_get_group_admin_permalink();
|
|
|
|
|
|
|
341 |
}
|
342 |
function bp_get_group_admin_permalink( $group = false ) {
|
343 |
global $groups_template, $bp;
|
360 |
return apply_filters( 'bp_get_group_slug', $group->slug );
|
361 |
}
|
362 |
|
363 |
+
function bp_group_description() {
|
364 |
+
echo bp_get_group_description();
|
|
|
|
|
|
|
365 |
}
|
366 |
function bp_get_group_description( $group = false ) {
|
367 |
global $groups_template;
|
372 |
return apply_filters( 'bp_get_group_description', stripslashes($group->description) );
|
373 |
}
|
374 |
|
375 |
+
function bp_group_description_editable() {
|
376 |
echo bp_get_group_description_editable();
|
377 |
}
|
378 |
function bp_get_group_description_editable( $group = false ) {
|
384 |
return apply_filters( 'bp_get_group_description_editable', $group->description );
|
385 |
}
|
386 |
|
387 |
+
function bp_group_description_excerpt() {
|
388 |
echo bp_get_group_description_excerpt();
|
389 |
}
|
390 |
function bp_get_group_description_excerpt( $group = false ) {
|
396 |
return apply_filters( 'bp_get_group_description_excerpt', bp_create_excerpt( $group->description, 20 ) );
|
397 |
}
|
398 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
399 |
|
400 |
+
function bp_group_public_status() {
|
401 |
echo bp_get_group_public_status();
|
402 |
}
|
403 |
function bp_get_group_public_status( $group = false ) {
|
413 |
}
|
414 |
}
|
415 |
|
416 |
+
function bp_group_is_public() {
|
417 |
echo bp_get_group_is_public();
|
418 |
}
|
419 |
function bp_get_group_is_public( $group = false ) {
|
425 |
return apply_filters( 'bp_get_group_is_public', $group->is_public );
|
426 |
}
|
427 |
|
428 |
+
function bp_group_date_created() {
|
429 |
echo bp_get_group_date_created();
|
430 |
}
|
431 |
function bp_get_group_date_created( $group = false ) {
|
434 |
if ( !$group )
|
435 |
$group =& $groups_template->group;
|
436 |
|
437 |
+
return apply_filters( 'bp_get_group_date_created', bp_core_time_since( strtotime( $group->date_created ) ) );
|
438 |
}
|
439 |
|
440 |
function bp_group_is_admin() {
|
449 |
return $bp->is_item_mod;
|
450 |
}
|
451 |
|
452 |
+
function bp_group_list_admins( $group = false ) {
|
453 |
global $groups_template;
|
454 |
|
455 |
if ( !$group )
|
456 |
$group =& $groups_template->group;
|
457 |
|
458 |
+
if ( $group->admins ) { ?>
|
459 |
+
<ul id="group-admins">
|
460 |
+
<?php foreach( (array)$group->admins as $admin ) { ?>
|
|
|
|
|
|
|
|
|
461 |
<li>
|
462 |
+
<a href="<?php echo bp_core_get_user_domain( $admin->user_id, $admin->user_nicename, $admin->user_login ) ?>"><?php echo bp_core_fetch_avatar( array( 'item_id' => $admin->user_id, 'email' => $admin->user_email ) ) ?></a>
|
|
|
|
|
|
|
463 |
</li>
|
464 |
<?php } ?>
|
465 |
+
</ul>
|
|
|
|
|
|
|
|
|
|
|
466 |
<?php } else { ?>
|
467 |
<span class="activity"><?php _e( 'No Admins', 'buddypress' ) ?></span>
|
468 |
<?php } ?>
|
|
|
469 |
<?php
|
470 |
}
|
471 |
|
472 |
+
function bp_group_list_mods( $group = false ) {
|
473 |
global $groups_template;
|
474 |
|
475 |
if ( !$group )
|
476 |
$group =& $groups_template->group;
|
477 |
|
478 |
+
if ( $group->mods ) { ?>
|
479 |
+
<ul id="group-mods">
|
480 |
+
<?php foreach( (array)$group->mods as $mod ) { ?>
|
|
|
|
|
|
|
481 |
<li>
|
482 |
+
<a href="<?php echo bp_core_get_user_domain( $mod->user_id, $mod->user_nicename, $mod->user_login ) ?>"><?php echo bp_core_fetch_avatar( array( 'item_id' => $mod->user_id, 'email' => $mod->user_email ) ) ?></a>
|
|
|
|
|
|
|
483 |
</li>
|
484 |
<?php } ?>
|
485 |
+
</ul>
|
|
|
|
|
|
|
|
|
|
|
486 |
<?php } else { ?>
|
487 |
<span class="activity"><?php _e( 'No Mods', 'buddypress' ) ?></span>
|
488 |
<?php } ?>
|
|
|
489 |
<?php
|
490 |
}
|
491 |
|
492 |
+
function bp_group_all_members_permalink() {
|
493 |
+
echo bp_get_group_all_members_permalink();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
494 |
}
|
495 |
function bp_get_group_all_members_permalink( $group = false ) {
|
496 |
global $groups_template, $bp;
|
498 |
if ( !$group )
|
499 |
$group =& $groups_template->group;
|
500 |
|
501 |
+
return apply_filters( 'bp_get_group_all_members_permalink', bp_get_group_permalink( $group ) . 'members' );
|
502 |
}
|
503 |
|
504 |
function bp_group_search_form() {
|
507 |
$action = $bp->displayed_user->domain . $bp->groups->slug . '/my-groups/search/';
|
508 |
$label = __('Filter Groups', 'buddypress');
|
509 |
$name = 'group-filter-box';
|
510 |
+
|
511 |
?>
|
512 |
<form action="<?php echo $action ?>" id="group-search-form" method="post">
|
513 |
<label for="<?php echo $name ?>" id="<?php echo $name ?>-label"><?php echo $label ?></label>
|
527 |
return false;
|
528 |
}
|
529 |
|
530 |
+
function bp_group_is_activity_permalink() {
|
531 |
+
global $bp;
|
532 |
+
|
533 |
+
if ( !$bp->is_single_item || $bp->current_component != $bp->groups->slug || $bp->current_action != $bp->activity->slug )
|
534 |
+
return false;
|
535 |
+
|
536 |
+
return true;
|
537 |
+
}
|
538 |
+
|
539 |
+
function bp_groups_pagination_links() {
|
540 |
+
echo bp_get_groups_pagination_links();
|
541 |
}
|
542 |
+
function bp_get_groups_pagination_links() {
|
543 |
global $groups_template;
|
544 |
|
545 |
+
return apply_filters( 'bp_get_groups_pagination_links', $groups_template->pag_links );
|
546 |
}
|
547 |
|
548 |
+
function bp_groups_pagination_count() {
|
549 |
global $bp, $groups_template;
|
550 |
|
551 |
+
$from_num = bp_core_number_format( intval( ( $groups_template->pag_page - 1 ) * $groups_template->pag_num ) + 1 );
|
552 |
+
$to_num = bp_core_number_format( ( $from_num + ( $groups_template->pag_num - 1 ) > $groups_template->total_group_count ) ? $groups_template->total_group_count : $from_num + ( $groups_template->pag_num - 1 ) );
|
553 |
+
$total = bp_core_number_format( $groups_template->total_group_count );
|
554 |
|
555 |
+
echo sprintf( __( 'Viewing group %s to %s (of %s groups)', 'buddypress' ), $from_num, $to_num, $total ); ?>
|
556 |
<span class="ajax-loader"></span><?php
|
557 |
}
|
558 |
|
559 |
+
function bp_group_total_members() {
|
560 |
+
echo bp_get_group_total_members();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
561 |
}
|
562 |
+
function bp_get_group_total_members( $group = false ) {
|
563 |
global $groups_template;
|
564 |
|
565 |
if ( !$group )
|
568 |
return apply_filters( 'bp_get_group_total_members', $group->total_member_count );
|
569 |
}
|
570 |
|
571 |
+
function bp_group_member_count() {
|
572 |
+
echo bp_get_group_member_count();
|
|
|
|
|
|
|
|
|
|
|
|
|
573 |
}
|
574 |
+
function bp_get_group_member_count() {
|
575 |
+
global $groups_template;
|
576 |
|
577 |
+
if ( 1 == (int) $groups_template->group->total_member_count )
|
578 |
+
return apply_filters( 'bp_get_group_member_count', sprintf( __( '%s member', 'buddypress' ), bp_core_number_format( $groups_template->group->total_member_count ) ) );
|
579 |
+
else
|
580 |
+
return apply_filters( 'bp_get_group_member_count', sprintf( __( '%s members', 'buddypress' ), bp_core_number_format( $groups_template->group->total_member_count ) ) );
|
581 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
582 |
|
583 |
+
function bp_group_forum_permalink() {
|
584 |
echo bp_get_group_forum_permalink();
|
585 |
}
|
586 |
function bp_get_group_forum_permalink( $group = false ) {
|
589 |
if ( !$group )
|
590 |
$group =& $groups_template->group;
|
591 |
|
592 |
+
return apply_filters( 'bp_get_group_forum_permalink', bp_get_group_permalink( $group ) . 'forum' );
|
593 |
}
|
594 |
|
595 |
+
function bp_group_forum_topic_count( $args = '' ) {
|
596 |
+
echo bp_get_group_forum_topic_count( $args );
|
597 |
+
}
|
598 |
+
function bp_get_group_forum_topic_count( $args = '' ) {
|
599 |
+
global $groups_template;
|
600 |
|
601 |
+
$defaults = array(
|
602 |
+
'showtext' => false
|
603 |
+
);
|
604 |
|
605 |
+
$r = wp_parse_args( $args, $defaults );
|
606 |
+
extract( $r, EXTR_SKIP );
|
|
|
|
|
607 |
|
608 |
+
if ( !$forum_id = groups_get_groupmeta( $groups_template->group->id, 'forum_id' ) )
|
609 |
return false;
|
610 |
+
|
611 |
+
if ( !function_exists( 'bp_forums_get_forum_topicpost_count' ) )
|
612 |
return false;
|
613 |
+
|
614 |
+
if ( !$groups_template->group->forum_counts )
|
615 |
+
$groups_template->group->forum_counts = bp_forums_get_forum_topicpost_count( (int)$forum_id );
|
616 |
+
|
617 |
+
if ( (bool) $showtext ) {
|
618 |
+
if ( 1 == (int) $groups_template->group->forum_counts[0]->topics )
|
619 |
+
$total_topics = sprintf( __( '%d topic', 'buddypress' ), (int) $groups_template->group->forum_counts[0]->topics );
|
620 |
+
else
|
621 |
+
$total_topics = sprintf( __( '%d topics', 'buddypress' ), (int) $groups_template->group->forum_counts[0]->topics );
|
622 |
+
} else {
|
623 |
+
$total_topics = (int) $groups_template->group->forum_counts[0]->topics;
|
624 |
}
|
625 |
+
|
626 |
+
return apply_filters( 'bp_get_group_forum_topic_count', $total_topics, (bool)$showtext );
|
627 |
}
|
628 |
|
629 |
+
function bp_group_forum_post_count( $args = '' ) {
|
630 |
+
echo bp_get_group_forum_post_count( $args );
|
631 |
}
|
632 |
+
function bp_get_group_forum_post_count( $args = '' ) {
|
633 |
+
global $groups_template;
|
634 |
|
635 |
+
$defaults = array(
|
636 |
+
'showtext' => false
|
637 |
+
);
|
638 |
+
|
639 |
+
$r = wp_parse_args( $args, $defaults );
|
640 |
+
extract( $r, EXTR_SKIP );
|
641 |
+
|
642 |
+
if ( !$forum_id = groups_get_groupmeta( $groups_template->group->id, 'forum_id' ) )
|
643 |
+
return false;
|
644 |
+
|
645 |
+
if ( !function_exists( 'bp_forums_get_forum_topicpost_count' ) )
|
646 |
+
return false;
|
647 |
+
|
648 |
+
if ( !$groups_template->group->forum_counts )
|
649 |
+
$groups_template->group->forum_counts = bp_forums_get_forum_topicpost_count( (int)$forum_id );
|
650 |
+
|
651 |
+
if ( (bool) $showtext ) {
|
652 |
+
if ( 1 == (int) $groups_template->group->forum_counts[0]->posts )
|
653 |
+
$total_posts = sprintf( __( '%d post', 'buddypress' ), (int) $groups_template->group->forum_counts[0]->posts );
|
654 |
+
else
|
655 |
+
$total_posts = sprintf( __( '%d posts', 'buddypress' ), (int) $groups_template->group->forum_counts[0]->posts );
|
656 |
+
} else {
|
657 |
+
$total_posts = (int) $groups_template->group->forum_counts[0]->posts;
|
658 |
+
}
|
659 |
+
|
660 |
+
return apply_filters( 'bp_get_group_forum_post_count', $total_posts, (bool)$showtext );
|
661 |
+
}
|
662 |
+
|
663 |
+
function bp_group_is_forum_enabled( $group = false ) {
|
664 |
+
global $groups_template;
|
665 |
+
|
666 |
+
if ( !$group )
|
667 |
+
$group =& $groups_template->group;
|
668 |
+
|
669 |
+
if ( function_exists( 'bp_forums_is_installed_correctly' ) ) {
|
670 |
+
if ( bp_forums_is_installed_correctly() ) {
|
671 |
+
if ( $group->enable_forum )
|
672 |
+
return true;
|
673 |
+
|
674 |
+
return false;
|
675 |
+
} else {
|
676 |
+
return false;
|
677 |
+
}
|
678 |
+
}
|
679 |
+
|
680 |
+
return false;
|
681 |
+
}
|
682 |
+
|
683 |
+
function bp_group_show_forum_setting( $group = false ) {
|
684 |
+
global $groups_template;
|
685 |
|
686 |
if ( !$group )
|
687 |
$group =& $groups_template->group;
|
710 |
?>
|
711 |
<?php if ( $admins ) { ?>
|
712 |
<ul id="admins-list" class="item-list<?php if ( $admin_list ) { ?> single-line<?php } ?>">
|
713 |
+
<?php foreach ( (array)$admins as $admin ) { ?>
|
714 |
<?php if ( $admin_list ) { ?>
|
715 |
<li>
|
716 |
<?php echo bp_core_fetch_avatar( array( 'item_id' => $admin->user_id, 'type' => 'thumb', 'width' => 30, 'height' => 30 ) ) ?>
|
748 |
?>
|
749 |
<?php if ( $group_mods ) { ?>
|
750 |
<ul id="mods-list" class="item-list<?php if ( $admin_list ) { ?> single-line<?php } ?>">
|
751 |
+
<?php foreach ( (array)$group_mods as $mod ) { ?>
|
752 |
<?php if ( $admin_list ) { ?>
|
753 |
<li>
|
754 |
<?php echo bp_core_fetch_avatar( array( 'item_id' => $mod->user_id, 'type' => 'thumb', 'width' => 30, 'height' => 30 ) ) ?>
|
799 |
$r = wp_parse_args( $args, $defaults );
|
800 |
extract( $r, EXTR_SKIP );
|
801 |
|
802 |
+
return apply_filters( 'bp_get_group_member_promote_mod_link', wp_nonce_url( bp_get_group_permalink( $group ) . 'admin/manage-members/promote/mod/' . $user_id, 'groups_promote_member' ) );
|
803 |
}
|
804 |
|
805 |
function bp_group_member_promote_admin_link( $args = '' ) {
|
816 |
$r = wp_parse_args( $args, $defaults );
|
817 |
extract( $r, EXTR_SKIP );
|
818 |
|
819 |
+
return apply_filters( 'bp_get_group_member_promote_admin_link', wp_nonce_url( bp_get_group_permalink( $group ) . 'admin/manage-members/promote/admin/' . $user_id, 'groups_promote_member' ) );
|
820 |
}
|
821 |
|
822 |
+
function bp_group_member_demote_link( $user_id = false ) {
|
823 |
global $members_template;
|
824 |
|
825 |
if ( !$user_id )
|
836 |
if ( !$user_id )
|
837 |
$user_id = $members_template->member->user_id;
|
838 |
|
839 |
+
return apply_filters( 'bp_get_group_member_demote_link', wp_nonce_url( bp_get_group_permalink( $group ) . 'admin/manage-members/demote/' . $user_id, 'groups_demote_member' ) );
|
840 |
}
|
841 |
|
842 |
+
function bp_group_member_ban_link( $user_id = false ) {
|
843 |
global $members_template;
|
844 |
|
845 |
if ( !$user_id )
|
853 |
if ( !$group )
|
854 |
$group =& $groups_template->group;
|
855 |
|
856 |
+
return apply_filters( 'bp_get_group_member_ban_link', wp_nonce_url( bp_get_group_permalink( $group ) . 'admin/manage-members/ban/' . $user_id, 'groups_ban_member' ) );
|
857 |
}
|
858 |
|
859 |
+
function bp_group_member_unban_link( $user_id = false ) {
|
860 |
global $members_template;
|
861 |
|
862 |
if ( !$user_id )
|
873 |
if ( !$group )
|
874 |
$group =& $groups_template->group;
|
875 |
|
876 |
+
return apply_filters( 'bp_get_group_member_unban_link', wp_nonce_url( bp_get_group_permalink( $group ) . 'admin/manage-members/unban/' . $user_id, 'groups_unban_member' ) );
|
877 |
}
|
878 |
|
879 |
function bp_group_admin_tabs( $group = false ) {
|
913 |
return apply_filters( 'bp_get_group_total_for_member', BP_Groups_Member::total_group_count() );
|
914 |
}
|
915 |
|
916 |
+
function bp_group_form_action( $page ) {
|
917 |
echo bp_get_group_form_action( $page );
|
918 |
}
|
919 |
function bp_get_group_form_action( $page, $group = false ) {
|
922 |
if ( !$group )
|
923 |
$group =& $groups_template->group;
|
924 |
|
925 |
+
return apply_filters( 'bp_group_form_action', bp_get_group_permalink( $group ) . $page );
|
926 |
}
|
927 |
|
928 |
+
function bp_group_admin_form_action( $page = false ) {
|
929 |
echo bp_get_group_admin_form_action( $page );
|
930 |
}
|
931 |
function bp_get_group_admin_form_action( $page = false, $group = false ) {
|
937 |
if ( !$page )
|
938 |
$page = $bp->action_variables[0];
|
939 |
|
940 |
+
return apply_filters( 'bp_group_admin_form_action', bp_get_group_permalink( $group ) . 'admin/' . $page );
|
941 |
}
|
942 |
|
943 |
function bp_group_has_requested_membership( $group = false ) {
|
955 |
function bp_group_is_member( $group = false ) {
|
956 |
global $bp, $groups_template;
|
957 |
|
958 |
+
if ( is_site_admin() )
|
959 |
+
return true;
|
960 |
+
|
961 |
if ( !$group )
|
962 |
$group =& $groups_template->group;
|
963 |
|
964 |
+
if ( null == $group->is_member )
|
965 |
+
return false;
|
966 |
|
967 |
+
return true;
|
968 |
}
|
969 |
|
970 |
+
function bp_group_accept_invite_link() {
|
971 |
echo bp_get_group_accept_invite_link();
|
972 |
}
|
973 |
function bp_get_group_accept_invite_link( $group = false ) {
|
979 |
return apply_filters( 'bp_get_group_accept_invite_link', wp_nonce_url( $bp->loggedin_user->domain . $bp->groups->slug . '/invites/accept/' . $group->id, 'groups_accept_invite' ) );
|
980 |
}
|
981 |
|
982 |
+
function bp_group_reject_invite_link() {
|
983 |
echo bp_get_group_reject_invite_link();
|
984 |
}
|
985 |
function bp_get_group_reject_invite_link( $group = false ) {
|
991 |
return apply_filters( 'bp_get_group_reject_invite_link', wp_nonce_url( $bp->loggedin_user->domain . $bp->groups->slug . '/invites/reject/' . $group->id, 'groups_reject_invite' ) );
|
992 |
}
|
993 |
|
994 |
+
function bp_group_leave_confirm_link() {
|
995 |
echo bp_get_group_leave_confirm_link();
|
996 |
}
|
997 |
function bp_get_group_leave_confirm_link( $group = false ) {
|
1000 |
if ( !$group )
|
1001 |
$group =& $groups_template->group;
|
1002 |
|
1003 |
+
return apply_filters( 'bp_group_leave_confirm_link', wp_nonce_url( bp_get_group_permalink( $group ) . 'leave-group/yes', 'groups_leave_group' ) );
|
1004 |
}
|
1005 |
|
1006 |
+
function bp_group_leave_reject_link() {
|
1007 |
echo bp_get_group_leave_reject_link();
|
1008 |
}
|
1009 |
function bp_get_group_leave_reject_link( $group = false ) {
|
1015 |
return apply_filters( 'bp_get_group_leave_reject_link', bp_get_group_permalink( $group ) );
|
1016 |
}
|
1017 |
|
1018 |
+
function bp_group_send_invite_form_action() {
|
1019 |
echo bp_get_group_send_invite_form_action();
|
1020 |
}
|
1021 |
function bp_get_group_send_invite_form_action( $group = false ) {
|
1024 |
if ( !$group )
|
1025 |
$group =& $groups_template->group;
|
1026 |
|
1027 |
+
return apply_filters( 'bp_group_send_invite_form_action', bp_get_group_permalink( $group ) . 'send-invites/send' );
|
1028 |
}
|
1029 |
|
1030 |
function bp_has_friends_to_invite( $group = false ) {
|
1049 |
$group =& $groups_template->group;
|
1050 |
|
1051 |
// If they're not logged in or are banned from the group, no join button.
|
1052 |
+
if ( !is_user_logged_in() || $group->is_banned )
|
1053 |
return false;
|
1054 |
|
1055 |
if ( !$group->status )
|
1056 |
return false;
|
1057 |
|
1058 |
+
if ( 'hidden' == $group->status && !$group->is_member )
|
1059 |
+
return false;
|
1060 |
+
|
1061 |
echo '<div class="generic-button group-button ' . $group->status . '" id="groupbutton-' . $group->id . '">';
|
1062 |
|
1063 |
switch ( $group->status ) {
|
1064 |
case 'public':
|
1065 |
+
if ( $group->is_member )
|
1066 |
+
echo '<a class="leave-group" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . 'leave-group', 'groups_leave_group' ) . '">' . __( 'Leave Group', 'buddypress' ) . '</a>';
|
1067 |
else
|
1068 |
+
echo '<a class="join-group" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . 'join', 'groups_join_group' ) . '">' . __( 'Join Group', 'buddypress' ) . '</a>';
|
1069 |
break;
|
1070 |
|
1071 |
case 'private':
|
1072 |
+
if ( $group->is_member ) {
|
1073 |
+
echo '<a class="leave-group" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . 'leave-group', 'groups_leave_group' ) . '">' . __( 'Leave Group', 'buddypress' ) . '</a>';
|
1074 |
} else {
|
1075 |
if ( !bp_group_has_requested_membership( $group ) )
|
1076 |
+
echo '<a class="request-membership" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . 'request-membership', 'groups_request_membership' ) . '">' . __('Request Membership', 'buddypress') . '</a>';
|
1077 |
else
|
1078 |
echo '<a class="membership-requested" href="' . bp_get_group_permalink( $group ) . '">' . __( 'Request Sent', 'buddypress' ) . '</a>';
|
1079 |
}
|
1080 |
break;
|
1081 |
+
|
1082 |
+
case 'hidden':
|
1083 |
+
if ( $group->is_member )
|
1084 |
+
echo '<a class="leave-group" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . 'leave-group', 'groups_leave_group' ) . '">' . __( 'Leave Group', 'buddypress' ) . '</a>';
|
1085 |
+
break;
|
1086 |
}
|
1087 |
|
1088 |
echo '</div>';
|
1107 |
}
|
1108 |
}
|
1109 |
|
1110 |
+
function bp_group_hidden_fields() {
|
1111 |
+
if ( isset( $_REQUEST['s'] ) ) {
|
1112 |
+
echo '<input type="hidden" id="search_terms" value="' . attribute_escape( $_REQUEST['s'] ) . '" name="search_terms" />';
|
1113 |
+
}
|
1114 |
+
|
1115 |
+
if ( isset( $_REQUEST['letter'] ) ) {
|
1116 |
+
echo '<input type="hidden" id="selected_letter" value="' . attribute_escape( $_REQUEST['letter'] ) . '" name="selected_letter" />';
|
1117 |
+
}
|
1118 |
+
|
1119 |
+
if ( isset( $_REQUEST['groups_search'] ) ) {
|
1120 |
+
echo '<input type="hidden" id="search_terms" value="' . attribute_escape( $_REQUEST['groups_search'] ) . '" name="search_terms" />';
|
1121 |
+
}
|
1122 |
+
}
|
1123 |
+
|
1124 |
+
function bp_total_group_count() {
|
1125 |
+
echo bp_get_total_group_count();
|
1126 |
+
}
|
1127 |
+
function bp_get_total_group_count() {
|
1128 |
+
return apply_filters( 'bp_get_total_group_count', groups_get_total_group_count() );
|
1129 |
+
}
|
1130 |
+
|
1131 |
+
function bp_total_group_count_for_user( $user_id = false ) {
|
1132 |
+
echo bp_get_total_group_count_for_user( $user_id );
|
1133 |
+
}
|
1134 |
+
function bp_get_total_group_count_for_user( $user_id = false ) {
|
1135 |
+
return apply_filters( 'bp_get_total_group_count_for_user', groups_total_groups_for_user( $user_id ) );
|
1136 |
+
}
|
1137 |
+
|
1138 |
|
1139 |
/***************************************************************************
|
1140 |
* Group Members Template Tags
|
1182 |
'format' => '',
|
1183 |
'total' => ceil( $this->total_member_count / $this->pag_num ),
|
1184 |
'current' => $this->pag_page,
|
1185 |
+
'prev_text' => '←',
|
1186 |
+
'next_text' => '→',
|
1187 |
'mid_size' => 1
|
1188 |
));
|
1189 |
}
|
1238 |
|
1239 |
$defaults = array(
|
1240 |
'group_id' => $bp->groups->current_group->id,
|
1241 |
+
'per_page' => 20,
|
1242 |
'max' => false,
|
1243 |
'exclude_admins_mods' => 1,
|
1244 |
'exclude_banned' => 1
|
1269 |
function bp_get_group_member_avatar() {
|
1270 |
global $members_template;
|
1271 |
|
1272 |
+
return apply_filters( 'bp_get_group_member_avatar', bp_core_fetch_avatar( array( 'item_id' => $members_template->member->user_id, 'type' => 'full', 'email' => $members_template->member->user_email ) ) );
|
1273 |
}
|
1274 |
|
1275 |
function bp_group_member_avatar_thumb() {
|
1278 |
function bp_get_group_member_avatar_thumb() {
|
1279 |
global $members_template;
|
1280 |
|
1281 |
+
return apply_filters( 'bp_get_group_member_avatar_thumb', bp_core_fetch_avatar( array( 'item_id' => $members_template->member->user_id, 'type' => 'thumb', 'email' => $members_template->member->user_email ) ) );
|
1282 |
}
|
1283 |
|
1284 |
function bp_group_member_avatar_mini( $width = 30, $height = 30 ) {
|
1287 |
function bp_get_group_member_avatar_mini( $width = 30, $height = 30 ) {
|
1288 |
global $members_template;
|
1289 |
|
1290 |
+
return apply_filters( 'bp_get_group_member_avatar_mini', bp_core_fetch_avatar( array( 'item_id' => $members_template->member->user_id, 'type' => 'thumb', 'width' => $width, 'height' => $height, 'email' => $members_template->member->user_email ) ) );
|
1291 |
}
|
1292 |
|
1293 |
function bp_group_member_name() {
|
1296 |
function bp_get_group_member_name() {
|
1297 |
global $members_template;
|
1298 |
|
1299 |
+
return apply_filters( 'bp_get_group_member_name', $members_template->member->display_name );
|
1300 |
}
|
1301 |
|
1302 |
function bp_group_member_url() {
|
1305 |
function bp_get_group_member_url() {
|
1306 |
global $members_template;
|
1307 |
|
1308 |
+
return apply_filters( 'bp_get_group_member_url', bp_core_get_user_domain( $members_template->member->user_id, $members_template->member->user_nicename, $members_template->member->user_login ) );
|
1309 |
}
|
1310 |
|
1311 |
function bp_group_member_link() {
|
1314 |
function bp_get_group_member_link() {
|
1315 |
global $members_template;
|
1316 |
|
1317 |
+
return apply_filters( 'bp_get_group_member_link', '<a href="' . bp_core_get_user_domain( $members_template->member->user_id, $members_template->member->user_nicename, $members_template->member->user_login ) . '">' . $members_template->member->display_name . '</a>' );
|
1318 |
+
}
|
1319 |
+
|
1320 |
+
function bp_group_member_domain() {
|
1321 |
+
echo bp_get_group_member_domain();
|
1322 |
+
}
|
1323 |
+
function bp_get_group_member_domain() {
|
1324 |
+
global $members_template;
|
1325 |
+
|
1326 |
+
return apply_filters( 'bp_get_group_member_domain', bp_core_get_user_domain( $members_template->member->user_id, $members_template->member->user_nicename, $members_template->member->user_login ) );
|
1327 |
+
}
|
1328 |
+
|
1329 |
+
function bp_group_member_is_friend() {
|
1330 |
+
echo bp_get_group_member_is_friend();
|
1331 |
+
}
|
1332 |
+
function bp_get_group_member_is_friend() {
|
1333 |
+
global $members_template;
|
1334 |
+
|
1335 |
+
if ( null === $members_template->member->is_friend )
|
1336 |
+
$friend_status = 'not_friends';
|
1337 |
+
else
|
1338 |
+
$friend_status = ( 0 == $members_template->member->is_friend ) ? 'pending' : 'is_friend';
|
1339 |
+
|
1340 |
+
return apply_filters( 'bp_get_group_member_is_friend', $friend_status );
|
1341 |
}
|
1342 |
|
1343 |
function bp_group_member_is_banned() {
|
1346 |
function bp_get_group_member_is_banned() {
|
1347 |
global $members_template, $groups_template;
|
1348 |
|
1349 |
+
return apply_filters( 'bp_get_group_member_is_banned', $members_template->member->is_banned );
|
1350 |
}
|
1351 |
|
1352 |
function bp_group_member_joined_since() {
|
1355 |
function bp_get_group_member_joined_since() {
|
1356 |
global $members_template;
|
1357 |
|
1358 |
+
return apply_filters( 'bp_get_group_member_joined_since', bp_core_get_last_activity( $members_template->member->date_modified, __( 'joined %s ago', 'buddypress') ) );
|
1359 |
}
|
1360 |
|
1361 |
function bp_group_member_id() {
|
1400 |
function bp_get_group_member_pagination_count() {
|
1401 |
global $members_template;
|
1402 |
|
1403 |
+
$from_num = bp_core_number_format( intval( ( $members_template->pag_page - 1 ) * $members_template->pag_num ) + 1 );
|
1404 |
+
$to_num = bp_core_number_format( ( $from_num + ( $members_template->pag_num - 1 ) > $members_template->total_member_count ) ? $members_template->total_member_count : $from_num + ( $members_template->pag_num - 1 ) );
|
1405 |
+
$total = bp_core_number_format( $members_template->total_member_count );
|
1406 |
|
1407 |
+
return apply_filters( 'bp_get_group_member_pagination_count', sprintf( __( 'Viewing members %s to %s (of %s members)', 'buddypress' ), $from_num, $to_num, $total ) );
|
1408 |
}
|
1409 |
|
1410 |
function bp_group_member_admin_pagination() {
|
1432 |
$bp->groups->current_create_step = array_shift( array_keys( $bp->groups->group_creation_steps ) );
|
1433 |
|
1434 |
$counter = 1;
|
1435 |
+
|
1436 |
+
foreach ( (array)$bp->groups->group_creation_steps as $slug => $step ) {
|
1437 |
$is_enabled = bp_are_previous_group_creation_steps_complete( $slug ); ?>
|
1438 |
|
1439 |
+
<li<?php if ( $bp->groups->current_create_step == $slug ) : ?> class="current"<?php endif; ?>><?php if ( $is_enabled ) : ?><a href="<?php echo $bp->root_domain . '/' . $bp->groups->slug ?>/create/step/<?php echo $slug ?>/"><?php else: ?><span><?php endif; ?><?php echo $counter ?>. <?php echo $step['name'] ?><?php if ( $is_enabled ) : ?></a><?php else: ?></span><?php endif ?></li><?php
|
1440 |
$counter++;
|
1441 |
}
|
1442 |
|
1460 |
if ( empty( $bp->action_variables[1] ) )
|
1461 |
$bp->action_variables[1] = array_shift( array_keys( $bp->groups->group_creation_steps ) );
|
1462 |
|
1463 |
+
return apply_filters( 'bp_get_group_creation_form_action', $bp->root_domain . '/' . $bp->groups->slug . '/create/step/' . $bp->action_variables[1] );
|
1464 |
}
|
1465 |
|
1466 |
function bp_is_group_creation_step( $step_slug ) {
|
1496 |
if ( is_array( $step_slugs ) ) {
|
1497 |
$found = true;
|
1498 |
|
1499 |
+
foreach ( (array)$step_slugs as $step_slug ) {
|
1500 |
if ( !in_array( $step_slug, $bp->groups->completed_create_steps ) )
|
1501 |
$found = false;
|
1502 |
}
|
1520 |
unset( $previous_steps );
|
1521 |
|
1522 |
/* Get previous steps */
|
1523 |
+
foreach ( (array)$bp->groups->group_creation_steps as $slug => $name ) {
|
1524 |
if ( $slug == $step_slug )
|
1525 |
break;
|
1526 |
|
1554 |
return apply_filters( 'bp_get_new_group_description', $bp->groups->current_group->description );
|
1555 |
}
|
1556 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1557 |
function bp_new_group_enable_forum() {
|
1558 |
echo bp_get_new_group_enable_forum();
|
1559 |
}
|
1582 |
'height' => false,
|
1583 |
'class' => 'avatar',
|
1584 |
'id' => 'avatar-crop-preview',
|
1585 |
+
'alt' => __( 'Group avatar', 'buddypress' ),
|
1586 |
+
'no_grav' => false
|
1587 |
);
|
1588 |
|
1589 |
$r = wp_parse_args( $args, $defaults );
|
1590 |
extract( $r, EXTR_SKIP );
|
1591 |
|
1592 |
+
return apply_filters( 'bp_get_new_group_avatar', bp_core_fetch_avatar( array( 'item_id' => $bp->groups->current_group->id, 'object' => 'group', 'type' => $type, 'avatar_dir' => 'group-avatars', 'alt' => $alt, 'width' => $width, 'height' => $height, 'class' => $class, 'no_grav' => $no_grav ) ) );
|
1593 |
}
|
1594 |
|
1595 |
function bp_group_creation_previous_link() {
|
1598 |
function bp_get_group_creation_previous_link() {
|
1599 |
global $bp;
|
1600 |
|
1601 |
+
foreach ( (array)$bp->groups->group_creation_steps as $slug => $name ) {
|
1602 |
if ( $slug == $bp->action_variables[1] )
|
1603 |
break;
|
1604 |
|
1671 |
return implode( "\n", (array)$items );
|
1672 |
}
|
1673 |
|
1674 |
+
function bp_directory_groups_search_form() {
|
1675 |
+
global $bp;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1676 |
|
1677 |
+
$search_value = __( 'Search anything...', 'buddypress' );
|
1678 |
+
if ( !empty( $_REQUEST['s'] ) )
|
1679 |
+
$search_value = $_REQUEST['s'];
|
1680 |
|
1681 |
+
?>
|
1682 |
+
<form action="" method="get" id="search-groups-form">
|
1683 |
+
<label><input type="text" name="s" id="groups_search" value="<?php echo attribute_escape($search_value) ?>" onfocus="if (this.value == '<?php _e( 'Search anything...', 'buddypress' ) ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php _e( 'Search anything...', 'buddypress' ) ?>';}" /></label>
|
1684 |
+
<input type="submit" id="groups_search_submit" name="groups_search_submit" value="<?php _e( 'Search', 'buddypress' ) ?>" />
|
1685 |
+
</form>
|
1686 |
+
<?php
|
1687 |
}
|
|
|
|
|
1688 |
|
1689 |
+
function bp_groups_header_tabs() {
|
1690 |
+
global $bp, $create_group_step, $completed_to_step;
|
1691 |
+
?>
|
1692 |
+
<li<?php if ( !isset($bp->action_variables[0]) || 'recently-active' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>/my-groups/recently-active"><?php _e( 'Recently Active', 'buddypress' ) ?></a></li>
|
1693 |
+
<li<?php if ( 'recently-joined' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>/my-groups/recently-joined"><?php _e( 'Recently Joined', 'buddypress' ) ?></a></li>
|
1694 |
+
<li<?php if ( 'most-popular' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>/my-groups/most-popular""><?php _e( 'Most Popular', 'buddypress' ) ?></a></li>
|
1695 |
+
<li<?php if ( 'admin-of' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>/my-groups/admin-of""><?php _e( 'Administrator Of', 'buddypress' ) ?></a></li>
|
1696 |
+
<li<?php if ( 'mod-of' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>/my-groups/mod-of""><?php _e( 'Moderator Of', 'buddypress' ) ?></a></li>
|
1697 |
+
<li<?php if ( 'alphabetically' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>/my-groups/alphabetically""><?php _e( 'Alphabetically', 'buddypress' ) ?></a></li>
|
1698 |
+
<?php
|
1699 |
+
do_action( 'groups_header_tabs' );
|
1700 |
}
|
|
|
|
|
1701 |
|
1702 |
+
function bp_groups_filter_title() {
|
1703 |
+
global $bp;
|
1704 |
|
1705 |
+
$current_filter = $bp->action_variables[0];
|
|
|
|
|
|
|
|
|
1706 |
|
1707 |
+
switch ( $current_filter ) {
|
1708 |
+
case 'recently-active': default:
|
1709 |
+
_e( 'Recently Active', 'buddypress' );
|
1710 |
+
break;
|
1711 |
+
case 'recently-joined':
|
1712 |
+
_e( 'Recently Joined', 'buddypress' );
|
1713 |
+
break;
|
1714 |
+
case 'most-popular':
|
1715 |
+
_e( 'Most Popular', 'buddypress' );
|
1716 |
+
break;
|
1717 |
+
case 'admin-of':
|
1718 |
+
_e( 'Administrator Of', 'buddypress' );
|
1719 |
+
break;
|
1720 |
+
case 'mod-of':
|
1721 |
+
_e( 'Moderator Of', 'buddypress' );
|
1722 |
+
break;
|
1723 |
+
case 'alphabetically':
|
1724 |
+
_e( 'Alphabetically', 'buddypress' );
|
1725 |
+
break;
|
1726 |
}
|
1727 |
+
do_action( 'bp_groups_filter_title' );
|
|
|
|
|
1728 |
}
|
|
|
|
|
1729 |
|
1730 |
+
function bp_is_group_admin_screen( $slug ) {
|
1731 |
+
global $bp;
|
|
|
|
|
|
|
|
|
|
|
|
|
1732 |
|
1733 |
+
if ( $bp->current_component != BP_GROUPS_SLUG || 'admin' != $bp->current_action )
|
1734 |
+
return false;
|
1735 |
|
1736 |
+
if ( $bp->action_variables[0] == $slug )
|
1737 |
+
return true;
|
1738 |
|
1739 |
+
return false;
|
|
|
1740 |
}
|
|
|
|
|
1741 |
|
1742 |
+
/************************************************************************************
|
1743 |
+
* Group Avatar Template Tags
|
1744 |
+
**/
|
1745 |
|
1746 |
+
function bp_group_current_avatar() {
|
1747 |
+
global $bp;
|
1748 |
|
1749 |
+
if ( $bp->groups->current_group->avatar_full ) { ?>
|
1750 |
+
<img src="<?php echo attribute_escape( $bp->groups->current_group->avatar_full ) ?>" alt="<?php _e( 'Group Avatar', 'buddypress' ) ?>" class="avatar" />
|
1751 |
+
<?php } else { ?>
|
1752 |
+
<img src="<?php echo $bp->groups->image_base . '/none.gif' ?>" alt="<?php _e( 'No Group Avatar', 'buddypress' ) ?>" class="avatar" />
|
1753 |
+
<?php }
|
1754 |
}
|
1755 |
|
1756 |
+
function bp_get_group_has_avatar() {
|
1757 |
+
global $bp;
|
|
|
|
|
|
|
1758 |
|
1759 |
+
if ( !empty( $_FILES ) || !bp_core_fetch_avatar( array( 'item_id' => $bp->groups->current_group->id, 'object' => 'group', 'no_grav' => true ) ) )
|
1760 |
+
return false;
|
1761 |
|
1762 |
+
return true;
|
|
|
1763 |
}
|
|
|
|
|
|
|
|
|
|
|
1764 |
|
1765 |
+
function bp_group_avatar_delete_link() {
|
1766 |
+
echo bp_get_group_avatar_delete_link();
|
1767 |
}
|
1768 |
+
function bp_get_group_avatar_delete_link() {
|
1769 |
+
global $bp;
|
1770 |
|
1771 |
+
return apply_filters( 'bp_get_group_avatar_delete_link', wp_nonce_url( bp_get_group_permalink( $bp->groups->current_group ) . '/admin/group-avatar/delete', 'bp_group_avatar_delete' ) );
|
1772 |
}
|
1773 |
|
1774 |
+
function bp_group_avatar_edit_form() {
|
1775 |
+
groups_avatar_upload();
|
1776 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1777 |
|
1778 |
+
function bp_custom_group_boxes() {
|
1779 |
+
do_action( 'groups_custom_group_boxes' );
|
1780 |
}
|
|
|
|
|
|
|
|
|
|
|
1781 |
|
1782 |
+
function bp_custom_group_admin_tabs() {
|
1783 |
+
do_action( 'groups_custom_group_admin_tabs' );
|
1784 |
}
|
|
|
|
|
1785 |
|
1786 |
+
function bp_custom_group_fields_editable() {
|
1787 |
+
do_action( 'groups_custom_group_fields_editable' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1788 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1789 |
|
1790 |
+
function bp_custom_group_fields() {
|
1791 |
+
do_action( 'groups_custom_group_fields' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1792 |
}
|
1793 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1794 |
|
1795 |
/************************************************************************************
|
1796 |
* Membership Requests Template Tags
|
1838 |
'format' => '',
|
1839 |
'total' => ceil( $this->total_request_count / $this->pag_num ),
|
1840 |
'current' => $this->pag_page,
|
1841 |
+
'prev_text' => '←',
|
1842 |
+
'next_text' => '→',
|
1843 |
'mid_size' => 1
|
1844 |
));
|
1845 |
}
|
2108 |
return wp_nonce_url( site_url( BP_GROUPS_SLUG . '/' . $invites_template->invite->group_id . '/invites/remove/' . $invites_template->invite->user->id ), 'groups_invite_uninvite_user' );
|
2109 |
}
|
2110 |
|
2111 |
+
/***
|
2112 |
+
* Groups RSS Feed Template Tags
|
2113 |
+
*/
|
2114 |
+
|
2115 |
+
function bp_group_activity_feed_link() {
|
2116 |
+
echo bp_get_group_activity_feed_link();
|
2117 |
+
}
|
2118 |
+
function bp_get_group_activity_feed_link() {
|
2119 |
+
global $bp;
|
2120 |
+
|
2121 |
+
return apply_filters( 'bp_get_group_activity_feed_link', bp_get_group_permalink( $bp->groups->current_group ) . 'feed/' );
|
2122 |
+
}
|
2123 |
+
|
2124 |
+
function bp_current_group_name() {
|
2125 |
+
echo bp_get_current_group_name();
|
2126 |
+
}
|
2127 |
+
function bp_get_current_group_name() {
|
2128 |
+
global $bp;
|
2129 |
+
|
2130 |
+
$name = apply_filters( 'bp_get_group_name', $bp->groups->current_group->name );
|
2131 |
+
return apply_filters( 'bp_get_current_group_name', $name );
|
2132 |
+
}
|
2133 |
?>
|
bp-groups/bp-groups-widgets.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
function groups_register_widgets() {
|
5 |
add_action('widgets_init', create_function('', 'return register_widget("BP_Groups_Widget");') );
|
6 |
}
|
7 |
-
add_action( '
|
8 |
|
9 |
/*** GROUPS WIDGET *****************/
|
10 |
|
@@ -13,7 +13,7 @@ class BP_Groups_Widget extends WP_Widget {
|
|
13 |
parent::WP_Widget( false, $name = __( 'Groups', 'buddypress' ) );
|
14 |
|
15 |
if ( is_active_widget( false, false, $this->id_base ) )
|
16 |
-
wp_enqueue_script( 'groups_widget_groups_list-js', BP_PLUGIN_URL . '/bp-groups/js/widget-groups.js', array('jquery'
|
17 |
}
|
18 |
|
19 |
function widget($args, $instance) {
|
@@ -26,7 +26,7 @@ class BP_Groups_Widget extends WP_Widget {
|
|
26 |
. $widget_name
|
27 |
. $after_title; ?>
|
28 |
|
29 |
-
<?php if (
|
30 |
<div class="item-options" id="groups-list-options">
|
31 |
<span class="ajax-loader" id="ajax-loader-groups"></span>
|
32 |
<a href="<?php echo site_url() . '/' . $bp->groups->slug ?>" id="newest-groups"><?php _e("Newest", 'buddypress') ?></a> |
|
@@ -35,15 +35,15 @@ class BP_Groups_Widget extends WP_Widget {
|
|
35 |
</div>
|
36 |
|
37 |
<ul id="groups-list" class="item-list">
|
38 |
-
<?php while (
|
39 |
<li>
|
40 |
<div class="item-avatar">
|
41 |
-
<a href="<?php
|
42 |
</div>
|
43 |
|
44 |
<div class="item">
|
45 |
-
<div class="item-title"><a href="<?php
|
46 |
-
<div class="item-meta"><span class="activity"><?php
|
47 |
</div>
|
48 |
</li>
|
49 |
|
@@ -98,27 +98,27 @@ function groups_ajax_widget_groups_list() {
|
|
98 |
break;
|
99 |
}
|
100 |
|
101 |
-
if (
|
102 |
<?php echo "0[[SPLIT]]"; ?>
|
103 |
|
104 |
<ul id="groups-list" class="item-list">
|
105 |
-
<?php while (
|
106 |
<li>
|
107 |
<div class="item-avatar">
|
108 |
-
<a href="<?php
|
109 |
</div>
|
110 |
|
111 |
<div class="item">
|
112 |
-
<div class="item-title"><a href="<?php
|
113 |
<div class="item-meta">
|
114 |
<span class="activity">
|
115 |
<?php
|
116 |
if ( 'newest-groups' == $_POST['filter'] ) {
|
117 |
-
|
118 |
} else if ( 'recently-active-groups' == $_POST['filter'] ) {
|
119 |
-
|
120 |
} else if ( 'popular-groups' == $_POST['filter'] ) {
|
121 |
-
|
122 |
}
|
123 |
?>
|
124 |
</span>
|
4 |
function groups_register_widgets() {
|
5 |
add_action('widgets_init', create_function('', 'return register_widget("BP_Groups_Widget");') );
|
6 |
}
|
7 |
+
add_action( 'bp_register_widgets', 'groups_register_widgets' );
|
8 |
|
9 |
/*** GROUPS WIDGET *****************/
|
10 |
|
13 |
parent::WP_Widget( false, $name = __( 'Groups', 'buddypress' ) );
|
14 |
|
15 |
if ( is_active_widget( false, false, $this->id_base ) )
|
16 |
+
wp_enqueue_script( 'groups_widget_groups_list-js', BP_PLUGIN_URL . '/bp-groups/js/widget-groups.js', array('jquery') );
|
17 |
}
|
18 |
|
19 |
function widget($args, $instance) {
|
26 |
. $widget_name
|
27 |
. $after_title; ?>
|
28 |
|
29 |
+
<?php if ( bp_has_groups( 'type=popular&per_page=' . $instance['max_groups'] . '&max=' . $instance['max_groups'] ) ) : ?>
|
30 |
<div class="item-options" id="groups-list-options">
|
31 |
<span class="ajax-loader" id="ajax-loader-groups"></span>
|
32 |
<a href="<?php echo site_url() . '/' . $bp->groups->slug ?>" id="newest-groups"><?php _e("Newest", 'buddypress') ?></a> |
|
35 |
</div>
|
36 |
|
37 |
<ul id="groups-list" class="item-list">
|
38 |
+
<?php while ( bp_groups() ) : bp_the_group(); ?>
|
39 |
<li>
|
40 |
<div class="item-avatar">
|
41 |
+
<a href="<?php bp_group_permalink() ?>"><?php bp_group_avatar_thumb() ?></a>
|
42 |
</div>
|
43 |
|
44 |
<div class="item">
|
45 |
+
<div class="item-title"><a href="<?php bp_group_permalink() ?>" title="<?php bp_group_name() ?>"><?php bp_group_name() ?></a></div>
|
46 |
+
<div class="item-meta"><span class="activity"><?php bp_group_member_count() ?></span></div>
|
47 |
</div>
|
48 |
</li>
|
49 |
|
98 |
break;
|
99 |
}
|
100 |
|
101 |
+
if ( bp_has_groups( 'type=' . $type . '&per_page=' . $_POST['max_groups'] . '&max=' . $_POST['max_groups'] ) ) : ?>
|
102 |
<?php echo "0[[SPLIT]]"; ?>
|
103 |
|
104 |
<ul id="groups-list" class="item-list">
|
105 |
+
<?php while ( bp_groups() ) : bp_the_group(); ?>
|
106 |
<li>
|
107 |
<div class="item-avatar">
|
108 |
+
<a href="<?php bp_group_permalink() ?>"><?php bp_group_avatar_thumb() ?></a>
|
109 |
</div>
|
110 |
|
111 |
<div class="item">
|
112 |
+
<div class="item-title"><a href="<?php bp_group_permalink() ?>" title="<?php bp_group_name() ?>"><?php bp_group_name() ?></a></div>
|
113 |
<div class="item-meta">
|
114 |
<span class="activity">
|
115 |
<?php
|
116 |
if ( 'newest-groups' == $_POST['filter'] ) {
|
117 |
+
printf( __( 'created %s ago', 'buddypress' ), bp_get_group_date_created() );
|
118 |
} else if ( 'recently-active-groups' == $_POST['filter'] ) {
|
119 |
+
printf( __( 'active %s ago', 'buddypress' ), bp_get_group_last_active() );
|
120 |
} else if ( 'popular-groups' == $_POST['filter'] ) {
|
121 |
+
bp_group_member_count();
|
122 |
}
|
123 |
?>
|
124 |
</span>
|
bp-groups/deprecated/bp-groups-deprecated.php
DELETED
@@ -1,842 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/***
|
3 |
-
* Deprecated Groups Functionality
|
4 |
-
*
|
5 |
-
* This file contains functions that are deprecated.
|
6 |
-
* You should not under any circumstance use these functions as they are
|
7 |
-
* either no longer valid, or have been replaced with something much more awesome.
|
8 |
-
*
|
9 |
-
* If you are using functions in this file you should slap the back of your head
|
10 |
-
* and then use the functions or solutions that have replaced them.
|
11 |
-
* Most functions contain a note telling you what you should be doing or using instead.
|
12 |
-
*
|
13 |
-
* Of course, things will still work if you use these functions but you will
|
14 |
-
* be the laughing stock of the BuddyPress community. We will all point and laugh at
|
15 |
-
* you. You'll also be making things harder for yourself in the long run,
|
16 |
-
* and you will miss out on lovely performance and functionality improvements.
|
17 |
-
*
|
18 |
-
* If you've checked you are not using any deprecated functions and finished your little
|
19 |
-
* dance, you can add the following line to your wp-config.php file to prevent any of
|
20 |
-
* these old functions from being loaded:
|
21 |
-
*
|
22 |
-
* define( 'BP_IGNORE_DEPRECATED', true );
|
23 |
-
*/
|
24 |
-
|
25 |
-
function groups_deprecated_globals() {
|
26 |
-
global $bp;
|
27 |
-
|
28 |
-
/* If we are using a BuddyPress 1.1+ theme ignore this. */
|
29 |
-
if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
|
30 |
-
return false;
|
31 |
-
|
32 |
-
$bp->groups->image_base = BP_PLUGIN_URL . '/bp-groups/deprecated/images';
|
33 |
-
}
|
34 |
-
add_action( 'plugins_loaded', 'groups_deprecated_globals', 5 );
|
35 |
-
add_action( 'admin_menu', 'groups_deprecated_globals', 2 );
|
36 |
-
|
37 |
-
function groups_avatar_upload( $deprecated = true ) { ?>
|
38 |
-
|
39 |
-
<?php if ( !bp_get_avatar_admin_step() ) : ?>
|
40 |
-
|
41 |
-
<p>
|
42 |
-
<input type="file" name="file" id="file" />
|
43 |
-
<input type="submit" name="upload" id="upload" value="<?php _e( 'Upload Image', 'buddypress' ) ?>" />
|
44 |
-
<input type="hidden" name="action" id="action" value="bp_avatar_upload" />
|
45 |
-
</p>
|
46 |
-
|
47 |
-
<?php endif; ?>
|
48 |
-
|
49 |
-
<?php if ( 'crop-image' == bp_get_avatar_admin_step() ) : ?>
|
50 |
-
|
51 |
-
<h3><?php _e( 'Crop Group Avatar', 'buddypress' ) ?></h3>
|
52 |
-
|
53 |
-
<img src="<?php bp_avatar_to_crop() ?>" id="avatar-to-crop" class="avatar" alt="<?php _e( 'Avatar to crop', 'buddypress' ) ?>" />
|
54 |
-
|
55 |
-
<input type="submit" name="avatar-crop-submit" id="avatar-crop-submit" value="<?php _e( 'Crop Image', 'buddypress' ) ?>" />
|
56 |
-
|
57 |
-
<input type="hidden" name="image_src" id="image_src" value="<?php bp_avatar_to_crop_src() ?>" />
|
58 |
-
<input type="hidden" name="upload" id="upload" />
|
59 |
-
<input type="hidden" id="x" name="x" />
|
60 |
-
<input type="hidden" id="y" name="y" />
|
61 |
-
<input type="hidden" id="w" name="w" />
|
62 |
-
<input type="hidden" id="h" name="h" />
|
63 |
-
|
64 |
-
<?php endif; ?>
|
65 |
-
<?php
|
66 |
-
}
|
67 |
-
|
68 |
-
function groups_get_avatar_hrefs( $avatars ) {
|
69 |
-
global $bp;
|
70 |
-
|
71 |
-
$src = $bp->root_domain . '/';
|
72 |
-
|
73 |
-
$thumb_href = str_replace( ABSPATH, $src, stripslashes( $avatars['v1_out'] ) );
|
74 |
-
$full_href = str_replace( ABSPATH, $src, stripslashes ( $avatars['v2_out'] ) );
|
75 |
-
|
76 |
-
return array( 'thumb_href' => $thumb_href, 'full_href' => $full_href );
|
77 |
-
}
|
78 |
-
|
79 |
-
function groups_get_avatar_path( $avatar ) {
|
80 |
-
global $bp;
|
81 |
-
|
82 |
-
$src = $bp->root_domain . '/';
|
83 |
-
|
84 |
-
$path = str_replace( $src, ABSPATH, stripslashes( $avatar ) );
|
85 |
-
return $path;
|
86 |
-
}
|
87 |
-
|
88 |
-
function bp_new_group_avatar_upload_form() {
|
89 |
-
groups_avatar_upload();
|
90 |
-
}
|
91 |
-
|
92 |
-
/* DEPRECATED - BuddyPress templates are now merged with WordPress themes */
|
93 |
-
function groups_force_buddypress_theme( $template ) {
|
94 |
-
global $bp;
|
95 |
-
|
96 |
-
/* If we are using a BuddyPress 1.1+ theme ignore this. */
|
97 |
-
if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
|
98 |
-
return $template;
|
99 |
-
|
100 |
-
if ( $bp->current_component != $bp->groups->slug )
|
101 |
-
return $template;
|
102 |
-
|
103 |
-
$member_theme = get_site_option('active-member-theme');
|
104 |
-
|
105 |
-
if ( empty($member_theme) )
|
106 |
-
$member_theme = 'bpmember';
|
107 |
-
|
108 |
-
add_filter( 'theme_root', 'bp_core_filter_buddypress_theme_root' );
|
109 |
-
add_filter( 'theme_root_uri', 'bp_core_filter_buddypress_theme_root_uri' );
|
110 |
-
|
111 |
-
return $member_theme;
|
112 |
-
}
|
113 |
-
add_filter( 'template', 'groups_force_buddypress_theme' );
|
114 |
-
|
115 |
-
/* DEPRECATED - BuddyPress templates are now merged with WordPress themes */
|
116 |
-
function groups_force_buddypress_stylesheet( $stylesheet ) {
|
117 |
-
global $bp;
|
118 |
-
|
119 |
-
/* If we are using a BuddyPress 1.1+ theme ignore this. */
|
120 |
-
if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
|
121 |
-
return $stylesheet;
|
122 |
-
|
123 |
-
if ( $bp->current_component != $bp->groups->slug )
|
124 |
-
return $stylesheet;
|
125 |
-
|
126 |
-
$member_theme = get_site_option('active-member-theme');
|
127 |
-
|
128 |
-
if ( empty( $member_theme ) )
|
129 |
-
$member_theme = 'bpmember';
|
130 |
-
|
131 |
-
add_filter( 'theme_root', 'bp_core_filter_buddypress_theme_root' );
|
132 |
-
add_filter( 'theme_root_uri', 'bp_core_filter_buddypress_theme_root_uri' );
|
133 |
-
|
134 |
-
return $member_theme;
|
135 |
-
}
|
136 |
-
add_filter( 'stylesheet', 'groups_force_buddypress_stylesheet' );
|
137 |
-
|
138 |
-
function groups_add_js() {
|
139 |
-
global $bp;
|
140 |
-
|
141 |
-
/* If we are using a BuddyPress 1.1+ theme ignore this. */
|
142 |
-
if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
|
143 |
-
return false;
|
144 |
-
|
145 |
-
if ( $bp->current_component == $bp->groups->slug )
|
146 |
-
wp_enqueue_script( 'bp-groups-js', BP_PLUGIN_URL . '/bp-groups/deprecated/js/general.js' );
|
147 |
-
}
|
148 |
-
add_action( 'template_redirect', 'groups_add_js', 1 );
|
149 |
-
|
150 |
-
function groups_add_structure_css() {
|
151 |
-
/* If we are using a BuddyPress 1.1+ theme ignore this. */
|
152 |
-
if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
|
153 |
-
return false;
|
154 |
-
|
155 |
-
/* Enqueue the structure CSS file to give basic positional formatting for components */
|
156 |
-
wp_enqueue_style( 'bp-groups-structure', BP_PLUGIN_URL . '/bp-groups/deprecated/css/structure.css' );
|
157 |
-
}
|
158 |
-
add_action( 'bp_styles', 'groups_add_structure_css' );
|
159 |
-
|
160 |
-
function groups_add_directory_js() {
|
161 |
-
/* If we are using a BuddyPress 1.1+ theme ignore this. */
|
162 |
-
if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
|
163 |
-
return false;
|
164 |
-
|
165 |
-
wp_enqueue_script( 'bp-groups-directory-groups', BP_PLUGIN_URL . '/bp-groups/deprecated/js/directory-groups.js', array( 'jquery', 'jquery-livequery-pack' ) );
|
166 |
-
}
|
167 |
-
add_action( 'groups_directory_groups_setup', 'groups_add_directory_js' );
|
168 |
-
|
169 |
-
/* DEPRECATED - use bp_has_groups( 'type=random' ) template loop */
|
170 |
-
function bp_groups_random_selection( $total_groups = 5 ) {
|
171 |
-
global $bp;
|
172 |
-
|
173 |
-
if ( !$group_ids = wp_cache_get( 'groups_random_groups', 'bp' ) ) {
|
174 |
-
$group_ids = BP_Groups_Group::get_random( $total_groups, 1 );
|
175 |
-
wp_cache_set( 'groups_random_groups', $group_ids, 'bp' );
|
176 |
-
}
|
177 |
-
?>
|
178 |
-
<?php if ( $group_ids['groups'] ) { ?>
|
179 |
-
<ul class="item-list" id="random-groups-list">
|
180 |
-
<?php
|
181 |
-
for ( $i = 0; $i < count( $group_ids['groups'] ); $i++ ) {
|
182 |
-
if ( !$group = wp_cache_get( 'groups_group_nouserdata_' . $group_ids['groups'][$i]->group_id, 'bp' ) ) {
|
183 |
-
$group = new BP_Groups_Group( $group_ids['groups'][$i]->group_id, false, false );
|
184 |
-
wp_cache_set( 'groups_group_nouserdata_' . $group_ids['groups'][$i]->group_id, $group, 'bp' );
|
185 |
-
}
|
186 |
-
?>
|
187 |
-
<li>
|
188 |
-
<div class="item-avatar">
|
189 |
-
<a href="<?php echo bp_get_group_permalink( $group ) ?>" title="<?php echo bp_get_group_name( $group ) ?>"><?php echo bp_get_group_avatar_thumb( $group ) ?></a>
|
190 |
-
</div>
|
191 |
-
|
192 |
-
<div class="item">
|
193 |
-
<div class="item-title"><a href="<?php echo bp_get_group_permalink( $group ) ?>" title="<?php echo bp_get_group_name( $group ) ?>"><?php echo bp_get_group_name( $group ) ?></a></div>
|
194 |
-
<div class="item-meta"><span class="activity"><?php echo bp_core_get_last_activity( groups_get_groupmeta( $group->id, 'last_activity' ), __( 'active %s ago', 'buddypress' ) ) ?></span></div>
|
195 |
-
<div class="item-meta desc"><?php echo bp_create_excerpt( $group->description ) ?></div>
|
196 |
-
</div>
|
197 |
-
|
198 |
-
<div class="action">
|
199 |
-
<?php bp_group_join_button( $group ) ?>
|
200 |
-
<div class="meta">
|
201 |
-
<?php $member_count = groups_get_groupmeta( $group->id, 'total_member_count' ) ?>
|
202 |
-
<?php echo ucwords($group->status) ?> <?php _e( 'Group', 'buddypress' ) ?> /
|
203 |
-
<?php if ( 1 == $member_count ) : ?>
|
204 |
-
<?php printf( __( '%d member', 'buddypress' ), $member_count ) ?>
|
205 |
-
<?php else : ?>
|
206 |
-
<?php printf( __( '%d members', 'buddypress' ), $member_count ) ?>
|
207 |
-
<?php endif; ?>
|
208 |
-
</div>
|
209 |
-
</div>
|
210 |
-
|
211 |
-
<div class="clear"></div>
|
212 |
-
</li>
|
213 |
-
<?php } ?>
|
214 |
-
</ul>
|
215 |
-
<?php } else { ?>
|
216 |
-
<div id="message" class="info">
|
217 |
-
<p><?php _e( "There aren't enough groups to show a random sample just yet.", 'buddypress' ) ?></p>
|
218 |
-
</div>
|
219 |
-
<?php } ?>
|
220 |
-
<?php
|
221 |
-
}
|
222 |
-
|
223 |
-
/* DEPRECATED - use bp_has_groups( 'type=random' ) template loop */
|
224 |
-
function bp_groups_random_groups( $total_groups = 5 ) {
|
225 |
-
global $bp;
|
226 |
-
|
227 |
-
if ( !$group_ids = wp_cache_get( 'groups_random_user_groups_' . $bp->displayed_user->id . '_' . $total_groups, 'bp' ) ) {
|
228 |
-
$group_ids = groups_get_random_groups_for_user( $bp->displayed_user->id, $total_groups, 1 );
|
229 |
-
wp_cache_set( 'groups_random_user_groups_' . $bp->displayed_user->id . '_' . $total_groups, $group_ids, 'bp' );
|
230 |
-
}
|
231 |
-
|
232 |
-
?>
|
233 |
-
<div class="info-group">
|
234 |
-
<h4><?php bp_word_or_name( __( "My Groups", 'buddypress' ), __( "%s's Groups", 'buddypress' ) ) ?> (<?php echo BP_Groups_Member::total_group_count() ?>) <span><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>"><?php _e('See All', 'buddypress') ?> »</a></span></h4>
|
235 |
-
<?php if ( $group_ids ) { ?>
|
236 |
-
<ul class="horiz-gallery">
|
237 |
-
<?php
|
238 |
-
for ( $i = 0; $i < count( $group_ids ); $i++ ) {
|
239 |
-
if ( !$group = wp_cache_get( 'groups_group_nouserdata_' . $group_ids[$i], 'bp' ) ) {
|
240 |
-
$group = new BP_Groups_Group( $group_ids[$i], false, false );
|
241 |
-
wp_cache_set( 'groups_group_nouserdata_' . $group_ids[$i], $group, 'bp' );
|
242 |
-
}
|
243 |
-
?> <li>
|
244 |
-
<a href="<?php echo bp_get_group_permalink( $group ) ?>"><?php echo bp_core_fetch_avatar( array( 'item_id' => $group->id, 'object' => 'group', 'type' => 'thumb' ) ) ?></a>
|
245 |
-
<h5><a href="<?php echo bp_get_group_permalink( $group ) ?>"><?php echo attribute_escape( $group->name ) ?></a></h5>
|
246 |
-
</li>
|
247 |
-
<?php } ?>
|
248 |
-
</ul>
|
249 |
-
<?php } else { ?>
|
250 |
-
<div id="message" class="info">
|
251 |
-
<p><?php bp_word_or_name( __( "You haven't joined any groups yet.", 'buddypress' ), __( "%s hasn't joined any groups yet.", 'buddypress' ) ) ?></p>
|
252 |
-
</div>
|
253 |
-
<?php } ?>
|
254 |
-
<div class="clear"></div>
|
255 |
-
</div>
|
256 |
-
<?php
|
257 |
-
}
|
258 |
-
|
259 |
-
/* DEPRECATED - use bp_has_topics() template loop */
|
260 |
-
function bp_group_active_forum_topics( $total_topics = 3, $group = false ) {
|
261 |
-
global $groups_template, $forum_template;
|
262 |
-
|
263 |
-
if ( !$group )
|
264 |
-
$group =& $groups_template->group;
|
265 |
-
|
266 |
-
$forum_id = groups_get_groupmeta( $group->id, 'forum_id' );
|
267 |
-
|
268 |
-
if ( $forum_id && $forum_id != '' ) {
|
269 |
-
if ( function_exists( 'bp_forums_setup' ) ) {
|
270 |
-
$latest_topics = bp_forums_get_forum_topics( array( 'forum_id' => $forum_id ) );
|
271 |
-
|
272 |
-
if ( $latest_topics ) { ?>
|
273 |
-
<ul class="item-list" id="recent-forum-topics"><?php
|
274 |
-
|
275 |
-
$counter = 0;
|
276 |
-
|
277 |
-
foreach( $latest_topics as $topic ) {
|
278 |
-
$alt = ( $counter % 2 == 1 ) ? ' class="alt"' : '';
|
279 |
-
$forum_template->topic = (object)$topic; ?>
|
280 |
-
|
281 |
-
<li<?php echo $alt ?>>
|
282 |
-
<div class="avatar">
|
283 |
-
<?php bp_the_topic_poster_avatar() ?>
|
284 |
-
</div>
|
285 |
-
|
286 |
-
<a href="<?php bp_the_topic_permalink() ?>" title="<?php bp_the_topic_title() ?> - <?php _e( 'Permalink', 'buddypress' ) ?>"><?php bp_the_topic_title() ?></a>
|
287 |
-
<span class="small">- <?php bp_the_topic_total_post_count() ?> </span>
|
288 |
-
<p><span class="activity"><?php echo sprintf( __( 'updated %s ago', 'buddypress' ), bp_the_topic_time_since_last_post( false ) ) ?></span></p>
|
289 |
-
|
290 |
-
<div class="latest-post">
|
291 |
-
<?php _e( 'Latest by', 'buddypress' ) ?> <?php bp_the_topic_last_poster_name() ?>:
|
292 |
-
<?php bp_the_topic_latest_post_excerpt() ?>
|
293 |
-
</div>
|
294 |
-
</li>
|
295 |
-
<?php $counter++ ?>
|
296 |
-
|
297 |
-
<?php } ?>
|
298 |
-
</ul>
|
299 |
-
<?php
|
300 |
-
} else {
|
301 |
-
?>
|
302 |
-
<div id="message" class="info">
|
303 |
-
<p><?php _e( 'There are no active forum topics for this group', 'buddypress' ) ?></p>
|
304 |
-
</div>
|
305 |
-
<?php
|
306 |
-
}
|
307 |
-
}
|
308 |
-
}
|
309 |
-
}
|
310 |
-
|
311 |
-
|
312 |
-
/* DEPRECATED - use group invite template loop (see groups/create.php in skeleton BuddyPress theme) */
|
313 |
-
function bp_group_send_invite_form( $group = false ) {
|
314 |
-
global $bp, $groups_template, $invites;
|
315 |
-
|
316 |
-
if ( !$group )
|
317 |
-
$group =& $groups_template->group;
|
318 |
-
?>
|
319 |
-
<div class="left-menu">
|
320 |
-
<h4><?php _e( 'Select Friends', 'buddypress' ) ?> <span class="ajax-loader"></span></h4>
|
321 |
-
<?php bp_group_list_invite_friends() ?>
|
322 |
-
<?php wp_nonce_field( 'groups_invite_uninvite_user', '_wpnonce_invite_uninvite_user' ) ?>
|
323 |
-
<input type="hidden" name="group_id" id="group_id" value="<?php echo attribute_escape( $group->id ) ?>" />
|
324 |
-
</div>
|
325 |
-
|
326 |
-
<div class="main-column">
|
327 |
-
|
328 |
-
<div id="message" class="info">
|
329 |
-
<p><?php _e('Select people to invite from your friends list.', 'buddypress'); ?></p>
|
330 |
-
</div>
|
331 |
-
|
332 |
-
<?php $invites = groups_get_invites_for_group( $bp->loggedin_user->id, $group->id ) ?>
|
333 |
-
|
334 |
-
<ul id="friend-list" class="item-list">
|
335 |
-
<?php for ( $i = 0; $i < count($invites); $i++ ) {
|
336 |
-
if ( !$user = wp_cache_get( 'bp_user_' . $invites[$i], 'bp' ) ) {
|
337 |
-
$user = new BP_Core_User( $invites[$i] );
|
338 |
-
wp_cache_set( 'bp_user_' . $invites[$i], $user, 'bp' );
|
339 |
-
}
|
340 |
-
?>
|
341 |
-
<li id="uid-<?php echo $user->id ?>">
|
342 |
-
<?php echo $user->avatar_thumb ?>
|
343 |
-
<h4><?php echo $user->user_link ?></h4>
|
344 |
-
<span class="activity"><?php echo $user->last_active ?></span>
|
345 |
-
<div class="action">
|
346 |
-
<a class="remove" href="<?php echo wp_nonce_url( site_url( $bp->groups->slug . '/' . $group->id . '/invites/remove/' . $user->id ), 'groups_invite_uninvite_user' ) ?>" id="uid-<?php echo $user->id ?>"><?php _e( 'Remove Invite', 'buddypress' ) ?></a>
|
347 |
-
</div>
|
348 |
-
</li>
|
349 |
-
<?php } // end for ?>
|
350 |
-
</ul>
|
351 |
-
|
352 |
-
<?php wp_nonce_field( 'groups_send_invites', '_wpnonce_send_invites' ) ?>
|
353 |
-
</div>
|
354 |
-
<?php
|
355 |
-
}
|
356 |
-
|
357 |
-
/* DEPRECATED - use bp_group_has_invites() template loop */
|
358 |
-
function bp_group_list_invite_friends( $args = '' ) {
|
359 |
-
global $bp, $invites;
|
360 |
-
|
361 |
-
if ( !function_exists('friends_install') )
|
362 |
-
return false;
|
363 |
-
|
364 |
-
$friends = friends_get_friends_invite_list( $bp->loggedin_user->id, $bp->groups->current_group->id );
|
365 |
-
|
366 |
-
if ( $friends ) {
|
367 |
-
$invites = groups_get_invites_for_group( $bp->loggedin_user->id, $bp->groups->current_group->id );
|
368 |
-
|
369 |
-
?>
|
370 |
-
<div id="invite-list">
|
371 |
-
<ul>
|
372 |
-
<?php
|
373 |
-
for ( $i = 0; $i < count( $friends ); $i++ ) {
|
374 |
-
if ( $invites ) {
|
375 |
-
if ( in_array( $friends[$i]['id'], $invites ) ) {
|
376 |
-
$checked = ' checked="checked"';
|
377 |
-
} else {
|
378 |
-
$checked = '';
|
379 |
-
}
|
380 |
-
}
|
381 |
-
?>
|
382 |
-
|
383 |
-
<li><input<?php echo $checked ?> type="checkbox" name="friends[]" id="f-<?php echo $friends[$i]['id'] ?>" value="<?php echo attribute_escape( $friends[$i]['id'] ); ?>" /> <?php echo $friends[$i]['full_name']; ?></li>
|
384 |
-
<?php } ?>
|
385 |
-
</ul>
|
386 |
-
</div>
|
387 |
-
<?php
|
388 |
-
} else {
|
389 |
-
_e( 'No friends to invite.', 'buddypress' );
|
390 |
-
}
|
391 |
-
}
|
392 |
-
|
393 |
-
/* DEPRECATED - use bp_group_has_members() template loop */
|
394 |
-
function bp_group_random_members( $group = false ) {
|
395 |
-
global $groups_template;
|
396 |
-
|
397 |
-
if ( !$group )
|
398 |
-
$group =& $groups_template->group;
|
399 |
-
|
400 |
-
$members = &$group->random_members;
|
401 |
-
?>
|
402 |
-
<ul class="horiz-gallery">
|
403 |
-
<?php for ( $i = 0; $i < count( $members ); $i++ ) { ?>
|
404 |
-
<li>
|
405 |
-
<a href="<?php echo $members[$i]->user->user_url ?>"><?php echo $members[$i]->user->avatar_thumb ?></a>
|
406 |
-
<h5><?php echo $members[$i]->user->user_link ?></h5>
|
407 |
-
</li>
|
408 |
-
<?php } ?>
|
409 |
-
</ul>
|
410 |
-
<div class="clear"></div>
|
411 |
-
<?php
|
412 |
-
}
|
413 |
-
|
414 |
-
/* Deprecated please use bp_group_member_promote_mod_link() or bp_group_member_promote_admin_link() */
|
415 |
-
function bp_group_member_promote_link( $user_id = false, $deprecated = false ) {
|
416 |
-
global $members_template;
|
417 |
-
|
418 |
-
if ( !$user_id )
|
419 |
-
$user_id = $members_template->member->user_id;
|
420 |
-
|
421 |
-
echo bp_get_group_member_promote_link( $user_id );
|
422 |
-
}
|
423 |
-
function bp_get_group_member_promote_link( $user_id = false, $group = false ) {
|
424 |
-
global $members_template, $groups_template, $bp;
|
425 |
-
|
426 |
-
if ( !$user_id )
|
427 |
-
$user_id = $members_template->member->user_id;
|
428 |
-
|
429 |
-
if ( !$group )
|
430 |
-
$group =& $groups_template->group;
|
431 |
-
|
432 |
-
return apply_filters( 'bp_get_group_member_promote_link', wp_nonce_url( bp_get_group_permalink( $group ) . '/admin/manage-members/promote/mod/' . $user_id, 'groups_promote_member' ) );
|
433 |
-
}
|
434 |
-
|
435 |
-
|
436 |
-
/* DEPRECATED - see latest default BuddyPress theme /groups/create.php for replacement template tags */
|
437 |
-
function bp_group_create_form() {
|
438 |
-
global $bp, $invites;
|
439 |
-
?>
|
440 |
-
<form action="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>/create/step/<?php echo $bp->groups->current_create_step ?>" method="post" id="create-group-form" class="standard-form" enctype="multipart/form-data">
|
441 |
-
<?php switch( $bp->groups->current_create_step ) {
|
442 |
-
case 'group-details': ?>
|
443 |
-
<label for="group-name">* <?php _e('Group Name', 'buddypress') ?></label>
|
444 |
-
<input type="text" name="group-name" id="group-name" value="<?php echo attribute_escape( ( $bp->groups->new_group ) ? $bp->groups->current_group->name : $_POST['group-name'] ); ?>" />
|
445 |
-
|
446 |
-
<label for="group-desc">* <?php _e('Group Description', 'buddypress') ?></label>
|
447 |
-
<textarea name="group-desc" id="group-desc"><?php echo htmlspecialchars( ( $bp->groups->new_group ) ? $bp->groups->current_group->description : $_POST['group-desc'] ); ?></textarea>
|
448 |
-
|
449 |
-
<label for="group-news"><?php _e('Recent News', 'buddypress') ?></label>
|
450 |
-
<textarea name="group-news" id="group-news"><?php echo htmlspecialchars( ( $bp->groups->new_group ) ? $bp->groups->current_group->news : $_POST['group-news'] ); ?></textarea>
|
451 |
-
|
452 |
-
<?php do_action( 'groups_custom_group_fields_editable' ) ?>
|
453 |
-
|
454 |
-
<?php wp_nonce_field( 'groups_create_save_group-details' ) ?>
|
455 |
-
|
456 |
-
<?php break; ?>
|
457 |
-
|
458 |
-
<?php case 'group-settings': ?>
|
459 |
-
<?php if ( bp_are_previous_group_creation_steps_complete( 'group-settings' ) ) { ?>
|
460 |
-
<?php if ( function_exists('bp_wire_install') ) : ?>
|
461 |
-
<div class="checkbox">
|
462 |
-
<label><input type="checkbox" name="group-show-wire" id="group-show-wire" value="1"<?php if ( $bp->groups->current_group->enable_wire ) { ?> checked="checked"<?php } ?> /> <?php _e('Enable comment wire', 'buddypress') ?></label>
|
463 |
-
</div>
|
464 |
-
<?php endif; ?>
|
465 |
-
|
466 |
-
<?php if ( function_exists('bp_forums_setup') ) : ?>
|
467 |
-
<?php if ( bp_forums_is_installed_correctly() ) { ?>
|
468 |
-
<div class="checkbox">
|
469 |
-
<label><input type="checkbox" name="group-show-forum" id="group-show-forum" value="1"<?php if ( $bp->groups->current_group->enable_forum ) { ?> checked="checked"<?php } ?> /> <?php _e('Enable discussion forum', 'buddypress') ?></label>
|
470 |
-
</div>
|
471 |
-
<?php } else {
|
472 |
-
if ( is_site_admin() ) {
|
473 |
-
?>
|
474 |
-
<div class="checkbox">
|
475 |
-
<label><input type="checkbox" disabled="disabled" name="disabled" id="disabled" value="0" /> <?php printf( __('<strong>Attention Site Admin:</strong> Group forums require the <a href="%s">correct setup and configuration</a> of a bbPress installation.', 'buddypress' ), $bp->root_domain . '/wp-admin/admin.php?page=' . BP_PLUGIN_DIR . '/bp-forums/bp-forums-admin.php' ) ?></label>
|
476 |
-
</div>
|
477 |
-
<?php
|
478 |
-
}
|
479 |
-
}?>
|
480 |
-
<?php endif; ?>
|
481 |
-
|
482 |
-
<?php if ( function_exists('bp_albums_install') ) : ?>
|
483 |
-
<div class="checkbox with-suboptions">
|
484 |
-
<label><input type="checkbox" name="group-show-photos" id="group-show-photos" value="1"<?php if ( $bp->groups->current_group->enable_photos ) { ?> checked="checked"<?php } ?> /> <?php _e('Enable photo gallery', 'buddypress') ?></label>
|
485 |
-
<div class="sub-options"<?php if ( !$bp->groups->current_group->enable_photos ) { ?> style="display: none;"<?php } ?>>
|
486 |
-
<label><input type="radio" name="group-photos-status" value="all"<?php if ( !$bp->groups->current_group->photos_admin_only ) { ?> checked="checked"<?php } ?> /> <?php _e('All members can upload photos', 'buddypress') ?></label>
|
487 |
-
<label><input type="radio" name="group-photos-status" value="admins"<?php if ( $bp->groups->current_group->photos_admin_only ) { ?> checked="checked"<?php } ?> /> <?php _e('Only group admins can upload photos', 'buddypress') ?></label>
|
488 |
-
</div>
|
489 |
-
</div>
|
490 |
-
<?php endif; ?>
|
491 |
-
|
492 |
-
<h3><?php _e( 'Privacy Options', 'buddypress' ); ?></h3>
|
493 |
-
|
494 |
-
<div class="radio">
|
495 |
-
<label><input type="radio" name="group-status" value="public"<?php if ( 'public' == $bp->groups->current_group->status ) { ?> checked="checked"<?php } ?> />
|
496 |
-
<strong><?php _e( 'This is a public group', 'buddypress' ) ?></strong>
|
497 |
-
<ul>
|
498 |
-
<li><?php _e( 'Any site member can join this group.', 'buddypress' ) ?></li>
|
499 |
-
<li><?php _e( 'This group will be listed in the groups directory and in search results.', 'buddypress' ) ?></li>
|
500 |
-
<li><?php _e( 'Group content and activity will be visible to any site member.', 'buddypress' ) ?></li>
|
501 |
-
</ul>
|
502 |
-
</label>
|
503 |
-
|
504 |
-
<label><input type="radio" name="group-status" value="private"<?php if ( 'private' == $bp->groups->current_group->status ) { ?> checked="checked"<?php } ?> />
|
505 |
-
<strong><?php _e( 'This is a private group', 'buddypress' ) ?></strong>
|
506 |
-
<ul>
|
507 |
-
<li><?php _e( 'Only users who request membership and are accepted can join the group.', 'buddypress' ) ?></li>
|
508 |
-
<li><?php _e( 'This group will be listed in the groups directory and in search results.', 'buddypress' ) ?></li>
|
509 |
-
<li><?php _e( 'Group content and activity will only be visible to members of the group.', 'buddypress' ) ?></li>
|
510 |
-
</ul>
|
511 |
-
</label>
|
512 |
-
|
513 |
-
<label><input type="radio" name="group-status" value="hidden"<?php if ( 'hidden' == $bp->groups->current_group->status ) { ?> checked="checked"<?php } ?> />
|
514 |
-
<strong><?php _e('This is a hidden group', 'buddypress') ?></strong>
|
515 |
-
<ul>
|
516 |
-
<li><?php _e( 'Only users who are invited can join the group.', 'buddypress' ) ?></li>
|
517 |
-
<li><?php _e( 'This group will not be listed in the groups directory or search results.', 'buddypress' ) ?></li>
|
518 |
-
<li><?php _e( 'Group content and activity will only be visible to members of the group.', 'buddypress' ) ?></li>
|
519 |
-
</ul>
|
520 |
-
</label>
|
521 |
-
</div>
|
522 |
-
|
523 |
-
<?php wp_nonce_field( 'groups_create_save_group-settings' ) ?>
|
524 |
-
<?php } else { ?>
|
525 |
-
<div id="message" class="info">
|
526 |
-
<p><?php _e('Please complete all previous steps first.', 'buddypress'); ?></p>
|
527 |
-
</div>
|
528 |
-
<?php } ?>
|
529 |
-
<?php break; ?>
|
530 |
-
|
531 |
-
<?php case 'group-avatar': ?>
|
532 |
-
<?php if ( bp_are_previous_group_creation_steps_complete( 'group-avatar' ) ) { ?>
|
533 |
-
<div class="left-menu">
|
534 |
-
<?php bp_new_group_avatar() ?>
|
535 |
-
</div>
|
536 |
-
|
537 |
-
<div class="main-column">
|
538 |
-
<p><?php _e("Upload an image to use as an avatar for this group. The image will be shown on the main group page, and in search results.", 'buddypress') ?></p>
|
539 |
-
|
540 |
-
<?php groups_avatar_upload() ?>
|
541 |
-
|
542 |
-
</div>
|
543 |
-
|
544 |
-
<?php wp_nonce_field( 'groups_step3_save' ) ?>
|
545 |
-
<?php } else { ?>
|
546 |
-
<div id="message" class="info">
|
547 |
-
<p><?php _e('Please complete all previous steps first.', 'buddypress'); ?></p>
|
548 |
-
</div>
|
549 |
-
<?php } ?>
|
550 |
-
|
551 |
-
<?php wp_nonce_field( 'groups_create_save_group-avatar' ) ?>
|
552 |
-
|
553 |
-
<?php break; ?>
|
554 |
-
<?php case 'group-invites': ?>
|
555 |
-
<?php
|
556 |
-
if ( bp_are_previous_group_creation_steps_complete( 'group-invites' ) ) {
|
557 |
-
$group_link = bp_get_group_permalink( $bp->groups->new_group );
|
558 |
-
|
559 |
-
if ( function_exists('friends_install') ) {
|
560 |
-
if ( friends_get_friend_count_for_user( $bp->loggedin_user->id ) ) {
|
561 |
-
bp_group_send_invite_form( $bp->groups->new_group );
|
562 |
-
} else {
|
563 |
-
?>
|
564 |
-
<div id="message" class="info">
|
565 |
-
<p><?php _e( 'Once you build up your friends list you will be able to invite friends to join your group.', 'buddypress' ) ?></p>
|
566 |
-
</div>
|
567 |
-
<?php
|
568 |
-
}
|
569 |
-
} ?>
|
570 |
-
|
571 |
-
<?php wp_nonce_field( 'groups_step4_save' ) ?>
|
572 |
-
|
573 |
-
<?php
|
574 |
-
} else { ?>
|
575 |
-
<div id="message" class="info">
|
576 |
-
<p><?php _e('Please complete all previous steps first.', 'buddypress'); ?></p>
|
577 |
-
</div>
|
578 |
-
<?php } ?>
|
579 |
-
|
580 |
-
<?php wp_nonce_field( 'groups_create_save_group-invites' ) ?>
|
581 |
-
|
582 |
-
<?php break; ?>
|
583 |
-
<?php } ?>
|
584 |
-
|
585 |
-
<?php do_action( 'groups_custom_create_steps' ) // Allow plugins to add custom group creation steps ?>
|
586 |
-
|
587 |
-
<div class="clear"></div>
|
588 |
-
|
589 |
-
<div id="previous-next">
|
590 |
-
<!-- Previous Button -->
|
591 |
-
<?php if ( !bp_is_first_group_creation_step() ) : ?>
|
592 |
-
<input type="button" value="← <?php _e('Previous Step', 'buddypress') ?>" id="group-creation-previous" style="width: auto;" name="previous" onclick="location.href='<?php bp_group_creation_previous_link() ?>'" />
|
593 |
-
<?php endif; ?>
|
594 |
-
|
595 |
-
<!-- Next Button -->
|
596 |
-
<?php if ( !bp_is_last_group_creation_step() && !bp_is_first_group_creation_step() ) : ?>
|
597 |
-
<input type="submit" value="<?php _e('Next Step', 'buddypress') ?> →" id="group-creation-next" name="save" />
|
598 |
-
<?php endif;?>
|
599 |
-
|
600 |
-
<!-- Create Button -->
|
601 |
-
<?php if ( bp_is_first_group_creation_step() ) : ?>
|
602 |
-
<input type="submit" value="<?php _e('Create Group and Continue', 'buddypress') ?> →" id="group-creation-create" name="save" />
|
603 |
-
<?php endif; ?>
|
604 |
-
|
605 |
-
<!-- Finish Button -->
|
606 |
-
<?php if ( bp_is_last_group_creation_step() ) : ?>
|
607 |
-
<input type="submit" value="<?php _e('Finish', 'buddypress') ?> →" id="group-creation-finish" name="save" />
|
608 |
-
<?php endif; ?>
|
609 |
-
</div>
|
610 |
-
|
611 |
-
<!-- Don't leave out this hidden field -->
|
612 |
-
<input type="hidden" name="group_id" id="group_id" value="<?php bp_new_group_id() ?>" />
|
613 |
-
|
614 |
-
</form>
|
615 |
-
<?php
|
616 |
-
}
|
617 |
-
|
618 |
-
function groups_ajax_invite_user() {
|
619 |
-
global $bp;
|
620 |
-
|
621 |
-
/* If we are using a BuddyPress 1.1+ theme ignore this. */
|
622 |
-
if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
|
623 |
-
return false;
|
624 |
-
|
625 |
-
check_ajax_referer( 'groups_invite_uninvite_user' );
|
626 |
-
|
627 |
-
if ( !$_POST['friend_id'] || !$_POST['friend_action'] || !$_POST['group_id'] )
|
628 |
-
return false;
|
629 |
-
|
630 |
-
if ( !groups_is_user_member( $bp->loggedin_user->id, $_POST['group_id'] ) )
|
631 |
-
return false;
|
632 |
-
|
633 |
-
if ( !friends_check_friendship( $bp->loggedin_user->id, $_POST['friend_id'] ) )
|
634 |
-
return false;
|
635 |
-
|
636 |
-
if ( 'invite' == $_POST['friend_action'] ) {
|
637 |
-
|
638 |
-
if ( !groups_invite_user( array( 'user_id' => $_POST['friend_id'], 'group_id' => $_POST['group_id'] ) ) )
|
639 |
-
return false;
|
640 |
-
|
641 |
-
$user = new BP_Core_User( $_POST['friend_id'] );
|
642 |
-
|
643 |
-
echo '<li id="uid-' . $user->id . '">';
|
644 |
-
echo $user->avatar_thumb;
|
645 |
-
echo '<h4>' . $user->user_link . '</h4>';
|
646 |
-
echo '<span class="activity">' . attribute_escape( $user->last_active ) . '</span>';
|
647 |
-
echo '<div class="action">
|
648 |
-
<a class="remove" href="' . wp_nonce_url( $bp->loggedin_user->domain . $bp->groups->slug . '/' . $_POST['group_id'] . '/invites/remove/' . $user->id, 'groups_invite_uninvite_user' ) . '" id="uid-' . attribute_escape( $user->id ) . '">' . __( 'Remove Invite', 'buddypress' ) . '</a>
|
649 |
-
</div>';
|
650 |
-
echo '</li>';
|
651 |
-
|
652 |
-
} else if ( 'uninvite' == $_POST['friend_action'] ) {
|
653 |
-
|
654 |
-
if ( !groups_uninvite_user( $_POST['friend_id'], $_POST['group_id'] ) )
|
655 |
-
return false;
|
656 |
-
|
657 |
-
return true;
|
658 |
-
|
659 |
-
} else {
|
660 |
-
return false;
|
661 |
-
}
|
662 |
-
}
|
663 |
-
add_action( 'wp_ajax_groups_invite_user', 'groups_ajax_invite_user' );
|
664 |
-
|
665 |
-
function groups_ajax_group_filter() {
|
666 |
-
global $bp;
|
667 |
-
|
668 |
-
/* If we are using a BuddyPress 1.1+ theme ignore this. */
|
669 |
-
if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
|
670 |
-
return false;
|
671 |
-
|
672 |
-
check_ajax_referer( 'group-filter-box' );
|
673 |
-
|
674 |
-
locate_template( array( 'groups/group-loop.php' ), true );
|
675 |
-
}
|
676 |
-
add_action( 'wp_ajax_group_filter', 'groups_ajax_group_filter' );
|
677 |
-
|
678 |
-
function groups_ajax_member_list() {
|
679 |
-
global $bp;
|
680 |
-
|
681 |
-
/* If we are using a BuddyPress 1.1+ theme ignore this. */
|
682 |
-
if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
|
683 |
-
return false;
|
684 |
-
?>
|
685 |
-
|
686 |
-
<?php if ( bp_group_has_members( 'group_id=' . $_REQUEST['group_id'] ) ) : ?>
|
687 |
-
|
688 |
-
<?php if ( bp_group_member_needs_pagination() ) : ?>
|
689 |
-
<div id="member-count" class="pag-count">
|
690 |
-
<?php bp_group_member_pagination_count() ?>
|
691 |
-
</div>
|
692 |
-
|
693 |
-
<div id="member-pagination" class="pagination-links">
|
694 |
-
<?php bp_group_member_pagination() ?>
|
695 |
-
</div>
|
696 |
-
<?php endif; ?>
|
697 |
-
|
698 |
-
<ul id="member-list" class="item-list">
|
699 |
-
<?php while ( bp_group_members() ) : bp_group_the_member(); ?>
|
700 |
-
<li>
|
701 |
-
<?php bp_group_member_avatar() ?>
|
702 |
-
<h5><?php bp_group_member_link() ?></h5>
|
703 |
-
<span class="activity"><?php bp_group_member_joined_since() ?></span>
|
704 |
-
|
705 |
-
<?php if ( function_exists( 'friends_install' ) ) : ?>
|
706 |
-
<div class="action">
|
707 |
-
<?php bp_add_friend_button( bp_get_group_member_id() ) ?>
|
708 |
-
</div>
|
709 |
-
<?php endif; ?>
|
710 |
-
</li>
|
711 |
-
<?php endwhile; ?>
|
712 |
-
</ul>
|
713 |
-
<?php else: ?>
|
714 |
-
|
715 |
-
<div id="message" class="info">
|
716 |
-
<p><?php _e( 'This group has no members.', 'buddypress' ) ?></p>
|
717 |
-
</div>
|
718 |
-
|
719 |
-
<?php endif; ?>
|
720 |
-
<input type="hidden" name="group_id" id="group_id" value="<?php echo attribute_escape( $_REQUEST['group_id'] ); ?>" />
|
721 |
-
<?php
|
722 |
-
}
|
723 |
-
add_action( 'wp_ajax_get_group_members', 'groups_ajax_member_list' );
|
724 |
-
|
725 |
-
function groups_ajax_member_admin_list() {
|
726 |
-
global $bp;
|
727 |
-
|
728 |
-
/* If we are using a BuddyPress 1.1+ theme ignore this. */
|
729 |
-
if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
|
730 |
-
return false;
|
731 |
-
?>
|
732 |
-
|
733 |
-
<?php if ( bp_group_has_members( 'group_id=' . $_REQUEST['group_id'] . '&per_page=' . $_REQUEST['num'] ) ) : ?>
|
734 |
-
|
735 |
-
<?php if ( bp_group_member_needs_pagination() ) : ?>
|
736 |
-
<div id="member-count" class="pag-count">
|
737 |
-
<?php bp_group_member_pagination_count() ?>
|
738 |
-
</div>
|
739 |
-
|
740 |
-
<div id="member-admin-pagination" class="pagination-links">
|
741 |
-
<?php bp_group_member_admin_pagination() ?>
|
742 |
-
</div>
|
743 |
-
<?php endif; ?>
|
744 |
-
|
745 |
-
<ul id="members-list" class="item-list single-line">
|
746 |
-
<?php while ( bp_group_members() ) : bp_group_the_member(); ?>
|
747 |
-
<?php if ( bp_get_group_member_is_banned() ) : ?>
|
748 |
-
<li class="banned-user">
|
749 |
-
<?php bp_group_member_avatar_mini() ?>
|
750 |
-
|
751 |
-
<h5><?php bp_group_member_link() ?> <?php _e( '(banned)', 'buddypress' ) ?> <span class="small"> — <a href="<?php bp_group_member_unban_link() ?>" title="<?php _e( 'Kick and ban this member', 'buddypress' ) ?>"><?php _e( 'Remove Ban', 'buddypress' ) ?></a> </h5>
|
752 |
-
<?php else : ?>
|
753 |
-
<li>
|
754 |
-
<?php bp_group_member_avatar_mini() ?>
|
755 |
-
<h5><?php bp_group_member_link() ?> <span class="small"> — <a href="<?php bp_group_member_ban_link() ?>" title="<?php _e( 'Kick and ban this member', 'buddypress' ) ?>"><?php _e( 'Kick & Ban', 'buddypress' ) ?></a> | <a href="<?php bp_group_member_promote_link() ?>" title="<?php _e( 'Promote this member', 'buddypress' ) ?>"><?php _e( 'Promote to Moderator', 'buddypress' ) ?></a></span></h5>
|
756 |
-
|
757 |
-
<?php endif; ?>
|
758 |
-
</li>
|
759 |
-
<?php endwhile; ?>
|
760 |
-
</ul>
|
761 |
-
<?php else: ?>
|
762 |
-
|
763 |
-
<div id="message" class="info">
|
764 |
-
<p><?php _e( 'This group has no members.', 'buddypress' ) ?></p>
|
765 |
-
</div>
|
766 |
-
|
767 |
-
<?php endif;?>
|
768 |
-
<input type="hidden" name="group_id" id="group_id" value="<?php echo attribute_escape( $_REQUEST['group_id'] ); ?>" />
|
769 |
-
<?php
|
770 |
-
}
|
771 |
-
add_action( 'wp_ajax_get_group_members_admin', 'groups_ajax_member_admin_list' );
|
772 |
-
|
773 |
-
function bp_core_ajax_directory_groups() {
|
774 |
-
global $bp;
|
775 |
-
|
776 |
-
/* If we are using a BuddyPress 1.1+ theme ignore this. */
|
777 |
-
if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
|
778 |
-
return false;
|
779 |
-
|
780 |
-
check_ajax_referer('directory_groups');
|
781 |
-
|
782 |
-
locate_template( array( 'directories/groups/groups-loop.php' ), true );
|
783 |
-
}
|
784 |
-
add_action( 'wp_ajax_directory_groups', 'bp_core_ajax_directory_groups' );
|
785 |
-
|
786 |
-
function groups_ajax_joinleave_group() {
|
787 |
-
global $bp;
|
788 |
-
|
789 |
-
/* If we are using a BuddyPress 1.1+ theme ignore this. */
|
790 |
-
if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
|
791 |
-
return false;
|
792 |
-
|
793 |
-
if ( groups_is_user_banned( $bp->loggedin_user->id, $_POST['gid'] ) )
|
794 |
-
return false;
|
795 |
-
|
796 |
-
if ( !$group = new BP_Groups_Group( $_POST['gid'], false, false ) )
|
797 |
-
return false;
|
798 |
-
|
799 |
-
if ( 'hidden' == $group->status )
|
800 |
-
return false;
|
801 |
-
|
802 |
-
if ( !groups_is_user_member( $bp->loggedin_user->id, $group->id ) ) {
|
803 |
-
|
804 |
-
if ( 'public' == $group->status ) {
|
805 |
-
|
806 |
-
check_ajax_referer( 'groups_join_group' );
|
807 |
-
|
808 |
-
if ( !groups_join_group( $group->id ) ) {
|
809 |
-
_e( 'Error joining group', 'buddypress' );
|
810 |
-
} else {
|
811 |
-
echo '<a id="group-' . attribute_escape( $group->id ) . '" class="leave-group" rel="leave" title="' . __( 'Leave Group', 'buddypress' ) . '" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . '/leave-group', 'groups_leave_group' ) . '">' . __( 'Leave Group', 'buddypress' ) . '</a>';
|
812 |
-
}
|
813 |
-
|
814 |
-
} else if ( 'private' == $group->status ) {
|
815 |
-
|
816 |
-
check_ajax_referer( 'groups_request_membership' );
|
817 |
-
|
818 |
-
if ( !groups_send_membership_request( $bp->loggedin_user->id, $group->id ) ) {
|
819 |
-
_e( 'Error requesting membership', 'buddypress' );
|
820 |
-
} else {
|
821 |
-
echo '<a id="group-' . attribute_escape( $group->id ) . '" class="membership-requested" rel="membership-requested" title="' . __( 'Membership Requested', 'buddypress' ) . '" href="' . bp_get_group_permalink( $group ) . '">' . __( 'Membership Requested', 'buddypress' ) . '</a>';
|
822 |
-
}
|
823 |
-
}
|
824 |
-
|
825 |
-
} else {
|
826 |
-
|
827 |
-
check_ajax_referer( 'groups_leave_group' );
|
828 |
-
|
829 |
-
if ( !groups_leave_group( $group->id ) ) {
|
830 |
-
_e( 'Error leaving group', 'buddypress' );
|
831 |
-
} else {
|
832 |
-
if ( 'public' == $group->status ) {
|
833 |
-
echo '<a id="group-' . attribute_escape( $group->id ) . '" class="join-group" rel="join" title="' . __( 'Join Group', 'buddypress' ) . '" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . '/join', 'groups_join_group' ) . '">' . __( 'Join Group', 'buddypress' ) . '</a>';
|
834 |
-
} else if ( 'private' == $group->status ) {
|
835 |
-
echo '<a id="group-' . attribute_escape( $group->id ) . '" class="request-membership" rel="join" title="' . __( 'Request Membership', 'buddypress' ) . '" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . '/request-membership', 'groups_send_membership_request' ) . '">' . __( 'Request Membership', 'buddypress' ) . '</a>';
|
836 |
-
}
|
837 |
-
}
|
838 |
-
}
|
839 |
-
}
|
840 |
-
add_action( 'wp_ajax_joinleave_group', 'groups_ajax_joinleave_group' );
|
841 |
-
|
842 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bp-groups/deprecated/css/structure.css
DELETED
@@ -1,38 +0,0 @@
|
|
1 |
-
/*
|
2 |
-
Basic layout structure styles for BuddyPress Friends. Formats BuddyPress friend pages within any WordPress theme.
|
3 |
-
No colors, fonts or pretty stuff. The only exception is buttons.
|
4 |
-
|
5 |
-
These structure styles can be overridden by the theme CSS file if needed.
|
6 |
-
*/
|
7 |
-
|
8 |
-
.group-button {
|
9 |
-
background: url(../../../bp-core/deprecated/images/button_back.gif) top left no-repeat;
|
10 |
-
display: inline-block;
|
11 |
-
margin: 10px 0;
|
12 |
-
}
|
13 |
-
|
14 |
-
.group-button a {
|
15 |
-
display: block;
|
16 |
-
height: 19px;
|
17 |
-
color: #777;
|
18 |
-
font-size: 11px;
|
19 |
-
padding: 0 33px 0 11px;
|
20 |
-
margin-right: -7px;
|
21 |
-
text-shadow: 0 1px 0 #fff;
|
22 |
-
}
|
23 |
-
.group-button a:hover {
|
24 |
-
color: #555;
|
25 |
-
text-decoration: none;
|
26 |
-
}
|
27 |
-
|
28 |
-
.group-button a.join-group, .group-button a.request-membership {
|
29 |
-
background: url(../../../bp-core/deprecated/images/add_button_side.gif) top right no-repeat;
|
30 |
-
}
|
31 |
-
|
32 |
-
.group-button a.leave-group {
|
33 |
-
background: url(../../../bp-core/deprecated/images/remove_button_side.gif) top right no-repeat;
|
34 |
-
}
|
35 |
-
|
36 |
-
.group-button a.membership-requested {
|
37 |
-
background: url(../../../bp-core/deprecated/images/check_button_side.gif) top right no-repeat;
|
38 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bp-groups/deprecated/images/ajax-loader.gif
DELETED
Binary file
|
bp-groups/deprecated/images/none-thumbnail.gif
DELETED
Binary file
|
bp-groups/deprecated/images/none.gif
DELETED
Binary file
|
bp-groups/deprecated/js/directory-groups.js
DELETED
@@ -1,138 +0,0 @@
|
|
1 |
-
jQuery(document).ready( function() {
|
2 |
-
jQuery("ul#letter-list li a").livequery('click',
|
3 |
-
function() {
|
4 |
-
jQuery('#ajax-loader-groups').toggle();
|
5 |
-
|
6 |
-
jQuery("div#groups-list-options a").removeClass("selected");
|
7 |
-
jQuery(this).addClass('selected');
|
8 |
-
jQuery("input#groups_search").val('');
|
9 |
-
|
10 |
-
var letter = jQuery(this).attr('id')
|
11 |
-
letter = letter.split('-');
|
12 |
-
|
13 |
-
jQuery.post( ajaxurl, {
|
14 |
-
action: 'directory_groups',
|
15 |
-
'cookie': encodeURIComponent(document.cookie),
|
16 |
-
'_wpnonce': jQuery("input#_wpnonce-group-filter").val(),
|
17 |
-
'letter': letter[1],
|
18 |
-
'page': 1
|
19 |
-
},
|
20 |
-
function(response)
|
21 |
-
{
|
22 |
-
response = response.substr(0, response.length-1);
|
23 |
-
jQuery("#group-dir-list").fadeOut(200,
|
24 |
-
function() {
|
25 |
-
jQuery('#ajax-loader-groups').toggle();
|
26 |
-
jQuery("#group-dir-list").html(response);
|
27 |
-
jQuery("#group-dir-list").fadeIn(200);
|
28 |
-
}
|
29 |
-
);
|
30 |
-
});
|
31 |
-
|
32 |
-
return false;
|
33 |
-
}
|
34 |
-
);
|
35 |
-
|
36 |
-
jQuery("form#search-groups-form").submit( function() {
|
37 |
-
jQuery('#ajax-loader-groups').toggle();
|
38 |
-
|
39 |
-
jQuery.post( ajaxurl, {
|
40 |
-
action: 'directory_groups',
|
41 |
-
'cookie': encodeURIComponent(document.cookie),
|
42 |
-
'_wpnonce': jQuery("input#_wpnonce-group-filter").val(),
|
43 |
-
's': jQuery("input#groups_search").val(),
|
44 |
-
'page': 1
|
45 |
-
},
|
46 |
-
function(response)
|
47 |
-
{
|
48 |
-
response = response.substr(0, response.length-1);
|
49 |
-
jQuery("#group-dir-list").fadeOut(200,
|
50 |
-
function() {
|
51 |
-
jQuery('#ajax-loader-groups').toggle();
|
52 |
-
jQuery("#group-dir-list").html(response);
|
53 |
-
jQuery("#group-dir-list").fadeIn(200);
|
54 |
-
}
|
55 |
-
);
|
56 |
-
});
|
57 |
-
|
58 |
-
return false;
|
59 |
-
}
|
60 |
-
);
|
61 |
-
|
62 |
-
jQuery("div#group-dir-pag a").livequery('click',
|
63 |
-
function() {
|
64 |
-
jQuery('#ajax-loader-groups').toggle();
|
65 |
-
|
66 |
-
var page = jQuery(this).attr('href');
|
67 |
-
page = page.split('gpage=');
|
68 |
-
|
69 |
-
if ( !jQuery("input#selected_letter").val() )
|
70 |
-
var letter = '';
|
71 |
-
else
|
72 |
-
var letter = jQuery("input#selected_letter").val();
|
73 |
-
|
74 |
-
if ( !jQuery("input#search_terms").val() )
|
75 |
-
var search_terms = '';
|
76 |
-
else
|
77 |
-
var search_terms = jQuery("input#search_terms").val();
|
78 |
-
|
79 |
-
jQuery.post( ajaxurl, {
|
80 |
-
action: 'directory_groups',
|
81 |
-
'cookie': encodeURIComponent(document.cookie),
|
82 |
-
'_wpnonce': jQuery("input#_wpnonce").val(),
|
83 |
-
'gpage': page[1],
|
84 |
-
'_wpnonce': jQuery("input#_wpnonce-group-filter").val(),
|
85 |
-
|
86 |
-
'letter': letter,
|
87 |
-
's': search_terms
|
88 |
-
},
|
89 |
-
function(response)
|
90 |
-
{
|
91 |
-
response = response.substr(0, response.length-1);
|
92 |
-
jQuery("#group-dir-list").fadeOut(200,
|
93 |
-
function() {
|
94 |
-
jQuery('#ajax-loader-groups').toggle();
|
95 |
-
jQuery("#group-dir-list").html(response);
|
96 |
-
jQuery("#group-dir-list").fadeIn(200);
|
97 |
-
}
|
98 |
-
);
|
99 |
-
});
|
100 |
-
|
101 |
-
return false;
|
102 |
-
}
|
103 |
-
);
|
104 |
-
|
105 |
-
jQuery("div.group-button a").livequery('click',
|
106 |
-
function() {
|
107 |
-
var gid = jQuery(this).parent().attr('id');
|
108 |
-
gid = gid.split('-');
|
109 |
-
gid = gid[1];
|
110 |
-
|
111 |
-
var nonce = jQuery(this).attr('href');
|
112 |
-
nonce = nonce.split('?_wpnonce=');
|
113 |
-
nonce = nonce[1].split('&');
|
114 |
-
nonce = nonce[0];
|
115 |
-
|
116 |
-
var thelink = jQuery(this);
|
117 |
-
|
118 |
-
jQuery.post( ajaxurl, {
|
119 |
-
action: 'joinleave_group',
|
120 |
-
'cookie': encodeURIComponent(document.cookie),
|
121 |
-
'gid': gid,
|
122 |
-
'_wpnonce': nonce
|
123 |
-
},
|
124 |
-
function(response)
|
125 |
-
{
|
126 |
-
response = response.substr(0, response.length-1);
|
127 |
-
var parentdiv = thelink.parent();
|
128 |
-
|
129 |
-
jQuery(parentdiv).fadeOut(200,
|
130 |
-
function() {
|
131 |
-
parentdiv.fadeIn(200).html(response);
|
132 |
-
}
|
133 |
-
);
|
134 |
-
});
|
135 |
-
return false;
|
136 |
-
}
|
137 |
-
);
|
138 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bp-groups/deprecated/js/general.js
DELETED
@@ -1,196 +0,0 @@
|
|
1 |
-
jQuery(document).ready( function() {
|
2 |
-
jQuery("form#group-search-form").submit(
|
3 |
-
function() {
|
4 |
-
return false;
|
5 |
-
}
|
6 |
-
);
|
7 |
-
|
8 |
-
jQuery("div#invite-list input").click(
|
9 |
-
function() {
|
10 |
-
jQuery('#ajax-loader').toggle();
|
11 |
-
|
12 |
-
var friend_id = jQuery(this).val();
|
13 |
-
|
14 |
-
if ( jQuery(this).attr('checked') == true ) {
|
15 |
-
var friend_action = 'invite';
|
16 |
-
} else {
|
17 |
-
var friend_action = 'uninvite';
|
18 |
-
}
|
19 |
-
|
20 |
-
jQuery.post( ajaxurl, {
|
21 |
-
action: 'groups_invite_user',
|
22 |
-
'friend_action': friend_action,
|
23 |
-
'cookie': encodeURIComponent(document.cookie),
|
24 |
-
'_wpnonce': jQuery("input#_wpnonce_invite_uninvite_user").val(),
|
25 |
-
'friend_id': friend_id,
|
26 |
-
'group_id': jQuery("input#group_id").val()
|
27 |
-
},
|
28 |
-
function(response)
|
29 |
-
{
|
30 |
-
if ( jQuery("#message") )
|
31 |
-
jQuery("#message").hide();
|
32 |
-
|
33 |
-
jQuery('#ajax-loader').toggle();
|
34 |
-
|
35 |
-
if ( friend_action == 'invite' ) {
|
36 |
-
jQuery('#friend-list').append(response);
|
37 |
-
} else if ( friend_action == 'uninvite' ) {
|
38 |
-
jQuery('#friend-list li#uid-' + friend_id).remove();
|
39 |
-
}
|
40 |
-
});
|
41 |
-
}
|
42 |
-
);
|
43 |
-
|
44 |
-
jQuery("#friend-list li a.remove").livequery('click',
|
45 |
-
function() {
|
46 |
-
jQuery('#ajax-loader').toggle();
|
47 |
-
|
48 |
-
var friend_id = jQuery(this).attr('id');
|
49 |
-
friend_id = friend_id.split('-');
|
50 |
-
friend_id = friend_id[1];
|
51 |
-
|
52 |
-
jQuery.post( ajaxurl, {
|
53 |
-
action: 'groups_invite_user',
|
54 |
-
'friend_action': 'uninvite',
|
55 |
-
'cookie': encodeURIComponent(document.cookie),
|
56 |
-
'_wpnonce': jQuery("input#_wpnonce_invite_uninvite_user").val(),
|
57 |
-
'friend_id': friend_id,
|
58 |
-
'group_id': jQuery("input#group_id").val()
|
59 |
-
},
|
60 |
-
function(response)
|
61 |
-
{
|
62 |
-
jQuery('#ajax-loader').toggle();
|
63 |
-
jQuery('#friend-list li#uid-' + friend_id).remove();
|
64 |
-
jQuery('#invite-list input#f-' + friend_id).attr('checked', false);
|
65 |
-
});
|
66 |
-
|
67 |
-
return false;
|
68 |
-
}
|
69 |
-
);
|
70 |
-
|
71 |
-
jQuery("div#pag a").livequery('click',
|
72 |
-
function() {
|
73 |
-
jQuery('#ajax-loader').toggle();
|
74 |
-
|
75 |
-
var grpage = jQuery(this).attr('href');
|
76 |
-
grpage = grpage.split('=');
|
77 |
-
|
78 |
-
jQuery.post( ajaxurl, {
|
79 |
-
action: 'group_filter',
|
80 |
-
'cookie': encodeURIComponent(document.cookie),
|
81 |
-
'_wpnonce': jQuery("input#_wpnonce_group_filter").val(),
|
82 |
-
'grpage': grpage[1],
|
83 |
-
|
84 |
-
'group-filter-box': jQuery("#group-filter-box").val()
|
85 |
-
},
|
86 |
-
function(response)
|
87 |
-
{
|
88 |
-
response = response.substr( 0, response.length - 1 );
|
89 |
-
|
90 |
-
jQuery("div#group-loop").fadeOut(200,
|
91 |
-
function() {
|
92 |
-
jQuery('#ajax-loader').toggle();
|
93 |
-
jQuery("div#group-loop").html(response);
|
94 |
-
jQuery("div#group-loop").fadeIn(200);
|
95 |
-
}
|
96 |
-
);
|
97 |
-
});
|
98 |
-
|
99 |
-
return false;
|
100 |
-
}
|
101 |
-
);
|
102 |
-
|
103 |
-
jQuery("input#group-filter-box").keyup(
|
104 |
-
function(e) {
|
105 |
-
if ( e.which == 13 ) {
|
106 |
-
jQuery('#ajax-loader').toggle();
|
107 |
-
|
108 |
-
jQuery.post( ajaxurl, {
|
109 |
-
action: 'group_filter',
|
110 |
-
'cookie': encodeURIComponent(document.cookie),
|
111 |
-
'_wpnonce': jQuery("input#_wpnonce_group_filter").val(),
|
112 |
-
|
113 |
-
'group-filter-box': jQuery("#group-filter-box").val()
|
114 |
-
},
|
115 |
-
function(response)
|
116 |
-
{
|
117 |
-
response = response.substr( 0, response.length - 1 );
|
118 |
-
|
119 |
-
jQuery("div#group-loop").fadeOut(200,
|
120 |
-
function() {
|
121 |
-
jQuery('#ajax-loader').toggle();
|
122 |
-
jQuery("div#group-loop").html(response);
|
123 |
-
jQuery("div#group-loop").fadeIn(200);
|
124 |
-
}
|
125 |
-
);
|
126 |
-
});
|
127 |
-
|
128 |
-
return false;
|
129 |
-
}
|
130 |
-
}
|
131 |
-
);
|
132 |
-
|
133 |
-
jQuery("div#member-pagination a").livequery('click',
|
134 |
-
function() {
|
135 |
-
jQuery('#ajax-loader').toggle();
|
136 |
-
|
137 |
-
var mlpage = jQuery(this).attr('href');
|
138 |
-
mlpage = mlpage.split('=');
|
139 |
-
|
140 |
-
jQuery.post( ajaxurl, {
|
141 |
-
action: 'get_group_members',
|
142 |
-
'cookie': encodeURIComponent(document.cookie),
|
143 |
-
'_wpnonce': jQuery("input#_member_pag_nonce").val(),
|
144 |
-
'group_id': jQuery("#group_id").val(),
|
145 |
-
'mlpage': mlpage[1]
|
146 |
-
},
|
147 |
-
function(response)
|
148 |
-
{
|
149 |
-
response = response.substr(0, response.length-1);
|
150 |
-
|
151 |
-
jQuery("form#group-members-form").fadeOut(200,
|
152 |
-
function() {
|
153 |
-
jQuery("form#group-members-form").html(response);
|
154 |
-
jQuery("form#group-members-form").fadeIn(200);
|
155 |
-
}
|
156 |
-
);
|
157 |
-
|
158 |
-
return false;
|
159 |
-
});
|
160 |
-
|
161 |
-
return false;
|
162 |
-
}
|
163 |
-
);
|
164 |
-
|
165 |
-
jQuery("div#member-admin-pagination a").livequery('click',
|
166 |
-
function() {
|
167 |
-
jQuery('#ajax-loader').toggle();
|
168 |
-
|
169 |
-
var mlpage = jQuery(this).attr('href');
|
170 |
-
mlpage = mlpage.split('=');
|
171 |
-
|
172 |
-
jQuery.post( ajaxurl, {
|
173 |
-
action: 'get_group_members_admin',
|
174 |
-
'cookie': encodeURIComponent(document.cookie),
|
175 |
-
'_wpnonce': jQuery("input#_member_admin_pag_nonce").val(),
|
176 |
-
'group_id': jQuery("#group_id").val(),
|
177 |
-
'mlpage': mlpage[1]
|
178 |
-
},
|
179 |
-
function(response)
|
180 |
-
{
|
181 |
-
response = response.substr(0, response.length-1);
|
182 |
-
|
183 |
-
jQuery("form#group-members-form").fadeOut(200,
|
184 |
-
function() {
|
185 |
-
jQuery("form#group-members-form").html(response);
|
186 |
-
jQuery("form#group-members-form").fadeIn(200);
|
187 |
-
}
|
188 |
-
);
|
189 |
-
|
190 |
-
return false;
|
191 |
-
});
|
192 |
-
|
193 |
-
return false;
|
194 |
-
}
|
195 |
-
);
|
196 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bp-groups/js/widget-groups.js
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
jQuery(document).ready( function() {
|
2 |
-
jQuery("div#groups-list-options a").
|
3 |
-
function() {
|
4 |
jQuery('#ajax-loader-groups').toggle();
|
5 |
|
6 |
-
jQuery("div#groups-list-options a").removeClass("selected");
|
7 |
jQuery(this).addClass('selected');
|
8 |
|
9 |
jQuery.post( ajaxurl, {
|
@@ -14,11 +14,11 @@ jQuery(document).ready( function() {
|
|
14 |
'filter': jQuery(this).attr('id')
|
15 |
},
|
16 |
function(response)
|
17 |
-
{
|
18 |
jQuery('#ajax-loader-groups').toggle();
|
19 |
groups_wiget_response(response);
|
20 |
});
|
21 |
-
|
22 |
return false;
|
23 |
}
|
24 |
);
|
@@ -29,19 +29,19 @@ function groups_wiget_response(response) {
|
|
29 |
response = response.split('[[SPLIT]]');
|
30 |
|
31 |
if ( response[0] != "-1" ) {
|
32 |
-
jQuery("ul#groups-list").fadeOut(200,
|
33 |
function() {
|
34 |
-
jQuery("ul#groups-list").html(response[1]);
|
35 |
-
jQuery("ul#groups-list").fadeIn(200);
|
36 |
}
|
37 |
);
|
38 |
|
39 |
-
} else {
|
40 |
-
jQuery("ul#groups-list").fadeOut(200,
|
41 |
function() {
|
42 |
var message = '<p>' + response[1] + '</p>';
|
43 |
-
jQuery("ul#groups-list").html(message);
|
44 |
-
jQuery("ul#groups-list").fadeIn(200);
|
45 |
}
|
46 |
);
|
47 |
}
|
1 |
jQuery(document).ready( function() {
|
2 |
+
jQuery(".widget div#groups-list-options a").live('click',
|
3 |
+
function() {
|
4 |
jQuery('#ajax-loader-groups').toggle();
|
5 |
|
6 |
+
jQuery(".widget div#groups-list-options a").removeClass("selected");
|
7 |
jQuery(this).addClass('selected');
|
8 |
|
9 |
jQuery.post( ajaxurl, {
|
14 |
'filter': jQuery(this).attr('id')
|
15 |
},
|
16 |
function(response)
|
17 |
+
{
|
18 |
jQuery('#ajax-loader-groups').toggle();
|
19 |
groups_wiget_response(response);
|
20 |
});
|
21 |
+
|
22 |
return false;
|
23 |
}
|
24 |
);
|
29 |
response = response.split('[[SPLIT]]');
|
30 |
|
31 |
if ( response[0] != "-1" ) {
|
32 |
+
jQuery(".widget ul#groups-list").fadeOut(200,
|
33 |
function() {
|
34 |
+
jQuery(".widget ul#groups-list").html(response[1]);
|
35 |
+
jQuery(".widget ul#groups-list").fadeIn(200);
|
36 |
}
|
37 |
);
|
38 |
|
39 |
+
} else {
|
40 |
+
jQuery(".widget ul#groups-list").fadeOut(200,
|
41 |
function() {
|
42 |
var message = '<p>' + response[1] + '</p>';
|
43 |
+
jQuery(".widget ul#groups-list").html(message);
|
44 |
+
jQuery(".widget ul#groups-list").fadeIn(200);
|
45 |
}
|
46 |
);
|
47 |
}
|
bp-languages/buddypress.pot
CHANGED
@@ -1,125 +1,328 @@
|
|
1 |
-
#
|
2 |
-
# Copyright (C)
|
3 |
-
# This file is distributed under the same license as the
|
4 |
-
# FIRST AUTHOR <EMAIL@ADDRESS>,
|
5 |
#
|
6 |
#, fuzzy
|
7 |
msgid ""
|
8 |
msgstr ""
|
9 |
-
"Project-Id-Version:
|
10 |
"Report-Msgid-Bugs-To: wp-polyglots@lists.automattic.com\n"
|
11 |
-
"POT-Creation-Date:
|
12 |
-
"PO-Revision-Date:
|
13 |
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
14 |
"Language-Team: LANGUAGE <LL@li.org>\n"
|
15 |
"MIME-Version: 1.0\n"
|
16 |
-
"Content-Type: text/plain; charset=
|
17 |
"Content-Transfer-Encoding: 8bit\n"
|
18 |
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
|
19 |
|
20 |
-
#: bp-activity.php:
|
|
|
|
|
21 |
msgid "Activity"
|
22 |
msgstr ""
|
23 |
|
24 |
-
#: bp-activity.php:
|
25 |
-
msgid "
|
26 |
msgstr ""
|
27 |
|
28 |
-
#: bp-activity.php:
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
msgstr ""
|
34 |
|
35 |
-
#: bp-activity.php:
|
|
|
|
|
|
|
|
|
|
|
36 |
msgid "My Activity"
|
37 |
msgstr ""
|
38 |
|
39 |
-
#: bp-activity.php:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
msgid "Activity deleted"
|
41 |
msgstr ""
|
42 |
|
43 |
-
#: bp-activity.php:
|
44 |
msgid "There was an error when deleting that activity"
|
45 |
msgstr ""
|
46 |
|
47 |
-
#: bp-activity/bp-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Translation of BuddyPress.
|
2 |
+
# Copyright (C) 2010 BuddyPress
|
3 |
+
# This file is distributed under the same license as the BuddyPress package.
|
4 |
+
# FIRST AUTHOR <EMAIL@ADDRESS>, 2010.
|
5 |
#
|
6 |
#, fuzzy
|
7 |
msgid ""
|
8 |
msgstr ""
|
9 |
+
"Project-Id-Version: BuddyPress \n"
|
10 |
"Report-Msgid-Bugs-To: wp-polyglots@lists.automattic.com\n"
|
11 |
+
"POT-Creation-Date: 2010-02-15 14:11+0000\n"
|
12 |
+
"PO-Revision-Date: 2010-MO-DA HO:MI+ZONE\n"
|
13 |
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
14 |
"Language-Team: LANGUAGE <LL@li.org>\n"
|
15 |
"MIME-Version: 1.0\n"
|
16 |
+
"Content-Type: text/plain; charset=utf-8\n"
|
17 |
"Content-Transfer-Encoding: 8bit\n"
|
18 |
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
|
19 |
|
20 |
+
#: bp-activity.php:111 bp-activity.php:264
|
21 |
+
#: bp-activity/feeds/bp-activity-personal-feed.php:21
|
22 |
+
#: bp-themes/bp-default/header.php:53
|
23 |
msgid "Activity"
|
24 |
msgstr ""
|
25 |
|
26 |
+
#: bp-activity.php:118
|
27 |
+
msgid "Personal"
|
28 |
msgstr ""
|
29 |
|
30 |
+
#: bp-activity.php:121 bp-core/bp-core-admin.php:201 bp-friends.php:146
|
31 |
+
msgid "Friends"
|
32 |
+
msgstr ""
|
33 |
+
|
34 |
+
#: bp-activity.php:124 bp-core/bp-core-admin.php:210
|
35 |
+
#: bp-core/bp-core-templatetags.php:992 bp-groups.php:960 bp-groups.php:1340
|
36 |
+
#: bp-groups.php:1353 bp-groups.php:1367 bp-groups.php:1380
|
37 |
+
#: bp-groups/bp-groups-widgets.php:13 bp-themes/bp-default/header.php:63
|
38 |
+
msgid "Groups"
|
39 |
+
msgstr ""
|
40 |
+
|
41 |
+
#: bp-activity.php:126 bp-forums/bbpress/bb-includes/functions.bb-core.php:847
|
42 |
+
#: bp-forums/bbpress/bb-templates/kakumei/favorites.php:3
|
43 |
+
msgid "Favorites"
|
44 |
msgstr ""
|
45 |
|
46 |
+
#: bp-activity.php:127 bp-themes/bp-default/activity/index.php:50
|
47 |
+
#, php-format
|
48 |
+
msgid "@%s Mentions"
|
49 |
+
msgstr ""
|
50 |
+
|
51 |
+
#: bp-activity.php:131
|
52 |
msgid "My Activity"
|
53 |
msgstr ""
|
54 |
|
55 |
+
#: bp-activity.php:250
|
56 |
+
msgid "You do not have access to this activity."
|
57 |
+
msgstr ""
|
58 |
+
|
59 |
+
#: bp-activity.php:265 bp-blogs/bp-blogs-templatetags.php:403
|
60 |
+
#: bp-core/bp-core-admin.php:60 bp-core/bp-core-admin.php:68
|
61 |
+
#: bp-core/bp-core-admin.php:75 bp-core/bp-core-admin.php:82
|
62 |
+
#: bp-core/bp-core-admin.php:90 bp-core/bp-core-admin.php:99
|
63 |
+
#: bp-friends.php:147 bp-groups.php:961 bp-messages.php:244
|
64 |
+
#: bp-themes/bp-default/groups/single/admin.php:26
|
65 |
+
#: bp-themes/bp-default/registration/register.php:195
|
66 |
+
#: bp-xprofile/bp-xprofile-admin.php:93
|
67 |
+
msgid "Yes"
|
68 |
+
msgstr ""
|
69 |
+
|
70 |
+
#: bp-activity.php:266 bp-blogs/bp-blogs-templatetags.php:407
|
71 |
+
#: bp-core/bp-core-admin.php:61 bp-core/bp-core-admin.php:69
|
72 |
+
#: bp-core/bp-core-admin.php:76 bp-core/bp-core-admin.php:83
|
73 |
+
#: bp-core/bp-core-admin.php:91 bp-core/bp-core-admin.php:100
|
74 |
+
#: bp-friends.php:148 bp-groups.php:962 bp-messages.php:245
|
75 |
+
#: bp-themes/bp-default/groups/single/admin.php:27
|
76 |
+
#: bp-themes/bp-default/registration/register.php:196
|
77 |
+
msgid "No"
|
78 |
+
msgstr ""
|
79 |
+
|
80 |
+
#: bp-activity.php:271
|
81 |
+
#, php-format
|
82 |
+
msgid "A member mentions you in an update using \"@%s\""
|
83 |
+
msgstr ""
|
84 |
+
|
85 |
+
#: bp-activity.php:277
|
86 |
+
msgid "A member replies to an update or comment you've posted"
|
87 |
+
msgstr ""
|
88 |
+
|
89 |
+
#: bp-activity.php:352
|
90 |
msgid "Activity deleted"
|
91 |
msgstr ""
|
92 |
|
93 |
+
#: bp-activity.php:354
|
94 |
msgid "There was an error when deleting that activity"
|
95 |
msgstr ""
|
96 |
|
97 |
+
#: bp-activity.php:376 bp-themes/bp-default/_inc/ajax.php:124
|
98 |
+
msgid "Please enter some content to post."
|
99 |
+
msgstr ""
|
100 |
+
|
101 |
+
#: bp-activity.php:391
|
102 |
+
msgid "Update Posted!"
|
103 |
+
msgstr ""
|
104 |
+
|
105 |
+
#: bp-activity.php:393
|
106 |
+
msgid "There was an error when posting your update, please try again."
|
107 |
+
msgstr ""
|
108 |
+
|
109 |
+
#: bp-activity.php:412 bp-themes/bp-default/_inc/ajax.php:162
|
110 |
+
msgid "Please do not leave the comment area blank."
|
111 |
+
msgstr ""
|
112 |
+
|
113 |
+
#: bp-activity.php:423
|
114 |
+
msgid "Reply Posted!"
|
115 |
+
msgstr ""
|
116 |
+
|
117 |
+
#: bp-activity.php:425 bp-themes/bp-default/_inc/ajax.php:167
|
118 |
+
#: bp-themes/bp-default/_inc/ajax.php:178
|
119 |
+
msgid "There was an error posting that reply, please try again."
|
120 |
+
msgstr ""
|
121 |
+
|
122 |
+
#: bp-activity.php:441
|
123 |
+
msgid "Activity marked as favorite."
|
124 |
+
msgstr ""
|
125 |
+
|
126 |
+
#: bp-activity.php:443
|
127 |
+
msgid ""
|
128 |
+
"There was an error marking that activity as a favorite, please try again."
|
129 |
+
msgstr ""
|
130 |
+
|
131 |
+
#: bp-activity.php:459
|
132 |
+
msgid "Activity removed as favorite."
|
133 |
+
msgstr ""
|
134 |
+
|
135 |
+
#: bp-activity.php:461
|
136 |
+
msgid ""
|
137 |
+
"There was an error removing that activity as a favorite, please try again."
|
138 |
+
msgstr ""
|
139 |
+
|
140 |
+
#: bp-activity.php:687
|
141 |
+
#, php-format
|
142 |
+
msgid "%s posted an update:"
|
143 |
+
msgstr ""
|
144 |
+
|
145 |
+
#: bp-activity.php:738
|
146 |
+
#, php-format
|
147 |
+
msgid "%s posted a new activity comment:"
|
148 |
+
msgstr ""
|
149 |
+
|
150 |
+
#: bp-activity.php:952
|
151 |
+
msgid "Thumbnail"
|
152 |
+
msgstr ""
|
153 |
+
|
154 |
+
#: bp-activity/bp-activity-notifications.php:31
|
155 |
+
#, php-format
|
156 |
+
msgid "%s mentioned you in an update"
|
157 |
+
msgstr ""
|
158 |
+
|
159 |
+
#: bp-activity/bp-activity-notifications.php:34
|
160 |
+
#, php-format
|
161 |
+
msgid ""
|
162 |
+
"%s mentioned you in an update:\n"
|
163 |
+
"\n"
|
164 |
+
"\"%s\"\n"
|
165 |
+
"\n"
|
166 |
+
"To view and respond to the message, log in and visit: %s\n"
|
167 |
+
"\n"
|
168 |
+
"---------------------\n"
|
169 |
+
msgstr ""
|
170 |
+
|
171 |
+
#: bp-activity/bp-activity-notifications.php:43
|
172 |
+
#: bp-activity/bp-activity-notifications.php:86
|
173 |
+
#: bp-activity/bp-activity-notifications.php:128
|
174 |
+
#: bp-friends/bp-friends-notifications.php:33
|
175 |
+
#: bp-friends/bp-friends-notifications.php:70
|
176 |
+
#: bp-groups/bp-groups-notifications.php:29
|
177 |
+
#: bp-groups/bp-groups-notifications.php:77
|
178 |
+
#: bp-groups/bp-groups-notifications.php:130
|
179 |
+
#: bp-groups/bp-groups-notifications.php:176
|
180 |
+
#: bp-groups/bp-groups-notifications.php:228
|
181 |
+
#: bp-groups/bp-groups-notifications.php:285
|
182 |
+
#: bp-messages/bp-messages-notifications.php:36
|
183 |
+
#, php-format
|
184 |
+
msgid "To disable these notifications please log in and go to: %s"
|
185 |
+
msgstr ""
|
186 |
+
|
187 |
+
#: bp-activity/bp-activity-notifications.php:74
|
188 |
+
#, php-format
|
189 |
+
msgid "%s replie
|