Version Description
= 1.8.1 = See: http://codex.buddypress.org/releases/version-1-8-1/
= 1.8 = See: http://codex.buddypress.org/releases/version-1-8/
= 1.7.3 = See: http://codex.buddypress.org/releases/version-1-7-3/
= 1.7.2 = See: http://codex.buddypress.org/releases/version-1-7-2/
= 1.7.1 = See: http://codex.buddypress.org/releases/version-1-7-1/
= 1.7 = See: http://codex.buddypress.org/releases/version-1-7/
= 1.6.5 = See: http://codex.buddypress.org/releases/version-1-6-5/
= 1.6.4 = See: http://codex.buddypress.org/releases/version-1-6-4/
= 1.6.3 = See: http://codex.buddypress.org/releases/version-1-6-3/
= 1.6.2 = Compatibility with WordPress 3.5
= 1.6.1 = Fixes 4 bugs
= 1.6 = See: http://codex.buddypress.org/releases/version-1-6/
= 1.5 = See: http://codex.buddypress.org/releases/version-1-5/
= 1.2.9 = Compatibility with WordPress 3.2
= 1.2.8 = Compatibility with WordPress 3.1
= 1.2.7 = Fixes over 10 bugs.
Release Info
Developer | boonebgorges |
Plugin | BuddyPress |
Version | 1.9-beta2 |
Comparing to | |
See all releases |
Code changes from version 1.9-beta1 to 1.9-beta2
- .travis.yml +52 -0
- bp-activity/bp-activity-functions.php +10 -64
- bp-activity/bp-activity-notifications.php +123 -8
- bp-activity/bp-activity-screens.php +0 -14
- bp-core/admin/bp-core-components.php +1 -1
- bp-core/admin/bp-core-functions.php +21 -11
- bp-core/bp-core-admin.php +48 -50
- bp-core/bp-core-classes.php +6 -2
- bp-core/bp-core-filters.php +5 -0
- bp-friends/bp-friends-activity.php +55 -68
- bp-friends/bp-friends-cache.php +0 -11
- bp-friends/bp-friends-functions.php +29 -72
- bp-friends/bp-friends-notifications.php +200 -4
- bp-friends/bp-friends-screens.php +0 -7
- bp-groups/bp-groups-activity.php +77 -232
- bp-groups/bp-groups-classes.php +23 -17
- bp-groups/bp-groups-forums.php +3 -0
- bp-groups/bp-groups-functions.php +32 -61
- bp-groups/bp-groups-notifications.php +352 -7
- bp-groups/bp-groups-screens.php +8 -30
- bp-languages/buddypress.pot +346 -351
- bp-loader.php +3 -3
- bp-members/bp-members-adminbar.php +16 -16
- bp-members/bp-members-notifications.php +54 -88
- bp-messages/bp-messages-functions.php +0 -53
- bp-messages/bp-messages-notifications.php +115 -5
- bp-messages/bp-messages-template.php +0 -4
- bp-notifications/bp-notifications-adminbar.php +2 -2
- bp-notifications/bp-notifications-buddybar.php +4 -4
- bp-notifications/bp-notifications-functions.php +1 -1
- bp-notifications/bp-notifications-loader.php +7 -6
- bp-notifications/bp-notifications-template.php +1 -1
- bp-settings/bp-settings-loader.php +1 -1
- bp-templates/bp-legacy/css/buddypress.css +44 -6
- bp-templates/bp-legacy/js/buddypress.js +1 -1
- bp-themes/bp-default/_inc/global.js +1 -1
- bp-themes/bp-default/rtl.css +1 -1
- bp-themes/bp-default/style.css +1 -1
- bp-xprofile/bp-xprofile-functions.php +1 -1
- bp-xprofile/bp-xprofile-template.php +7 -9
- readme.txt +4 -4
- tests/assets/group-extensions.php +148 -0
- tests/bootstrap.php +55 -0
- tests/includes/factory.php +165 -0
- tests/includes/install.php +74 -0
- tests/includes/loader.php +6 -0
- tests/includes/testcase.php +317 -0
- tests/multisite.xml +17 -0
- tests/phpunit.xml +14 -0
- tests/testcases/activity/class.BP_Activity_Activity.php +308 -0
- tests/testcases/activity/functions.php +208 -0
- tests/testcases/activity/template.php +256 -0
- tests/testcases/admin/functions.php +123 -0
- tests/testcases/blogs/class-bp-blogs-blog.php +67 -0
- tests/testcases/core/avatars.php +56 -0
- tests/testcases/core/class-bp-core-user.php +124 -0
- tests/testcases/core/class-bp-user-query.php +301 -0
- tests/testcases/core/functions.php +258 -0
- tests/testcases/friends/class-bp-friends-friendship.php +126 -0
- tests/testcases/groups/class-bp-group-extension.php +225 -0
- tests/testcases/groups/class-bp-group-member-query.php +337 -0
- tests/testcases/groups/class-bp-groups-group.php +657 -0
- tests/testcases/groups/class-bp-groups-member.php +131 -0
- tests/testcases/groups/functions.php +288 -0
- tests/testcases/groups/template.php +410 -0
- tests/testcases/members/functions.php +79 -0
- tests/testcases/members/template.php +102 -0
- tests/testcases/routing/activity.php +68 -0
- tests/testcases/routing/anonymous.php +29 -0
- tests/testcases/routing/core.php +31 -0
- tests/testcases/routing/friends.php +30 -0
- tests/testcases/routing/groups.php +30 -0
- tests/testcases/routing/members.php +30 -0
- tests/testcases/routing/messages.php +40 -0
- tests/testcases/routing/settings.php +40 -0
- tests/testcases/routing/xprofile.php +35 -0
- tests/testcases/url/url.php +65 -0
- tests/testcases/xprofile/class-bp-xprofile-field.php +29 -0
- tests/testcases/xprofile/functions.php +83 -0
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
language: php
|
2 |
+
|
3 |
+
php:
|
4 |
+
- 5.2
|
5 |
+
- 5.3
|
6 |
+
- 5.4
|
7 |
+
- 5.5
|
8 |
+
|
9 |
+
env:
|
10 |
+
- WP_VERSION=master WP_MULTISITE=0
|
11 |
+
- WP_VERSION=3.7.1 WP_MULTISITE=0
|
12 |
+
- WP_VERSION=3.6.1 WP_MULTISITE=0
|
13 |
+
- WP_VERSION=3.5.2 WP_MULTISITE=0
|
14 |
+
- WP_VERSION=master WP_MULTISITE=1
|
15 |
+
- WP_VERSION=3.7.1 WP_MULTISITE=1
|
16 |
+
- WP_VERSION=3.6.1 WP_MULTISITE=1
|
17 |
+
- WP_VERSION=3.5.2 WP_MULTISITE=1
|
18 |
+
|
19 |
+
before_script:
|
20 |
+
# set up WP install
|
21 |
+
- WP_CORE_DIR=/tmp/wordpress/
|
22 |
+
- wget -nv -O /tmp/wordpress.tar.gz https://github.com/WordPress/WordPress/tarball/$WP_VERSION
|
23 |
+
- mkdir -p $WP_CORE_DIR
|
24 |
+
- tar --strip-components=1 -zxmf /tmp/wordpress.tar.gz -C $WP_CORE_DIR
|
25 |
+
- plugin_slug=$(basename $(pwd))
|
26 |
+
- plugin_dir=$WP_CORE_DIR/wp-content/plugins/$plugin_slug
|
27 |
+
- cd ..
|
28 |
+
- mv $plugin_slug $plugin_dir
|
29 |
+
# set up testing suite
|
30 |
+
- export WP_TESTS_DIR=/tmp/wordpress-tests/
|
31 |
+
- svn co --ignore-externals http://unit-tests.svn.wordpress.org/trunk/ $WP_TESTS_DIR
|
32 |
+
- cd $WP_TESTS_DIR
|
33 |
+
- cp wp-tests-config-sample.php wp-tests-config.php
|
34 |
+
- sed -i "s:dirname( __FILE__ ) . '/wordpress/':'$WP_CORE_DIR':" wp-tests-config.php
|
35 |
+
- sed -i "s/yourdbnamehere/wordpress_test/" wp-tests-config.php
|
36 |
+
- sed -i "s/yourusernamehere/root/" wp-tests-config.php
|
37 |
+
- sed -i "s/yourpasswordhere//" wp-tests-config.php
|
38 |
+
# set up database
|
39 |
+
- mysql -e 'CREATE DATABASE wordpress_test;' -uroot
|
40 |
+
# prepare for running the tests
|
41 |
+
- cd $plugin_dir/tests
|
42 |
+
|
43 |
+
script: phpunit
|
44 |
+
|
45 |
+
notifications:
|
46 |
+
email: false
|
47 |
+
|
48 |
+
irc:
|
49 |
+
channels:
|
50 |
+
- "irc.freenode.net#buddypress-dev"
|
51 |
+
template:
|
52 |
+
- "Build %{build_number} (%{branch} - %{commit}): %{message} %{build_url}"
|
@@ -190,59 +190,6 @@ function bp_activity_update_mention_count_for_user( $user_id, $activity_id, $act
|
|
190 |
return true;
|
191 |
}
|
192 |
|
193 |
-
/**
|
194 |
-
* Format notifications related to activity.
|
195 |
-
*
|
196 |
-
* @since BuddyPress (1.5)
|
197 |
-
*
|
198 |
-
* @uses bp_loggedin_user_domain()
|
199 |
-
* @uses bp_get_activity_slug()
|
200 |
-
* @uses bp_core_get_user_displayname()
|
201 |
-
* @uses apply_filters() To call the 'bp_activity_multiple_at_mentions_notification' hook.
|
202 |
-
* @uses apply_filters() To call the 'bp_activity_single_at_mentions_notification' hook.
|
203 |
-
* @uses do_action() To call 'activity_format_notifications' hook.
|
204 |
-
*
|
205 |
-
* @param string $action The type of activity item. Just 'new_at_mention' for now.
|
206 |
-
* @param int $item_id The activity ID.
|
207 |
-
* @param int $secondary_item_id In the case of at-mentions, this is the mentioner's ID.
|
208 |
-
* @param int $total_items The total number of notifications to format.
|
209 |
-
* @param string $format 'string' to get a BuddyBar-compatible notification, 'array' otherwise.
|
210 |
-
* @return string $return Formatted @mention notification.
|
211 |
-
*/
|
212 |
-
function bp_activity_format_notifications( $action, $item_id, $secondary_item_id, $total_items, $format = 'string' ) {
|
213 |
-
|
214 |
-
switch ( $action ) {
|
215 |
-
case 'new_at_mention':
|
216 |
-
$activity_id = $item_id;
|
217 |
-
$poster_user_id = $secondary_item_id;
|
218 |
-
$at_mention_link = bp_loggedin_user_domain() . bp_get_activity_slug() . '/mentions/';
|
219 |
-
$at_mention_title = sprintf( __( '@%s Mentions', 'buddypress' ), bp_get_loggedin_user_username() );
|
220 |
-
|
221 |
-
if ( (int) $total_items > 1 ) {
|
222 |
-
$text = sprintf( __( 'You have %1$d new mentions', 'buddypress' ), (int) $total_items );
|
223 |
-
$filter = 'bp_activity_multiple_at_mentions_notification';
|
224 |
-
} else {
|
225 |
-
$user_fullname = bp_core_get_user_displayname( $poster_user_id );
|
226 |
-
$text = sprintf( __( '%1$s mentioned you', 'buddypress' ), $user_fullname );
|
227 |
-
$filter = 'bp_activity_single_at_mentions_notification';
|
228 |
-
}
|
229 |
-
break;
|
230 |
-
}
|
231 |
-
|
232 |
-
if ( 'string' == $format ) {
|
233 |
-
$return = apply_filters( $filter, '<a href="' . $at_mention_link . '" title="' . $at_mention_title . '">' . $text . '</a>', $at_mention_link, (int) $total_items, $activity_id, $poster_user_id );
|
234 |
-
} else {
|
235 |
-
$return = apply_filters( $filter, array(
|
236 |
-
'text' => $text,
|
237 |
-
'link' => $at_mention_link
|
238 |
-
), $at_mention_link, (int) $total_items, $activity_id, $poster_user_id );
|
239 |
-
}
|
240 |
-
|
241 |
-
do_action( 'activity_format_notifications', $action, $item_id, $secondary_item_id, $total_items );
|
242 |
-
|
243 |
-
return $return;
|
244 |
-
}
|
245 |
-
|
246 |
/**
|
247 |
* Determine a user's "mentionname", the name used for that user in @-mentions.
|
248 |
*
|
@@ -1266,27 +1213,29 @@ function bp_activity_post_update( $args = '' ) {
|
|
1266 |
* @return int|bool The ID of the comment on success, otherwise false.
|
1267 |
*/
|
1268 |
function bp_activity_new_comment( $args = '' ) {
|
1269 |
-
global $bp;
|
1270 |
|
1271 |
-
$
|
1272 |
'id' => false,
|
1273 |
'content' => false,
|
1274 |
'user_id' => bp_loggedin_user_id(),
|
1275 |
'activity_id' => false, // ID of the root activity item
|
1276 |
'parent_id' => false // ID of a parent comment (optional)
|
1277 |
-
);
|
1278 |
|
1279 |
-
$params = wp_parse_args( $args, $defaults );
|
1280 |
extract( $params, EXTR_SKIP );
|
1281 |
|
1282 |
-
|
|
|
1283 |
return false;
|
|
|
1284 |
|
1285 |
-
|
|
|
1286 |
$parent_id = $activity_id;
|
|
|
1287 |
|
1288 |
// Check to see if the parent activity is hidden, and if so, hide this comment publically.
|
1289 |
-
$activity
|
1290 |
$is_hidden = ( (int) $activity->hide_sitewide ) ? 1 : 0;
|
1291 |
|
1292 |
// Insert the activity comment
|
@@ -1294,7 +1243,7 @@ function bp_activity_new_comment( $args = '' ) {
|
|
1294 |
'id' => $id,
|
1295 |
'action' => apply_filters( 'bp_activity_comment_action', sprintf( __( '%s posted a new activity comment', 'buddypress' ), bp_core_get_userlink( $user_id ) ) ),
|
1296 |
'content' => apply_filters( 'bp_activity_comment_content', $content ),
|
1297 |
-
'component' =>
|
1298 |
'type' => 'activity_comment',
|
1299 |
'user_id' => $user_id,
|
1300 |
'item_id' => $activity_id,
|
@@ -1302,9 +1251,6 @@ function bp_activity_new_comment( $args = '' ) {
|
|
1302 |
'hide_sitewide' => $is_hidden
|
1303 |
) );
|
1304 |
|
1305 |
-
// Send an email notification if settings allow
|
1306 |
-
bp_activity_new_comment_notification( $comment_id, $user_id, $params );
|
1307 |
-
|
1308 |
// Clear the comment cache for this activity
|
1309 |
wp_cache_delete( 'bp_activity_comments_' . $parent_id );
|
1310 |
|
190 |
return true;
|
191 |
}
|
192 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
193 |
/**
|
194 |
* Determine a user's "mentionname", the name used for that user in @-mentions.
|
195 |
*
|
1213 |
* @return int|bool The ID of the comment on success, otherwise false.
|
1214 |
*/
|
1215 |
function bp_activity_new_comment( $args = '' ) {
|
|
|
1216 |
|
1217 |
+
$params = wp_parse_args( $args, array(
|
1218 |
'id' => false,
|
1219 |
'content' => false,
|
1220 |
'user_id' => bp_loggedin_user_id(),
|
1221 |
'activity_id' => false, // ID of the root activity item
|
1222 |
'parent_id' => false // ID of a parent comment (optional)
|
1223 |
+
) );
|
1224 |
|
|
|
1225 |
extract( $params, EXTR_SKIP );
|
1226 |
|
1227 |
+
// Bail if missing necessary data
|
1228 |
+
if ( empty( $content ) || empty( $user_id ) || empty( $activity_id ) ) {
|
1229 |
return false;
|
1230 |
+
}
|
1231 |
|
1232 |
+
// Maybe set current activity ID as the parent
|
1233 |
+
if ( empty( $parent_id ) ) {
|
1234 |
$parent_id = $activity_id;
|
1235 |
+
}
|
1236 |
|
1237 |
// Check to see if the parent activity is hidden, and if so, hide this comment publically.
|
1238 |
+
$activity = new BP_Activity_Activity( $activity_id );
|
1239 |
$is_hidden = ( (int) $activity->hide_sitewide ) ? 1 : 0;
|
1240 |
|
1241 |
// Insert the activity comment
|
1243 |
'id' => $id,
|
1244 |
'action' => apply_filters( 'bp_activity_comment_action', sprintf( __( '%s posted a new activity comment', 'buddypress' ), bp_core_get_userlink( $user_id ) ) ),
|
1245 |
'content' => apply_filters( 'bp_activity_comment_content', $content ),
|
1246 |
+
'component' => buddypress()->activity->id,
|
1247 |
'type' => 'activity_comment',
|
1248 |
'user_id' => $user_id,
|
1249 |
'item_id' => $activity_id,
|
1251 |
'hide_sitewide' => $is_hidden
|
1252 |
) );
|
1253 |
|
|
|
|
|
|
|
1254 |
// Clear the comment cache for this activity
|
1255 |
wp_cache_delete( 'bp_activity_comments_' . $parent_id );
|
1256 |
|
@@ -10,12 +10,14 @@
|
|
10 |
// Exit if accessed directly
|
11 |
if ( !defined( 'ABSPATH' ) ) exit;
|
12 |
|
|
|
|
|
13 |
/**
|
14 |
* Send email and BP notifications when a user is mentioned in an update.
|
15 |
*
|
16 |
* @since BuddyPress (1.2)
|
17 |
*
|
18 |
-
* @uses
|
19 |
* @uses bp_get_user_meta()
|
20 |
* @uses bp_core_get_user_displayname()
|
21 |
* @uses bp_activity_get_permalink()
|
@@ -54,9 +56,6 @@ function bp_activity_at_message_notification( $activity_id, $receiver_user_id )
|
|
54 |
$message = '';
|
55 |
$content = '';
|
56 |
|
57 |
-
// Add the BP notification
|
58 |
-
bp_core_add_notification( $activity_id, $receiver_user_id, 'activity', 'new_at_mention', $activity->user_id );
|
59 |
-
|
60 |
// Now email the user with the contents of the message (if they have enabled email notifications)
|
61 |
if ( 'no' != bp_get_user_meta( $receiver_user_id, 'notification_activity_new_mention', true ) ) {
|
62 |
$poster_name = bp_core_get_user_displayname( $activity->user_id );
|
@@ -100,7 +99,7 @@ To view and respond to the message, log in and visit: %3$s
|
|
100 |
$message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
|
101 |
}
|
102 |
|
103 |
-
|
104 |
$to = apply_filters( 'bp_activity_at_message_notification_to', $to );
|
105 |
$subject = apply_filters( 'bp_activity_at_message_notification_subject', $subject, $poster_name );
|
106 |
$message = apply_filters( 'bp_activity_at_message_notification_message', $message, $poster_name, $content, $message_link, $settings_link );
|
@@ -108,7 +107,7 @@ To view and respond to the message, log in and visit: %3$s
|
|
108 |
wp_mail( $to, $subject, $message );
|
109 |
}
|
110 |
|
111 |
-
do_action( 'bp_activity_sent_mention_email', $activity, $subject, $message, $content );
|
112 |
}
|
113 |
|
114 |
/**
|
@@ -140,7 +139,7 @@ To view and respond to the message, log in and visit: %3$s
|
|
140 |
* @param int $commenter_id The ID of the user who posted the comment.
|
141 |
* @param array $params {@link bp_activity_new_comment()}
|
142 |
*/
|
143 |
-
function bp_activity_new_comment_notification( $comment_id, $commenter_id, $params ) {
|
144 |
|
145 |
// Set some default parameters
|
146 |
$activity_id = 0;
|
@@ -192,8 +191,9 @@ To view your original update and all comments, log in and visit: %3$s
|
|
192 |
* If this is a reply to another comment, send an email notification to the
|
193 |
* author of the immediate parent comment.
|
194 |
*/
|
195 |
-
if ( empty( $parent_id ) || ( $activity_id == $parent_id ) )
|
196 |
return false;
|
|
|
197 |
|
198 |
$parent_comment = new BP_Activity_Activity( $parent_id );
|
199 |
|
@@ -236,3 +236,118 @@ To view the original activity, your comment and all replies, log in and visit: %
|
|
236 |
do_action( 'bp_activity_sent_reply_to_reply_email', $original_activity->user_id, $subject, $message, $comment_id, $commenter_id, $params );
|
237 |
}
|
238 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
// Exit if accessed directly
|
11 |
if ( !defined( 'ABSPATH' ) ) exit;
|
12 |
|
13 |
+
/* Emails *********************************************************************/
|
14 |
+
|
15 |
/**
|
16 |
* Send email and BP notifications when a user is mentioned in an update.
|
17 |
*
|
18 |
* @since BuddyPress (1.2)
|
19 |
*
|
20 |
+
* @uses bp_notifications_add_notification()
|
21 |
* @uses bp_get_user_meta()
|
22 |
* @uses bp_core_get_user_displayname()
|
23 |
* @uses bp_activity_get_permalink()
|
56 |
$message = '';
|
57 |
$content = '';
|
58 |
|
|
|
|
|
|
|
59 |
// Now email the user with the contents of the message (if they have enabled email notifications)
|
60 |
if ( 'no' != bp_get_user_meta( $receiver_user_id, 'notification_activity_new_mention', true ) ) {
|
61 |
$poster_name = bp_core_get_user_displayname( $activity->user_id );
|
99 |
$message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
|
100 |
}
|
101 |
|
102 |
+
// Send the message
|
103 |
$to = apply_filters( 'bp_activity_at_message_notification_to', $to );
|
104 |
$subject = apply_filters( 'bp_activity_at_message_notification_subject', $subject, $poster_name );
|
105 |
$message = apply_filters( 'bp_activity_at_message_notification_message', $message, $poster_name, $content, $message_link, $settings_link );
|
107 |
wp_mail( $to, $subject, $message );
|
108 |
}
|
109 |
|
110 |
+
do_action( 'bp_activity_sent_mention_email', $activity, $subject, $message, $content, $receiver_user_id );
|
111 |
}
|
112 |
|
113 |
/**
|
139 |
* @param int $commenter_id The ID of the user who posted the comment.
|
140 |
* @param array $params {@link bp_activity_new_comment()}
|
141 |
*/
|
142 |
+
function bp_activity_new_comment_notification( $comment_id = 0, $commenter_id = 0, $params = array() ) {
|
143 |
|
144 |
// Set some default parameters
|
145 |
$activity_id = 0;
|
191 |
* If this is a reply to another comment, send an email notification to the
|
192 |
* author of the immediate parent comment.
|
193 |
*/
|
194 |
+
if ( empty( $parent_id ) || ( $activity_id == $parent_id ) ) {
|
195 |
return false;
|
196 |
+
}
|
197 |
|
198 |
$parent_comment = new BP_Activity_Activity( $parent_id );
|
199 |
|
236 |
do_action( 'bp_activity_sent_reply_to_reply_email', $original_activity->user_id, $subject, $message, $comment_id, $commenter_id, $params );
|
237 |
}
|
238 |
}
|
239 |
+
|
240 |
+
/**
|
241 |
+
* Helper method to map action arguments to function parameters
|
242 |
+
*
|
243 |
+
* @since BuddyPress (1.9.0)
|
244 |
+
* @param int $comment_id
|
245 |
+
* @param array $params
|
246 |
+
*/
|
247 |
+
function bp_activity_new_comment_notification_helper( $comment_id, $params ) {
|
248 |
+
bp_activity_new_comment_notification( $comment_id, $params['user_id'], $params );
|
249 |
+
}
|
250 |
+
add_action( 'bp_activity_comment_posted', 'bp_activity_new_comment_notification_helper', 10, 2 );
|
251 |
+
|
252 |
+
/** Notifications *************************************************************/
|
253 |
+
|
254 |
+
/**
|
255 |
+
* Format notifications related to activity.
|
256 |
+
*
|
257 |
+
* @since BuddyPress (1.5)
|
258 |
+
*
|
259 |
+
* @uses bp_loggedin_user_domain()
|
260 |
+
* @uses bp_get_activity_slug()
|
261 |
+
* @uses bp_core_get_user_displayname()
|
262 |
+
* @uses apply_filters() To call the 'bp_activity_multiple_at_mentions_notification' hook.
|
263 |
+
* @uses apply_filters() To call the 'bp_activity_single_at_mentions_notification' hook.
|
264 |
+
* @uses do_action() To call 'activity_format_notifications' hook.
|
265 |
+
*
|
266 |
+
* @param string $action The type of activity item. Just 'new_at_mention' for now.
|
267 |
+
* @param int $item_id The activity ID.
|
268 |
+
* @param int $secondary_item_id In the case of at-mentions, this is the mentioner's ID.
|
269 |
+
* @param int $total_items The total number of notifications to format.
|
270 |
+
* @param string $format 'string' to get a BuddyBar-compatible notification, 'array' otherwise.
|
271 |
+
* @return string $return Formatted @mention notification.
|
272 |
+
*/
|
273 |
+
function bp_activity_format_notifications( $action, $item_id, $secondary_item_id, $total_items, $format = 'string' ) {
|
274 |
+
|
275 |
+
switch ( $action ) {
|
276 |
+
case 'new_at_mention':
|
277 |
+
$activity_id = $item_id;
|
278 |
+
$poster_user_id = $secondary_item_id;
|
279 |
+
$at_mention_link = bp_loggedin_user_domain() . bp_get_activity_slug() . '/mentions/';
|
280 |
+
$at_mention_title = sprintf( __( '@%s Mentions', 'buddypress' ), bp_get_loggedin_user_username() );
|
281 |
+
|
282 |
+
if ( (int) $total_items > 1 ) {
|
283 |
+
$text = sprintf( __( 'You have %1$d new mentions', 'buddypress' ), (int) $total_items );
|
284 |
+
$filter = 'bp_activity_multiple_at_mentions_notification';
|
285 |
+
} else {
|
286 |
+
$user_fullname = bp_core_get_user_displayname( $poster_user_id );
|
287 |
+
$text = sprintf( __( '%1$s mentioned you', 'buddypress' ), $user_fullname );
|
288 |
+
$filter = 'bp_activity_single_at_mentions_notification';
|
289 |
+
}
|
290 |
+
break;
|
291 |
+
}
|
292 |
+
|
293 |
+
if ( 'string' == $format ) {
|
294 |
+
$return = apply_filters( $filter, '<a href="' . esc_url( $at_mention_link ) . '" title="' . esc_attr( $at_mention_title ) . '">' . esc_html( $text ) . '</a>', $at_mention_link, (int) $total_items, $activity_id, $poster_user_id );
|
295 |
+
} else {
|
296 |
+
$return = apply_filters( $filter, array(
|
297 |
+
'text' => $text,
|
298 |
+
'link' => $at_mention_link
|
299 |
+
), $at_mention_link, (int) $total_items, $activity_id, $poster_user_id );
|
300 |
+
}
|
301 |
+
|
302 |
+
do_action( 'activity_format_notifications', $action, $item_id, $secondary_item_id, $total_items );
|
303 |
+
|
304 |
+
return $return;
|
305 |
+
}
|
306 |
+
|
307 |
+
/**
|
308 |
+
* Notify a member when their nicename is mentioned in an activity stream item.
|
309 |
+
*
|
310 |
+
* Hooked to the 'bp_activity_sent_mention_email' action, we piggy back off the
|
311 |
+
* existing email code for now, since it does the heavy lifting for us. In the
|
312 |
+
* future when we separate emails from Notifications, this will need its own
|
313 |
+
* 'bp_activity_at_name_send_emails' equivalent helper function.
|
314 |
+
*
|
315 |
+
* @since BuddyPress (1.9.0)
|
316 |
+
*
|
317 |
+
* @param obj $activity
|
318 |
+
* @param string $subject (not used)
|
319 |
+
* @param string $message (not used)
|
320 |
+
* @param string $content (not used)
|
321 |
+
* @param int $receiver_user_id
|
322 |
+
*/
|
323 |
+
function bp_activity_at_mention_add_notification( $activity, $subject, $message, $content, $receiver_user_id ) {
|
324 |
+
if ( bp_is_active( 'notifications' ) ) {
|
325 |
+
bp_notifications_add_notification( array(
|
326 |
+
'user_id' => $receiver_user_id,
|
327 |
+
'item_id' => $activity->id,
|
328 |
+
'secondary_item_id' => $activity->user_id,
|
329 |
+
'component_name' => buddypress()->activity->id,
|
330 |
+
'component_action' => 'new_at_mention',
|
331 |
+
'date_notified' => bp_core_current_time(),
|
332 |
+
'is_new' => 1,
|
333 |
+
) );
|
334 |
+
}
|
335 |
+
}
|
336 |
+
add_action( 'bp_activity_sent_mention_email', 'bp_activity_at_mention_add_notification', 10, 5 );
|
337 |
+
|
338 |
+
/**
|
339 |
+
* Remove activity notifications when a user clicks on them.
|
340 |
+
*
|
341 |
+
* @since BuddyPress (1.5)
|
342 |
+
*
|
343 |
+
* @uses bp_notifications_mark_all_notifications_by_type()
|
344 |
+
*/
|
345 |
+
function bp_activity_remove_screen_notifications() {
|
346 |
+
if ( bp_is_active( 'notifications' ) ) {
|
347 |
+
bp_notifications_mark_notifications_by_type( bp_loggedin_user_id(), buddypress()->activity->id, 'new_at_mention' );
|
348 |
+
}
|
349 |
+
}
|
350 |
+
add_action( 'bp_activity_screen_my_activity', 'bp_activity_remove_screen_notifications' );
|
351 |
+
add_action( 'bp_activity_screen_single_activity_permalink', 'bp_activity_remove_screen_notifications' );
|
352 |
+
add_action( 'bp_activity_screen_mentions', 'bp_activity_remove_screen_notifications' );
|
353 |
+
|
@@ -128,20 +128,6 @@ function bp_activity_screen_mentions() {
|
|
128 |
bp_core_load_template( apply_filters( 'bp_activity_template_mention_activity', 'members/single/home' ) );
|
129 |
}
|
130 |
|
131 |
-
/**
|
132 |
-
* Remove activity notifications when a user clicks on them.
|
133 |
-
*
|
134 |
-
* @since BuddyPress (1.5)
|
135 |
-
*
|
136 |
-
* @uses bp_core_mark_all_notifications_by_type()
|
137 |
-
*/
|
138 |
-
function bp_activity_remove_screen_notifications() {
|
139 |
-
bp_core_mark_notifications_by_type( bp_loggedin_user_id(), buddypress()->activity->id, 'new_at_mention' );
|
140 |
-
}
|
141 |
-
add_action( 'bp_activity_screen_my_activity', 'bp_activity_remove_screen_notifications' );
|
142 |
-
add_action( 'bp_activity_screen_single_activity_permalink', 'bp_activity_remove_screen_notifications' );
|
143 |
-
add_action( 'bp_activity_screen_mentions', 'bp_activity_remove_screen_notifications' );
|
144 |
-
|
145 |
/**
|
146 |
* Reset the logged-in user's new mentions data when he visits his mentions screen.
|
147 |
*
|
128 |
bp_core_load_template( apply_filters( 'bp_activity_template_mention_activity', 'members/single/home' ) );
|
129 |
}
|
130 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
131 |
/**
|
132 |
* Reset the logged-in user's new mentions data when he visits his mentions screen.
|
133 |
*
|
@@ -377,7 +377,7 @@ function bp_core_admin_get_components( $type = 'all' ) {
|
|
377 |
),
|
378 |
'activity' => array(
|
379 |
'title' => __( 'Activity Streams', 'buddypress' ),
|
380 |
-
'description' => __( 'Global, personal, and group activity streams with threaded commenting, direct posting, favoriting and @mentions, all with full RSS feed and email notification support.', 'buddypress' )
|
381 |
),
|
382 |
'notifications' => array(
|
383 |
'title' => __( 'Notifications', 'buddypress' ),
|
377 |
),
|
378 |
'activity' => array(
|
379 |
'title' => __( 'Activity Streams', 'buddypress' ),
|
380 |
+
'description' => __( 'Global, personal, and group activity streams with threaded commenting, direct posting, favoriting, and @mentions, all with full RSS feed and email notification support.', 'buddypress' )
|
381 |
),
|
382 |
'notifications' => array(
|
383 |
'title' => __( 'Notifications', 'buddypress' ),
|
@@ -383,6 +383,7 @@ function bp_core_admin_tabs( $active_tab = '' ) {
|
|
383 |
|
384 |
// If forums component is active, add additional tab
|
385 |
if ( bp_is_active( 'forums' ) && class_exists( 'BP_Forums_Component' ) ) {
|
|
|
386 |
// enqueue thickbox
|
387 |
wp_enqueue_script( 'thickbox' );
|
388 |
wp_enqueue_style( 'thickbox' );
|
@@ -393,11 +394,14 @@ function bp_core_admin_tabs( $active_tab = '' ) {
|
|
393 |
);
|
394 |
}
|
395 |
|
|
|
|
|
|
|
396 |
// Loop through tabs and build navigation
|
397 |
foreach ( array_values( $tabs ) as $tab_data ) {
|
398 |
$is_current = (bool) ( $tab_data['name'] == $active_tab );
|
399 |
$tab_class = $is_current ? $active_class : $idle_class;
|
400 |
-
$tabs_html .= '<a href="' . $tab_data['href'] . '" class="' . $tab_class . '">' . $tab_data['name'] . '</a>';
|
401 |
}
|
402 |
|
403 |
// Output the tabs
|
@@ -508,25 +512,32 @@ function bp_core_add_contextual_help_content( $tab = '' ) {
|
|
508 |
|
509 |
switch ( $tab ) {
|
510 |
case 'bp-comp-overview' :
|
511 |
-
|
512 |
break;
|
513 |
|
514 |
-
case'bp-page-overview' :
|
515 |
-
|
516 |
break;
|
517 |
|
518 |
case 'bp-settings-overview' :
|
519 |
-
|
520 |
break;
|
521 |
|
522 |
case 'bp-profile-overview' :
|
523 |
-
|
524 |
break;
|
525 |
|
526 |
default:
|
527 |
-
|
528 |
break;
|
529 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
530 |
}
|
531 |
|
532 |
/** Separator *****************************************************************/
|
@@ -692,7 +703,6 @@ function bp_admin_do_wp_nav_menu_meta_box() {
|
|
692 |
$args = array( 'walker' => $walker );
|
693 |
|
694 |
$post_type_name = 'buddypress';
|
695 |
-
$current_tab = 'loggedin';
|
696 |
|
697 |
$tabs = array();
|
698 |
|
@@ -751,17 +761,17 @@ function bp_admin_do_wp_nav_menu_meta_box() {
|
|
751 |
* @since BuddyPress (1.9.0)
|
752 |
*/
|
753 |
function bp_admin_wp_nav_menu_restrict_items() {
|
754 |
-
|
755 |
<script type="text/javascript">
|
756 |
jQuery( '#menu-to-edit').on( 'click', 'a.item-edit', function() {
|
757 |
var settings = jQuery(this).closest( '.menu-item-bar' ).next( '.menu-item-settings' );
|
758 |
var css_class = settings.find( '.edit-menu-item-classes' );
|
759 |
|
760 |
-
if( css_class.val().indexOf( 'bp-menu' )
|
761 |
css_class.attr( 'readonly', 'readonly' );
|
762 |
settings.find( '.field-url' ).css( 'display', 'none' );
|
763 |
}
|
764 |
});
|
765 |
</script>
|
766 |
-
|
767 |
}
|
383 |
|
384 |
// If forums component is active, add additional tab
|
385 |
if ( bp_is_active( 'forums' ) && class_exists( 'BP_Forums_Component' ) ) {
|
386 |
+
|
387 |
// enqueue thickbox
|
388 |
wp_enqueue_script( 'thickbox' );
|
389 |
wp_enqueue_style( 'thickbox' );
|
394 |
);
|
395 |
}
|
396 |
|
397 |
+
// Allow the tabs to be filtered
|
398 |
+
$tabs = apply_filters( 'bp_core_admin_tabs', $tabs );
|
399 |
+
|
400 |
// Loop through tabs and build navigation
|
401 |
foreach ( array_values( $tabs ) as $tab_data ) {
|
402 |
$is_current = (bool) ( $tab_data['name'] == $active_tab );
|
403 |
$tab_class = $is_current ? $active_class : $idle_class;
|
404 |
+
$tabs_html .= '<a href="' . esc_url( $tab_data['href'] ) . '" class="' . esc_attr( $tab_class ) . '">' . esc_html( $tab_data['name'] ) . '</a>';
|
405 |
}
|
406 |
|
407 |
// Output the tabs
|
512 |
|
513 |
switch ( $tab ) {
|
514 |
case 'bp-comp-overview' :
|
515 |
+
$retval = __( 'By default, all BuddyPress components are enabled. You can selectively disable any of the components by using the form. 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' );
|
516 |
break;
|
517 |
|
518 |
+
case 'bp-page-overview' :
|
519 |
+
$retval = __( 'BuddyPress Components use WordPress Pages for their root directory/archive pages. Here you can change the page associations for each active component.', 'buddypress' );
|
520 |
break;
|
521 |
|
522 |
case 'bp-settings-overview' :
|
523 |
+
$retval = __( 'Extra configuration settings.', 'buddypress' );
|
524 |
break;
|
525 |
|
526 |
case 'bp-profile-overview' :
|
527 |
+
$retval = __( 'Your users will distinguish themselves through their profile page. Create relevant profile fields that will show on each users profile.</br></br>Note: Any fields in the first group will appear on the signup page.', 'buddypress' );
|
528 |
break;
|
529 |
|
530 |
default:
|
531 |
+
$retval = false;
|
532 |
break;
|
533 |
}
|
534 |
+
|
535 |
+
// Wrap text in a paragraph tag
|
536 |
+
if ( !empty( $retval ) ) {
|
537 |
+
$retval = '<p>' . $retval . '</p>';
|
538 |
+
}
|
539 |
+
|
540 |
+
return $retval;
|
541 |
}
|
542 |
|
543 |
/** Separator *****************************************************************/
|
703 |
$args = array( 'walker' => $walker );
|
704 |
|
705 |
$post_type_name = 'buddypress';
|
|
|
706 |
|
707 |
$tabs = array();
|
708 |
|
761 |
* @since BuddyPress (1.9.0)
|
762 |
*/
|
763 |
function bp_admin_wp_nav_menu_restrict_items() {
|
764 |
+
?>
|
765 |
<script type="text/javascript">
|
766 |
jQuery( '#menu-to-edit').on( 'click', 'a.item-edit', function() {
|
767 |
var settings = jQuery(this).closest( '.menu-item-bar' ).next( '.menu-item-settings' );
|
768 |
var css_class = settings.find( '.edit-menu-item-classes' );
|
769 |
|
770 |
+
if( css_class.val().indexOf( 'bp-menu' ) === 0 ) {
|
771 |
css_class.attr( 'readonly', 'readonly' );
|
772 |
settings.find( '.field-url' ).css( 'display', 'none' );
|
773 |
}
|
774 |
});
|
775 |
</script>
|
776 |
+
<?php
|
777 |
}
|
@@ -570,64 +570,62 @@ class BP_Admin {
|
|
570 |
|
571 |
<h4 class="wp-people-group"><?php _e( 'Recent Rockstars', 'buddypress' ); ?></h4>
|
572 |
<ul class="wp-people-group " id="wp-people-group-rockstars">
|
573 |
-
<li class="wp-person" id="wp-person-
|
574 |
-
<a href="http://profiles.wordpress.org/
|
575 |
-
<a class="web" href="http://profiles.wordpress.org/
|
576 |
-
|
|
|
|
|
|
|
577 |
</li>
|
578 |
<li class="wp-person" id="wp-person-mercime">
|
579 |
<a href="http://profiles.wordpress.org/mercime"><img src="http://0.gravatar.com/avatar/fae451be6708241627983570a1a1817a?s=60" class="gravatar" alt="Mercime" /></a>
|
580 |
<a class="web" href="http://profiles.wordpress.org/mercime">Mercime</a>
|
581 |
-
|
|
|
|
|
|
|
582 |
</li>
|
583 |
</ul>
|
584 |
|
585 |
-
<h4 class="wp-people-group"><?php _e( '
|
586 |
<p class="wp-credits-list">
|
587 |
-
<a href="http://profiles.wordpress.org/
|
588 |
-
<a href="http://profiles.wordpress.org/
|
589 |
-
<a href="http://profiles.wordpress.org/
|
590 |
-
<a href="http://profiles.wordpress.org/
|
591 |
-
<a href="http://profiles.wordpress.org/
|
592 |
-
<a href="http://profiles.wordpress.org/
|
593 |
-
<a href="http://profiles.wordpress.org/
|
594 |
-
<a href="http://profiles.wordpress.org/
|
595 |
-
<a href="http://profiles.wordpress.org/
|
596 |
-
<a href="http://profiles.wordpress.org/
|
597 |
-
<a href="http://profiles.wordpress.org/
|
598 |
-
<a href="http://profiles.wordpress.org/
|
599 |
-
<a href="http://profiles.wordpress.org/
|
600 |
-
<a href="http://profiles.wordpress.org/
|
601 |
-
|
602 |
-
<a href="http://profiles.wordpress.org/
|
603 |
-
<a href="http://profiles.wordpress.org/
|
604 |
-
<a href="http://profiles.wordpress.org/
|
605 |
-
<a href="http://profiles.wordpress.org/
|
606 |
-
<a href="http://profiles.wordpress.org/
|
607 |
-
<a href="http://profiles.wordpress.org/
|
608 |
-
<a href="http://profiles.wordpress.org/
|
609 |
-
<a href="http://profiles.wordpress.org/
|
610 |
-
<a href="http://profiles.wordpress.org/
|
611 |
-
<a href="http://profiles.wordpress.org/
|
612 |
-
<a href="http://profiles.wordpress.org/
|
613 |
-
<a href="http://profiles.wordpress.org/
|
614 |
-
<a href="http://profiles.wordpress.org/
|
615 |
-
<a href="http://profiles.wordpress.org/
|
616 |
-
<a href="http://profiles.wordpress.org/
|
617 |
-
<a href="http://profiles.wordpress.org/
|
618 |
-
<a href="http://profiles.wordpress.org/
|
619 |
-
<a href="http://profiles.wordpress.org/
|
620 |
-
<a href="http://profiles.wordpress.org/
|
621 |
-
<a href="http://profiles.wordpress.org/
|
622 |
-
<a href="http://profiles.wordpress.org/
|
623 |
-
<a href="http://profiles.wordpress.org/shanebp">shanebp</a>,
|
624 |
-
<a href="http://profiles.wordpress.org/splatte">splatte</a>,
|
625 |
-
<a href="http://profiles.wordpress.org/thebrandonallen">thebrandonallen</a>,
|
626 |
-
<a href="http://profiles.wordpress.org/themightymo">themightymo</a>,
|
627 |
-
<a href="http://profiles.wordpress.org/tivnet">tivnet</a>,
|
628 |
-
<a href="http://profiles.wordpress.org/trishasalas">trishasalas</a>,
|
629 |
-
<a href="http://profiles.wordpress.org/vegasgeek">vegasgeek</a>,
|
630 |
-
<a href="http://profiles.wordpress.org/wpdennis">wpdennis</a>
|
631 |
</p>
|
632 |
|
633 |
<div class="return-to-dashboard">
|
570 |
|
571 |
<h4 class="wp-people-group"><?php _e( 'Recent Rockstars', 'buddypress' ); ?></h4>
|
572 |
<ul class="wp-people-group " id="wp-people-group-rockstars">
|
573 |
+
<li class="wp-person" id="wp-person-imath">
|
574 |
+
<a href="http://profiles.wordpress.org/imath"><img src="http://0.gravatar.com/avatar/8b208ca408dad63888253ee1800d6a03?s=60" class="gravatar" alt="Mathieu Viet" /></a>
|
575 |
+
<a class="web" href="http://profiles.wordpress.org/imath">Mathieu Viet</a>
|
576 |
+
</li>
|
577 |
+
<li class="wp-person" id="wp-person-hnla">
|
578 |
+
<a href="http://profiles.wordpress.org/hnla"><img src="http://0.gravatar.com/avatar/3860c955aa3f79f13b92826ae47d07fe?s=60" class="gravatar" alt="Hugo Ashmore" /></a>
|
579 |
+
<a class="web" href="http://profiles.wordpress.org/hnla">Hugo Ashmore</a>
|
580 |
</li>
|
581 |
<li class="wp-person" id="wp-person-mercime">
|
582 |
<a href="http://profiles.wordpress.org/mercime"><img src="http://0.gravatar.com/avatar/fae451be6708241627983570a1a1817a?s=60" class="gravatar" alt="Mercime" /></a>
|
583 |
<a class="web" href="http://profiles.wordpress.org/mercime">Mercime</a>
|
584 |
+
</li>
|
585 |
+
<li class="wp-person" id="wp-person-karmatosed">
|
586 |
+
<a href="http://profiles.wordpress.org/karmatosed"><img src="http://0.gravatar.com/avatar/d36d2c1821af9249b69ff7f5ed60529b?s=60" class="gravatar" alt="Tammie Lister" /></a>
|
587 |
+
<a class="web" href="http://profiles.wordpress.org/karmatosed">Tammie Lister</a>
|
588 |
</li>
|
589 |
</ul>
|
590 |
|
591 |
+
<h4 class="wp-people-group"><?php _e( 'Contributors to BuddyPress 1.9', 'buddypress' ); ?></h4>
|
592 |
<p class="wp-credits-list">
|
593 |
+
<a href="http://profiles.wordpress.org/AliMH/">AliMH</a>,
|
594 |
+
<a href="http://profiles.wordpress.org/asakurayoh/">asakurayoh</a>,
|
595 |
+
<a href="http://profiles.wordpress.org/boonebgorges/">boonebgorges</a>,
|
596 |
+
<a href="http://profiles.wordpress.org/burakali/">burakali</a>,
|
597 |
+
<a href="http://profiles.wordpress.org/dcavins/">dcavins</a>,
|
598 |
+
<a href="http://profiles.wordpress.org/ddean/">ddean</a>,
|
599 |
+
<a href="http://profiles.wordpress.org/DennisSmolek/">DennisSmolek</a>,
|
600 |
+
<a href="http://profiles.wordpress.org/dimensionmedia/">dimensionmedia</a>,
|
601 |
+
<a href="http://profiles.wordpress.org/dtc7240/">dtc7240</a>,
|
602 |
+
<a href="http://profiles.wordpress.org/ericlewis/">ericlewis</a>,
|
603 |
+
<a href="http://profiles.wordpress.org/gametako/">gametako</a>,
|
604 |
+
<a href="http://profiles.wordpress.org/geoffroycochard/">geoffroycochard</a>,
|
605 |
+
<a href="http://profiles.wordpress.org/hanni/">hanni</a>,
|
606 |
+
<a href="http://profiles.wordpress.org/henrywright/">henrywright</a>,
|
607 |
+
<a href="http://profiles.wordpress.org/hnla/">hnla</a>,
|
608 |
+
<a href="http://profiles.wordpress.org/imath/">imath</a>,
|
609 |
+
<a href="http://profiles.wordpress.org/johnjamesjacoby/">johnjamesjacoby</a>,
|
610 |
+
<a href="http://profiles.wordpress.org/lenasterg/">lenasterg</a>,
|
611 |
+
<a href="http://profiles.wordpress.org/mboynes/">mboynes</a>,
|
612 |
+
<a href="http://profiles.wordpress.org/megainfo/">megainfo</a>,
|
613 |
+
<a href="http://profiles.wordpress.org/Mike_Cowobo/">Mike_Cowobo</a>,
|
614 |
+
<a href="http://profiles.wordpress.org/modemlooper/">modemlooper</a>,
|
615 |
+
<a href="http://profiles.wordpress.org/olivM/">olivM</a>,
|
616 |
+
<a href="http://profiles.wordpress.org/needle/">needle</a>,
|
617 |
+
<a href="http://profiles.wordpress.org/netweblogic/">netweblogic</a>,
|
618 |
+
<a href="http://profiles.wordpress.org/r-a-y/">r-a-y</a>,
|
619 |
+
<a href="http://profiles.wordpress.org/ryderlewis/">ryderlewis</a>,
|
620 |
+
<a href="http://profiles.wordpress.org/sbrajesh/">sbrajesh</a>,
|
621 |
+
<a href="http://profiles.wordpress.org/sgr33n/">sgr33n</a>,
|
622 |
+
<a href="http://profiles.wordpress.org/sooskriszta/">sooskriszta</a>,
|
623 |
+
<a href="http://profiles.wordpress.org/terraling/">terraling</a>,
|
624 |
+
<a href="http://profiles.wordpress.org/tomdxw/">tomdxw</a>,
|
625 |
+
<a href="http://profiles.wordpress.org/trishasalas/">trishasalas</a>,
|
626 |
+
<a href="http://profiles.wordpress.org/vhauri/">vhauri</a>,
|
627 |
+
<a href="http://profiles.wordpress.org/williamsba1/">williamsba1</a>,
|
628 |
+
<a href="http://profiles.wordpress.org/wpdennis/">wpdennis</a>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
629 |
</p>
|
630 |
|
631 |
<div class="return-to-dashboard">
|
@@ -23,8 +23,7 @@ if ( !defined( 'ABSPATH' ) ) exit;
|
|
23 |
* @type string $type Determines sort order. Select from 'newest', 'active',
|
24 |
* 'online', 'random', 'popular', 'alphabetical'. Default: 'newest'.
|
25 |
* @type int $per_page Number of results to return. Default: 0 (no limit).
|
26 |
-
* @type int $page Page offset (together with $per_page). Default:
|
27 |
-
* limit).
|
28 |
* @type int $user_id ID of a user. If present, and if the friends
|
29 |
* component is activated, results will be limited to the friends of
|
30 |
* that user. Default: 0.
|
@@ -311,6 +310,11 @@ class BP_User_Query {
|
|
311 |
$sql['order'] = "ASC";
|
312 |
}
|
313 |
|
|
|
|
|
|
|
|
|
|
|
314 |
break;
|
315 |
|
316 |
// Any other 'type' falls through
|
23 |
* @type string $type Determines sort order. Select from 'newest', 'active',
|
24 |
* 'online', 'random', 'popular', 'alphabetical'. Default: 'newest'.
|
25 |
* @type int $per_page Number of results to return. Default: 0 (no limit).
|
26 |
+
* @type int $page Page offset (together with $per_page). Default: 1.
|
|
|
27 |
* @type int $user_id ID of a user. If present, and if the friends
|
28 |
* component is activated, results will be limited to the friends of
|
29 |
* that user. Default: 0.
|
310 |
$sql['order'] = "ASC";
|
311 |
}
|
312 |
|
313 |
+
// Alphabetical queries ignore last_activity, while BP uses last_activity
|
314 |
+
// to infer spam/deleted/non-activated users. To ensure that these users
|
315 |
+
// are filtered out, we add an appropriate sub-query.
|
316 |
+
$sql['where'][] = "u.{$this->uid_name} IN ( SELECT ID FROM {$wpdb->users} WHERE " . bp_core_get_status_sql( '' ) . " )";
|
317 |
+
|
318 |
break;
|
319 |
|
320 |
// Any other 'type' falls through
|
@@ -348,6 +348,11 @@ function bp_modify_page_title( $title, $sep, $seplocation ) {
|
|
348 |
if ( bp_is_blog_page() )
|
349 |
return $title;
|
350 |
|
|
|
|
|
|
|
|
|
|
|
351 |
// If this is the front page of the site, return WP's title
|
352 |
if ( is_front_page() || is_home() )
|
353 |
return $title;
|
348 |
if ( bp_is_blog_page() )
|
349 |
return $title;
|
350 |
|
351 |
+
// If this is a 404, let WordPress handle it
|
352 |
+
if ( is_404() ) {
|
353 |
+
return $title;
|
354 |
+
}
|
355 |
+
|
356 |
// If this is the front page of the site, return WP's title
|
357 |
if ( is_front_page() || is_home() )
|
358 |
return $title;
|
@@ -32,28 +32,25 @@ if ( !defined( 'ABSPATH' ) ) exit;
|
|
32 |
* @return bool See {@link bp_activity_add()}.
|
33 |
*/
|
34 |
function friends_record_activity( $args = '' ) {
|
35 |
-
global $bp;
|
36 |
|
37 |
-
if ( !bp_is_active( 'activity' ) )
|
38 |
return false;
|
|
|
39 |
|
40 |
-
$
|
41 |
'user_id' => bp_loggedin_user_id(),
|
42 |
'action' => '',
|
43 |
'content' => '',
|
44 |
'primary_link' => '',
|
45 |
-
'component' =>
|
46 |
'type' => false,
|
47 |
'item_id' => false,
|
48 |
'secondary_item_id' => false,
|
49 |
'recorded_time' => bp_core_current_time(),
|
50 |
'hide_sitewide' => false
|
51 |
-
);
|
52 |
-
|
53 |
-
$r = wp_parse_args( $args, $defaults );
|
54 |
-
extract( $r, EXTR_SKIP );
|
55 |
|
56 |
-
return bp_activity_add(
|
57 |
}
|
58 |
|
59 |
/**
|
@@ -71,26 +68,32 @@ function friends_record_activity( $args = '' ) {
|
|
71 |
* @return bool True on success, false on failure.
|
72 |
*/
|
73 |
function friends_delete_activity( $args ) {
|
74 |
-
|
75 |
-
|
76 |
-
if ( bp_is_active( 'activity' ) ) {
|
77 |
-
extract( (array) $args );
|
78 |
-
bp_activity_delete_by_item_id( array( 'item_id' => $item_id, 'component' => $bp->friends->id, 'type' => $type, 'user_id' => $user_id ) );
|
79 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
}
|
81 |
|
82 |
/**
|
83 |
* Register the activity actions for bp-friends.
|
84 |
*/
|
85 |
function friends_register_activity_actions() {
|
86 |
-
global $bp;
|
87 |
|
88 |
-
if ( !bp_is_active( 'activity' ) )
|
89 |
return false;
|
|
|
|
|
|
|
90 |
|
91 |
// These two added in BP 1.6
|
92 |
bp_activity_set_action( $bp->friends->id, 'friendship_accepted', __( 'Friendships accepted', 'buddypress' ) );
|
93 |
-
bp_activity_set_action( $bp->friends->id, 'friendship_created',
|
94 |
|
95 |
// < BP 1.6 backpat
|
96 |
bp_activity_set_action( $bp->friends->id, 'friends_register_activity_action', __( 'New friendship created', 'buddypress' ) );
|
@@ -100,60 +103,44 @@ function friends_register_activity_actions() {
|
|
100 |
add_action( 'bp_register_activity_actions', 'friends_register_activity_actions' );
|
101 |
|
102 |
/**
|
103 |
-
*
|
|
|
|
|
|
|
104 |
*
|
105 |
-
* @param
|
106 |
-
* @param int $
|
107 |
-
* @param int $
|
108 |
-
* @param
|
109 |
-
* waiting for the user.
|
110 |
-
* @param string $format 'string' for BuddyBar-compatible notifications;
|
111 |
-
* 'array' for WP Toolbar. Default: 'string'.
|
112 |
-
* @return array|string
|
113 |
*/
|
114 |
-
function
|
115 |
-
|
116 |
-
switch ( $action ) {
|
117 |
-
case 'friendship_accepted':
|
118 |
-
$link = trailingslashit( bp_loggedin_user_domain() . bp_get_friends_slug() . '/my-friends' );
|
119 |
-
|
120 |
-
// Set up the string and the filter
|
121 |
-
if ( (int) $total_items > 1 ) {
|
122 |
-
$text = sprintf( __( '%d friends accepted your friendship requests', 'buddypress' ), (int) $total_items );
|
123 |
-
$filter = 'bp_friends_multiple_friendship_accepted_notification';
|
124 |
-
} else {
|
125 |
-
$text = sprintf( __( '%s accepted your friendship request', 'buddypress' ), bp_core_get_user_displayname( $item_id ) );
|
126 |
-
$filter = 'bp_friends_single_friendship_accepted_notification';
|
127 |
-
}
|
128 |
-
|
129 |
-
break;
|
130 |
-
|
131 |
-
case 'friendship_request':
|
132 |
-
$link = bp_loggedin_user_domain() . bp_get_friends_slug() . '/requests/?new';
|
133 |
-
|
134 |
-
// Set up the string and the filter
|
135 |
-
if ( (int) $total_items > 1 ) {
|
136 |
-
$text = sprintf( __( 'You have %d pending friendship requests', 'buddypress' ), (int) $total_items );
|
137 |
-
$filter = 'bp_friends_multiple_friendship_request_notification';
|
138 |
-
} else {
|
139 |
-
$text = sprintf( __( 'You have a friendship request from %s', 'buddypress' ), bp_core_get_user_displayname( $item_id ) );
|
140 |
-
$filter = 'bp_friends_single_friendship_request_notification';
|
141 |
-
}
|
142 |
-
|
143 |
-
break;
|
144 |
-
}
|
145 |
|
146 |
-
//
|
147 |
-
if ( '
|
148 |
-
|
149 |
-
} else {
|
150 |
-
$return = apply_filters( $filter, array(
|
151 |
-
'link' => $link,
|
152 |
-
'text' => $text
|
153 |
-
), (int) $total_items );
|
154 |
}
|
155 |
|
156 |
-
|
157 |
-
|
158 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
159 |
}
|
|
32 |
* @return bool See {@link bp_activity_add()}.
|
33 |
*/
|
34 |
function friends_record_activity( $args = '' ) {
|
|
|
35 |
|
36 |
+
if ( ! bp_is_active( 'activity' ) ) {
|
37 |
return false;
|
38 |
+
}
|
39 |
|
40 |
+
$r = wp_parse_args( $args, array(
|
41 |
'user_id' => bp_loggedin_user_id(),
|
42 |
'action' => '',
|
43 |
'content' => '',
|
44 |
'primary_link' => '',
|
45 |
+
'component' => buddypress()->friends->id,
|
46 |
'type' => false,
|
47 |
'item_id' => false,
|
48 |
'secondary_item_id' => false,
|
49 |
'recorded_time' => bp_core_current_time(),
|
50 |
'hide_sitewide' => false
|
51 |
+
) );
|
|
|
|
|
|
|
52 |
|
53 |
+
return bp_activity_add( $r );
|
54 |
}
|
55 |
|
56 |
/**
|
68 |
* @return bool True on success, false on failure.
|
69 |
*/
|
70 |
function friends_delete_activity( $args ) {
|
71 |
+
if ( ! bp_is_active( 'activity' ) ) {
|
72 |
+
return;
|
|
|
|
|
|
|
73 |
}
|
74 |
+
|
75 |
+
bp_activity_delete_by_item_id( array(
|
76 |
+
'component' => buddypress()->friends->id,
|
77 |
+
'item_id' => $args['item_id'],
|
78 |
+
'type' => $args['type'],
|
79 |
+
'user_id' => $args['user_id']
|
80 |
+
) );
|
81 |
}
|
82 |
|
83 |
/**
|
84 |
* Register the activity actions for bp-friends.
|
85 |
*/
|
86 |
function friends_register_activity_actions() {
|
|
|
87 |
|
88 |
+
if ( !bp_is_active( 'activity' ) ) {
|
89 |
return false;
|
90 |
+
}
|
91 |
+
|
92 |
+
$bp = buddypress();
|
93 |
|
94 |
// These two added in BP 1.6
|
95 |
bp_activity_set_action( $bp->friends->id, 'friendship_accepted', __( 'Friendships accepted', 'buddypress' ) );
|
96 |
+
bp_activity_set_action( $bp->friends->id, 'friendship_created', __( 'New friendships', 'buddypress' ) );
|
97 |
|
98 |
// < BP 1.6 backpat
|
99 |
bp_activity_set_action( $bp->friends->id, 'friends_register_activity_action', __( 'New friendship created', 'buddypress' ) );
|
103 |
add_action( 'bp_register_activity_actions', 'friends_register_activity_actions' );
|
104 |
|
105 |
/**
|
106 |
+
* Add activity stream items when one members accepts another members request
|
107 |
+
* for virtual friendship.
|
108 |
+
*
|
109 |
+
* @since BuddyPress (1.9.0)
|
110 |
*
|
111 |
+
* @param int $friendship_id
|
112 |
+
* @param int $initiator_user_id
|
113 |
+
* @param int $friend_user_id
|
114 |
+
* @param object $friendship Optional
|
|
|
|
|
|
|
|
|
115 |
*/
|
116 |
+
function bp_friends_friendship_accepted_activity( $friendship_id, $initiator_user_id, $friend_user_id, $friendship = false ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
117 |
|
118 |
+
// Bail if Activity component is not active
|
119 |
+
if ( ! bp_is_active( 'activity' ) ) {
|
120 |
+
return;
|
|
|
|
|
|
|
|
|
|
|
121 |
}
|
122 |
|
123 |
+
// Get links to both members profiles
|
124 |
+
$initiator_link = bp_core_get_userlink( $initiator_user_id );
|
125 |
+
$friend_link = bp_core_get_userlink( $friend_user_id );
|
126 |
+
|
127 |
+
// Record in activity streams for the initiator
|
128 |
+
friends_record_activity( array(
|
129 |
+
'user_id' => $initiator_user_id,
|
130 |
+
'type' => 'friendship_created',
|
131 |
+
'action' => apply_filters( 'friends_activity_friendship_accepted_action', sprintf( __( '%1$s and %2$s are now friends', 'buddypress' ), $initiator_link, $friend_link ), $friendship ),
|
132 |
+
'item_id' => $friendship_id,
|
133 |
+
'secondary_item_id' => $friend_user_id
|
134 |
+
) );
|
135 |
+
|
136 |
+
// Record in activity streams for the friend
|
137 |
+
friends_record_activity( array(
|
138 |
+
'user_id' => $friend_user_id,
|
139 |
+
'type' => 'friendship_created',
|
140 |
+
'action' => apply_filters( 'friends_activity_friendship_accepted_action', sprintf( __( '%1$s and %2$s are now friends', 'buddypress' ), $friend_link, $initiator_link ), $friendship ),
|
141 |
+
'item_id' => $friendship_id,
|
142 |
+
'secondary_item_id' => $initiator_user_id,
|
143 |
+
'hide_sitewide' => true // We've already got the first entry site wide
|
144 |
+
) );
|
145 |
}
|
146 |
+
add_action( 'friends_friendship_accepted', 'bp_friends_friendship_accepted_activity', 10, 4 );
|
@@ -10,7 +10,6 @@
|
|
10 |
* @subpackage FriendsCaching
|
11 |
*/
|
12 |
|
13 |
-
|
14 |
// Exit if accessed directly
|
15 |
if ( !defined( 'ABSPATH' ) ) exit;
|
16 |
|
@@ -28,16 +27,6 @@ function friends_clear_friend_object_cache( $friendship_id ) {
|
|
28 |
wp_cache_delete( 'friends_friend_ids_' . $friendship->friend_user_id, 'bp' );
|
29 |
}
|
30 |
|
31 |
-
/**
|
32 |
-
* Clear friend-related notifications when ?new=1.
|
33 |
-
*/
|
34 |
-
function friends_clear_friend_notifications() {
|
35 |
-
if ( isset( $_GET['new'] ) ) {
|
36 |
-
bp_core_mark_notifications_by_type( bp_loggedin_user_id(), buddypress()->friends->id, 'friendship_accepted' );
|
37 |
-
}
|
38 |
-
}
|
39 |
-
add_action( 'bp_activity_screen_my_activity', 'friends_clear_friend_notifications' );
|
40 |
-
|
41 |
// List actions to clear object caches on
|
42 |
add_action( 'friends_friendship_accepted', 'friends_clear_friend_object_cache' );
|
43 |
add_action( 'friends_friendship_deleted', 'friends_clear_friend_object_cache' );
|
10 |
* @subpackage FriendsCaching
|
11 |
*/
|
12 |
|
|
|
13 |
// Exit if accessed directly
|
14 |
if ( !defined( 'ABSPATH' ) ) exit;
|
15 |
|
27 |
wp_cache_delete( 'friends_friend_ids_' . $friendship->friend_user_id, 'bp' );
|
28 |
}
|
29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
// List actions to clear object caches on
|
31 |
add_action( 'friends_friendship_accepted', 'friends_clear_friend_object_cache' );
|
32 |
add_action( 'friends_friendship_deleted', 'friends_clear_friend_object_cache' );
|
@@ -29,43 +29,43 @@ if ( !defined( 'ABSPATH' ) ) exit;
|
|
29 |
* @return bool True on success, false on failure.
|
30 |
*/
|
31 |
function friends_add_friend( $initiator_userid, $friend_userid, $force_accept = false ) {
|
32 |
-
global $bp;
|
33 |
|
|
|
34 |
$friendship = new BP_Friends_Friendship;
|
35 |
-
|
36 |
-
if ( (int) $friendship->is_confirmed )
|
37 |
return true;
|
|
|
38 |
|
|
|
39 |
$friendship->initiator_user_id = $initiator_userid;
|
40 |
$friendship->friend_user_id = $friend_userid;
|
41 |
$friendship->is_confirmed = 0;
|
42 |
$friendship->is_limited = 0;
|
43 |
$friendship->date_created = bp_core_current_time();
|
44 |
|
45 |
-
if ( $force_accept )
|
46 |
$friendship->is_confirmed = 1;
|
|
|
47 |
|
48 |
-
if
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
bp_core_add_notification( $friendship->initiator_user_id, $friendship->friend_user_id, $bp->friends->id, 'friendship_request' );
|
53 |
-
|
54 |
-
// Send the email notification
|
55 |
-
friends_notification_new_request( $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id );
|
56 |
-
|
57 |
-
do_action( 'friends_friendship_requested', $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id );
|
58 |
-
} else {
|
59 |
-
// Update friend totals
|
60 |
-
friends_update_friend_totals( $friendship->initiator_user_id, $friendship->friend_user_id, 'add' );
|
61 |
|
62 |
-
|
63 |
-
|
|
|
64 |
|
65 |
-
|
|
|
|
|
|
|
66 |
}
|
67 |
|
68 |
-
|
|
|
|
|
|
|
69 |
}
|
70 |
|
71 |
/**
|
@@ -111,45 +111,17 @@ function friends_remove_friend( $initiator_userid, $friend_userid ) {
|
|
111 |
* @return bool True on success, false on failure.
|
112 |
*/
|
113 |
function friends_accept_friendship( $friendship_id ) {
|
114 |
-
global $bp;
|
115 |
|
|
|
116 |
$friendship = new BP_Friends_Friendship( $friendship_id, true, false );
|
117 |
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
// Remove the friend request notice
|
122 |
-
bp_core_mark_notifications_by_item_id( $friendship->friend_user_id, $friendship->initiator_user_id, $bp->friends->id, 'friendship_request' );
|
123 |
-
|
124 |
-
// Add a friend accepted notice for the initiating user
|
125 |
-
bp_core_add_notification( $friendship->friend_user_id, $friendship->initiator_user_id, $bp->friends->id, 'friendship_accepted' );
|
126 |
-
|
127 |
-
$initiator_link = bp_core_get_userlink( $friendship->initiator_user_id );
|
128 |
-
$friend_link = bp_core_get_userlink( $friendship->friend_user_id );
|
129 |
|
130 |
-
//
|
131 |
-
|
132 |
-
'user_id' => $friendship->initiator_user_id,
|
133 |
-
'type' => 'friendship_created',
|
134 |
-
'action' => apply_filters( 'friends_activity_friendship_accepted_action', sprintf( __( '%1$s and %2$s are now friends', 'buddypress' ), $initiator_link, $friend_link ), $friendship ),
|
135 |
-
'item_id' => $friendship_id,
|
136 |
-
'secondary_item_id' => $friendship->friend_user_id
|
137 |
-
) );
|
138 |
-
|
139 |
-
// Record in activity streams for the friend
|
140 |
-
friends_record_activity( array(
|
141 |
-
'user_id' => $friendship->friend_user_id,
|
142 |
-
'type' => 'friendship_created',
|
143 |
-
'action' => apply_filters( 'friends_activity_friendship_accepted_action', sprintf( __( '%1$s and %2$s are now friends', 'buddypress' ), $friend_link, $initiator_link ), $friendship ),
|
144 |
-
'item_id' => $friendship_id,
|
145 |
-
'secondary_item_id' => $friendship->initiator_user_id,
|
146 |
-
'hide_sitewide' => true // We've already got the first entry site wide
|
147 |
-
) );
|
148 |
-
|
149 |
-
// Send the email notification
|
150 |
-
friends_notification_accepted_request( $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id );
|
151 |
|
152 |
-
do_action( 'friends_friendship_accepted', $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id );
|
153 |
|
154 |
return true;
|
155 |
}
|
@@ -164,15 +136,9 @@ function friends_accept_friendship( $friendship_id ) {
|
|
164 |
* @return bool True on success, false on failure.
|
165 |
*/
|
166 |
function friends_reject_friendship( $friendship_id ) {
|
167 |
-
global $bp;
|
168 |
-
|
169 |
$friendship = new BP_Friends_Friendship( $friendship_id, true, false );
|
170 |
|
171 |
-
if (
|
172 |
-
|
173 |
-
// Remove the friend request notice
|
174 |
-
bp_core_mark_notifications_by_item_id( $friendship->friend_user_id, $friendship->initiator_user_id, $bp->friends->id, 'friendship_request' );
|
175 |
-
|
176 |
do_action_ref_array( 'friends_friendship_rejected', array( $friendship_id, &$friendship ) );
|
177 |
return true;
|
178 |
}
|
@@ -189,15 +155,10 @@ function friends_reject_friendship( $friendship_id ) {
|
|
189 |
* @return bool True on success, false on failure.
|
190 |
*/
|
191 |
function friends_withdraw_friendship( $initiator_userid, $friend_userid ) {
|
192 |
-
global $bp;
|
193 |
-
|
194 |
$friendship_id = BP_Friends_Friendship::get_friendship_id( $initiator_userid, $friend_userid );
|
195 |
$friendship = new BP_Friends_Friendship( $friendship_id, true, false );
|
196 |
|
197 |
-
if (
|
198 |
-
// Remove the friend request notice
|
199 |
-
bp_core_delete_notifications_by_item_id( $friendship->friend_user_id, $friendship->initiator_user_id, $bp->friends->id, 'friendship_request' );
|
200 |
-
|
201 |
do_action_ref_array( 'friends_friendship_whithdrawn', array( $friendship_id, &$friendship ) );
|
202 |
return true;
|
203 |
}
|
@@ -566,7 +527,6 @@ function friends_update_friend_totals( $initiator_user_id, $friend_user_id, $sta
|
|
566 |
* @param int $user_id ID of the user whose friend data is being removed.
|
567 |
*/
|
568 |
function friends_remove_data( $user_id ) {
|
569 |
-
global $bp;
|
570 |
|
571 |
do_action( 'friends_before_remove_data', $user_id );
|
572 |
|
@@ -575,9 +535,6 @@ function friends_remove_data( $user_id ) {
|
|
575 |
// Remove usermeta
|
576 |
bp_delete_user_meta( $user_id, 'total_friend_count' );
|
577 |
|
578 |
-
// Remove friendship requests FROM user
|
579 |
-
bp_core_delete_notifications_from_user( $user_id, $bp->friends->id, 'friendship_request' );
|
580 |
-
|
581 |
do_action( 'friends_remove_data', $user_id );
|
582 |
}
|
583 |
add_action( 'wpmu_delete_user', 'friends_remove_data' );
|
29 |
* @return bool True on success, false on failure.
|
30 |
*/
|
31 |
function friends_add_friend( $initiator_userid, $friend_userid, $force_accept = false ) {
|
|
|
32 |
|
33 |
+
// Check if already friends, and bail if so
|
34 |
$friendship = new BP_Friends_Friendship;
|
35 |
+
if ( (int) $friendship->is_confirmed ) {
|
|
|
36 |
return true;
|
37 |
+
}
|
38 |
|
39 |
+
// Setup the friendship data
|
40 |
$friendship->initiator_user_id = $initiator_userid;
|
41 |
$friendship->friend_user_id = $friend_userid;
|
42 |
$friendship->is_confirmed = 0;
|
43 |
$friendship->is_limited = 0;
|
44 |
$friendship->date_created = bp_core_current_time();
|
45 |
|
46 |
+
if ( !empty( $force_accept ) ) {
|
47 |
$friendship->is_confirmed = 1;
|
48 |
+
}
|
49 |
|
50 |
+
// Bail if friendship could not be saved (how sad!)
|
51 |
+
if ( ! $friendship->save() ) {
|
52 |
+
return false;
|
53 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
|
55 |
+
// Send notifications
|
56 |
+
if ( empty( $force_accept ) ) {
|
57 |
+
$action = 'friends_friendship_requested';
|
58 |
|
59 |
+
// Update friend totals
|
60 |
+
} else {
|
61 |
+
$action = 'friends_friendship_accepted';
|
62 |
+
friends_update_friend_totals( $friendship->initiator_user_id, $friendship->friend_user_id, 'add' );
|
63 |
}
|
64 |
|
65 |
+
// Call the above titled action and pass friendship data into it
|
66 |
+
do_action( $action, $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id, $friendship );
|
67 |
+
|
68 |
+
return true;
|
69 |
}
|
70 |
|
71 |
/**
|
111 |
* @return bool True on success, false on failure.
|
112 |
*/
|
113 |
function friends_accept_friendship( $friendship_id ) {
|
|
|
114 |
|
115 |
+
// Get the friesdhip data
|
116 |
$friendship = new BP_Friends_Friendship( $friendship_id, true, false );
|
117 |
|
118 |
+
// Accepting friendship
|
119 |
+
if ( empty( $friendship->is_confirmed ) && BP_Friends_Friendship::accept( $friendship_id ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
|
121 |
+
// Bump the friendship counts
|
122 |
+
friends_update_friend_totals( $friendship->initiator_user_id, $friendship->friend_user_id );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
|
124 |
+
do_action( 'friends_friendship_accepted', $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id, $friendship );
|
125 |
|
126 |
return true;
|
127 |
}
|
136 |
* @return bool True on success, false on failure.
|
137 |
*/
|
138 |
function friends_reject_friendship( $friendship_id ) {
|
|
|
|
|
139 |
$friendship = new BP_Friends_Friendship( $friendship_id, true, false );
|
140 |
|
141 |
+
if ( empty( $friendship->is_confirmed ) && BP_Friends_Friendship::reject( $friendship_id ) ) {
|
|
|
|
|
|
|
|
|
142 |
do_action_ref_array( 'friends_friendship_rejected', array( $friendship_id, &$friendship ) );
|
143 |
return true;
|
144 |
}
|
155 |
* @return bool True on success, false on failure.
|
156 |
*/
|
157 |
function friends_withdraw_friendship( $initiator_userid, $friend_userid ) {
|
|
|
|
|
158 |
$friendship_id = BP_Friends_Friendship::get_friendship_id( $initiator_userid, $friend_userid );
|
159 |
$friendship = new BP_Friends_Friendship( $friendship_id, true, false );
|
160 |
|
161 |
+
if ( empty( $friendship->is_confirmed ) && BP_Friends_Friendship::withdraw( $friendship_id ) ) {
|
|
|
|
|
|
|
162 |
do_action_ref_array( 'friends_friendship_whithdrawn', array( $friendship_id, &$friendship ) );
|
163 |
return true;
|
164 |
}
|
527 |
* @param int $user_id ID of the user whose friend data is being removed.
|
528 |
*/
|
529 |
function friends_remove_data( $user_id ) {
|
|
|
530 |
|
531 |
do_action( 'friends_before_remove_data', $user_id );
|
532 |
|
535 |
// Remove usermeta
|
536 |
bp_delete_user_meta( $user_id, 'total_friend_count' );
|
537 |
|
|
|
|
|
|
|
538 |
do_action( 'friends_remove_data', $user_id );
|
539 |
}
|
540 |
add_action( 'wpmu_delete_user', 'friends_remove_data' );
|
@@ -13,6 +13,8 @@
|
|
13 |
// Exit if accessed directly
|
14 |
if ( !defined( 'ABSPATH' ) ) exit;
|
15 |
|
|
|
|
|
16 |
/**
|
17 |
* Send notifications related to a new friendship request.
|
18 |
*
|
@@ -54,8 +56,8 @@ To view %3$s\'s profile: %4$s
|
|
54 |
$message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
|
55 |
}
|
56 |
|
57 |
-
|
58 |
-
$to
|
59 |
$subject = apply_filters( 'friends_notification_new_request_subject', $subject, $initiator_name );
|
60 |
$message = apply_filters( 'friends_notification_new_request_message', $message, $initiator_name, $initiator_link, $all_requests_link, $settings_link );
|
61 |
|
@@ -63,6 +65,7 @@ To view %3$s\'s profile: %4$s
|
|
63 |
|
64 |
do_action( 'bp_friends_sent_request_email', $friend_id, $subject, $message, $friendship_id, $initiator_id );
|
65 |
}
|
|
|
66 |
|
67 |
/**
|
68 |
* Send notifications related to the acceptance of a friendship request.
|
@@ -102,8 +105,8 @@ To view %2$s\'s profile: %3$s
|
|
102 |
$message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
|
103 |
}
|
104 |
|
105 |
-
|
106 |
-
$to
|
107 |
$subject = apply_filters( 'friends_notification_accepted_request_subject', $subject, $friend_name );
|
108 |
$message = apply_filters( 'friends_notification_accepted_request_message', $message, $friend_name, $friend_link, $settings_link );
|
109 |
|
@@ -111,3 +114,196 @@ To view %2$s\'s profile: %3$s
|
|
111 |
|
112 |
do_action( 'bp_friends_sent_accepted_email', $initiator_id, $subject, $message, $friendship_id, $friend_id );
|
113 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
// Exit if accessed directly
|
14 |
if ( !defined( 'ABSPATH' ) ) exit;
|
15 |
|
16 |
+
/** Emails ********************************************************************/
|
17 |
+
|
18 |
/**
|
19 |
* Send notifications related to a new friendship request.
|
20 |
*
|
56 |
$message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
|
57 |
}
|
58 |
|
59 |
+
// Send the message
|
60 |
+
$to = apply_filters( 'friends_notification_new_request_to', $to );
|
61 |
$subject = apply_filters( 'friends_notification_new_request_subject', $subject, $initiator_name );
|
62 |
$message = apply_filters( 'friends_notification_new_request_message', $message, $initiator_name, $initiator_link, $all_requests_link, $settings_link );
|
63 |
|
65 |
|
66 |
do_action( 'bp_friends_sent_request_email', $friend_id, $subject, $message, $friendship_id, $initiator_id );
|
67 |
}
|
68 |
+
add_action( 'friends_friendship_requested', 'friends_notification_new_request', 10, 3 );
|
69 |
|
70 |
/**
|
71 |
* Send notifications related to the acceptance of a friendship request.
|
105 |
$message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
|
106 |
}
|
107 |
|
108 |
+
// Send the message
|
109 |
+
$to = apply_filters( 'friends_notification_accepted_request_to', $to );
|
110 |
$subject = apply_filters( 'friends_notification_accepted_request_subject', $subject, $friend_name );
|
111 |
$message = apply_filters( 'friends_notification_accepted_request_message', $message, $friend_name, $friend_link, $settings_link );
|
112 |
|
114 |
|
115 |
do_action( 'bp_friends_sent_accepted_email', $initiator_id, $subject, $message, $friendship_id, $friend_id );
|
116 |
}
|
117 |
+
add_action( 'friends_friendship_accepted', 'friends_notification_accepted_request', 10, 3 );
|
118 |
+
|
119 |
+
/** Notifications *************************************************************/
|
120 |
+
|
121 |
+
/**
|
122 |
+
* Notification formatting callback for bp-friends notifications.
|
123 |
+
*
|
124 |
+
* @param string $action The kind of notification being rendered.
|
125 |
+
* @param int $item_id The primary item ID.
|
126 |
+
* @param int $secondary_item_id The secondary item ID.
|
127 |
+
* @param int $total_items The total number of messaging-related notifications
|
128 |
+
* waiting for the user.
|
129 |
+
* @param string $format 'string' for BuddyBar-compatible notifications;
|
130 |
+
* 'array' for WP Toolbar. Default: 'string'.
|
131 |
+
* @return array|string
|
132 |
+
*/
|
133 |
+
function friends_format_notifications( $action, $item_id, $secondary_item_id, $total_items, $format = 'string' ) {
|
134 |
+
|
135 |
+
switch ( $action ) {
|
136 |
+
case 'friendship_accepted':
|
137 |
+
$link = trailingslashit( bp_loggedin_user_domain() . bp_get_friends_slug() . '/my-friends' );
|
138 |
+
|
139 |
+
// Set up the string and the filter
|
140 |
+
if ( (int) $total_items > 1 ) {
|
141 |
+
$text = sprintf( __( '%d friends accepted your friendship requests', 'buddypress' ), (int) $total_items );
|
142 |
+
$filter = 'bp_friends_multiple_friendship_accepted_notification';
|
143 |
+
} else {
|
144 |
+
$text = sprintf( __( '%s accepted your friendship request', 'buddypress' ), bp_core_get_user_displayname( $item_id ) );
|
145 |
+
$filter = 'bp_friends_single_friendship_accepted_notification';
|
146 |
+
}
|
147 |
+
|
148 |
+
break;
|
149 |
+
|
150 |
+
case 'friendship_request':
|
151 |
+
$link = bp_loggedin_user_domain() . bp_get_friends_slug() . '/requests/?new';
|
152 |
+
|
153 |
+
// Set up the string and the filter
|
154 |
+
if ( (int) $total_items > 1 ) {
|
155 |
+
$text = sprintf( __( 'You have %d pending friendship requests', 'buddypress' ), (int) $total_items );
|
156 |
+
$filter = 'bp_friends_multiple_friendship_request_notification';
|
157 |
+
} else {
|
158 |
+
$text = sprintf( __( 'You have a friendship request from %s', 'buddypress' ), bp_core_get_user_displayname( $item_id ) );
|
159 |
+
$filter = 'bp_friends_single_friendship_request_notification';
|
160 |
+
}
|
161 |
+
|
162 |
+
break;
|
163 |
+
}
|
164 |
+
|
165 |
+
// Return either an HTML link or an array, depending on the requested format
|
166 |
+
if ( 'string' == $format ) {
|
167 |
+
$return = apply_filters( $filter, '<a href="' . esc_url( $link ) . '">' . esc_html( $text ) . '</a>', (int) $total_items );
|
168 |
+
} else {
|
169 |
+
$return = apply_filters( $filter, array(
|
170 |
+
'link' => $link,
|
171 |
+
'text' => $text
|
172 |
+
), (int) $total_items );
|
173 |
+
}
|
174 |
+
|
175 |
+
do_action( 'friends_format_notifications', $action, $item_id, $secondary_item_id, $total_items, $return );
|
176 |
+
|
177 |
+
return $return;
|
178 |
+
}
|
179 |
+
|
180 |
+
/**
|
181 |
+
* Clear friend-related notifications when ?new=1
|
182 |
+
*/
|
183 |
+
function friends_clear_friend_notifications() {
|
184 |
+
if ( isset( $_GET['new'] ) && bp_is_active( 'notifications' ) ) {
|
185 |
+
bp_notifications_mark_notifications_by_type( bp_loggedin_user_id(), buddypress()->friends->id, 'friendship_accepted' );
|
186 |
+
}
|
187 |
+
}
|
188 |
+
add_action( 'bp_activity_screen_my_activity', 'friends_clear_friend_notifications' );
|
189 |
+
|
190 |
+
/**
|
191 |
+
* Delete any friendship request notifications for the logged in user.
|
192 |
+
*
|
193 |
+
* @since BuddyPress (1.9.0)
|
194 |
+
*/
|
195 |
+
function bp_friends_mark_friendship_request_notifications_by_type() {
|
196 |
+
if ( isset( $_GET['new'] ) && bp_is_active( 'notifications' ) ) {
|
197 |
+
bp_notifications_mark_notifications_by_type( bp_loggedin_user_id(), buddypress()->friends->id, 'friendship_request' );
|
198 |
+
}
|
199 |
+
}
|
200 |
+
add_action( 'friends_screen_requests', 'bp_friends_mark_friendship_request_notifications_by_type' );
|
201 |
+
|
202 |
+
/**
|
203 |
+
* Delete any friendship acceptance notifications for the logged in user.
|
204 |
+
*
|
205 |
+
* @since BuddyPress (1.9.0)
|
206 |
+
*/
|
207 |
+
function bp_friends_mark_friendship_accepted_notifications_by_type() {
|
208 |
+
if ( bp_is_active( 'notifications' ) ) {
|
209 |
+
bp_notifications_mark_notifications_by_type( bp_loggedin_user_id(), buddypress()->friends->id, 'friendship_accepted' );
|
210 |
+
}
|
211 |
+
}
|
212 |
+
add_action( 'friends_screen_my_friends', 'bp_friends_mark_friendship_accepted_notifications_by_type' );
|
213 |
+
|
214 |
+
/**
|
215 |
+
* Notify one use that another user has requested their virtual friendship.
|
216 |
+
*
|
217 |
+
* @since BuddyPress (1.9.0)
|
218 |
+
* @param int $friendship_id The unique ID of the friendship
|
219 |
+
* @param int $initiator_user_id The friendship initiator user ID
|
220 |
+
* @param int $friend_user_id The friendship request reciever user ID
|
221 |
+
*/
|
222 |
+
function bp_friends_friendship_requested_notification( $friendship_id, $initiator_user_id, $friend_user_id ) {
|
223 |
+
if ( bp_is_active( 'notifications' ) ) {
|
224 |
+
bp_notifications_add_notification( array(
|
225 |
+
'user_id' => $friend_user_id,
|
226 |
+
'item_id' => $initiator_user_id,
|
227 |
+
'secondary_item_id' => $friendship_id,
|
228 |
+
'component_name' => buddypress()->friends->id,
|
229 |
+
'component_action' => 'friendship_request',
|
230 |
+
'date_notified' => bp_core_current_time(),
|
231 |
+
'is_new' => 1,
|
232 |
+
) );
|
233 |
+
}
|
234 |
+
}
|
235 |
+
add_action( 'friends_friendship_requested', 'bp_friends_friendship_requested_notification', 10, 3 );
|
236 |
+
|
237 |
+
/**
|
238 |
+
* Remove friend request notice when a member rejects another members
|
239 |
+
*
|
240 |
+
* @since BuddyPress (1.9.0)
|
241 |
+
*
|
242 |
+
* @param int $friendship_id (not used)
|
243 |
+
* @param object $friendship
|
244 |
+
*/
|
245 |
+
function bp_friends_mark_friendship_rejected_notifications_by_item_id( $friendship_id, $friendship ) {
|
246 |
+
if ( bp_is_active( 'notifications' ) ) {
|
247 |
+
bp_notifications_mark_notifications_by_item_id( $friendship->friend_user_id, $friendship->initiator_user_id, buddypress()->friends->id, 'friendship_request' );
|
248 |
+
}
|
249 |
+
}
|
250 |
+
add_action( 'friends_friendship_rejected', 'bp_friends_mark_friendship_rejected_notifications_by_item_id', 10, 2 );
|
251 |
+
|
252 |
+
/**
|
253 |
+
* Notify a member when another member accepts their virtual friendship request.
|
254 |
+
*
|
255 |
+
* @since BuddyPress (1.9.0)
|
256 |
+
* @param int $friendship_id The unique ID of the friendship
|
257 |
+
* @param int $initiator_user_id The friendship initiator user ID
|
258 |
+
* @param int $friend_user_id The friendship request reciever user ID
|
259 |
+
*/
|
260 |
+
function bp_friends_add_friendship_accepted_notification( $friendship_id, $initiator_user_id, $friend_user_id ) {
|
261 |
+
|
262 |
+
// Bail if notifications is not active
|
263 |
+
if ( ! bp_is_active( 'notifications' ) ) {
|
264 |
+
return;
|
265 |
+
}
|
266 |
+
|
267 |
+
// Remove the friend request notice
|
268 |
+
bp_notifications_mark_notifications_by_item_id( $friend_user_id, $initiator_user_id, buddypress()->friends->id, 'friendship_request' );
|
269 |
+
|
270 |
+
// Add a friend accepted notice for the initiating user
|
271 |
+
bp_notifications_add_notification( array(
|
272 |
+
'user_id' => $initiator_user_id,
|
273 |
+
'item_id' => $friend_user_id,
|
274 |
+
'secondary_item_id' => $friendship_id,
|
275 |
+
'component_name' => buddypress()->friends->id,
|
276 |
+
'component_action' => 'friendship_accepted',
|
277 |
+
'date_notified' => bp_core_current_time(),
|
278 |
+
'is_new' => 1,
|
279 |
+
) );
|
280 |
+
}
|
281 |
+
add_action( 'friends_friendship_accepted', 'bp_friends_add_friendship_accepted_notification', 10, 3 );
|
282 |
+
|
283 |
+
/**
|
284 |
+
* Remove friend request notice when a member withdraws their friend request
|
285 |
+
*
|
286 |
+
* @since BuddyPress (1.9.0)
|
287 |
+
*
|
288 |
+
* @param int $friendship_id (not used)
|
289 |
+
* @param object $friendship
|
290 |
+
*/
|
291 |
+
function bp_friends_mark_friendship_withdrawn_notifications_by_item_id( $friendship_id, $friendship ) {
|
292 |
+
if ( bp_is_active( 'notifications' ) ) {
|
293 |
+
bp_notifications_delete_notifications_by_item_id( $friendship->friend_user_id, $friendship->initiator_user_id, buddypress()->friends->id, 'friendship_request' );
|
294 |
+
}
|
295 |
+
}
|
296 |
+
add_action( 'friends_friendship_withdrawn', 'bp_friends_mark_friendship_withdrawn_notifications_by_item_id', 10, 2 );
|
297 |
+
|
298 |
+
/**
|
299 |
+
* Remove friendship requests FROM user, used primarily when a user is deleted
|
300 |
+
*
|
301 |
+
* @since BuddyPress (1.9.0)
|
302 |
+
* @param int $user_id
|
303 |
+
*/
|
304 |
+
function bp_friends_remove_notifications_data( $user_id = 0 ) {
|
305 |
+
if ( bp_is_active( 'notifications' ) ) {
|
306 |
+
bp_notifications_delete_notifications_from_user( $user_id, buddypress()->friends->id, 'friendship_request' );
|
307 |
+
}
|
308 |
+
}
|
309 |
+
add_action( 'friends_remove_data', 'bp_friends_remove_notifications_data', 10, 1 );
|
@@ -19,9 +19,6 @@ if ( !defined( 'ABSPATH' ) ) exit;
|
|
19 |
*/
|
20 |
function friends_screen_my_friends() {
|
21 |
|
22 |
-
// Delete any friendship acceptance notifications for the user when viewing a profile
|
23 |
-
bp_core_mark_notifications_by_type( bp_loggedin_user_id(), buddypress()->friends->id, 'friendship_accepted' );
|
24 |
-
|
25 |
do_action( 'friends_screen_my_friends' );
|
26 |
|
27 |
bp_core_load_template( apply_filters( 'friends_template_my_friends', 'members/single/home' ) );
|
@@ -67,10 +64,6 @@ function friends_screen_requests() {
|
|
67 |
|
68 |
do_action( 'friends_screen_requests' );
|
69 |
|
70 |
-
if ( isset( $_GET['new'] ) ) {
|
71 |
-
bp_core_mark_notifications_by_type( bp_loggedin_user_id(), buddypress()->friends->id, 'friendship_request' );
|
72 |
-
}
|
73 |
-
|
74 |
bp_core_load_template( apply_filters( 'friends_template_requests', 'members/single/home' ) );
|
75 |
}
|
76 |
|
19 |
*/
|
20 |
function friends_screen_my_friends() {
|
21 |
|
|
|
|
|
|
|
22 |
do_action( 'friends_screen_my_friends' );
|
23 |
|
24 |
bp_core_load_template( apply_filters( 'friends_template_my_friends', 'members/single/home' ) );
|
64 |
|
65 |
do_action( 'friends_screen_requests' );
|
66 |
|
|
|
|
|
|
|
|
|
67 |
bp_core_load_template( apply_filters( 'friends_template_requests', 'members/single/home' ) );
|
68 |
}
|
69 |
|
@@ -59,10 +59,10 @@ add_action( 'bp_register_activity_actions', 'groups_register_activity_actions' )
|
|
59 |
* @return bool See {@link bp_activity_add()}.
|
60 |
*/
|
61 |
function groups_record_activity( $args = '' ) {
|
62 |
-
global $bp;
|
63 |
|
64 |
-
if ( !bp_is_active( 'activity' ) )
|
65 |
return false;
|
|
|
66 |
|
67 |
// Set the default for hide_sitewide by checking the status of the group
|
68 |
$hide_sitewide = false;
|
@@ -78,24 +78,21 @@ function groups_record_activity( $args = '' ) {
|
|
78 |
}
|
79 |
}
|
80 |
|
81 |
-
$
|
82 |
'id' => false,
|
83 |
'user_id' => bp_loggedin_user_id(),
|
84 |
'action' => '',
|
85 |
'content' => '',
|
86 |
'primary_link' => '',
|
87 |
-
'component' =>
|
88 |
'type' => false,
|
89 |
'item_id' => false,
|
90 |
'secondary_item_id' => false,
|
91 |
'recorded_time' => bp_core_current_time(),
|
92 |
'hide_sitewide' => $hide_sitewide
|
93 |
-
);
|
94 |
-
|
95 |
-
$r = wp_parse_args( $args, $defaults );
|
96 |
-
extract( $r );
|
97 |
|
98 |
-
return bp_activity_add(
|
99 |
}
|
100 |
|
101 |
/**
|
@@ -105,13 +102,14 @@ function groups_record_activity( $args = '' ) {
|
|
105 |
* being updated. Default: the current group's ID.
|
106 |
*/
|
107 |
function groups_update_last_activity( $group_id = 0 ) {
|
108 |
-
global $bp;
|
109 |
|
110 |
-
if ( empty( $group_id ) )
|
111 |
-
$group_id =
|
|
|
112 |
|
113 |
-
if ( empty( $group_id ) )
|
114 |
return false;
|
|
|
115 |
|
116 |
groups_update_groupmeta( $group_id, 'last_activity', bp_core_current_time() );
|
117 |
}
|
@@ -120,231 +118,78 @@ add_action( 'groups_created_group', 'groups_update_last_activity' );
|
|
120 |
add_action( 'groups_new_forum_topic', 'groups_update_last_activity' );
|
121 |
add_action( 'groups_new_forum_topic_post', 'groups_update_last_activity' );
|
122 |
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
$group_link = bp_get_group_permalink( $group );
|
132 |
-
|
133 |
-
// Set up the string and the filter
|
134 |
-
// Because different values are passed to the filters, we'll return the
|
135 |
-
// values inline
|
136 |
-
if ( (int) $total_items > 1 ) {
|
137 |
-
$text = sprintf( __( '%1$d new membership requests for the group "%2$s"', 'buddypress' ), (int) $total_items, $group->name );
|
138 |
-
$filter = 'bp_groups_multiple_new_membership_requests_notification';
|
139 |
-
$notification_link = $group_link . 'admin/membership-requests/?n=1';
|
140 |
-
|
141 |
-
if ( 'string' == $format ) {
|
142 |
-
return apply_filters( $filter, '<a href="' . $notification_link . '" title="' . __( 'Group Membership Requests', 'buddypress' ) . '">' . $text . '</a>', $group_link, $total_items, $group->name, $text, $notification_link );
|
143 |
-
} else {
|
144 |
-
return apply_filters( $filter, array(
|
145 |
-
'link' => $notification_link,
|
146 |
-
'text' => $text
|
147 |
-
), $group_link, $total_items, $group->name, $text, $notification_link );
|
148 |
-
}
|
149 |
-
} else {
|
150 |
-
$user_fullname = bp_core_get_user_displayname( $requesting_user_id );
|
151 |
-
$text = sprintf( __( '%s requests group membership', 'buddypress' ), $user_fullname );
|
152 |
-
$filter = 'bp_groups_single_new_membership_request_notification';
|
153 |
-
$notification_link = $group_link . 'admin/membership-requests/?n=1';
|
154 |
-
|
155 |
-
if ( 'string' == $format ) {
|
156 |
-
return apply_filters( $filter, '<a href="' . $notification_link . '" title="' . sprintf( __( '%s requests group membership', 'buddypress' ), $user_fullname ) . '">' . $text . '</a>', $group_link, $user_fullname, $group->name, $text, $notification_link );
|
157 |
-
} else {
|
158 |
-
return apply_filters( $filter, array(
|
159 |
-
'link' => $notification_link,
|
160 |
-
'text' => $text
|
161 |
-
), $group_link, $user_fullname, $group->name, $text, $notification_link );
|
162 |
-
}
|
163 |
-
}
|
164 |
-
|
165 |
-
break;
|
166 |
-
|
167 |
-
case 'membership_request_accepted':
|
168 |
-
$group_id = $item_id;
|
169 |
-
|
170 |
-
$group = groups_get_group( array( 'group_id' => $group_id ) );
|
171 |
-
$group_link = bp_get_group_permalink( $group );
|
172 |
-
|
173 |
-
if ( (int) $total_items > 1 ) {
|
174 |
-
$text = sprintf( __( '%d accepted group membership requests', 'buddypress' ), (int) $total_items, $group->name );
|
175 |
-
$filter = 'bp_groups_multiple_membership_request_accepted_notification';
|
176 |
-
$notification_link = trailingslashit( bp_loggedin_user_domain() . bp_get_groups_slug() ) . '?n=1';
|
177 |
-
|
178 |
-
if ( 'string' == $format ) {
|
179 |
-
return apply_filters( $filter, '<a href="' . $notification_link . '" title="' . __( 'Groups', 'buddypress' ) . '">' . $text . '</a>', $total_items, $group->name, $text, $notification_link );
|
180 |
-
} else {
|
181 |
-
return apply_filters( $filter, array(
|
182 |
-
'link' => $notification_link,
|
183 |
-
'text' => $text
|
184 |
-
), $total_items, $group->name, $text, $notification_link );
|
185 |
-
}
|
186 |
-
} else {
|
187 |
-
$text = sprintf( __( 'Membership for group "%s" accepted', 'buddypress' ), $group->name );
|
188 |
-
$filter = 'bp_groups_single_membership_request_accepted_notification';
|
189 |
-
$notification_link = $group_link . '?n=1';
|
190 |
-
|
191 |
-
if ( 'string' == $format ) {
|
192 |
-
return apply_filters( $filter, '<a href="' . $notification_link . '">' . $text . '</a>', $group_link, $group->name, $text, $notification_link );
|
193 |
-
} else {
|
194 |
-
return apply_filters( $filter, array(
|
195 |
-
'link' => $notification_link,
|
196 |
-
'text' => $text
|
197 |
-
), $group_link, $group->name, $text, $notification_link );
|
198 |
-
}
|
199 |
-
}
|
200 |
-
|
201 |
-
break;
|
202 |
-
|
203 |
-
case 'membership_request_rejected':
|
204 |
-
$group_id = $item_id;
|
205 |
-
|
206 |
-
$group = groups_get_group( array( 'group_id' => $group_id ) );
|
207 |
-
$group_link = bp_get_group_permalink( $group );
|
208 |
-
|
209 |
-
if ( (int) $total_items > 1 ) {
|
210 |
-
$text = sprintf( __( '%d rejected group membership requests', 'buddypress' ), (int) $total_items, $group->name );
|
211 |
-
$filter = 'bp_groups_multiple_membership_request_rejected_notification';
|
212 |
-
$notification_link = trailingslashit( bp_loggedin_user_domain() . bp_get_groups_slug() ) . '?n=1';
|
213 |
-
|
214 |
-
if ( 'string' == $format ) {
|
215 |
-
return apply_filters( $filter, '<a href="' . $notification_link . '" title="' . __( 'Groups', 'buddypress' ) . '">' . $text . '</a>', $total_items, $group->name );
|
216 |
-
} else {
|
217 |
-
return apply_filters( $filter, array(
|
218 |
-
'link' => $notification_link,
|
219 |
-
'text' => $text
|
220 |
-
), $total_items, $group->name, $text, $notification_link );
|
221 |
-
}
|
222 |
-
} else {
|
223 |
-
$text = sprintf( __( 'Membership for group "%s" rejected', 'buddypress' ), $group->name );
|
224 |
-
$filter = 'bp_groups_single_membership_request_rejected_notification';
|
225 |
-
$notification_link = $group_link . '?n=1';
|
226 |
-
|
227 |
-
if ( 'string' == $format ) {
|
228 |
-
return apply_filters( $filter, '<a href="' . $notification_link . '">' . $text . '</a>', $group_link, $group->name, $text, $notification_link );
|
229 |
-
} else {
|
230 |
-
return apply_filters( $filter, array(
|
231 |
-
'link' => $notification_link,
|
232 |
-
'text' => $text
|
233 |
-
), $group_link, $group->name, $text, $notification_link );
|
234 |
-
}
|
235 |
-
}
|
236 |
-
|
237 |
-
break;
|
238 |
-
|
239 |
-
case 'member_promoted_to_admin':
|
240 |
-
$group_id = $item_id;
|
241 |
-
|
242 |
-
$group = groups_get_group( array( 'group_id' => $group_id ) );
|
243 |
-
$group_link = bp_get_group_permalink( $group );
|
244 |
-
|
245 |
-
if ( (int) $total_items > 1 ) {
|
246 |
-
$text = sprintf( __( 'You were promoted to an admin in %d groups', 'buddypress' ), (int) $total_items );
|
247 |
-
$filter = 'bp_groups_multiple_member_promoted_to_admin_notification';
|
248 |
-
$notification_link = trailingslashit( bp_loggedin_user_domain() . bp_get_groups_slug() ) . '?n=1';
|
249 |
-
|
250 |
-
if ( 'string' == $format ) {
|
251 |
-
return apply_filters( $filter, '<a href="' . $notification_link . '" title="' . __( 'Groups', 'buddypress' ) . '">' . $text . '</a>', $total_items, $text, $notification_link );
|
252 |
-
} else {
|
253 |
-
return apply_filters( $filter, array(
|
254 |
-
'link' => $notification_link,
|
255 |
-
'text' => $text
|
256 |
-
), $total_items, $text, $notification_link );
|
257 |
-
}
|
258 |
-
} else {
|
259 |
-
$text = sprintf( __( 'You were promoted to an admin in the group "%s"', 'buddypress' ), $group->name );
|
260 |
-
$filter = 'bp_groups_single_member_promoted_to_admin_notification';
|
261 |
-
$notification_link = $group_link . '?n=1';
|
262 |
-
|
263 |
-
if ( 'string' == $format ) {
|
264 |
-
return apply_filters( $filter, '<a href="' . $notification_link . '">' . $text . '</a>', $group_link, $group->name, $text, $notification_link );
|
265 |
-
} else {
|
266 |
-
return apply_filters( $filter, array(
|
267 |
-
'link' => $notification_link,
|
268 |
-
'text' => $text
|
269 |
-
), $group_link, $group->name, $text, $notification_link );
|
270 |
-
}
|
271 |
-
}
|
272 |
-
|
273 |
-
break;
|
274 |
-
|
275 |
-
case 'member_promoted_to_mod':
|
276 |
-
$group_id = $item_id;
|
277 |
-
|
278 |
-
$group = groups_get_group( array( 'group_id' => $group_id ) );
|
279 |
-
$group_link = bp_get_group_permalink( $group );
|
280 |
-
|
281 |
-
if ( (int) $total_items > 1 ) {
|
282 |
-
$text = sprintf( __( 'You were promoted to a mod in %d groups', 'buddypress' ), (int) $total_items );
|
283 |
-
$filter = 'bp_groups_multiple_member_promoted_to_mod_notification';
|
284 |
-
$notification_link = trailingslashit( bp_loggedin_user_domain() . bp_get_groups_slug() ) . '?n=1';
|
285 |
-
|
286 |
-
if ( 'string' == $format ) {
|
287 |
-
return apply_filters( $filter, '<a href="' . $notification_link . '" title="' . __( 'Groups', 'buddypress' ) . '">' . $text . '</a>', $total_items, $text, $notification_link );
|
288 |
-
} else {
|
289 |
-
return apply_filters( $filter, array(
|
290 |
-
'link' => $notification_link,
|
291 |
-
'text' => $text
|
292 |
-
), $total_items, $text, $notification_link );
|
293 |
-
}
|
294 |
-
} else {
|
295 |
-
$text = sprintf( __( 'You were promoted to a mod in the group "%s"', 'buddypress' ), $group->name );
|
296 |
-
$filter = 'bp_groups_single_member_promoted_to_mod_notification';
|
297 |
-
$notification_link = $group_link . '?n=1';
|
298 |
-
|
299 |
-
if ( 'string' == $format ) {
|
300 |
-
return apply_filters( $filter, '<a href="' . $notification_link . '">' . $text . '</a>', $group_link, $group->name, $text, $notification_link );
|
301 |
-
} else {
|
302 |
-
return apply_filters( $filter, array(
|
303 |
-
'link' => $notification_link,
|
304 |
-
'text' => $text
|
305 |
-
), $group_link, $group->name, $text, $notification_link );
|
306 |
-
}
|
307 |
-
}
|
308 |
-
|
309 |
-
break;
|
310 |
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
|
316 |
-
|
|
|
317 |
|
318 |
-
|
319 |
-
|
320 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
321 |
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
|
|
|
|
|
|
333 |
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
|
|
|
|
343 |
|
344 |
-
|
|
|
|
|
345 |
}
|
346 |
|
347 |
-
|
348 |
-
|
349 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
350 |
}
|
|
|
|
|
|
59 |
* @return bool See {@link bp_activity_add()}.
|
60 |
*/
|
61 |
function groups_record_activity( $args = '' ) {
|
|
|
62 |
|
63 |
+
if ( ! bp_is_active( 'activity' ) ) {
|
64 |
return false;
|
65 |
+
}
|
66 |
|
67 |
// Set the default for hide_sitewide by checking the status of the group
|
68 |
$hide_sitewide = false;
|
78 |
}
|
79 |
}
|
80 |
|
81 |
+
$r = wp_parse_args( $args, array(
|
82 |
'id' => false,
|
83 |
'user_id' => bp_loggedin_user_id(),
|
84 |
'action' => '',
|
85 |
'content' => '',
|
86 |
'primary_link' => '',
|
87 |
+
'component' => buddypress()->groups->id,
|
88 |
'type' => false,
|
89 |
'item_id' => false,
|
90 |
'secondary_item_id' => false,
|
91 |
'recorded_time' => bp_core_current_time(),
|
92 |
'hide_sitewide' => $hide_sitewide
|
93 |
+
) );
|
|
|
|
|
|
|
94 |
|
95 |
+
return bp_activity_add( $r );
|
96 |
}
|
97 |
|
98 |
/**
|
102 |
* being updated. Default: the current group's ID.
|
103 |
*/
|
104 |
function groups_update_last_activity( $group_id = 0 ) {
|
|
|
105 |
|
106 |
+
if ( empty( $group_id ) ) {
|
107 |
+
$group_id = buddypress()->groups->current_group->id;
|
108 |
+
}
|
109 |
|
110 |
+
if ( empty( $group_id ) ) {
|
111 |
return false;
|
112 |
+
}
|
113 |
|
114 |
groups_update_groupmeta( $group_id, 'last_activity', bp_core_current_time() );
|
115 |
}
|
118 |
add_action( 'groups_new_forum_topic', 'groups_update_last_activity' );
|
119 |
add_action( 'groups_new_forum_topic_post', 'groups_update_last_activity' );
|
120 |
|
121 |
+
/**
|
122 |
+
* Add an activity stream item when a member joins a group
|
123 |
+
*
|
124 |
+
* @since BuddyPress (1.9.0)
|
125 |
+
* @param int $user_id
|
126 |
+
* @param int $group_id
|
127 |
+
*/
|
128 |
+
function bp_groups_membership_accepted_add_activity( $user_id, $group_id ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
129 |
|
130 |
+
// Bail if Activity is not active
|
131 |
+
if ( ! bp_is_active( 'activity' ) ) {
|
132 |
+
return false;
|
133 |
+
}
|
134 |
|
135 |
+
// Get the group so we can get it's name
|
136 |
+
$group = groups_get_group( array( 'group_id' => $group_id ) );
|
137 |
|
138 |
+
// Record in activity streams
|
139 |
+
groups_record_activity( array(
|
140 |
+
'action' => apply_filters_ref_array( 'groups_activity_membership_accepted_action', array( sprintf( __( '%1$s joined the group %2$s', 'buddypress' ), bp_core_get_userlink( $user_id ), '<a href="' . bp_get_group_permalink( $group ) . '">' . esc_attr( $group->name ) . '</a>' ), $user_id, &$group ) ),
|
141 |
+
'type' => 'joined_group',
|
142 |
+
'item_id' => $group_id,
|
143 |
+
'user_id' => $user_id
|
144 |
+
) );
|
145 |
+
}
|
146 |
+
add_action( 'groups_membership_accepted', 'bp_groups_membership_accepted_add_activity', 10, 2 );
|
147 |
|
148 |
+
/**
|
149 |
+
* Delete all group activity from activity streams
|
150 |
+
*
|
151 |
+
* @since BuddyPress (1.9.0)
|
152 |
+
*/
|
153 |
+
function bp_groups_delete_group_delete_all_activity( $group_id ) {
|
154 |
+
if ( bp_is_active( 'activity' ) ) {
|
155 |
+
bp_activity_delete_by_item_id( array(
|
156 |
+
'item_id' => $group_id,
|
157 |
+
'component' => buddypress()->groups->id
|
158 |
+
) );
|
159 |
+
}
|
160 |
+
}
|
161 |
+
add_action( 'groups_delete_group', 'bp_groups_delete_group_delete_all_activity', 10 );
|
162 |
|
163 |
+
/**
|
164 |
+
* Delete group member activity if they leave or are removed within 5 minutes of
|
165 |
+
* membership modification.
|
166 |
+
*
|
167 |
+
* If the user joined this group less than five minutes ago, remove the
|
168 |
+
* joined_group activity so users cannot flood the activity stream by
|
169 |
+
* joining/leaving the group in quick succession.
|
170 |
+
*
|
171 |
+
* @since BuddyPress (1.9.0)
|
172 |
+
*/
|
173 |
+
function bp_groups_leave_group_delete_recent_activity( $group_id, $user_id ) {
|
174 |
|
175 |
+
// Bail if Activity component is not active
|
176 |
+
if ( ! bp_is_active( 'activity' ) ) {
|
177 |
+
return;
|
178 |
}
|
179 |
|
180 |
+
// Get the member's group membership information
|
181 |
+
$membership = new BP_Groups_Member( $user_id, $group_id );
|
182 |
+
|
183 |
+
// Check the time period, and maybe delete their recent group activity
|
184 |
+
if ( time() <= strtotime( '+5 minutes', (int) strtotime( $membership->date_modified ) ) ) {
|
185 |
+
bp_activity_delete( array(
|
186 |
+
'component' => buddypress()->groups->id,
|
187 |
+
'type' => 'joined_group',
|
188 |
+
'user_id' => $user_id,
|
189 |
+
'item_id' => $group_id
|
190 |
+
) );
|
191 |
+
}
|
192 |
}
|
193 |
+
add_action( 'groups_leave_group', 'bp_groups_leave_group_delete_recent_activity', 10, 2 );
|
194 |
+
add_action( 'groups_remove_member', 'bp_groups_leave_group_delete_recent_activity', 10, 2 );
|
195 |
+
add_action( 'groups_ban_member', 'bp_groups_leave_group_delete_recent_activity', 10, 2 );
|
@@ -854,31 +854,37 @@ class BP_Groups_Group {
|
|
854 |
$group_ids = implode( ',', wp_parse_id_list( $group_ids ) );
|
855 |
|
856 |
// Fetch the logged-in user's status within each group
|
857 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
858 |
|
859 |
for ( $i = 0, $count = count( $paged_groups ); $i < $count; ++$i ) {
|
860 |
-
|
861 |
-
|
862 |
-
$is_member = $is_invited = $is_pending = '0';
|
863 |
|
864 |
-
|
865 |
-
if ( $group->is_confirmed ) {
|
866 |
-
$is_member = '1';
|
867 |
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
}
|
876 |
|
877 |
-
|
878 |
-
|
879 |
-
$
|
880 |
}
|
881 |
}
|
|
|
|
|
|
|
|
|
882 |
}
|
883 |
|
884 |
$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() ) );
|
854 |
$group_ids = implode( ',', wp_parse_id_list( $group_ids ) );
|
855 |
|
856 |
// Fetch the logged-in user's status within each group
|
857 |
+
$user_status_results = $wpdb->get_results( $wpdb->prepare( "SELECT group_id, is_confirmed, invite_sent FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id IN ( {$group_ids} ) AND is_banned = 0", bp_loggedin_user_id() ) );
|
858 |
+
|
859 |
+
// Reindex
|
860 |
+
$user_status = array();
|
861 |
+
foreach ( $user_status_results as $user_status_result ) {
|
862 |
+
$user_status[ $user_status_result->group_id ] = $user_status_result;
|
863 |
+
}
|
864 |
|
865 |
for ( $i = 0, $count = count( $paged_groups ); $i < $count; ++$i ) {
|
866 |
+
$is_member = $is_invited = $is_pending = '0';
|
867 |
+
$gid = $paged_groups[ $i ]->id;
|
|
|
868 |
|
869 |
+
if ( isset( $user_status[ $gid ] ) ) {
|
|
|
|
|
870 |
|
871 |
+
// is_confirmed means the user is a member
|
872 |
+
if ( $user_status[ $gid ]->is_confirmed ) {
|
873 |
+
$is_member = '1';
|
874 |
|
875 |
+
// invite_sent means the user has been invited
|
876 |
+
} else if ( $user_status[ $gid ]->invite_sent ) {
|
877 |
+
$is_invited = '1';
|
|
|
878 |
|
879 |
+
// User has sent request, but has not been confirmed
|
880 |
+
} else {
|
881 |
+
$is_pending = '1';
|
882 |
}
|
883 |
}
|
884 |
+
|
885 |
+
$paged_groups[ $i ]->is_member = $is_member;
|
886 |
+
$paged_groups[ $i ]->is_invited = $is_invited;
|
887 |
+
$paged_groups[ $i ]->is_pending = $is_pending;
|
888 |
}
|
889 |
|
890 |
$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() ) );
|
@@ -7,6 +7,9 @@
|
|
7 |
* have a template screen associated with them. Usually they will send the user
|
8 |
* back to the default screen after execution.
|
9 |
*
|
|
|
|
|
|
|
10 |
* @package BuddyPress
|
11 |
* @subpackage GroupsForums
|
12 |
*/
|
7 |
* have a template screen associated with them. Usually they will send the user
|
8 |
* back to the default screen after execution.
|
9 |
*
|
10 |
+
* Note that this file is only used for the retired version of bbPress (1.x) and
|
11 |
+
* will see minimal updates as of BuddyPress 1.9.0.
|
12 |
+
*
|
13 |
* @package BuddyPress
|
14 |
* @subpackage GroupsForums
|
15 |
*/
|
@@ -200,26 +200,21 @@ function groups_edit_group_settings( $group_id, $enable_forum, $status, $invite_
|
|
200 |
* @since BuddyPress (1.0)
|
201 |
*/
|
202 |
function groups_delete_group( $group_id ) {
|
203 |
-
global $bp;
|
204 |
|
205 |
do_action( 'groups_before_delete_group', $group_id );
|
206 |
|
207 |
// Get the group object
|
208 |
$group = groups_get_group( array( 'group_id' => $group_id ) );
|
209 |
-
if ( !$group->delete() )
|
210 |
-
return false;
|
211 |
|
212 |
-
//
|
213 |
-
if (
|
214 |
-
|
|
|
215 |
|
216 |
// Remove all outstanding invites for this group
|
217 |
groups_delete_all_group_invites( $group_id );
|
218 |
|
219 |
-
|
220 |
-
bp_core_delete_all_notifications_by_type( $group_id, $bp->groups->id );
|
221 |
-
|
222 |
-
do_action( 'groups_delete_group', $group_id);
|
223 |
|
224 |
return true;
|
225 |
}
|
@@ -288,19 +283,10 @@ function groups_leave_group( $group_id, $user_id = 0 ) {
|
|
288 |
}
|
289 |
}
|
290 |
|
291 |
-
$membership = new BP_Groups_Member( $user_id, $group_id );
|
292 |
-
|
293 |
// This is exactly the same as deleting an invite, just is_confirmed = 1 NOT 0.
|
294 |
-
if ( !groups_uninvite_user( $user_id, $group_id ) )
|
295 |
return false;
|
296 |
-
|
297 |
-
/**
|
298 |
-
* If the user joined this group less than five minutes ago, remove the
|
299 |
-
* joined_group activity so users cannot flood the activity stream by
|
300 |
-
* joining/leaving the group in quick succession.
|
301 |
-
*/
|
302 |
-
if ( bp_is_active( 'activity' ) && time() <= strtotime( '+5 minutes', (int)strtotime( $membership->date_modified ) ) )
|
303 |
-
bp_activity_delete( array( 'component' => $bp->groups->id, 'type' => 'joined_group', 'user_id' => $user_id, 'item_id' => $group_id ) );
|
304 |
|
305 |
bp_core_add_message( __( 'You successfully left the group.', 'buddypress' ) );
|
306 |
|
@@ -696,11 +682,13 @@ function groups_accept_invite( $user_id, $group_id ) {
|
|
696 |
// If the user is already a member (because BP at one point allowed two invitations to
|
697 |
// slip through), delete all existing invitations/requests and return true
|
698 |
if ( groups_is_user_member( $user_id, $group_id ) ) {
|
699 |
-
if ( groups_check_user_has_invite( $user_id, $group_id ) )
|
700 |
groups_delete_invite( $user_id, $group_id );
|
|
|
701 |
|
702 |
-
if ( groups_check_for_membership_request( $user_id, $group_id ) )
|
703 |
groups_delete_membership_request( $user_id, $group_id );
|
|
|
704 |
|
705 |
return true;
|
706 |
}
|
@@ -708,24 +696,25 @@ function groups_accept_invite( $user_id, $group_id ) {
|
|
708 |
$member = new BP_Groups_Member( $user_id, $group_id );
|
709 |
$member->accept_invite();
|
710 |
|
711 |
-
if ( !$member->save() )
|
712 |
return false;
|
|
|
713 |
|
714 |
// Remove request to join
|
715 |
-
if ( $member->check_for_membership_request( $user_id, $group_id ) )
|
716 |
$member->delete_request( $user_id, $group_id );
|
|
|
717 |
|
718 |
// Modify group meta
|
719 |
groups_update_groupmeta( $group_id, 'last_activity', bp_core_current_time() );
|
720 |
|
721 |
-
bp_core_mark_notifications_by_item_id( $user_id, $group_id, buddypress()->groups->id, 'group_invite' );
|
722 |
-
|
723 |
do_action( 'groups_accept_invite', $user_id, $group_id );
|
|
|
724 |
return true;
|
725 |
}
|
726 |
|
727 |
function groups_reject_invite( $user_id, $group_id ) {
|
728 |
-
if ( !BP_Groups_Member::delete( $user_id, $group_id ) )
|
729 |
return false;
|
730 |
|
731 |
do_action( 'groups_reject_invite', $user_id, $group_id );
|
@@ -734,14 +723,12 @@ function groups_reject_invite( $user_id, $group_id ) {
|
|
734 |
}
|
735 |
|
736 |
function groups_delete_invite( $user_id, $group_id ) {
|
|
|
|
|
737 |
|
738 |
-
|
739 |
-
|
740 |
-
if ( !empty( $delete ) ) {
|
741 |
-
bp_core_mark_notifications_by_item_id( $user_id, $group_id, buddypress()->groups->id, 'group_invite' );
|
742 |
-
}
|
743 |
|
744 |
-
return
|
745 |
}
|
746 |
|
747 |
function groups_send_invites( $user_id, $group_id ) {
|
@@ -905,46 +892,34 @@ function groups_send_membership_request( $requesting_user_id, $group_id ) {
|
|
905 |
|
906 |
function groups_accept_membership_request( $membership_id, $user_id = 0, $group_id = 0 ) {
|
907 |
|
908 |
-
if ( !empty( $user_id ) && !empty( $group_id ) )
|
909 |
$membership = new BP_Groups_Member( $user_id, $group_id );
|
910 |
-
else
|
911 |
$membership = new BP_Groups_Member( false, false, $membership_id );
|
|
|
912 |
|
913 |
$membership->accept_request();
|
914 |
|
915 |
-
if ( !$membership->save() )
|
916 |
return false;
|
|
|
917 |
|
918 |
// Check if the user has an outstanding invite, if so delete it.
|
919 |
-
if ( groups_check_user_has_invite( $membership->user_id, $membership->group_id ) )
|
920 |
groups_delete_invite( $membership->user_id, $membership->group_id );
|
|
|
921 |
|
922 |
-
|
923 |
-
$group = groups_get_group( array( 'group_id' => $membership->group_id ) );
|
924 |
-
|
925 |
-
groups_record_activity( array(
|
926 |
-
'action' => apply_filters_ref_array( 'groups_activity_membership_accepted_action', array( sprintf( __( '%1$s joined the group %2$s', 'buddypress'), bp_core_get_userlink( $membership->user_id ), '<a href="' . bp_get_group_permalink( $group ) . '">' . esc_attr( $group->name ) . '</a>' ), $membership->user_id, &$group ) ),
|
927 |
-
'type' => 'joined_group',
|
928 |
-
'item_id' => $membership->group_id,
|
929 |
-
'user_id' => $membership->user_id
|
930 |
-
) );
|
931 |
-
|
932 |
-
// Send a notification to the user.
|
933 |
-
groups_notification_membership_request_completed( $membership->user_id, $membership->group_id, true );
|
934 |
-
|
935 |
-
do_action( 'groups_membership_accepted', $membership->user_id, $membership->group_id );
|
936 |
|
937 |
return true;
|
938 |
}
|
939 |
|
940 |
function groups_reject_membership_request( $membership_id, $user_id = 0, $group_id = 0 ) {
|
941 |
-
if ( !$membership = groups_delete_membership_request( $membership_id, $user_id, $group_id ) )
|
942 |
return false;
|
|
|
943 |
|
944 |
-
|
945 |
-
groups_notification_membership_request_completed( $membership->user_id, $membership->group_id, false );
|
946 |
-
|
947 |
-
do_action( 'groups_membership_rejected', $membership->user_id, $membership->group_id );
|
948 |
|
949 |
return true;
|
950 |
}
|
@@ -1074,12 +1049,8 @@ function groups_update_groupmeta( $group_id, $meta_key, $meta_value ) {
|
|
1074 |
/*** Group Cleanup Functions ****************************************************/
|
1075 |
|
1076 |
function groups_remove_data_for_user( $user_id ) {
|
1077 |
-
global $bp;
|
1078 |
-
|
1079 |
BP_Groups_Member::delete_all_for_user( $user_id );
|
1080 |
|
1081 |
-
bp_core_delete_notifications_from_user( $user_id, $bp->groups->id, 'new_membership_request' );
|
1082 |
-
|
1083 |
do_action( 'groups_remove_data_for_user', $user_id );
|
1084 |
}
|
1085 |
add_action( 'wpmu_delete_user', 'groups_remove_data_for_user' );
|
200 |
* @since BuddyPress (1.0)
|
201 |
*/
|
202 |
function groups_delete_group( $group_id ) {
|
|
|
203 |
|
204 |
do_action( 'groups_before_delete_group', $group_id );
|
205 |
|
206 |
// Get the group object
|
207 |
$group = groups_get_group( array( 'group_id' => $group_id ) );
|
|
|
|
|
208 |
|
209 |
+
// Bail if group cannot be deleted
|
210 |
+
if ( ! $group->delete() ) {
|
211 |
+
return false;
|
212 |
+
}
|
213 |
|
214 |
// Remove all outstanding invites for this group
|
215 |
groups_delete_all_group_invites( $group_id );
|
216 |
|
217 |
+
do_action( 'groups_delete_group', $group_id );
|
|
|
|
|
|
|
218 |
|
219 |
return true;
|
220 |
}
|
283 |
}
|
284 |
}
|
285 |
|
|
|
|
|
286 |
// This is exactly the same as deleting an invite, just is_confirmed = 1 NOT 0.
|
287 |
+
if ( !groups_uninvite_user( $user_id, $group_id ) ) {
|
288 |
return false;
|
289 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
290 |
|
291 |
bp_core_add_message( __( 'You successfully left the group.', 'buddypress' ) );
|
292 |
|
682 |
// If the user is already a member (because BP at one point allowed two invitations to
|
683 |
// slip through), delete all existing invitations/requests and return true
|
684 |
if ( groups_is_user_member( $user_id, $group_id ) ) {
|
685 |
+
if ( groups_check_user_has_invite( $user_id, $group_id ) ) {
|
686 |
groups_delete_invite( $user_id, $group_id );
|
687 |
+
}
|
688 |
|
689 |
+
if ( groups_check_for_membership_request( $user_id, $group_id ) ) {
|
690 |
groups_delete_membership_request( $user_id, $group_id );
|
691 |
+
}
|
692 |
|
693 |
return true;
|
694 |
}
|
696 |
$member = new BP_Groups_Member( $user_id, $group_id );
|
697 |
$member->accept_invite();
|
698 |
|
699 |
+
if ( !$member->save() ) {
|
700 |
return false;
|
701 |
+
}
|
702 |
|
703 |
// Remove request to join
|
704 |
+
if ( $member->check_for_membership_request( $user_id, $group_id ) ) {
|
705 |
$member->delete_request( $user_id, $group_id );
|
706 |
+
}
|
707 |
|
708 |
// Modify group meta
|
709 |
groups_update_groupmeta( $group_id, 'last_activity', bp_core_current_time() );
|
710 |
|
|
|
|
|
711 |
do_action( 'groups_accept_invite', $user_id, $group_id );
|
712 |
+
|
713 |
return true;
|
714 |
}
|
715 |
|
716 |
function groups_reject_invite( $user_id, $group_id ) {
|
717 |
+
if ( ! BP_Groups_Member::delete( $user_id, $group_id ) )
|
718 |
return false;
|
719 |
|
720 |
do_action( 'groups_reject_invite', $user_id, $group_id );
|
723 |
}
|
724 |
|
725 |
function groups_delete_invite( $user_id, $group_id ) {
|
726 |
+
if ( ! BP_Groups_Member::delete_invite( $user_id, $group_id ) )
|
727 |
+
return false;
|
728 |
|
729 |
+
do_action( 'groups_delete_invite', $user_id, $group_id );
|
|
|
|
|
|
|
|
|
730 |
|
731 |
+
return true;
|
732 |
}
|
733 |
|
734 |
function groups_send_invites( $user_id, $group_id ) {
|
892 |
|
893 |
function groups_accept_membership_request( $membership_id, $user_id = 0, $group_id = 0 ) {
|
894 |
|
895 |
+
if ( !empty( $user_id ) && !empty( $group_id ) ) {
|
896 |
$membership = new BP_Groups_Member( $user_id, $group_id );
|
897 |
+
} else {
|
898 |
$membership = new BP_Groups_Member( false, false, $membership_id );
|
899 |
+
}
|
900 |
|
901 |
$membership->accept_request();
|
902 |
|
903 |
+
if ( !$membership->save() ) {
|
904 |
return false;
|
905 |
+
}
|
906 |
|
907 |
// Check if the user has an outstanding invite, if so delete it.
|
908 |
+
if ( groups_check_user_has_invite( $membership->user_id, $membership->group_id ) ) {
|
909 |
groups_delete_invite( $membership->user_id, $membership->group_id );
|
910 |
+
}
|
911 |
|
912 |
+
do_action( 'groups_membership_accepted', $membership->user_id, $membership->group_id, true );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
913 |
|
914 |
return true;
|
915 |
}
|
916 |
|
917 |
function groups_reject_membership_request( $membership_id, $user_id = 0, $group_id = 0 ) {
|
918 |
+
if ( !$membership = groups_delete_membership_request( $membership_id, $user_id, $group_id ) ) {
|
919 |
return false;
|
920 |
+
}
|
921 |
|
922 |
+
do_action( 'groups_membership_rejected', $membership->user_id, $membership->group_id, false );
|
|
|
|
|
|
|
923 |
|
924 |
return true;
|
925 |
}
|
1049 |
/*** Group Cleanup Functions ****************************************************/
|
1050 |
|
1051 |
function groups_remove_data_for_user( $user_id ) {
|
|
|
|
|
1052 |
BP_Groups_Member::delete_all_for_user( $user_id );
|
1053 |
|
|
|
|
|
1054 |
do_action( 'groups_remove_data_for_user', $user_id );
|
1055 |
}
|
1056 |
add_action( 'wpmu_delete_user', 'groups_remove_data_for_user' );
|
@@ -13,6 +13,8 @@
|
|
13 |
// Exit if accessed directly
|
14 |
if ( !defined( 'ABSPATH' ) ) exit;
|
15 |
|
|
|
|
|
16 |
function groups_notification_group_updated( $group_id ) {
|
17 |
|
18 |
$group = groups_get_group( array( 'group_id' => $group_id ) );
|
@@ -56,7 +58,9 @@ To view the group: %2$s
|
|
56 |
|
57 |
function groups_notification_new_membership_request( $requesting_user_id, $admin_id, $group_id, $membership_id ) {
|
58 |
|
59 |
-
|
|
|
|
|
60 |
|
61 |
if ( 'no' == bp_get_user_meta( $admin_id, 'notification_groups_membership_request', true ) )
|
62 |
return false;
|
@@ -105,10 +109,13 @@ To view %4$s\'s profile: %5$s
|
|
105 |
function groups_notification_membership_request_completed( $requesting_user_id, $group_id, $accepted = true ) {
|
106 |
|
107 |
// Post a screen notification first.
|
108 |
-
if (
|
109 |
-
|
110 |
-
|
111 |
-
|
|
|
|
|
|
|
112 |
|
113 |
if ( 'no' == bp_get_user_meta( $requesting_user_id, 'notification_membership_request_completed', true ) )
|
114 |
return false;
|
@@ -159,6 +166,8 @@ To submit another request please log in and visit: %2$s
|
|
159 |
|
160 |
do_action( 'bp_groups_sent_membership_approved_email', $requesting_user_id, $subject, $message, $group_id );
|
161 |
}
|
|
|
|
|
162 |
|
163 |
function groups_notification_promoted_member( $user_id, $group_id ) {
|
164 |
|
@@ -171,7 +180,9 @@ function groups_notification_promoted_member( $user_id, $group_id ) {
|
|
171 |
}
|
172 |
|
173 |
// Post a screen notification first.
|
174 |
-
|
|
|
|
|
175 |
|
176 |
if ( 'no' == bp_get_user_meta( $user_id, 'notification_groups_admin_promotion', true ) )
|
177 |
return false;
|
@@ -222,7 +233,9 @@ function groups_notification_group_invites( &$group, &$member, $inviter_user_id
|
|
222 |
$invited_user_id = $member->user_id;
|
223 |
|
224 |
// Post a screen notification first.
|
225 |
-
|
|
|
|
|
226 |
|
227 |
if ( 'no' == bp_get_user_meta( $invited_user_id, 'notification_groups_invite', true ) )
|
228 |
return false;
|
@@ -264,3 +277,335 @@ To view %5$s\'s profile visit: %6$s
|
|
264 |
do_action( 'bp_groups_sent_invited_email', $invited_user_id, $subject, $message, $group );
|
265 |
}
|
266 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
// Exit if accessed directly
|
14 |
if ( !defined( 'ABSPATH' ) ) exit;
|
15 |
|
16 |
+
/** Emails ********************************************************************/
|
17 |
+
|
18 |
function groups_notification_group_updated( $group_id ) {
|
19 |
|
20 |
$group = groups_get_group( array( 'group_id' => $group_id ) );
|
58 |
|
59 |
function groups_notification_new_membership_request( $requesting_user_id, $admin_id, $group_id, $membership_id ) {
|
60 |
|
61 |
+
if ( bp_is_active( 'notifications' ) ) {
|
62 |
+
bp_notifications_add_notification( $requesting_user_id, $admin_id, 'groups', 'new_membership_request', $group_id );
|
63 |
+
}
|
64 |
|
65 |
if ( 'no' == bp_get_user_meta( $admin_id, 'notification_groups_membership_request', true ) )
|
66 |
return false;
|
109 |
function groups_notification_membership_request_completed( $requesting_user_id, $group_id, $accepted = true ) {
|
110 |
|
111 |
// Post a screen notification first.
|
112 |
+
if ( bp_is_active( 'notifications' ) ) {
|
113 |
+
if ( $accepted ) {
|
114 |
+
bp_notifications_add_notification( $group_id, $requesting_user_id, 'groups', 'membership_request_accepted' );
|
115 |
+
} else {
|
116 |
+
bp_notifications_add_notification( $group_id, $requesting_user_id, 'groups', 'membership_request_rejected' );
|
117 |
+
}
|
118 |
+
}
|
119 |
|
120 |
if ( 'no' == bp_get_user_meta( $requesting_user_id, 'notification_membership_request_completed', true ) )
|
121 |
return false;
|
166 |
|
167 |
do_action( 'bp_groups_sent_membership_approved_email', $requesting_user_id, $subject, $message, $group_id );
|
168 |
}
|
169 |
+
add_action( 'groups_membership_accepted', 'groups_notification_membership_request_completed', 10, 3 );
|
170 |
+
add_action( 'groups_membership_rejected', 'groups_notification_membership_request_completed', 10, 3 );
|
171 |
|
172 |
function groups_notification_promoted_member( $user_id, $group_id ) {
|
173 |
|
180 |
}
|
181 |
|
182 |
// Post a screen notification first.
|
183 |
+
if ( bp_is_active( 'notifications' ) ) {
|
184 |
+
bp_notifications_add_notification( $group_id, $user_id, 'groups', $type );
|
185 |
+
}
|
186 |
|
187 |
if ( 'no' == bp_get_user_meta( $user_id, 'notification_groups_admin_promotion', true ) )
|
188 |
return false;
|
233 |
$invited_user_id = $member->user_id;
|
234 |
|
235 |
// Post a screen notification first.
|
236 |
+
if ( bp_is_active( 'notifications' ) ) {
|
237 |
+
bp_notifications_add_notification( $group->id, $invited_user_id, 'groups', 'group_invite' );
|
238 |
+
}
|
239 |
|
240 |
if ( 'no' == bp_get_user_meta( $invited_user_id, 'notification_groups_invite', true ) )
|
241 |
return false;
|
277 |
do_action( 'bp_groups_sent_invited_email', $invited_user_id, $subject, $message, $group );
|
278 |
}
|
279 |
}
|
280 |
+
|
281 |
+
/** Notifications *************************************************************/
|
282 |
+
|
283 |
+
/**
|
284 |
+
* Format the BuddyBar/Toolbar notifications for the Groups component
|
285 |
+
*
|
286 |
+
* @since BuddyPress (1.0)
|
287 |
+
* @param string $action The kind of notification being rendered
|
288 |
+
* @param int $item_id The primary item id
|
289 |
+
* @param int $secondary_item_id The secondary item id
|
290 |
+
* @param int $total_items The total number of messaging-related notifications waiting for the user
|
291 |
+
* @param string $format 'string' for BuddyBar-compatible notifications; 'array' for WP Toolbar
|
292 |
+
*/
|
293 |
+
function groups_format_notifications( $action, $item_id, $secondary_item_id, $total_items, $format = 'string' ) {
|
294 |
+
|
295 |
+
switch ( $action ) {
|
296 |
+
case 'new_membership_request':
|
297 |
+
$group_id = $secondary_item_id;
|
298 |
+
$requesting_user_id = $item_id;
|
299 |
+
|
300 |
+
$group = groups_get_group( array( 'group_id' => $group_id ) );
|
301 |
+
$group_link = bp_get_group_permalink( $group );
|
302 |
+
|
303 |
+
// Set up the string and the filter
|
304 |
+
// Because different values are passed to the filters, we'll return the
|
305 |
+
// values inline
|
306 |
+
if ( (int) $total_items > 1 ) {
|
307 |
+
$text = sprintf( __( '%1$d new membership requests for the group "%2$s"', 'buddypress' ), (int) $total_items, $group->name );
|
308 |
+
$filter = 'bp_groups_multiple_new_membership_requests_notification';
|
309 |
+
$notification_link = $group_link . 'admin/membership-requests/?n=1';
|
310 |
+
|
311 |
+
if ( 'string' == $format ) {
|
312 |
+
return apply_filters( $filter, '<a href="' . $notification_link . '" title="' . __( 'Group Membership Requests', 'buddypress' ) . '">' . $text . '</a>', $group_link, $total_items, $group->name, $text, $notification_link );
|
313 |
+
} else {
|
314 |
+
return apply_filters( $filter, array(
|
315 |
+
'link' => $notification_link,
|
316 |
+
'text' => $text
|
317 |
+
), $group_link, $total_items, $group->name, $text, $notification_link );
|
318 |
+
}
|
319 |
+
} else {
|
320 |
+
$user_fullname = bp_core_get_user_displayname( $requesting_user_id );
|
321 |
+
$text = sprintf( __( '%s requests group membership', 'buddypress' ), $user_fullname );
|
322 |
+
$filter = 'bp_groups_single_new_membership_request_notification';
|
323 |
+
$notification_link = $group_link . 'admin/membership-requests/?n=1';
|
324 |
+
|
325 |
+
if ( 'string' == $format ) {
|
326 |
+
return apply_filters( $filter, '<a href="' . $notification_link . '" title="' . sprintf( __( '%s requests group membership', 'buddypress' ), $user_fullname ) . '">' . $text . '</a>', $group_link, $user_fullname, $group->name, $text, $notification_link );
|
327 |
+
} else {
|
328 |
+
return apply_filters( $filter, array(
|
329 |
+
'link' => $notification_link,
|
330 |
+
'text' => $text
|
331 |
+
), $group_link, $user_fullname, $group->name, $text, $notification_link );
|
332 |
+
}
|
333 |
+
}
|
334 |
+
|
335 |
+
break;
|
336 |
+
|
337 |
+
case 'membership_request_accepted':
|
338 |
+
$group_id = $item_id;
|
339 |
+
|
340 |
+
$group = groups_get_group( array( 'group_id' => $group_id ) );
|
341 |
+
$group_link = bp_get_group_permalink( $group );
|
342 |
+
|
343 |
+
if ( (int) $total_items > 1 ) {
|
344 |
+
$text = sprintf( __( '%d accepted group membership requests', 'buddypress' ), (int) $total_items, $group->name );
|
345 |
+
$filter = 'bp_groups_multiple_membership_request_accepted_notification';
|
346 |
+
$notification_link = trailingslashit( bp_loggedin_user_domain() . bp_get_groups_slug() ) . '?n=1';
|
347 |
+
|
348 |
+
if ( 'string' == $format ) {
|
349 |
+
return apply_filters( $filter, '<a href="' . $notification_link . '" title="' . __( 'Groups', 'buddypress' ) . '">' . $text . '</a>', $total_items, $group->name, $text, $notification_link );
|
350 |
+
} else {
|
351 |
+
return apply_filters( $filter, array(
|
352 |
+
'link' => $notification_link,
|
353 |
+
'text' => $text
|
354 |
+
), $total_items, $group->name, $text, $notification_link );
|
355 |
+
}
|
356 |
+
} else {
|
357 |
+
$text = sprintf( __( 'Membership for group "%s" accepted', 'buddypress' ), $group->name );
|
358 |
+
$filter = 'bp_groups_single_membership_request_accepted_notification';
|
359 |
+
$notification_link = $group_link . '?n=1';
|
360 |
+
|
361 |
+
if ( 'string' == $format ) {
|
362 |
+
return apply_filters( $filter, '<a href="' . $notification_link . '">' . $text . '</a>', $group_link, $group->name, $text, $notification_link );
|
363 |
+
} else {
|
364 |
+
return apply_filters( $filter, array(
|
365 |
+
'link' => $notification_link,
|
366 |
+
'text' => $text
|
367 |
+
), $group_link, $group->name, $text, $notification_link );
|
368 |
+
}
|
369 |
+
}
|
370 |
+
|
371 |
+
break;
|
372 |
+
|
373 |
+
case 'membership_request_rejected':
|
374 |
+
$group_id = $item_id;
|
375 |
+
|
376 |
+
$group = groups_get_group( array( 'group_id' => $group_id ) );
|
377 |
+
$group_link = bp_get_group_permalink( $group );
|
378 |
+
|
379 |
+
if ( (int) $total_items > 1 ) {
|
380 |
+
$text = sprintf( __( '%d rejected group membership requests', 'buddypress' ), (int) $total_items, $group->name );
|
381 |
+
$filter = 'bp_groups_multiple_membership_request_rejected_notification';
|
382 |
+
$notification_link = trailingslashit( bp_loggedin_user_domain() . bp_get_groups_slug() ) . '?n=1';
|
383 |
+
|
384 |
+
if ( 'string' == $format ) {
|
385 |
+
return apply_filters( $filter, '<a href="' . $notification_link . '" title="' . __( 'Groups', 'buddypress' ) . '">' . $text . '</a>', $total_items, $group->name );
|
386 |
+
} else {
|
387 |
+
return apply_filters( $filter, array(
|
388 |
+
'link' => $notification_link,
|
389 |
+
'text' => $text
|
390 |
+
), $total_items, $group->name, $text, $notification_link );
|
391 |
+
}
|
392 |
+
} else {
|
393 |
+
$text = sprintf( __( 'Membership for group "%s" rejected', 'buddypress' ), $group->name );
|
394 |
+
$filter = 'bp_groups_single_membership_request_rejected_notification';
|
395 |
+
$notification_link = $group_link . '?n=1';
|
396 |
+
|
397 |
+
if ( 'string' == $format ) {
|
398 |
+
return apply_filters( $filter, '<a href="' . $notification_link . '">' . $text . '</a>', $group_link, $group->name, $text, $notification_link );
|
399 |
+
} else {
|
400 |
+
return apply_filters( $filter, array(
|
401 |
+
'link' => $notification_link,
|
402 |
+
'text' => $text
|
403 |
+
), $group_link, $group->name, $text, $notification_link );
|
404 |
+
}
|
405 |
+
}
|
406 |
+
|
407 |
+
break;
|
408 |
+
|
409 |
+
case 'member_promoted_to_admin':
|
410 |
+
$group_id = $item_id;
|
411 |
+
|
412 |
+
$group = groups_get_group( array( 'group_id' => $group_id ) );
|
413 |
+
$group_link = bp_get_group_permalink( $group );
|
414 |
+
|
415 |
+
if ( (int) $total_items > 1 ) {
|
416 |
+
$text = sprintf( __( 'You were promoted to an admin in %d groups', 'buddypress' ), (int) $total_items );
|
417 |
+
$filter = 'bp_groups_multiple_member_promoted_to_admin_notification';
|
418 |
+
$notification_link = trailingslashit( bp_loggedin_user_domain() . bp_get_groups_slug() ) . '?n=1';
|
419 |
+
|
420 |
+
if ( 'string' == $format ) {
|
421 |
+
return apply_filters( $filter, '<a href="' . $notification_link . '" title="' . __( 'Groups', 'buddypress' ) . '">' . $text . '</a>', $total_items, $text, $notification_link );
|
422 |
+
} else {
|
423 |
+
return apply_filters( $filter, array(
|
424 |
+
'link' => $notification_link,
|
425 |
+
'text' => $text
|
426 |
+
), $total_items, $text, $notification_link );
|
427 |
+
}
|
428 |
+
} else {
|
429 |
+
$text = sprintf( __( 'You were promoted to an admin in the group "%s"', 'buddypress' ), $group->name );
|
430 |
+
$filter = 'bp_groups_single_member_promoted_to_admin_notification';
|
431 |
+
$notification_link = $group_link . '?n=1';
|
432 |
+
|
433 |
+
if ( 'string' == $format ) {
|
434 |
+
return apply_filters( $filter, '<a href="' . $notification_link . '">' . $text . '</a>', $group_link, $group->name, $text, $notification_link );
|
435 |
+
} else {
|
436 |
+
return apply_filters( $filter, array(
|
437 |
+
'link' => $notification_link,
|
438 |
+
'text' => $text
|
439 |
+
), $group_link, $group->name, $text, $notification_link );
|
440 |
+
}
|
441 |
+
}
|
442 |
+
|
443 |
+
break;
|
444 |
+
|
445 |
+
case 'member_promoted_to_mod':
|
446 |
+
$group_id = $item_id;
|
447 |
+
|
448 |
+
$group = groups_get_group( array( 'group_id' => $group_id ) );
|
449 |
+
$group_link = bp_get_group_permalink( $group );
|
450 |
+
|
451 |
+
if ( (int) $total_items > 1 ) {
|
452 |
+
$text = sprintf( __( 'You were promoted to a mod in %d groups', 'buddypress' ), (int) $total_items );
|
453 |
+
$filter = 'bp_groups_multiple_member_promoted_to_mod_notification';
|
454 |
+
$notification_link = trailingslashit( bp_loggedin_user_domain() . bp_get_groups_slug() ) . '?n=1';
|
455 |
+
|
456 |
+
if ( 'string' == $format ) {
|
457 |
+
return apply_filters( $filter, '<a href="' . $notification_link . '" title="' . __( 'Groups', 'buddypress' ) . '">' . $text . '</a>', $total_items, $text, $notification_link );
|
458 |
+
} else {
|
459 |
+
return apply_filters( $filter, array(
|
460 |
+
'link' => $notification_link,
|
461 |
+
'text' => $text
|
462 |
+
), $total_items, $text, $notification_link );
|
463 |
+
}
|
464 |
+
} else {
|
465 |
+
$text = sprintf( __( 'You were promoted to a mod in the group "%s"', 'buddypress' ), $group->name );
|
466 |
+
$filter = 'bp_groups_single_member_promoted_to_mod_notification';
|
467 |
+
$notification_link = $group_link . '?n=1';
|
468 |
+
|
469 |
+
if ( 'string' == $format ) {
|
470 |
+
return apply_filters( $filter, '<a href="' . $notification_link . '">' . $text . '</a>', $group_link, $group->name, $text, $notification_link );
|
471 |
+
} else {
|
472 |
+
return apply_filters( $filter, array(
|
473 |
+
'link' => $notification_link,
|
474 |
+
'text' => $text
|
475 |
+
), $group_link, $group->name, $text, $notification_link );
|
476 |
+
}
|
477 |
+
}
|
478 |
+
|
479 |
+
break;
|
480 |
+
|
481 |
+
case 'group_invite':
|
482 |
+
$group_id = $item_id;
|
483 |
+
$group = groups_get_group( array( 'group_id' => $group_id ) );
|
484 |
+
$group_link = bp_get_group_permalink( $group );
|
485 |
+
|
486 |
+
$notification_link = bp_loggedin_user_domain() . bp_get_groups_slug() . '/invites/?n=1';
|
487 |
+
|
488 |
+
if ( (int) $total_items > 1 ) {
|
489 |
+
$text = sprintf( __( 'You have %d new group invitations', 'buddypress' ), (int) $total_items );
|
490 |
+
$filter = 'bp_groups_multiple_group_invite_notification';
|
491 |
+
|
492 |
+
if ( 'string' == $format ) {
|
493 |
+
return apply_filters( $filter, '<a href="' . $notification_link . '" title="' . __( 'Group Invites', 'buddypress' ) . '">' . $text . '</a>', $total_items, $text, $notification_link );
|
494 |
+
} else {
|
495 |
+
return apply_filters( $filter, array(
|
496 |
+
'link' => $notification_link,
|
497 |
+
'text' => $text
|
498 |
+
), $total_items, $text, $notification_link );
|
499 |
+
}
|
500 |
+
} else {
|
501 |
+
$text = sprintf( __( 'You have an invitation to the group: %s', 'buddypress' ), $group->name );
|
502 |
+
$filter = 'bp_groups_single_group_invite_notification';
|
503 |
+
|
504 |
+
if ( 'string' == $format ) {
|
505 |
+
return apply_filters( $filter, '<a href="' . $notification_link . '">' . $text . '</a>', $group_link, $group->name, $text, $notification_link );
|
506 |
+
} else {
|
507 |
+
return apply_filters( $filter, array(
|
508 |
+
'link' => $notification_link,
|
509 |
+
'text' => $text
|
510 |
+
), $group_link, $group->name, $text, $notification_link );
|
511 |
+
}
|
512 |
+
}
|
513 |
+
|
514 |
+
break;
|
515 |
+
}
|
516 |
+
|
517 |
+
do_action( 'groups_format_notifications', $action, $item_id, $secondary_item_id, $total_items );
|
518 |
+
|
519 |
+
return false;
|
520 |
+
}
|
521 |
+
|
522 |
+
/**
|
523 |
+
* Remove all notifications for any member belonging to a specific group
|
524 |
+
*
|
525 |
+
* @since BuddyPress (1.9.0)
|
526 |
+
*/
|
527 |
+
function bp_groups_delete_group_delete_all_notifications( $group_id ) {
|
528 |
+
if ( bp_is_active( 'notifications' ) ) {
|
529 |
+
bp_notifications_delete_all_notifications_by_type( $group_id, buddypress()->groups->id );
|
530 |
+
}
|
531 |
+
}
|
532 |
+
add_action( 'groups_delete_group', 'bp_groups_delete_group_delete_all_notifications', 10 );
|
533 |
+
|
534 |
+
/**
|
535 |
+
* Mark notifications read when a member accepts a group invitation
|
536 |
+
*
|
537 |
+
* @since BuddyPress (1.9.0)
|
538 |
+
* @param int $user_id
|
539 |
+
* @param int $group_id
|
540 |
+
*/
|
541 |
+
function bp_groups_accept_invite_mark_notifications( $user_id, $group_id ) {
|
542 |
+
if ( bp_is_active( 'notifications' ) ) {
|
543 |
+
bp_notifications_mark_notifications_by_item_id( $user_id, $group_id, buddypress()->groups->id, 'group_invite' );
|
544 |
+
}
|
545 |
+
}
|
546 |
+
add_action( 'groups_accept_invite', 'bp_groups_accept_invite_mark_notifications', 10, 2 );
|
547 |
+
add_action( 'groups_reject_invite', 'bp_groups_accept_invite_mark_notifications', 10, 2 );
|
548 |
+
add_action( 'groups_delete_invite', 'bp_groups_accept_invite_mark_notifications', 10, 2 );
|
549 |
+
|
550 |
+
/**
|
551 |
+
* Mark notifications read when a member views their group memberships
|
552 |
+
*
|
553 |
+
* @since BuddyPress (1.9.0)
|
554 |
+
*/
|
555 |
+
function bp_groups_screen_my_groups_mark_notifications() {
|
556 |
+
|
557 |
+
// Delete group request notifications for the user
|
558 |
+
if ( isset( $_GET['n'] ) && bp_is_active( 'notifications' ) ) {
|
559 |
+
|
560 |
+
// Get the necessary ID's
|
561 |
+
$group_id = buddypress()->groups->id;
|
562 |
+
$user_id = bp_loggedin_user_id();
|
563 |
+
|
564 |
+
// Mark notifications read
|
565 |
+
bp_notifications_mark_notifications_by_type( $user_id, $group_id, 'membership_request_accepted' );
|
566 |
+
bp_notifications_mark_notifications_by_type( $user_id, $group_id, 'membership_request_rejected' );
|
567 |
+
bp_notifications_mark_notifications_by_type( $user_id, $group_id, 'member_promoted_to_mod' );
|
568 |
+
bp_notifications_mark_notifications_by_type( $user_id, $group_id, 'member_promoted_to_admin' );
|
569 |
+
}
|
570 |
+
}
|
571 |
+
add_action( 'groups_screen_my_groups', 'bp_groups_screen_my_groups_mark_notifications', 10 );
|
572 |
+
add_action( 'groups_screen_home', 'bp_groups_screen_my_groups_mark_notifications', 10 );
|
573 |
+
|
574 |
+
/**
|
575 |
+
* Mark group invitation notifications read when a member views their invitations
|
576 |
+
*
|
577 |
+
* @since BuddyPress (1.9.0)
|
578 |
+
*/
|
579 |
+
function bp_groups_screen_invites_mark_notifications() {
|
580 |
+
if ( bp_is_active( 'notifications' ) ) {
|
581 |
+
bp_notifications_mark_notifications_by_type( bp_loggedin_user_id(), buddypress()->groups->id, 'group_invite' );
|
582 |
+
}
|
583 |
+
}
|
584 |
+
add_action( 'groups_screen_invites', 'bp_groups_screen_invites_mark_notifications', 10 );
|
585 |
+
|
586 |
+
/**
|
587 |
+
* Mark group join requests read when an admin or moderator visits the group
|
588 |
+
* administration area.
|
589 |
+
*
|
590 |
+
* @since BuddyPress (1.9.0)
|
591 |
+
* @param int $group_id
|
592 |
+
*/
|
593 |
+
function bp_groups_screen_group_admin_requests_mark_notifications( $group_id ) {
|
594 |
+
if ( bp_is_active( 'notifications' ) ) {
|
595 |
+
bp_notifications_mark_notifications_by_type( bp_loggedin_user_id(), $group_id, 'new_membership_request' );
|
596 |
+
}
|
597 |
+
}
|
598 |
+
add_action( 'groups_screen_group_admin_requests', 'bp_groups_screen_group_admin_requests_mark_notifications', 10 );
|
599 |
+
|
600 |
+
/**
|
601 |
+
* Delete new group membership notifications when a user is being deleted.
|
602 |
+
*
|
603 |
+
* @since BuddyPress (1.9.0)
|
604 |
+
* @param int $user_id
|
605 |
+
*/
|
606 |
+
function bp_groups_remove_data_for_user_notifications( $user_id ) {
|
607 |
+
if ( bp_is_active( 'notifications' ) ) {
|
608 |
+
bp_notifications_delete_notifications_from_user( $user_id, buddypress()->groups->id, 'new_membership_request' );
|
609 |
+
}
|
610 |
+
}
|
611 |
+
add_action( 'groups_remove_data_for_user', 'bp_groups_remove_data_for_user_notifications', 10 );
|
@@ -27,16 +27,6 @@ add_action( 'bp_screens', 'groups_directory_groups_setup', 2 );
|
|
27 |
|
28 |
function groups_screen_my_groups() {
|
29 |
|
30 |
-
$bp = buddypress();
|
31 |
-
|
32 |
-
// Delete group request notifications for the user
|
33 |
-
if ( isset( $_GET['n'] ) ) {
|
34 |
-
bp_core_mark_notifications_by_type( bp_loggedin_user_id(), $bp->groups->id, 'membership_request_accepted' );
|
35 |
-
bp_core_mark_notifications_by_type( bp_loggedin_user_id(), $bp->groups->id, 'membership_request_rejected' );
|
36 |
-
bp_core_mark_notifications_by_type( bp_loggedin_user_id(), $bp->groups->id, 'member_promoted_to_mod' );
|
37 |
-
bp_core_mark_notifications_by_type( bp_loggedin_user_id(), $bp->groups->id, 'member_promoted_to_admin' );
|
38 |
-
}
|
39 |
-
|
40 |
do_action( 'groups_screen_my_groups' );
|
41 |
|
42 |
bp_core_load_template( apply_filters( 'groups_template_my_groups', 'members/single/home' ) );
|
@@ -93,9 +83,6 @@ function groups_screen_group_invites() {
|
|
93 |
bp_core_redirect( $redirect_to );
|
94 |
}
|
95 |
|
96 |
-
// Remove notifications
|
97 |
-
bp_core_mark_notifications_by_type( bp_loggedin_user_id(), buddypress()->groups->id, 'group_invite' );
|
98 |
-
|
99 |
do_action( 'groups_screen_group_invites', $group_id );
|
100 |
|
101 |
bp_core_load_template( apply_filters( 'groups_template_group_invites', 'members/single/home' ) );
|
@@ -103,16 +90,8 @@ function groups_screen_group_invites() {
|
|
103 |
|
104 |
function groups_screen_group_home() {
|
105 |
|
106 |
-
if ( ! bp_is_single_item() )
|
107 |
return false;
|
108 |
-
|
109 |
-
$bp = buddypress();
|
110 |
-
|
111 |
-
if ( isset( $_GET['n'] ) ) {
|
112 |
-
bp_core_mark_notifications_by_type( bp_loggedin_user_id(), $bp->groups->id, 'membership_request_accepted' );
|
113 |
-
bp_core_mark_notifications_by_type( bp_loggedin_user_id(), $bp->groups->id, 'membership_request_rejected' );
|
114 |
-
bp_core_mark_notifications_by_type( bp_loggedin_user_id(), $bp->groups->id, 'member_promoted_to_mod' );
|
115 |
-
bp_core_mark_notifications_by_type( bp_loggedin_user_id(), $bp->groups->id, 'member_promoted_to_admin' );
|
116 |
}
|
117 |
|
118 |
do_action( 'groups_screen_group_home' );
|
@@ -804,19 +783,18 @@ function groups_screen_group_admin_manage_members() {
|
|
804 |
add_action( 'bp_screens', 'groups_screen_group_admin_manage_members' );
|
805 |
|
806 |
function groups_screen_group_admin_requests() {
|
807 |
-
|
808 |
|
809 |
-
if ( 'membership-requests' != bp_get_group_current_admin_tab() )
|
810 |
return false;
|
|
|
811 |
|
812 |
-
if ( ! bp_is_item_admin() || ( 'public' == $bp->groups->current_group->status ) )
|
813 |
return false;
|
|
|
814 |
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
$request_action = (string)bp_action_variable( 1 );
|
819 |
-
$membership_id = (int)bp_action_variable( 2 );
|
820 |
|
821 |
if ( !empty( $request_action ) && !empty( $membership_id ) ) {
|
822 |
if ( 'accept' == $request_action && is_numeric( $membership_id ) ) {
|
27 |
|
28 |
function groups_screen_my_groups() {
|
29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
do_action( 'groups_screen_my_groups' );
|
31 |
|
32 |
bp_core_load_template( apply_filters( 'groups_template_my_groups', 'members/single/home' ) );
|
83 |
bp_core_redirect( $redirect_to );
|
84 |
}
|
85 |
|
|
|
|
|
|
|
86 |
do_action( 'groups_screen_group_invites', $group_id );
|
87 |
|
88 |
bp_core_load_template( apply_filters( 'groups_template_group_invites', 'members/single/home' ) );
|
90 |
|
91 |
function groups_screen_group_home() {
|
92 |
|
93 |
+
if ( ! bp_is_single_item() ) {
|
94 |
return false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
}
|
96 |
|
97 |
do_action( 'groups_screen_group_home' );
|
783 |
add_action( 'bp_screens', 'groups_screen_group_admin_manage_members' );
|
784 |
|
785 |
function groups_screen_group_admin_requests() {
|
786 |
+
$bp = buddypress();
|
787 |
|
788 |
+
if ( 'membership-requests' != bp_get_group_current_admin_tab() ) {
|
789 |
return false;
|
790 |
+
}
|
791 |
|
792 |
+
if ( ! bp_is_item_admin() || ( 'public' == $bp->groups->current_group->status ) ) {
|
793 |
return false;
|
794 |
+
}
|
795 |
|
796 |
+
$request_action = (string) bp_action_variable( 1 );
|
797 |
+
$membership_id = (int) bp_action_variable( 2 );
|
|
|
|
|
|
|
798 |
|
799 |
if ( !empty( $request_action ) && !empty( $membership_id ) ) {
|
800 |
if ( 'accept' == $request_action && is_numeric( $membership_id ) ) {
|
@@ -3,8 +3,8 @@
|
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
"Project-Id-Version: BuddyPress \n"
|
6 |
-
"Report-Msgid-Bugs-To: http://
|
7 |
-
"POT-Creation-Date: 2013-
|
8 |
"MIME-Version: 1.0\n"
|
9 |
"Content-Type: text/plain; charset=UTF-8\n"
|
10 |
"Content-Transfer-Encoding: 8bit\n"
|
@@ -144,8 +144,8 @@ msgstr ""
|
|
144 |
#: bp-activity/bp-activity-admin.php:871 bp-activity/bp-activity-admin.php:1204
|
145 |
#: bp-activity/bp-activity-loader.php:132
|
146 |
#: bp-activity/bp-activity-loader.php:261
|
147 |
-
#: bp-activity/bp-activity-screens.php:
|
148 |
-
#: bp-activity/bp-activity-screens.php:
|
149 |
msgid "Activity"
|
150 |
msgstr ""
|
151 |
|
@@ -158,10 +158,10 @@ msgid "ERROR: The item you are trying to reply to cannot be found, or it has bee
|
|
158 |
msgstr ""
|
159 |
|
160 |
#: bp-activity/bp-activity-admin.php:209 bp-activity/bp-activity-admin.php:256
|
161 |
-
#: bp-core/admin/bp-core-functions.php:
|
162 |
-
#: bp-core/admin/bp-core-functions.php:
|
163 |
-
#: bp-core/admin/bp-core-functions.php:
|
164 |
-
#: bp-core/admin/bp-core-functions.php:
|
165 |
#: bp-groups/bp-groups-admin.php:148
|
166 |
msgid "Overview"
|
167 |
msgstr ""
|
@@ -199,10 +199,10 @@ msgid "For information about when and how BuddyPress uses all of these settings,
|
|
199 |
msgstr ""
|
200 |
|
201 |
#: bp-activity/bp-activity-admin.php:228 bp-activity/bp-activity-admin.php:273
|
202 |
-
#: bp-core/admin/bp-core-functions.php:
|
203 |
-
#: bp-core/admin/bp-core-functions.php:
|
204 |
-
#: bp-core/admin/bp-core-functions.php:
|
205 |
-
#: bp-core/admin/bp-core-functions.php:
|
206 |
#: bp-groups/bp-groups-admin.php:164
|
207 |
msgid "For more information:"
|
208 |
msgstr ""
|
@@ -212,10 +212,10 @@ msgid "<a href=\"http://codex.buddypress.org/buddypress-site-administration/mana
|
|
212 |
msgstr ""
|
213 |
|
214 |
#: bp-activity/bp-activity-admin.php:230 bp-activity/bp-activity-admin.php:274
|
215 |
-
#: bp-core/admin/bp-core-functions.php:
|
216 |
-
#: bp-core/admin/bp-core-functions.php:
|
217 |
-
#: bp-core/admin/bp-core-functions.php:
|
218 |
-
#: bp-core/admin/bp-core-functions.php:
|
219 |
msgid "<a href=\"http://buddypress.org/support/\">Support Forums</a>"
|
220 |
msgstr ""
|
221 |
|
@@ -419,7 +419,7 @@ msgid "No activities found."
|
|
419 |
msgstr ""
|
420 |
|
421 |
#: bp-activity/bp-activity-admin.php:1167 bp-groups/bp-groups-admin.php:1262
|
422 |
-
#: bp-messages/bp-messages-template.php:
|
423 |
msgid "All"
|
424 |
msgstr ""
|
425 |
|
@@ -552,36 +552,24 @@ msgstr ""
|
|
552 |
msgid "…"
|
553 |
msgstr ""
|
554 |
|
555 |
-
#: bp-activity/bp-activity-functions.php:
|
556 |
-
msgid "@%s Mentions"
|
557 |
-
msgstr ""
|
558 |
-
|
559 |
-
#: bp-activity/bp-activity-functions.php:222
|
560 |
-
msgid "You have %1$d new mentions"
|
561 |
-
msgstr ""
|
562 |
-
|
563 |
-
#: bp-activity/bp-activity-functions.php:226
|
564 |
-
msgid "%1$s mentioned you"
|
565 |
-
msgstr ""
|
566 |
-
|
567 |
-
#: bp-activity/bp-activity-functions.php:928
|
568 |
msgid "Posted a status update"
|
569 |
msgstr ""
|
570 |
|
571 |
-
#: bp-activity/bp-activity-functions.php:
|
572 |
msgid "Replied to a status update"
|
573 |
msgstr ""
|
574 |
|
575 |
-
#: bp-activity/bp-activity-functions.php:
|
576 |
msgid "%s posted an update"
|
577 |
msgstr ""
|
578 |
|
579 |
-
#: bp-activity/bp-activity-functions.php:
|
580 |
#: tests/testcases/activity/class.BP_Activity_Activity.php:202
|
581 |
msgid "%s posted a new activity comment"
|
582 |
msgstr ""
|
583 |
|
584 |
-
#: bp-activity/bp-activity-functions.php:
|
585 |
msgid "Thumbnail"
|
586 |
msgstr ""
|
587 |
|
@@ -613,19 +601,21 @@ msgstr ""
|
|
613 |
|
614 |
#: bp-activity/bp-activity-loader.php:193
|
615 |
#: bp-activity/bp-activity-loader.php:296 bp-friends/bp-friends-loader.php:185
|
616 |
-
#: bp-friends/bp-friends-screens.php:
|
617 |
msgid "Friends"
|
618 |
msgstr ""
|
619 |
|
620 |
#: bp-activity/bp-activity-loader.php:206
|
621 |
#: bp-activity/bp-activity-loader.php:306 bp-core/bp-core-template.php:364
|
622 |
-
#: bp-groups/bp-groups-activity.php:179 bp-groups/bp-groups-activity.php:215
|
623 |
-
#: bp-groups/bp-groups-activity.php:251 bp-groups/bp-groups-activity.php:287
|
624 |
#: bp-groups/bp-groups-admin.php:32 bp-groups/bp-groups-admin.php:33
|
625 |
#: bp-groups/bp-groups-admin.php:638 bp-groups/bp-groups-loader.php:516
|
626 |
-
#: bp-groups/bp-groups-
|
627 |
-
#: bp-groups/bp-groups-
|
628 |
-
#: bp-groups/bp-groups-
|
|
|
|
|
|
|
|
|
629 |
#: bp-groups/bp-groups-widgets.php:124
|
630 |
msgid "Groups"
|
631 |
msgstr ""
|
@@ -655,8 +645,8 @@ msgstr ""
|
|
655 |
#: bp-members/bp-members-template.php:820
|
656 |
#: bp-members/bp-members-template.php:839
|
657 |
#: bp-messages/bp-messages-loader.php:258
|
658 |
-
#: bp-messages/bp-messages-template.php:
|
659 |
-
#: bp-notifications/bp-notifications-loader.php:
|
660 |
#: bp-templates/bp-legacy/buddypress/groups/single/admin.php:185
|
661 |
#: bp-templates/bp-legacy/buddypress/groups/single/admin.php:212
|
662 |
#: bp-themes/bp-default/groups/single/admin.php:185
|
@@ -665,11 +655,11 @@ msgstr ""
|
|
665 |
msgid "Profile picture of %s"
|
666 |
msgstr ""
|
667 |
|
668 |
-
#: bp-activity/bp-activity-notifications.php:
|
669 |
msgid "%s mentioned you in an update"
|
670 |
msgstr ""
|
671 |
|
672 |
-
#: bp-activity/bp-activity-notifications.php:
|
673 |
msgid ""
|
674 |
"%1$s mentioned you in the group \"%2$s\":\n"
|
675 |
"\n"
|
@@ -680,7 +670,7 @@ msgid ""
|
|
680 |
"---------------------\n"
|
681 |
msgstr ""
|
682 |
|
683 |
-
#: bp-activity/bp-activity-notifications.php:
|
684 |
msgid ""
|
685 |
"%1$s mentioned you in an update:\n"
|
686 |
"\n"
|
@@ -691,25 +681,25 @@ msgid ""
|
|
691 |
"---------------------\n"
|
692 |
msgstr ""
|
693 |
|
694 |
-
#: bp-activity/bp-activity-notifications.php:
|
695 |
-
#: bp-activity/bp-activity-notifications.php:
|
696 |
#: bp-activity/bp-activity-notifications.php:226 bp-core/deprecated/1.5.php:364
|
697 |
-
#: bp-friends/bp-friends-notifications.php:
|
698 |
-
#: bp-friends/bp-friends-notifications.php:
|
699 |
-
#: bp-groups/bp-groups-notifications.php:
|
700 |
-
#: bp-groups/bp-groups-notifications.php:
|
701 |
-
#: bp-groups/bp-groups-notifications.php:
|
702 |
-
#: bp-groups/bp-groups-notifications.php:
|
703 |
-
#: bp-groups/bp-groups-notifications.php:
|
704 |
-
#: bp-messages/bp-messages-notifications.php:
|
705 |
msgid "To disable these notifications please log in and go to: %s"
|
706 |
msgstr ""
|
707 |
|
708 |
-
#: bp-activity/bp-activity-notifications.php:
|
709 |
msgid "%s replied to one of your updates"
|
710 |
msgstr ""
|
711 |
|
712 |
-
#: bp-activity/bp-activity-notifications.php:
|
713 |
msgid ""
|
714 |
"%1$s replied to one of your updates:\n"
|
715 |
"\n"
|
@@ -735,35 +725,47 @@ msgid ""
|
|
735 |
"---------------------\n"
|
736 |
msgstr ""
|
737 |
|
738 |
-
#: bp-activity/bp-activity-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
739 |
msgid "You do not have access to this activity."
|
740 |
msgstr ""
|
741 |
|
742 |
-
#: bp-activity/bp-activity-screens.php:
|
743 |
-
#: bp-friends/bp-friends-screens.php:
|
744 |
#: bp-messages/bp-messages-screens.php:169
|
745 |
#: bp-templates/bp-legacy/buddypress/members/register.php:227
|
746 |
#: bp-themes/bp-default/registration/register.php:232
|
747 |
msgid "Yes"
|
748 |
msgstr ""
|
749 |
|
750 |
-
#: bp-activity/bp-activity-screens.php:
|
751 |
-
#: bp-friends/bp-friends-screens.php:
|
752 |
#: bp-messages/bp-messages-screens.php:170
|
753 |
#: bp-templates/bp-legacy/buddypress/members/register.php:228
|
754 |
#: bp-themes/bp-default/registration/register.php:233
|
755 |
msgid "No"
|
756 |
msgstr ""
|
757 |
|
758 |
-
#: bp-activity/bp-activity-screens.php:
|
759 |
msgid "A member mentions you in an update using \"@%s\""
|
760 |
msgstr ""
|
761 |
|
762 |
-
#: bp-activity/bp-activity-screens.php:
|
763 |
msgid "A member replies to an update or comment you've posted"
|
764 |
msgstr ""
|
765 |
|
766 |
-
#: bp-activity/bp-activity-screens.php:
|
767 |
msgid "Sitewide Activity"
|
768 |
msgstr ""
|
769 |
|
@@ -926,7 +928,7 @@ msgid "Sites"
|
|
926 |
msgstr ""
|
927 |
|
928 |
#: bp-blogs/bp-blogs-loader.php:203 bp-blogs/bp-blogs-screens.php:209
|
929 |
-
#: bp-blogs/bp-blogs-template.php:1099 bp-core/bp-core-filters.php:
|
930 |
#: bp-themes/bp-default/blogs/create.php:21
|
931 |
#: bp-themes/bp-default/blogs/index.php:21
|
932 |
msgid "Create a Site"
|
@@ -956,7 +958,7 @@ msgstr[1] ""
|
|
956 |
msgid "Profile picture of site author %s"
|
957 |
msgstr ""
|
958 |
|
959 |
-
#: bp-blogs/bp-blogs-template.php:633 bp-core/bp-core-classes.php:
|
960 |
#: bp-groups/bp-groups-widgets.php:85 bp-groups/bp-groups-widgets.php:188
|
961 |
#: bp-members/bp-members-template.php:596
|
962 |
#: bp-members/bp-members-template.php:871
|
@@ -1048,7 +1050,7 @@ msgstr ""
|
|
1048 |
#: bp-blogs/bp-blogs-template.php:1134 bp-core/deprecated/1.5.php:417
|
1049 |
#: bp-forums/bp-forums-template.php:2196 bp-groups/bp-groups-template.php:2530
|
1050 |
#: bp-members/bp-members-template.php:710
|
1051 |
-
#: bp-messages/bp-messages-template.php:
|
1052 |
#: bp-themes/bp-default/searchform.php:5
|
1053 |
msgid "Search"
|
1054 |
msgstr ""
|
@@ -1122,9 +1124,8 @@ msgstr ""
|
|
1122 |
#: bp-core/admin/bp-core-components.php:383
|
1123 |
#: bp-notifications/bp-notifications-buddybar.php:28
|
1124 |
#: bp-notifications/bp-notifications-loader.php:26
|
1125 |
-
#: bp-notifications/bp-notifications-loader.php:
|
1126 |
-
#: bp-notifications/bp-notifications-loader.php:
|
1127 |
-
#: bp-settings/bp-settings-loader.php:179
|
1128 |
msgid "Notifications"
|
1129 |
msgstr ""
|
1130 |
|
@@ -1225,7 +1226,7 @@ msgid "Allow your users to talk to each other directly and in private. Not just
|
|
1225 |
msgstr ""
|
1226 |
|
1227 |
#: bp-core/admin/bp-core-components.php:380
|
1228 |
-
msgid "Global, personal, and group activity streams with threaded commenting, direct posting, favoriting and @mentions, all with full RSS feed and email notification support."
|
1229 |
msgstr ""
|
1230 |
|
1231 |
#: bp-core/admin/bp-core-components.php:387 bp-groups/bp-groups-loader.php:83
|
@@ -1269,7 +1270,7 @@ msgid "<strong>BuddyPress is almost ready</strong>. You must <a href=\"%s\">upda
|
|
1269 |
msgstr ""
|
1270 |
|
1271 |
#: bp-core/admin/bp-core-functions.php:257 bp-core/admin/bp-core-slugs.php:135
|
1272 |
-
#: bp-messages/bp-messages-template.php:
|
1273 |
#: bp-templates/bp-legacy/buddypress/members/activate.php:29
|
1274 |
#: bp-themes/bp-default/registration/activate.php:38
|
1275 |
msgid "Activate"
|
@@ -1300,7 +1301,7 @@ msgstr ""
|
|
1300 |
msgid "Settings"
|
1301 |
msgstr ""
|
1302 |
|
1303 |
-
#: bp-core/admin/bp-core-functions.php:
|
1304 |
#: bp-forums/bp-forums-loader.php:132 bp-forums/bp-forums-loader.php:199
|
1305 |
#: bp-forums/bp-forums-loader.php:240 bp-forums/bp-forums-screens.php:208
|
1306 |
#: bp-forums/bp-forums-screens.php:210 bp-forums/deprecated/1.6.php:42
|
@@ -1308,62 +1309,62 @@ msgstr ""
|
|
1308 |
msgid "Forums"
|
1309 |
msgstr ""
|
1310 |
|
1311 |
-
#: bp-core/admin/bp-core-functions.php:
|
1312 |
msgid "<a href=\"http://codex.buddypress.org/getting-started/configure-buddypress-components/#settings-buddypress-components\">Managing Components</a>"
|
1313 |
msgstr ""
|
1314 |
|
1315 |
-
#: bp-core/admin/bp-core-functions.php:
|
1316 |
msgid "<a href=\"http://codex.buddypress.org/getting-started/configure-buddypress-components/#settings-buddypress-pages\">Managing Pages</a>"
|
1317 |
msgstr ""
|
1318 |
|
1319 |
-
#: bp-core/admin/bp-core-functions.php:
|
1320 |
msgid "<a href=\"http://codex.buddypress.org/getting-started/configure-buddypress-components/#settings-buddypress-settings\">Managing Settings</a>"
|
1321 |
msgstr ""
|
1322 |
|
1323 |
-
#: bp-core/admin/bp-core-functions.php:
|
1324 |
msgid "<a href=\"http://codex.buddypress.org/getting-started/configure-buddypress-components/#users-profile-fields\">Managing Profile Fields</a>"
|
1325 |
msgstr ""
|
1326 |
|
1327 |
-
#: bp-core/admin/bp-core-functions.php:
|
1328 |
msgid "By default, all BuddyPress components are enabled. You can selectively disable any of the components by using the form. Your BuddyPress installation will continue to function. However, the features of the disabled components will no longer be accessible to anyone using the site."
|
1329 |
msgstr ""
|
1330 |
|
1331 |
-
#: bp-core/admin/bp-core-functions.php:
|
1332 |
msgid "BuddyPress Components use WordPress Pages for their root directory/archive pages. Here you can change the page associations for each active component."
|
1333 |
msgstr ""
|
1334 |
|
1335 |
-
#: bp-core/admin/bp-core-functions.php:
|
1336 |
msgid "Extra configuration settings."
|
1337 |
msgstr ""
|
1338 |
|
1339 |
-
#: bp-core/admin/bp-core-functions.php:
|
1340 |
msgid "Your users will distinguish themselves through their profile page. Create relevant profile fields that will show on each users profile.</br></br>Note: Any fields in the first group will appear on the signup page."
|
1341 |
msgstr ""
|
1342 |
|
1343 |
-
#: bp-core/admin/bp-core-functions.php:
|
1344 |
#: bp-core/bp-core-admin.php:198 bp-core/bp-core-admin.php:218
|
1345 |
msgid "BuddyPress"
|
1346 |
msgstr ""
|
1347 |
|
1348 |
-
#: bp-core/admin/bp-core-functions.php:
|
1349 |
-
#: bp-core/admin/bp-core-functions.php:
|
1350 |
msgid "Logged-In"
|
1351 |
msgstr ""
|
1352 |
|
1353 |
-
#: bp-core/admin/bp-core-functions.php:
|
1354 |
-
#: bp-core/admin/bp-core-functions.php:
|
1355 |
msgid "Logged-Out"
|
1356 |
msgstr ""
|
1357 |
|
1358 |
-
#: bp-core/admin/bp-core-functions.php:
|
1359 |
msgid "<em>Logged-In</em> links are relative to the current user, and are not visible to visitors who are not logged in."
|
1360 |
msgstr ""
|
1361 |
|
1362 |
-
#: bp-core/admin/bp-core-functions.php:
|
1363 |
msgid "<em>Logged-Out</em> links are not visible to users who are logged in."
|
1364 |
msgstr ""
|
1365 |
|
1366 |
-
#: bp-core/admin/bp-core-functions.php:
|
1367 |
msgid "Add to Menu"
|
1368 |
msgstr ""
|
1369 |
|
@@ -1663,7 +1664,7 @@ msgstr ""
|
|
1663 |
msgid "Not using @-mentions? Disable them with <code>add_filter( 'bp_activity_do_mentions', '__return_false' );</code>"
|
1664 |
msgstr ""
|
1665 |
|
1666 |
-
#: bp-core/bp-core-admin.php:504 bp-core/bp-core-admin.php:
|
1667 |
msgid "Go to the BuddyPress Settings page"
|
1668 |
msgstr ""
|
1669 |
|
@@ -1699,16 +1700,8 @@ msgstr ""
|
|
1699 |
msgid "Recent Rockstars"
|
1700 |
msgstr ""
|
1701 |
|
1702 |
-
#: bp-core/bp-core-admin.php:
|
1703 |
-
msgid "
|
1704 |
-
msgstr ""
|
1705 |
-
|
1706 |
-
#: bp-core/bp-core-admin.php:581
|
1707 |
-
msgid "Support Officer"
|
1708 |
-
msgstr ""
|
1709 |
-
|
1710 |
-
#: bp-core/bp-core-admin.php:585
|
1711 |
-
msgid "Core Contributors to BuddyPress 1.8"
|
1712 |
msgstr ""
|
1713 |
|
1714 |
#: bp-core/bp-core-adminbar.php:36 bp-core/bp-core-buddybar.php:571
|
@@ -1759,8 +1752,8 @@ msgstr ""
|
|
1759 |
msgid "Upload failed! Error was: %s"
|
1760 |
msgstr ""
|
1761 |
|
1762 |
-
#: bp-core/bp-core-avatars.php:831 bp-core/bp-core-classes.php:
|
1763 |
-
#: bp-core/bp-core-classes.php:
|
1764 |
#: bp-core/bp-core-template.php:135 bp-core/bp-core-template.php:151
|
1765 |
msgid "Avatar of %s"
|
1766 |
msgstr ""
|
@@ -1813,7 +1806,7 @@ msgstr ""
|
|
1813 |
msgid "You must log in to access the page you requested."
|
1814 |
msgstr ""
|
1815 |
|
1816 |
-
#: bp-core/bp-core-classes.php:
|
1817 |
msgid "%d group"
|
1818 |
msgid_plural "%d groups"
|
1819 |
msgstr[0] ""
|
@@ -1856,40 +1849,40 @@ msgstr ""
|
|
1856 |
msgid "Activate Your Account"
|
1857 |
msgstr ""
|
1858 |
|
1859 |
-
#: bp-core/bp-core-filters.php:
|
1860 |
msgctxt "Construct the page title. 1 = user name, 2 = component name, 3 = seperator"
|
1861 |
msgid "%1$s %3$s %2$s"
|
1862 |
msgstr ""
|
1863 |
|
1864 |
#. translators: "group name | group nav section name"
|
1865 |
|
1866 |
-
#: bp-core/bp-core-filters.php:
|
1867 |
msgid "%1$s | %2$s"
|
1868 |
msgstr ""
|
1869 |
|
1870 |
#. translators: "component item name | component nav section name | root
|
1871 |
#. component name"
|
1872 |
|
1873 |
-
#: bp-core/bp-core-filters.php:
|
1874 |
msgid "%1$s | %2$s | %3$s"
|
1875 |
msgstr ""
|
1876 |
|
1877 |
-
#: bp-core/bp-core-filters.php:
|
1878 |
msgid "%s Directory"
|
1879 |
msgstr ""
|
1880 |
|
1881 |
-
#: bp-core/bp-core-filters.php:
|
1882 |
#: bp-themes/bp-default/registration/register.php:23
|
1883 |
msgid "Create an Account"
|
1884 |
msgstr ""
|
1885 |
|
1886 |
-
#: bp-core/bp-core-filters.php:
|
1887 |
#: bp-themes/bp-default/registration/activate.php:13
|
1888 |
msgid "Activate your Account"
|
1889 |
msgstr ""
|
1890 |
|
1891 |
-
#: bp-core/bp-core-filters.php:
|
1892 |
-
#: bp-groups/bp-groups-screens.php:
|
1893 |
#: bp-themes/bp-default/groups/create.php:18
|
1894 |
#: bp-themes/bp-default/groups/index.php:21
|
1895 |
msgid "Create a Group"
|
@@ -2251,19 +2244,19 @@ msgstr ""
|
|
2251 |
msgid "The forums component has not been set up yet."
|
2252 |
msgstr ""
|
2253 |
|
2254 |
-
#: bp-forums/bp-forums-screens.php:48 bp-groups/bp-groups-screens.php:
|
2255 |
msgid "Please provide a title for your forum topic."
|
2256 |
msgstr ""
|
2257 |
|
2258 |
-
#: bp-forums/bp-forums-screens.php:50 bp-groups/bp-groups-screens.php:
|
2259 |
msgid "Forum posts cannot be empty. Please enter some text."
|
2260 |
msgstr ""
|
2261 |
|
2262 |
-
#: bp-forums/bp-forums-screens.php:57 bp-groups/bp-groups-screens.php:
|
2263 |
msgid "There was an error when creating the topic"
|
2264 |
msgstr ""
|
2265 |
|
2266 |
-
#: bp-forums/bp-forums-screens.php:60 bp-groups/bp-groups-screens.php:
|
2267 |
msgid "The topic was created successfully"
|
2268 |
msgstr ""
|
2269 |
|
@@ -2292,8 +2285,8 @@ msgstr ""
|
|
2292 |
#: bp-forums/bp-forums-template.php:756 bp-forums/bp-forums-template.php:870
|
2293 |
#: bp-forums/bp-forums-template.php:2014
|
2294 |
#: bp-messages/bp-messages-classes.php:270
|
2295 |
-
#: bp-messages/bp-messages-template.php:
|
2296 |
-
#: bp-messages/bp-messages-template.php:
|
2297 |
msgid "Deleted User"
|
2298 |
msgstr ""
|
2299 |
|
@@ -2543,37 +2536,20 @@ msgstr ""
|
|
2543 |
msgid "You have a pending friendship request with this user"
|
2544 |
msgstr ""
|
2545 |
|
2546 |
-
#: bp-friends/bp-friends-activity.php:
|
2547 |
msgid "Friendships accepted"
|
2548 |
msgstr ""
|
2549 |
|
2550 |
-
#: bp-friends/bp-friends-activity.php:
|
2551 |
msgid "New friendships"
|
2552 |
msgstr ""
|
2553 |
|
2554 |
-
#: bp-friends/bp-friends-activity.php:
|
2555 |
msgid "New friendship created"
|
2556 |
msgstr ""
|
2557 |
|
2558 |
-
#: bp-friends/bp-friends-activity.php:
|
2559 |
-
|
2560 |
-
msgstr ""
|
2561 |
-
|
2562 |
-
#: bp-friends/bp-friends-activity.php:125
|
2563 |
-
#: bp-friends/bp-friends-notifications.php:91
|
2564 |
-
msgid "%s accepted your friendship request"
|
2565 |
-
msgstr ""
|
2566 |
-
|
2567 |
-
#: bp-friends/bp-friends-activity.php:136
|
2568 |
-
msgid "You have %d pending friendship requests"
|
2569 |
-
msgstr ""
|
2570 |
-
|
2571 |
-
#: bp-friends/bp-friends-activity.php:139
|
2572 |
-
msgid "You have a friendship request from %s"
|
2573 |
-
msgstr ""
|
2574 |
-
|
2575 |
-
#: bp-friends/bp-friends-functions.php:134
|
2576 |
-
#: bp-friends/bp-friends-functions.php:143
|
2577 |
msgid "%1$s and %2$s are now friends"
|
2578 |
msgstr ""
|
2579 |
|
@@ -2610,11 +2586,11 @@ msgstr ""
|
|
2610 |
msgid "No Pending Requests"
|
2611 |
msgstr ""
|
2612 |
|
2613 |
-
#: bp-friends/bp-friends-notifications.php:
|
2614 |
msgid "New friendship request from %s"
|
2615 |
msgstr ""
|
2616 |
|
2617 |
-
#: bp-friends/bp-friends-notifications.php:
|
2618 |
msgid ""
|
2619 |
"%1$s wants to add you as a friend.\n"
|
2620 |
"\n"
|
@@ -2625,7 +2601,12 @@ msgid ""
|
|
2625 |
"---------------------\n"
|
2626 |
msgstr ""
|
2627 |
|
2628 |
-
#: bp-friends/bp-friends-notifications.php:
|
|
|
|
|
|
|
|
|
|
|
2629 |
msgid ""
|
2630 |
"%1$s accepted your friend request.\n"
|
2631 |
"\n"
|
@@ -2634,35 +2615,47 @@ msgid ""
|
|
2634 |
"---------------------\n"
|
2635 |
msgstr ""
|
2636 |
|
2637 |
-
#: bp-friends/bp-friends-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2638 |
msgid "Friendship accepted"
|
2639 |
msgstr ""
|
2640 |
|
2641 |
-
#: bp-friends/bp-friends-screens.php:
|
2642 |
msgid "Friendship could not be accepted"
|
2643 |
msgstr ""
|
2644 |
|
2645 |
-
#: bp-friends/bp-friends-screens.php:
|
2646 |
msgid "Friendship rejected"
|
2647 |
msgstr ""
|
2648 |
|
2649 |
-
#: bp-friends/bp-friends-screens.php:
|
2650 |
msgid "Friendship could not be rejected"
|
2651 |
msgstr ""
|
2652 |
|
2653 |
-
#: bp-friends/bp-friends-screens.php:
|
2654 |
msgid "Friendship request withdrawn"
|
2655 |
msgstr ""
|
2656 |
|
2657 |
-
#: bp-friends/bp-friends-screens.php:
|
2658 |
msgid "Friendship request could not be withdrawn"
|
2659 |
msgstr ""
|
2660 |
|
2661 |
-
#: bp-friends/bp-friends-screens.php:
|
2662 |
msgid "A member sends you a friendship request"
|
2663 |
msgstr ""
|
2664 |
|
2665 |
-
#: bp-friends/bp-friends-screens.php:
|
2666 |
msgid "A member accepts your friendship request"
|
2667 |
msgstr ""
|
2668 |
|
@@ -2794,7 +2787,7 @@ msgstr ""
|
|
2794 |
msgid "You joined the group!"
|
2795 |
msgstr ""
|
2796 |
|
2797 |
-
#: bp-groups/bp-groups-actions.php:272 bp-groups/bp-groups-screens.php:
|
2798 |
msgid "This group must have at least one admin"
|
2799 |
msgstr ""
|
2800 |
|
@@ -2802,7 +2795,7 @@ msgstr ""
|
|
2802 |
msgid "There was an error leaving the group."
|
2803 |
msgstr ""
|
2804 |
|
2805 |
-
#: bp-groups/bp-groups-actions.php:276 bp-groups/bp-groups-functions.php:
|
2806 |
msgid "You successfully left the group."
|
2807 |
msgstr ""
|
2808 |
|
@@ -2826,60 +2819,9 @@ msgstr ""
|
|
2826 |
msgid "New group forum post"
|
2827 |
msgstr ""
|
2828 |
|
2829 |
-
#: bp-groups/bp-groups-activity.php:
|
2830 |
-
|
2831 |
-
|
2832 |
-
|
2833 |
-
#: bp-groups/bp-groups-activity.php:142
|
2834 |
-
msgid "Group Membership Requests"
|
2835 |
-
msgstr ""
|
2836 |
-
|
2837 |
-
#: bp-groups/bp-groups-activity.php:151 bp-groups/bp-groups-activity.php:156
|
2838 |
-
msgid "%s requests group membership"
|
2839 |
-
msgstr ""
|
2840 |
-
|
2841 |
-
#: bp-groups/bp-groups-activity.php:174
|
2842 |
-
msgid "%d accepted group membership requests"
|
2843 |
-
msgstr ""
|
2844 |
-
|
2845 |
-
#: bp-groups/bp-groups-activity.php:187
|
2846 |
-
msgid "Membership for group \"%s\" accepted"
|
2847 |
-
msgstr ""
|
2848 |
-
|
2849 |
-
#: bp-groups/bp-groups-activity.php:210
|
2850 |
-
msgid "%d rejected group membership requests"
|
2851 |
-
msgstr ""
|
2852 |
-
|
2853 |
-
#: bp-groups/bp-groups-activity.php:223
|
2854 |
-
msgid "Membership for group \"%s\" rejected"
|
2855 |
-
msgstr ""
|
2856 |
-
|
2857 |
-
#: bp-groups/bp-groups-activity.php:246
|
2858 |
-
msgid "You were promoted to an admin in %d groups"
|
2859 |
-
msgstr ""
|
2860 |
-
|
2861 |
-
#: bp-groups/bp-groups-activity.php:259
|
2862 |
-
msgid "You were promoted to an admin in the group \"%s\""
|
2863 |
-
msgstr ""
|
2864 |
-
|
2865 |
-
#: bp-groups/bp-groups-activity.php:282
|
2866 |
-
msgid "You were promoted to a mod in %d groups"
|
2867 |
-
msgstr ""
|
2868 |
-
|
2869 |
-
#: bp-groups/bp-groups-activity.php:295
|
2870 |
-
msgid "You were promoted to a mod in the group \"%s\""
|
2871 |
-
msgstr ""
|
2872 |
-
|
2873 |
-
#: bp-groups/bp-groups-activity.php:319
|
2874 |
-
msgid "You have %d new group invitations"
|
2875 |
-
msgstr ""
|
2876 |
-
|
2877 |
-
#: bp-groups/bp-groups-activity.php:323
|
2878 |
-
msgid "Group Invites"
|
2879 |
-
msgstr ""
|
2880 |
-
|
2881 |
-
#: bp-groups/bp-groups-activity.php:331
|
2882 |
-
msgid "You have an invitation to the group: %s"
|
2883 |
msgstr ""
|
2884 |
|
2885 |
#: bp-groups/bp-groups-admin.php:114
|
@@ -3135,7 +3077,7 @@ msgstr ""
|
|
3135 |
msgid "Delete Group"
|
3136 |
msgstr ""
|
3137 |
|
3138 |
-
#: bp-groups/bp-groups-admin.php:881 bp-groups/bp-groups-classes.php:
|
3139 |
#: bp-templates/bp-legacy/buddypress/groups/single/admin.php:32
|
3140 |
#: bp-templates/bp-legacy/buddypress/groups/single/admin.php:117
|
3141 |
#: bp-templates/bp-legacy/buddypress/groups/single/forum/edit.php:58
|
@@ -3231,7 +3173,7 @@ msgstr ""
|
|
3231 |
msgid "Edit Settings"
|
3232 |
msgstr ""
|
3233 |
|
3234 |
-
#: bp-groups/bp-groups-adminbar.php:64 bp-members/bp-members-adminbar.php:
|
3235 |
msgid "Edit Avatar"
|
3236 |
msgstr ""
|
3237 |
|
@@ -3260,36 +3202,31 @@ msgstr ""
|
|
3260 |
msgid "Group Avatar"
|
3261 |
msgstr ""
|
3262 |
|
3263 |
-
#: bp-groups/bp-groups-classes.php:
|
3264 |
msgid "Group Mod"
|
3265 |
msgstr ""
|
3266 |
|
3267 |
-
#: bp-groups/bp-groups-classes.php:
|
3268 |
msgid "Group Admin"
|
3269 |
msgstr ""
|
3270 |
|
3271 |
-
#: bp-groups/bp-groups-forums.php:
|
3272 |
msgid "%1$s replied to the forum topic %2$s in the group %3$s"
|
3273 |
msgstr ""
|
3274 |
|
3275 |
-
#: bp-groups/bp-groups-forums.php:
|
3276 |
msgid "%1$s started the forum topic %2$s in the group %3$s"
|
3277 |
msgstr ""
|
3278 |
|
3279 |
-
#: bp-groups/bp-groups-forums.php:
|
3280 |
msgid "%1$s edited the forum topic %2$s in the group %3$s"
|
3281 |
msgstr ""
|
3282 |
|
3283 |
-
#: bp-groups/bp-groups-functions.php:
|
3284 |
msgid "As the only Admin, you cannot leave the group."
|
3285 |
msgstr ""
|
3286 |
|
3287 |
-
#: bp-groups/bp-groups-functions.php:
|
3288 |
-
#: bp-groups/bp-groups-screens.php:62
|
3289 |
-
msgid "%1$s joined the group %2$s"
|
3290 |
-
msgstr ""
|
3291 |
-
|
3292 |
-
#: bp-groups/bp-groups-functions.php:610
|
3293 |
msgid "%1$s posted an update in the group %2$s"
|
3294 |
msgstr ""
|
3295 |
|
@@ -3372,11 +3309,11 @@ msgstr ""
|
|
3372 |
msgid "Pending Invites <span class=\"count\">%s</span>"
|
3373 |
msgstr ""
|
3374 |
|
3375 |
-
#: bp-groups/bp-groups-notifications.php:
|
3376 |
msgid "Group Details Updated"
|
3377 |
msgstr ""
|
3378 |
|
3379 |
-
#: bp-groups/bp-groups-notifications.php:
|
3380 |
msgid ""
|
3381 |
"Group details for the group \"%1$s\" were updated:\n"
|
3382 |
"\n"
|
@@ -3385,11 +3322,11 @@ msgid ""
|
|
3385 |
"---------------------\n"
|
3386 |
msgstr ""
|
3387 |
|
3388 |
-
#: bp-groups/bp-groups-notifications.php:
|
3389 |
msgid "Membership request for group: %s"
|
3390 |
msgstr ""
|
3391 |
|
3392 |
-
#: bp-groups/bp-groups-notifications.php:
|
3393 |
msgid ""
|
3394 |
"%1$s wants to join the group \"%2$s\".\n"
|
3395 |
"\n"
|
@@ -3403,11 +3340,11 @@ msgid ""
|
|
3403 |
"---------------------\n"
|
3404 |
msgstr ""
|
3405 |
|
3406 |
-
#: bp-groups/bp-groups-notifications.php:
|
3407 |
msgid "Membership request for group \"%s\" accepted"
|
3408 |
msgstr ""
|
3409 |
|
3410 |
-
#: bp-groups/bp-groups-notifications.php:
|
3411 |
msgid ""
|
3412 |
"Your membership request for the group \"%1$s\" has been accepted.\n"
|
3413 |
"\n"
|
@@ -3416,11 +3353,11 @@ msgid ""
|
|
3416 |
"---------------------\n"
|
3417 |
msgstr ""
|
3418 |
|
3419 |
-
#: bp-groups/bp-groups-notifications.php:
|
3420 |
msgid "Membership request for group \"%s\" rejected"
|
3421 |
msgstr ""
|
3422 |
|
3423 |
-
#: bp-groups/bp-groups-notifications.php:
|
3424 |
msgid ""
|
3425 |
"Your membership request for the group \"%1$s\" has been rejected.\n"
|
3426 |
"\n"
|
@@ -3429,19 +3366,19 @@ msgid ""
|
|
3429 |
"---------------------\n"
|
3430 |
msgstr ""
|
3431 |
|
3432 |
-
#: bp-groups/bp-groups-notifications.php:
|
3433 |
msgid "an administrator"
|
3434 |
msgstr ""
|
3435 |
|
3436 |
-
#: bp-groups/bp-groups-notifications.php:
|
3437 |
msgid "a moderator"
|
3438 |
msgstr ""
|
3439 |
|
3440 |
-
#: bp-groups/bp-groups-notifications.php:
|
3441 |
msgid "You have been promoted in the group: \"%s\""
|
3442 |
msgstr ""
|
3443 |
|
3444 |
-
#: bp-groups/bp-groups-notifications.php:
|
3445 |
msgid ""
|
3446 |
"You have been promoted to %1$s for the group: \"%2$s\".\n"
|
3447 |
"\n"
|
@@ -3450,11 +3387,11 @@ msgid ""
|
|
3450 |
"---------------------\n"
|
3451 |
msgstr ""
|
3452 |
|
3453 |
-
#: bp-groups/bp-groups-notifications.php:
|
3454 |
msgid "You have an invitation to the group: \"%s\""
|
3455 |
msgstr ""
|
3456 |
|
3457 |
-
#: bp-groups/bp-groups-notifications.php:
|
3458 |
msgid ""
|
3459 |
"One of your friends %1$s has invited you to the group: \"%2$s\".\n"
|
3460 |
"\n"
|
@@ -3467,231 +3404,288 @@ msgid ""
|
|
3467 |
"---------------------\n"
|
3468 |
msgstr ""
|
3469 |
|
3470 |
-
#: bp-groups/bp-groups-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3471 |
msgid "Group invite could not be accepted"
|
3472 |
msgstr ""
|
3473 |
|
3474 |
-
#: bp-groups/bp-groups-screens.php:
|
3475 |
msgid "Group invite accepted"
|
3476 |
msgstr ""
|
3477 |
|
3478 |
-
#: bp-groups/bp-groups-screens.php:
|
3479 |
msgid "Group invite could not be rejected"
|
3480 |
msgstr ""
|
3481 |
|
3482 |
-
#: bp-groups/bp-groups-screens.php:
|
3483 |
msgid "Group invite rejected"
|
3484 |
msgstr ""
|
3485 |
|
3486 |
-
#: bp-groups/bp-groups-screens.php:
|
3487 |
msgid "It looks like you've already said that!"
|
3488 |
msgstr ""
|
3489 |
|
3490 |
-
#: bp-groups/bp-groups-screens.php:
|
3491 |
msgid "There was an error when replying to that topic"
|
3492 |
msgstr ""
|
3493 |
|
3494 |
-
#: bp-groups/bp-groups-screens.php:
|
3495 |
msgid "Your reply was posted successfully"
|
3496 |
msgstr ""
|
3497 |
|
3498 |
-
#: bp-groups/bp-groups-screens.php:
|
3499 |
msgid "There was an error when making that topic a sticky"
|
3500 |
msgstr ""
|
3501 |
|
3502 |
-
#: bp-groups/bp-groups-screens.php:
|
3503 |
msgid "The topic was made sticky successfully"
|
3504 |
msgstr ""
|
3505 |
|
3506 |
-
#: bp-groups/bp-groups-screens.php:
|
3507 |
msgid "There was an error when unsticking that topic"
|
3508 |
msgstr ""
|
3509 |
|
3510 |
-
#: bp-groups/bp-groups-screens.php:
|
3511 |
msgid "The topic was unstuck successfully"
|
3512 |
msgstr ""
|
3513 |
|
3514 |
-
#: bp-groups/bp-groups-screens.php:
|
3515 |
msgid "There was an error when closing that topic"
|
3516 |
msgstr ""
|
3517 |
|
3518 |
-
#: bp-groups/bp-groups-screens.php:
|
3519 |
msgid "The topic was closed successfully"
|
3520 |
msgstr ""
|
3521 |
|
3522 |
-
#: bp-groups/bp-groups-screens.php:
|
3523 |
msgid "There was an error when opening that topic"
|
3524 |
msgstr ""
|
3525 |
|
3526 |
-
#: bp-groups/bp-groups-screens.php:
|
3527 |
msgid "The topic was opened successfully"
|
3528 |
msgstr ""
|
3529 |
|
3530 |
-
#: bp-groups/bp-groups-screens.php:
|
3531 |
msgid "There was an error deleting the topic"
|
3532 |
msgstr ""
|
3533 |
|
3534 |
-
#: bp-groups/bp-groups-screens.php:
|
3535 |
msgid "The topic was deleted successfully"
|
3536 |
msgstr ""
|
3537 |
|
3538 |
-
#: bp-groups/bp-groups-screens.php:
|
3539 |
msgid "There was an error when editing that topic"
|
3540 |
msgstr ""
|
3541 |
|
3542 |
-
#: bp-groups/bp-groups-screens.php:
|
3543 |
msgid "The topic was edited successfully"
|
3544 |
msgstr ""
|
3545 |
|
3546 |
-
#: bp-groups/bp-groups-screens.php:
|
3547 |
msgid "There was an error deleting that post"
|
3548 |
msgstr ""
|
3549 |
|
3550 |
-
#: bp-groups/bp-groups-screens.php:
|
3551 |
msgid "The post was deleted successfully"
|
3552 |
msgstr ""
|
3553 |
|
3554 |
-
#: bp-groups/bp-groups-screens.php:
|
3555 |
msgid "There was an error when editing that post"
|
3556 |
msgstr ""
|
3557 |
|
3558 |
-
#: bp-groups/bp-groups-screens.php:
|
3559 |
msgid "The post was edited successfully"
|
3560 |
msgstr ""
|
3561 |
|
3562 |
-
#: bp-groups/bp-groups-screens.php:
|
3563 |
msgid "You have been banned from this group."
|
3564 |
msgstr ""
|
3565 |
|
3566 |
-
#: bp-groups/bp-groups-screens.php:
|
3567 |
msgid "This group does not have a forum setup yet."
|
3568 |
msgstr ""
|
3569 |
|
3570 |
-
#: bp-groups/bp-groups-screens.php:
|
3571 |
msgid "Group invites sent."
|
3572 |
msgstr ""
|
3573 |
|
3574 |
-
#: bp-groups/bp-groups-screens.php:
|
3575 |
msgid "There was an error accepting the group invitation, please try again."
|
3576 |
msgstr ""
|
3577 |
|
3578 |
-
#: bp-groups/bp-groups-screens.php:
|
3579 |
msgid "There was an error sending your group membership request, please try again."
|
3580 |
msgstr ""
|
3581 |
|
3582 |
-
#: bp-groups/bp-groups-screens.php:
|
3583 |
msgid "Your membership request was sent to the group administrator successfully. You will be notified when the group administrator responds to your request."
|
3584 |
msgstr ""
|
3585 |
|
3586 |
-
#: bp-groups/bp-groups-screens.php:
|
3587 |
msgid "There was an error updating group details, please try again."
|
3588 |
msgstr ""
|
3589 |
|
3590 |
-
#: bp-groups/bp-groups-screens.php:
|
3591 |
msgid "Group details were successfully updated."
|
3592 |
msgstr ""
|
3593 |
|
3594 |
-
#: bp-groups/bp-groups-screens.php:
|
3595 |
msgid "There was an error updating group settings, please try again."
|
3596 |
msgstr ""
|
3597 |
|
3598 |
-
#: bp-groups/bp-groups-screens.php:
|
3599 |
msgid "Group settings were successfully updated."
|
3600 |
msgstr ""
|
3601 |
|
3602 |
-
#: bp-groups/bp-groups-screens.php:
|
3603 |
msgid "Your avatar was deleted successfully!"
|
3604 |
msgstr ""
|
3605 |
|
3606 |
-
#: bp-groups/bp-groups-screens.php:
|
3607 |
msgid "There was a problem deleting that avatar, please try again."
|
3608 |
msgstr ""
|
3609 |
|
3610 |
-
#: bp-groups/bp-groups-screens.php:
|
3611 |
msgid "There was a problem cropping the avatar."
|
3612 |
msgstr ""
|
3613 |
|
3614 |
-
#: bp-groups/bp-groups-screens.php:
|
3615 |
msgid "The new group avatar was uploaded successfully."
|
3616 |
msgstr ""
|
3617 |
|
3618 |
-
#: bp-groups/bp-groups-screens.php:
|
3619 |
msgid "There was an error when promoting that user, please try again"
|
3620 |
msgstr ""
|
3621 |
|
3622 |
-
#: bp-groups/bp-groups-screens.php:
|
3623 |
msgid "User promoted successfully"
|
3624 |
msgstr ""
|
3625 |
|
3626 |
-
#: bp-groups/bp-groups-screens.php:
|
3627 |
msgid "There was an error when demoting that user, please try again"
|
3628 |
msgstr ""
|
3629 |
|
3630 |
-
#: bp-groups/bp-groups-screens.php:
|
3631 |
msgid "User demoted successfully"
|
3632 |
msgstr ""
|
3633 |
|
3634 |
-
#: bp-groups/bp-groups-screens.php:
|
3635 |
msgid "There was an error when banning that user, please try again"
|
3636 |
msgstr ""
|
3637 |
|
3638 |
-
#: bp-groups/bp-groups-screens.php:
|
3639 |
msgid "User banned successfully"
|
3640 |
msgstr ""
|
3641 |
|
3642 |
-
#: bp-groups/bp-groups-screens.php:
|
3643 |
msgid "There was an error when unbanning that user, please try again"
|
3644 |
msgstr ""
|
3645 |
|
3646 |
-
#: bp-groups/bp-groups-screens.php:
|
3647 |
msgid "User ban removed successfully"
|
3648 |
msgstr ""
|
3649 |
|
3650 |
-
#: bp-groups/bp-groups-screens.php:
|
3651 |
msgid "There was an error removing that user from the group, please try again"
|
3652 |
msgstr ""
|
3653 |
|
3654 |
-
#: bp-groups/bp-groups-screens.php:
|
3655 |
msgid "User removed successfully"
|
3656 |
msgstr ""
|
3657 |
|
3658 |
-
#: bp-groups/bp-groups-screens.php:
|
3659 |
msgid "There was an error accepting the membership request, please try again."
|
3660 |
msgstr ""
|
3661 |
|
3662 |
-
#: bp-groups/bp-groups-screens.php:
|
3663 |
msgid "Group membership request accepted"
|
3664 |
msgstr ""
|
3665 |
|
3666 |
-
#: bp-groups/bp-groups-screens.php:
|
3667 |
msgid "There was an error rejecting the membership request, please try again."
|
3668 |
msgstr ""
|
3669 |
|
3670 |
-
#: bp-groups/bp-groups-screens.php:
|
3671 |
msgid "Group membership request rejected"
|
3672 |
msgstr ""
|
3673 |
|
3674 |
-
#: bp-groups/bp-groups-screens.php:
|
3675 |
msgid "There was an error deleting the group, please try again."
|
3676 |
msgstr ""
|
3677 |
|
3678 |
-
#: bp-groups/bp-groups-screens.php:
|
3679 |
msgid "The group was deleted successfully"
|
3680 |
msgstr ""
|
3681 |
|
3682 |
-
#: bp-groups/bp-groups-screens.php:
|
3683 |
msgid "A member invites you to join a group"
|
3684 |
msgstr ""
|
3685 |
|
3686 |
-
#: bp-groups/bp-groups-screens.php:
|
3687 |
msgid "Group information is updated"
|
3688 |
msgstr ""
|
3689 |
|
3690 |
-
#: bp-groups/bp-groups-screens.php:
|
3691 |
msgid "You are promoted to a group administrator or moderator"
|
3692 |
msgstr ""
|
3693 |
|
3694 |
-
#: bp-groups/bp-groups-screens.php:
|
3695 |
msgid "A member requests to join a private group for which you are an admin"
|
3696 |
msgstr ""
|
3697 |
|
@@ -3933,9 +3927,9 @@ msgstr ""
|
|
3933 |
msgid "Edit Member"
|
3934 |
msgstr ""
|
3935 |
|
3936 |
-
#: bp-members/bp-members-adminbar.php:
|
3937 |
-
#: bp-xprofile/bp-xprofile-template.php:
|
3938 |
-
#: bp-xprofile/bp-xprofile-template.php:
|
3939 |
msgid "Edit Profile"
|
3940 |
msgstr ""
|
3941 |
|
@@ -4154,24 +4148,6 @@ msgstr ""
|
|
4154 |
msgid "No Subject"
|
4155 |
msgstr ""
|
4156 |
|
4157 |
-
#: bp-messages/bp-messages-functions.php:242
|
4158 |
-
#: bp-messages/bp-messages-loader.php:132
|
4159 |
-
#: bp-messages/bp-messages-loader.php:196
|
4160 |
-
msgid "Inbox"
|
4161 |
-
msgstr ""
|
4162 |
-
|
4163 |
-
#: bp-messages/bp-messages-functions.php:245
|
4164 |
-
msgid "You have %d new messages"
|
4165 |
-
msgstr ""
|
4166 |
-
|
4167 |
-
#: bp-messages/bp-messages-functions.php:249
|
4168 |
-
msgid "You have %d new message from %s"
|
4169 |
-
msgstr ""
|
4170 |
-
|
4171 |
-
#: bp-messages/bp-messages-functions.php:251
|
4172 |
-
msgid "You have %d new message"
|
4173 |
-
msgstr ""
|
4174 |
-
|
4175 |
#: bp-messages/bp-messages-loader.php:33
|
4176 |
msgid "Private Messages"
|
4177 |
msgstr ""
|
@@ -4185,6 +4161,12 @@ msgstr ""
|
|
4185 |
msgid "Messages <span>%s</span>"
|
4186 |
msgstr ""
|
4187 |
|
|
|
|
|
|
|
|
|
|
|
|
|
4188 |
#: bp-messages/bp-messages-loader.php:142
|
4189 |
#: bp-messages/bp-messages-loader.php:219
|
4190 |
msgid "Sent"
|
@@ -4220,11 +4202,11 @@ msgstr ""
|
|
4220 |
msgid "My Messages"
|
4221 |
msgstr ""
|
4222 |
|
4223 |
-
#: bp-messages/bp-messages-notifications.php:
|
4224 |
msgid "New message from %s"
|
4225 |
msgstr ""
|
4226 |
|
4227 |
-
#: bp-messages/bp-messages-notifications.php:
|
4228 |
msgid ""
|
4229 |
"%1$s sent you a new message:\n"
|
4230 |
"\n"
|
@@ -4237,6 +4219,18 @@ msgid ""
|
|
4237 |
"---------------------\n"
|
4238 |
msgstr ""
|
4239 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4240 |
#: bp-messages/bp-messages-screens.php:56
|
4241 |
#: bp-messages/bp-messages-screens.php:78
|
4242 |
msgid "There was an error sending that message, please try again"
|
@@ -4292,51 +4286,51 @@ msgctxt "Message pagination next text"
|
|
4292 |
msgid "→"
|
4293 |
msgstr ""
|
4294 |
|
4295 |
-
#: bp-messages/bp-messages-template.php:
|
4296 |
msgid "Viewing message %1$s to %2$s (of %3$s message)"
|
4297 |
msgid_plural "Viewing message %1$s to %2$s (of %3$s messages)"
|
4298 |
msgstr[0] ""
|
4299 |
msgstr[1] ""
|
4300 |
|
4301 |
-
#: bp-messages/bp-messages-template.php:
|
4302 |
msgid "Select:"
|
4303 |
msgstr ""
|
4304 |
|
4305 |
-
#: bp-messages/bp-messages-template.php:
|
4306 |
-
#: bp-notifications/bp-notifications-loader.php:
|
4307 |
-
#: bp-notifications/bp-notifications-loader.php:
|
4308 |
#: bp-notifications/bp-notifications-template.php:733
|
4309 |
msgid "Read"
|
4310 |
msgstr ""
|
4311 |
|
4312 |
-
#: bp-messages/bp-messages-template.php:
|
4313 |
-
#: bp-notifications/bp-notifications-loader.php:
|
4314 |
-
#: bp-notifications/bp-notifications-loader.php:
|
4315 |
#: bp-notifications/bp-notifications-template.php:763
|
4316 |
msgid "Unread"
|
4317 |
msgstr ""
|
4318 |
|
4319 |
-
#: bp-messages/bp-messages-template.php:
|
4320 |
msgid "Mark as Read"
|
4321 |
msgstr ""
|
4322 |
|
4323 |
-
#: bp-messages/bp-messages-template.php:
|
4324 |
msgid "Mark as Unread"
|
4325 |
msgstr ""
|
4326 |
|
4327 |
-
#: bp-messages/bp-messages-template.php:
|
4328 |
msgid "Delete Selected"
|
4329 |
msgstr ""
|
4330 |
|
4331 |
-
#: bp-messages/bp-messages-template.php:
|
4332 |
msgid "Currently Active"
|
4333 |
msgstr ""
|
4334 |
|
4335 |
-
#: bp-messages/bp-messages-template.php:
|
4336 |
msgid "Deactivate"
|
4337 |
msgstr ""
|
4338 |
|
4339 |
-
#: bp-messages/bp-messages-template.php:
|
4340 |
#: bp-templates/bp-legacy/buddypress/members/register.php:168
|
4341 |
#: bp-templates/bp-legacy/buddypress/members/single/profile/edit.php:130
|
4342 |
#: bp-templates/bp-legacy/buddypress-functions.php:233
|
@@ -4346,19 +4340,19 @@ msgstr ""
|
|
4346 |
msgid "Close"
|
4347 |
msgstr ""
|
4348 |
|
4349 |
-
#: bp-messages/bp-messages-template.php:
|
4350 |
msgid "Send a private message to this user."
|
4351 |
msgstr ""
|
4352 |
|
4353 |
-
#: bp-messages/bp-messages-template.php:
|
4354 |
msgid "Private Message"
|
4355 |
msgstr ""
|
4356 |
|
4357 |
-
#: bp-messages/bp-messages-template.php:
|
4358 |
msgid "%d Recipients"
|
4359 |
msgstr ""
|
4360 |
|
4361 |
-
#: bp-messages/bp-messages-template.php:
|
4362 |
#: bp-templates/bp-legacy/buddypress-functions.php:1186
|
4363 |
#: bp-themes/bp-default/_inc/ajax.php:833
|
4364 |
msgid "Sent %s"
|
@@ -4409,11 +4403,11 @@ msgstr ""
|
|
4409 |
msgid "Notifications <span>%d</span>"
|
4410 |
msgstr ""
|
4411 |
|
4412 |
-
#: bp-notifications/bp-notifications-loader.php:
|
4413 |
msgid "Notifications <span class=\"count\">%s</span>"
|
4414 |
msgstr ""
|
4415 |
|
4416 |
-
#: bp-notifications/bp-notifications-loader.php:
|
4417 |
msgid "Unread <span class=\"count\">%s</span>"
|
4418 |
msgstr ""
|
4419 |
|
@@ -4528,6 +4522,7 @@ msgid "General"
|
|
4528 |
msgstr ""
|
4529 |
|
4530 |
#: bp-settings/bp-settings-loader.php:106
|
|
|
4531 |
#: bp-themes/bp-default/functions.php:645
|
4532 |
msgid "Email"
|
4533 |
msgstr ""
|
@@ -4914,7 +4909,7 @@ msgstr ""
|
|
4914 |
|
4915 |
#: bp-templates/bp-legacy/buddypress/forums/index.php:98
|
4916 |
#: bp-themes/bp-default/forums/index.php:116
|
4917 |
-
#: bp-xprofile/bp-xprofile-template.php:
|
4918 |
msgid "----"
|
4919 |
msgstr ""
|
4920 |
|
@@ -6492,62 +6487,62 @@ msgstr ""
|
|
6492 |
msgid "Your new avatar was uploaded successfully."
|
6493 |
msgstr ""
|
6494 |
|
6495 |
-
#: bp-xprofile/bp-xprofile-template.php:
|
6496 |
msgid "January"
|
6497 |
msgstr ""
|
6498 |
|
6499 |
-
#: bp-xprofile/bp-xprofile-template.php:
|
6500 |
msgid "February"
|
6501 |
msgstr ""
|
6502 |
|
6503 |
-
#: bp-xprofile/bp-xprofile-template.php:
|
6504 |
msgid "March"
|
6505 |
msgstr ""
|
6506 |
|
6507 |
-
#: bp-xprofile/bp-xprofile-template.php:
|
6508 |
msgid "April"
|
6509 |
msgstr ""
|
6510 |
|
6511 |
-
#: bp-xprofile/bp-xprofile-template.php:
|
6512 |
msgid "May"
|
6513 |
msgstr ""
|
6514 |
|
6515 |
-
#: bp-xprofile/bp-xprofile-template.php:
|
6516 |
msgid "June"
|
6517 |
msgstr ""
|
6518 |
|
6519 |
-
#: bp-xprofile/bp-xprofile-template.php:
|
6520 |
msgid "July"
|
6521 |
msgstr ""
|
6522 |
|
6523 |
-
#: bp-xprofile/bp-xprofile-template.php:
|
6524 |
msgid "August"
|
6525 |
msgstr ""
|
6526 |
|
6527 |
-
#: bp-xprofile/bp-xprofile-template.php:
|
6528 |
msgid "September"
|
6529 |
msgstr ""
|
6530 |
|
6531 |
-
#: bp-xprofile/bp-xprofile-template.php:
|
6532 |
msgid "October"
|
6533 |
msgstr ""
|
6534 |
|
6535 |
-
#: bp-xprofile/bp-xprofile-template.php:
|
6536 |
msgid "November"
|
6537 |
msgstr ""
|
6538 |
|
6539 |
-
#: bp-xprofile/bp-xprofile-template.php:
|
6540 |
msgid "December"
|
6541 |
msgstr ""
|
6542 |
|
6543 |
-
#: bp-xprofile/bp-xprofile-template.php:
|
6544 |
msgid "Avatar uploads are currently disabled. Why not use a <a href=\"http://gravatar.com\" target=\"_blank\">gravatar</a> instead?"
|
6545 |
msgstr ""
|
6546 |
|
6547 |
-
#: bp-xprofile/bp-xprofile-template.php:
|
6548 |
msgid "Profile not recently updated"
|
6549 |
msgstr ""
|
6550 |
|
6551 |
-
#: bp-xprofile/bp-xprofile-template.php:
|
6552 |
msgid "Profile updated %s"
|
6553 |
msgstr ""
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
"Project-Id-Version: BuddyPress \n"
|
6 |
+
"Report-Msgid-Bugs-To: http://wppolyglots.wordpress.com\n"
|
7 |
+
"POT-Creation-Date: 2013-12-02 21:35:24+00:00\n"
|
8 |
"MIME-Version: 1.0\n"
|
9 |
"Content-Type: text/plain; charset=UTF-8\n"
|
10 |
"Content-Transfer-Encoding: 8bit\n"
|
144 |
#: bp-activity/bp-activity-admin.php:871 bp-activity/bp-activity-admin.php:1204
|
145 |
#: bp-activity/bp-activity-loader.php:132
|
146 |
#: bp-activity/bp-activity-loader.php:261
|
147 |
+
#: bp-activity/bp-activity-screens.php:270
|
148 |
+
#: bp-activity/bp-activity-screens.php:437 bp-core/bp-core-admin.php:434
|
149 |
msgid "Activity"
|
150 |
msgstr ""
|
151 |
|
158 |
msgstr ""
|
159 |
|
160 |
#: bp-activity/bp-activity-admin.php:209 bp-activity/bp-activity-admin.php:256
|
161 |
+
#: bp-core/admin/bp-core-functions.php:434
|
162 |
+
#: bp-core/admin/bp-core-functions.php:452
|
163 |
+
#: bp-core/admin/bp-core-functions.php:471
|
164 |
+
#: bp-core/admin/bp-core-functions.php:490 bp-groups/bp-groups-admin.php:112
|
165 |
#: bp-groups/bp-groups-admin.php:148
|
166 |
msgid "Overview"
|
167 |
msgstr ""
|
199 |
msgstr ""
|
200 |
|
201 |
#: bp-activity/bp-activity-admin.php:228 bp-activity/bp-activity-admin.php:273
|
202 |
+
#: bp-core/admin/bp-core-functions.php:440
|
203 |
+
#: bp-core/admin/bp-core-functions.php:458
|
204 |
+
#: bp-core/admin/bp-core-functions.php:477
|
205 |
+
#: bp-core/admin/bp-core-functions.php:496 bp-groups/bp-groups-admin.php:120
|
206 |
#: bp-groups/bp-groups-admin.php:164
|
207 |
msgid "For more information:"
|
208 |
msgstr ""
|
212 |
msgstr ""
|
213 |
|
214 |
#: bp-activity/bp-activity-admin.php:230 bp-activity/bp-activity-admin.php:274
|
215 |
+
#: bp-core/admin/bp-core-functions.php:442
|
216 |
+
#: bp-core/admin/bp-core-functions.php:460
|
217 |
+
#: bp-core/admin/bp-core-functions.php:479
|
218 |
+
#: bp-core/admin/bp-core-functions.php:498 bp-groups/bp-groups-admin.php:165
|
219 |
msgid "<a href=\"http://buddypress.org/support/\">Support Forums</a>"
|
220 |
msgstr ""
|
221 |
|
419 |
msgstr ""
|
420 |
|
421 |
#: bp-activity/bp-activity-admin.php:1167 bp-groups/bp-groups-admin.php:1262
|
422 |
+
#: bp-messages/bp-messages-template.php:477
|
423 |
msgid "All"
|
424 |
msgstr ""
|
425 |
|
552 |
msgid "…"
|
553 |
msgstr ""
|
554 |
|
555 |
+
#: bp-activity/bp-activity-functions.php:875
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
556 |
msgid "Posted a status update"
|
557 |
msgstr ""
|
558 |
|
559 |
+
#: bp-activity/bp-activity-functions.php:876
|
560 |
msgid "Replied to a status update"
|
561 |
msgstr ""
|
562 |
|
563 |
+
#: bp-activity/bp-activity-functions.php:1164
|
564 |
msgid "%s posted an update"
|
565 |
msgstr ""
|
566 |
|
567 |
+
#: bp-activity/bp-activity-functions.php:1244
|
568 |
#: tests/testcases/activity/class.BP_Activity_Activity.php:202
|
569 |
msgid "%s posted a new activity comment"
|
570 |
msgstr ""
|
571 |
|
572 |
+
#: bp-activity/bp-activity-functions.php:1627
|
573 |
msgid "Thumbnail"
|
574 |
msgstr ""
|
575 |
|
601 |
|
602 |
#: bp-activity/bp-activity-loader.php:193
|
603 |
#: bp-activity/bp-activity-loader.php:296 bp-friends/bp-friends-loader.php:185
|
604 |
+
#: bp-friends/bp-friends-screens.php:85
|
605 |
msgid "Friends"
|
606 |
msgstr ""
|
607 |
|
608 |
#: bp-activity/bp-activity-loader.php:206
|
609 |
#: bp-activity/bp-activity-loader.php:306 bp-core/bp-core-template.php:364
|
|
|
|
|
610 |
#: bp-groups/bp-groups-admin.php:32 bp-groups/bp-groups-admin.php:33
|
611 |
#: bp-groups/bp-groups-admin.php:638 bp-groups/bp-groups-loader.php:516
|
612 |
+
#: bp-groups/bp-groups-notifications.php:349
|
613 |
+
#: bp-groups/bp-groups-notifications.php:385
|
614 |
+
#: bp-groups/bp-groups-notifications.php:421
|
615 |
+
#: bp-groups/bp-groups-notifications.php:457
|
616 |
+
#: bp-groups/bp-groups-screens.php:894 bp-groups/bp-groups-screens.php:1026
|
617 |
+
#: bp-groups/bp-groups-screens.php:1028 bp-groups/bp-groups-screens.php:1087
|
618 |
+
#: bp-groups/bp-groups-screens.php:1089 bp-groups/bp-groups-widgets.php:53
|
619 |
#: bp-groups/bp-groups-widgets.php:124
|
620 |
msgid "Groups"
|
621 |
msgstr ""
|
645 |
#: bp-members/bp-members-template.php:820
|
646 |
#: bp-members/bp-members-template.php:839
|
647 |
#: bp-messages/bp-messages-loader.php:258
|
648 |
+
#: bp-messages/bp-messages-template.php:356
|
649 |
+
#: bp-notifications/bp-notifications-loader.php:227
|
650 |
#: bp-templates/bp-legacy/buddypress/groups/single/admin.php:185
|
651 |
#: bp-templates/bp-legacy/buddypress/groups/single/admin.php:212
|
652 |
#: bp-themes/bp-default/groups/single/admin.php:185
|
655 |
msgid "Profile picture of %s"
|
656 |
msgstr ""
|
657 |
|
658 |
+
#: bp-activity/bp-activity-notifications.php:73
|
659 |
msgid "%s mentioned you in an update"
|
660 |
msgstr ""
|
661 |
|
662 |
+
#: bp-activity/bp-activity-notifications.php:76 bp-core/deprecated/1.5.php:354
|
663 |
msgid ""
|
664 |
"%1$s mentioned you in the group \"%2$s\":\n"
|
665 |
"\n"
|
670 |
"---------------------\n"
|
671 |
msgstr ""
|
672 |
|
673 |
+
#: bp-activity/bp-activity-notifications.php:86
|
674 |
msgid ""
|
675 |
"%1$s mentioned you in an update:\n"
|
676 |
"\n"
|
681 |
"---------------------\n"
|
682 |
msgstr ""
|
683 |
|
684 |
+
#: bp-activity/bp-activity-notifications.php:99
|
685 |
+
#: bp-activity/bp-activity-notifications.php:177
|
686 |
#: bp-activity/bp-activity-notifications.php:226 bp-core/deprecated/1.5.php:364
|
687 |
+
#: bp-friends/bp-friends-notifications.php:56
|
688 |
+
#: bp-friends/bp-friends-notifications.php:105
|
689 |
+
#: bp-groups/bp-groups-notifications.php:44
|
690 |
+
#: bp-groups/bp-groups-notifications.php:96
|
691 |
+
#: bp-groups/bp-groups-notifications.php:157
|
692 |
+
#: bp-groups/bp-groups-notifications.php:209
|
693 |
+
#: bp-groups/bp-groups-notifications.php:267
|
694 |
+
#: bp-messages/bp-messages-notifications.php:83
|
695 |
msgid "To disable these notifications please log in and go to: %s"
|
696 |
msgstr ""
|
697 |
|
698 |
+
#: bp-activity/bp-activity-notifications.php:164
|
699 |
msgid "%s replied to one of your updates"
|
700 |
msgstr ""
|
701 |
|
702 |
+
#: bp-activity/bp-activity-notifications.php:165
|
703 |
msgid ""
|
704 |
"%1$s replied to one of your updates:\n"
|
705 |
"\n"
|
725 |
"---------------------\n"
|
726 |
msgstr ""
|
727 |
|
728 |
+
#: bp-activity/bp-activity-notifications.php:280
|
729 |
+
msgid "@%s Mentions"
|
730 |
+
msgstr ""
|
731 |
+
|
732 |
+
#: bp-activity/bp-activity-notifications.php:283
|
733 |
+
msgid "You have %1$d new mentions"
|
734 |
+
msgstr ""
|
735 |
+
|
736 |
+
#: bp-activity/bp-activity-notifications.php:287
|
737 |
+
msgid "%1$s mentioned you"
|
738 |
+
msgstr ""
|
739 |
+
|
740 |
+
#: bp-activity/bp-activity-screens.php:231
|
741 |
msgid "You do not have access to this activity."
|
742 |
msgstr ""
|
743 |
|
744 |
+
#: bp-activity/bp-activity-screens.php:271 bp-blogs/bp-blogs-template.php:982
|
745 |
+
#: bp-friends/bp-friends-screens.php:86 bp-groups/bp-groups-screens.php:895
|
746 |
#: bp-messages/bp-messages-screens.php:169
|
747 |
#: bp-templates/bp-legacy/buddypress/members/register.php:227
|
748 |
#: bp-themes/bp-default/registration/register.php:232
|
749 |
msgid "Yes"
|
750 |
msgstr ""
|
751 |
|
752 |
+
#: bp-activity/bp-activity-screens.php:272 bp-blogs/bp-blogs-template.php:986
|
753 |
+
#: bp-friends/bp-friends-screens.php:87 bp-groups/bp-groups-screens.php:896
|
754 |
#: bp-messages/bp-messages-screens.php:170
|
755 |
#: bp-templates/bp-legacy/buddypress/members/register.php:228
|
756 |
#: bp-themes/bp-default/registration/register.php:233
|
757 |
msgid "No"
|
758 |
msgstr ""
|
759 |
|
760 |
+
#: bp-activity/bp-activity-screens.php:280
|
761 |
msgid "A member mentions you in an update using \"@%s\""
|
762 |
msgstr ""
|
763 |
|
764 |
+
#: bp-activity/bp-activity-screens.php:288
|
765 |
msgid "A member replies to an update or comment you've posted"
|
766 |
msgstr ""
|
767 |
|
768 |
+
#: bp-activity/bp-activity-screens.php:384
|
769 |
msgid "Sitewide Activity"
|
770 |
msgstr ""
|
771 |
|
928 |
msgstr ""
|
929 |
|
930 |
#: bp-blogs/bp-blogs-loader.php:203 bp-blogs/bp-blogs-screens.php:209
|
931 |
+
#: bp-blogs/bp-blogs-template.php:1099 bp-core/bp-core-filters.php:413
|
932 |
#: bp-themes/bp-default/blogs/create.php:21
|
933 |
#: bp-themes/bp-default/blogs/index.php:21
|
934 |
msgid "Create a Site"
|
958 |
msgid "Profile picture of site author %s"
|
959 |
msgstr ""
|
960 |
|
961 |
+
#: bp-blogs/bp-blogs-template.php:633 bp-core/bp-core-classes.php:796
|
962 |
#: bp-groups/bp-groups-widgets.php:85 bp-groups/bp-groups-widgets.php:188
|
963 |
#: bp-members/bp-members-template.php:596
|
964 |
#: bp-members/bp-members-template.php:871
|
1050 |
#: bp-blogs/bp-blogs-template.php:1134 bp-core/deprecated/1.5.php:417
|
1051 |
#: bp-forums/bp-forums-template.php:2196 bp-groups/bp-groups-template.php:2530
|
1052 |
#: bp-members/bp-members-template.php:710
|
1053 |
+
#: bp-messages/bp-messages-template.php:410 bp-themes/bp-default/header.php:30
|
1054 |
#: bp-themes/bp-default/searchform.php:5
|
1055 |
msgid "Search"
|
1056 |
msgstr ""
|
1124 |
#: bp-core/admin/bp-core-components.php:383
|
1125 |
#: bp-notifications/bp-notifications-buddybar.php:28
|
1126 |
#: bp-notifications/bp-notifications-loader.php:26
|
1127 |
+
#: bp-notifications/bp-notifications-loader.php:179
|
1128 |
+
#: bp-notifications/bp-notifications-loader.php:222
|
|
|
1129 |
msgid "Notifications"
|
1130 |
msgstr ""
|
1131 |
|
1226 |
msgstr ""
|
1227 |
|
1228 |
#: bp-core/admin/bp-core-components.php:380
|
1229 |
+
msgid "Global, personal, and group activity streams with threaded commenting, direct posting, favoriting, and @mentions, all with full RSS feed and email notification support."
|
1230 |
msgstr ""
|
1231 |
|
1232 |
#: bp-core/admin/bp-core-components.php:387 bp-groups/bp-groups-loader.php:83
|
1270 |
msgstr ""
|
1271 |
|
1272 |
#: bp-core/admin/bp-core-functions.php:257 bp-core/admin/bp-core-slugs.php:135
|
1273 |
+
#: bp-messages/bp-messages-template.php:601
|
1274 |
#: bp-templates/bp-legacy/buddypress/members/activate.php:29
|
1275 |
#: bp-themes/bp-default/registration/activate.php:38
|
1276 |
msgid "Activate"
|
1301 |
msgid "Settings"
|
1302 |
msgstr ""
|
1303 |
|
1304 |
+
#: bp-core/admin/bp-core-functions.php:393 bp-core/bp-core-template.php:370
|
1305 |
#: bp-forums/bp-forums-loader.php:132 bp-forums/bp-forums-loader.php:199
|
1306 |
#: bp-forums/bp-forums-loader.php:240 bp-forums/bp-forums-screens.php:208
|
1307 |
#: bp-forums/bp-forums-screens.php:210 bp-forums/deprecated/1.6.php:42
|
1309 |
msgid "Forums"
|
1310 |
msgstr ""
|
1311 |
|
1312 |
+
#: bp-core/admin/bp-core-functions.php:441
|
1313 |
msgid "<a href=\"http://codex.buddypress.org/getting-started/configure-buddypress-components/#settings-buddypress-components\">Managing Components</a>"
|
1314 |
msgstr ""
|
1315 |
|
1316 |
+
#: bp-core/admin/bp-core-functions.php:459
|
1317 |
msgid "<a href=\"http://codex.buddypress.org/getting-started/configure-buddypress-components/#settings-buddypress-pages\">Managing Pages</a>"
|
1318 |
msgstr ""
|
1319 |
|
1320 |
+
#: bp-core/admin/bp-core-functions.php:478
|
1321 |
msgid "<a href=\"http://codex.buddypress.org/getting-started/configure-buddypress-components/#settings-buddypress-settings\">Managing Settings</a>"
|
1322 |
msgstr ""
|
1323 |
|
1324 |
+
#: bp-core/admin/bp-core-functions.php:497
|
1325 |
msgid "<a href=\"http://codex.buddypress.org/getting-started/configure-buddypress-components/#users-profile-fields\">Managing Profile Fields</a>"
|
1326 |
msgstr ""
|
1327 |
|
1328 |
+
#: bp-core/admin/bp-core-functions.php:515
|
1329 |
msgid "By default, all BuddyPress components are enabled. You can selectively disable any of the components by using the form. Your BuddyPress installation will continue to function. However, the features of the disabled components will no longer be accessible to anyone using the site."
|
1330 |
msgstr ""
|
1331 |
|
1332 |
+
#: bp-core/admin/bp-core-functions.php:519
|
1333 |
msgid "BuddyPress Components use WordPress Pages for their root directory/archive pages. Here you can change the page associations for each active component."
|
1334 |
msgstr ""
|
1335 |
|
1336 |
+
#: bp-core/admin/bp-core-functions.php:523
|
1337 |
msgid "Extra configuration settings."
|
1338 |
msgstr ""
|
1339 |
|
1340 |
+
#: bp-core/admin/bp-core-functions.php:527
|
1341 |
msgid "Your users will distinguish themselves through their profile page. Create relevant profile fields that will show on each users profile.</br></br>Note: Any fields in the first group will appear on the signup page."
|
1342 |
msgstr ""
|
1343 |
|
1344 |
+
#: bp-core/admin/bp-core-functions.php:687 bp-core/bp-core-admin.php:197
|
1345 |
#: bp-core/bp-core-admin.php:198 bp-core/bp-core-admin.php:218
|
1346 |
msgid "BuddyPress"
|
1347 |
msgstr ""
|
1348 |
|
1349 |
+
#: bp-core/admin/bp-core-functions.php:709
|
1350 |
+
#: bp-core/admin/bp-core-functions.php:718
|
1351 |
msgid "Logged-In"
|
1352 |
msgstr ""
|
1353 |
|
1354 |
+
#: bp-core/admin/bp-core-functions.php:712
|
1355 |
+
#: bp-core/admin/bp-core-functions.php:727
|
1356 |
msgid "Logged-Out"
|
1357 |
msgstr ""
|
1358 |
|
1359 |
+
#: bp-core/admin/bp-core-functions.php:719
|
1360 |
msgid "<em>Logged-In</em> links are relative to the current user, and are not visible to visitors who are not logged in."
|
1361 |
msgstr ""
|
1362 |
|
1363 |
+
#: bp-core/admin/bp-core-functions.php:728
|
1364 |
msgid "<em>Logged-Out</em> links are not visible to users who are logged in."
|
1365 |
msgstr ""
|
1366 |
|
1367 |
+
#: bp-core/admin/bp-core-functions.php:738
|
1368 |
msgid "Add to Menu"
|
1369 |
msgstr ""
|
1370 |
|
1664 |
msgid "Not using @-mentions? Disable them with <code>add_filter( 'bp_activity_do_mentions', '__return_false' );</code>"
|
1665 |
msgstr ""
|
1666 |
|
1667 |
+
#: bp-core/bp-core-admin.php:504 bp-core/bp-core-admin.php:632
|
1668 |
msgid "Go to the BuddyPress Settings page"
|
1669 |
msgstr ""
|
1670 |
|
1700 |
msgid "Recent Rockstars"
|
1701 |
msgstr ""
|
1702 |
|
1703 |
+
#: bp-core/bp-core-admin.php:591
|
1704 |
+
msgid "Contributors to BuddyPress 1.9"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1705 |
msgstr ""
|
1706 |
|
1707 |
#: bp-core/bp-core-adminbar.php:36 bp-core/bp-core-buddybar.php:571
|
1752 |
msgid "Upload failed! Error was: %s"
|
1753 |
msgstr ""
|
1754 |
|
1755 |
+
#: bp-core/bp-core-avatars.php:831 bp-core/bp-core-classes.php:793
|
1756 |
+
#: bp-core/bp-core-classes.php:794 bp-core/bp-core-classes.php:795
|
1757 |
#: bp-core/bp-core-template.php:135 bp-core/bp-core-template.php:151
|
1758 |
msgid "Avatar of %s"
|
1759 |
msgstr ""
|
1806 |
msgid "You must log in to access the page you requested."
|
1807 |
msgstr ""
|
1808 |
|
1809 |
+
#: bp-core/bp-core-classes.php:810
|
1810 |
msgid "%d group"
|
1811 |
msgid_plural "%d groups"
|
1812 |
msgstr[0] ""
|
1849 |
msgid "Activate Your Account"
|
1850 |
msgstr ""
|
1851 |
|
1852 |
+
#: bp-core/bp-core-filters.php:378
|
1853 |
msgctxt "Construct the page title. 1 = user name, 2 = component name, 3 = seperator"
|
1854 |
msgid "%1$s %3$s %2$s"
|
1855 |
msgstr ""
|
1856 |
|
1857 |
#. translators: "group name | group nav section name"
|
1858 |
|
1859 |
+
#: bp-core/bp-core-filters.php:384
|
1860 |
msgid "%1$s | %2$s"
|
1861 |
msgstr ""
|
1862 |
|
1863 |
#. translators: "component item name | component nav section name | root
|
1864 |
#. component name"
|
1865 |
|
1866 |
+
#: bp-core/bp-core-filters.php:389
|
1867 |
msgid "%1$s | %2$s | %3$s"
|
1868 |
msgstr ""
|
1869 |
|
1870 |
+
#: bp-core/bp-core-filters.php:394 bp-core/bp-core-filters.php:396
|
1871 |
msgid "%s Directory"
|
1872 |
msgstr ""
|
1873 |
|
1874 |
+
#: bp-core/bp-core-filters.php:401 bp-members/bp-members-screens.php:525
|
1875 |
#: bp-themes/bp-default/registration/register.php:23
|
1876 |
msgid "Create an Account"
|
1877 |
msgstr ""
|
1878 |
|
1879 |
+
#: bp-core/bp-core-filters.php:405 bp-members/bp-members-screens.php:533
|
1880 |
#: bp-themes/bp-default/registration/activate.php:13
|
1881 |
msgid "Activate your Account"
|
1882 |
msgstr ""
|
1883 |
|
1884 |
+
#: bp-core/bp-core-filters.php:409 bp-groups/bp-groups-loader.php:553
|
1885 |
+
#: bp-groups/bp-groups-screens.php:1026 bp-groups/bp-groups-screens.php:1087
|
1886 |
#: bp-themes/bp-default/groups/create.php:18
|
1887 |
#: bp-themes/bp-default/groups/index.php:21
|
1888 |
msgid "Create a Group"
|
2244 |
msgid "The forums component has not been set up yet."
|
2245 |
msgstr ""
|
2246 |
|
2247 |
+
#: bp-forums/bp-forums-screens.php:48 bp-groups/bp-groups-screens.php:372
|
2248 |
msgid "Please provide a title for your forum topic."
|
2249 |
msgstr ""
|
2250 |
|
2251 |
+
#: bp-forums/bp-forums-screens.php:50 bp-groups/bp-groups-screens.php:374
|
2252 |
msgid "Forum posts cannot be empty. Please enter some text."
|
2253 |
msgstr ""
|
2254 |
|
2255 |
+
#: bp-forums/bp-forums-screens.php:57 bp-groups/bp-groups-screens.php:386
|
2256 |
msgid "There was an error when creating the topic"
|
2257 |
msgstr ""
|
2258 |
|
2259 |
+
#: bp-forums/bp-forums-screens.php:60 bp-groups/bp-groups-screens.php:389
|
2260 |
msgid "The topic was created successfully"
|
2261 |
msgstr ""
|
2262 |
|
2285 |
#: bp-forums/bp-forums-template.php:756 bp-forums/bp-forums-template.php:870
|
2286 |
#: bp-forums/bp-forums-template.php:2014
|
2287 |
#: bp-messages/bp-messages-classes.php:270
|
2288 |
+
#: bp-messages/bp-messages-template.php:884
|
2289 |
+
#: bp-messages/bp-messages-template.php:966
|
2290 |
msgid "Deleted User"
|
2291 |
msgstr ""
|
2292 |
|
2536 |
msgid "You have a pending friendship request with this user"
|
2537 |
msgstr ""
|
2538 |
|
2539 |
+
#: bp-friends/bp-friends-activity.php:95
|
2540 |
msgid "Friendships accepted"
|
2541 |
msgstr ""
|
2542 |
|
2543 |
+
#: bp-friends/bp-friends-activity.php:96
|
2544 |
msgid "New friendships"
|
2545 |
msgstr ""
|
2546 |
|
2547 |
+
#: bp-friends/bp-friends-activity.php:99
|
2548 |
msgid "New friendship created"
|
2549 |
msgstr ""
|
2550 |
|
2551 |
+
#: bp-friends/bp-friends-activity.php:131
|
2552 |
+
#: bp-friends/bp-friends-activity.php:140
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2553 |
msgid "%1$s and %2$s are now friends"
|
2554 |
msgstr ""
|
2555 |
|
2586 |
msgid "No Pending Requests"
|
2587 |
msgstr ""
|
2588 |
|
2589 |
+
#: bp-friends/bp-friends-notifications.php:43
|
2590 |
msgid "New friendship request from %s"
|
2591 |
msgstr ""
|
2592 |
|
2593 |
+
#: bp-friends/bp-friends-notifications.php:44
|
2594 |
msgid ""
|
2595 |
"%1$s wants to add you as a friend.\n"
|
2596 |
"\n"
|
2601 |
"---------------------\n"
|
2602 |
msgstr ""
|
2603 |
|
2604 |
+
#: bp-friends/bp-friends-notifications.php:94
|
2605 |
+
#: bp-friends/bp-friends-notifications.php:144
|
2606 |
+
msgid "%s accepted your friendship request"
|
2607 |
+
msgstr ""
|
2608 |
+
|
2609 |
+
#: bp-friends/bp-friends-notifications.php:95
|
2610 |
msgid ""
|
2611 |
"%1$s accepted your friend request.\n"
|
2612 |
"\n"
|
2615 |
"---------------------\n"
|
2616 |
msgstr ""
|
2617 |
|
2618 |
+
#: bp-friends/bp-friends-notifications.php:141
|
2619 |
+
msgid "%d friends accepted your friendship requests"
|
2620 |
+
msgstr ""
|
2621 |
+
|
2622 |
+
#: bp-friends/bp-friends-notifications.php:155
|
2623 |
+
msgid "You have %d pending friendship requests"
|
2624 |
+
msgstr ""
|
2625 |
+
|
2626 |
+
#: bp-friends/bp-friends-notifications.php:158
|
2627 |
+
msgid "You have a friendship request from %s"
|
2628 |
+
msgstr ""
|
2629 |
+
|
2630 |
+
#: bp-friends/bp-friends-screens.php:36
|
2631 |
msgid "Friendship accepted"
|
2632 |
msgstr ""
|
2633 |
|
2634 |
+
#: bp-friends/bp-friends-screens.php:38
|
2635 |
msgid "Friendship could not be accepted"
|
2636 |
msgstr ""
|
2637 |
|
2638 |
+
#: bp-friends/bp-friends-screens.php:47
|
2639 |
msgid "Friendship rejected"
|
2640 |
msgstr ""
|
2641 |
|
2642 |
+
#: bp-friends/bp-friends-screens.php:49
|
2643 |
msgid "Friendship could not be rejected"
|
2644 |
msgstr ""
|
2645 |
|
2646 |
+
#: bp-friends/bp-friends-screens.php:58
|
2647 |
msgid "Friendship request withdrawn"
|
2648 |
msgstr ""
|
2649 |
|
2650 |
+
#: bp-friends/bp-friends-screens.php:60
|
2651 |
msgid "Friendship request could not be withdrawn"
|
2652 |
msgstr ""
|
2653 |
|
2654 |
+
#: bp-friends/bp-friends-screens.php:94
|
2655 |
msgid "A member sends you a friendship request"
|
2656 |
msgstr ""
|
2657 |
|
2658 |
+
#: bp-friends/bp-friends-screens.php:100
|
2659 |
msgid "A member accepts your friendship request"
|
2660 |
msgstr ""
|
2661 |
|
2787 |
msgid "You joined the group!"
|
2788 |
msgstr ""
|
2789 |
|
2790 |
+
#: bp-groups/bp-groups-actions.php:272 bp-groups/bp-groups-screens.php:711
|
2791 |
msgid "This group must have at least one admin"
|
2792 |
msgstr ""
|
2793 |
|
2795 |
msgid "There was an error leaving the group."
|
2796 |
msgstr ""
|
2797 |
|
2798 |
+
#: bp-groups/bp-groups-actions.php:276 bp-groups/bp-groups-functions.php:291
|
2799 |
msgid "You successfully left the group."
|
2800 |
msgstr ""
|
2801 |
|
2819 |
msgid "New group forum post"
|
2820 |
msgstr ""
|
2821 |
|
2822 |
+
#: bp-groups/bp-groups-activity.php:140 bp-groups/bp-groups-functions.php:335
|
2823 |
+
#: bp-groups/bp-groups-screens.php:52
|
2824 |
+
msgid "%1$s joined the group %2$s"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2825 |
msgstr ""
|
2826 |
|
2827 |
#: bp-groups/bp-groups-admin.php:114
|
3077 |
msgid "Delete Group"
|
3078 |
msgstr ""
|
3079 |
|
3080 |
+
#: bp-groups/bp-groups-admin.php:881 bp-groups/bp-groups-classes.php:2162
|
3081 |
#: bp-templates/bp-legacy/buddypress/groups/single/admin.php:32
|
3082 |
#: bp-templates/bp-legacy/buddypress/groups/single/admin.php:117
|
3083 |
#: bp-templates/bp-legacy/buddypress/groups/single/forum/edit.php:58
|
3173 |
msgid "Edit Settings"
|
3174 |
msgstr ""
|
3175 |
|
3176 |
+
#: bp-groups/bp-groups-adminbar.php:64 bp-members/bp-members-adminbar.php:108
|
3177 |
msgid "Edit Avatar"
|
3178 |
msgstr ""
|
3179 |
|
3202 |
msgid "Group Avatar"
|
3203 |
msgstr ""
|
3204 |
|
3205 |
+
#: bp-groups/bp-groups-classes.php:1346
|
3206 |
msgid "Group Mod"
|
3207 |
msgstr ""
|
3208 |
|
3209 |
+
#: bp-groups/bp-groups-classes.php:1352 bp-groups/bp-groups-functions.php:121
|
3210 |
msgid "Group Admin"
|
3211 |
msgstr ""
|
3212 |
|
3213 |
+
#: bp-groups/bp-groups-forums.php:107 bp-groups/bp-groups-forums.php:256
|
3214 |
msgid "%1$s replied to the forum topic %2$s in the group %3$s"
|
3215 |
msgstr ""
|
3216 |
|
3217 |
+
#: bp-groups/bp-groups-forums.php:157
|
3218 |
msgid "%1$s started the forum topic %2$s in the group %3$s"
|
3219 |
msgstr ""
|
3220 |
|
3221 |
+
#: bp-groups/bp-groups-forums.php:209
|
3222 |
msgid "%1$s edited the forum topic %2$s in the group %3$s"
|
3223 |
msgstr ""
|
3224 |
|
3225 |
+
#: bp-groups/bp-groups-functions.php:281
|
3226 |
msgid "As the only Admin, you cannot leave the group."
|
3227 |
msgstr ""
|
3228 |
|
3229 |
+
#: bp-groups/bp-groups-functions.php:596
|
|
|
|
|
|
|
|
|
|
|
3230 |
msgid "%1$s posted an update in the group %2$s"
|
3231 |
msgstr ""
|
3232 |
|
3309 |
msgid "Pending Invites <span class=\"count\">%s</span>"
|
3310 |
msgstr ""
|
3311 |
|
3312 |
+
#: bp-groups/bp-groups-notifications.php:21
|
3313 |
msgid "Group Details Updated"
|
3314 |
msgstr ""
|
3315 |
|
3316 |
+
#: bp-groups/bp-groups-notifications.php:36
|
3317 |
msgid ""
|
3318 |
"Group details for the group \"%1$s\" were updated:\n"
|
3319 |
"\n"
|
3322 |
"---------------------\n"
|
3323 |
msgstr ""
|
3324 |
|
3325 |
+
#: bp-groups/bp-groups-notifications.php:79
|
3326 |
msgid "Membership request for group: %s"
|
3327 |
msgstr ""
|
3328 |
|
3329 |
+
#: bp-groups/bp-groups-notifications.php:81
|
3330 |
msgid ""
|
3331 |
"%1$s wants to join the group \"%2$s\".\n"
|
3332 |
"\n"
|
3340 |
"---------------------\n"
|
3341 |
msgstr ""
|
3342 |
|
3343 |
+
#: bp-groups/bp-groups-notifications.php:135
|
3344 |
msgid "Membership request for group \"%s\" accepted"
|
3345 |
msgstr ""
|
3346 |
|
3347 |
+
#: bp-groups/bp-groups-notifications.php:136
|
3348 |
msgid ""
|
3349 |
"Your membership request for the group \"%1$s\" has been accepted.\n"
|
3350 |
"\n"
|
3353 |
"---------------------\n"
|
3354 |
msgstr ""
|
3355 |
|
3356 |
+
#: bp-groups/bp-groups-notifications.php:145
|
3357 |
msgid "Membership request for group \"%s\" rejected"
|
3358 |
msgstr ""
|
3359 |
|
3360 |
+
#: bp-groups/bp-groups-notifications.php:146
|
3361 |
msgid ""
|
3362 |
"Your membership request for the group \"%1$s\" has been rejected.\n"
|
3363 |
"\n"
|
3366 |
"---------------------\n"
|
3367 |
msgstr ""
|
3368 |
|
3369 |
+
#: bp-groups/bp-groups-notifications.php:175
|
3370 |
msgid "an administrator"
|
3371 |
msgstr ""
|
3372 |
|
3373 |
+
#: bp-groups/bp-groups-notifications.php:178
|
3374 |
msgid "a moderator"
|
3375 |
msgstr ""
|
3376 |
|
3377 |
+
#: bp-groups/bp-groups-notifications.php:198
|
3378 |
msgid "You have been promoted in the group: \"%s\""
|
3379 |
msgstr ""
|
3380 |
|
3381 |
+
#: bp-groups/bp-groups-notifications.php:199
|
3382 |
msgid ""
|
3383 |
"You have been promoted to %1$s for the group: \"%2$s\".\n"
|
3384 |
"\n"
|
3387 |
"---------------------\n"
|
3388 |
msgstr ""
|
3389 |
|
3390 |
+
#: bp-groups/bp-groups-notifications.php:251
|
3391 |
msgid "You have an invitation to the group: \"%s\""
|
3392 |
msgstr ""
|
3393 |
|
3394 |
+
#: bp-groups/bp-groups-notifications.php:253
|
3395 |
msgid ""
|
3396 |
"One of your friends %1$s has invited you to the group: \"%2$s\".\n"
|
3397 |
"\n"
|
3404 |
"---------------------\n"
|
3405 |
msgstr ""
|
3406 |
|
3407 |
+
#: bp-groups/bp-groups-notifications.php:307
|
3408 |
+
msgid "%1$d new membership requests for the group \"%2$s\""
|
3409 |
+
msgstr ""
|
3410 |
+
|
3411 |
+
#: bp-groups/bp-groups-notifications.php:312
|
3412 |
+
msgid "Group Membership Requests"
|
3413 |
+
msgstr ""
|
3414 |
+
|
3415 |
+
#: bp-groups/bp-groups-notifications.php:321
|
3416 |
+
#: bp-groups/bp-groups-notifications.php:326
|
3417 |
+
msgid "%s requests group membership"
|
3418 |
+
msgstr ""
|
3419 |
+
|
3420 |
+
#: bp-groups/bp-groups-notifications.php:344
|
3421 |
+
msgid "%d accepted group membership requests"
|
3422 |
+
msgstr ""
|
3423 |
+
|
3424 |
+
#: bp-groups/bp-groups-notifications.php:357
|
3425 |
+
msgid "Membership for group \"%s\" accepted"
|
3426 |
+
msgstr ""
|
3427 |
+
|
3428 |
+
#: bp-groups/bp-groups-notifications.php:380
|
3429 |
+
msgid "%d rejected group membership requests"
|
3430 |
+
msgstr ""
|
3431 |
+
|
3432 |
+
#: bp-groups/bp-groups-notifications.php:393
|
3433 |
+
msgid "Membership for group \"%s\" rejected"
|
3434 |
+
msgstr ""
|
3435 |
+
|
3436 |
+
#: bp-groups/bp-groups-notifications.php:416
|
3437 |
+
msgid "You were promoted to an admin in %d groups"
|
3438 |
+
msgstr ""
|
3439 |
+
|
3440 |
+
#: bp-groups/bp-groups-notifications.php:429
|
3441 |
+
msgid "You were promoted to an admin in the group \"%s\""
|
3442 |
+
msgstr ""
|
3443 |
+
|
3444 |
+
#: bp-groups/bp-groups-notifications.php:452
|
3445 |
+
msgid "You were promoted to a mod in %d groups"
|
3446 |
+
msgstr ""
|
3447 |
+
|
3448 |
+
#: bp-groups/bp-groups-notifications.php:465
|
3449 |
+
msgid "You were promoted to a mod in the group \"%s\""
|
3450 |
+
msgstr ""
|
3451 |
+
|
3452 |
+
#: bp-groups/bp-groups-notifications.php:489
|
3453 |
+
msgid "You have %d new group invitations"
|
3454 |
+
msgstr ""
|
3455 |
+
|
3456 |
+
#: bp-groups/bp-groups-notifications.php:493
|
3457 |
+
msgid "Group Invites"
|
3458 |
+
msgstr ""
|
3459 |
+
|
3460 |
+
#: bp-groups/bp-groups-notifications.php:501
|
3461 |
+
msgid "You have an invitation to the group: %s"
|
3462 |
+
msgstr ""
|
3463 |
+
|
3464 |
+
#: bp-groups/bp-groups-screens.php:44
|
3465 |
msgid "Group invite could not be accepted"
|
3466 |
msgstr ""
|
3467 |
|
3468 |
+
#: bp-groups/bp-groups-screens.php:46 bp-groups/bp-groups-screens.php:464
|
3469 |
msgid "Group invite accepted"
|
3470 |
msgstr ""
|
3471 |
|
3472 |
+
#: bp-groups/bp-groups-screens.php:72
|
3473 |
msgid "Group invite could not be rejected"
|
3474 |
msgstr ""
|
3475 |
|
3476 |
+
#: bp-groups/bp-groups-screens.php:74
|
3477 |
msgid "Group invite rejected"
|
3478 |
msgstr ""
|
3479 |
|
3480 |
+
#: bp-groups/bp-groups-screens.php:152
|
3481 |
msgid "It looks like you've already said that!"
|
3482 |
msgstr ""
|
3483 |
|
3484 |
+
#: bp-groups/bp-groups-screens.php:155
|
3485 |
msgid "There was an error when replying to that topic"
|
3486 |
msgstr ""
|
3487 |
|
3488 |
+
#: bp-groups/bp-groups-screens.php:157
|
3489 |
msgid "Your reply was posted successfully"
|
3490 |
msgstr ""
|
3491 |
|
3492 |
+
#: bp-groups/bp-groups-screens.php:178
|
3493 |
msgid "There was an error when making that topic a sticky"
|
3494 |
msgstr ""
|
3495 |
|
3496 |
+
#: bp-groups/bp-groups-screens.php:180
|
3497 |
msgid "The topic was made sticky successfully"
|
3498 |
msgstr ""
|
3499 |
|
3500 |
+
#: bp-groups/bp-groups-screens.php:193
|
3501 |
msgid "There was an error when unsticking that topic"
|
3502 |
msgstr ""
|
3503 |
|
3504 |
+
#: bp-groups/bp-groups-screens.php:195
|
3505 |
msgid "The topic was unstuck successfully"
|
3506 |
msgstr ""
|
3507 |
|
3508 |
+
#: bp-groups/bp-groups-screens.php:208
|
3509 |
msgid "There was an error when closing that topic"
|
3510 |
msgstr ""
|
3511 |
|
3512 |
+
#: bp-groups/bp-groups-screens.php:210
|
3513 |
msgid "The topic was closed successfully"
|
3514 |
msgstr ""
|
3515 |
|
3516 |
+
#: bp-groups/bp-groups-screens.php:223
|
3517 |
msgid "There was an error when opening that topic"
|
3518 |
msgstr ""
|
3519 |
|
3520 |
+
#: bp-groups/bp-groups-screens.php:225
|
3521 |
msgid "The topic was opened successfully"
|
3522 |
msgstr ""
|
3523 |
|
3524 |
+
#: bp-groups/bp-groups-screens.php:248
|
3525 |
msgid "There was an error deleting the topic"
|
3526 |
msgstr ""
|
3527 |
|
3528 |
+
#: bp-groups/bp-groups-screens.php:250
|
3529 |
msgid "The topic was deleted successfully"
|
3530 |
msgstr ""
|
3531 |
|
3532 |
+
#: bp-groups/bp-groups-screens.php:274
|
3533 |
msgid "There was an error when editing that topic"
|
3534 |
msgstr ""
|
3535 |
|
3536 |
+
#: bp-groups/bp-groups-screens.php:276
|
3537 |
msgid "The topic was edited successfully"
|
3538 |
msgstr ""
|
3539 |
|
3540 |
+
#: bp-groups/bp-groups-screens.php:301
|
3541 |
msgid "There was an error deleting that post"
|
3542 |
msgstr ""
|
3543 |
|
3544 |
+
#: bp-groups/bp-groups-screens.php:303
|
3545 |
msgid "The post was deleted successfully"
|
3546 |
msgstr ""
|
3547 |
|
3548 |
+
#: bp-groups/bp-groups-screens.php:327
|
3549 |
msgid "There was an error when editing that post"
|
3550 |
msgstr ""
|
3551 |
|
3552 |
+
#: bp-groups/bp-groups-screens.php:329
|
3553 |
msgid "The post was edited successfully"
|
3554 |
msgstr ""
|
3555 |
|
3556 |
+
#: bp-groups/bp-groups-screens.php:345 bp-groups/bp-groups-screens.php:364
|
3557 |
msgid "You have been banned from this group."
|
3558 |
msgstr ""
|
3559 |
|
3560 |
+
#: bp-groups/bp-groups-screens.php:378
|
3561 |
msgid "This group does not have a forum setup yet."
|
3562 |
msgstr ""
|
3563 |
|
3564 |
+
#: bp-groups/bp-groups-screens.php:437
|
3565 |
msgid "Group invites sent."
|
3566 |
msgstr ""
|
3567 |
|
3568 |
+
#: bp-groups/bp-groups-screens.php:466
|
3569 |
msgid "There was an error accepting the group invitation, please try again."
|
3570 |
msgstr ""
|
3571 |
|
3572 |
+
#: bp-groups/bp-groups-screens.php:478
|
3573 |
msgid "There was an error sending your group membership request, please try again."
|
3574 |
msgstr ""
|
3575 |
|
3576 |
+
#: bp-groups/bp-groups-screens.php:480
|
3577 |
msgid "Your membership request was sent to the group administrator successfully. You will be notified when the group administrator responds to your request."
|
3578 |
msgstr ""
|
3579 |
|
3580 |
+
#: bp-groups/bp-groups-screens.php:529
|
3581 |
msgid "There was an error updating group details, please try again."
|
3582 |
msgstr ""
|
3583 |
|
3584 |
+
#: bp-groups/bp-groups-screens.php:531
|
3585 |
msgid "Group details were successfully updated."
|
3586 |
msgstr ""
|
3587 |
|
3588 |
+
#: bp-groups/bp-groups-screens.php:573
|
3589 |
msgid "There was an error updating group settings, please try again."
|
3590 |
msgstr ""
|
3591 |
|
3592 |
+
#: bp-groups/bp-groups-screens.php:575
|
3593 |
msgid "Group settings were successfully updated."
|
3594 |
msgstr ""
|
3595 |
|
3596 |
+
#: bp-groups/bp-groups-screens.php:607 bp-xprofile/bp-xprofile-actions.php:39
|
3597 |
msgid "Your avatar was deleted successfully!"
|
3598 |
msgstr ""
|
3599 |
|
3600 |
+
#: bp-groups/bp-groups-screens.php:609 bp-xprofile/bp-xprofile-actions.php:41
|
3601 |
msgid "There was a problem deleting that avatar, please try again."
|
3602 |
msgstr ""
|
3603 |
|
3604 |
+
#: bp-groups/bp-groups-screens.php:652
|
3605 |
msgid "There was a problem cropping the avatar."
|
3606 |
msgstr ""
|
3607 |
|
3608 |
+
#: bp-groups/bp-groups-screens.php:654
|
3609 |
msgid "The new group avatar was uploaded successfully."
|
3610 |
msgstr ""
|
3611 |
|
3612 |
+
#: bp-groups/bp-groups-screens.php:690
|
3613 |
msgid "There was an error when promoting that user, please try again"
|
3614 |
msgstr ""
|
3615 |
|
3616 |
+
#: bp-groups/bp-groups-screens.php:692
|
3617 |
msgid "User promoted successfully"
|
3618 |
msgstr ""
|
3619 |
|
3620 |
+
#: bp-groups/bp-groups-screens.php:715
|
3621 |
msgid "There was an error when demoting that user, please try again"
|
3622 |
msgstr ""
|
3623 |
|
3624 |
+
#: bp-groups/bp-groups-screens.php:717
|
3625 |
msgid "User demoted successfully"
|
3626 |
msgstr ""
|
3627 |
|
3628 |
+
#: bp-groups/bp-groups-screens.php:733
|
3629 |
msgid "There was an error when banning that user, please try again"
|
3630 |
msgstr ""
|
3631 |
|
3632 |
+
#: bp-groups/bp-groups-screens.php:735
|
3633 |
msgid "User banned successfully"
|
3634 |
msgstr ""
|
3635 |
|
3636 |
+
#: bp-groups/bp-groups-screens.php:751
|
3637 |
msgid "There was an error when unbanning that user, please try again"
|
3638 |
msgstr ""
|
3639 |
|
3640 |
+
#: bp-groups/bp-groups-screens.php:753
|
3641 |
msgid "User ban removed successfully"
|
3642 |
msgstr ""
|
3643 |
|
3644 |
+
#: bp-groups/bp-groups-screens.php:769
|
3645 |
msgid "There was an error removing that user from the group, please try again"
|
3646 |
msgstr ""
|
3647 |
|
3648 |
+
#: bp-groups/bp-groups-screens.php:771
|
3649 |
msgid "User removed successfully"
|
3650 |
msgstr ""
|
3651 |
|
3652 |
+
#: bp-groups/bp-groups-screens.php:808
|
3653 |
msgid "There was an error accepting the membership request, please try again."
|
3654 |
msgstr ""
|
3655 |
|
3656 |
+
#: bp-groups/bp-groups-screens.php:810
|
3657 |
msgid "Group membership request accepted"
|
3658 |
msgstr ""
|
3659 |
|
3660 |
+
#: bp-groups/bp-groups-screens.php:819
|
3661 |
msgid "There was an error rejecting the membership request, please try again."
|
3662 |
msgstr ""
|
3663 |
|
3664 |
+
#: bp-groups/bp-groups-screens.php:821
|
3665 |
msgid "Group membership request rejected"
|
3666 |
msgstr ""
|
3667 |
|
3668 |
+
#: bp-groups/bp-groups-screens.php:853
|
3669 |
msgid "There was an error deleting the group, please try again."
|
3670 |
msgstr ""
|
3671 |
|
3672 |
+
#: bp-groups/bp-groups-screens.php:855
|
3673 |
msgid "The group was deleted successfully"
|
3674 |
msgstr ""
|
3675 |
|
3676 |
+
#: bp-groups/bp-groups-screens.php:903
|
3677 |
msgid "A member invites you to join a group"
|
3678 |
msgstr ""
|
3679 |
|
3680 |
+
#: bp-groups/bp-groups-screens.php:909
|
3681 |
msgid "Group information is updated"
|
3682 |
msgstr ""
|
3683 |
|
3684 |
+
#: bp-groups/bp-groups-screens.php:915
|
3685 |
msgid "You are promoted to a group administrator or moderator"
|
3686 |
msgstr ""
|
3687 |
|
3688 |
+
#: bp-groups/bp-groups-screens.php:921
|
3689 |
msgid "A member requests to join a private group for which you are an admin"
|
3690 |
msgstr ""
|
3691 |
|
3927 |
msgid "Edit Member"
|
3928 |
msgstr ""
|
3929 |
|
3930 |
+
#: bp-members/bp-members-adminbar.php:100
|
3931 |
+
#: bp-xprofile/bp-xprofile-template.php:921
|
3932 |
+
#: bp-xprofile/bp-xprofile-template.php:922
|
3933 |
msgid "Edit Profile"
|
3934 |
msgstr ""
|
3935 |
|
4148 |
msgid "No Subject"
|
4149 |
msgstr ""
|
4150 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4151 |
#: bp-messages/bp-messages-loader.php:33
|
4152 |
msgid "Private Messages"
|
4153 |
msgstr ""
|
4161 |
msgid "Messages <span>%s</span>"
|
4162 |
msgstr ""
|
4163 |
|
4164 |
+
#: bp-messages/bp-messages-loader.php:132
|
4165 |
+
#: bp-messages/bp-messages-loader.php:196
|
4166 |
+
#: bp-messages/bp-messages-notifications.php:115
|
4167 |
+
msgid "Inbox"
|
4168 |
+
msgstr ""
|
4169 |
+
|
4170 |
#: bp-messages/bp-messages-loader.php:142
|
4171 |
#: bp-messages/bp-messages-loader.php:219
|
4172 |
msgid "Sent"
|
4202 |
msgid "My Messages"
|
4203 |
msgstr ""
|
4204 |
|
4205 |
+
#: bp-messages/bp-messages-notifications.php:67
|
4206 |
msgid "New message from %s"
|
4207 |
msgstr ""
|
4208 |
|
4209 |
+
#: bp-messages/bp-messages-notifications.php:69
|
4210 |
msgid ""
|
4211 |
"%1$s sent you a new message:\n"
|
4212 |
"\n"
|
4219 |
"---------------------\n"
|
4220 |
msgstr ""
|
4221 |
|
4222 |
+
#: bp-messages/bp-messages-notifications.php:118
|
4223 |
+
msgid "You have %d new messages"
|
4224 |
+
msgstr ""
|
4225 |
+
|
4226 |
+
#: bp-messages/bp-messages-notifications.php:122
|
4227 |
+
msgid "You have %d new message from %s"
|
4228 |
+
msgstr ""
|
4229 |
+
|
4230 |
+
#: bp-messages/bp-messages-notifications.php:124
|
4231 |
+
msgid "You have %d new message"
|
4232 |
+
msgstr ""
|
4233 |
+
|
4234 |
#: bp-messages/bp-messages-screens.php:56
|
4235 |
#: bp-messages/bp-messages-screens.php:78
|
4236 |
msgid "There was an error sending that message, please try again"
|
4286 |
msgid "→"
|
4287 |
msgstr ""
|
4288 |
|
4289 |
+
#: bp-messages/bp-messages-template.php:395
|
4290 |
msgid "Viewing message %1$s to %2$s (of %3$s message)"
|
4291 |
msgid_plural "Viewing message %1$s to %2$s (of %3$s messages)"
|
4292 |
msgstr[0] ""
|
4293 |
msgstr[1] ""
|
4294 |
|
4295 |
+
#: bp-messages/bp-messages-template.php:471
|
4296 |
msgid "Select:"
|
4297 |
msgstr ""
|
4298 |
|
4299 |
+
#: bp-messages/bp-messages-template.php:475
|
4300 |
+
#: bp-notifications/bp-notifications-loader.php:142
|
4301 |
+
#: bp-notifications/bp-notifications-loader.php:203
|
4302 |
#: bp-notifications/bp-notifications-template.php:733
|
4303 |
msgid "Read"
|
4304 |
msgstr ""
|
4305 |
|
4306 |
+
#: bp-messages/bp-messages-template.php:476
|
4307 |
+
#: bp-notifications/bp-notifications-loader.php:131
|
4308 |
+
#: bp-notifications/bp-notifications-loader.php:180
|
4309 |
#: bp-notifications/bp-notifications-template.php:763
|
4310 |
msgid "Unread"
|
4311 |
msgstr ""
|
4312 |
|
4313 |
+
#: bp-messages/bp-messages-template.php:482
|
4314 |
msgid "Mark as Read"
|
4315 |
msgstr ""
|
4316 |
|
4317 |
+
#: bp-messages/bp-messages-template.php:483
|
4318 |
msgid "Mark as Unread"
|
4319 |
msgstr ""
|
4320 |
|
4321 |
+
#: bp-messages/bp-messages-template.php:487
|
4322 |
msgid "Delete Selected"
|
4323 |
msgstr ""
|
4324 |
|
4325 |
+
#: bp-messages/bp-messages-template.php:532
|
4326 |
msgid "Currently Active"
|
4327 |
msgstr ""
|
4328 |
|
4329 |
+
#: bp-messages/bp-messages-template.php:599
|
4330 |
msgid "Deactivate"
|
4331 |
msgstr ""
|
4332 |
|
4333 |
+
#: bp-messages/bp-messages-template.php:648
|
4334 |
#: bp-templates/bp-legacy/buddypress/members/register.php:168
|
4335 |
#: bp-templates/bp-legacy/buddypress/members/single/profile/edit.php:130
|
4336 |
#: bp-templates/bp-legacy/buddypress-functions.php:233
|
4340 |
msgid "Close"
|
4341 |
msgstr ""
|
4342 |
|
4343 |
+
#: bp-messages/bp-messages-template.php:693
|
4344 |
msgid "Send a private message to this user."
|
4345 |
msgstr ""
|
4346 |
|
4347 |
+
#: bp-messages/bp-messages-template.php:694
|
4348 |
msgid "Private Message"
|
4349 |
msgstr ""
|
4350 |
|
4351 |
+
#: bp-messages/bp-messages-template.php:877
|
4352 |
msgid "%d Recipients"
|
4353 |
msgstr ""
|
4354 |
|
4355 |
+
#: bp-messages/bp-messages-template.php:986
|
4356 |
#: bp-templates/bp-legacy/buddypress-functions.php:1186
|
4357 |
#: bp-themes/bp-default/_inc/ajax.php:833
|
4358 |
msgid "Sent %s"
|
4403 |
msgid "Notifications <span>%d</span>"
|
4404 |
msgstr ""
|
4405 |
|
4406 |
+
#: bp-notifications/bp-notifications-loader.php:176
|
4407 |
msgid "Notifications <span class=\"count\">%s</span>"
|
4408 |
msgstr ""
|
4409 |
|
4410 |
+
#: bp-notifications/bp-notifications-loader.php:177
|
4411 |
msgid "Unread <span class=\"count\">%s</span>"
|
4412 |
msgstr ""
|
4413 |
|
4522 |
msgstr ""
|
4523 |
|
4524 |
#: bp-settings/bp-settings-loader.php:106
|
4525 |
+
#: bp-settings/bp-settings-loader.php:179
|
4526 |
#: bp-themes/bp-default/functions.php:645
|
4527 |
msgid "Email"
|
4528 |
msgstr ""
|
4909 |
|
4910 |
#: bp-templates/bp-legacy/buddypress/forums/index.php:98
|
4911 |
#: bp-themes/bp-default/forums/index.php:116
|
4912 |
+
#: bp-xprofile/bp-xprofile-template.php:471
|
4913 |
msgid "----"
|
4914 |
msgstr ""
|
4915 |
|
6487 |
msgid "Your new avatar was uploaded successfully."
|
6488 |
msgstr ""
|
6489 |
|
6490 |
+
#: bp-xprofile/bp-xprofile-template.php:675
|
6491 |
msgid "January"
|
6492 |
msgstr ""
|
6493 |
|
6494 |
+
#: bp-xprofile/bp-xprofile-template.php:676
|
6495 |
msgid "February"
|
6496 |
msgstr ""
|
6497 |
|
6498 |
+
#: bp-xprofile/bp-xprofile-template.php:677
|
6499 |
msgid "March"
|
6500 |
msgstr ""
|
6501 |
|
6502 |
+
#: bp-xprofile/bp-xprofile-template.php:678
|
6503 |
msgid "April"
|
6504 |
msgstr ""
|
6505 |
|
6506 |
+
#: bp-xprofile/bp-xprofile-template.php:679
|
6507 |
msgid "May"
|
6508 |
msgstr ""
|
6509 |
|
6510 |
+
#: bp-xprofile/bp-xprofile-template.php:680
|
6511 |
msgid "June"
|
6512 |
msgstr ""
|
6513 |
|
6514 |
+
#: bp-xprofile/bp-xprofile-template.php:681
|
6515 |
msgid "July"
|
6516 |
msgstr ""
|
6517 |
|
6518 |
+
#: bp-xprofile/bp-xprofile-template.php:682
|
6519 |
msgid "August"
|
6520 |
msgstr ""
|
6521 |
|
6522 |
+
#: bp-xprofile/bp-xprofile-template.php:683
|
6523 |
msgid "September"
|
6524 |
msgstr ""
|
6525 |
|
6526 |
+
#: bp-xprofile/bp-xprofile-template.php:684
|
6527 |
msgid "October"
|
6528 |
msgstr ""
|
6529 |
|
6530 |
+
#: bp-xprofile/bp-xprofile-template.php:685
|
6531 |
msgid "November"
|
6532 |
msgstr ""
|
6533 |
|
6534 |
+
#: bp-xprofile/bp-xprofile-template.php:686
|
6535 |
msgid "December"
|
6536 |
msgstr ""
|
6537 |
|
6538 |
+
#: bp-xprofile/bp-xprofile-template.php:869
|
6539 |
msgid "Avatar uploads are currently disabled. Why not use a <a href=\"http://gravatar.com\" target=\"_blank\">gravatar</a> instead?"
|
6540 |
msgstr ""
|
6541 |
|
6542 |
+
#: bp-xprofile/bp-xprofile-template.php:877
|
6543 |
msgid "Profile not recently updated"
|
6544 |
msgstr ""
|
6545 |
|
6546 |
+
#: bp-xprofile/bp-xprofile-template.php:887
|
6547 |
msgid "Profile updated %s"
|
6548 |
msgstr ""
|
@@ -16,7 +16,7 @@
|
|
16 |
* Description: Social networking in a box. Build a social network for your company, school, sports team or niche community all based on the power and flexibility of WordPress.
|
17 |
* Author: The BuddyPress Community
|
18 |
* Author URI: http://buddypress.org/community/members/
|
19 |
-
* Version: 1.9-
|
20 |
* Text Domain: buddypress
|
21 |
* Domain Path: /bp-languages/
|
22 |
* License: GPLv2 or later (license.txt)
|
@@ -228,7 +228,7 @@ class BuddyPress {
|
|
228 |
|
229 |
// Path and URL
|
230 |
if ( ! defined( 'BP_PLUGIN_DIR' ) ) {
|
231 |
-
define( 'BP_PLUGIN_DIR', trailingslashit(
|
232 |
}
|
233 |
|
234 |
if ( ! defined( 'BP_PLUGIN_URL' ) ) {
|
@@ -297,7 +297,7 @@ class BuddyPress {
|
|
297 |
|
298 |
/** Versions **********************************************************/
|
299 |
|
300 |
-
$this->version = '1.9-
|
301 |
$this->db_version = 7553;
|
302 |
|
303 |
/** Loading ***********************************************************/
|
16 |
* Description: Social networking in a box. Build a social network for your company, school, sports team or niche community all based on the power and flexibility of WordPress.
|
17 |
* Author: The BuddyPress Community
|
18 |
* Author URI: http://buddypress.org/community/members/
|
19 |
+
* Version: 1.9-beta2
|
20 |
* Text Domain: buddypress
|
21 |
* Domain Path: /bp-languages/
|
22 |
* License: GPLv2 or later (license.txt)
|
228 |
|
229 |
// Path and URL
|
230 |
if ( ! defined( 'BP_PLUGIN_DIR' ) ) {
|
231 |
+
define( 'BP_PLUGIN_DIR', trailingslashit( plugin_dir_path( __FILE__ ) ) );
|
232 |
}
|
233 |
|
234 |
if ( ! defined( 'BP_PLUGIN_URL' ) ) {
|
297 |
|
298 |
/** Versions **********************************************************/
|
299 |
|
300 |
+
$this->version = '1.9-beta2';
|
301 |
$this->db_version = 7553;
|
302 |
|
303 |
/** Loading ***********************************************************/
|
@@ -92,25 +92,25 @@ function bp_members_admin_bar_user_admin_menu() {
|
|
92 |
'href' => bp_displayed_user_domain()
|
93 |
) );
|
94 |
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
// User Admin > Edit this user's avatar
|
104 |
-
$wp_admin_bar->add_menu( array(
|
105 |
-
'parent' => $bp->user_admin_menu_id,
|
106 |
-
'id' => $bp->user_admin_menu_id . '-change-avatar',
|
107 |
-
'title' => __( "Edit Avatar", 'buddypress' ),
|
108 |
-
'href' => bp_get_members_component_link( 'profile', 'change-avatar' )
|
109 |
-
) );
|
110 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
111 |
|
112 |
if ( bp_is_active( 'settings' ) ) {
|
113 |
-
|
114 |
// User Admin > Spam/unspam
|
115 |
$wp_admin_bar->add_menu( array(
|
116 |
'parent' => $bp->user_admin_menu_id,
|
92 |
'href' => bp_displayed_user_domain()
|
93 |
) );
|
94 |
|
95 |
+
if( bp_is_active( 'xprofile' ) ) {
|
96 |
+
// User Admin > Edit this user's profile
|
97 |
+
$wp_admin_bar->add_menu( array(
|
98 |
+
'parent' => $bp->user_admin_menu_id,
|
99 |
+
'id' => $bp->user_admin_menu_id . '-edit-profile',
|
100 |
+
'title' => __( "Edit Profile", 'buddypress' ),
|
101 |
+
'href' => bp_get_members_component_link( 'profile', 'edit' )
|
102 |
+
) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
103 |
|
104 |
+
// User Admin > Edit this user's avatar
|
105 |
+
$wp_admin_bar->add_menu( array(
|
106 |
+
'parent' => $bp->user_admin_menu_id,
|
107 |
+
'id' => $bp->user_admin_menu_id . '-change-avatar',
|
108 |
+
'title' => __( "Edit Avatar", 'buddypress' ),
|
109 |
+
'href' => bp_get_members_component_link( 'profile', 'change-avatar' )
|
110 |
+
) );
|
111 |
+
}
|
112 |
|
113 |
if ( bp_is_active( 'settings' ) ) {
|
|
|
114 |
// User Admin > Spam/unspam
|
115 |
$wp_admin_bar->add_menu( array(
|
116 |
'parent' => $bp->user_admin_menu_id,
|
@@ -16,6 +16,9 @@ if ( !defined( 'ABSPATH' ) ) exit;
|
|
16 |
/**
|
17 |
* Add a notification for a specific user, from a specific component
|
18 |
*
|
|
|
|
|
|
|
19 |
* @since BuddyPress (1.0)
|
20 |
* @param string $item_id
|
21 |
* @param int $user_id
|
@@ -33,6 +36,9 @@ function bp_core_add_notification( $item_id, $user_id, $component_name, $compone
|
|
33 |
return false;
|
34 |
}
|
35 |
|
|
|
|
|
|
|
36 |
// Notifications must always have a time
|
37 |
if ( false === $date_notified ) {
|
38 |
$date_notified = bp_core_current_time();
|
@@ -53,6 +59,9 @@ function bp_core_add_notification( $item_id, $user_id, $component_name, $compone
|
|
53 |
/**
|
54 |
* Delete a specific notification by its ID
|
55 |
*
|
|
|
|
|
|
|
56 |
* @since BuddyPress (1.0)
|
57 |
* @param int $id
|
58 |
* @return boolean True on success, false on fail
|
@@ -64,12 +73,18 @@ function bp_core_delete_notification( $id ) {
|
|
64 |
return false;
|
65 |
}
|
66 |
|
|
|
|
|
|
|
67 |
return BP_Notifications_Notification::delete_by_id( $id );
|
68 |
}
|
69 |
|
70 |
/**
|
71 |
* Get a specific notification by its ID
|
72 |
*
|
|
|
|
|
|
|
73 |
* @since BuddyPress (1.0)
|
74 |
* @param int $id
|
75 |
* @return BP_Core_Notification
|
@@ -81,12 +96,18 @@ function bp_core_get_notification( $id ) {
|
|
81 |
return false;
|
82 |
}
|
83 |
|
|
|
|
|
|
|
84 |
return bp_notifications_get_notification( $id );
|
85 |
}
|
86 |
|
87 |
/**
|
88 |
* Get notifications for a specific user
|
89 |
*
|
|
|
|
|
|
|
90 |
* @since BuddyPress (1.0)
|
91 |
* @global BuddyPress $bp
|
92 |
* @param int $user_id
|
@@ -100,6 +121,9 @@ function bp_core_get_notifications_for_user( $user_id, $format = 'simple' ) {
|
|
100 |
return false;
|
101 |
}
|
102 |
|
|
|
|
|
|
|
103 |
$renderable = bp_notifications_get_notifications_for_user( $user_id, $format );
|
104 |
|
105 |
return apply_filters( 'bp_core_get_notifications_for_user', $renderable, $user_id, $format );
|
@@ -113,6 +137,9 @@ function bp_core_get_notifications_for_user( $user_id, $format = 'simple' ) {
|
|
113 |
* Used when clearing out notifications for a specific component when the user
|
114 |
* has visited that component.
|
115 |
*
|
|
|
|
|
|
|
116 |
* @since BuddyPress (1.0)
|
117 |
* @param int $user_id
|
118 |
* @param string $component_name
|
@@ -126,6 +153,9 @@ function bp_core_delete_notifications_by_type( $user_id, $component_name, $compo
|
|
126 |
return false;
|
127 |
}
|
128 |
|
|
|
|
|
|
|
129 |
return bp_notifications_delete_notifications_by_type( $user_id, $component_name, $component_action );
|
130 |
}
|
131 |
|
@@ -135,6 +165,9 @@ function bp_core_delete_notifications_by_type( $user_id, $component_name, $compo
|
|
135 |
* Used when clearing out notifications for a specific component when the user
|
136 |
* has visited that component.
|
137 |
*
|
|
|
|
|
|
|
138 |
* @since BuddyPress (1.0)
|
139 |
* @param int $user_id
|
140 |
* @param string $component_name
|
@@ -148,12 +181,18 @@ function bp_core_delete_notifications_by_item_id( $user_id, $item_id, $component
|
|
148 |
return false;
|
149 |
}
|
150 |
|
|
|
|
|
|
|
151 |
return bp_notifications_delete_notifications_by_item_id( $user_id, $item_id, $component_name, $component_action, $secondary_item_id );
|
152 |
}
|
153 |
|
154 |
/**
|
155 |
* Delete all notifications for by type
|
156 |
*
|
|
|
|
|
|
|
157 |
* @since BuddyPress (1.0)
|
158 |
* @param int $user_id
|
159 |
* @param string $component_name
|
@@ -167,6 +206,9 @@ function bp_core_delete_all_notifications_by_type( $item_id, $component_name, $c
|
|
167 |
return false;
|
168 |
}
|
169 |
|
|
|
|
|
|
|
170 |
bp_notifications_delete_all_notifications_by_type( $item_id, $component_name, $component_action, $secondary_item_id );
|
171 |
}
|
172 |
|
@@ -175,6 +217,9 @@ function bp_core_delete_all_notifications_by_type( $item_id, $component_name, $c
|
|
175 |
*
|
176 |
* Used when clearing out all notifications for a user, whene deleted or spammed
|
177 |
*
|
|
|
|
|
|
|
178 |
* @since BuddyPress (1.0)
|
179 |
* @param int $user_id
|
180 |
* @param string $component_name
|
@@ -188,95 +233,10 @@ function bp_core_delete_notifications_from_user( $user_id, $component_name, $com
|
|
188 |
return false;
|
189 |
}
|
190 |
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
/** Mark **********************************************************************/
|
195 |
-
|
196 |
-
/**
|
197 |
-
* Delete notifications for a user by type
|
198 |
-
*
|
199 |
-
* Used when clearing out notifications for a specific component when the user
|
200 |
-
* has visited that component.
|
201 |
-
*
|
202 |
-
* @since BuddyPress (1.9.0)
|
203 |
-
* @param int $user_id
|
204 |
-
* @param string $component_name
|
205 |
-
* @param string $component_action
|
206 |
-
* @param int $is_new
|
207 |
-
* @return boolean True on success, false on fail
|
208 |
-
*/
|
209 |
-
function bp_core_mark_notifications_by_type( $user_id, $component_name, $component_action, $is_new = false ) {
|
210 |
-
|
211 |
-
// Bail if notifications is not active
|
212 |
-
if ( ! bp_is_active( 'notifications' ) ) {
|
213 |
-
return false;
|
214 |
-
}
|
215 |
-
|
216 |
-
return bp_notifications_mark_notifications_by_type( $user_id, $component_name, $component_action, $is_new );
|
217 |
-
}
|
218 |
-
|
219 |
-
/**
|
220 |
-
* Delete notifications for an item ID
|
221 |
-
*
|
222 |
-
* Used when clearing out notifications for a specific component when the user
|
223 |
-
* has visited that component.
|
224 |
-
*
|
225 |
-
* @since BuddyPress (1.9.0)
|
226 |
-
* @param int $user_id
|
227 |
-
* @param string $component_name
|
228 |
-
* @param string $component_action
|
229 |
-
* @param int $is_new
|
230 |
-
* @return boolean True on success, false on fail
|
231 |
-
*/
|
232 |
-
function bp_core_mark_notifications_by_item_id( $user_id, $item_id, $component_name, $component_action, $secondary_item_id = false, $is_new = false ) {
|
233 |
-
|
234 |
-
// Bail if notifications is not active
|
235 |
-
if ( ! bp_is_active( 'notifications' ) ) {
|
236 |
-
return false;
|
237 |
-
}
|
238 |
-
|
239 |
-
return bp_notifications_mark_notifications_by_item_id( $user_id, $item_id, $component_name, $component_action, $secondary_item_id, $is_new );
|
240 |
-
}
|
241 |
|
242 |
-
|
243 |
-
* Mark all notifications read/unread for by type
|
244 |
-
*
|
245 |
-
* Used when clearing out notifications for an entire component
|
246 |
-
*
|
247 |
-
* @since BuddyPress (1.9.0)
|
248 |
-
* @param int $user_id
|
249 |
-
* @param string $component_name
|
250 |
-
* @param string $component_action
|
251 |
-
* @return boolean True on success, false on fail
|
252 |
-
*/
|
253 |
-
function bp_core_mark_all_notifications_by_type( $item_id, $component_name, $component_action = false, $secondary_item_id = false, $is_new = false ) {
|
254 |
-
|
255 |
-
// Bail if notifications is not active
|
256 |
-
if ( ! bp_is_active( 'notifications' ) ) {
|
257 |
-
return false;
|
258 |
-
}
|
259 |
-
|
260 |
-
bp_notifications_mark_all_notifications_by_type( $item_id, $component_name, $component_action, $secondary_item_id, $is_new );
|
261 |
-
}
|
262 |
-
|
263 |
-
/**
|
264 |
-
* Mark all notifications read/unread from a user
|
265 |
-
*
|
266 |
-
* @since BuddyPress (1.9.0)
|
267 |
-
* @param int $user_id
|
268 |
-
* @param string $component_name
|
269 |
-
* @param string $component_action
|
270 |
-
* @return boolean True on success, false on fail
|
271 |
-
*/
|
272 |
-
function bp_core_mark_notifications_from_user( $user_id, $component_name, $component_action, $is_new = false ) {
|
273 |
-
|
274 |
-
// Bail if notifications is not active
|
275 |
-
if ( ! bp_is_active( 'notifications' ) ) {
|
276 |
-
return false;
|
277 |
-
}
|
278 |
-
|
279 |
-
return bp_notifications_mark_notifications_from_user( $user_id, $component_name, $component_action, $is_new );
|
280 |
}
|
281 |
|
282 |
/** Helpers *******************************************************************/
|
@@ -286,6 +246,9 @@ function bp_core_mark_notifications_from_user( $user_id, $component_name, $compo
|
|
286 |
*
|
287 |
* Used before deleting a notification for a user
|
288 |
*
|
|
|
|
|
|
|
289 |
* @since BuddyPress (1.0)
|
290 |
* @param int $user_id
|
291 |
* @param int $notification_id
|
@@ -298,5 +261,8 @@ function bp_core_check_notification_access( $user_id, $notification_id ) {
|
|
298 |
return false;
|
299 |
}
|
300 |
|
|
|
|
|
|
|
301 |
return bp_notifications_check_notification_access( $user_id, $notification_id );
|
302 |
}
|
16 |
/**
|
17 |
* Add a notification for a specific user, from a specific component
|
18 |
*
|
19 |
+
* @deprecated Deprecated since BuddyPress 1.9.0. Use
|
20 |
+
* bp_notifications_add_notification() instead.
|
21 |
+
*
|
22 |
* @since BuddyPress (1.0)
|
23 |
* @param string $item_id
|
24 |
* @param int $user_id
|
36 |
return false;
|
37 |
}
|
38 |
|
39 |
+
// Trigger the deprecated function notice
|
40 |
+
_deprecated_function( __FUNCTION__, '1.9', 'bp_notifications_add_notification()' );
|
41 |
+
|
42 |
// Notifications must always have a time
|
43 |
if ( false === $date_notified ) {
|
44 |
$date_notified = bp_core_current_time();
|
59 |
/**
|
60 |
* Delete a specific notification by its ID
|
61 |
*
|
62 |
+
* @deprecated Deprecated since BuddyPress 1.9.0. Use
|
63 |
+
* bp_notifications_delete_notification() instead.
|
64 |
+
*
|
65 |
* @since BuddyPress (1.0)
|
66 |
* @param int $id
|
67 |
* @return boolean True on success, false on fail
|
73 |
return false;
|
74 |
}
|
75 |
|
76 |
+
// Trigger the deprecated function notice
|
77 |
+
_deprecated_function( __FUNCTION__, '1.9', 'bp_notifications_delete_notification()' );
|
78 |
+
|
79 |
return BP_Notifications_Notification::delete_by_id( $id );
|
80 |
}
|
81 |
|
82 |
/**
|
83 |
* Get a specific notification by its ID
|
84 |
*
|
85 |
+
* @deprecated Deprecated since BuddyPress 1.9.0. Use
|
86 |
+
* bp_notifications_get_notification() instead.
|
87 |
+
*
|
88 |
* @since BuddyPress (1.0)
|
89 |
* @param int $id
|
90 |
* @return BP_Core_Notification
|
96 |
return false;
|
97 |
}
|
98 |
|
99 |
+
// Trigger the deprecated function notice
|
100 |
+
_deprecated_function( __FUNCTION__, '1.9', 'bp_notifications_get_notification()' );
|
101 |
+
|
102 |
return bp_notifications_get_notification( $id );
|
103 |
}
|
104 |
|
105 |
/**
|
106 |
* Get notifications for a specific user
|
107 |
*
|
108 |
+
* @deprecated Deprecated since BuddyPress 1.9.0. Use
|
109 |
+
* bp_notifications_get_notifications_for_user() instead.
|
110 |
+
*
|
111 |
* @since BuddyPress (1.0)
|
112 |
* @global BuddyPress $bp
|
113 |
* @param int $user_id
|
121 |
return false;
|
122 |
}
|
123 |
|
124 |
+
// Trigger the deprecated function notice
|
125 |
+
_deprecated_function( __FUNCTION__, '1.9', 'bp_notifications_get_notifications_for_user()' );
|
126 |
+
|
127 |
$renderable = bp_notifications_get_notifications_for_user( $user_id, $format );
|
128 |
|
129 |
return apply_filters( 'bp_core_get_notifications_for_user', $renderable, $user_id, $format );
|
137 |
* Used when clearing out notifications for a specific component when the user
|
138 |
* has visited that component.
|
139 |
*
|
140 |
+
* @deprecated Deprecated since BuddyPress 1.9.0. Use
|
141 |
+
* bp_notifications_delete_notifications_by_type() instead.
|
142 |
+
*
|
143 |
* @since BuddyPress (1.0)
|
144 |
* @param int $user_id
|
145 |
* @param string $component_name
|
153 |
return false;
|
154 |
}
|
155 |
|
156 |
+
// Trigger the deprecated function notice
|
157 |
+
_deprecated_function( __FUNCTION__, '1.9', 'bp_notifications_delete_notifications_by_type()' );
|
158 |
+
|
159 |
return bp_notifications_delete_notifications_by_type( $user_id, $component_name, $component_action );
|
160 |
}
|
161 |
|
165 |
* Used when clearing out notifications for a specific component when the user
|
166 |
* has visited that component.
|
167 |
*
|
168 |
+
* @deprecated Deprecated since BuddyPress 1.9.0. Use
|
169 |
+
* bp_notifications_delete_notifications_by_item_id() instead.
|
170 |
+
*
|
171 |
* @since BuddyPress (1.0)
|
172 |
* @param int $user_id
|
173 |
* @param string $component_name
|
181 |
return false;
|
182 |
}
|
183 |
|
184 |
+
// Trigger the deprecated function notice
|
185 |
+
_deprecated_function( __FUNCTION__, '1.9', 'bp_notifications_delete_notifications_by_item_id()' );
|
186 |
+
|
187 |
return bp_notifications_delete_notifications_by_item_id( $user_id, $item_id, $component_name, $component_action, $secondary_item_id );
|
188 |
}
|
189 |
|
190 |
/**
|
191 |
* Delete all notifications for by type
|
192 |
*
|
193 |
+
* @deprecated Deprecated since BuddyPress 1.9.0. Use
|
194 |
+
* bp_notifications_delete_all_notifications_by_type() instead.
|
195 |
+
*
|
196 |
* @since BuddyPress (1.0)
|
197 |
* @param int $user_id
|
198 |
* @param string $component_name
|
206 |
return false;
|
207 |
}
|
208 |
|
209 |
+
// Trigger the deprecated function notice
|
210 |
+
_deprecated_function( __FUNCTION__, '1.9', 'bp_notifications_delete_all_notifications_by_type()' );
|
211 |
+
|
212 |
bp_notifications_delete_all_notifications_by_type( $item_id, $component_name, $component_action, $secondary_item_id );
|
213 |
}
|
214 |
|
217 |
*
|
218 |
* Used when clearing out all notifications for a user, whene deleted or spammed
|
219 |
*
|
220 |
+
* @deprecated Deprecated since BuddyPress 1.9.0. Use
|
221 |
+
* bp_notifications_delete_notifications_from_user() instead.
|
222 |
+
*
|
223 |
* @since BuddyPress (1.0)
|
224 |
* @param int $user_id
|
225 |
* @param string $component_name
|
233 |
return false;
|
234 |
}
|
235 |
|
236 |
+
// Trigger the deprecated function notice
|
237 |
+
_deprecated_function( __FUNCTION__, '1.9', 'bp_notifications_delete_notifications_from_user()' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
238 |
|
239 |
+
return bp_notifications_delete_notifications_from_user( $user_id, $component_name, $component_action );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
240 |
}
|
241 |
|
242 |
/** Helpers *******************************************************************/
|
246 |
*
|
247 |
* Used before deleting a notification for a user
|
248 |
*
|
249 |
+
* @deprecated Deprecated since BuddyPress 1.9.0. Use
|
250 |
+
* bp_notifications_check_notification_access() instead.
|
251 |
+
*
|
252 |
* @since BuddyPress (1.0)
|
253 |
* @param int $user_id
|
254 |
* @param int $notification_id
|
261 |
return false;
|
262 |
}
|
263 |
|
264 |
+
// Trigger the deprecated function notice
|
265 |
+
_deprecated_function( __FUNCTION__, '1.9', 'bp_notifications_check_notification_access()' );
|
266 |
+
|
267 |
return bp_notifications_check_notification_access( $user_id, $notification_id );
|
268 |
}
|
@@ -114,15 +114,6 @@ function messages_new_message( $args = '' ) {
|
|
114 |
}
|
115 |
|
116 |
if ( $message->send() ) {
|
117 |
-
|
118 |
-
// Send screen notifications to the recipients
|
119 |
-
foreach ( (array) $message->recipients as $recipient ) {
|
120 |
-
bp_core_add_notification( $message->id, $recipient->user_id, 'messages', 'new_message', $message->sender_id );
|
121 |
-
}
|
122 |
-
|
123 |
-
// Send email notifications to the recipients
|
124 |
-
messages_notification_new_message( array( 'message_id' => $message->id, 'sender_id' => $message->sender_id, 'subject' => $message->subject, 'content' => $message->message, 'recipients' => $message->recipients, 'thread_id' => $message->thread_id) );
|
125 |
-
|
126 |
do_action_ref_array( 'messages_message_sent', array( &$message ) );
|
127 |
|
128 |
return $message->thread_id;
|
@@ -223,47 +214,3 @@ function messages_get_message_sender( $message_id ) {
|
|
223 |
function messages_is_valid_thread( $thread_id ) {
|
224 |
return BP_Messages_Thread::is_valid( $thread_id );
|
225 |
}
|
226 |
-
|
227 |
-
/**
|
228 |
-
* Format the BuddyBar/Toolbar notifications for the Messages component
|
229 |
-
*
|
230 |
-
* @package BuddyPress
|
231 |
-
*
|
232 |
-
* @param string $action The kind of notification being rendered
|
233 |
-
* @param int $item_id The primary item id
|
234 |
-
* @param int $secondary_item_id The secondary item id
|
235 |
-
* @param int $total_items The total number of messaging-related notifications waiting for the user
|
236 |
-
* @param string $format 'string' for BuddyBar-compatible notifications; 'array' for WP Toolbar
|
237 |
-
*/
|
238 |
-
function messages_format_notifications( $action, $item_id, $secondary_item_id, $total_items, $format = 'string' ) {
|
239 |
-
|
240 |
-
if ( 'new_message' == $action ) {
|
241 |
-
$link = trailingslashit( bp_loggedin_user_domain() . bp_get_messages_slug() . '/inbox' );
|
242 |
-
$title = __( 'Inbox', 'buddypress' );
|
243 |
-
|
244 |
-
if ( (int) $total_items > 1 ) {
|
245 |
-
$text = sprintf( __('You have %d new messages', 'buddypress' ), (int) $total_items );
|
246 |
-
$filter = 'bp_messages_multiple_new_message_notification';
|
247 |
-
} else {
|
248 |
-
if ( !empty( $secondary_item_id ) ) {
|
249 |
-
$text = sprintf( __('You have %d new message from %s', 'buddypress' ), (int) $total_items, bp_core_get_user_displayname( $secondary_item_id ) );
|
250 |
-
} else {
|
251 |
-
$text = sprintf( __('You have %d new message', 'buddypress' ), (int) $total_items );
|
252 |
-
}
|
253 |
-
$filter = 'bp_messages_single_new_message_notification';
|
254 |
-
}
|
255 |
-
}
|
256 |
-
|
257 |
-
if ( 'string' == $format ) {
|
258 |
-
$return = apply_filters( $filter, '<a href="' . $link . '" title="' . $title . '">' . $text . '</a>', (int) $total_items, $text, $link );
|
259 |
-
} else {
|
260 |
-
$return = apply_filters( $filter, array(
|
261 |
-
'text' => $text,
|
262 |
-
'link' => $link
|
263 |
-
), $link, (int) $total_items, $text, $link );
|
264 |
-
}
|
265 |
-
|
266 |
-
do_action( 'messages_format_notifications', $action, $item_id, $secondary_item_id, $total_items );
|
267 |
-
|
268 |
-
return $return;
|
269 |
-
}
|
114 |
}
|
115 |
|
116 |
if ( $message->send() ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
117 |
do_action_ref_array( 'messages_message_sent', array( &$message ) );
|
118 |
|
119 |
return $message->thread_id;
|
214 |
function messages_is_valid_thread( $thread_id ) {
|
215 |
return BP_Messages_Thread::is_valid( $thread_id );
|
216 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -7,34 +7,51 @@
|
|
7 |
* @subpackage MessagesNotifications
|
8 |
*/
|
9 |
|
10 |
-
|
11 |
// Exit if accessed directly
|
12 |
if ( !defined( 'ABSPATH' ) ) exit;
|
13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
function messages_notification_new_message( $args = array() ) {
|
15 |
|
|
|
|
|
|
|
|
|
|
|
16 |
// These should be extracted below
|
17 |
$recipients = array();
|
18 |
$email_subject = $email_content = '';
|
|
|
19 |
|
|
|
20 |
extract( $args );
|
21 |
|
|
|
22 |
$sender_name = bp_core_get_user_displayname( $sender_id );
|
23 |
|
24 |
// Bail if no recipients
|
25 |
if ( ! empty( $recipients ) ) {
|
26 |
|
27 |
-
foreach( $recipients as $recipient ) {
|
28 |
|
29 |
-
if ( $sender_id == $recipient->user_id || 'no' == bp_get_user_meta( $recipient->user_id, 'notification_messages_new_message', true ) )
|
30 |
continue;
|
|
|
31 |
|
32 |
// User data and links
|
33 |
-
$ud
|
34 |
|
35 |
// Bail if user cannot be found
|
36 |
-
if ( empty( $ud ) )
|
37 |
continue;
|
|
|
38 |
|
39 |
$message_link = bp_core_get_user_domain( $recipient->user_id ) . bp_get_messages_slug() .'/';
|
40 |
$settings_slug = function_exists( 'bp_get_settings_slug' ) ? bp_get_settings_slug() : 'settings';
|
@@ -77,3 +94,96 @@ To view and read your messages please log in and visit: %4$s
|
|
77 |
|
78 |
do_action( 'bp_messages_sent_notification_email', $recipients, $email_subject, $email_content, $args );
|
79 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
* @subpackage MessagesNotifications
|
8 |
*/
|
9 |
|
|
|
10 |
// Exit if accessed directly
|
11 |
if ( !defined( 'ABSPATH' ) ) exit;
|
12 |
|
13 |
+
/** Email *********************************************************************/
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Email message recipients to alert them of a new unread private message
|
17 |
+
*
|
18 |
+
* @since BuddyPress (1.0)
|
19 |
+
* @param array $args
|
20 |
+
*/
|
21 |
function messages_notification_new_message( $args = array() ) {
|
22 |
|
23 |
+
// Cast possible $message object as an array
|
24 |
+
if ( is_object( $args ) ) {
|
25 |
+
$args = (array) $args;
|
26 |
+
}
|
27 |
+
|
28 |
// These should be extracted below
|
29 |
$recipients = array();
|
30 |
$email_subject = $email_content = '';
|
31 |
+
$sender_id = 0;
|
32 |
|
33 |
+
// Barf
|
34 |
extract( $args );
|
35 |
|
36 |
+
// Get the sender display name
|
37 |
$sender_name = bp_core_get_user_displayname( $sender_id );
|
38 |
|
39 |
// Bail if no recipients
|
40 |
if ( ! empty( $recipients ) ) {
|
41 |
|
42 |
+
foreach ( $recipients as $recipient ) {
|
43 |
|
44 |
+
if ( $sender_id == $recipient->user_id || 'no' == bp_get_user_meta( $recipient->user_id, 'notification_messages_new_message', true ) ) {
|
45 |
continue;
|
46 |
+
}
|
47 |
|
48 |
// User data and links
|
49 |
+
$ud = get_userdata( $recipient->user_id );
|
50 |
|
51 |
// Bail if user cannot be found
|
52 |
+
if ( empty( $ud ) ) {
|
53 |
continue;
|
54 |
+
}
|
55 |
|
56 |
$message_link = bp_core_get_user_domain( $recipient->user_id ) . bp_get_messages_slug() .'/';
|
57 |
$settings_slug = function_exists( 'bp_get_settings_slug' ) ? bp_get_settings_slug() : 'settings';
|
94 |
|
95 |
do_action( 'bp_messages_sent_notification_email', $recipients, $email_subject, $email_content, $args );
|
96 |
}
|
97 |
+
add_action( 'messages_message_sent', 'messages_notification_new_message', 10 );
|
98 |
+
|
99 |
+
/** Notifications *************************************************************/
|
100 |
+
|
101 |
+
/**
|
102 |
+
* Format the BuddyBar/Toolbar notifications for the Messages component
|
103 |
+
*
|
104 |
+
* @since BuddyPress (1.0)
|
105 |
+
* @param string $action The kind of notification being rendered
|
106 |
+
* @param int $item_id The primary item id
|
107 |
+
* @param int $secondary_item_id The secondary item id
|
108 |
+
* @param int $total_items The total number of messaging-related notifications waiting for the user
|
109 |
+
* @param string $format 'string' for BuddyBar-compatible notifications; 'array' for WP Toolbar
|
110 |
+
*/
|
111 |
+
function messages_format_notifications( $action, $item_id, $secondary_item_id, $total_items, $format = 'string' ) {
|
112 |
+
|
113 |
+
if ( 'new_message' === $action ) {
|
114 |
+
$link = trailingslashit( bp_loggedin_user_domain() . bp_get_messages_slug() . '/inbox' );
|
115 |
+
$title = __( 'Inbox', 'buddypress' );
|
116 |
+
|
117 |
+
if ( (int) $total_items > 1 ) {
|
118 |
+
$text = sprintf( __('You have %d new messages', 'buddypress' ), (int) $total_items );
|
119 |
+
$filter = 'bp_messages_multiple_new_message_notification';
|
120 |
+
} else {
|
121 |
+
if ( !empty( $secondary_item_id ) ) {
|
122 |
+
$text = sprintf( __('You have %d new message from %s', 'buddypress' ), (int) $total_items, bp_core_get_user_displayname( $secondary_item_id ) );
|
123 |
+
} else {
|
124 |
+
$text = sprintf( __('You have %d new message', 'buddypress' ), (int) $total_items );
|
125 |
+
}
|
126 |
+
$filter = 'bp_messages_single_new_message_notification';
|
127 |
+
}
|
128 |
+
}
|
129 |
+
|
130 |
+
if ( 'string' === $format ) {
|
131 |
+
$return = apply_filters( $filter, '<a href="' . esc_url( $link ) . '" title="' . esc_attr( $title ) . '">' . esc_html( $text ) . '</a>', (int) $total_items, $text, $link, $item_id, $secondary_item_id );
|
132 |
+
} else {
|
133 |
+
$return = apply_filters( $filter, array(
|
134 |
+
'text' => $text,
|
135 |
+
'link' => $link
|
136 |
+
), $link, (int) $total_items, $text, $link, $item_id, $secondary_item_id );
|
137 |
+
}
|
138 |
+
|
139 |
+
do_action( 'messages_format_notifications', $action, $item_id, $secondary_item_id, $total_items );
|
140 |
+
|
141 |
+
return $return;
|
142 |
+
}
|
143 |
+
|
144 |
+
/**
|
145 |
+
* Send notifications to message recipients
|
146 |
+
*
|
147 |
+
* @since BuddyPress (1.9.0)
|
148 |
+
* @param obj $message
|
149 |
+
*/
|
150 |
+
function bp_messages_message_sent_add_notification( $message ) {
|
151 |
+
if ( bp_is_active( 'notifications' ) && ! empty( $message->recipients ) ) {
|
152 |
+
foreach ( (array) $message->recipients as $recipient ) {
|
153 |
+
bp_notifications_add_notification( array(
|
154 |
+
'user_id' => $recipient->user_id,
|
155 |
+
'item_id' => $message->id,
|
156 |
+
'secondary_item_id' => $message->sender_id,
|
157 |
+
'component_name' => buddypress()->messages->id,
|
158 |
+
'component_action' => 'new_message',
|
159 |
+
'date_notified' => bp_core_current_time(),
|
160 |
+
'is_new' => 1,
|
161 |
+
) );
|
162 |
+
}
|
163 |
+
}
|
164 |
+
}
|
165 |
+
add_action( 'messages_message_sent', 'bp_messages_message_sent_add_notification', 10 );
|
166 |
+
|
167 |
+
/**
|
168 |
+
* Mark new message notifications when member views their inbox.
|
169 |
+
*
|
170 |
+
* @since BuddyPress (1.9.0)
|
171 |
+
*/
|
172 |
+
function bp_messages_screen_inbox_mark_notifications() {
|
173 |
+
if ( bp_is_active( 'notifications' ) ) {
|
174 |
+
bp_notifications_mark_notifications_by_type( bp_loggedin_user_id(), buddypress()->messages->id, 'new_message' );
|
175 |
+
}
|
176 |
+
}
|
177 |
+
add_action( 'messages_screen_inbox', 'bp_messages_screen_inbox_mark_notifications', 10 );
|
178 |
+
|
179 |
+
/**
|
180 |
+
* Mark new message notification when member reads a message thread directly.
|
181 |
+
*
|
182 |
+
* @since BuddyPress (1.9.0)
|
183 |
+
*/
|
184 |
+
function bp_messages_screen_conversation_mark_notifications() {
|
185 |
+
if ( bp_is_active( 'notifications' ) ) {
|
186 |
+
bp_notifications_mark_notifications_by_item_id( bp_loggedin_user_id(), (int) bp_action_variable( 0 ), buddypress()->messages->id, 'new_message' );
|
187 |
+
}
|
188 |
+
}
|
189 |
+
add_action( 'messages_screen_conversation', 'bp_messages_screen_inbox_mark_notifications', 10 );
|
@@ -184,10 +184,6 @@ function bp_has_message_threads( $args = '' ) {
|
|
184 |
if ( bp_is_current_action( 'notices' ) && !bp_current_user_can( 'bp_moderate' ) ) {
|
185 |
wp_redirect( bp_displayed_user_id() );
|
186 |
} else {
|
187 |
-
if ( bp_is_current_action( 'inbox' ) ) {
|
188 |
-
bp_core_mark_notifications_by_type( bp_loggedin_user_id(), $bp->messages->id, 'new_message' );
|
189 |
-
}
|
190 |
-
|
191 |
if ( bp_is_current_action( 'sentbox' ) ) {
|
192 |
$box = 'sentbox';
|
193 |
}
|
184 |
if ( bp_is_current_action( 'notices' ) && !bp_current_user_can( 'bp_moderate' ) ) {
|
185 |
wp_redirect( bp_displayed_user_id() );
|
186 |
} else {
|
|
|
|
|
|
|
|
|
187 |
if ( bp_is_current_action( 'sentbox' ) ) {
|
188 |
$box = 'sentbox';
|
189 |
}
|
@@ -24,10 +24,10 @@ function bp_notifications_toolbar_menu() {
|
|
24 |
return false;
|
25 |
}
|
26 |
|
27 |
-
$notifications =
|
28 |
$count = ! empty( $notifications ) ? count( $notifications ) : 0;
|
29 |
$alert_class = (int) $count > 0 ? 'pending-count alert' : 'count no-alert';
|
30 |
-
$menu_title = '<span id="ab-pending-notifications" class="' . $alert_class . '">' . $count . '</span>';
|
31 |
$menu_link = trailingslashit( bp_loggedin_user_domain() . bp_get_notifications_slug() );
|
32 |
|
33 |
// Add the top-level Notifications button
|
24 |
return false;
|
25 |
}
|
26 |
|
27 |
+
$notifications = bp_notifications_get_notifications_for_user( bp_loggedin_user_id(), 'object' );
|
28 |
$count = ! empty( $notifications ) ? count( $notifications ) : 0;
|
29 |
$alert_class = (int) $count > 0 ? 'pending-count alert' : 'count no-alert';
|
30 |
+
$menu_title = '<span id="ab-pending-notifications" class="' . $alert_class . '">' . number_format_i18n( $count ) . '</span>';
|
31 |
$menu_link = trailingslashit( bp_loggedin_user_domain() . bp_get_notifications_slug() );
|
32 |
|
33 |
// Add the top-level Notifications button
|
@@ -24,11 +24,11 @@ function bp_notifications_buddybar_menu() {
|
|
24 |
return false;
|
25 |
}
|
26 |
|
27 |
-
echo '<li id="bp-adminbar-notifications-menu"><a href="' . bp_loggedin_user_domain() . '">';
|
28 |
_e( 'Notifications', 'buddypress' );
|
29 |
|
30 |
-
if ( $notifications =
|
31 |
-
<span><?php echo
|
32 |
<?php
|
33 |
endif;
|
34 |
|
@@ -46,7 +46,7 @@ function bp_notifications_buddybar_menu() {
|
|
46 |
}
|
47 |
} else { ?>
|
48 |
|
49 |
-
<li><a href="<?php echo bp_loggedin_user_domain() ?>"><?php _e( 'No new notifications.', 'buddypress' ); ?></a></li>
|
50 |
|
51 |
<?php
|
52 |
}
|
24 |
return false;
|
25 |
}
|
26 |
|
27 |
+
echo '<li id="bp-adminbar-notifications-menu"><a href="' . esc_url( bp_loggedin_user_domain() ) . '">';
|
28 |
_e( 'Notifications', 'buddypress' );
|
29 |
|
30 |
+
if ( $notifications = bp_notifications_get_notifications_for_user( bp_loggedin_user_id() ) ) : ?>
|
31 |
+
<span><?php echo number_format_i18n( $notifications ); ?></span>
|
32 |
<?php
|
33 |
endif;
|
34 |
|
46 |
}
|
47 |
} else { ?>
|
48 |
|
49 |
+
<li><a href="<?php echo esc_url( bp_loggedin_user_domain() ); ?>"><?php _e( 'No new notifications.', 'buddypress' ); ?></a></li>
|
50 |
|
51 |
<?php
|
52 |
}
|
@@ -453,7 +453,7 @@ function bp_notifications_mark_all_notifications_by_type( $item_id, $component_n
|
|
453 |
* @return bool True on success, false on failure.
|
454 |
*/
|
455 |
function bp_notifications_mark_notifications_from_user( $user_id, $component_name, $component_action, $is_new = false ) {
|
456 |
-
return BP_Notifications_Notification::
|
457 |
array(
|
458 |
'is_new' => $is_new
|
459 |
),
|
453 |
* @return bool True on success, false on failure.
|
454 |
*/
|
455 |
function bp_notifications_mark_notifications_from_user( $user_id, $component_name, $component_action, $is_new = false ) {
|
456 |
+
return BP_Notifications_Notification::update(
|
457 |
array(
|
458 |
'is_new' => $is_new
|
459 |
),
|
@@ -106,12 +106,13 @@ class BP_Notifications_Component extends BP_Component {
|
|
106 |
// Add 'Notifications' to the main navigation
|
107 |
$count = bp_notifications_get_unread_notification_count( bp_loggedin_user_id() );
|
108 |
$main_nav = array(
|
109 |
-
'name'
|
110 |
-
'slug'
|
111 |
-
'position'
|
112 |
-
'
|
113 |
-
'
|
114 |
-
'
|
|
|
115 |
);
|
116 |
|
117 |
// Determine user to use
|
106 |
// Add 'Notifications' to the main navigation
|
107 |
$count = bp_notifications_get_unread_notification_count( bp_loggedin_user_id() );
|
108 |
$main_nav = array(
|
109 |
+
'name' => sprintf( __( 'Notifications <span>%d</span>', 'buddypress' ), number_format_i18n( $count ) ),
|
110 |
+
'slug' => $this->slug,
|
111 |
+
'position' => 30,
|
112 |
+
'show_for_displayed_user' => bp_core_can_edit_settings(),
|
113 |
+
'screen_function' => 'bp_notifications_screen_unread',
|
114 |
+
'default_subnav_slug' => 'unread',
|
115 |
+
'item_css_id' => $this->id,
|
116 |
);
|
117 |
|
118 |
// Determine user to use
|
@@ -823,7 +823,7 @@ function bp_the_notification_delete_link() {
|
|
823 |
// Start the output buffer
|
824 |
ob_start(); ?>
|
825 |
|
826 |
-
<a href="<?php echo esc_url( $url ); ?>" class="delete secondary"><?php _e( 'Delete', 'buddypress' ); ?></a>
|
827 |
|
828 |
<?php $retval = ob_get_clean();
|
829 |
|
823 |
// Start the output buffer
|
824 |
ob_start(); ?>
|
825 |
|
826 |
+
<a href="<?php echo esc_url( $url ); ?>" class="delete secondary confirm"><?php _e( 'Delete', 'buddypress' ); ?></a>
|
827 |
|
828 |
<?php $retval = ob_get_clean();
|
829 |
|
@@ -176,7 +176,7 @@ class BP_Settings_Component extends BP_Component {
|
|
176 |
$wp_admin_nav[] = array(
|
177 |
'parent' => 'my-account-' . $this->id,
|
178 |
'id' => 'my-account-' . $this->id . '-notifications',
|
179 |
-
'title' => __( '
|
180 |
'href' => trailingslashit( $settings_link . 'notifications' )
|
181 |
);
|
182 |
|
176 |
$wp_admin_nav[] = array(
|
177 |
'parent' => 'my-account-' . $this->id,
|
178 |
'id' => 'my-account-' . $this->id . '-notifications',
|
179 |
+
'title' => __( 'Email', 'buddypress' ),
|
180 |
'href' => trailingslashit( $settings_link . 'notifications' )
|
181 |
);
|
182 |
|
@@ -765,6 +765,14 @@ a.bp-title-button {
|
|
765 |
clear:none;
|
766 |
}
|
767 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
768 |
/*--------------------------------------------------------------
|
769 |
3.6 - Ajax Loading
|
770 |
--------------------------------------------------------------*/
|
@@ -879,10 +887,20 @@ a.bp-title-button {
|
|
879 |
margin: 20px 0 0 0;
|
880 |
padding: 1px 0 0 0;
|
881 |
}
|
882 |
-
#buddypress table
|
|
|
|
|
|
|
|
|
|
|
883 |
width: 100%;
|
884 |
}
|
885 |
-
#buddypress table thead tr
|
|
|
|
|
|
|
|
|
|
|
886 |
background: #eaeaea;
|
887 |
}
|
888 |
#buddypress table#message-threads {
|
@@ -902,12 +920,27 @@ a.bp-title-button {
|
|
902 |
#buddypress table.profile-fields p:last-child {
|
903 |
margin-top: 0;
|
904 |
}
|
905 |
-
#buddypress table tr td,
|
906 |
-
#buddypress table tr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
907 |
padding: 8px;
|
908 |
vertical-align: middle;
|
909 |
}
|
910 |
-
#buddypress table tr td.label
|
|
|
|
|
|
|
|
|
|
|
911 |
border-right: 1px solid #eaeaea;
|
912 |
font-weight: bold;
|
913 |
width: 25%;
|
@@ -923,7 +956,12 @@ a.bp-title-button {
|
|
923 |
#buddypress table.forum td {
|
924 |
text-align: center;
|
925 |
}
|
926 |
-
#buddypress table tr.alt td
|
|
|
|
|
|
|
|
|
|
|
927 |
background: #f5f5f5;
|
928 |
}
|
929 |
#buddypress table.notification-settings {
|
765 |
clear:none;
|
766 |
}
|
767 |
|
768 |
+
/* Overrides for embedded WP editors */
|
769 |
+
#buddypress .wp-editor-wrap a.button,
|
770 |
+
#buddypress .wp-editor-wrap button,
|
771 |
+
#buddypress .wp-editor-wrap input[type=submit],
|
772 |
+
#buddypress .wp-editor-wrap input[type=button],
|
773 |
+
#buddypress .wp-editor-wrap input[type=reset] {
|
774 |
+
padding: 0 10px 1px;
|
775 |
+
}
|
776 |
/*--------------------------------------------------------------
|
777 |
3.6 - Ajax Loading
|
778 |
--------------------------------------------------------------*/
|
887 |
margin: 20px 0 0 0;
|
888 |
padding: 1px 0 0 0;
|
889 |
}
|
890 |
+
#buddypress table.notifications,
|
891 |
+
#buddypress table.notifications-settings,
|
892 |
+
#buddypress table.profile-fields,
|
893 |
+
#buddypress table.wp-profile-fields,
|
894 |
+
#buddypress table.messages-notices,
|
895 |
+
#buddypress table.forum {
|
896 |
width: 100%;
|
897 |
}
|
898 |
+
#buddypress table.notifications thead tr,
|
899 |
+
#buddypress table.notifications-settings thead tr,
|
900 |
+
#buddypress table.profile-fields thead tr,
|
901 |
+
#buddypress table.wp-profile-fields thead tr,
|
902 |
+
#buddypress table.messages-notices thead tr,
|
903 |
+
#buddypress table.forum thead tr {
|
904 |
background: #eaeaea;
|
905 |
}
|
906 |
#buddypress table#message-threads {
|
920 |
#buddypress table.profile-fields p:last-child {
|
921 |
margin-top: 0;
|
922 |
}
|
923 |
+
#buddypress table.notifications tr td,
|
924 |
+
#buddypress table.notifications-settings tr td,
|
925 |
+
#buddypress table.profile-fields tr td,
|
926 |
+
#buddypress table.wp-profile-fields tr td,
|
927 |
+
#buddypress table.messages-notices tr td,
|
928 |
+
#buddypress table.forum tr td,
|
929 |
+
#buddypress table.notifications tr th,
|
930 |
+
#buddypress table.notifications-settings tr th,
|
931 |
+
#buddypress table.profile-fields tr th,
|
932 |
+
#buddypress table.wp-profile-fields tr th,
|
933 |
+
#buddypress table.messages-notices tr th,
|
934 |
+
#buddypress table.forum tr th {
|
935 |
padding: 8px;
|
936 |
vertical-align: middle;
|
937 |
}
|
938 |
+
#buddypress table.notifications tr td.label,
|
939 |
+
#buddypress table.notifications-settings tr td.label,
|
940 |
+
#buddypress table.profile-fields tr td.label,
|
941 |
+
#buddypress table.wp-profile-fields tr td.label,
|
942 |
+
#buddypress table.messages-notices tr td.label,
|
943 |
+
#buddypress table.forum tr td.label {
|
944 |
border-right: 1px solid #eaeaea;
|
945 |
font-weight: bold;
|
946 |
width: 25%;
|
956 |
#buddypress table.forum td {
|
957 |
text-align: center;
|
958 |
}
|
959 |
+
#buddypress table.notifications tr.alt td,
|
960 |
+
#buddypress table.notifications-settings tr.alt td,
|
961 |
+
#buddypress table.profile-fields tr.alt td,
|
962 |
+
#buddypress table.wp-profile-fields tr.alt td,
|
963 |
+
#buddypress table.messages-notices tr.alt td,
|
964 |
+
#buddypress table.forum tr.alt td {
|
965 |
background: #f5f5f5;
|
966 |
}
|
967 |
#buddypress table.notification-settings {
|
@@ -354,7 +354,7 @@ jq(document).ready( function() {
|
|
354 |
});
|
355 |
|
356 |
// Activity "Read More" links
|
357 |
-
jq('.activity
|
358 |
var target = jq(event.target);
|
359 |
var link_id = target.parent().attr('id').split('-');
|
360 |
var a_id = link_id[3];
|
354 |
});
|
355 |
|
356 |
// Activity "Read More" links
|
357 |
+
jq('div.activity').on('click', '.activity-read-more a', function(event) {
|
358 |
var target = jq(event.target);
|
359 |
var link_id = target.parent().attr('id').split('-');
|
360 |
var a_id = link_id[3];
|
@@ -349,7 +349,7 @@ jq(document).ready( function() {
|
|
349 |
});
|
350 |
|
351 |
// Activity "Read More" links
|
352 |
-
jq('.activity
|
353 |
var target = jq(event.target);
|
354 |
var link_id = target.parent().attr('id').split('-');
|
355 |
var a_id = link_id[3];
|
349 |
});
|
350 |
|
351 |
// Activity "Read More" links
|
352 |
+
jq('div.activity').on('click', '.activity-read-more a', function(event) {
|
353 |
var target = jq(event.target);
|
354 |
var link_id = target.parent().attr('id').split('-');
|
355 |
var a_id = link_id[3];
|
@@ -2,7 +2,7 @@
|
|
2 |
* Theme Name: BuddyPress Default
|
3 |
* Theme URI: http://buddypress.org/extend/themes/
|
4 |
* Description: Clean and stylish, BuddyPress Default lets you build a social network straight out of the box. Make it yours with a custom menu, header image, and background. Along with five widgetized areas (one in the sidebar, four in the footer), BP-Default supports featured images (as custom header images on posts and pages) and is furnished with an optional one-column page template that removes the sidebar, and a stylesheet for the admin Visual Editor.
|
5 |
-
* Version: 1.9-
|
6 |
* Author: the BuddyPress team
|
7 |
* Author URI: http://buddypress.org
|
8 |
* License: GNU General Public License
|
2 |
* Theme Name: BuddyPress Default
|
3 |
* Theme URI: http://buddypress.org/extend/themes/
|
4 |
* Description: Clean and stylish, BuddyPress Default lets you build a social network straight out of the box. Make it yours with a custom menu, header image, and background. Along with five widgetized areas (one in the sidebar, four in the footer), BP-Default supports featured images (as custom header images on posts and pages) and is furnished with an optional one-column page template that removes the sidebar, and a stylesheet for the admin Visual Editor.
|
5 |
+
* Version: 1.9-beta2
|
6 |
* Author: the BuddyPress team
|
7 |
* Author URI: http://buddypress.org
|
8 |
* License: GNU General Public License
|
@@ -2,7 +2,7 @@
|
|
2 |
* Theme Name: BuddyPress Default
|
3 |
* Theme URI: http://buddypress.org/extend/themes/
|
4 |
* Description: [NOTE: except for security issues, BuddyPress Default is no longer being actively maintained by the BuddyPress team.] Clean and stylish, BuddyPress Default lets you build a social network straight out of the box. Make it yours with a custom menu, header image, and background. Along with five widgetized areas (one in the sidebar, four in the footer), BP-Default supports featured images (as custom header images on posts and pages) and is furnished with an optional one-column page template that removes the sidebar, and a stylesheet for the admin Visual Editor.
|
5 |
-
* Version: 1.9-
|
6 |
* Author: the BuddyPress team
|
7 |
* Author URI: http://buddypress.org
|
8 |
* License: GNU General Public License
|
2 |
* Theme Name: BuddyPress Default
|
3 |
* Theme URI: http://buddypress.org/extend/themes/
|
4 |
* Description: [NOTE: except for security issues, BuddyPress Default is no longer being actively maintained by the BuddyPress team.] Clean and stylish, BuddyPress Default lets you build a social network straight out of the box. Make it yours with a custom menu, header image, and background. Along with five widgetized areas (one in the sidebar, four in the footer), BP-Default supports featured images (as custom header images on posts and pages) and is furnished with an optional one-column page template that removes the sidebar, and a stylesheet for the admin Visual Editor.
|
5 |
+
* Version: 1.9-beta2
|
6 |
* Author: the BuddyPress team
|
7 |
* Author URI: http://buddypress.org
|
8 |
* License: GNU General Public License
|
@@ -752,7 +752,7 @@ function bp_xprofile_get_fields_by_visibility_levels( $user_id, $levels = array(
|
|
752 |
foreach( (array) $default_visibility_levels as $d_field_id => $defaults ) {
|
753 |
// If the admin has forbidden custom visibility levels for this field, replace
|
754 |
// the user-provided setting with the default specified by the admin
|
755 |
-
if ( isset( $defaults['allow_custom'] ) && isset( $defaults['default'] ) && 'disabled' == $defaults['allow_custom']
|
756 |
$user_visibility_levels[$d_field_id] = $defaults['default'];
|
757 |
}
|
758 |
}
|
752 |
foreach( (array) $default_visibility_levels as $d_field_id => $defaults ) {
|
753 |
// If the admin has forbidden custom visibility levels for this field, replace
|
754 |
// the user-provided setting with the default specified by the admin
|
755 |
+
if ( isset( $defaults['allow_custom'] ) && isset( $defaults['default'] ) && 'disabled' == $defaults['allow_custom'] ) {
|
756 |
$user_visibility_levels[$d_field_id] = $defaults['default'];
|
757 |
}
|
758 |
}
|
@@ -437,12 +437,8 @@ function bp_the_profile_field_options( $args = '' ) {
|
|
437 |
function bp_get_the_profile_field_options( $args = '' ) {
|
438 |
global $field;
|
439 |
|
440 |
-
// Generally a required dropdown field will not get a blank value at
|
441 |
-
// the top. Set 'null_on_required' to true if you want this blank value
|
442 |
-
// even on required fields.
|
443 |
$defaults = array(
|
444 |
-
'type'
|
445 |
-
'null_on_required' => false
|
446 |
);
|
447 |
|
448 |
$r = wp_parse_args( $args, $defaults );
|
@@ -472,9 +468,7 @@ function bp_the_profile_field_options( $args = '' ) {
|
|
472 |
switch ( $field->type ) {
|
473 |
case 'selectbox':
|
474 |
|
475 |
-
|
476 |
-
$html .= '<option value="">' . /* translators: no option picked in select box */ __( '----', 'buddypress' ) . '</option>';
|
477 |
-
}
|
478 |
|
479 |
$original_option_values = '';
|
480 |
$original_option_values = maybe_unserialize( BP_XProfile_ProfileData::get_value_byid( $field->id ) );
|
@@ -944,7 +938,11 @@ function bp_profile_visibility_radio_buttons() {
|
|
944 |
foreach( bp_xprofile_get_visibility_levels() as $level ) {
|
945 |
$checked = $level['id'] == bp_get_the_profile_field_visibility_level() ? ' checked="checked" ' : '';
|
946 |
|
947 |
-
|
|
|
|
|
|
|
|
|
948 |
}
|
949 |
|
950 |
$html .= '</ul>';
|
437 |
function bp_get_the_profile_field_options( $args = '' ) {
|
438 |
global $field;
|
439 |
|
|
|
|
|
|
|
440 |
$defaults = array(
|
441 |
+
'type' => false,
|
|
|
442 |
);
|
443 |
|
444 |
$r = wp_parse_args( $args, $defaults );
|
468 |
switch ( $field->type ) {
|
469 |
case 'selectbox':
|
470 |
|
471 |
+
$html .= '<option value="">' . /* translators: no option picked in select box */ __( '----', 'buddypress' ) . '</option>';
|
|
|
|
|
472 |
|
473 |
$original_option_values = '';
|
474 |
$original_option_values = maybe_unserialize( BP_XProfile_ProfileData::get_value_byid( $field->id ) );
|
938 |
foreach( bp_xprofile_get_visibility_levels() as $level ) {
|
939 |
$checked = $level['id'] == bp_get_the_profile_field_visibility_level() ? ' checked="checked" ' : '';
|
940 |
|
941 |
+
// Only sanitize once
|
942 |
+
$field_id = bp_get_the_profile_field_id();
|
943 |
+
$level_id = esc_attr( $level_id );
|
944 |
+
|
945 |
+
$html .= '<li><label for="see-field_' . $field_id . '_' . $level_id . '"><input type="radio" id="see-field_' . $field_id . '_' . $level_id . '" name="field_' . $field_id . '_visibility" value="' . $level_id . '"' . $checked . ' /> ' . esc_html( $level['label'] ) . '</label></li>';
|
946 |
}
|
947 |
|
948 |
$html .= '</ul>';
|
@@ -7,7 +7,7 @@ Stable tag: 1.8.1
|
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
10 |
-
Social networking in a box. Build a social network for your company, school, sports team or niche community.
|
11 |
|
12 |
== Description ==
|
13 |
|
@@ -29,7 +29,7 @@ Visit the <a href="http://buddypress.org/">BuddyPress website</a> for more infor
|
|
29 |
|
30 |
You can download and install BuddyPress using the built in WordPress plugin installer. If you download BuddyPress manually, make sure it is uploaded to "/wp-content/plugins/buddypress/".
|
31 |
|
32 |
-
Activate BuddyPress in the "Plugins" admin panel using the "Activate" link. If you're using WordPress Multisite, you can optionally activate BuddyPress Network Wide, allowing
|
33 |
|
34 |
= Discussion Forums =
|
35 |
|
@@ -63,11 +63,11 @@ Check out the development trunk of BuddyPress via Subversion, from <a href="http
|
|
63 |
|
64 |
== Screenshots ==
|
65 |
|
66 |
-
1. **Activity Streams** - Global, personal and group activity streams with threaded commenting, direct posting, favoriting and @mentions. All with full RSS feeds and email notification support.
|
67 |
2. **Extended Profiles** - Fully editable profile fields allow you to define the fields users can fill in to describe themselves. Tailor profile fields to suit your audience.
|
68 |
3. **User Settings** - Give your users complete control over profile and notification settings. Settings are fully integrated into your theme, and can be disabled by the administrator.
|
69 |
4. **Extensible Groups** - Powerful public, private or hidden groups allow your users to break the discussion down into specific topics. Extend groups with your own custom features using the group extension API.
|
70 |
-
5. **Friend Connections** - Let your users make connections so they can track the activity of others, or filter
|
71 |
6. **Private Messaging** - Private messaging will allow your users to talk to each other directly and in private. Not just limited to one-on-one discussions, your users can send messages to multiple recipients.
|
72 |
7. **Blogging Network** - Allow your users to start their own blogs using WordPress's Multisite feature, and track posts and comments from across your blog network in the activity stream.
|
73 |
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
10 |
+
Social networking in a box. Build a social network for your company, school, sports team, or niche community.
|
11 |
|
12 |
== Description ==
|
13 |
|
29 |
|
30 |
You can download and install BuddyPress using the built in WordPress plugin installer. If you download BuddyPress manually, make sure it is uploaded to "/wp-content/plugins/buddypress/".
|
31 |
|
32 |
+
Activate BuddyPress in the "Plugins" admin panel using the "Activate" link. If you're using WordPress Multisite, you can optionally activate BuddyPress Network Wide, allowing its toolbar integration to appear on all of your sites, and optionally turning on post and comment aggregation to the Activity Stream too!
|
33 |
|
34 |
= Discussion Forums =
|
35 |
|
63 |
|
64 |
== Screenshots ==
|
65 |
|
66 |
+
1. **Activity Streams** - Global, personal, and group activity streams with threaded commenting, direct posting, favoriting and @mentions. All with full RSS feeds and email notification support.
|
67 |
2. **Extended Profiles** - Fully editable profile fields allow you to define the fields users can fill in to describe themselves. Tailor profile fields to suit your audience.
|
68 |
3. **User Settings** - Give your users complete control over profile and notification settings. Settings are fully integrated into your theme, and can be disabled by the administrator.
|
69 |
4. **Extensible Groups** - Powerful public, private or hidden groups allow your users to break the discussion down into specific topics. Extend groups with your own custom features using the group extension API.
|
70 |
+
5. **Friend Connections** - Let your users make connections so they can track the activity of others, or filter to show only those users they care about the most.
|
71 |
6. **Private Messaging** - Private messaging will allow your users to talk to each other directly and in private. Not just limited to one-on-one discussions, your users can send messages to multiple recipients.
|
72 |
7. **Blogging Network** - Allow your users to start their own blogs using WordPress's Multisite feature, and track posts and comments from across your blog network in the activity stream.
|
73 |
|
@@ -0,0 +1,148 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* The following implementations of BP_Group_Extension act as dummy plugins
|
5 |
+
* for our unit tests
|
6 |
+
*/
|
7 |
+
|
8 |
+
class BPTest_Group_Extension_Parse_Legacy_Properties extends BP_Group_Extension {
|
9 |
+
function __construct() {
|
10 |
+
$class_name = get_class( $this );
|
11 |
+
$this->name = $class_name;
|
12 |
+
$this->slug = sanitize_title( $class_name );
|
13 |
+
$this->admin_name = $this->name . ' Edit';
|
14 |
+
$this->admin_slug = $this->slug . '-edit';
|
15 |
+
$this->create_name = $this->name . ' Create';
|
16 |
+
$this->create_slug = $this->slug . '-create';
|
17 |
+
$this->visibility = 'private';
|
18 |
+
$this->create_step_position = 58;
|
19 |
+
$this->nav_item_position = 63;
|
20 |
+
$this->admin_metabox_context = 'high';
|
21 |
+
$this->admin_metabox_priority = 'side';
|
22 |
+
$this->enable_create_step = false;
|
23 |
+
$this->enable_nav_item = true;
|
24 |
+
$this->enable_edit_item = false;
|
25 |
+
$this->enable_admin_item = true;
|
26 |
+
$this->nav_item_name = $this->name . ' Nav';
|
27 |
+
$this->display_hook = 'foo_hook';
|
28 |
+
$this->template_file = 'foo_template';
|
29 |
+
}
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Provides access to protected method unneeded in BP
|
33 |
+
*/
|
34 |
+
function _parse_legacy_properties() {
|
35 |
+
return $this->parse_legacy_properties();
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Provides access to protected property unneeded in BP
|
40 |
+
*/
|
41 |
+
function _get_legacy_properties_converted() {
|
42 |
+
return $this->legacy_properties_converted;
|
43 |
+
}
|
44 |
+
}
|
45 |
+
|
46 |
+
class BPTest_Group_Extension_Setup_Screens_Use_Global_Fallbacks extends BP_Group_Extension {
|
47 |
+
function __construct() {
|
48 |
+
$class_name = get_class( $this );
|
49 |
+
$this->slug = sanitize_title( $class_name );
|
50 |
+
$this->name = $class_name;
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Provides access to protected method unneeded in BP
|
55 |
+
*/
|
56 |
+
function _get_default_screens() {
|
57 |
+
return $this->get_default_screens();
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Provides access to protected method unneeded in BP
|
62 |
+
*/
|
63 |
+
function _setup_class_info() {
|
64 |
+
return $this->setup_class_info();
|
65 |
+
}
|
66 |
+
|
67 |
+
function settings_screen( $group_id = null ) {}
|
68 |
+
function settings_screen_save( $group_id = null ) {}
|
69 |
+
}
|
70 |
+
|
71 |
+
class BPTest_Group_Extension_Setup_Screens_Define_Edit_Screens_Locally extends BP_Group_Extension {
|
72 |
+
function __construct() {
|
73 |
+
$class_name = get_class( $this );
|
74 |
+
$this->slug = sanitize_title( $class_name );
|
75 |
+
$this->name = $class_name;
|
76 |
+
}
|
77 |
+
|
78 |
+
function edit_screen( $group_id = null ) {}
|
79 |
+
function edit_screen_save( $group_id = null ) {}
|
80 |
+
function settings_screen( $group_id = null ) {}
|
81 |
+
function settings_screen_save( $group_id = null ) {}
|
82 |
+
|
83 |
+
/**
|
84 |
+
* Provides access to protected method unneeded in BP
|
85 |
+
*/
|
86 |
+
function _get_default_screens() {
|
87 |
+
return $this->get_default_screens();
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* Provides access to protected method unneeded in BP
|
92 |
+
*/
|
93 |
+
function _setup_class_info() {
|
94 |
+
return $this->setup_class_info();
|
95 |
+
}
|
96 |
+
|
97 |
+
}
|
98 |
+
|
99 |
+
class BPTest_Group_Extension_Access_Root_Property extends BP_Group_Extension {
|
100 |
+
function __construct() {
|
101 |
+
$class_name = get_class( $this );
|
102 |
+
|
103 |
+
$args = array(
|
104 |
+
'slug' => sanitize_title( $class_name ),
|
105 |
+
'name' => $class_name,
|
106 |
+
'nav_item_position' => 39,
|
107 |
+
);
|
108 |
+
|
109 |
+
parent::init( $args );
|
110 |
+
}
|
111 |
+
}
|
112 |
+
|
113 |
+
class BPTest_Group_Extension_Access_Init_Property_Using_Legacy_Location extends BP_Group_Extension {
|
114 |
+
function __construct() {
|
115 |
+
$class_name = get_class( $this );
|
116 |
+
|
117 |
+
$args = array(
|
118 |
+
'slug' => sanitize_title( $class_name ),
|
119 |
+
'name' => $class_name,
|
120 |
+
'screens' => array(
|
121 |
+
'create' => array(
|
122 |
+
'position' => 18,
|
123 |
+
),
|
124 |
+
),
|
125 |
+
);
|
126 |
+
|
127 |
+
parent::init( $args );
|
128 |
+
}
|
129 |
+
}
|
130 |
+
|
131 |
+
class BPTest_Group_Extension_Get_Screen_Callback_Fallbacks extends BP_Group_Extension {
|
132 |
+
function __construct() {
|
133 |
+
$class_name = get_class( $this );
|
134 |
+
|
135 |
+
$args = array(
|
136 |
+
'slug' => sanitize_title( $class_name ),
|
137 |
+
'name' => $class_name,
|
138 |
+
);
|
139 |
+
|
140 |
+
parent::init( $args );
|
141 |
+
}
|
142 |
+
|
143 |
+
function settings_screen( $group_id = null ) {}
|
144 |
+
function settings_screen_save( $group_id = null ) {}
|
145 |
+
|
146 |
+
function edit_screen( $group_id = null ) {}
|
147 |
+
function edit_screen_save( $group_id = null ) {}
|
148 |
+
}
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
define( 'BP_PLUGIN_DIR', dirname( dirname( __FILE__ ) ) . '/' );
|
4 |
+
|
5 |
+
if ( ! defined( 'BP_TESTS_DIR' ) ) {
|
6 |
+
define( 'BP_TESTS_DIR', dirname( __FILE__ ) . '/' );
|
7 |
+
}
|
8 |
+
|
9 |
+
/**
|
10 |
+
* In the pre-develop.svn WP development environment, an environmental bash
|
11 |
+
* variable would be set to run PHP Unit tests. However, this has been done
|
12 |
+
* away with in a post-develop.svn world. We'll still check if this variable
|
13 |
+
* is set for backwards compat.
|
14 |
+
*/
|
15 |
+
if ( getenv( 'WP_TESTS_DIR' ) ) {
|
16 |
+
define( 'WP_TESTS_DIR', getenv( 'WP_TESTS_DIR' ) );
|
17 |
+
define( 'WP_ROOT_DIR', WP_TESTS_DIR );
|
18 |
+
} else {
|
19 |
+
define( 'WP_ROOT_DIR', dirname( dirname( dirname( dirname( dirname( __DIR__ ) ) ) ) ) );
|
20 |
+
define( 'WP_TESTS_DIR', WP_ROOT_DIR . '/tests/phpunit' );
|
21 |
+
}
|
22 |
+
|
23 |
+
// Based on the tests directory, look for a config file
|
24 |
+
if ( file_exists( WP_ROOT_DIR . '/wp-tests-config.php' ) ) {
|
25 |
+
// Standard develop.svn.wordpress.org setup
|
26 |
+
define( 'WP_TESTS_CONFIG_PATH', WP_ROOT_DIR . '/wp-tests-config.php' );
|
27 |
+
|
28 |
+
} else if ( file_exists( WP_TESTS_DIR . '/wp-tests-config.php' ) ) {
|
29 |
+
// Legacy unit-test.svn.wordpress.org setup
|
30 |
+
define( 'WP_TESTS_CONFIG_PATH', WP_TESTS_DIR . '/wp-tests-config.php' );
|
31 |
+
|
32 |
+
} else if ( file_exists( dirname( dirname( WP_TESTS_DIR ) ) . '/wp-tests-config.php' ) ) {
|
33 |
+
// Environment variable exists and points to tests/phpunit of
|
34 |
+
// develop.svn.wordpress.org setup
|
35 |
+
define( 'WP_TESTS_CONFIG_PATH', dirname( dirname( WP_TESTS_DIR ) ) . '/wp-tests-config.php' );
|
36 |
+
|
37 |
+
} else {
|
38 |
+
die( "wp-tests-config.php could not be found.\n" );
|
39 |
+
}
|
40 |
+
|
41 |
+
if ( ! file_exists( WP_TESTS_DIR . '/includes/functions.php' ) ) {
|
42 |
+
die( "The WordPress PHPUnit test suite could not be found.\n" );
|
43 |
+
}
|
44 |
+
|
45 |
+
require_once WP_TESTS_DIR . '/includes/functions.php';
|
46 |
+
|
47 |
+
function _install_and_load_buddypress() {
|
48 |
+
require BP_TESTS_DIR . '/includes/loader.php';
|
49 |
+
}
|
50 |
+
tests_add_filter( 'muplugins_loaded', '_install_and_load_buddypress' );
|
51 |
+
|
52 |
+
require WP_TESTS_DIR . '/includes/bootstrap.php';
|
53 |
+
|
54 |
+
// Load the BP-specific testing tools
|
55 |
+
require BP_TESTS_DIR . '/includes/testcase.php';
|
@@ -0,0 +1,165 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class BP_UnitTest_Factory extends WP_UnitTest_Factory {
|
3 |
+
public $activity = null;
|
4 |
+
|
5 |
+
function __construct() {
|
6 |
+
parent::__construct();
|
7 |
+
|
8 |
+
$this->activity = new BP_UnitTest_Factory_For_Activity( $this );
|
9 |
+
$this->group = new BP_UnitTest_Factory_For_Group( $this );
|
10 |
+
$this->xprofile_group = new BP_UnitTest_Factory_For_XProfileGroup( $this );
|
11 |
+
$this->xprofile_field = new BP_UnitTest_Factory_For_XProfileField( $this );
|
12 |
+
$this->notification = new BP_UnitTest_Factory_For_Notification( $this );
|
13 |
+
}
|
14 |
+
}
|
15 |
+
|
16 |
+
class BP_UnitTest_Factory_For_Activity extends WP_UnitTest_Factory_For_Thing {
|
17 |
+
|
18 |
+
function __construct( $factory = null ) {
|
19 |
+
parent::__construct( $factory );
|
20 |
+
|
21 |
+
$this->default_generation_definitions = array(
|
22 |
+
'action' => new WP_UnitTest_Generator_Sequence( 'Activity action %s' ),
|
23 |
+
'component' => buddypress()->activity->id,
|
24 |
+
'content' => new WP_UnitTest_Generator_Sequence( 'Activity content %s' ),
|
25 |
+
'primary_link' => 'http://example.com',
|
26 |
+
'type' => 'activity_update',
|
27 |
+
'recorded_time' => bp_core_current_time(),
|
28 |
+
);
|
29 |
+
}
|
30 |
+
|
31 |
+
function create_object( $args ) {
|
32 |
+
if ( ! isset( $args['user_id'] ) )
|
33 |
+
$args['user_id'] = get_current_user_id();
|
34 |
+
|
35 |
+
return bp_activity_add( $args );
|
36 |
+
}
|
37 |
+
|
38 |
+
function update_object( $activity_id, $fields ) {
|
39 |
+
$activity = new BP_Activity_Activity( $activity_id );
|
40 |
+
|
41 |
+
foreach ( $fields as $field_name => $value ) {
|
42 |
+
if ( isset( $activity->$field_name ) )
|
43 |
+
$activity->$field_name = $value;
|
44 |
+
}
|
45 |
+
|
46 |
+
$activity->save();
|
47 |
+
return $activity;
|
48 |
+
}
|
49 |
+
|
50 |
+
function get_object_by_id( $user_id ) {
|
51 |
+
return new BP_Activity_Activity( $user_id );
|
52 |
+
}
|
53 |
+
}
|
54 |
+
|
55 |
+
class BP_UnitTest_Factory_For_Group extends WP_UnitTest_Factory_For_Thing {
|
56 |
+
|
57 |
+
function __construct( $factory = null ) {
|
58 |
+
parent::__construct( $factory );
|
59 |
+
|
60 |
+
$this->default_generation_definitions = array(
|
61 |
+
'name' => new WP_UnitTest_Generator_Sequence( 'Group %s' ),
|
62 |
+
'description' => new WP_UnitTest_Generator_Sequence( 'Group description %s' ),
|
63 |
+
'slug' => new WP_UnitTest_Generator_Sequence( 'group-slug-%s' ),
|
64 |
+
'status' => 'public',
|
65 |
+
'enable_forum' => true,
|
66 |
+
'date_created' => bp_core_current_time(),
|
67 |
+
);
|
68 |
+
}
|
69 |
+
|
70 |
+
function create_object( $args ) {
|
71 |
+
if ( ! isset( $args['creator_id'] ) ) {
|
72 |
+
$args['creator_id'] = get_current_user_id();
|
73 |
+
}
|
74 |
+
|
75 |
+
$group_id = groups_create_group( $args );
|
76 |
+
|
77 |
+
groups_update_groupmeta( $group_id, 'total_member_count', 1 );
|
78 |
+
|
79 |
+
$last_activity = isset( $args['last_activity'] ) ? $args['last_activity'] : bp_core_current_time();
|
80 |
+
groups_update_groupmeta( $group_id, 'last_activity', $last_activity );
|
81 |
+
|
82 |
+
return $group_id;
|
83 |
+
}
|
84 |
+
|
85 |
+
function update_object( $group_id, $fields ) {
|
86 |
+
$group = new BP_Groups_Group( $group_id );
|
87 |
+
|
88 |
+
foreach ( $fields as $field_name => $value ) {
|
89 |
+
if ( isset( $group->field_name ) )
|
90 |
+
$group->field_name = $value;
|
91 |
+
}
|
92 |
+
|
93 |
+
$group->save();
|
94 |
+
return $group;
|
95 |
+
}
|
96 |
+
|
97 |
+
function get_object_by_id( $group_id ) {
|
98 |
+
return new BP_Groups_Group( $group_id );
|
99 |
+
}
|
100 |
+
}
|
101 |
+
|
102 |
+
class BP_UnitTest_Factory_For_XProfileGroup extends WP_UnitTest_Factory_For_Thing {
|
103 |
+
|
104 |
+
function __construct( $factory = null ) {
|
105 |
+
parent::__construct( $factory );
|
106 |
+
|
107 |
+
$this->default_generation_definitions = array(
|
108 |
+
'name' => new WP_UnitTest_Generator_Sequence( 'XProfile group %s' ),
|
109 |
+
'description' => new WP_UnitTest_Generator_Sequence( 'XProfile group description %s' ),
|
110 |
+
'slug' => new WP_UnitTest_Generator_Sequence( 'xprofile-group-slug-%s' ),
|
111 |
+
);
|
112 |
+
}
|
113 |
+
|
114 |
+
function create_object( $args ) {
|
115 |
+
$group_id = xprofile_insert_field_group( $args );
|
116 |
+
return $this->get_object_by_id( $group_id );
|
117 |
+
}
|
118 |
+
|
119 |
+
function update_object( $group_id, $fields ) {
|
120 |
+
}
|
121 |
+
|
122 |
+
function get_object_by_id( $group_id ) {
|
123 |
+
return new BP_XProfile_Group( $group_id );
|
124 |
+
}
|
125 |
+
}
|
126 |
+
|
127 |
+
class BP_UnitTest_Factory_For_XProfileField extends WP_UnitTest_Factory_For_Thing {
|
128 |
+
|
129 |
+
function __construct( $factory = null ) {
|
130 |
+
parent::__construct( $factory );
|
131 |
+
|
132 |
+
$this->default_generation_definitions = array(
|
133 |
+
'name' => new WP_UnitTest_Generator_Sequence( 'XProfile field %s' ),
|
134 |
+
'description' => new WP_UnitTest_Generator_Sequence( 'XProfile field description %s' ),
|
135 |
+
);
|
136 |
+
}
|
137 |
+
|
138 |
+
function create_object( $args ) {
|
139 |
+
$field_id = xprofile_insert_field( $args );
|
140 |
+
return $this->get_object_by_id( $field_id );
|
141 |
+
}
|
142 |
+
|
143 |
+
function update_object( $field_id, $fields ) {
|
144 |
+
}
|
145 |
+
|
146 |
+
function get_object_by_id( $field_id ) {
|
147 |
+
return new BP_XProfile_Field( $field_id );
|
148 |
+
}
|
149 |
+
}
|
150 |
+
|
151 |
+
class BP_UnitTest_Factory_For_Notification extends WP_UnitTest_Factory_For_Thing {
|
152 |
+
public function __construct( $factory = null ) {
|
153 |
+
parent::__construct( $factory );
|
154 |
+
}
|
155 |
+
|
156 |
+
public function create_object( $args ) {
|
157 |
+
return bp_notifications_add_notification( $args );
|
158 |
+
}
|
159 |
+
|
160 |
+
public function update_object( $id, $fields ) {}
|
161 |
+
|
162 |
+
public function get_object_by_id( $id ) {
|
163 |
+
return new BP_Notifications_Notification( $id );
|
164 |
+
}
|
165 |
+
}
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Installs BuddyPress for the purpose of the unit-tests
|
4 |
+
*
|
5 |
+
* @todo Reuse the init/load code in init.php
|
6 |
+
* @todo Support MULTIBLOG
|
7 |
+
*/
|
8 |
+
error_reporting( E_ALL & ~E_DEPRECATED & ~E_STRICT );
|
9 |
+
|
10 |
+
$config_file_path = $argv[1];
|
11 |
+
$tests_dir_path = $argv[2];
|
12 |
+
$multisite = ! empty( $argv[3] );
|
13 |
+
|
14 |
+
require_once $config_file_path;
|
15 |
+
require_once $tests_dir_path . '/includes/functions.php';
|
16 |
+
|
17 |
+
function _load_buddypress() {
|
18 |
+
require dirname( dirname( dirname( __FILE__ ) ) ) . '/bp-loader.php';
|
19 |
+
}
|
20 |
+
tests_add_filter( 'muplugins_loaded', '_load_buddypress' );
|
21 |
+
|
22 |
+
define( 'BP_PLUGIN_DIR', dirname( dirname( dirname( __FILE__ ) ) ) . '/' );
|
23 |
+
define( 'BP_ROOT_BLOG', 1 );
|
24 |
+
|
25 |
+
// Always load admin bar
|
26 |
+
tests_add_filter( 'show_admin_bar', '__return_true' );
|
27 |
+
|
28 |
+
function wp_test_bp_install( $value ) {
|
29 |
+
return array( 'activity' => 1, 'blogs' => 1, 'friends' => 1, 'groups' => 1, 'members' => 1, 'messages' => 1, 'notifications' => 1, 'settings' => 1, 'xprofile' => 1, );
|
30 |
+
}
|
31 |
+
tests_add_filter( 'bp_new_install_default_components', 'wp_test_bp_install' );
|
32 |
+
|
33 |
+
$_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.1';
|
34 |
+
$_SERVER['HTTP_HOST'] = WP_TESTS_DOMAIN;
|
35 |
+
$PHP_SELF = $GLOBALS['PHP_SELF'] = $_SERVER['PHP_SELF'] = '/index.php';
|
36 |
+
|
37 |
+
require_once ABSPATH . '/wp-settings.php';
|
38 |
+
define( 'BP_TESTS_DB_VERSION_FILE', ABSPATH . '.bp-tests-version' );
|
39 |
+
|
40 |
+
// Check if BuddyPress has already been installed
|
41 |
+
$db_version = buddypress()->db_version;
|
42 |
+
$hash = $db_version . ' ' . (int) $multisite . ' ' . sha1_file( $config_file_path );
|
43 |
+
|
44 |
+
if ( $db_version && file_exists( BP_TESTS_DB_VERSION_FILE ) ) {
|
45 |
+
$version_file = file_get_contents( BP_TESTS_DB_VERSION_FILE );
|
46 |
+
|
47 |
+
if ( $hash === $version_file ) {
|
48 |
+
return;
|
49 |
+
}
|
50 |
+
}
|
51 |
+
|
52 |
+
echo "Installing BuddyPress...\n";
|
53 |
+
|
54 |
+
// Make sure that BP has been cleaned from all blogs before reinstalling
|
55 |
+
$blogs = is_multisite() ? $wpdb->get_col( "SELECT blog_id FROM {$wpdb->blogs}" ) : array( 1 );
|
56 |
+
foreach ( $blogs as $blog ) {
|
57 |
+
if ( is_multisite() ) {
|
58 |
+
switch_to_blog( $blog );
|
59 |
+
}
|
60 |
+
|
61 |
+
$wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE '%bp%'" );
|
62 |
+
|
63 |
+
if ( is_multisite() ) {
|
64 |
+
restore_current_blog();
|
65 |
+
}
|
66 |
+
}
|
67 |
+
|
68 |
+
$wpdb->query( 'SET storage_engine = INNODB' );
|
69 |
+
$wpdb->select( DB_NAME, $wpdb->dbh );
|
70 |
+
|
71 |
+
// Install BuddyPress
|
72 |
+
bp_version_updater();
|
73 |
+
|
74 |
+
file_put_contents( BP_TESTS_DB_VERSION_FILE, $hash );
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$multisite = (int) ( defined( 'WP_TESTS_MULTISITE') && WP_TESTS_MULTISITE );
|
3 |
+
system( WP_PHP_BINARY . ' ' . escapeshellarg( dirname( __FILE__ ) . '/install.php' ) . ' ' . escapeshellarg( WP_TESTS_CONFIG_PATH ) . ' ' . escapeshellarg( WP_TESTS_DIR ) . ' ' . $multisite );
|
4 |
+
|
5 |
+
// Bootstrap BP
|
6 |
+
require dirname( __FILE__ ) . '/../../bp-loader.php';
|
@@ -0,0 +1,317 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* WP's test suite wipes out BP's directory page mappings with _delete_all_posts()
|
5 |
+
* We must reestablish them before our tests can be successfully run
|
6 |
+
*/
|
7 |
+
bp_core_add_page_mappings( bp_get_option( 'bp-active-components' ), 'delete' );
|
8 |
+
|
9 |
+
require_once dirname( __FILE__ ) . '/factory.php';
|
10 |
+
|
11 |
+
class BP_UnitTestCase extends WP_UnitTestCase {
|
12 |
+
|
13 |
+
protected $temp_has_bp_moderate = array();
|
14 |
+
|
15 |
+
public function setUp() {
|
16 |
+
parent::setUp();
|
17 |
+
|
18 |
+
// Make sure all users are deleted
|
19 |
+
// There's a bug in the multisite tests that causes the
|
20 |
+
// transaction rollback to fail for the first user created,
|
21 |
+
// which busts every other attempt to create users. This is a
|
22 |
+
// hack workaround
|
23 |
+
global $wpdb;
|
24 |
+
$wpdb->query( "TRUNCATE TABLE {$wpdb->users}" );
|
25 |
+
|
26 |
+
$this->factory = new BP_UnitTest_Factory;
|
27 |
+
}
|
28 |
+
|
29 |
+
function clean_up_global_scope() {
|
30 |
+
buddypress()->bp_nav = buddypress()->bp_options_nav = buddypress()->action_variables = buddypress()->canonical_stack = buddypress()->unfiltered_uri = $GLOBALS['bp_unfiltered_uri'] = array();
|
31 |
+
buddypress()->current_component = buddypress()->current_item = buddypress()->current_action = '';
|
32 |
+
buddypress()->unfiltered_uri_offset = 0;
|
33 |
+
buddypress()->is_single_item = false;
|
34 |
+
buddypress()->current_user = new stdClass();
|
35 |
+
buddypress()->displayed_user = new stdClass();
|
36 |
+
buddypress()->loggedin_user = new stdClass();
|
37 |
+
buddypress()->avatar = new stdClass();
|
38 |
+
|
39 |
+
parent::clean_up_global_scope();
|
40 |
+
}
|
41 |
+
|
42 |
+
function assertPreConditions() {
|
43 |
+
parent::assertPreConditions();
|
44 |
+
|
45 |
+
// Reinit some of the globals that might have been cleared by BP_UnitTestCase::clean_up_global_scope().
|
46 |
+
// This is here because it didn't work in clean_up_global_scope(); I don't know why.
|
47 |
+
do_action( 'bp_setup_globals' );
|
48 |
+
}
|
49 |
+
|
50 |
+
function go_to( $url ) {
|
51 |
+
// note: the WP and WP_Query classes like to silently fetch parameters
|
52 |
+
// from all over the place (globals, GET, etc), which makes it tricky
|
53 |
+
// to run them more than once without very carefully clearing everything
|
54 |
+
$_GET = $_POST = array();
|
55 |
+
foreach (array('query_string', 'id', 'postdata', 'authordata', 'day', 'currentmonth', 'page', 'pages', 'multipage', 'more', 'numpages', 'pagenow') as $v) {
|
56 |
+
if ( isset( $GLOBALS[$v] ) ) unset( $GLOBALS[$v] );
|
57 |
+
}
|
58 |
+
$parts = parse_url($url);
|
59 |
+
if (isset($parts['scheme'])) {
|
60 |
+
// set the HTTP_HOST
|
61 |
+
$GLOBALS['_SERVER']['HTTP_HOST'] = $parts['host'];
|
62 |
+
|
63 |
+
$req = $parts['path'];
|
64 |
+
if (isset($parts['query'])) {
|
65 |
+
$req .= '?' . $parts['query'];
|
66 |
+
// parse the url query vars into $_GET
|
67 |
+
parse_str($parts['query'], $_GET);
|
68 |
+
}
|
69 |
+
} else {
|
70 |
+
$req = $url;
|
71 |
+
}
|
72 |
+
if ( ! isset( $parts['query'] ) ) {
|
73 |
+
$parts['query'] = '';
|
74 |
+
}
|
75 |
+
|
76 |
+
// Scheme
|
77 |
+
if ( 0 === strpos( $req, '/wp-admin' ) && force_ssl_admin() ) {
|
78 |
+
$_SERVER['HTTPS'] = 'on';
|
79 |
+
} else {
|
80 |
+
unset( $_SERVER['HTTPS'] );
|
81 |
+
}
|
82 |
+
|
83 |
+
// Set this for bp_core_set_uri_globals()
|
84 |
+
$GLOBALS['_SERVER']['REQUEST_URI'] = $req;
|
85 |
+
unset($_SERVER['PATH_INFO']);
|
86 |
+
|
87 |
+
// setup $current_site and $current_blog globals for multisite based on
|
88 |
+
// REQUEST_URI; mostly copied from /wp-includes/ms-settings.php
|
89 |
+
if ( is_multisite() ) {
|
90 |
+
$domain = addslashes( $_SERVER['HTTP_HOST'] );
|
91 |
+
if ( false !== strpos( $domain, ':' ) ) {
|
92 |
+
if ( substr( $domain, -3 ) == ':80' ) {
|
93 |
+
$domain = substr( $domain, 0, -3 );
|
94 |
+
$_SERVER['HTTP_HOST'] = substr( $_SERVER['HTTP_HOST'], 0, -3 );
|
95 |
+
} elseif ( substr( $domain, -4 ) == ':443' ) {
|
96 |
+
$domain = substr( $domain, 0, -4 );
|
97 |
+
$_SERVER['HTTP_HOST'] = substr( $_SERVER['HTTP_HOST'], 0, -4 );
|
98 |
+
}
|
99 |
+
}
|
100 |
+
|
101 |
+
$domain = rtrim( $domain, '.' );
|
102 |
+
$cookie_domain = $domain;
|
103 |
+
if ( substr( $cookie_domain, 0, 4 ) == 'www.' )
|
104 |
+
$cookie_domain = substr( $cookie_domain, 4 );
|
105 |
+
|
106 |
+
$path = preg_replace( '|([a-z0-9-]+.php.*)|', '', $GLOBALS['_SERVER']['REQUEST_URI'] );
|
107 |
+
$path = str_replace ( '/wp-admin/', '/', $path );
|
108 |
+
$path = preg_replace( '|(/[a-z0-9-]+?/).*|', '$1', $path );
|
109 |
+
|
110 |
+
$GLOBALS['current_site'] = wpmu_current_site();
|
111 |
+
if ( ! isset( $GLOBALS['current_site']->blog_id ) )
|
112 |
+
$GLOBALS['current_site']->blog_id = $wpdb->get_var( $wpdb->prepare( "SELECT blog_id FROM $wpdb->blogs WHERE domain = %s AND path = %s", $GLOBALS['current_site']->domain, $GLOBALS['current_site']->path ) );
|
113 |
+
|
114 |
+
// unit tests only support subdirectory install at the moment
|
115 |
+
// removed object cache references
|
116 |
+
if ( ! is_subdomain_install() ) {
|
117 |
+
$blogname = htmlspecialchars( substr( $GLOBALS['_SERVER']['REQUEST_URI'], strlen( $path ) ) );
|
118 |
+
if ( false !== strpos( $blogname, '/' ) )
|
119 |
+
$blogname = substr( $blogname, 0, strpos( $blogname, '/' ) );
|
120 |
+
if ( false !== strpos( $blogname, '?' ) )
|
121 |
+
$blogname = substr( $blogname, 0, strpos( $blogname, '?' ) );
|
122 |
+
$reserved_blognames = array( 'page', 'comments', 'blog', 'wp-admin', 'wp-includes', 'wp-content', 'files', 'feed' );
|
123 |
+
if ( $blogname != '' && ! in_array( $blogname, $reserved_blognames ) && ! is_file( $blogname ) )
|
124 |
+
$path .= $blogname . '/';
|
125 |
+
|
126 |
+
$GLOBALS['current_blog'] = get_blog_details( array( 'domain' => $domain, 'path' => $path ), false );
|
127 |
+
|
128 |
+
unset($reserved_blognames);
|
129 |
+
}
|
130 |
+
|
131 |
+
$GLOBALS['blog_id'] = $GLOBALS['current_blog']->blog_id;
|
132 |
+
}
|
133 |
+
|
134 |
+
unset($GLOBALS['wp_query'], $GLOBALS['wp_the_query']);
|
135 |
+
$GLOBALS['wp_the_query'] = new WP_Query();
|
136 |
+
$GLOBALS['wp_query'] = $GLOBALS['wp_the_query'];
|
137 |
+
$GLOBALS['wp'] = new WP();
|
138 |
+
|
139 |
+
// clean out globals to stop them polluting wp and wp_query
|
140 |
+
foreach ($GLOBALS['wp']->public_query_vars as $v) {
|
141 |
+
unset($GLOBALS[$v]);
|
142 |
+
}
|
143 |
+
foreach ($GLOBALS['wp']->private_query_vars as $v) {
|
144 |
+
unset($GLOBALS[$v]);
|
145 |
+
}
|
146 |
+
|
147 |
+
$GLOBALS['wp']->main($parts['query']);
|
148 |
+
|
149 |
+
// For BuddyPress, James.
|
150 |
+
$GLOBALS['bp']->loggedin_user = NULL;
|
151 |
+
do_action( 'bp_init' );
|
152 |
+
}
|
153 |
+
|
154 |
+
protected function checkRequirements() {
|
155 |
+
if ( WP_TESTS_FORCE_KNOWN_BUGS )
|
156 |
+
return;
|
157 |
+
|
158 |
+
parent::checkRequirements();
|
159 |
+
|
160 |
+
$tickets = PHPUnit_Util_Test::getTickets( get_class( $this ), $this->getName( false ) );
|
161 |
+
foreach ( $tickets as $ticket ) {
|
162 |
+
if ( 'BP' == substr( $ticket, 0, 2 ) ) {
|
163 |
+
$ticket = substr( $ticket, 2 );
|
164 |
+
if ( $ticket && is_numeric( $ticket ) )
|
165 |
+
$this->knownBPBug( $ticket );
|
166 |
+
}
|
167 |
+
}
|
168 |
+
}
|
169 |
+
|
170 |
+
/**
|
171 |
+
* Skips the current test if there is an open BuddyPress ticket with id $ticket_id
|
172 |
+
*/
|
173 |
+
function knownBPBug( $ticket_id ) {
|
174 |
+
if ( WP_TESTS_FORCE_KNOWN_BUGS || in_array( $ticket_id, self::$forced_tickets ) )
|
175 |
+
return;
|
176 |
+
|
177 |
+
if ( ! TracTickets::isTracTicketClosed( 'http://buddypress.trac.wordpress.org', $ticket_id ) )
|
178 |
+
$this->markTestSkipped( sprintf( 'BuddyPress Ticket #%d is not fixed', $ticket_id ) );
|
179 |
+
}
|
180 |
+
|
181 |
+
/**
|
182 |
+
* WP's core tests use wp_set_current_user() to change the current
|
183 |
+
* user during tests. BP caches the current user differently, so we
|
184 |
+
* have to do a bit more work to change it
|
185 |
+
*
|
186 |
+
* @global BuddyPres $bp
|
187 |
+
*/
|
188 |
+
function set_current_user( $user_id ) {
|
189 |
+
global $bp;
|
190 |
+
$bp->loggedin_user->id = $user_id;
|
191 |
+
$bp->loggedin_user->fullname = bp_core_get_user_displayname( $user_id );
|
192 |
+
$bp->loggedin_user->is_super_admin = $bp->loggedin_user->is_site_admin = is_super_admin( $user_id );
|
193 |
+
$bp->loggedin_user->domain = bp_core_get_user_domain( $user_id );
|
194 |
+
$bp->loggedin_user->userdata = bp_core_get_core_userdata( $user_id );
|
195 |
+
|
196 |
+
wp_set_current_user( $user_id );
|
197 |
+
}
|
198 |
+
|
199 |
+
/**
|
200 |
+
* When creating a new user, it's almost always necessary to have the
|
201 |
+
* last_activity usermeta set right away, so that the user shows up in
|
202 |
+
* directory queries. This is a shorthand wrapper for the user factory
|
203 |
+
* create() method.
|
204 |
+
*
|
205 |
+
* Also set a display name
|
206 |
+
*/
|
207 |
+
function create_user( $args = array() ) {
|
208 |
+
$r = wp_parse_args( $args, array(
|
209 |
+
'role' => 'subscriber',
|
210 |
+
'last_activity' => bp_core_current_time() - 60*60*24*365,
|
211 |
+
) );
|
212 |
+
|
213 |
+
$last_activity = $r['last_activity'];
|
214 |
+
unset( $r['last_activity'] );
|
215 |
+
|
216 |
+
$user_id = $this->factory->user->create( $args );
|
217 |
+
|
218 |
+
bp_update_user_last_activity( $user_id, $last_activity );
|
219 |
+
|
220 |
+
if ( bp_is_active( 'xprofile' ) ) {
|
221 |
+
$user = new WP_User( $user_id );
|
222 |
+
xprofile_set_field_data( 1, $user_id, $user->display_name );
|
223 |
+
}
|
224 |
+
|
225 |
+
return $user_id;
|
226 |
+
}
|
227 |
+
|
228 |
+
public static function add_user_to_group( $user_id, $group_id, $args = array() ) {
|
229 |
+
$r = wp_parse_args( $args, array(
|
230 |
+
'date_modified' => bp_core_current_time(),
|
231 |
+
'is_confirmed' => 1,
|
232 |
+
) );
|
233 |
+
|
234 |
+
$new_member = new BP_Groups_Member;
|
235 |
+
$new_member->group_id = $group_id;
|
236 |
+
$new_member->user_id = $user_id;
|
237 |
+
$new_member->inviter_id = 0;
|
238 |
+
$new_member->is_admin = 0;
|
239 |
+
$new_member->user_title = '';
|
240 |
+
$new_member->date_modified = $r['date_modified'];
|
241 |
+
$new_member->is_confirmed = $r['is_confirmed'];
|
242 |
+
|
243 |
+
$new_member->save();
|
244 |
+
return $new_member->id;
|
245 |
+
}
|
246 |
+
|
247 |
+
/**
|
248 |
+
* We can't use grant_super_admin() because we will need to modify
|
249 |
+
* the list more than once, and grant_super_admin() can only be run
|
250 |
+
* once because of its global check
|
251 |
+
*/
|
252 |
+
public function grant_super_admin( $user_id ) {
|
253 |
+
global $super_admins;
|
254 |
+
if ( ! is_multisite() ) {
|
255 |
+
return;
|
256 |
+
}
|
257 |
+
|
258 |
+
$user = get_userdata( $user_id );
|
259 |
+
$super_admins[] = $user->user_login;
|
260 |
+
}
|
261 |
+
|
262 |
+
public function restore_admins() {
|
263 |
+
// We assume that the global can be wiped out
|
264 |
+
// @see grant_super_admin()
|
265 |
+
unset( $GLOBALS['super_admins'] );
|
266 |
+
}
|
267 |
+
|
268 |
+
public function grant_bp_moderate( $user_id ) {
|
269 |
+
if ( ! isset( $this->temp_has_bp_moderate[ $user_id ] ) ) {
|
270 |
+
$this->temp_has_bp_moderate[ $user_id ] = 1;
|
271 |
+
}
|
272 |
+
add_filter( 'bp_current_user_can', array( $this, 'grant_bp_moderate_cb' ), 10, 2 );
|
273 |
+
}
|
274 |
+
|
275 |
+
public function revoke_bp_moderate( $user_id ) {
|
276 |
+
if ( isset( $this->temp_has_bp_moderate[ $user_id ] ) ) {
|
277 |
+
unset( $this->temp_has_bp_moderate[ $user_id ] );
|
278 |
+
}
|
279 |
+
remove_filter( 'bp_current_user_can', array( $this, 'grant_bp_moderate_cb' ), 10, 2 );
|
280 |
+
}
|
281 |
+
|
282 |
+
public function grant_bp_moderate_cb( $retval, $capability ) {
|
283 |
+
$current_user = bp_loggedin_user_id();
|
284 |
+
if ( ! isset( $this->temp_has_bp_moderate[ $current_user ] ) ) {
|
285 |
+
return $retval;
|
286 |
+
}
|
287 |
+
|
288 |
+
if ( 'bp_moderate' == $capability ) {
|
289 |
+
$retval = true;
|
290 |
+
}
|
291 |
+
|
292 |
+
return $retval;
|
293 |
+
}
|
294 |
+
|
295 |
+
/**
|
296 |
+
* Go to the root blog. This helps reset globals after moving between
|
297 |
+
* blogs.
|
298 |
+
*/
|
299 |
+
public function go_to_root() {
|
300 |
+
$blog_1_url = get_blog_option( 1, 'home' );
|
301 |
+
$this->go_to( str_replace( $blog_1_url, '', trailingslashit( bp_get_root_domain() ) ) );
|
302 |
+
}
|
303 |
+
|
304 |
+
/**
|
305 |
+
* Set up globals necessary to avoid errors when using wp_mail()
|
306 |
+
*/
|
307 |
+
public function setUp_wp_mail() {
|
308 |
+
$_SERVER['SERVER_NAME'] = 'example.com';
|
309 |
+
}
|
310 |
+
|
311 |
+
/**
|
312 |
+
* Tear down globals set up in setUp_wp_mail()
|
313 |
+
*/
|
314 |
+
public function tearDown_wp_mail() {
|
315 |
+
unset( $_SERVER['SERVER_NAME'] );
|
316 |
+
}
|
317 |
+
}
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<phpunit
|
2 |
+
bootstrap="bootstrap.php"
|
3 |
+
backupGlobals="false"
|
4 |
+
colors="true"
|
5 |
+
convertErrorsToExceptions="true"
|
6 |
+
convertNoticesToExceptions="true"
|
7 |
+
convertWarningsToExceptions="true"
|
8 |
+
>
|
9 |
+
<php>
|
10 |
+
<const name="WP_TESTS_MULTISITE" value="1" />
|
11 |
+
</php>
|
12 |
+
<testsuites>
|
13 |
+
<testsuite>
|
14 |
+
<directory suffix=".php">./testcases/</directory>
|
15 |
+
</testsuite>
|
16 |
+
</testsuites>
|
17 |
+
</phpunit>
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<phpunit
|
2 |
+
bootstrap="bootstrap.php"
|
3 |
+
backupGlobals="false"
|
4 |
+
colors="true"
|
5 |
+
convertErrorsToExceptions="true"
|
6 |
+
convertNoticesToExceptions="true"
|
7 |
+
convertWarningsToExceptions="true"
|
8 |
+
>
|
9 |
+
<testsuites>
|
10 |
+
<testsuite>
|
11 |
+
<directory suffix=".php">./testcases/</directory>
|
12 |
+
</testsuite>
|
13 |
+
</testsuites>
|
14 |
+
</phpunit>
|
@@ -0,0 +1,308 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @group activity
|
4 |
+
*/
|
5 |
+
class BP_Tests_Activity_Class extends BP_UnitTestCase {
|
6 |
+
protected $old_current_user = 0;
|
7 |
+
|
8 |
+
public function setUp() {
|
9 |
+
parent::setUp();
|
10 |
+
|
11 |
+
$this->old_current_user = get_current_user_id();
|
12 |
+
$this->set_current_user( $this->factory->user->create( array( 'role' => 'subscriber' ) ) );
|
13 |
+
}
|
14 |
+
|
15 |
+
public function tearDown() {
|
16 |
+
parent::tearDown();
|
17 |
+
$this->set_current_user( $this->old_current_user );
|
18 |
+
}
|
19 |
+
|
20 |
+
public function test_check_exists_by_content() {
|
21 |
+
$content = 'A classy girl who know how to enjoy the freedom of a cup of coffee';
|
22 |
+
$activity = $this->factory->activity->create( array(
|
23 |
+
'content' => $content,
|
24 |
+
'type' => 'activity_update',
|
25 |
+
) );
|
26 |
+
|
27 |
+
$result = BP_Activity_Activity::check_exists_by_content( $content );
|
28 |
+
$this->assertEquals( $activity, $result );
|
29 |
+
}
|
30 |
+
|
31 |
+
public function test_delete_activity_item_comments() {
|
32 |
+
$parent_activity = $this->factory->activity->create( array(
|
33 |
+
'type' => 'activity_update',
|
34 |
+
) );
|
35 |
+
|
36 |
+
$comments = $this->factory->activity->create_many( 3, array(
|
37 |
+
'item_id' => $parent_activity,
|
38 |
+
'type' => 'activity_comment',
|
39 |
+
) );
|
40 |
+
|
41 |
+
BP_Activity_Activity::delete_activity_item_comments( $parent_activity );
|
42 |
+
|
43 |
+
$result = BP_Activity_Activity::get( array( 'in' => wp_list_pluck( $comments, 'id' ), ) );
|
44 |
+
$this->assertEmpty( $result['activities'] );
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* @ticket BP4804
|
49 |
+
*/
|
50 |
+
public function test_delete_activity_meta_entries() {
|
51 |
+
$activity = $this->factory->activity->create( array(
|
52 |
+
'type' => 'activity_update',
|
53 |
+
) );
|
54 |
+
|
55 |
+
bp_activity_update_meta( $activity, 'Paul', 'is cool' );
|
56 |
+
BP_Activity_Activity::delete_activity_meta_entries( $activity );
|
57 |
+
|
58 |
+
$meta = bp_activity_get_meta( $activity, 'Paul' );
|
59 |
+
$this->assertFalse( $meta );
|
60 |
+
}
|
61 |
+
|
62 |
+
public function test_hide_all_for_user() {
|
63 |
+
$activity = $this->factory->activity->create( array(
|
64 |
+
'type' => 'activity_update',
|
65 |
+
) );
|
66 |
+
|
67 |
+
BP_Activity_Activity::hide_all_for_user( get_current_user_id() );
|
68 |
+
|
69 |
+
$activity = BP_Activity_Activity::get( array(
|
70 |
+
'in' => $activity,
|
71 |
+
'show_hidden' => true,
|
72 |
+
) );
|
73 |
+
$this->assertEquals( $activity['activities'][0]->hide_sitewide, 1 );
|
74 |
+
}
|
75 |
+
|
76 |
+
/**
|
77 |
+
* @group get
|
78 |
+
* @group meta_query
|
79 |
+
*/
|
80 |
+
public function test_get_with_meta_query() {
|
81 |
+
$a1 = $this->factory->activity->create();
|
82 |
+
$a2 = $this->factory->activity->create();
|
83 |
+
bp_activity_update_meta( $a1, 'foo', 'bar' );
|
84 |
+
|
85 |
+
$activity = BP_Activity_Activity::get( array(
|
86 |
+
'meta_query' => array(
|
87 |
+
array(
|
88 |
+
'key' => 'foo',
|
89 |
+
'value' => 'bar',
|
90 |
+
),
|
91 |
+
),
|
92 |
+
) );
|
93 |
+
$ids = wp_list_pluck( $activity['activities'], 'id' );
|
94 |
+
$this->assertEquals( $ids, array( $a1 ) );
|
95 |
+
}
|
96 |
+
|
97 |
+
public function test_get_with_meta_query_two_clauses_with_or_relation() {
|
98 |
+
$now = time();
|
99 |
+
$a1 = $this->factory->activity->create( array(
|
100 |
+
'recorded_time' => date( 'Y-m-d H:i:s', $now ),
|
101 |
+
) );
|
102 |
+
$a2 = $this->factory->activity->create( array(
|
103 |
+
'recorded_time' => date( 'Y-m-d H:i:s', $now - 60 ),
|
104 |
+
) );
|
105 |
+
$a3 = $this->factory->activity->create( array(
|
106 |
+
'recorded_time' => date( 'Y-m-d H:i:s', $now - 120 ),
|
107 |
+
) );
|
108 |
+
bp_activity_update_meta( $a1, 'foo', 'bar' );
|
109 |
+
bp_activity_update_meta( $a2, 'foo', 'bar' );
|
110 |
+
bp_activity_update_meta( $a1, 'baz', 'barry' );
|
111 |
+
|
112 |
+
$activity = BP_Activity_Activity::get( array(
|
113 |
+
'meta_query' => array(
|
114 |
+
'relation' => 'OR',
|
115 |
+
array(
|
116 |
+
'key' => 'foo',
|
117 |
+
'value' => 'bar',
|
118 |
+
),
|
119 |
+
array(
|
120 |
+
'key' => 'baz',
|
121 |
+
'value' => 'barry',
|
122 |
+
),
|
123 |
+
),
|
124 |
+
) );
|
125 |
+
|
126 |
+
$ids = wp_list_pluck( $activity['activities'], 'id' );
|
127 |
+
$this->assertEquals( array( $a1, $a2 ), $ids );
|
128 |
+
$this->assertEquals( 2, $activity['total'] );
|
129 |
+
}
|
130 |
+
|
131 |
+
/**
|
132 |
+
* @group get
|
133 |
+
*/
|
134 |
+
public function test_get_with_search_terms() {
|
135 |
+
$a1 = $this->factory->activity->create( array(
|
136 |
+
'content' => 'Boone is a cool guy',
|
137 |
+
) );
|
138 |
+
$a2 = $this->factory->activity->create( array(
|
139 |
+
'content' => 'No he isn\'t',
|
140 |
+
) );
|
141 |
+
|
142 |
+
$activity = BP_Activity_Activity::get( array(
|
143 |
+
'search_terms' => 'cool',
|
144 |
+
) );
|
145 |
+
$ids = wp_list_pluck( $activity['activities'], 'id' );
|
146 |
+
$this->assertEquals( $ids, array( $a1 ) );
|
147 |
+
}
|
148 |
+
|
149 |
+
/**
|
150 |
+
* @group get
|
151 |
+
*/
|
152 |
+
public function test_get_with_display_comments_threaded() {
|
153 |
+
$now = time();
|
154 |
+
$a1 = $this->factory->activity->create( array(
|
155 |
+
'content' => 'Life Rules',
|
156 |
+
'recorded_time' => date( 'Y-m-d H:i:s', $now ),
|
157 |
+
) );
|
158 |
+
$a2 = $this->factory->activity->create( array(
|
159 |
+
'content' => 'Life Drools',
|
160 |
+
'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ),
|
161 |
+
) );
|
162 |
+
$a3 = bp_activity_new_comment( array(
|
163 |
+
'activity_id' => $a1,
|
164 |
+
'content' => 'Candy is good',
|
165 |
+
'recorded_time' => date( 'Y-m-d H:i:s', $now - 50 ),
|
166 |
+
) );
|
167 |
+
|
168 |
+
$activity = BP_Activity_Activity::get( array(
|
169 |
+
'display_comments' => 'threaded',
|
170 |
+
) );
|
171 |
+
|
172 |
+
// Kinda crummy, but let's construct a skeleton
|
173 |
+
$expected = array(
|
174 |
+
$a1 => array( $a3 ),
|
175 |
+
$a2 => array(),
|
176 |
+
);
|
177 |
+
|
178 |
+
$found = array();
|
179 |
+
foreach ( $activity['activities'] as $a ) {
|
180 |
+
$found[ $a->id ] = ! empty( $a->children ) ? array_keys( $a->children ) : array();
|
181 |
+
}
|
182 |
+
|
183 |
+
$this->assertEquals( $expected, $found );
|
184 |
+
}
|
185 |
+
|
186 |
+
/**
|
187 |
+
* @group get
|
188 |
+
*/
|
189 |
+
public function test_get_with_display_comments_stream() {
|
190 |
+
$now = time();
|
191 |
+
$a1 = $this->factory->activity->create( array(
|
192 |
+
'content' => 'Life Rules',
|
193 |
+
'recorded_time' => date( 'Y-m-d H:i:s', $now ),
|
194 |
+
) );
|
195 |
+
$a2 = $this->factory->activity->create( array(
|
196 |
+
'content' => 'Life Drools',
|
197 |
+
'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ),
|
198 |
+
) );
|
199 |
+
|
200 |
+
// bp_activity_new_comment() doesn't allow date_recorded
|
201 |
+
$a3 = bp_activity_add( array(
|
202 |
+
'action' => sprintf( __( '%s posted a new activity comment', 'buddypress' ), bp_get_loggedin_user_link() ) ,
|
203 |
+
'content' => 'Candy is good',
|
204 |
+
'component' => buddypress()->activity->id,
|
205 |
+
'type' => 'activity_comment',
|
206 |
+
'user_id' => bp_loggedin_user_id(),
|
207 |
+
'item_id' => $a1,
|
208 |
+
'secondary_item_id' => $a1,
|
209 |
+
'recorded_time' => date( 'Y-m-d H:i:s', $now - 50 ),
|
210 |
+
) );
|
211 |
+
|
212 |
+
$activity = BP_Activity_Activity::get( array(
|
213 |
+
'display_comments' => 'stream',
|
214 |
+
) );
|
215 |
+
$ids = wp_list_pluck( $activity['activities'], 'id' );
|
216 |
+
$this->assertEquals( array( $a1, $a3, $a2 ), $ids );
|
217 |
+
}
|
218 |
+
|
219 |
+
/**
|
220 |
+
* @group get
|
221 |
+
*/
|
222 |
+
public function test_get_with_display_comments_false() {
|
223 |
+
$now = time();
|
224 |
+
$a1 = $this->factory->activity->create( array(
|
225 |
+
'content' => 'Life Rules',
|
226 |
+
'recorded_time' => date( 'Y-m-d H:i:s', $now ),
|
227 |
+
) );
|
228 |
+
$a2 = $this->factory->activity->create( array(
|
229 |
+
'content' => 'Life Drools',
|
230 |
+
'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ),
|
231 |
+
) );
|
232 |
+
$a3 = bp_activity_new_comment( array(
|
233 |
+
'activity_id' => $a1,
|
234 |
+
'content' => 'Candy is good',
|
235 |
+
'recorded_time' => date( 'Y-m-d H:i:s', $now - 50 ),
|
236 |
+
) );
|
237 |
+
|
238 |
+
$activity = BP_Activity_Activity::get( array(
|
239 |
+
'display_comments' => false,
|
240 |
+
) );
|
241 |
+
$ids = wp_list_pluck( $activity['activities'], 'id' );
|
242 |
+
$this->assertEquals( array( $a1, $a2 ), $ids );
|
243 |
+
}
|
244 |
+
|
245 |
+
/**
|
246 |
+
* @group get_id
|
247 |
+
*/
|
248 |
+
public function test_get_id_with_item_id() {
|
249 |
+
$a1 = $this->factory->activity->create( array(
|
250 |
+
'item_id' => 523,
|
251 |
+
) );
|
252 |
+
$a2 = $this->factory->activity->create( array(
|
253 |
+
'item_id' => 1888,
|
254 |
+
) );
|
255 |
+
|
256 |
+
$activity = BP_Activity_Activity::get_id( false, false, false, 523, false, false, false, false );
|
257 |
+
$this->assertEquals( $a1, $activity );
|
258 |
+
}
|
259 |
+
|
260 |
+
/**
|
261 |
+
* @group get_id
|
262 |
+
*/
|
263 |
+
public function test_get_id_with_secondary_item_id() {
|
264 |
+
$a1 = $this->factory->activity->create( array(
|
265 |
+
'secondary_item_id' => 523,
|
266 |
+
) );
|
267 |
+
$a2 = $this->factory->activity->create( array(
|
268 |
+
'secondary_content' => 1888,
|
269 |
+
) );
|
270 |
+
|
271 |
+
$activity = BP_Activity_Activity::get_id( false, false, false, false, 523, false, false, false );
|
272 |
+
$this->assertEquals( $a1, $activity );
|
273 |
+
}
|
274 |
+
|
275 |
+
/**
|
276 |
+
* @group delete
|
277 |
+
*/
|
278 |
+
public function test_delete_with_item_id() {
|
279 |
+
$a1 = $this->factory->activity->create( array(
|
280 |
+
'item_id' => 523,
|
281 |
+
) );
|
282 |
+
$a2 = $this->factory->activity->create( array(
|
283 |
+
'item_id' => 1888,
|
284 |
+
) );
|
285 |
+
|
286 |
+
$activity = BP_Activity_Activity::delete( array(
|
287 |
+
'item_id' => 523,
|
288 |
+
) );
|
289 |
+
$this->assertEquals( array( $a1 ), $activity );
|
290 |
+
}
|
291 |
+
|
292 |
+
/**
|
293 |
+
* @group delete
|
294 |
+
*/
|
295 |
+
public function test_delete_with_secondary_item_id() {
|
296 |
+
$a1 = $this->factory->activity->create( array(
|
297 |
+
'secondary_item_id' => 523,
|
298 |
+
) );
|
299 |
+
$a2 = $this->factory->activity->create( array(
|
300 |
+
'secondary_item_id' => 1888,
|
301 |
+
) );
|
302 |
+
|
303 |
+
$activity = BP_Activity_Activity::delete( array(
|
304 |
+
'secondary_item_id' => 523,
|
305 |
+
) );
|
306 |
+
$this->assertEquals( array( $a1 ), $activity );
|
307 |
+
}
|
308 |
+
}
|
@@ -0,0 +1,208 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @group activity
|
4 |
+
*/
|
5 |
+
class BP_Tests_Activity_Functions extends BP_UnitTestCase {
|
6 |
+
protected $old_current_user = 0;
|
7 |
+
|
8 |
+
public function setUp() {
|
9 |
+
parent::setUp();
|
10 |
+
|
11 |
+
$this->old_current_user = get_current_user_id();
|
12 |
+
$this->set_current_user( $this->factory->user->create( array( 'role' => 'subscriber' ) ) );
|
13 |
+
}
|
14 |
+
|
15 |
+
public function tearDown() {
|
16 |
+
parent::tearDown();
|
17 |
+
$this->set_current_user( $this->old_current_user );
|
18 |
+
}
|
19 |
+
|
20 |
+
/**
|
21 |
+
* @ticket BP4488
|
22 |
+
*/
|
23 |
+
public function test_thumbnail_content_images() {
|
24 |
+
// No images
|
25 |
+
$post_content = 'foo bar';
|
26 |
+
$this->assertEquals( bp_activity_thumbnail_content_images( $post_content ), 'foo bar' );
|
27 |
+
|
28 |
+
// Image first, no caption. See #BP4488
|
29 |
+
$post_content = '<img src="http://example.com/foo.jpg" alt="foo" width="40" height="40" class="alignnone size-full wp-image-236" /> foo bar';
|
30 |
+
$this->assertEquals( bp_activity_thumbnail_content_images( $post_content ), '<img src="http://example.com/foo.jpg" width="40" height="40" alt="Thumbnail" class="align-left thumbnail" /> foo bar' );
|
31 |
+
|
32 |
+
// Image first, caption. See #BP4488
|
33 |
+
$post_content = '[caption id="attachment_236" align="alignnone" width="40"]<img src="http://example.com/foo.jpg" alt="FOO!" width="40" height="40" class="size-full wp-image-236" /> FOO![/caption] Awesome.';
|
34 |
+
$this->assertEquals( bp_activity_thumbnail_content_images( $post_content ), '<img src="http://example.com/foo.jpg" width="40" height="40" alt="Thumbnail" class="align-left thumbnail" /> Awesome.' );
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* @group delete
|
39 |
+
*/
|
40 |
+
public function test_delete_activity_and_meta() {
|
41 |
+
// create an activity update
|
42 |
+
$parent_activity = $this->factory->activity->create( array(
|
43 |
+
'type' => 'activity_update',
|
44 |
+
) );
|
45 |
+
|
46 |
+
// create some activity comments
|
47 |
+
$comment_one = $this->factory->activity->create( array(
|
48 |
+
'type' => 'activity_comment',
|
49 |
+
'item_id' => $parent_activity,
|
50 |
+
'secondary_item_id' => $parent_activity,
|
51 |
+
) );
|
52 |
+
|
53 |
+
$comment_two = $this->factory->activity->create( array(
|
54 |
+
'type' => 'activity_comment',
|
55 |
+
'item_id' => $parent_activity,
|
56 |
+
'secondary_item_id' => $parent_activity,
|
57 |
+
) );
|
58 |
+
|
59 |
+
// add some meta to the activity items
|
60 |
+
bp_activity_update_meta( $parent_activity, 'foo', 'bar' );
|
61 |
+
bp_activity_update_meta( $comment_one, 'foo', 'bar' );
|
62 |
+
bp_activity_update_meta( $comment_two, 'foo', 'bar' );
|
63 |
+
|
64 |
+
// now delete the parent activity item
|
65 |
+
// this should hopefully delete the associated comments and meta entries
|
66 |
+
bp_activity_delete( array(
|
67 |
+
'id' => $parent_activity
|
68 |
+
) );
|
69 |
+
|
70 |
+
// now fetch the deleted activity entries
|
71 |
+
$get = bp_activity_get( array(
|
72 |
+
'in' => array( $parent_activity, $comment_one, $comment_two ),
|
73 |
+
'display_comments' => 'stream'
|
74 |
+
) );
|
75 |
+
|
76 |
+
// activities should equal zero
|
77 |
+
$this->assertEquals( 0, $get['total'] );
|
78 |
+
|
79 |
+
// now fetch activity meta for the deleted activity entries
|
80 |
+
$m1 = bp_activity_get_meta( $parent_activity );
|
81 |
+
$m2 = bp_activity_get_meta( $comment_one );
|
82 |
+
$m3 = bp_activity_get_meta( $comment_two );
|
83 |
+
|
84 |
+
// test if activity meta entries still exist
|
85 |
+
$this->assertEquals( false, $m1 );
|
86 |
+
$this->assertEquals( false, $m2 );
|
87 |
+
$this->assertEquals( false, $m3 );
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* @group bp_activity_update_meta
|
92 |
+
* @ticket BP5180
|
93 |
+
*/
|
94 |
+
public function test_bp_activity_update_meta_with_line_breaks() {
|
95 |
+
$a = $this->factory->activity->create();
|
96 |
+
$meta_value = 'Foo!
|
97 |
+
|
98 |
+
|
99 |
+
Bar!';
|
100 |
+
bp_activity_update_meta( $a, 'linebreak_test', $meta_value );
|
101 |
+
$this->assertEquals( $meta_value, bp_activity_get_meta( $a, 'linebreak_test' ) );
|
102 |
+
}
|
103 |
+
|
104 |
+
/**
|
105 |
+
* @group bp_activity_update_meta
|
106 |
+
* @ticket BP5083
|
107 |
+
*/
|
108 |
+
public function test_bp_activity_update_meta_with_0() {
|
109 |
+
$a = $this->factory->activity->create();
|
110 |
+
$meta_value = 0;
|
111 |
+
|
112 |
+
bp_activity_update_meta( $a, '0_test', $meta_value );
|
113 |
+
|
114 |
+
$this->assertNotSame( false, bp_activity_get_meta( $a, '0_test' ) );
|
115 |
+
}
|
116 |
+
|
117 |
+
/**
|
118 |
+
* @group bp_activity_get_user_mentionname
|
119 |
+
*/
|
120 |
+
public function test_bp_activity_get_user_mentionname_compatibilitymode_off() {
|
121 |
+
add_filter( 'bp_is_username_compatibility_mode', '__return_false' );
|
122 |
+
|
123 |
+
$u = $this->create_user( array(
|
124 |
+
'user_login' => 'foo bar baz',
|
125 |
+
'user_nicename' => 'foo-bar-baz',
|
126 |
+
) );
|
127 |
+
|
128 |
+
$this->assertEquals( 'foo-bar-baz', bp_activity_get_user_mentionname( $u ) );
|
129 |
+
|
130 |
+
remove_filter( 'bp_is_username_compatibility_mode', '__return_false' );
|
131 |
+
}
|
132 |
+
|
133 |
+
/**
|
134 |
+
* @group bp_activity_get_user_mentionname
|
135 |
+
*/
|
136 |
+
public function test_bp_activity_get_user_mentionname_compatibilitymode_on() {
|
137 |
+
add_filter( 'bp_is_username_compatibility_mode', '__return_true' );
|
138 |
+
|
139 |
+
$u1 = $this->create_user( array(
|
140 |
+
'user_login' => 'foo bar baz',
|
141 |
+
'user_nicename' => 'foo-bar-baz',
|
142 |
+
) );
|
143 |
+
|
144 |
+
$u2 = $this->create_user( array(
|
145 |
+
'user_login' => 'foo.bar.baz',
|
146 |
+
'user_nicename' => 'foo-bar-baz',
|
147 |
+
) );
|
148 |
+
|
149 |
+
$this->assertEquals( 'foo-bar-baz', bp_activity_get_user_mentionname( $u1 ) );
|
150 |
+
$this->assertEquals( 'foo.bar.baz', bp_activity_get_user_mentionname( $u2 ) );
|
151 |
+
|
152 |
+
remove_filter( 'bp_is_username_compatibility_mode', '__return_true' );
|
153 |
+
}
|
154 |
+
|
155 |
+
/**
|
156 |
+
* @group bp_activity_get_userid_from_mentionname
|
157 |
+
*/
|
158 |
+
public function test_bp_activity_get_userid_from_mentionname_compatibilitymode_off() {
|
159 |
+
add_filter( 'bp_is_username_compatibility_mode', '__return_false' );
|
160 |
+
|
161 |
+
$u = $this->create_user( array(
|
162 |
+
'user_login' => 'foo bar baz',
|
163 |
+
'user_nicename' => 'foo-bar-baz',
|
164 |
+
) );
|
165 |
+
|
166 |
+
$this->assertEquals( $u, bp_activity_get_userid_from_mentionname( 'foo-bar-baz' ) );
|
167 |
+
|
168 |
+
remove_filter( 'bp_is_username_compatibility_mode', '__return_false' );
|
169 |
+
}
|
170 |
+
|
171 |
+
/**
|
172 |
+
* @group bp_activity_get_userid_from_mentionname
|
173 |
+
*/
|
174 |
+
public function test_bp_activity_get_userid_from_mentionname_compatibilitymode_on() {
|
175 |
+
add_filter( 'bp_is_username_compatibility_mode', '__return_true' );
|
176 |
+
|
177 |
+
// all spaces are hyphens
|
178 |
+
$u1 = $this->create_user( array(
|
179 |
+
'user_login' => 'foo bar baz',
|
180 |
+
'user_nicename' => 'foobarbaz',
|
181 |
+
) );
|
182 |
+
|
183 |
+
// no spaces are hyphens
|
184 |
+
$u2 = $this->create_user( array(
|
185 |
+
'user_login' => 'foo-bar-baz-1',
|
186 |
+
'user_nicename' => 'foobarbaz-1',
|
187 |
+
) );
|
188 |
+
|
189 |
+
// some spaces are hyphens
|
190 |
+
$u3 = $this->create_user( array(
|
191 |
+
'user_login' => 'foo bar-baz 2',
|
192 |
+
'user_nicename' => 'foobarbaz-2',
|
193 |
+
) );
|
194 |
+
|
195 |
+
$u4 = $this->create_user( array(
|
196 |
+
'user_login' => 'foo.bar.baz',
|
197 |
+
'user_nicename' => 'foo-bar-baz',
|
198 |
+
) );
|
199 |
+
|
200 |
+
$this->assertEquals( $u1, bp_activity_get_userid_from_mentionname( 'foo-bar-baz' ) );
|
201 |
+
$this->assertEquals( $u2, bp_activity_get_userid_from_mentionname( 'foo-bar-baz-1' ) );
|
202 |
+
$this->assertEquals( $u3, bp_activity_get_userid_from_mentionname( 'foo-bar-baz-2' ) );
|
203 |
+
$this->assertEquals( $u4, bp_activity_get_userid_from_mentionname( 'foo.bar.baz' ) );
|
204 |
+
|
205 |
+
remove_filter( 'bp_is_username_compatibility_mode', '__return_true' );
|
206 |
+
}
|
207 |
+
|
208 |
+
}
|
@@ -0,0 +1,256 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @group activity
|
4 |
+
*/
|
5 |
+
class BP_Tests_Activity_Template extends BP_UnitTestCase {
|
6 |
+
protected $old_current_user = 0;
|
7 |
+
|
8 |
+
public function setUp() {
|
9 |
+
parent::setUp();
|
10 |
+
|
11 |
+
$this->old_current_user = get_current_user_id();
|
12 |
+
$this->set_current_user( $this->factory->user->create( array( 'role' => 'subscriber' ) ) );
|
13 |
+
}
|
14 |
+
|
15 |
+
public function tearDown() {
|
16 |
+
parent::tearDown();
|
17 |
+
$this->set_current_user( $this->old_current_user );
|
18 |
+
}
|
19 |
+
|
20 |
+
/**
|
21 |
+
* @ticket BP4735
|
22 |
+
*/
|
23 |
+
public function test_user_can_delete() {
|
24 |
+
global $bp;
|
25 |
+
|
26 |
+
$a = $this->factory->activity->create( array(
|
27 |
+
'type' => 'activity_update',
|
28 |
+
) );
|
29 |
+
|
30 |
+
// User can delete his own items
|
31 |
+
$activity = $this->factory->activity->get_object_by_id( $a );
|
32 |
+
$this->assertTrue( bp_activity_user_can_delete( $activity ) );
|
33 |
+
|
34 |
+
// Stash original user
|
35 |
+
$original_user = get_current_user_id();
|
36 |
+
|
37 |
+
// Logged-out user can't delete
|
38 |
+
$this->set_current_user( 0 );
|
39 |
+
$this->assertFalse( bp_activity_user_can_delete( $activity ) );
|
40 |
+
|
41 |
+
// Miscellaneous user can't delete
|
42 |
+
$misc_user = $this->factory->user->create( array( 'role' => 'subscriber' ) );
|
43 |
+
$this->set_current_user( $misc_user );
|
44 |
+
$this->assertFalse( bp_activity_user_can_delete( $activity ) );
|
45 |
+
|
46 |
+
// Item admin can delete
|
47 |
+
$is_single_item = $bp->is_single_item;
|
48 |
+
$bp->is_single_item = true;
|
49 |
+
|
50 |
+
$is_item_admin = $bp->is_item_admin;
|
51 |
+
$bp->is_item_admin = true;
|
52 |
+
|
53 |
+
$this->assertTrue( bp_activity_user_can_delete( $activity ) );
|
54 |
+
|
55 |
+
$bp->is_single_item = $is_single_item;
|
56 |
+
$bp->is_item_admin = $is_item_admin;
|
57 |
+
$this->set_current_user( $original_user );
|
58 |
+
}
|
59 |
+
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Make sure that action filters ('activity_update', etc) work when
|
63 |
+
* limiting query to user favorites
|
64 |
+
*
|
65 |
+
* @ticket BP4872
|
66 |
+
*/
|
67 |
+
public function test_bp_has_activities_favorites_action_filter() {
|
68 |
+
$user_id = $this->factory->user->create( array( 'role' => 'subscriber' ) );
|
69 |
+
|
70 |
+
$now = time();
|
71 |
+
|
72 |
+
$a1 = $this->factory->activity->create( array(
|
73 |
+
'type' => 'activity_update',
|
74 |
+
'recorded_time' => date( 'Y-m-d H:i:s', $now ),
|
75 |
+
) );
|
76 |
+
|
77 |
+
$a2 = $this->factory->activity->create( array(
|
78 |
+
'type' => 'joined_group',
|
79 |
+
'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ),
|
80 |
+
) );
|
81 |
+
|
82 |
+
bp_activity_add_user_favorite( $a1, $user_id );
|
83 |
+
bp_activity_add_user_favorite( $a2, $user_id );
|
84 |
+
|
85 |
+
// groan. It sucks that you have to invoke the global
|
86 |
+
global $activities_template;
|
87 |
+
|
88 |
+
// Case 1: no action filter
|
89 |
+
bp_has_activities( array(
|
90 |
+
'user_id' => $user_id,
|
91 |
+
'scope' => 'favorites',
|
92 |
+
) );
|
93 |
+
|
94 |
+
// The formatting of $activities_template->activities is messed
|
95 |
+
// up, so we're just going to look at the IDs. This should be
|
96 |
+
// fixed in BP at some point
|
97 |
+
$ids = wp_list_pluck( $activities_template->activities, 'id' );
|
98 |
+
|
99 |
+
$this->assertEquals( array( $a1, $a2 ), $ids );
|
100 |
+
|
101 |
+
$activities_template = null;
|
102 |
+
|
103 |
+
// Case 2: action filter
|
104 |
+
bp_has_activities( array(
|
105 |
+
'user_id' => $user_id,
|
106 |
+
'scope' => 'favorites',
|
107 |
+
'action' => 'activity_update',
|
108 |
+
) );
|
109 |
+
|
110 |
+
global $wpdb, $bp;
|
111 |
+
|
112 |
+
$ids = wp_list_pluck( $activities_template->activities, 'id' );
|
113 |
+
|
114 |
+
$this->assertEquals( array( $a1 ), $ids );
|
115 |
+
|
116 |
+
$activities_template = null;
|
117 |
+
}
|
118 |
+
|
119 |
+
/**
|
120 |
+
* Integration test for 'meta_query' param
|
121 |
+
*/
|
122 |
+
function test_bp_has_activities_with_meta_query() {
|
123 |
+
$a1 = $this->factory->activity->create();
|
124 |
+
$a2 = $this->factory->activity->create();
|
125 |
+
bp_activity_update_meta( $a1, 'foo', 'bar' );
|
126 |
+
|
127 |
+
global $activities_template;
|
128 |
+
bp_has_activities( array(
|
129 |
+
'meta_query' => array(
|
130 |
+
array(
|
131 |
+
'key' => 'foo',
|
132 |
+
'value' => 'bar',
|
133 |
+
),
|
134 |
+
),
|
135 |
+
) );
|
136 |
+
|
137 |
+
$ids = wp_list_pluck( $activities_template->activities, 'id' );
|
138 |
+
$this->assertEquals( $ids, array( $a1 ) );
|
139 |
+
}
|
140 |
+
|
141 |
+
/**
|
142 |
+
* @ticket BP5029
|
143 |
+
* @group bp_has_activities
|
144 |
+
*/
|
145 |
+
public function test_bp_has_activities_with_display_comments_false() {
|
146 |
+
$now = time();
|
147 |
+
$a1 = $this->factory->activity->create( array(
|
148 |
+
'content' => 'Life Rules',
|
149 |
+
'recorded_time' => date( 'Y-m-d H:i:s', $now ),
|
150 |
+
) );
|
151 |
+
$a2 = $this->factory->activity->create( array(
|
152 |
+
'content' => 'Life Drools',
|
153 |
+
'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ),
|
154 |
+
) );
|
155 |
+
$a3 = bp_activity_new_comment( array(
|
156 |
+
'activity_id' => $a1,
|
157 |
+
'content' => 'Candy is good',
|
158 |
+
'recorded_time' => date( 'Y-m-d H:i:s', $now - 50 ),
|
159 |
+
) );
|
160 |
+
|
161 |
+
global $activities_template;
|
162 |
+
bp_has_activities( array(
|
163 |
+
'display_comments' => false,
|
164 |
+
) );
|
165 |
+
$ids = wp_list_pluck( $activities_template->activities, 'id' );
|
166 |
+
|
167 |
+
$this->assertEquals( array( $a1, $a2 ), wp_parse_id_list( $ids ) );
|
168 |
+
|
169 |
+
}
|
170 |
+
|
171 |
+
/**
|
172 |
+
* @ticket BP5029
|
173 |
+
* @group bp_has_activities
|
174 |
+
*/
|
175 |
+
public function test_bp_has_activities_with_display_comments_0() {
|
176 |
+
$now = time();
|
177 |
+
$a1 = $this->factory->activity->create( array(
|
178 |
+
'content' => 'Life Rules',
|
179 |
+
'recorded_time' => date( 'Y-m-d H:i:s', $now ),
|
180 |
+
) );
|
181 |
+
$a2 = $this->factory->activity->create( array(
|
182 |
+
'content' => 'Life Drools',
|
183 |
+
'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ),
|
184 |
+
) );
|
185 |
+
$a3 = bp_activity_new_comment( array(
|
186 |
+
'activity_id' => $a1,
|
187 |
+
'content' => 'Candy is good',
|
188 |
+
'recorded_time' => date( 'Y-m-d H:i:s', $now - 50 ),
|
189 |
+
) );
|
190 |
+
|
191 |
+
global $activities_template;
|
192 |
+
bp_has_activities( array(
|
193 |
+
'display_comments' => 0,
|
194 |
+
) );
|
195 |
+
$ids = wp_list_pluck( $activities_template->activities, 'id' );
|
196 |
+
|
197 |
+
$this->assertEquals( array( $a1, $a2 ), wp_parse_id_list( $ids ) );
|
198 |
+
|
199 |
+
}
|
200 |
+
|
201 |
+
/**
|
202 |
+
* @ticket BP5029
|
203 |
+
* @group bp_has_activities
|
204 |
+
*/
|
205 |
+
public function test_bp_has_activities_with_display_comments_0_querystring() {
|
206 |
+
$now = time();
|
207 |
+
$a1 = $this->factory->activity->create( array(
|
208 |
+
'content' => 'Life Rules',
|
209 |
+
'recorded_time' => date( 'Y-m-d H:i:s', $now ),
|
210 |
+
) );
|
211 |
+
$a2 = $this->factory->activity->create( array(
|
212 |
+
'content' => 'Life Drools',
|
213 |
+
'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ),
|
214 |
+
) );
|
215 |
+
$a3 = bp_activity_new_comment( array(
|
216 |
+
'activity_id' => $a1,
|
217 |
+
'content' => 'Candy is good',
|
218 |
+
'recorded_time' => date( 'Y-m-d H:i:s', $now - 50 ),
|
219 |
+
) );
|
220 |
+
|
221 |
+
global $activities_template;
|
222 |
+
bp_has_activities( 'display_comments=0' );
|
223 |
+
$ids = wp_list_pluck( $activities_template->activities, 'id' );
|
224 |
+
|
225 |
+
$this->assertEquals( array( $a1, $a2 ), $ids );
|
226 |
+
|
227 |
+
}
|
228 |
+
|
229 |
+
/**
|
230 |
+
* @ticket BP5029
|
231 |
+
* @group bp_has_activities
|
232 |
+
*/
|
233 |
+
public function test_bp_has_activities_with_display_comments_none_querystring() {
|
234 |
+
$now = time();
|
235 |
+
$a1 = $this->factory->activity->create( array(
|
236 |
+
'content' => 'Life Rules',
|
237 |
+
'recorded_time' => date( 'Y-m-d H:i:s', $now ),
|
238 |
+
) );
|
239 |
+
$a2 = $this->factory->activity->create( array(
|
240 |
+
'content' => 'Life Drools',
|
241 |
+
'recorded_time' => date( 'Y-m-d H:i:s', $now - 100 ),
|
242 |
+
) );
|
243 |
+
$a3 = bp_activity_new_comment( array(
|
244 |
+
'activity_id' => $a1,
|
245 |
+
'content' => 'Candy is good',
|
246 |
+
'recorded_time' => date( 'Y-m-d H:i:s', $now - 50 ),
|
247 |
+
) );
|
248 |
+
|
249 |
+
global $activities_template;
|
250 |
+
bp_has_activities( 'display_comments=none' );
|
251 |
+
$ids = wp_list_pluck( $activities_template->activities, 'id' );
|
252 |
+
|
253 |
+
$this->assertEquals( array( $a1, $a2 ), $ids );
|
254 |
+
|
255 |
+
}
|
256 |
+
}
|
@@ -0,0 +1,123 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @group admin
|
4 |
+
*/
|
5 |
+
class BP_Tests_Admin_Functions extends BP_UnitTestCase {
|
6 |
+
protected $old_current_user = 0;
|
7 |
+
|
8 |
+
public function setUp() {
|
9 |
+
parent::setUp();
|
10 |
+
$this->old_current_user = get_current_user_id();
|
11 |
+
$this->set_current_user( $this->create_user( array( 'role' => 'administrator' ) ) );
|
12 |
+
|
13 |
+
if ( ! function_exists( 'bp_admin' ) ) {
|
14 |
+
require_once( BP_PLUGIN_DIR . 'bp-core/bp-core-admin.php' );
|
15 |
+
}
|
16 |
+
|
17 |
+
if ( ! function_exists( 'bp_new_site' ) ) {
|
18 |
+
bp_admin();
|
19 |
+
}
|
20 |
+
}
|
21 |
+
|
22 |
+
public function tearDown() {
|
23 |
+
parent::tearDown();
|
24 |
+
$this->set_current_user( $this->old_current_user );
|
25 |
+
}
|
26 |
+
|
27 |
+
public function test_bp_admin_list_table_current_bulk_action() {
|
28 |
+
$_REQUEST['action'] = 'foo';
|
29 |
+
$_REQUEST['action2'] = '-1';
|
30 |
+
$this->assertEquals( bp_admin_list_table_current_bulk_action(), 'foo' );
|
31 |
+
|
32 |
+
$_REQUEST['action'] = '-1';
|
33 |
+
$_REQUEST['action2'] = 'foo';
|
34 |
+
$this->assertEquals( bp_admin_list_table_current_bulk_action(), 'foo' );
|
35 |
+
|
36 |
+
$_REQUEST['action'] = 'bar';
|
37 |
+
$_REQUEST['action2'] = 'foo';
|
38 |
+
$this->assertEquals( bp_admin_list_table_current_bulk_action(), 'foo' );
|
39 |
+
}
|
40 |
+
|
41 |
+
public function test_bp_core_admin_get_active_components_from_submitted_settings() {
|
42 |
+
$get_action = isset( $_GET['action'] ) ? $_GET['action'] : null;
|
43 |
+
$ac = buddypress()->active_components;
|
44 |
+
|
45 |
+
// Standard deactivation from All screen
|
46 |
+
unset( $_GET['action'] );
|
47 |
+
buddypress()->active_components = array(
|
48 |
+
'activity' => 1,
|
49 |
+
'friends' => 1,
|
50 |
+
'groups' => 1,
|
51 |
+
'members' => 1,
|
52 |
+
'messages' => 1,
|
53 |
+
'settings' => 1,
|
54 |
+
'xprofile' => 1,
|
55 |
+
);
|
56 |
+
|
57 |
+
$submitted = array(
|
58 |
+
'groups' => 1,
|
59 |
+
'members' => 1,
|
60 |
+
'messages' => 1,
|
61 |
+
'settings' => 1,
|
62 |
+
'xprofile' => 1,
|
63 |
+
);
|
64 |
+
|
65 |
+
$this->assertEquals( bp_core_admin_get_active_components_from_submitted_settings( $submitted ), array( 'groups' => 1, 'members' => 1, 'messages' => 1, 'settings' => 1, 'xprofile' => 1 ) );
|
66 |
+
|
67 |
+
// Activating deactivated components from the Inactive screen
|
68 |
+
$_GET['action'] = 'inactive';
|
69 |
+
buddypress()->active_components = array(
|
70 |
+
'activity' => 1,
|
71 |
+
'members' => 1,
|
72 |
+
'messages' => 1,
|
73 |
+
'settings' => 1,
|
74 |
+
'xprofile' => 1,
|
75 |
+
);
|
76 |
+
|
77 |
+
$submitted2 = array(
|
78 |
+
'groups' => 1,
|
79 |
+
);
|
80 |
+
|
81 |
+
$this->assertEquals( bp_core_admin_get_active_components_from_submitted_settings( $submitted2 ), array( 'activity' => 1, 'groups' => 1, 'members' => 1, 'messages' => 1, 'settings' => 1, 'xprofile' => 1 ) );
|
82 |
+
|
83 |
+
// Activating from the Retired screen
|
84 |
+
$_GET['action'] = 'retired';
|
85 |
+
buddypress()->active_components = array(
|
86 |
+
'activity' => 1,
|
87 |
+
'members' => 1,
|
88 |
+
'messages' => 1,
|
89 |
+
'settings' => 1,
|
90 |
+
'xprofile' => 1,
|
91 |
+
);
|
92 |
+
|
93 |
+
$submitted3 = array(
|
94 |
+
'forums' => 1,
|
95 |
+
);
|
96 |
+
|
97 |
+
$this->assertEquals( bp_core_admin_get_active_components_from_submitted_settings( $submitted3 ), array( 'activity' => 1, 'forums' => 1, 'members' => 1, 'messages' => 1, 'settings' => 1, 'xprofile' => 1 ) );
|
98 |
+
|
99 |
+
// Deactivating from the Retired screen
|
100 |
+
$_GET['action'] = 'retired';
|
101 |
+
buddypress()->active_components = array(
|
102 |
+
'activity' => 1,
|
103 |
+
'forums' => 1,
|
104 |
+
'members' => 1,
|
105 |
+
'messages' => 1,
|
106 |
+
'settings' => 1,
|
107 |
+
'xprofile' => 1,
|
108 |
+
);
|
109 |
+
|
110 |
+
$submitted4 = array();
|
111 |
+
|
112 |
+
$this->assertEquals( bp_core_admin_get_active_components_from_submitted_settings( $submitted4 ), array( 'activity' => 1, 'members' => 1, 'messages' => 1, 'settings' => 1, 'xprofile' => 1 ) );
|
113 |
+
|
114 |
+
// reset
|
115 |
+
if ( $get_action ) {
|
116 |
+
$_GET['action'] = $get_action;
|
117 |
+
} else {
|
118 |
+
unset( $_GET['action'] );
|
119 |
+
}
|
120 |
+
|
121 |
+
buddypress()->active_components = $ac;
|
122 |
+
}
|
123 |
+
}
|
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @group blogs
|
5 |
+
*/
|
6 |
+
class BP_Tests_BP_Blogs_Blog_TestCases extends BP_UnitTestCase {
|
7 |
+
public function setUp() {
|
8 |
+
parent::setUp();
|
9 |
+
}
|
10 |
+
|
11 |
+
public function tearDown() {
|
12 |
+
parent::tearDown();
|
13 |
+
}
|
14 |
+
|
15 |
+
public function test_get_with_search_terms() {
|
16 |
+
if ( ! is_multisite() ) {
|
17 |
+
return;
|
18 |
+
}
|
19 |
+
|
20 |
+
$old_user = get_current_user_id();
|
21 |
+
|
22 |
+
$u = $this->create_user();
|
23 |
+
$this->set_current_user( $u );
|
24 |
+
$b = $this->factory->blog->create( array(
|
25 |
+
'title' => 'The Foo Bar Blog',
|
26 |
+
'user_id' => $u,
|
27 |
+
) );
|
28 |
+
bp_blogs_record_existing_blogs();
|
29 |
+
|
30 |
+
// make the blog public or it won't turn up in generic results
|
31 |
+
update_blog_option( $b, 'blog_public', '1' );
|
32 |
+
|
33 |
+
$blogs = BP_Blogs_Blog::get( 'active', false, false, 0, 'Foo' );
|
34 |
+
$blog_ids = wp_list_pluck( $blogs['blogs'], 'blog_id' );
|
35 |
+
|
36 |
+
$this->assertEquals( array( $b ), $blog_ids );
|
37 |
+
|
38 |
+
$this->set_current_user( $old_user );
|
39 |
+
}
|
40 |
+
|
41 |
+
public function test_search_blogs() {
|
42 |
+
if ( ! is_multisite() ) {
|
43 |
+
return;
|
44 |
+
}
|
45 |
+
|
46 |
+
$old_user = get_current_user_id();
|
47 |
+
|
48 |
+
$u = $this->create_user();
|
49 |
+
$this->set_current_user( $u );
|
50 |
+
$b = $this->factory->blog->create( array(
|
51 |
+
'title' => 'The Foo Bar Blog',
|
52 |
+
'user_id' => $u,
|
53 |
+
) );
|
54 |
+
bp_blogs_record_existing_blogs();
|
55 |
+
|
56 |
+
// make the blog public or it won't turn up in generic results
|
57 |
+
update_blog_option( $b, 'blog_public', '1' );
|
58 |
+
|
59 |
+
$blogs = BP_Blogs_Blog::search_blogs( 'Foo' );
|
60 |
+
$blog_ids = wp_list_pluck( $blogs['blogs'], 'blog_id' );
|
61 |
+
|
62 |
+
$this->assertEquals( array( $b ), $blog_ids );
|
63 |
+
|
64 |
+
$this->set_current_user( $old_user );
|
65 |
+
}
|
66 |
+
|
67 |
+
}
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @group core
|
4 |
+
* @group avatars
|
5 |
+
*/
|
6 |
+
class BP_Tests_Avatars extends BP_UnitTestCase {
|
7 |
+
protected $old_current_user = 0;
|
8 |
+
|
9 |
+
public function setUp() {
|
10 |
+
parent::setUp();
|
11 |
+
|
12 |
+
$this->old_current_user = get_current_user_id();
|
13 |
+
$this->administrator = $this->factory->user->create( array( 'role' => 'administrator' ) );
|
14 |
+
wp_set_current_user( $this->administrator );
|
15 |
+
}
|
16 |
+
|
17 |
+
public function tearDown() {
|
18 |
+
parent::tearDown();
|
19 |
+
wp_set_current_user( $this->old_current_user );
|
20 |
+
}
|
21 |
+
|
22 |
+
/**
|
23 |
+
* @ticket 4948
|
24 |
+
*/
|
25 |
+
function test_avatars_on_non_root_blog() {
|
26 |
+
// Do not pass 'Go', do not collect $200
|
27 |
+
if ( ! is_multisite() ) {
|
28 |
+
return;
|
29 |
+
}
|
30 |
+
|
31 |
+
// switch to BP root blog if necessary
|
32 |
+
if ( bp_get_root_blog_id() != get_current_blog_id() ) {
|
33 |
+
$this->go_to_root();
|
34 |
+
}
|
35 |
+
|
36 |
+
// get BP root blog's upload directory data
|
37 |
+
$upload_dir = wp_upload_dir();
|
38 |
+
|
39 |
+
restore_current_blog();
|
40 |
+
|
41 |
+
// create new subsite
|
42 |
+
$blog_id = $this->factory->blog->create( array(
|
43 |
+
'user_id' => $this->administrator,
|
44 |
+
'title' => 'Test Title'
|
45 |
+
) );
|
46 |
+
|
47 |
+
// emulate a page load on the new sub-site
|
48 |
+
$this->go_to( get_blog_option( $blog_id, 'siteurl' ) );
|
49 |
+
|
50 |
+
// test to see if the upload dir is correct
|
51 |
+
$this->assertEquals( $upload_dir['baseurl'], bp_core_avatar_url() );
|
52 |
+
|
53 |
+
// reset globals
|
54 |
+
$this->go_to_root();
|
55 |
+
}
|
56 |
+
}
|
@@ -0,0 +1,124 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @group core
|
5 |
+
*/
|
6 |
+
class BP_Tests_BP_Core_User_TestCases extends BP_UnitTestCase {
|
7 |
+
protected $old_current_user = 0;
|
8 |
+
|
9 |
+
public function setUp() {
|
10 |
+
parent::setUp();
|
11 |
+
}
|
12 |
+
|
13 |
+
public function tearDown() {
|
14 |
+
parent::tearDown();
|
15 |
+
}
|
16 |
+
|
17 |
+
/**
|
18 |
+
* @expectedDeprecated BP_Core_User::get_users
|
19 |
+
*/
|
20 |
+
public function test_get_users_with_exclude_querystring() {
|
21 |
+
$u1 = $this->create_user();
|
22 |
+
$u2 = $this->create_user();
|
23 |
+
$u3 = $this->create_user();
|
24 |
+
|
25 |
+
$exclude_qs = $u1 . ',junkstring,' . $u3;
|
26 |
+
|
27 |
+
$users = BP_Core_User::get_users( 'active', 0, 1, 0, false, false, true, $exclude_qs );
|
28 |
+
$user_ids = wp_parse_id_list( wp_list_pluck( $users['users'], 'id' ) );
|
29 |
+
|
30 |
+
$this->assertEquals( array( $u2 ), $user_ids );
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* @expectedDeprecated BP_Core_User::get_users
|
35 |
+
*/
|
36 |
+
public function test_get_users_with_exclude_array() {
|
37 |
+
$u1 = $this->create_user();
|
38 |
+
$u2 = $this->create_user();
|
39 |
+
$u3 = $this->create_user();
|
40 |
+
|
41 |
+
$exclude_array = array(
|
42 |
+
$u1,
|
43 |
+
'junkstring',
|
44 |
+
$u3,
|
45 |
+
);
|
46 |
+
|
47 |
+
$users = BP_Core_User::get_users( 'active', 0, 1, 0, false, false, true, $exclude_array );
|
48 |
+
$user_ids = wp_parse_id_list( wp_list_pluck( $users['users'], 'id' ) );
|
49 |
+
|
50 |
+
$this->assertEquals( array( $u2 ), $user_ids );
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* @expectedDeprecated BP_Core_User::get_users
|
55 |
+
*/
|
56 |
+
public function test_get_users_with_include_querystring() {
|
57 |
+
$u1 = $this->create_user( array(
|
58 |
+
'last_activity' => gmdate( 'Y-m-d H:i:s' ),
|
59 |
+
) );
|
60 |
+
$u2 = $this->create_user( array(
|
61 |
+
'last_activity' => gmdate( 'Y-m-d H:i:s', time() - 1000 ),
|
62 |
+
) );
|
63 |
+
$u3 = $this->create_user( array(
|
64 |
+
'last_activity' => gmdate( 'Y-m-d H:i:s', time() - 50 ),
|
65 |
+
) );
|
66 |
+
|
67 |
+
$include_qs = $u1 . ',junkstring,' . $u3;
|
68 |
+
|
69 |
+
$users = BP_Core_User::get_users( 'active', 0, 1, 0, $include_qs );
|
70 |
+
$user_ids = wp_parse_id_list( wp_list_pluck( $users['users'], 'id' ) );
|
71 |
+
|
72 |
+
$this->assertEquals( array( $u1, $u3 ), $user_ids );
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* @expectedDeprecated BP_Core_User::get_users
|
77 |
+
*/
|
78 |
+
public function test_get_users_with_include_array() {
|
79 |
+
$u1 = $this->create_user( array(
|
80 |
+
'last_activity' => gmdate( 'Y-m-d H:i:s' ),
|
81 |
+
) );
|
82 |
+
$u2 = $this->create_user( array(
|
83 |
+
'last_activity' => gmdate( 'Y-m-d H:i:s', time() - 1000 ),
|
84 |
+
) );
|
85 |
+
$u3 = $this->create_user( array(
|
86 |
+
'last_activity' => gmdate( 'Y-m-d H:i:s', time() - 50 ),
|
87 |
+
) );
|
88 |
+
|
89 |
+
|
90 |
+
$include_array = array(
|
91 |
+
$u1,
|
92 |
+
'junkstring',
|
93 |
+
$u3,
|
94 |
+
);
|
95 |
+
|
96 |
+
$users = BP_Core_User::get_users( 'active', 0, 1, 0, $include_array );
|
97 |
+
$user_ids = wp_list_pluck( $users['users'], 'id' );
|
98 |
+
|
99 |
+
// typecast...ugh
|
100 |
+
$user_ids = array_map( 'intval', $user_ids );
|
101 |
+
|
102 |
+
$this->assertEquals( array( $u1, $u3 ), $user_ids );
|
103 |
+
}
|
104 |
+
|
105 |
+
public function test_get_specific_users() {
|
106 |
+
$u1 = $this->create_user();
|
107 |
+
$u2 = $this->create_user();
|
108 |
+
$u3 = $this->create_user();
|
109 |
+
|
110 |
+
$include_array = array(
|
111 |
+
$u1,
|
112 |
+
'junkstring',
|
113 |
+
$u3,
|
114 |
+
);
|
115 |
+
|
116 |
+
$users = BP_Core_User::get_specific_users( $include_array );
|
117 |
+
$user_ids = wp_parse_id_list( wp_list_pluck( $users['users'], 'id' ) );
|
118 |
+
|
119 |
+
$this->assertEquals( array( $u1, $u3 ), $user_ids );
|
120 |
+
}
|
121 |
+
|
122 |
+
|
123 |
+
|
124 |
+
}
|
@@ -0,0 +1,301 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @group core
|
5 |
+
* @group BP_User_Query
|
6 |
+
*/
|
7 |
+
class BP_Tests_BP_User_Query_TestCases extends BP_UnitTestCase {
|
8 |
+
protected $old_current_user = 0;
|
9 |
+
|
10 |
+
public function setUp() {
|
11 |
+
parent::setUp();
|
12 |
+
|
13 |
+
$this->old_current_user = get_current_user_id();
|
14 |
+
$this->set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) );
|
15 |
+
}
|
16 |
+
|
17 |
+
public function tearDown() {
|
18 |
+
parent::tearDown();
|
19 |
+
$this->set_current_user( $this->old_current_user );
|
20 |
+
}
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Checks that user_id returns friends
|
24 |
+
*/
|
25 |
+
public function test_bp_user_query_friends() {
|
26 |
+
$u1 = $this->create_user();
|
27 |
+
$u2 = $this->create_user();
|
28 |
+
$u3 = $this->create_user();
|
29 |
+
friends_add_friend( $u1, $u2, true );
|
30 |
+
|
31 |
+
$q = new BP_User_Query( array(
|
32 |
+
'user_id' => $u2,
|
33 |
+
) );
|
34 |
+
|
35 |
+
$friends = is_array( $q->results ) ? array_values( $q->results ) : array();
|
36 |
+
$friend_ids = wp_list_pluck( $friends, 'ID' );
|
37 |
+
$this->assertEquals( $friend_ids, array( $u1 ) );
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* @ticket 4938
|
42 |
+
*/
|
43 |
+
public function test_bp_user_query_friends_with_include() {
|
44 |
+
$u1 = $this->create_user();
|
45 |
+
$u2 = $this->create_user();
|
46 |
+
$u3 = $this->create_user();
|
47 |
+
$u4 = $this->create_user();
|
48 |
+
friends_add_friend( $u1, $u2, true );
|
49 |
+
friends_add_friend( $u1, $u3, true );
|
50 |
+
|
51 |
+
$q = new BP_User_Query( array(
|
52 |
+
'user_id' => $u1,
|
53 |
+
|
54 |
+
// Represents an independent filter passed by a plugin
|
55 |
+
// u4 is not a friend of u1 and should not be returned
|
56 |
+
'include' => array( $u2, $u4 ),
|
57 |
+
) );
|
58 |
+
|
59 |
+
$friends = is_array( $q->results ) ? array_values( $q->results ) : array();
|
60 |
+
$friend_ids = wp_list_pluck( $friends, 'ID' );
|
61 |
+
$this->assertEquals( $friend_ids, array( $u2 ) );
|
62 |
+
}
|
63 |
+
|
64 |
+
public function test_bp_user_query_friends_with_include_but_zero_friends() {
|
65 |
+
$u1 = $this->create_user();
|
66 |
+
$u2 = $this->create_user();
|
67 |
+
$u3 = $this->create_user();
|
68 |
+
$u4 = $this->create_user();
|
69 |
+
|
70 |
+
$q = new BP_User_Query( array(
|
71 |
+
'user_id' => $u1,
|
72 |
+
|
73 |
+
// Represents an independent filter passed by a plugin
|
74 |
+
// u4 is not a friend of u1 and should not be returned
|
75 |
+
'include' => array( $u2, $u4 ),
|
76 |
+
) );
|
77 |
+
|
78 |
+
$friends = is_array( $q->results ) ? array_values( $q->results ) : array();
|
79 |
+
$friend_ids = wp_list_pluck( $friends, 'ID' );
|
80 |
+
$this->assertEquals( $friend_ids, array() );
|
81 |
+
}
|
82 |
+
|
83 |
+
public function test_bp_user_query_sort_by_popular() {
|
84 |
+
$u1 = $this->create_user();
|
85 |
+
$u2 = $this->create_user();
|
86 |
+
$u3 = $this->create_user();
|
87 |
+
$u4 = $this->create_user();
|
88 |
+
|
89 |
+
bp_update_user_meta( $u1, bp_get_user_meta_key( 'total_friend_count' ), '5' );
|
90 |
+
bp_update_user_meta( $u2, bp_get_user_meta_key( 'total_friend_count' ), '90' );
|
91 |
+
bp_update_user_meta( $u3, bp_get_user_meta_key( 'total_friend_count' ), '101' );
|
92 |
+
bp_update_user_meta( $u4, bp_get_user_meta_key( 'total_friend_count' ), '3002' );
|
93 |
+
|
94 |
+
$q = new BP_User_Query( array(
|
95 |
+
'type' => 'popular',
|
96 |
+
) );
|
97 |
+
|
98 |
+
$users = is_array( $q->results ) ? array_values( $q->results ) : array();
|
99 |
+
$user_ids = wp_parse_id_list( wp_list_pluck( $users, 'ID' ) );
|
100 |
+
|
101 |
+
$expected = array( $u4, $u3, $u2, $u1 );
|
102 |
+
$this->assertEquals( $expected, $user_ids );
|
103 |
+
}
|
104 |
+
|
105 |
+
/**
|
106 |
+
* @group online
|
107 |
+
*/
|
108 |
+
public function test_bp_user_query_type_online() {
|
109 |
+
$now = time();
|
110 |
+
$u1 = $this->create_user( array(
|
111 |
+
'last_activity' => date( 'Y-m-d H:i:s', $now ),
|
112 |
+
) );
|
113 |
+
$u2 = $this->create_user( array(
|
114 |
+
'last_activity' => date( 'Y-m-d H:i:s', $now - 60*13 ),
|
115 |
+
) );
|
116 |
+
$u3 = $this->create_user( array(
|
117 |
+
'last_activity' => date( 'Y-m-d H:i:s', $now - 60*16 ),
|
118 |
+
) );
|
119 |
+
|
120 |
+
$q = new BP_User_Query( array(
|
121 |
+
'type' => 'online',
|
122 |
+
) );
|
123 |
+
|
124 |
+
$users = is_array( $q->results ) ? array_values( $q->results ) : array();
|
125 |
+
$user_ids = wp_parse_id_list( wp_list_pluck( $users, 'ID' ) );
|
126 |
+
$this->assertEquals( array( $u1, $u2 ), $user_ids );
|
127 |
+
}
|
128 |
+
|
129 |
+
/**
|
130 |
+
* @group online
|
131 |
+
*/
|
132 |
+
public function test_bp_user_query_type_online_five_minute_interval() {
|
133 |
+
$now = time();
|
134 |
+
$u1 = $this->create_user( array(
|
135 |
+
'last_activity' => date( 'Y-m-d H:i:s', $now ),
|
136 |
+
) );
|
137 |
+
$u2 = $this->create_user( array(
|
138 |
+
'last_activity' => date( 'Y-m-d H:i:s', $now - 60*4 ),
|
139 |
+
) );
|
140 |
+
$u3 = $this->create_user( array(
|
141 |
+
'last_activity' => date( 'Y-m-d H:i:s', $now - 60*6 ),
|
142 |
+
) );
|
143 |
+
|
144 |
+
add_filter( 'bp_user_query_online_interval', create_function( '', 'return 5;' ) );
|
145 |
+
|
146 |
+
$q = new BP_User_Query( array(
|
147 |
+
'type' => 'online',
|
148 |
+
) );
|
149 |
+
|
150 |
+
$users = is_array( $q->results ) ? array_values( $q->results ) : array();
|
151 |
+
$user_ids = wp_parse_id_list( wp_list_pluck( $users, 'ID' ) );
|
152 |
+
$this->assertEquals( array( $u1, $u2 ), $user_ids );
|
153 |
+
}
|
154 |
+
|
155 |
+
|
156 |
+
public function test_bp_user_query_search_with_apostrophe() {
|
157 |
+
// Apostrophe. Search_terms must escaped to mimic POST payload
|
158 |
+
$user_id = $this->create_user();
|
159 |
+
xprofile_set_field_data( 1, $user_id, "Foo'Bar" );
|
160 |
+
$q = new BP_User_Query( array( 'search_terms' => "oo\'Ba", ) );
|
161 |
+
|
162 |
+
$found_user_id = null;
|
163 |
+
if ( ! empty( $q->results ) ) {
|
164 |
+
$found_user = array_pop( $q->results );
|
165 |
+
$found_user_id = $found_user->ID;
|
166 |
+
}
|
167 |
+
|
168 |
+
$this->assertEquals( $user_id, $found_user_id );
|
169 |
+
}
|
170 |
+
|
171 |
+
public function test_bp_user_query_search_with_percent_sign() {
|
172 |
+
|
173 |
+
// LIKE special character: %
|
174 |
+
$user_id = $this->create_user();
|
175 |
+
xprofile_set_field_data( 1, $user_id, "Foo%Bar" );
|
176 |
+
$q = new BP_User_Query( array( 'search_terms' => "oo%Bar", ) );
|
177 |
+
|
178 |
+
$found_user_id = null;
|
179 |
+
if ( ! empty( $q->results ) ) {
|
180 |
+
$found_user = array_pop( $q->results );
|
181 |
+
$found_user_id = $found_user->ID;
|
182 |
+
}
|
183 |
+
|
184 |
+
$this->assertEquals( $user_id, $found_user_id );
|
185 |
+
|
186 |
+
}
|
187 |
+
|
188 |
+
public function test_bp_user_query_search_with_underscore() {
|
189 |
+
|
190 |
+
// LIKE special character: _
|
191 |
+
$user_id = $this->create_user();
|
192 |
+
xprofile_set_field_data( 1, $user_id, "Foo_Bar" );
|
193 |
+
$q = new BP_User_Query( array( 'search_terms' => "oo_Bar", ) );
|
194 |
+
|
195 |
+
$found_user_id = null;
|
196 |
+
if ( ! empty( $q->results ) ) {
|
197 |
+
$found_user = array_pop( $q->results );
|
198 |
+
$found_user_id = $found_user->ID;
|
199 |
+
}
|
200 |
+
|
201 |
+
$this->assertEquals( $user_id, $found_user_id );
|
202 |
+
}
|
203 |
+
|
204 |
+
/**
|
205 |
+
* @group exclude
|
206 |
+
*/
|
207 |
+
public function test_bp_user_query_with_exclude() {
|
208 |
+
// Grab list of existing users who should also be excluded
|
209 |
+
global $wpdb;
|
210 |
+
$existing_users = $wpdb->get_col( "SELECT ID FROM {$wpdb->users}" );
|
211 |
+
|
212 |
+
$u1 = $this->create_user();
|
213 |
+
$u2 = $this->create_user();
|
214 |
+
|
215 |
+
$exclude = array_merge( array( $u1 ), $existing_users );
|
216 |
+
$q = new BP_User_Query( array( 'exclude' => $exclude, ) );
|
217 |
+
|
218 |
+
$found_user_ids = null;
|
219 |
+
if ( ! empty( $q->results ) ) {
|
220 |
+
$found_user_ids = array_values( wp_parse_id_list( wp_list_pluck( $q->results, 'ID' ) ) );
|
221 |
+
}
|
222 |
+
|
223 |
+
$this->assertEquals( array( $u2 ), $found_user_ids );
|
224 |
+
}
|
225 |
+
|
226 |
+
/**
|
227 |
+
* @group type
|
228 |
+
* @group spam
|
229 |
+
*/
|
230 |
+
public function test_bp_user_query_type_alphabetical_spam_xprofileon() {
|
231 |
+
if ( is_multisite() ) {
|
232 |
+
return;
|
233 |
+
}
|
234 |
+
|
235 |
+
// Make sure xprofile is on
|
236 |
+
$xprofile_toggle = isset( buddypress()->active_components['xprofile'] );
|
237 |
+
buddypress()->active_components['xprofile'] = 1;
|
238 |
+
add_filter( 'bp_disable_profile_sync', '__return_false' );
|
239 |
+
|
240 |
+
$u1 = $this->create_user();
|
241 |
+
$u2 = $this->create_user();
|
242 |
+
|
243 |
+
global $wpdb;
|
244 |
+
bp_core_process_spammer_status( $u1, 'spam' );
|
245 |
+
|
246 |
+
$q = new BP_User_Query( array( 'type' => 'alphabetical', ) );
|
247 |
+
|
248 |
+
// Restore xprofile setting
|
249 |
+
if ( $xprofile_toggle ) {
|
250 |
+
buddypress()->active_components['xprofile'] = 1;
|
251 |
+
} else {
|
252 |
+
unset( buddypress()->active_components['xprofile'] );
|
253 |
+
}
|
254 |
+
remove_filter( 'bp_disable_profile_sync', '__return_false' );
|
255 |
+
|
256 |
+
$found_user_ids = null;
|
257 |
+
|
258 |
+
if ( ! empty( $q->results ) ) {
|
259 |
+
$found_user_ids = array_values( wp_parse_id_list( wp_list_pluck( $q->results, 'ID' ) ) );
|
260 |
+
}
|
261 |
+
|
262 |
+
// Do a assertNotContains because there are weird issues with user #1 as created by WP
|
263 |
+
$this->assertNotContains( $u1, $found_user_ids );
|
264 |
+
}
|
265 |
+
|
266 |
+
/**
|
267 |
+
* @group type
|
268 |
+
* @group spam
|
269 |
+
*/
|
270 |
+
public function test_bp_user_query_type_alphabetical_spam_xprofileoff() {
|
271 |
+
$u1 = $this->create_user();
|
272 |
+
$u2 = $this->create_user();
|
273 |
+
|
274 |
+
// Make sure xprofile and profile sync are off
|
275 |
+
$xprofile_toggle = isset( buddypress()->active_components['xprofile'] );
|
276 |
+
buddypress()->active_components['xprofile'] = 0;
|
277 |
+
add_filter( 'bp_disable_profile_sync', '__return_false' );
|
278 |
+
|
279 |
+
bp_core_process_spammer_status( $u1, 'spam' );
|
280 |
+
|
281 |
+
$q = new BP_User_Query( array( 'type' => 'alphabetical', ) );
|
282 |
+
|
283 |
+
// Restore xprofile setting
|
284 |
+
if ( $xprofile_toggle ) {
|
285 |
+
buddypress()->active_components['xprofile'] = 1;
|
286 |
+
} else {
|
287 |
+
unset( buddypress()->active_components['xprofile'] );
|
288 |
+
}
|
289 |
+
remove_filter( 'bp_disable_profile_sync', '__return_false' );
|
290 |
+
|
291 |
+
$found_user_ids = null;
|
292 |
+
|
293 |
+
if ( ! empty( $q->results ) ) {
|
294 |
+
$found_user_ids = array_values( wp_parse_id_list( wp_list_pluck( $q->results, 'ID' ) ) );
|
295 |
+
}
|
296 |
+
|
297 |
+
// Do a assertNotContains because there are weird issues with user #1 as created by WP
|
298 |
+
$this->assertNotContains( $u1, $found_user_ids );
|
299 |
+
}
|
300 |
+
|
301 |
+
}
|
@@ -0,0 +1,258 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @group core
|
5 |
+
*/
|
6 |
+
|
7 |
+
class BP_Tests_Core_Functions extends BP_UnitTestCase {
|
8 |
+
/**
|
9 |
+
* @group bp_esc_sql_order
|
10 |
+
*/
|
11 |
+
public function test_bp_esc_sql_order_ASC() {
|
12 |
+
$this->assertEquals( 'ASC', bp_esc_sql_order( 'ASC' ) );
|
13 |
+
}
|
14 |
+
|
15 |
+
/**
|
16 |
+
* @group bp_esc_sql_order
|
17 |
+
*/
|
18 |
+
public function test_bp_esc_sql_order_DESC() {
|
19 |
+
$this->assertEquals( 'DESC', bp_esc_sql_order( 'DESC' ) );
|
20 |
+
}
|
21 |
+
|
22 |
+
/**
|
23 |
+
* @group bp_esc_sql_order
|
24 |
+
*/
|
25 |
+
public function test_bp_esc_sql_order_desc_lowercase() {
|
26 |
+
$this->assertEquals( 'DESC', bp_esc_sql_order( 'desc' ) );
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* @group bp_esc_sql_order
|
31 |
+
*/
|
32 |
+
public function test_bp_esc_sql_order_desc_whitespace() {
|
33 |
+
$this->assertEquals( 'DESC', bp_esc_sql_order( ' desc ' ) );
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* @group bp_esc_sql_order
|
38 |
+
*/
|
39 |
+
public function test_bp_esc_sql_order_invalid() {
|
40 |
+
$this->assertEquals( 'ASC', bp_esc_sql_order( 'In ur base killin ur d00dz' ) );
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* @group bp_core_time_since
|
45 |
+
*/
|
46 |
+
public function test_bp_core_time_since_years_months() {
|
47 |
+
$now = time();
|
48 |
+
$then = $now - ( 3 * YEAR_IN_SECONDS ) - ( 3 * 30 * DAY_IN_SECONDS );
|
49 |
+
$this->assertEquals( '3 years, 3 months ago', bp_core_time_since( $then, $now ) );
|
50 |
+
}
|
51 |
+
|
52 |
+
/**
|
53 |
+
* @group bp_core_time_since
|
54 |
+
*/
|
55 |
+
public function test_bp_core_time_since_years_nomonths() {
|
56 |
+
$now = time();
|
57 |
+
$then = $now - ( 3 * YEAR_IN_SECONDS );
|
58 |
+
$this->assertEquals( '3 years ago', bp_core_time_since( $then, $now ) );
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* @group bp_core_time_since
|
63 |
+
*/
|
64 |
+
public function test_bp_core_time_since_months_weeks() {
|
65 |
+
$now = time();
|
66 |
+
$then = $now - ( 3 * 30 * DAY_IN_SECONDS ) - ( 3 * WEEK_IN_SECONDS );
|
67 |
+
$this->assertEquals( '3 months, 3 weeks ago', bp_core_time_since( $then, $now ) );
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* @group bp_core_time_since
|
72 |
+
*/
|
73 |
+
public function test_bp_core_time_since_months_noweeks() {
|
74 |
+
$now = time();
|
75 |
+
$then = $now - ( 3 * 30 * DAY_IN_SECONDS );
|
76 |
+
$this->assertEquals( '3 months ago', bp_core_time_since( $then, $now ) );
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* @group bp_core_time_since
|
81 |
+
*/
|
82 |
+
public function test_bp_core_time_since_weeks_days() {
|
83 |
+
$now = time();
|
84 |
+
$then = $now - ( 3 * WEEK_IN_SECONDS ) - ( 3 * DAY_IN_SECONDS );
|
85 |
+
$this->assertEquals( '3 weeks, 3 days ago', bp_core_time_since( $then, $now ) );
|
86 |
+
}
|
87 |
+
|
88 |
+
/**
|
89 |
+
* @group bp_core_time_since
|
90 |
+
*/
|
91 |
+
public function test_bp_core_time_since_weeks_nodays() {
|
92 |
+
$now = time();
|
93 |
+
$then = $now - ( 3 * WEEK_IN_SECONDS );
|
94 |
+
$this->assertEquals( '3 weeks ago', bp_core_time_since( $then, $now ) );
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* @group bp_core_time_since
|
99 |
+
*/
|
100 |
+
public function test_bp_core_time_since_days_hours() {
|
101 |
+
$now = time();
|
102 |
+
$then = $now - ( 3 * DAY_IN_SECONDS ) - ( 3 * HOUR_IN_SECONDS );
|
103 |
+
$this->assertEquals( '3 days, 3 hours ago', bp_core_time_since( $then, $now ) );
|
104 |
+
}
|
105 |
+
|
106 |
+
/**
|
107 |
+
* @group bp_core_time_since
|
108 |
+
*/
|
109 |
+
public function test_bp_core_time_since_days_nohours() {
|
110 |
+
$now = time();
|
111 |
+
$then = $now - ( 3 * DAY_IN_SECONDS );
|
112 |
+
$this->assertEquals( '3 days ago', bp_core_time_since( $then, $now ) );
|
113 |
+
}
|
114 |
+
|
115 |
+
/**
|
116 |
+
* @group bp_core_time_since
|
117 |
+
*/
|
118 |
+
public function test_bp_core_time_since_hours_minutes() {
|
119 |
+
$now = time();
|
120 |
+
$then = $now - ( 3 * HOUR_IN_SECONDS ) - ( 3 * MINUTE_IN_SECONDS );
|
121 |
+
$this->assertEquals( '3 hours, 3 minutes ago', bp_core_time_since( $then, $now ) );
|
122 |
+
}
|
123 |
+
|
124 |
+
/**
|
125 |
+
* @group bp_core_time_since
|
126 |
+
*/
|
127 |
+
public function test_bp_core_time_since_hours_nominutes() {
|
128 |
+
$now = time();
|
129 |
+
$then = $now - ( 3 * HOUR_IN_SECONDS );
|
130 |
+
$this->assertEquals( '3 hours ago', bp_core_time_since( $then, $now ) );
|
131 |
+
}
|
132 |
+
|
133 |
+
/**
|
134 |
+
* @group bp_core_time_since
|
135 |
+
* @ticket BP5017
|
136 |
+
*/
|
137 |
+
public function test_bp_core_time_since_minutes_seconds() {
|
138 |
+
$now = time();
|
139 |
+
$then = $now - ( 3 * MINUTE_IN_SECONDS ) - 3;
|
140 |
+
$this->assertEquals( '3 minutes ago', bp_core_time_since( $then, $now ) );
|
141 |
+
}
|
142 |
+
|
143 |
+
/**
|
144 |
+
* @group bp_core_time_since
|
145 |
+
*/
|
146 |
+
public function test_bp_core_time_since_minutes_noseconds() {
|
147 |
+
$now = time();
|
148 |
+
$then = $now - ( 3 * MINUTE_IN_SECONDS );
|
149 |
+
$this->assertEquals( '3 minutes ago', bp_core_time_since( $then, $now ) );
|
150 |
+
}
|
151 |
+
|
152 |
+
/**
|
153 |
+
* @group bp_core_time_since
|
154 |
+
*/
|
155 |
+
public function test_bp_core_time_since_seconds() {
|
156 |
+
$now = time();
|
157 |
+
$then = $now - 3;
|
158 |
+
$this->assertEquals( '3 seconds ago', bp_core_time_since( $then, $now ) );
|
159 |
+
}
|
160 |
+
|
161 |
+
/**
|
162 |
+
* Sanity check for the singular version of 'year'
|
163 |
+
*
|
164 |
+
* @group bp_core_time_since
|
165 |
+
*/
|
166 |
+
public function test_bp_core_time_since_year() {
|
167 |
+
$now = time();
|
168 |
+
$then = $now - YEAR_IN_SECONDS;
|
169 |
+
$this->assertEquals( '1 year ago', bp_core_time_since( $then, $now ) );
|
170 |
+
}
|
171 |
+
|
172 |
+
/**
|
173 |
+
* @group bp_core_time_since
|
174 |
+
*/
|
175 |
+
public function test_bp_core_time_since_rightnow() {
|
176 |
+
$now = time();
|
177 |
+
$then = $now;
|
178 |
+
$this->assertEquals( 'right now', bp_core_time_since( $then, $now ) );
|
179 |
+
}
|
180 |
+
|
181 |
+
/**
|
182 |
+
* @group bp_core_time_since
|
183 |
+
*/
|
184 |
+
public function test_bp_core_time_since_future() {
|
185 |
+
$now = time();
|
186 |
+
$then = $now + 100;
|
187 |
+
$this->assertEquals( 'sometime ago', bp_core_time_since( $then, $now ) );
|
188 |
+
}
|
189 |
+
|
190 |
+
/**
|
191 |
+
* @group bp_alpha_sort_by_key
|
192 |
+
*/
|
193 |
+
public function test_bp_alpha_sort_by_key_arrays() {
|
194 |
+
$items = array(
|
195 |
+
array(
|
196 |
+
'foo' => 'bar',
|
197 |
+
'name' => 'alpha',
|
198 |
+
),
|
199 |
+
array(
|
200 |
+
'foo' => 'bar',
|
201 |
+
'name' => 'charlie',
|
202 |
+
),
|
203 |
+
array(
|
204 |
+
'foo' => 'bar',
|
205 |
+
'name' => 'beta',
|
206 |
+
),
|
207 |
+
);
|
208 |
+
|
209 |
+
$expected = array(
|
210 |
+
array(
|
211 |
+
'foo' => 'bar',
|
212 |
+
'name' => 'alpha',
|
213 |
+
),
|
214 |
+
array(
|
215 |
+
'foo' => 'bar',
|
216 |
+
'name' => 'beta',
|
217 |
+
),
|
218 |
+
array(
|
219 |
+
'foo' => 'bar',
|
220 |
+
'name' => 'charlie',
|
221 |
+
),
|
222 |
+
);
|
223 |
+
|
224 |
+
$this->assertEquals( $expected, bp_alpha_sort_by_key( $items, 'name' ) );
|
225 |
+
}
|
226 |
+
|
227 |
+
/**
|
228 |
+
* @group bp_alpha_sort_by_key
|
229 |
+
*/
|
230 |
+
public function test_bp_alpha_sort_by_key_objects() {
|
231 |
+
$items = array(
|
232 |
+
new stdClass,
|
233 |
+
new stdClass,
|
234 |
+
new stdClass,
|
235 |
+
);
|
236 |
+
$items[0]->foo = 'bar';
|
237 |
+
$items[0]->name = 'alpha';
|
238 |
+
$items[1]->foo = 'bar';
|
239 |
+
$items[1]->name = 'charlie';
|
240 |
+
$items[2]->foo = 'bar';
|
241 |
+
$items[2]->name = 'beta';
|
242 |
+
|
243 |
+
$expected = array(
|
244 |
+
new stdClass,
|
245 |
+
new stdClass,
|
246 |
+
new stdClass,
|
247 |
+
);
|
248 |
+
$expected[0]->foo = 'bar';
|
249 |
+
$expected[0]->name = 'alpha';
|
250 |
+
$expected[1]->foo = 'bar';
|
251 |
+
$expected[1]->name = 'beta';
|
252 |
+
$expected[2]->foo = 'bar';
|
253 |
+
$expected[2]->name = 'charlie';
|
254 |
+
|
255 |
+
$this->assertEquals( $expected, bp_alpha_sort_by_key( $items, 'name' ) );
|
256 |
+
}
|
257 |
+
|
258 |
+
}
|
@@ -0,0 +1,126 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @group friends
|
5 |
+
*/
|
6 |
+
class BP_Tests_BP_Friends_Friendship_TestCases extends BP_UnitTestCase {
|
7 |
+
protected $old_current_user = 0;
|
8 |
+
|
9 |
+
public function setUp() {
|
10 |
+
parent::setUp();
|
11 |
+
|
12 |
+
$this->old_current_user = get_current_user_id();
|
13 |
+
$this->set_current_user( $this->factory->user->create( array( 'role' => 'subscriber' ) ) );
|
14 |
+
}
|
15 |
+
|
16 |
+
public function tearDown() {
|
17 |
+
parent::tearDown();
|
18 |
+
$this->set_current_user( $this->old_current_user );
|
19 |
+
}
|
20 |
+
|
21 |
+
public function test_search_friends() {
|
22 |
+
$u1 = $this->create_user();
|
23 |
+
$u2 = $this->create_user();
|
24 |
+
$u3 = $this->create_user();
|
25 |
+
|
26 |
+
xprofile_set_field_data( 1, $u2, 'Cool Dude' );
|
27 |
+
xprofile_set_field_data( 1, $u3, 'Rock And Roll America Yeah' );
|
28 |
+
|
29 |
+
friends_add_friend( $u1, $u2, true );
|
30 |
+
friends_add_friend( $u1, $u3, true );
|
31 |
+
|
32 |
+
$friends = BP_Friends_Friendship::search_friends( 'Coo', $u1 );
|
33 |
+
$this->assertEquals( array( $u2 ), $friends['friends'] );
|
34 |
+
}
|
35 |
+
|
36 |
+
public function test_get_bulk_last_active() {
|
37 |
+
$u1 = $this->create_user( array(
|
38 |
+
'last_activity' => gmdate( 'Y-m-d H:i:s' ),
|
39 |
+
) );
|
40 |
+
$u2 = $this->create_user( array(
|
41 |
+
'last_activity' => gmdate( 'Y-m-d H:i:s', time() - 1000 ),
|
42 |
+
) );
|
43 |
+
$u3 = $this->create_user( array(
|
44 |
+
'last_activity' => gmdate( 'Y-m-d H:i:s', time() - 50 ),
|
45 |
+
) );
|
46 |
+
|
47 |
+
$friends = BP_Friends_Friendship::get_bulk_last_active( array( $u1, $u2, $u3, 'junk' ) );
|
48 |
+
$friend_ids = wp_list_pluck( $friends, 'user_id' );
|
49 |
+
$this->assertEquals( array( $u1, $u3, $u2 ), $friend_ids );
|
50 |
+
}
|
51 |
+
|
52 |
+
public function test_search_users() {
|
53 |
+
$u1 = $this->create_user();
|
54 |
+
$u2 = $this->create_user();
|
55 |
+
$u3 = $this->create_user();
|
56 |
+
|
57 |
+
xprofile_set_field_data( 1, $u1, 'Freedom Isn\'t Free' );
|
58 |
+
xprofile_set_field_data( 1, $u2, 'Cool Dude' );
|
59 |
+
xprofile_set_field_data( 1, $u3, 'Rock And Roll America Yeah' );
|
60 |
+
|
61 |
+
// Needs a user_id param though it does nothing
|
62 |
+
$friends = BP_Friends_Friendship::search_users( 'Coo', 1 );
|
63 |
+
$this->assertEquals( array( $u2 ), $friends );
|
64 |
+
}
|
65 |
+
|
66 |
+
public function test_search_users_count() {
|
67 |
+
$u1 = $this->create_user();
|
68 |
+
$u2 = $this->create_user();
|
69 |
+
$u3 = $this->create_user();
|
70 |
+
|
71 |
+
xprofile_set_field_data( 1, $u1, 'Freedom Isn\'t Free' );
|
72 |
+
xprofile_set_field_data( 1, $u2, 'Cool Dude' );
|
73 |
+
xprofile_set_field_data( 1, $u3, 'Rock And Roll America Yeah' );
|
74 |
+
|
75 |
+
// Needs a user_id param though it does nothing
|
76 |
+
$friends = BP_Friends_Friendship::search_users_count( 'Coo' );
|
77 |
+
$this->assertEquals( 1, $friends );
|
78 |
+
}
|
79 |
+
|
80 |
+
/**
|
81 |
+
* @group check_is_friend
|
82 |
+
*/
|
83 |
+
public function test_check_is_friend_not_friends() {
|
84 |
+
$u1 = $this->create_user();
|
85 |
+
$u2 = $this->create_user();
|
86 |
+
$this->assertEquals( 'not_friends', BP_Friends_Friendship::check_is_friend( $u1, $u2 ) );
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* @group check_is_friend
|
91 |
+
*/
|
92 |
+
public function test_check_is_friend_pending() {
|
93 |
+
$u1 = $this->create_user();
|
94 |
+
$u2 = $this->create_user();
|
95 |
+
|
96 |
+
$this->setUp_wp_mail();
|
97 |
+
friends_add_friend( $u1, $u2, false );
|
98 |
+
$this->tearDown_wp_mail();
|
99 |
+
|
100 |
+
$this->assertEquals( 'pending', BP_Friends_Friendship::check_is_friend( $u1, $u2 ) );
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* @group check_is_friend
|
105 |
+
*/
|
106 |
+
public function test_check_is_friend_awaiting_response() {
|
107 |
+
$u1 = $this->create_user();
|
108 |
+
$u2 = $this->create_user();
|
109 |
+
|
110 |
+
$this->setUp_wp_mail();
|
111 |
+
friends_add_friend( $u1, $u2, false );
|
112 |
+
$this->tearDown_wp_mail();
|
113 |
+
|
114 |
+
$this->assertEquals( 'awaiting_response', BP_Friends_Friendship::check_is_friend( $u2, $u1 ) );
|
115 |
+
}
|
116 |
+
|
117 |
+
/**
|
118 |
+
* @group check_is_friend
|
119 |
+
*/
|
120 |
+
public function test_check_is_friend_is_friend() {
|
121 |
+
$u1 = $this->create_user();
|
122 |
+
$u2 = $this->create_user();
|
123 |
+
friends_add_friend( $u1, $u2, true );
|
124 |
+
$this->assertEquals( 'is_friend', BP_Friends_Friendship::check_is_friend( $u1, $u2 ) );
|
125 |
+
}
|
126 |
+
}
|
@@ -0,0 +1,225 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
include_once BP_TESTS_DIR . '/assets/group-extensions.php';
|
4 |
+
|
5 |
+
/**
|
6 |
+
* @group groups
|
7 |
+
* @group BP_Group_Extension
|
8 |
+
*/
|
9 |
+
class BP_Tests_Group_Extension_TestCases extends BP_UnitTestCase {
|
10 |
+
public function setUp() {
|
11 |
+
parent::setUp();
|
12 |
+
}
|
13 |
+
|
14 |
+
public function tearDown() {
|
15 |
+
parent::tearDown();
|
16 |
+
}
|
17 |
+
|
18 |
+
public function test_parse_legacy_properties() {
|
19 |
+
$class_name = 'BPTest_Group_Extension_Parse_Legacy_Properties';
|
20 |
+
$class_slug = sanitize_title( $class_name );
|
21 |
+
$e = new $class_name();
|
22 |
+
$e->_register();
|
23 |
+
|
24 |
+
// Test most items separately so we can ignore irrelevant props
|
25 |
+
$l = $e->_get_legacy_properties_converted();
|
26 |
+
$this->assertEquals( $l['name'], $class_name );
|
27 |
+
$this->assertEquals( $l['slug'], $class_slug );
|
28 |
+
$this->assertEquals( $l['visibility'], 'private' );
|
29 |
+
$this->assertEquals( $l['nav_item_position'], 63 );
|
30 |
+
$this->assertEquals( $l['enable_nav_item'], true );
|
31 |
+
$this->assertEquals( $l['nav_item_name'], $class_name . ' Nav' );
|
32 |
+
$this->assertEquals( $l['display_hook'], 'foo_hook' );
|
33 |
+
$this->assertEquals( $l['template_file'], 'foo_template' );
|
34 |
+
|
35 |
+
// Build the screens array manually
|
36 |
+
$expected = array(
|
37 |
+
'create' => array(
|
38 |
+
'name' => $class_name . ' Create',
|
39 |
+
'slug' => $class_slug . '-create',
|
40 |
+
'position' => 58,
|
41 |
+
'enabled' => false,
|
42 |
+
),
|
43 |
+
'edit' => array(
|
44 |
+
'name' => $class_name . ' Edit',
|
45 |
+
'slug' => $class_slug . '-edit',
|
46 |
+
'enabled' => false,
|
47 |
+
),
|
48 |
+
'admin' => array(
|
49 |
+
'enabled' => true,
|
50 |
+
'metabox_context' => 'high',
|
51 |
+
'metabox_priority' => 'side',
|
52 |
+
),
|
53 |
+
);
|
54 |
+
|
55 |
+
$this->assertEquals( $expected, $l['screens'] );
|
56 |
+
}
|
57 |
+
|
58 |
+
public function test_setup_screens_use_global_fallbacks() {
|
59 |
+
$class_name = 'BPTest_Group_Extension_Setup_Screens_Use_Global_Fallbacks';
|
60 |
+
$e = new $class_name();
|
61 |
+
$e->_setup_class_info();
|
62 |
+
$screens = $e->_get_default_screens();
|
63 |
+
|
64 |
+
$fallback = array(
|
65 |
+
'screen_callback' => array( $e, 'settings_screen' ),
|
66 |
+
'screen_save_callback' => array( $e, 'settings_screen_save' ),
|
67 |
+
);
|
68 |
+
$fallbacks = array(
|
69 |
+
'create' => $fallback,
|
70 |
+
'edit' => $fallback,
|
71 |
+
'admin' => $fallback,
|
72 |
+
);
|
73 |
+
|
74 |
+
// strip everything from the screens array but what we we're
|
75 |
+
// testing
|
76 |
+
foreach ( $screens as &$screen ) {
|
77 |
+
foreach ( $screen as $k => $v ) {
|
78 |
+
if ( ! in_array( $k, array( 'screen_callback', 'screen_save_callback' ) ) ) {
|
79 |
+
unset( $screen[ $k ] );
|
80 |
+
}
|
81 |
+
}
|
82 |
+
}
|
83 |
+
|
84 |
+
$this->assertEquals( $fallbacks, $screens );
|
85 |
+
}
|
86 |
+
|
87 |
+
public function test_setup_screens_define_edit_screens_locally() {
|
88 |
+
$class_name = 'BPTest_Group_Extension_Setup_Screens_Define_Edit_Screens_Locally';
|
89 |
+
$e = new $class_name();
|
90 |
+
$e->_setup_class_info();
|
91 |
+
$screens = $e->_get_default_screens();
|
92 |
+
|
93 |
+
$fallback = array(
|
94 |
+
'screen_callback' => array( $e, 'settings_screen' ),
|
95 |
+
'screen_save_callback' => array( $e, 'settings_screen_save' ),
|
96 |
+
);
|
97 |
+
$expected = array(
|
98 |
+
'create' => $fallback,
|
99 |
+
'edit' => array(
|
100 |
+
'screen_callback' => array( $e, 'edit_screen' ),
|
101 |
+
'screen_save_callback' => array( $e, 'edit_screen_save' ),
|
102 |
+
),
|
103 |
+
'admin' => $fallback,
|
104 |
+
);
|
105 |
+
|
106 |
+
// strip everything from the screens array but what we we're
|
107 |
+
// testing
|
108 |
+
foreach ( $screens as &$screen ) {
|
109 |
+
foreach ( $screen as $k => $v ) {
|
110 |
+
if ( ! in_array( $k, array( 'screen_callback', 'screen_save_callback' ) ) ) {
|
111 |
+
unset( $screen[ $k ] );
|
112 |
+
}
|
113 |
+
}
|
114 |
+
}
|
115 |
+
|
116 |
+
$this->assertEquals( $screens, $expected );
|
117 |
+
}
|
118 |
+
|
119 |
+
public function test_parse_args_r() {
|
120 |
+
$a = array(
|
121 |
+
'veggies' => 'yes',
|
122 |
+
'ice_cream' => 'dope',
|
123 |
+
'fruit' => array(
|
124 |
+
'apple' => 'gross',
|
125 |
+
'berries' => array(
|
126 |
+
'blueberries' => array(
|
127 |
+
'in_season' => 'never',
|
128 |
+
'oh' => 'boy',
|
129 |
+
),
|
130 |
+
'cherries' => 'sometimes',
|
131 |
+
),
|
132 |
+
),
|
133 |
+
);
|
134 |
+
|
135 |
+
$b = array(
|
136 |
+
'veggies' => 'no',
|
137 |
+
'cheese' => array(
|
138 |
+
'cheddar' => 'good',
|
139 |
+
),
|
140 |
+
'fruit' => array(
|
141 |
+
'apple' => 'yum',
|
142 |
+
'berries' => array(
|
143 |
+
'strawberries' => 'awesome',
|
144 |
+
'blueberries' => array(
|
145 |
+
'in_season' => 'yes',
|
146 |
+
'out_of_season' => 'no',
|
147 |
+
),
|
148 |
+
),
|
149 |
+
),
|
150 |
+
);
|
151 |
+
|
152 |
+
$expected = array(
|
153 |
+
'veggies' => 'yes',
|
154 |
+
'ice_cream' => 'dope',
|
155 |
+
'cheese' => array(
|
156 |
+
'cheddar' => 'good',
|
157 |
+
),
|
158 |
+
'fruit' => array(
|
159 |
+
'apple' => 'gross',
|
160 |
+
'berries' => array(
|
161 |
+
'strawberries' => 'awesome',
|
162 |
+
'blueberries' => array(
|
163 |
+
'in_season' => 'never',
|
164 |
+
'out_of_season' => 'no',
|
165 |
+
'oh' => 'boy',
|
166 |
+
),
|
167 |
+
'cherries' => 'sometimes',
|
168 |
+
),
|
169 |
+
),
|
170 |
+
);
|
171 |
+
|
172 |
+
$this->assertEquals( $expected, BP_Group_Extension::parse_args_r( $a, $b ) );
|
173 |
+
}
|
174 |
+
|
175 |
+
/**
|
176 |
+
* Config that gets intentionally stored as a direct property of object
|
177 |
+
*/
|
178 |
+
public function test_access_root_property() {
|
179 |
+
$class_name = 'BPTest_Group_Extension_Access_Root_Property';
|
180 |
+
$e = new $class_name();
|
181 |
+
$e->_register();
|
182 |
+
|
183 |
+
$this->assertEquals( 39, $e->nav_item_position );
|
184 |
+
}
|
185 |
+
|
186 |
+
/**
|
187 |
+
* Config that gets registered using init(), but is then accessed via
|
188 |
+
* the legacy location
|
189 |
+
*/
|
190 |
+
public function test_access_init_property_using_legacy_location() {
|
191 |
+
$class_name = 'BPTest_Group_Extension_Access_Init_Property_Using_Legacy_Location';
|
192 |
+
$e = new $class_name();
|
193 |
+
$e->_register();
|
194 |
+
|
195 |
+
$this->assertEquals( 18, $e->create_step_position );
|
196 |
+
}
|
197 |
+
|
198 |
+
/**
|
199 |
+
* Provides settings_screen* and edit_screen*
|
200 |
+
*/
|
201 |
+
public function test_get_screen_callback_fallbacks() {
|
202 |
+
$class_name = 'BPTest_Group_Extension_Get_Screen_Callback_Fallbacks';
|
203 |
+
$e = new $class_name();
|
204 |
+
$e->_register();
|
205 |
+
|
206 |
+
$this->assertEquals( array( $e, 'settings_screen' ), $e->screens['create']['screen_callback'] );
|
207 |
+
$this->assertEquals( array( $e, 'settings_screen_save' ), $e->screens['create']['screen_save_callback'] );
|
208 |
+
$this->assertEquals( array( $e, 'settings_screen' ), $e->screens['admin']['screen_callback'] );
|
209 |
+
$this->assertEquals( array( $e, 'settings_screen_save' ), $e->screens['admin']['screen_save_callback'] );
|
210 |
+
$this->assertEquals( array( $e, 'edit_screen' ), $e->screens['edit']['screen_callback'] );
|
211 |
+
$this->assertEquals( array( $e, 'edit_screen_save' ), $e->screens['edit']['screen_save_callback'] );
|
212 |
+
}
|
213 |
+
|
214 |
+
public function test_has_submit_button() {
|
215 |
+
$a = '<p>Foo bar</p><input type="text" name="awesome" /><input name="save" type="submit" id="saverrrr" />sweet';
|
216 |
+
$this->assertTrue( BP_Group_Extension::has_submit_button( $a ) );
|
217 |
+
|
218 |
+
$b = '<p>Foo bar</p><input type="text" name="awesome" />sweet';
|
219 |
+
$this->assertFalse( BP_Group_Extension::has_submit_button( $b ) );
|
220 |
+
|
221 |
+
// switch the quotation marks
|
222 |
+
$c = "<p>Foo bar</p><input type='text' name='awesome' /><input name='save' type='submit' id='saverrrr' />sweet";
|
223 |
+
$this->assertTrue( BP_Group_Extension::has_submit_button( $c ) );
|
224 |
+
}
|
225 |
+
}
|
@@ -0,0 +1,337 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @group groups
|
4 |
+
* @group BP_Group_Member_Query
|
5 |
+
*/
|
6 |
+
class BP_Tests_BP_Group_Member_Query_TestCases extends BP_UnitTestCase {
|
7 |
+
/**
|
8 |
+
* Make sure that a manual 'include' param is parsed correctly with
|
9 |
+
* BP_Group_Member_Query's limiting of the query to group members
|
10 |
+
*/
|
11 |
+
public function test_with_include() {
|
12 |
+
$g = $this->factory->group->create();
|
13 |
+
$u1 = $this->create_user();
|
14 |
+
$u2 = $this->create_user();
|
15 |
+
$u3 = $this->create_user();
|
16 |
+
$time = time();
|
17 |
+
|
18 |
+
$this->add_user_to_group( $u1, $g, array( 'date_modified' => gmdate( 'Y-m-d H:i:s', $time - 100 ) ) );
|
19 |
+
$this->add_user_to_group( $u2, $g, array( 'date_modified' => gmdate( 'Y-m-d H:i:s', $time - 200 ) ) );
|
20 |
+
|
21 |
+
$query = new BP_Group_Member_Query( array(
|
22 |
+
'group_id' => $g,
|
23 |
+
'include' => array( $u2 ),
|
24 |
+
) );
|
25 |
+
|
26 |
+
$ids = wp_parse_id_list( array_keys( $query->results ) );
|
27 |
+
$this->assertEquals( array( $u2, ), $ids );
|
28 |
+
}
|
29 |
+
|
30 |
+
// Make sure we're falling back on 'member'
|
31 |
+
public function test_with_group_role_null() {
|
32 |
+
$g = $this->factory->group->create();
|
33 |
+
$u1 = $this->create_user();
|
34 |
+
$u2 = $this->create_user();
|
35 |
+
$u3 = $this->create_user();
|
36 |
+
$time = time();
|
37 |
+
|
38 |
+
$this->add_user_to_group( $u1, $g, array( 'date_modified' => gmdate( 'Y-m-d H:i:s', $time - 100 ) ) );
|
39 |
+
$this->add_user_to_group( $u2, $g, array( 'date_modified' => gmdate( 'Y-m-d H:i:s', $time - 200 ) ) );
|
40 |
+
$this->add_user_to_group( $u3, $g, array( 'date_modified' => gmdate( 'Y-m-d H:i:s', $time - 300 ) ) );
|
41 |
+
|
42 |
+
$m1 = new BP_Groups_Member( $u1, $g );
|
43 |
+
$m1->promote( 'admin' );
|
44 |
+
$m2 = new BP_Groups_Member( $u2, $g );
|
45 |
+
$m2->promote( 'mod' );
|
46 |
+
|
47 |
+
$query = new BP_Group_Member_Query( array(
|
48 |
+
'group_id' => $g,
|
49 |
+
) );
|
50 |
+
|
51 |
+
$expected = new BP_Group_Member_Query( array(
|
52 |
+
'group_id' => $g,
|
53 |
+
'group_role' => array( 'member' ),
|
54 |
+
) );
|
55 |
+
|
56 |
+
$this->assertEquals( $expected->results, $query->results );
|
57 |
+
}
|
58 |
+
|
59 |
+
public function test_with_group_role_member() {
|
60 |
+
$g = $this->factory->group->create();
|
61 |
+
$u1 = $this->create_user();
|
62 |
+
$u2 = $this->create_user();
|
63 |
+
$u3 = $this->create_user();
|
64 |
+
$time = time();
|
65 |
+
|
66 |
+
$this->add_user_to_group( $u1, $g, array( 'date_modified' => gmdate( 'Y-m-d H:i:s', $time - 100 ) ) );
|
67 |
+
$this->add_user_to_group( $u2, $g, array( 'date_modified' => gmdate( 'Y-m-d H:i:s', $time - 200 ) ) );
|
68 |
+
$this->add_user_to_group( $u3, $g, array( 'date_modified' => gmdate( 'Y-m-d H:i:s', $time - 300 ) ) );
|
69 |
+
|
70 |
+
$m1 = new BP_Groups_Member( $u1, $g );
|
71 |
+
$m1->promote( 'admin' );
|
72 |
+
$m2 = new BP_Groups_Member( $u2, $g );
|
73 |
+
$m2->promote( 'mod' );
|
74 |
+
|
75 |
+
$query_members = new BP_Group_Member_Query( array(
|
76 |
+
'group_id' => $g,
|
77 |
+
'group_role' => array( 'member' ),
|
78 |
+
) );
|
79 |
+
|
80 |
+
$ids = wp_parse_id_list( array_keys( $query_members->results ) );
|
81 |
+
$this->assertEquals( array( $u3, ), $ids );
|
82 |
+
}
|
83 |
+
|
84 |
+
public function test_with_group_role_mod() {
|
85 |
+
$g = $this->factory->group->create();
|
86 |
+
$u1 = $this->create_user();
|
87 |
+
$u2 = $this->create_user();
|
88 |
+
$u3 = $this->create_user();
|
89 |
+
$time = time();
|
90 |
+
|
91 |
+
$this->add_user_to_group( $u1, $g, array( 'date_modified' => gmdate( 'Y-m-d H:i:s', $time - 100 ) ) );
|
92 |
+
$this->add_user_to_group( $u2, $g, array( 'date_modified' => gmdate( 'Y-m-d H:i:s', $time - 200 ) ) );
|
93 |
+
$this->add_user_to_group( $u3, $g, array( 'date_modified' => gmdate( 'Y-m-d H:i:s', $time - 300 ) ) );
|
94 |
+
|
95 |
+
$m1 = new BP_Groups_Member( $u1, $g );
|
96 |
+
$m1->promote( 'admin' );
|
97 |
+
$m2 = new BP_Groups_Member( $u2, $g );
|
98 |
+
$m2->promote( 'mod' );
|
99 |
+
|
100 |
+
$query_members = new BP_Group_Member_Query( array(
|
101 |
+
'group_id' => $g,
|
102 |
+
'group_role' => array( 'mod' ),
|
103 |
+
) );
|
104 |
+
|
105 |
+
$ids = wp_parse_id_list( array_keys( $query_members->results ) );
|
106 |
+
$this->assertEquals( array( $u2, ), $ids );
|
107 |
+
}
|
108 |
+
|
109 |
+
public function test_with_group_role_admin() {
|
110 |
+
$g = $this->factory->group->create();
|
111 |
+
$u1 = $this->create_user();
|
112 |
+
$u2 = $this->create_user();
|
113 |
+
$u3 = $this->create_user();
|
114 |
+
$time = time();
|
115 |
+
|
116 |
+
$this->add_user_to_group( $u1, $g, array( 'date_modified' => gmdate( 'Y-m-d H:i:s', $time - 100 ) ) );
|
117 |
+
$this->add_user_to_group( $u2, $g, array( 'date_modified' => gmdate( 'Y-m-d H:i:s', $time - 200 ) ) );
|
118 |
+
$this->add_user_to_group( $u3, $g, array( 'date_modified' => gmdate( 'Y-m-d H:i:s', $time - 300 ) ) );
|
119 |
+
|
120 |
+
$m1 = new BP_Groups_Member( $u1, $g );
|
121 |
+
$m1->promote( 'admin' );
|
122 |
+
$m2 = new BP_Groups_Member( $u2, $g );
|
123 |
+
$m2->promote( 'mod' );
|
124 |
+
|
125 |
+
$query_members = new BP_Group_Member_Query( array(
|
126 |
+
'group_id' => $g,
|
127 |
+
'group_role' => array( 'admin' ),
|
128 |
+
) );
|
129 |
+
|
130 |
+
$ids = wp_parse_id_list( array_keys( $query_members->results ) );
|
131 |
+
$this->assertEquals( array( $u1, ), $ids );
|
132 |
+
}
|
133 |
+
|
134 |
+
public function test_with_group_role_member_mod() {
|
135 |
+
$g = $this->factory->group->create();
|
136 |
+
$u1 = $this->create_user();
|
137 |
+
$u2 = $this->create_user();
|
138 |
+
$u3 = $this->create_user();
|
139 |
+
$time = time();
|
140 |
+
|
141 |
+
$this->add_user_to_group( $u1, $g, array( 'date_modified' => gmdate( 'Y-m-d H:i:s', $time - 100 ) ) );
|
142 |
+
$this->add_user_to_group( $u2, $g, array( 'date_modified' => gmdate( 'Y-m-d H:i:s', $time - 200 ) ) );
|
143 |
+
$this->add_user_to_group( $u3, $g, array( 'date_modified' => gmdate( 'Y-m-d H:i:s', $time - 300 ) ) );
|
144 |
+
|
145 |
+
$m1 = new BP_Groups_Member( $u1, $g );
|
146 |
+
$m1->promote( 'admin' );
|
147 |
+
$m2 = new BP_Groups_Member( $u2, $g );
|
148 |
+
$m2->promote( 'mod' );
|
149 |
+
|
150 |
+
$query_members = new BP_Group_Member_Query( array(
|
151 |
+
'group_id' => $g,
|
152 |
+
'group_role' => array( 'member', 'mod' ),
|
153 |
+
) );
|
154 |
+
|
155 |
+
$ids = wp_parse_id_list( array_keys( $query_members->results ) );
|
156 |
+
$this->assertEquals( array( $u2, $u3, ), $ids );
|
157 |
+
}
|
158 |
+
|
159 |
+
public function test_with_group_role_member_admin() {
|
160 |
+
$g = $this->factory->group->create();
|
161 |
+
$u1 = $this->create_user();
|
162 |
+
$u2 = $this->create_user();
|
163 |
+
$u3 = $this->create_user();
|
164 |
+
$time = time();
|
165 |
+
|
166 |
+
$this->add_user_to_group( $u1, $g, array( 'date_modified' => gmdate( 'Y-m-d H:i:s', $time - 100 ) ) );
|
167 |
+
$this->add_user_to_group( $u2, $g, array( 'date_modified' => gmdate( 'Y-m-d H:i:s', $time - 200 ) ) );
|
168 |
+
$this->add_user_to_group( $u3, $g, array( 'date_modified' => gmdate( 'Y-m-d H:i:s', $time - 300 ) ) );
|
169 |
+
|
170 |
+
$m1 = new BP_Groups_Member( $u1, $g );
|
171 |
+
$m1->promote( 'admin' );
|
172 |
+
$m2 = new BP_Groups_Member( $u2, $g );
|
173 |
+
$m2->promote( 'mod' );
|
174 |
+
|
175 |
+
$query_members = new BP_Group_Member_Query( array(
|
176 |
+
'group_id' => $g,
|
177 |
+
'group_role' => array( 'member', 'admin' ),
|
178 |
+
) );
|
179 |
+
|
180 |
+
$ids = wp_parse_id_list( array_keys( $query_members->results ) );
|
181 |
+
$this->assertEquals( array( $u1, $u3, ), $ids );
|
182 |
+
}
|
183 |
+
|
184 |
+
public function test_with_group_role_mod_admin() {
|
185 |
+
$g = $this->factory->group->create();
|
186 |
+
$u1 = $this->create_user();
|
187 |
+
$u2 = $this->create_user();
|
188 |
+
$u3 = $this->create_user();
|
189 |
+
$time = time();
|
190 |
+
|
191 |
+
$this->add_user_to_group( $u1, $g, array( 'date_modified' => gmdate( 'Y-m-d H:i:s', $time - 100 ) ) );
|
192 |
+
$this->add_user_to_group( $u2, $g, array( 'date_modified' => gmdate( 'Y-m-d H:i:s', $time - 200 ) ) );
|
193 |
+
$this->add_user_to_group( $u3, $g, array( 'date_modified' => gmdate( 'Y-m-d H:i:s', $time - 300 ) ) );
|
194 |
+
|
195 |
+
$m1 = new BP_Groups_Member( $u1, $g );
|
196 |
+
$m1->promote( 'admin' );
|
197 |
+
$m2 = new BP_Groups_Member( $u2, $g );
|
198 |
+
$m2->promote( 'mod' );
|
199 |
+
|
200 |
+
$query_members = new BP_Group_Member_Query( array(
|
201 |
+
'group_id' => $g,
|
202 |
+
'group_role' => array( 'mod', 'admin' ),
|
203 |
+
) );
|
204 |
+
|
205 |
+
$ids = wp_parse_id_list( array_keys( $query_members->results ) );
|
206 |
+
$this->assertEquals( array( $u1, $u2, ), $ids );
|
207 |
+
}
|
208 |
+
|
209 |
+
public function test_with_group_role_member_mod_admin() {
|
210 |
+
$g = $this->factory->group->create();
|
211 |
+
$u1 = $this->create_user();
|
212 |
+
$u2 = $this->create_user();
|
213 |
+
$u3 = $this->create_user();
|
214 |
+
$time = time();
|
215 |
+
|
216 |
+
$this->add_user_to_group( $u1, $g, array( 'date_modified' => gmdate( 'Y-m-d H:i:s', $time - 100 ) ) );
|
217 |
+
$this->add_user_to_group( $u2, $g, array( 'date_modified' => gmdate( 'Y-m-d H:i:s', $time - 200 ) ) );
|
218 |
+
$this->add_user_to_group( $u3, $g, array( 'date_modified' => gmdate( 'Y-m-d H:i:s', $time - 300 ) ) );
|
219 |
+
|
220 |
+
$m1 = new BP_Groups_Member( $u1, $g );
|
221 |
+
$m1->promote( 'admin' );
|
222 |
+
$m2 = new BP_Groups_Member( $u2, $g );
|
223 |
+
$m2->promote( 'mod' );
|
224 |
+
|
225 |
+
$query_members = new BP_Group_Member_Query( array(
|
226 |
+
'group_id' => $g,
|
227 |
+
'group_role' => array( 'member', 'mod', 'admin' ),
|
228 |
+
) );
|
229 |
+
|
230 |
+
$ids = wp_parse_id_list( array_keys( $query_members->results ) );
|
231 |
+
$this->assertEquals( array( $u1, $u2, $u3, ), $ids );
|
232 |
+
}
|
233 |
+
|
234 |
+
public function test_with_group_role_member_mod_admin_banned() {
|
235 |
+
$g = $this->factory->group->create();
|
236 |
+
$u1 = $this->create_user();
|
237 |
+
$u2 = $this->create_user();
|
238 |
+
$u3 = $this->create_user();
|
239 |
+
$u4 = $this->create_user();
|
240 |
+
$time = time();
|
241 |
+
|
242 |
+
$this->add_user_to_group( $u1, $g, array( 'date_modified' => gmdate( 'Y-m-d H:i:s', $time - 100 ) ) );
|
243 |
+
$this->add_user_to_group( $u2, $g, array( 'date_modified' => gmdate( 'Y-m-d H:i:s', $time - 200 ) ) );
|
244 |
+
$this->add_user_to_group( $u3, $g, array( 'date_modified' => gmdate( 'Y-m-d H:i:s', $time - 300 ) ) );
|
245 |
+
$this->add_user_to_group( $u4, $g, array( 'date_modified' => gmdate( 'Y-m-d H:i:s', $time - 300 ) ) );
|
246 |
+
|
247 |
+
$m1 = new BP_Groups_Member( $u1, $g );
|
248 |
+
$m1->promote( 'admin' );
|
249 |
+
$m2 = new BP_Groups_Member( $u2, $g );
|
250 |
+
$m2->promote( 'mod' );
|
251 |
+
$m3 = new BP_Groups_Member( $u3, $g );
|
252 |
+
$m3->ban();
|
253 |
+
|
254 |
+
$query_members = new BP_Group_Member_Query( array(
|
255 |
+
'group_id' => $g,
|
256 |
+
'group_role' => array( 'member', 'mod', 'admin', 'banned' ),
|
257 |
+
) );
|
258 |
+
|
259 |
+
$ids = wp_parse_id_list( array_keys( $query_members->results ) );
|
260 |
+
$this->assertEquals( array( $u1, $u2, $u3, $u4, ), $ids );
|
261 |
+
}
|
262 |
+
|
263 |
+
public function test_with_group_role_banned() {
|
264 |
+
$g = $this->factory->group->create();
|
265 |
+
$u1 = $this->create_user();
|
266 |
+
$u2 = $this->create_user();
|
267 |
+
$time = time();
|
268 |
+
|
269 |
+
$this->add_user_to_group( $u1, $g, array( 'date_modified' => gmdate( 'Y-m-d H:i:s', $time - 100 ) ) );
|
270 |
+
$this->add_user_to_group( $u2, $g, array( 'date_modified' => gmdate( 'Y-m-d H:i:s', $time - 200 ) ) );
|
271 |
+
|
272 |
+
$m1 = new BP_Groups_Member( $u1, $g );
|
273 |
+
$m1->ban();
|
274 |
+
|
275 |
+
$query_members = new BP_Group_Member_Query( array(
|
276 |
+
'group_id' => $g,
|
277 |
+
'group_role' => array( 'banned' ),
|
278 |
+
) );
|
279 |
+
|
280 |
+
$ids = wp_parse_id_list( array_keys( $query_members->results ) );
|
281 |
+
$this->assertEquals( array( $u1, ), $ids );
|
282 |
+
}
|
283 |
+
|
284 |
+
public function test_group_has_no_members() {
|
285 |
+
$g = $this->factory->group->create();
|
286 |
+
$u1 = $this->create_user();
|
287 |
+
|
288 |
+
$query_members = new BP_Group_Member_Query( array(
|
289 |
+
'group_id' => $g,
|
290 |
+
'group_role' => array( 'member', 'mod', 'admin' ),
|
291 |
+
) );
|
292 |
+
|
293 |
+
$ids = wp_parse_id_list( array_keys( $query_members->results ) );
|
294 |
+
$this->assertEquals( array(), $ids );
|
295 |
+
}
|
296 |
+
|
297 |
+
public function test_group_has_no_members_of_role_mod() {
|
298 |
+
$g = $this->factory->group->create();
|
299 |
+
$u1 = $this->create_user();
|
300 |
+
$time = time();
|
301 |
+
|
302 |
+
$this->add_user_to_group( $u1, $g, array( 'date_modified' => gmdate( 'Y-m-d H:i:s', $time - 100 ) ) );
|
303 |
+
|
304 |
+
$query_members = new BP_Group_Member_Query( array(
|
305 |
+
'group_id' => $g,
|
306 |
+
'group_role' => array( 'mod' ),
|
307 |
+
) );
|
308 |
+
|
309 |
+
$ids = wp_parse_id_list( array_keys( $query_members->results ) );
|
310 |
+
$this->assertEquals( array(), $ids );
|
311 |
+
}
|
312 |
+
|
313 |
+
public function test_confirmed_members() {
|
314 |
+
$g = $this->factory->group->create();
|
315 |
+
$u1 = $this->create_user();
|
316 |
+
$u2 = $this->create_user();
|
317 |
+
$time = time();
|
318 |
+
|
319 |
+
$this->add_user_to_group( $u1, $g, array(
|
320 |
+
'date_modified' => gmdate( 'Y-m-d H:i:s', $time - 100 ),
|
321 |
+
'is_confirmed' => 0,
|
322 |
+
) );
|
323 |
+
|
324 |
+
$this->add_user_to_group( $u2, $g, array(
|
325 |
+
'date_modified' => gmdate( 'Y-m-d H:i:s', $time - 100 ),
|
326 |
+
'is_confirmed' => 1,
|
327 |
+
) );
|
328 |
+
|
329 |
+
$query_members = new BP_Group_Member_Query( array(
|
330 |
+
'group_id' => $g,
|
331 |
+
) );
|
332 |
+
|
333 |
+
$ids = wp_parse_id_list( array_keys( $query_members->results ) );
|
334 |
+
$this->assertEquals( array( $u2 ), $ids );
|
335 |
+
}
|
336 |
+
|
337 |
+
}
|
@@ -0,0 +1,657 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @group groups
|
4 |
+
* @group BP_Groups_Group
|
5 |
+
*/
|
6 |
+
class BP_Tests_BP_Groups_Group_TestCases extends BP_UnitTestCase {
|
7 |
+
public function setUp() {
|
8 |
+
parent::setUp();
|
9 |
+
}
|
10 |
+
|
11 |
+
public function tearDown() {
|
12 |
+
parent::tearDown();
|
13 |
+
}
|
14 |
+
|
15 |
+
/** __construct() ***************************************************/
|
16 |
+
|
17 |
+
/**
|
18 |
+
* @group __construct
|
19 |
+
*/
|
20 |
+
public function test_non_existent_group() {
|
21 |
+
$group = new BP_Groups_Group( 123456789 );
|
22 |
+
$this->assertSame( 0, $group->id );
|
23 |
+
}
|
24 |
+
|
25 |
+
/** get() ************************************************************/
|
26 |
+
|
27 |
+
/**
|
28 |
+
* @group get
|
29 |
+
*/
|
30 |
+
public function test_get_with_exclude() {
|
31 |
+
$g1 = $this->factory->group->create();
|
32 |
+
$g2 = $this->factory->group->create();
|
33 |
+
groups_update_groupmeta( $g1, 'foo', 'bar' );
|
34 |
+
|
35 |
+
$groups = BP_Groups_Group::get( array(
|
36 |
+
'exclude' => array(
|
37 |
+
$g1,
|
38 |
+
'foobar',
|
39 |
+
),
|
40 |
+
) );
|
41 |
+
$ids = wp_list_pluck( $groups['groups'], 'id' );
|
42 |
+
$this->assertEquals( $ids, array( $g2 ) );
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* @group get
|
47 |
+
*/
|
48 |
+
public function test_get_with_include() {
|
49 |
+
$g1 = $this->factory->group->create();
|
50 |
+
$g2 = $this->factory->group->create();
|
51 |
+
groups_update_groupmeta( $g1, 'foo', 'bar' );
|
52 |
+
|
53 |
+
$groups = BP_Groups_Group::get( array(
|
54 |
+
'include' => array(
|
55 |
+
$g1,
|
56 |
+
'foobar',
|
57 |
+
),
|
58 |
+
) );
|
59 |
+
$ids = wp_list_pluck( $groups['groups'], 'id' );
|
60 |
+
$this->assertEquals( $ids, array( $g1 ) );
|
61 |
+
}
|
62 |
+
|
63 |
+
/**
|
64 |
+
* @group get
|
65 |
+
* @group group_meta_query
|
66 |
+
*/
|
67 |
+
public function test_get_with_meta_query() {
|
68 |
+
$g1 = $this->factory->group->create();
|
69 |
+
$g2 = $this->factory->group->create();
|
70 |
+
groups_update_groupmeta( $g1, 'foo', 'bar' );
|
71 |
+
|
72 |
+
$groups = BP_Groups_Group::get( array(
|
73 |
+
'meta_query' => array(
|
74 |
+
array(
|
75 |
+
'key' => 'foo',
|
76 |
+
'value' => 'bar',
|
77 |
+
),
|
78 |
+
),
|
79 |
+
) );
|
80 |
+
$ids = wp_list_pluck( $groups['groups'], 'id' );
|
81 |
+
$this->assertEquals( $ids, array( $g1 ) );
|
82 |
+
}
|
83 |
+
|
84 |
+
/**
|
85 |
+
* @group get
|
86 |
+
* @group group_meta_query
|
87 |
+
*/
|
88 |
+
public function test_get_empty_meta_query() {
|
89 |
+
$g1 = $this->factory->group->create();
|
90 |
+
$g2 = $this->factory->group->create();
|
91 |
+
groups_update_groupmeta( $g1, 'foo', 'bar' );
|
92 |
+
|
93 |
+
$groups = BP_Groups_Group::get( array(
|
94 |
+
'meta_query' => array(),
|
95 |
+
) );
|
96 |
+
$ids = wp_list_pluck( $groups['groups'], 'id' );
|
97 |
+
$this->assertEquals( $ids, array( $g1, $g2, ) );
|
98 |
+
}
|
99 |
+
|
100 |
+
/**
|
101 |
+
* @group get
|
102 |
+
* @group group_meta_query
|
103 |
+
*/
|
104 |
+
public function test_get_with_meta_query_multiple_clauses() {
|
105 |
+
$now = time();
|
106 |
+
$g1 = $this->factory->group->create( array(
|
107 |
+
'last_activity' => date( 'Y-m-d H:i:s', $now - 60*60 ),
|
108 |
+
) );
|
109 |
+
$g2 = $this->factory->group->create( array(
|
110 |
+
'last_activity' => date( 'Y-m-d H:i:s', $now - 60*60*2 ),
|
111 |
+
) );
|
112 |
+
$g3 = $this->factory->group->create( array(
|
113 |
+
'last_activity' => date( 'Y-m-d H:i:s', $now - 60*60*3 ),
|
114 |
+
) );
|
115 |
+
groups_update_groupmeta( $g1, 'foo', 'bar' );
|
116 |
+
groups_update_groupmeta( $g2, 'foo', 'bar' );
|
117 |
+
groups_update_groupmeta( $g1, 'bar', 'barry' );
|
118 |
+
|
119 |
+
$groups = BP_Groups_Group::get( array(
|
120 |
+
'meta_query' => array(
|
121 |
+
'relation' => 'AND',
|
122 |
+
array(
|
123 |
+
'key' => 'foo',
|
124 |
+
'value' => 'bar',
|
125 |
+
),
|
126 |
+
array(
|
127 |
+
'key' => 'bar',
|
128 |
+
'value' => 'barry',
|
129 |
+
),
|
130 |
+
),
|
131 |
+
) );
|
132 |
+
$ids = wp_list_pluck( $groups['groups'], 'id' );
|
133 |
+
$this->assertEquals( $ids, array( $g1 ) );
|
134 |
+
$this->assertEquals( 1, $groups['total'] );
|
135 |
+
}
|
136 |
+
|
137 |
+
/**
|
138 |
+
* @group get
|
139 |
+
*/
|
140 |
+
public function test_get_normal_search() {
|
141 |
+
$g1 = $this->factory->group->create( array(
|
142 |
+
'name' => 'Cool Group',
|
143 |
+
'description' => 'This is one cool group',
|
144 |
+
) );
|
145 |
+
$g2 = $this->factory->group->create();
|
146 |
+
|
147 |
+
$groups = BP_Groups_Group::get( array(
|
148 |
+
'search_terms' => 'Cool',
|
149 |
+
) );
|
150 |
+
|
151 |
+
$found = wp_list_pluck( $groups['groups'], 'id' );
|
152 |
+
$this->assertEquals( array( $g1 ), $found );
|
153 |
+
}
|
154 |
+
|
155 |
+
/**
|
156 |
+
* @group get
|
157 |
+
*/
|
158 |
+
public function test_get_search_with_underscores() {
|
159 |
+
$g1 = $this->factory->group->create( array(
|
160 |
+
'name' => 'Cool Group',
|
161 |
+
'description' => '_cool_ dude',
|
162 |
+
) );
|
163 |
+
$g2 = $this->factory->group->create();
|
164 |
+
|
165 |
+
$groups = BP_Groups_Group::get( array(
|
166 |
+
'search_terms' => '_cool_',
|
167 |
+
) );
|
168 |
+
|
169 |
+
$found = wp_list_pluck( $groups['groups'], 'id' );
|
170 |
+
$this->assertEquals( array( $g1 ), $found );
|
171 |
+
}
|
172 |
+
|
173 |
+
/**
|
174 |
+
* @group get
|
175 |
+
*/
|
176 |
+
public function test_get_search_with_percent_sign() {
|
177 |
+
$g1 = $this->factory->group->create( array(
|
178 |
+
'name' => 'Cool Group',
|
179 |
+
'description' => '100% awesome',
|
180 |
+
) );
|
181 |
+
$g2 = $this->factory->group->create();
|
182 |
+
|
183 |
+
$groups = BP_Groups_Group::get( array(
|
184 |
+
'search_terms' => '100%',
|
185 |
+
) );
|
186 |
+
|
187 |
+
$found = wp_list_pluck( $groups['groups'], 'id' );
|
188 |
+
$this->assertEquals( array( $g1 ), $found );
|
189 |
+
}
|
190 |
+
|
191 |
+
/**
|
192 |
+
* @group get
|
193 |
+
*/
|
194 |
+
public function test_get_search_with_quotes() {
|
195 |
+
$g1 = $this->factory->group->create( array(
|
196 |
+
'name' => 'Cool Group',
|
197 |
+
'description' => "'tis sweet",
|
198 |
+
) );
|
199 |
+
$g2 = $this->factory->group->create();
|
200 |
+
|
201 |
+
$groups = BP_Groups_Group::get( array(
|
202 |
+
'search_terms' => "'tis ",
|
203 |
+
) );
|
204 |
+
|
205 |
+
$found = wp_list_pluck( $groups['groups'], 'id' );
|
206 |
+
|
207 |
+
$this->assertEquals( array( $g1 ), $found );
|
208 |
+
}
|
209 |
+
|
210 |
+
/**
|
211 |
+
* BP 1.8 will change the default 'type' param in favor of default
|
212 |
+
* 'order' and 'orderby'. This is to make sure that existing plugins
|
213 |
+
* will work appropriately
|
214 |
+
*
|
215 |
+
* @group get
|
216 |
+
*/
|
217 |
+
public function test_get_with_default_type_value_should_be_newest() {
|
218 |
+
$g1 = $this->factory->group->create( array(
|
219 |
+
'name' => 'A Group',
|
220 |
+
'date_created' => bp_core_current_time(),
|
221 |
+
) );
|
222 |
+
$g2 = $this->factory->group->create( array(
|
223 |
+
'name' => 'D Group',
|
224 |
+
'date_created' => gmdate( 'Y-m-d H:i:s', time() - 100 ),
|
225 |
+
) );
|
226 |
+
$g3 = $this->factory->group->create( array(
|
227 |
+
'name' => 'B Group',
|
228 |
+
'date_created' => gmdate( 'Y-m-d H:i:s', time() - 100000 ),
|
229 |
+
) );
|
230 |
+
$g4 = $this->factory->group->create( array(
|
231 |
+
'name' => 'C Group',
|
232 |
+
'date_created' => gmdate( 'Y-m-d H:i:s', time() - 1000 ),
|
233 |
+
) );
|
234 |
+
|
235 |
+
$found = BP_Groups_Group::get();
|
236 |
+
|
237 |
+
$this->assertEquals( BP_Groups_Group::get( array( 'type' => 'newest' ) ), $found );
|
238 |
+
}
|
239 |
+
|
240 |
+
/**
|
241 |
+
* @group get
|
242 |
+
*/
|
243 |
+
public function test_get_with_type_newest() {
|
244 |
+
$time = time();
|
245 |
+
$g1 = $this->factory->group->create( array(
|
246 |
+
'name' => 'A Group',
|
247 |
+
'date_created' => bp_core_current_time(),
|
248 |
+
) );
|
249 |
+
$g2 = $this->factory->group->create( array(
|
250 |
+
'name' => 'D Group',
|
251 |
+
'date_created' => gmdate( 'Y-m-d H:i:s', $time - 100 ),
|
252 |
+
) );
|
253 |
+
$g3 = $this->factory->group->create( array(
|
254 |
+
'name' => 'B Group',
|
255 |
+
'date_created' => gmdate( 'Y-m-d H:i:s', $time - 100000 ),
|
256 |
+
) );
|
257 |
+
$g4 = $this->factory->group->create( array(
|
258 |
+
'name' => 'C Group',
|
259 |
+
'date_created' => gmdate( 'Y-m-d H:i:s', $time - 1000 ),
|
260 |
+
) );
|
261 |
+
|
262 |
+
$groups = BP_Groups_Group::get( array( 'type' => 'newest' ) );
|
263 |
+
$found = wp_parse_id_list( wp_list_pluck( $groups['groups'], 'id' ) );
|
264 |
+
$this->assertEquals( array( $g1, $g2, $g4, $g3 ), $found );
|
265 |
+
}
|
266 |
+
|
267 |
+
/**
|
268 |
+
* @group get
|
269 |
+
*/
|
270 |
+
public function test_get_with_type_popular() {
|
271 |
+
$time = time();
|
272 |
+
$g1 = $this->factory->group->create( array(
|
273 |
+
'name' => 'A Group',
|
274 |
+
'date_created' => bp_core_current_time(),
|
275 |
+
) );
|
276 |
+
$g2 = $this->factory->group->create( array(
|
277 |
+
'name' => 'D Group',
|
278 |
+
'date_created' => gmdate( 'Y-m-d H:i:s', $time - 100 ),
|
279 |
+
) );
|
280 |
+
$g3 = $this->factory->group->create( array(
|
281 |
+
'name' => 'B Group',
|
282 |
+
'date_created' => gmdate( 'Y-m-d H:i:s', $time - 100000 ),
|
283 |
+
) );
|
284 |
+
$g4 = $this->factory->group->create( array(
|
285 |
+
'name' => 'C Group',
|
286 |
+
'date_created' => gmdate( 'Y-m-d H:i:s', $time - 1000 ),
|
287 |
+
) );
|
288 |
+
|
289 |
+
groups_update_groupmeta( $g1, 'total_member_count', 1 );
|
290 |
+
groups_update_groupmeta( $g2, 'total_member_count', 4 );
|
291 |
+
groups_update_groupmeta( $g3, 'total_member_count', 2 );
|
292 |
+
groups_update_groupmeta( $g4, 'total_member_count', 3 );
|
293 |
+
|
294 |
+
$groups = BP_Groups_Group::get( array( 'type' => 'popular' ) );
|
295 |
+
$found = wp_parse_id_list( wp_list_pluck( $groups['groups'], 'id' ) );
|
296 |
+
$this->assertEquals( array( $g2, $g4, $g3, $g1 ), $found );
|
297 |
+
}
|
298 |
+
|
299 |
+
/**
|
300 |
+
* @group get
|
301 |
+
* @group group_meta_query
|
302 |
+
* @ticket BP5099
|
303 |
+
*/
|
304 |
+
public function test_meta_query_and_total_groups() {
|
305 |
+
$time = time();
|
306 |
+
|
307 |
+
$g1 = $this->factory->group->create( array(
|
308 |
+
'name' => 'A Group',
|
309 |
+
'date_created' => bp_core_current_time(),
|
310 |
+
) );
|
311 |
+
$g2 = $this->factory->group->create( array(
|
312 |
+
'name' => 'D Group',
|
313 |
+
'date_created' => gmdate( 'Y-m-d H:i:s', $time - 100 ),
|
314 |
+
) );
|
315 |
+
$g3 = $this->factory->group->create( array(
|
316 |
+
'name' => 'B Group',
|
317 |
+
'date_created' => gmdate( 'Y-m-d H:i:s', $time - 100000 ),
|
318 |
+
) );
|
319 |
+
$g4 = $this->factory->group->create( array(
|
320 |
+
'name' => 'C Group',
|
321 |
+
'date_created' => gmdate( 'Y-m-d H:i:s', $time - 1000 ),
|
322 |
+
) );
|
323 |
+
|
324 |
+
// mark one group with the metakey 'supergroup'
|
325 |
+
groups_update_groupmeta( $g1, 'supergroup', 1 );
|
326 |
+
|
327 |
+
// fetch groups with our 'supergroup' metakey
|
328 |
+
$groups = BP_Groups_Group::get( array(
|
329 |
+
'meta_query' => array(
|
330 |
+
array(
|
331 |
+
'key' => 'supergroup',
|
332 |
+
'compare' => 'EXISTS',
|
333 |
+
)
|
334 |
+
)
|
335 |
+
) );
|
336 |
+
|
337 |
+
// group total should match 1
|
338 |
+
$this->assertEquals( '1', $groups['total'] );
|
339 |
+
}
|
340 |
+
|
341 |
+
/** convert_type_to_order_orderby() **********************************/
|
342 |
+
|
343 |
+
/**
|
344 |
+
* @group convert_type_to_order_orderby
|
345 |
+
*/
|
346 |
+
public function test_convert_type_to_order_orderby_newest() {
|
347 |
+
$expected = array(
|
348 |
+
'order' => 'DESC',
|
349 |
+
'orderby' => 'date_created',
|
350 |
+
);
|
351 |
+
$this->assertEquals( $expected, _BP_Groups_Group::_convert_type_to_order_orderby( 'newest' ) );
|
352 |
+
}
|
353 |
+
|
354 |
+
/**
|
355 |
+
* @group convert_type_to_order_orderby
|
356 |
+
*/
|
357 |
+
public function test_convert_type_to_order_orderby_active() {
|
358 |
+
$expected = array(
|
359 |
+
'order' => 'DESC',
|
360 |
+
'orderby' => 'last_activity',
|
361 |
+
);
|
362 |
+
$this->assertEquals( $expected, _BP_Groups_Group::_convert_type_to_order_orderby( 'active' ) );
|
363 |
+
}
|
364 |
+
|
365 |
+
/**
|
366 |
+
* @group convert_type_to_order_orderby
|
367 |
+
*/
|
368 |
+
public function test_convert_type_to_order_orderby_popular() {
|
369 |
+
$expected = array(
|
370 |
+
'order' => 'DESC',
|
371 |
+
'orderby' => 'total_member_count',
|
372 |
+
);
|
373 |
+
$this->assertEquals( $expected, _BP_Groups_Group::_convert_type_to_order_orderby( 'popular' ) );
|
374 |
+
}
|
375 |
+
|
376 |
+
/**
|
377 |
+
* @group convert_type_to_order_orderby
|
378 |
+
*/
|
379 |
+
public function test_convert_type_to_order_orderby_alphabetical() {
|
380 |
+
$expected = array(
|
381 |
+
'order' => 'ASC',
|
382 |
+
'orderby' => 'name',
|
383 |
+
);
|
384 |
+
$this->assertEquals( $expected, _BP_Groups_Group::_convert_type_to_order_orderby( 'alphabetical' ) );
|
385 |
+
}
|
386 |
+
|
387 |
+
/**
|
388 |
+
* @group convert_type_to_order_orderby
|
389 |
+
*/
|
390 |
+
public function test_convert_type_to_order_orderby_random() {
|
391 |
+
$expected = array(
|
392 |
+
// order gets thrown out
|
393 |
+
'order' => '',
|
394 |
+
'orderby' => 'random',
|
395 |
+
);
|
396 |
+
$this->assertEquals( $expected, _BP_Groups_Group::_convert_type_to_order_orderby( 'random' ) );
|
397 |
+
}
|
398 |
+
|
399 |
+
/**
|
400 |
+
* @group convert_type_to_order_orderby
|
401 |
+
*/
|
402 |
+
public function test_convert_type_to_order_orderby_invalid() {
|
403 |
+
$expected = array(
|
404 |
+
'order' => '',
|
405 |
+
'orderby' => '',
|
406 |
+
);
|
407 |
+
$this->assertEquals( $expected, _BP_Groups_Group::_convert_type_to_order_orderby( 'foooooooooooooooobar' ) );
|
408 |
+
}
|
409 |
+
|
410 |
+
/** convert_orderby_to_order_by_term() **********************************/
|
411 |
+
|
412 |
+
/**
|
413 |
+
* @group convert_orderby_to_order_by_term
|
414 |
+
*/
|
415 |
+
public function test_convert_orderby_to_order_by_term_date_created() {
|
416 |
+
$this->assertEquals( 'g.date_created', _BP_Groups_Group::_convert_orderby_to_order_by_term( 'date_created' ) );
|
417 |
+
}
|
418 |
+
|
419 |
+
/**
|
420 |
+
* @group convert_orderby_to_order_by_term
|
421 |
+
*/
|
422 |
+
public function test_convert_orderby_to_order_by_term_last_activity() {
|
423 |
+
$c = new _BP_Groups_Group();
|
424 |
+
$this->assertEquals( 'last_activity', _BP_Groups_Group::_convert_orderby_to_order_by_term( 'last_activity' ) );
|
425 |
+
}
|
426 |
+
|
427 |
+
/**
|
428 |
+
* @group convert_orderby_to_order_by_term
|
429 |
+
*/
|
430 |
+
public function test_convert_orderby_to_order_by_term_total_member_count() {
|
431 |
+
$c = new _BP_Groups_Group();
|
432 |
+
$this->assertEquals( 'CONVERT(gm1.meta_value, SIGNED)', _BP_Groups_Group::_convert_orderby_to_order_by_term( 'total_member_count' ) );
|
433 |
+
}
|
434 |
+
|
435 |
+
/**
|
436 |
+
* @group convert_orderby_to_order_by_term
|
437 |
+
*/
|
438 |
+
public function test_convert_orderby_to_order_by_term_name() {
|
439 |
+
$c = new _BP_Groups_Group();
|
440 |
+
$this->assertEquals( 'g.name', _BP_Groups_Group::_convert_orderby_to_order_by_term( 'name' ) );
|
441 |
+
}
|
442 |
+
|
443 |
+
/**
|
444 |
+
* @group convert_orderby_to_order_by_term
|
445 |
+
*/
|
446 |
+
public function test_convert_orderby_to_order_by_term_random() {
|
447 |
+
$c = new _BP_Groups_Group();
|
448 |
+
$this->assertEquals( 'rand()', _BP_Groups_Group::_convert_orderby_to_order_by_term( 'random' ) );
|
449 |
+
}
|
450 |
+
|
451 |
+
/**
|
452 |
+
* @group convert_orderby_to_order_by_term
|
453 |
+
*/
|
454 |
+
public function test_convert_orderby_to_order_by_term_invalid_fallback_to_date_created() {
|
455 |
+
$c = new _BP_Groups_Group();
|
456 |
+
$this->assertEquals( _BP_Groups_Group::_convert_orderby_to_order_by_term( 'date_created' ), _BP_Groups_Group::_convert_orderby_to_order_by_term( 'I am a bad boy' ) );
|
457 |
+
}
|
458 |
+
|
459 |
+
public function test_filter_user_groups_normal_search() {
|
460 |
+
$g1 = $this->factory->group->create( array(
|
461 |
+
'name' => 'Cool Group',
|
462 |
+
'description' => 'This is one cool group',
|
463 |
+
) );
|
464 |
+
$g2 = $this->factory->group->create();
|
465 |
+
$u = $this->factory->user->create();
|
466 |
+
self::add_user_to_group( $u, $g1 );
|
467 |
+
|
468 |
+
$groups = BP_Groups_Group::filter_user_groups( 'Cool', $u );
|
469 |
+
|
470 |
+
$found = wp_list_pluck( $groups['groups'], 'group_id' );
|
471 |
+
$this->assertEquals( array( $g1 ), $found );
|
472 |
+
}
|
473 |
+
|
474 |
+
public function test_filter_user_groups_search_with_underscores() {
|
475 |
+
$g1 = $this->factory->group->create( array(
|
476 |
+
'name' => 'Cool Group',
|
477 |
+
'description' => '_cool_ dude',
|
478 |
+
) );
|
479 |
+
$g2 = $this->factory->group->create();
|
480 |
+
|
481 |
+
$u = $this->factory->user->create();
|
482 |
+
self::add_user_to_group( $u, $g1 );
|
483 |
+
self::add_user_to_group( $u, $g2 );
|
484 |
+
|
485 |
+
$groups = BP_Groups_Group::filter_user_groups( '_cool_', $u );
|
486 |
+
|
487 |
+
$found = wp_list_pluck( $groups['groups'], 'group_id' );
|
488 |
+
$this->assertEquals( array( $g1 ), $found );
|
489 |
+
}
|
490 |
+
|
491 |
+
public function test_filter_user_groups_search_with_percent_sign() {
|
492 |
+
$g1 = $this->factory->group->create( array(
|
493 |
+
'name' => 'Cool Group',
|
494 |
+
'description' => '100% awesome',
|
495 |
+
) );
|
496 |
+
$g2 = $this->factory->group->create();
|
497 |
+
|
498 |
+
$u = $this->factory->user->create();
|
499 |
+
self::add_user_to_group( $u, $g1 );
|
500 |
+
self::add_user_to_group( $u, $g2 );
|
501 |
+
|
502 |
+
$groups = BP_Groups_Group::filter_user_groups( '100%', $u );
|
503 |
+
|
504 |
+
$found = wp_list_pluck( $groups['groups'], 'group_id' );
|
505 |
+
$this->assertEquals( array( $g1 ), $found );
|
506 |
+
}
|
507 |
+
|
508 |
+
public function test_filter_user_groups_search_with_quotes() {
|
509 |
+
$g1 = $this->factory->group->create( array(
|
510 |
+
'name' => 'Cool Group',
|
511 |
+
'description' => "'tis sweet",
|
512 |
+
) );
|
513 |
+
$g2 = $this->factory->group->create();
|
514 |
+
|
515 |
+
$u = $this->factory->user->create();
|
516 |
+
self::add_user_to_group( $u, $g1 );
|
517 |
+
self::add_user_to_group( $u, $g2 );
|
518 |
+
|
519 |
+
$groups = BP_Groups_Group::filter_user_groups( "'tis ", $u );
|
520 |
+
|
521 |
+
$found = wp_list_pluck( $groups['groups'], 'group_id' );
|
522 |
+
|
523 |
+
// @todo
|
524 |
+
//$this->assertEquals( array( $g1->id ), $found );
|
525 |
+
}
|
526 |
+
|
527 |
+
public function test_search_groups_normal_search() {
|
528 |
+
$g1 = $this->factory->group->create( array(
|
529 |
+
'name' => 'Cool Group',
|
530 |
+
'description' => 'This is one cool group',
|
531 |
+
) );
|
532 |
+
$g2 = $this->factory->group->create();
|
533 |
+
|
534 |
+
$groups = BP_Groups_Group::search_groups( 'Cool' );
|
535 |
+
|
536 |
+
$found = wp_list_pluck( $groups['groups'], 'group_id' );
|
537 |
+
$this->assertEquals( array( $g1 ), $found );
|
538 |
+
}
|
539 |
+
|
540 |
+
public function test_search_groups_search_with_underscores() {
|
541 |
+
$g1 = $this->factory->group->create( array(
|
542 |
+
'name' => 'Cool Group',
|
543 |
+
'description' => '_cool_ dude',
|
544 |
+
) );
|
545 |
+
$g2 = $this->factory->group->create();
|
546 |
+
|
547 |
+
$groups = BP_Groups_Group::search_groups( '_cool_' );
|
548 |
+
|
549 |
+
$found = wp_list_pluck( $groups['groups'], 'group_id' );
|
550 |
+
$this->assertEquals( array( $g1 ), $found );
|
551 |
+
}
|
552 |
+
|
553 |
+
public function test_search_groups_search_with_percent_sign() {
|
554 |
+
$g1 = $this->factory->group->create( array(
|
555 |
+
'name' => 'Cool Group',
|
556 |
+
'description' => '100% awesome',
|
557 |
+
) );
|
558 |
+
$g2 = $this->factory->group->create();
|
559 |
+
|
560 |
+
$groups = BP_Groups_Group::search_groups( '100%' );
|
561 |
+
|
562 |
+
$found = wp_list_pluck( $groups['groups'], 'group_id' );
|
563 |
+
$this->assertEquals( array( $g1 ), $found );
|
564 |
+
}
|
565 |
+
|
566 |
+
public function test_search_groups_search_with_quotes() {
|
567 |
+
$g1 = $this->factory->group->create( array(
|
568 |
+
'name' => 'Cool Group',
|
569 |
+
'description' => "'tis sweet",
|
570 |
+
) );
|
571 |
+
$g2 = $this->factory->group->create();
|
572 |
+
|
573 |
+
$groups = BP_Groups_Group::search_groups( "'tis " );
|
574 |
+
|
575 |
+
$found = wp_list_pluck( $groups['groups'], 'group_id' );
|
576 |
+
|
577 |
+
$this->assertEquals( array( $g1 ), $found );
|
578 |
+
}
|
579 |
+
|
580 |
+
public function test_get_by_letter_with_exclude() {
|
581 |
+
$g1 = $this->factory->group->create( array(
|
582 |
+
'name' => 'Awesome Cool Group',
|
583 |
+
'description' => 'Neat',
|
584 |
+
) );
|
585 |
+
$g2 = $this->factory->group->create( array(
|
586 |
+
'name' => 'Another Cool Group',
|
587 |
+
'description' => 'Awesome',
|
588 |
+
) );
|
589 |
+
|
590 |
+
$groups = BP_Groups_Group::get_by_letter( 'A', null, null, true, array( $g1, 'stringthatshouldberemoved' ) );
|
591 |
+
|
592 |
+
$found = wp_list_pluck( $groups['groups'], 'id' );
|
593 |
+
|
594 |
+
$this->assertEquals( array( $g2 ), $found );
|
595 |
+
|
596 |
+
}
|
597 |
+
|
598 |
+
public function test_get_by_letter_starts_with_apostrophe() {
|
599 |
+
$g1 = $this->factory->group->create( array(
|
600 |
+
'name' => "'Tis Sweet",
|
601 |
+
'description' => 'Neat',
|
602 |
+
) );
|
603 |
+
$g2 = $this->factory->group->create( array(
|
604 |
+
'name' => 'Another Cool Group',
|
605 |
+
'description' => 'Awesome',
|
606 |
+
) );
|
607 |
+
|
608 |
+
$groups = BP_Groups_Group::get_by_letter( "'" );
|
609 |
+
|
610 |
+
$found = wp_list_pluck( $groups['groups'], 'id' );
|
611 |
+
|
612 |
+
// @todo
|
613 |
+
// The test fails but at least it's sanitized
|
614 |
+
//$this->assertEquals( array( $g1->id ), $found );
|
615 |
+
}
|
616 |
+
|
617 |
+
public function test_get_random_with_exclude() {
|
618 |
+
$g1 = $this->factory->group->create();
|
619 |
+
$g2 = $this->factory->group->create();
|
620 |
+
|
621 |
+
// There are only two groups, so excluding one should give us the other
|
622 |
+
$groups = BP_Groups_Group::get_random( null, null, 0, false, true, array( $g1, 'ignore this' ) );
|
623 |
+
|
624 |
+
$found = wp_list_pluck( $groups['groups'], 'id' );
|
625 |
+
|
626 |
+
$this->assertEquals( array( $g2 ), $found );
|
627 |
+
}
|
628 |
+
|
629 |
+
public function test_get_random_with_search_terms() {
|
630 |
+
$g1 = $this->factory->group->create( array(
|
631 |
+
'name' => 'Bodacious',
|
632 |
+
) );
|
633 |
+
$g2 = $this->factory->group->create( array(
|
634 |
+
'name' => 'Crummy group',
|
635 |
+
) );
|
636 |
+
|
637 |
+
// Only one group will match, so the random part doesn't matter
|
638 |
+
$groups = BP_Groups_Group::get_random( null, null, 0, 'daci' );
|
639 |
+
|
640 |
+
$found = wp_list_pluck( $groups['groups'], 'id' );
|
641 |
+
|
642 |
+
$this->assertEquals( array( $g1 ), $found );
|
643 |
+
}
|
644 |
+
}
|
645 |
+
|
646 |
+
/**
|
647 |
+
* Stub class for accessing protected methods
|
648 |
+
*/
|
649 |
+
class _BP_Groups_Group extends BP_Groups_Group {
|
650 |
+
static public function _convert_type_to_order_orderby( $type ) {
|
651 |
+
return self::convert_type_to_order_orderby( $type );
|
652 |
+
}
|
653 |
+
|
654 |
+
static public function _convert_orderby_to_order_by_term( $term ) {
|
655 |
+
return self::convert_orderby_to_order_by_term( $term );
|
656 |
+
}
|
657 |
+
}
|
@@ -0,0 +1,131 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @group groups
|
4 |
+
* @group BP_Groups_Member
|
5 |
+
*/
|
6 |
+
class BP_Tests_BP_Groups_Member_TestCases extends BP_UnitTestCase {
|
7 |
+
public function setUp() {
|
8 |
+
parent::setUp();
|
9 |
+
}
|
10 |
+
|
11 |
+
public function tearDown() {
|
12 |
+
parent::tearDown();
|
13 |
+
}
|
14 |
+
|
15 |
+
public static function invite_user_to_group( $user_id, $group_id, $inviter_id ) {
|
16 |
+
$invite = new BP_Groups_Member;
|
17 |
+
$invite->group_id = $group_id;
|
18 |
+
$invite->user_id = $user_id;
|
19 |
+
$invite->date_modified = bp_core_current_time();
|
20 |
+
$invite->inviter_id = $inviter_id;
|
21 |
+
$invite->is_confirmed = 0;
|
22 |
+
$invite->invite_sent = 1;
|
23 |
+
|
24 |
+
$invite->save();
|
25 |
+
return $invite->id;
|
26 |
+
}
|
27 |
+
|
28 |
+
public function test_get_recently_joined_with_filter() {
|
29 |
+
$g1 = $this->factory->group->create( array(
|
30 |
+
'name' => 'Tab',
|
31 |
+
) );
|
32 |
+
$g2 = $this->factory->group->create( array(
|
33 |
+
'name' => 'Diet Rite',
|
34 |
+
) );
|
35 |
+
|
36 |
+
$u = $this->factory->user->create();
|
37 |
+
self::add_user_to_group( $u, $g1 );
|
38 |
+
self::add_user_to_group( $u, $g2 );
|
39 |
+
|
40 |
+
$groups = BP_Groups_Member::get_recently_joined( $u, false, false, 'Rite' );
|
41 |
+
|
42 |
+
$ids = wp_list_pluck( $groups['groups'], 'id' );
|
43 |
+
$this->assertEquals( $ids, array( $g2 ) );
|
44 |
+
}
|
45 |
+
|
46 |
+
public function test_get_is_admin_of_with_filter() {
|
47 |
+
$g1 = $this->factory->group->create( array(
|
48 |
+
'name' => 'RC Cola',
|
49 |
+
) );
|
50 |
+
$g2 = $this->factory->group->create( array(
|
51 |
+
'name' => 'Pepsi',
|
52 |
+
) );
|
53 |
+
|
54 |
+
$u = $this->factory->user->create();
|
55 |
+
self::add_user_to_group( $u, $g1 );
|
56 |
+
self::add_user_to_group( $u, $g2 );
|
57 |
+
|
58 |
+
$m1 = new BP_Groups_Member( $u, $g1 );
|
59 |
+
$m1->promote( 'admin' );
|
60 |
+
$m2 = new BP_Groups_Member( $u, $g2 );
|
61 |
+
$m2->promote( 'admin' );
|
62 |
+
|
63 |
+
$groups = BP_Groups_Member::get_is_admin_of( $u, false, false, 'eps' );
|
64 |
+
|
65 |
+
$ids = wp_list_pluck( $groups['groups'], 'id' );
|
66 |
+
$this->assertEquals( $ids, array( $g2 ) );
|
67 |
+
}
|
68 |
+
|
69 |
+
public function test_get_is_mod_of_with_filter() {
|
70 |
+
$g1 = $this->factory->group->create( array(
|
71 |
+
'name' => 'RC Cola',
|
72 |
+
) );
|
73 |
+
$g2 = $this->factory->group->create( array(
|
74 |
+
'name' => 'Pepsi',
|
75 |
+
) );
|
76 |
+
|
77 |
+
$u = $this->factory->user->create();
|
78 |
+
self::add_user_to_group( $u, $g1 );
|
79 |
+
self::add_user_to_group( $u, $g2 );
|
80 |
+
|
81 |
+
$m1 = new BP_Groups_Member( $u, $g1 );
|
82 |
+
$m1->promote( 'mod' );
|
83 |
+
$m2 = new BP_Groups_Member( $u, $g2 );
|
84 |
+
$m2->promote( 'mod' );
|
85 |
+
|
86 |
+
$groups = BP_Groups_Member::get_is_mod_of( $u, false, false, 'eps' );
|
87 |
+
|
88 |
+
$ids = wp_list_pluck( $groups['groups'], 'id' );
|
89 |
+
$this->assertEquals( $ids, array( $g2 ) );
|
90 |
+
}
|
91 |
+
|
92 |
+
public function test_get_invites_with_exclude() {
|
93 |
+
$g1 = $this->factory->group->create( array(
|
94 |
+
'name' => 'RC Cola',
|
95 |
+
) );
|
96 |
+
$g2 = $this->factory->group->create( array(
|
97 |
+
'name' => 'Pepsi',
|
98 |
+
) );
|
99 |
+
|
100 |
+
$u1 = $this->factory->user->create();
|
101 |
+
$u2 = $this->factory->user->create();
|
102 |
+
self::add_user_to_group( $u1, $g1 );
|
103 |
+
self::add_user_to_group( $u1, $g2 );
|
104 |
+
self::invite_user_to_group( $u2, $g1, $u1 );
|
105 |
+
self::invite_user_to_group( $u2, $g2, $u1 );
|
106 |
+
|
107 |
+
$groups = BP_Groups_Member::get_invites( $u2, false, false, array( 'awesome', $g1 ) );
|
108 |
+
|
109 |
+
$ids = wp_list_pluck( $groups['groups'], 'id' );
|
110 |
+
$this->assertEquals( $ids, array( $g2 ) );
|
111 |
+
}
|
112 |
+
|
113 |
+
/**
|
114 |
+
* @expectedDeprecated BP_Groups_Member::get_all_for_group
|
115 |
+
*/
|
116 |
+
public function test_get_all_for_group_with_exclude() {
|
117 |
+
$g1 = $this->factory->group->create();
|
118 |
+
|
119 |
+
$u1 = $this->create_user();
|
120 |
+
$u2 = $this->create_user();
|
121 |
+
self::add_user_to_group( $u1, $g1 );
|
122 |
+
self::add_user_to_group( $u2, $g1 );
|
123 |
+
|
124 |
+
$members = BP_Groups_Member::get_all_for_group( $g1, false, false, true, true, array( $u1 ) );
|
125 |
+
|
126 |
+
$mm = (array) $members['members'];
|
127 |
+
$ids = wp_list_pluck( $mm, 'user_id' );
|
128 |
+
$this->assertEquals( array( $u2 ), $ids );
|
129 |
+
}
|
130 |
+
}
|
131 |
+
|
@@ -0,0 +1,288 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @group groups
|
5 |
+
* @group functions
|
6 |
+
*/
|
7 |
+
class BP_Tests_Groups_Functions extends BP_UnitTestCase {
|
8 |
+
/**
|
9 |
+
* @group total_group_count
|
10 |
+
* @group groups_join_group
|
11 |
+
*/
|
12 |
+
public function test_total_group_count_groups_join_group() {
|
13 |
+
$u1 = $this->create_user();
|
14 |
+
$u2 = $this->create_user();
|
15 |
+
$g = $this->factory->group->create( array( 'creator_id' => $u1 ) );
|
16 |
+
|
17 |
+
groups_join_group( $g, $u2 );
|
18 |
+
$this->assertEquals( 1, bp_get_user_meta( $u2, 'total_group_count', true ) );
|
19 |
+
}
|
20 |
+
|
21 |
+
/**
|
22 |
+
* @group total_group_count
|
23 |
+
* @group groups_leave_group
|
24 |
+
*/
|
25 |
+
public function test_total_group_count_groups_leave_group() {
|
26 |
+
$u1 = $this->create_user();
|
27 |
+
$u2 = $this->create_user();
|
28 |
+
$g1 = $this->factory->group->create( array( 'creator_id' => $u1 ) );
|
29 |
+
$g2 = $this->factory->group->create( array( 'creator_id' => $u1 ) );
|
30 |
+
groups_join_group( $g1, $u2 );
|
31 |
+
groups_join_group( $g2, $u2 );
|
32 |
+
|
33 |
+
groups_leave_group( $g1, $u2 );
|
34 |
+
$this->assertEquals( 1, bp_get_user_meta( $u2, 'total_group_count', true ) );
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* @group total_group_count
|
39 |
+
* @group groups_ban_member
|
40 |
+
*/
|
41 |
+
public function test_total_group_count_groups_ban_member() {
|
42 |
+
$u1 = $this->create_user();
|
43 |
+
$u2 = $this->create_user();
|
44 |
+
$g1 = $this->factory->group->create( array( 'creator_id' => $u1 ) );
|
45 |
+
$g2 = $this->factory->group->create( array( 'creator_id' => $u1 ) );
|
46 |
+
groups_join_group( $g1, $u2 );
|
47 |
+
groups_join_group( $g2, $u2 );
|
48 |
+
|
49 |
+
// Fool the admin check
|
50 |
+
$this->set_current_user( $u1 );
|
51 |
+
buddypress()->is_item_admin = true;
|
52 |
+
|
53 |
+
groups_ban_member( $u2, $g1 );
|
54 |
+
|
55 |
+
$this->assertEquals( 1, bp_get_user_meta( $u2, 'total_group_count', true ) );
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* @group total_group_count
|
60 |
+
* @group groups_unban_member
|
61 |
+
*/
|
62 |
+
public function test_total_group_count_groups_unban_member() {
|
63 |
+
$u1 = $this->create_user();
|
64 |
+
$u2 = $this->create_user();
|
65 |
+
$g1 = $this->factory->group->create( array( 'creator_id' => $u1 ) );
|
66 |
+
$g2 = $this->factory->group->create( array( 'creator_id' => $u1 ) );
|
67 |
+
groups_join_group( $g1, $u2 );
|
68 |
+
groups_join_group( $g2, $u2 );
|
69 |
+
|
70 |
+
// Fool the admin check
|
71 |
+
$this->set_current_user( $u1 );
|
72 |
+
buddypress()->is_item_admin = true;
|
73 |
+
|
74 |
+
groups_ban_member( $u2, $g1 );
|
75 |
+
|
76 |
+
groups_unban_member( $u2, $g1 );
|
77 |
+
|
78 |
+
$this->assertEquals( 2, bp_get_user_meta( $u2, 'total_group_count', true ) );
|
79 |
+
}
|
80 |
+
|
81 |
+
/**
|
82 |
+
* @group total_group_count
|
83 |
+
* @group groups_accept_invite
|
84 |
+
*/
|
85 |
+
public function test_total_group_count_groups_accept_invite() {
|
86 |
+
$u1 = $this->create_user();
|
87 |
+
$u2 = $this->create_user();
|
88 |
+
$g = $this->factory->group->create();
|
89 |
+
groups_invite_user( array(
|
90 |
+
'user_id' => $u1,
|
91 |
+
'group_id' => $g,
|
92 |
+
'inviter_id' => $u2,
|
93 |
+
) );
|
94 |
+
|
95 |
+
groups_accept_invite( $u2, $g );
|
96 |
+
|
97 |
+
$this->assertEquals( 1, bp_get_user_meta( $u2, 'total_group_count', true ) );
|
98 |
+
}
|
99 |
+
|
100 |
+
/**
|
101 |
+
* @group total_group_count
|
102 |
+
* @group groups_accept_membership_request
|
103 |
+
*/
|
104 |
+
public function test_total_group_count_groups_accept_membership_request() {
|
105 |
+
$u = $this->create_user();
|
106 |
+
$g = $this->factory->group->create();
|
107 |
+
groups_send_membership_request( $u, $g );
|
108 |
+
|
109 |
+
groups_accept_membership_request( 0, $u, $g );
|
110 |
+
|
111 |
+
$this->assertEquals( 1, bp_get_user_meta( $u, 'total_group_count', true ) );
|
112 |
+
}
|
113 |
+
|
114 |
+
/**
|
115 |
+
* @group total_group_count
|
116 |
+
* @group groups_remove_member
|
117 |
+
*/
|
118 |
+
public function test_total_group_count_groups_remove_member() {
|
119 |
+
$u1 = $this->create_user();
|
120 |
+
$u2 = $this->create_user();
|
121 |
+
$g1 = $this->factory->group->create( array( 'creator_id' => $u1 ) );
|
122 |
+
$g2 = $this->factory->group->create( array( 'creator_id' => $u1 ) );
|
123 |
+
groups_join_group( $g1, $u2 );
|
124 |
+
groups_join_group( $g2, $u2 );
|
125 |
+
|
126 |
+
// Fool the admin check
|
127 |
+
$this->set_current_user( $u1 );
|
128 |
+
buddypress()->is_item_admin = true;
|
129 |
+
|
130 |
+
groups_remove_member( $u2, $g1 );
|
131 |
+
|
132 |
+
$this->assertEquals( 1, bp_get_user_meta( $u2, 'total_group_count', true ) );
|
133 |
+
}
|
134 |
+
|
135 |
+
/**
|
136 |
+
* @group total_member_count
|
137 |
+
* @group groups_join_group
|
138 |
+
*/
|
139 |
+
public function test_total_member_count_groups_join_group() {
|
140 |
+
$u1 = $this->create_user();
|
141 |
+
$u2 = $this->create_user();
|
142 |
+
$g = $this->factory->group->create( array( 'creator_id' => $u1 ) );
|
143 |
+
|
144 |
+
groups_join_group( $g, $u2 );
|
145 |
+
$this->assertEquals( 2, groups_get_groupmeta( $g, 'total_member_count' ) );
|
146 |
+
}
|
147 |
+
|
148 |
+
/**
|
149 |
+
* @group total_member_count
|
150 |
+
* @group groups_leave_group
|
151 |
+
*/
|
152 |
+
public function test_total_member_count_groups_leave_group() {
|
153 |
+
$u1 = $this->create_user();
|
154 |
+
$g1 = $this->factory->group->create( array( 'creator_id' => $u1 ) );
|
155 |
+
groups_join_group( $g1, $u1 );
|
156 |
+
|
157 |
+
groups_leave_group( $g1, $u1 );
|
158 |
+
$this->assertEquals( 1, groups_get_groupmeta( $g1, 'total_member_count' ) );
|
159 |
+
}
|
160 |
+
|
161 |
+
/**
|
162 |
+
* @group total_member_count
|
163 |
+
* @group groups_ban_member
|
164 |
+
*/
|
165 |
+
public function test_total_member_count_groups_ban_member() {
|
166 |
+
$u1 = $this->create_user();
|
167 |
+
$u2 = $this->create_user();
|
168 |
+
$g1 = $this->factory->group->create( array( 'creator_id' => $u1 ) );
|
169 |
+
groups_join_group( $g1, $u2 );
|
170 |
+
|
171 |
+
// Fool the admin check
|
172 |
+
$this->set_current_user( $u1 );
|
173 |
+
buddypress()->is_item_admin = true;
|
174 |
+
|
175 |
+
groups_ban_member( $u2, $g1 );
|
176 |
+
|
177 |
+
$this->assertEquals( 1, groups_get_groupmeta( $g1, 'total_member_count' ) );
|
178 |
+
}
|
179 |
+
|
180 |
+
/**
|
181 |
+
* @group total_member_count
|
182 |
+
* @group groups_unban_member
|
183 |
+
*/
|
184 |
+
public function test_total_member_count_groups_unban_member() {
|
185 |
+
$u1 = $this->create_user();
|
186 |
+
$u2 = $this->create_user();
|
187 |
+
$g1 = $this->factory->group->create( array( 'creator_id' => $u1 ) );
|
188 |
+
groups_join_group( $g1, $u2 );
|
189 |
+
|
190 |
+
// Fool the admin check
|
191 |
+
$this->set_current_user( $u1 );
|
192 |
+
buddypress()->is_item_admin = true;
|
193 |
+
|
194 |
+
groups_ban_member( $u2, $g1 );
|
195 |
+
|
196 |
+
groups_unban_member( $u2, $g1 );
|
197 |
+
|
198 |
+
$this->assertEquals( 2, groups_get_groupmeta( $g1, 'total_member_count' ) );
|
199 |
+
}
|
200 |
+
|
201 |
+
/**
|
202 |
+
* @group total_member_count
|
203 |
+
* @group groups_accept_invite
|
204 |
+
*/
|
205 |
+
public function test_total_member_count_groups_accept_invite() {
|
206 |
+
$u1 = $this->create_user();
|
207 |
+
$u2 = $this->create_user();
|
208 |
+
$g = $this->factory->group->create( array( 'creator_id' => $u1 ) );
|
209 |
+
groups_invite_user( array(
|
210 |
+
'user_id' => $u1,
|
211 |
+
'group_id' => $g,
|
212 |
+
'inviter_id' => $u2,
|
213 |
+
) );
|
214 |
+
|
215 |
+
groups_accept_invite( $u2, $g );
|
216 |
+
|
217 |
+
$this->assertEquals( 2, groups_get_groupmeta( $g, 'total_member_count' ) );
|
218 |
+
}
|
219 |
+
|
220 |
+
/**
|
221 |
+
* @group total_member_count
|
222 |
+
* @group groups_accept_membership_request
|
223 |
+
*/
|
224 |
+
public function test_total_member_count_groups_accept_membership_request() {
|
225 |
+
$u1 = $this->create_user();
|
226 |
+
$u2 = $this->create_user();
|
227 |
+
$g = $this->factory->group->create( array( 'creator_id' => $u1 ) );
|
228 |
+
|
229 |
+
$this->setUp_wp_mail();
|
230 |
+
groups_send_membership_request( $u2, $g );
|
231 |
+
groups_accept_membership_request( 0, $u2, $g );
|
232 |
+
$this->tearDown_wp_mail();
|
233 |
+
|
234 |
+
$this->assertEquals( 2, groups_get_groupmeta( $g, 'total_member_count' ) );
|
235 |
+
}
|
236 |
+
|
237 |
+
/**
|
238 |
+
* @group total_member_count
|
239 |
+
* @group groups_remove_member
|
240 |
+
*/
|
241 |
+
public function test_total_member_count_groups_remove_member() {
|
242 |
+
$u1 = $this->create_user();
|
243 |
+
$u2 = $this->create_user();
|
244 |
+
$g1 = $this->factory->group->create( array( 'creator_id' => $u1 ) );
|
245 |
+
groups_join_group( $g1, $u2 );
|
246 |
+
|
247 |
+
// Fool the admin check
|
248 |
+
$this->set_current_user( $u1 );
|
249 |
+
buddypress()->is_item_admin = true;
|
250 |
+
|
251 |
+
groups_remove_member( $u2, $g1 );
|
252 |
+
|
253 |
+
$this->assertEquals( 1, groups_get_groupmeta( $g1, 'total_member_count' ) );
|
254 |
+
}
|
255 |
+
|
256 |
+
/**
|
257 |
+
* @group total_member_count
|
258 |
+
* @group groups_create_group
|
259 |
+
*/
|
260 |
+
public function test_total_member_count_groups_create_group() {
|
261 |
+
$u1 = $this->create_user();
|
262 |
+
$g = groups_create_group( array(
|
263 |
+
'creator_id' => $u1,
|
264 |
+
'name' => 'Boone Is Handsome',
|
265 |
+
'description' => 'Yes',
|
266 |
+
'slug' => 'boone-is-handsome',
|
267 |
+
'status' => 'public',
|
268 |
+
'enable_forum' => 0,
|
269 |
+
'date_created' => bp_core_current_time(),
|
270 |
+
) );
|
271 |
+
|
272 |
+
$this->assertEquals( 1, groups_get_groupmeta( $g, 'total_member_count' ) );
|
273 |
+
}
|
274 |
+
|
275 |
+
/**
|
276 |
+
* @group groupmeta
|
277 |
+
* @ticket BP5180
|
278 |
+
*/
|
279 |
+
public function test_groups_update_groupmeta_with_line_breaks() {
|
280 |
+
$g = $this->factory->group->create();
|
281 |
+
$meta_value = 'Foo!
|
282 |
+
|
283 |
+
Bar!';
|
284 |
+
groups_update_groupmeta( $g, 'linebreak_test', $meta_value );
|
285 |
+
|
286 |
+
$this->assertEquals( $meta_value, groups_get_groupmeta( $g, 'linebreak_test' ) );
|
287 |
+
}
|
288 |
+
}
|
@@ -0,0 +1,410 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @group groups
|
4 |
+
* @group template
|
5 |
+
*/
|
6 |
+
class BP_Tests_Groups_Template extends BP_UnitTestCase {
|
7 |
+
public function setUp() {
|
8 |
+
parent::setUp();
|
9 |
+
}
|
10 |
+
|
11 |
+
public function tearDown() {
|
12 |
+
parent::tearDown();
|
13 |
+
}
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Integration test to make sure meta_query is getting passed through
|
17 |
+
*
|
18 |
+
* @group bp_has_groups
|
19 |
+
*/
|
20 |
+
public function test_bp_has_groups_with_meta_query() {
|
21 |
+
$g1 = $this->factory->group->create();
|
22 |
+
$g2 = $this->factory->group->create();
|
23 |
+
groups_update_groupmeta( $g1, 'foo', 'bar' );
|
24 |
+
|
25 |
+
global $groups_template;
|
26 |
+
bp_has_groups( array(
|
27 |
+
'meta_query' => array(
|
28 |
+
array(
|
29 |
+
'key' => 'foo',
|
30 |
+
'value' => 'bar',
|
31 |
+
),
|
32 |
+
),
|
33 |
+
) );
|
34 |
+
|
35 |
+
$ids = wp_list_pluck( $groups_template->groups, 'id' );
|
36 |
+
$this->assertEquals( $ids, array( $g1, ) );
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Integration test to make sure order and orderby are interpreted when
|
41 |
+
* no 'type' value has been passed
|
42 |
+
*
|
43 |
+
* @group bp_has_groups
|
44 |
+
*/
|
45 |
+
public function test_bp_has_groups_with_order_orderby_with_null_type() {
|
46 |
+
$g1 = $this->factory->group->create( array(
|
47 |
+
'name' => 'AAAAA',
|
48 |
+
'date_created' => gmdate( 'Y-m-d H:i:s', time() - 100 ),
|
49 |
+
'last_activity' => gmdate( 'Y-m-d H:i:s', time() - 1000000 ),
|
50 |
+
) );
|
51 |
+
$g2 = $this->factory->group->create( array(
|
52 |
+
'name' => 'BBBBB',
|
53 |
+
'date_created' => gmdate( 'Y-m-d H:i:s', time() - 1000000 ),
|
54 |
+
'last_activity' => gmdate( 'Y-m-d H:i:s', time() - 10000 ),
|
55 |
+
) );
|
56 |
+
$g3 = $this->factory->group->create( array(
|
57 |
+
'name' => 'CCCCC',
|
58 |
+
'date_created' => gmdate( 'Y-m-d H:i:s', time() - 10000 ),
|
59 |
+
'last_activity' => gmdate( 'Y-m-d H:i:s', time() - 10 ),
|
60 |
+
) );
|
61 |
+
|
62 |
+
global $groups_template;
|
63 |
+
bp_has_groups( array(
|
64 |
+
'order' => 'ASC',
|
65 |
+
'orderby' => 'name',
|
66 |
+
) );
|
67 |
+
|
68 |
+
$ids = wp_parse_id_list( wp_list_pluck( $groups_template->groups, 'id' ) );
|
69 |
+
$this->assertEquals( array( $g1, $g2, $g3, ), $ids );
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Integration test to make sure 'order' is set to 'DESC' and 'orderby'
|
74 |
+
* to 'last_activity' when no type or order/orderby params are passed.
|
75 |
+
* This ensures backpat with the old system, where 'active' was the
|
76 |
+
* default type param, and there were no order/orderby params.
|
77 |
+
*
|
78 |
+
* @group bp_has_groups
|
79 |
+
*/
|
80 |
+
public function test_bp_has_groups_defaults_to_DESC_last_activity_for_default_type_active_backpat() {
|
81 |
+
$g1 = $this->factory->group->create( array(
|
82 |
+
'name' => 'AAAAA',
|
83 |
+
'last_activity' => gmdate( 'Y-m-d H:i:s', time() - 100 ),
|
84 |
+
) );
|
85 |
+
$g2 = $this->factory->group->create( array(
|
86 |
+
'name' => 'BBBBB',
|
87 |
+
'last_activity' => gmdate( 'Y-m-d H:i:s', time() - 1000000 ),
|
88 |
+
) );
|
89 |
+
$g3 = $this->factory->group->create( array(
|
90 |
+
'name' => 'CCCCC',
|
91 |
+
'last_activity' => gmdate( 'Y-m-d H:i:s', time() - 10000 ),
|
92 |
+
) );
|
93 |
+
|
94 |
+
global $groups_template;
|
95 |
+
bp_has_groups();
|
96 |
+
|
97 |
+
$ids = wp_parse_id_list( wp_list_pluck( $groups_template->groups, 'id' ) );
|
98 |
+
$this->assertEquals( array( $g1, $g3, $g2, ), $ids );
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* @group bp_group_has_members
|
103 |
+
*/
|
104 |
+
public function test_bp_group_has_members_vanilla() {
|
105 |
+
$g = $this->factory->group->create();
|
106 |
+
$u1 = $this->create_user();
|
107 |
+
$u2 = $this->create_user();
|
108 |
+
|
109 |
+
$this->add_user_to_group( $u1, $g );
|
110 |
+
|
111 |
+
global $members_template;
|
112 |
+
bp_group_has_members( array(
|
113 |
+
'group_id' => $g,
|
114 |
+
'exclude_admins_mods' => false,
|
115 |
+
) );
|
116 |
+
|
117 |
+
$ids = wp_parse_id_list( wp_list_pluck( $members_template->members, 'user_id' ) );
|
118 |
+
$this->assertEquals( array( $u1, ), $ids );
|
119 |
+
}
|
120 |
+
|
121 |
+
/**
|
122 |
+
* Switching from BP_Groups_Member to BP_Group_Member_Query meant a
|
123 |
+
* change in the format of the values returned from the query. For
|
124 |
+
* backward compatibility, we translate some of the return values
|
125 |
+
* of BP_Group_Member_Query to the older format. This test makes sure
|
126 |
+
* that the translation happens properly.
|
127 |
+
*
|
128 |
+
* @group bp_group_has_members
|
129 |
+
*/
|
130 |
+
public function test_bp_group_has_members_backpat_retval_format() {
|
131 |
+
$u1 = $this->create_user();
|
132 |
+
$u2 = $this->create_user();
|
133 |
+
$g = $this->factory->group->create( array( 'creator_id' => $u2 ) );
|
134 |
+
|
135 |
+
$date_modified = gmdate( 'Y-m-d H:i:s', time() - 100 );
|
136 |
+
|
137 |
+
$this->add_user_to_group( $u1, $g, array( 'date_modified' => $date_modified ) );
|
138 |
+
|
139 |
+
global $members_template;
|
140 |
+
bp_group_has_members( array(
|
141 |
+
'group_id' => $g,
|
142 |
+
) );
|
143 |
+
|
144 |
+
$u1_object = new WP_User( $u1 );
|
145 |
+
|
146 |
+
$expected = new stdClass;
|
147 |
+
$expected->user_id = $u1;
|
148 |
+
$expected->date_modified = $date_modified;
|
149 |
+
$expected->is_banned = 0;
|
150 |
+
$expected->user_login = $u1_object->user_login;
|
151 |
+
$expected->user_nicename = $u1_object->user_nicename;
|
152 |
+
$expected->user_email = $u1_object->user_email;
|
153 |
+
$expected->display_name = $u1_object->display_name;
|
154 |
+
|
155 |
+
// In order to use assertEquals, we need to discard the
|
156 |
+
// irrelevant properties of the found object. Hack alert
|
157 |
+
$found = new stdClass;
|
158 |
+
foreach ( array( 'user_id', 'date_modified', 'is_banned', 'user_login', 'user_nicename', 'user_email', 'display_name' ) as $key ) {
|
159 |
+
if ( isset( $members_template->members[0]->{$key} ) ) {
|
160 |
+
$found->{$key} = $members_template->members[0]->{$key};
|
161 |
+
}
|
162 |
+
}
|
163 |
+
|
164 |
+
$this->assertEquals( $expected, $found );
|
165 |
+
}
|
166 |
+
|
167 |
+
/**
|
168 |
+
* @group bp_group_has_members
|
169 |
+
*/
|
170 |
+
public function test_bp_group_has_members_with_per_page() {
|
171 |
+
$g = $this->factory->group->create();
|
172 |
+
|
173 |
+
$users = array();
|
174 |
+
for ( $i = 1; $i <= 10; $i++ ) {
|
175 |
+
$users[ $i ] = $this->create_user();
|
176 |
+
}
|
177 |
+
|
178 |
+
$expected = array();
|
179 |
+
$now = time();
|
180 |
+
for ( $i = 3; $i <= 10; $i++ ) {
|
181 |
+
$this->add_user_to_group( $users[ $i ], $g, array(
|
182 |
+
'date_modified' => $now - 60 * $i,
|
183 |
+
) );
|
184 |
+
$expected[] = $users[ $i ];
|
185 |
+
}
|
186 |
+
|
187 |
+
// hack it down to 5 (per page arg below)
|
188 |
+
$expected = array_slice( $expected, 0, 5 );
|
189 |
+
|
190 |
+
global $members_template;
|
191 |
+
bp_group_has_members( array(
|
192 |
+
'group_id' => $g,
|
193 |
+
'per_page' => 5,
|
194 |
+
) );
|
195 |
+
|
196 |
+
$ids = wp_parse_id_list( wp_list_pluck( $members_template->members, 'user_id' ) );
|
197 |
+
$this->assertEquals( $expected, $ids );
|
198 |
+
}
|
199 |
+
|
200 |
+
/**
|
201 |
+
* Note: 'max' is a weird parameter. It just changes the member_count
|
202 |
+
* in the global - not the sql query at all. I'm testing what it
|
203 |
+
* appears to be designed to do, not what it feels like it ought to do
|
204 |
+
* if it made any sense. Programming is fun, QED.
|
205 |
+
*
|
206 |
+
* @group bp_group_has_members
|
207 |
+
*/
|
208 |
+
public function test_bp_group_has_members_with_max() {
|
209 |
+
$g = $this->factory->group->create();
|
210 |
+
|
211 |
+
$users = array();
|
212 |
+
for ( $i = 1; $i <= 10; $i++ ) {
|
213 |
+
$users[ $i ] = $this->create_user();
|
214 |
+
}
|
215 |
+
|
216 |
+
$expected = array();
|
217 |
+
for ( $i = 3; $i <= 10; $i++ ) {
|
218 |
+
$this->add_user_to_group( $users[ $i ], $g );
|
219 |
+
$expected[] = $users[ $i ];
|
220 |
+
}
|
221 |
+
|
222 |
+
global $members_template;
|
223 |
+
bp_group_has_members( array(
|
224 |
+
'group_id' => $g,
|
225 |
+
'max' => 5,
|
226 |
+
) );
|
227 |
+
|
228 |
+
$this->assertEquals( 5, $members_template->member_count );
|
229 |
+
}
|
230 |
+
|
231 |
+
/**
|
232 |
+
* @group bp_group_has_members
|
233 |
+
*/
|
234 |
+
public function test_bp_group_has_members_with_exclude() {
|
235 |
+
$g = $this->factory->group->create();
|
236 |
+
$u1 = $this->create_user();
|
237 |
+
$u2 = $this->create_user();
|
238 |
+
|
239 |
+
$this->add_user_to_group( $u1, $g );
|
240 |
+
$this->add_user_to_group( $u2, $g );
|
241 |
+
|
242 |
+
global $members_template;
|
243 |
+
bp_group_has_members( array(
|
244 |
+
'group_id' => $g,
|
245 |
+
'exclude' => $u1,
|
246 |
+
) );
|
247 |
+
|
248 |
+
$ids = wp_parse_id_list( wp_list_pluck( $members_template->members, 'user_id' ) );
|
249 |
+
$this->assertEquals( array( $u2 ), $ids );
|
250 |
+
}
|
251 |
+
|
252 |
+
/**
|
253 |
+
* @group bp_group_has_members
|
254 |
+
*/
|
255 |
+
public function test_bp_group_has_members_with_exclude_admins_mods_1() {
|
256 |
+
$g = $this->factory->group->create();
|
257 |
+
$u1 = $this->create_user();
|
258 |
+
$u2 = $this->create_user();
|
259 |
+
$u3 = $this->create_user();
|
260 |
+
|
261 |
+
$this->add_user_to_group( $u1, $g );
|
262 |
+
$this->add_user_to_group( $u2, $g );
|
263 |
+
$this->add_user_to_group( $u3, $g );
|
264 |
+
|
265 |
+
$m1 = new BP_Groups_Member( $u1, $g );
|
266 |
+
$m1->promote( 'admin' );
|
267 |
+
$m2 = new BP_Groups_Member( $u2, $g );
|
268 |
+
$m2->promote( 'mod' );
|
269 |
+
|
270 |
+
global $members_template;
|
271 |
+
bp_group_has_members( array(
|
272 |
+
'group_id' => $g,
|
273 |
+
'exclude_admins_mods' => 1,
|
274 |
+
) );
|
275 |
+
|
276 |
+
$ids = wp_parse_id_list( wp_list_pluck( $members_template->members, 'user_id' ) );
|
277 |
+
$this->assertEquals( array( $u3 ), $ids );
|
278 |
+
}
|
279 |
+
|
280 |
+
/**
|
281 |
+
* @group bp_group_has_members
|
282 |
+
*/
|
283 |
+
public function test_bp_group_has_members_with_exclude_admins_mods_0() {
|
284 |
+
$u1 = $this->create_user();
|
285 |
+
$u2 = $this->create_user();
|
286 |
+
$u3 = $this->create_user();
|
287 |
+
$g = $this->factory->group->create( array(
|
288 |
+
'creator_id' => $u1,
|
289 |
+
) );
|
290 |
+
|
291 |
+
$now = time();
|
292 |
+
$this->add_user_to_group( $u2, $g, array(
|
293 |
+
'date_modified' => $now - 60,
|
294 |
+
) );
|
295 |
+
$this->add_user_to_group( $u3, $g, array(
|
296 |
+
'date_modified' => $now - 60*60,
|
297 |
+
) );
|
298 |
+
|
299 |
+
$m1 = new BP_Groups_Member( $u1, $g );
|
300 |
+
$m1->promote( 'admin' );
|
301 |
+
$m2 = new BP_Groups_Member( $u2, $g );
|
302 |
+
$m2->promote( 'mod' );
|
303 |
+
|
304 |
+
global $members_template;
|
305 |
+
bp_group_has_members( array(
|
306 |
+
'group_id' => $g,
|
307 |
+
'exclude_admins_mods' => 0,
|
308 |
+
) );
|
309 |
+
|
310 |
+
$ids = wp_parse_id_list( wp_list_pluck( $members_template->members, 'user_id' ) );
|
311 |
+
$this->assertEquals( array( $u1, $u2, $u3 ), $ids );
|
312 |
+
}
|
313 |
+
|
314 |
+
/**
|
315 |
+
* @group bp_group_has_members
|
316 |
+
*/
|
317 |
+
public function test_bp_group_has_members_with_exclude_banned_1() {
|
318 |
+
$g = $this->factory->group->create();
|
319 |
+
$u1 = $this->create_user();
|
320 |
+
$u2 = $this->create_user();
|
321 |
+
|
322 |
+
$this->add_user_to_group( $u1, $g );
|
323 |
+
$this->add_user_to_group( $u2, $g );
|
324 |
+
|
325 |
+
$m1 = new BP_Groups_Member( $u1, $g );
|
326 |
+
$m1->ban();
|
327 |
+
|
328 |
+
global $members_template;
|
329 |
+
bp_group_has_members( array(
|
330 |
+
'group_id' => $g,
|
331 |
+
'exclude_banned' => 1,
|
332 |
+
) );
|
333 |
+
|
334 |
+
$ids = wp_parse_id_list( wp_list_pluck( $members_template->members, 'user_id' ) );
|
335 |
+
$this->assertEquals( array( $u2, ), $ids );
|
336 |
+
}
|
337 |
+
|
338 |
+
/**
|
339 |
+
* @group bp_group_has_members
|
340 |
+
*/
|
341 |
+
public function test_bp_group_has_members_with_exclude_banned_0() {
|
342 |
+
$u1 = $this->create_user();
|
343 |
+
$u2 = $this->create_user();
|
344 |
+
$u3 = $this->create_user();
|
345 |
+
|
346 |
+
$g = $this->factory->group->create( array(
|
347 |
+
'creator_id' => $u1,
|
348 |
+
) );
|
349 |
+
|
350 |
+
$this->add_user_to_group( $u2, $g, array(
|
351 |
+
'date_modified' => gmdate( 'Y-m-d H:i:s', time() - 60*60*24 ),
|
352 |
+
) );
|
353 |
+
$this->add_user_to_group( $u3, $g, array(
|
354 |
+
'date_modified' => gmdate( 'Y-m-d H:i:s', time() - 60*60*12 ),
|
355 |
+
) );
|
356 |
+
|
357 |
+
$m2 = new BP_Groups_Member( $u2, $g );
|
358 |
+
$m2->ban();
|
359 |
+
|
360 |
+
global $members_template;
|
361 |
+
bp_group_has_members( array(
|
362 |
+
'group_id' => $g,
|
363 |
+
'exclude_banned' => 0,
|
364 |
+
'exclude_admins_mods' => false,
|
365 |
+
) );
|
366 |
+
|
367 |
+
$ids = wp_parse_id_list( wp_list_pluck( $members_template->members, 'user_id' ) );
|
368 |
+
$this->assertEquals( array( $u1, $u3, $u2 ), $ids );
|
369 |
+
}
|
370 |
+
|
371 |
+
/**
|
372 |
+
* Default sort order should be the joined date
|
373 |
+
*
|
374 |
+
* @tickett BP5106
|
375 |
+
* @group bp_group_has_members
|
376 |
+
*/
|
377 |
+
public function test_bp_group_has_members_default_order() {
|
378 |
+
$u1 = $this->create_user( array(
|
379 |
+
'last_activity' => gmdate( 'Y-m-d H:i:s', time() - 60 ),
|
380 |
+
) );
|
381 |
+
$u2 = $this->create_user( array(
|
382 |
+
'last_activity' => gmdate( 'Y-m-d H:i:s', time() - 600 ),
|
383 |
+
) );
|
384 |
+
$u3 = $this->create_user( array(
|
385 |
+
'last_activity' => gmdate( 'Y-m-d H:i:s', time() - 6000 ),
|
386 |
+
) );
|
387 |
+
|
388 |
+
$g = $this->factory->group->create( array(
|
389 |
+
'creator_id' => $u1,
|
390 |
+
) );
|
391 |
+
|
392 |
+
$this->add_user_to_group( $u2, $g, array(
|
393 |
+
'date_modified' => gmdate( 'Y-m-d H:i:s', time() - 60*60*24 ),
|
394 |
+
) );
|
395 |
+
|
396 |
+
$this->add_user_to_group( $u3, $g, array(
|
397 |
+
'date_modified' => gmdate( 'Y-m-d H:i:s', time() - 60*60*12 ),
|
398 |
+
) );
|
399 |
+
|
400 |
+
global $members_template;
|
401 |
+
bp_group_has_members( array(
|
402 |
+
'group_id' => $g,
|
403 |
+
'exclude_banned' => 0,
|
404 |
+
'exclude_admins_mods' => false,
|
405 |
+
) );
|
406 |
+
|
407 |
+
$ids = wp_parse_id_list( wp_list_pluck( $members_template->members, 'user_id' ) );
|
408 |
+
$this->assertEquals( array( $u1, $u3, $u2, ), $ids );
|
409 |
+
}
|
410 |
+
}
|
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @group members
|
4 |
+
*/
|
5 |
+
class BP_Tests_Members_Functions extends BP_UnitTestCase {
|
6 |
+
protected $old_current_user = 0;
|
7 |
+
|
8 |
+
public function setUp() {
|
9 |
+
parent::setUp();
|
10 |
+
|
11 |
+
$this->old_current_user = get_current_user_id();
|
12 |
+
$this->set_current_user( $this->factory->user->create( array( 'role' => 'subscriber' ) ) );
|
13 |
+
}
|
14 |
+
|
15 |
+
public function tearDown() {
|
16 |
+
parent::tearDown();
|
17 |
+
$this->set_current_user( $this->old_current_user );
|
18 |
+
}
|
19 |
+
|
20 |
+
/**
|
21 |
+
* ticket BP4915
|
22 |
+
*/
|
23 |
+
public function test_bp_core_delete_account() {
|
24 |
+
// Stash
|
25 |
+
$current_user = get_current_user_id();
|
26 |
+
$deletion_disabled = bp_disable_account_deletion();
|
27 |
+
|
28 |
+
// Create an admin for testing
|
29 |
+
$admin_user = $this->factory->user->create( array( 'role' => 'administrator' ) );
|
30 |
+
$this->grant_super_admin( $admin_user );
|
31 |
+
|
32 |
+
// 1. Admin can delete user account
|
33 |
+
$this->set_current_user( $admin_user );
|
34 |
+
$user1 = $this->factory->user->create( array( 'role' => 'subscriber' ) );
|
35 |
+
bp_core_delete_account( $user1 );
|
36 |
+
$maybe_user = new WP_User( $user1 );
|
37 |
+
$this->assertEquals( 0, $maybe_user->ID );
|
38 |
+
unset( $maybe_user );
|
39 |
+
|
40 |
+
// 2. Admin cannot delete superadmin account
|
41 |
+
$user2 = $this->factory->user->create( array( 'role' => 'administrator' ) );
|
42 |
+
$this->grant_super_admin( $user2 );
|
43 |
+
bp_core_delete_account( $user2 );
|
44 |
+
$maybe_user = new WP_User( $user2 );
|
45 |
+
$this->assertNotEquals( 0, $maybe_user->ID );
|
46 |
+
unset( $maybe_user );
|
47 |
+
|
48 |
+
// User cannot delete other's account
|
49 |
+
$user3 = $this->factory->user->create( array( 'role' => 'subscriber' ) );
|
50 |
+
$user4 = $this->factory->user->create( array( 'role' => 'subscriber' ) );
|
51 |
+
$this->set_current_user( $user3 );
|
52 |
+
bp_core_delete_account( $user4 );
|
53 |
+
$maybe_user = new WP_User( $user4 );
|
54 |
+
$this->assertNotEquals( 0, $maybe_user->ID );
|
55 |
+
unset( $maybe_user );
|
56 |
+
|
57 |
+
// User cannot delete own account when account deletion is disabled
|
58 |
+
$user5 = $this->factory->user->create( array( 'role' => 'subscriber' ) );
|
59 |
+
$this->set_current_user( $user5 );
|
60 |
+
bp_update_option( 'bp-disable-account-deletion', 1 );
|
61 |
+
bp_core_delete_account( $user5 );
|
62 |
+
$maybe_user = new WP_User( $user5 );
|
63 |
+
$this->assertNotEquals( 0, $maybe_user->ID );
|
64 |
+
unset( $maybe_user );
|
65 |
+
|
66 |
+
// User can delete own account when account deletion is enabled
|
67 |
+
$user6 = $this->factory->user->create( array( 'role' => 'subscriber' ) );
|
68 |
+
$this->set_current_user( $user6 );
|
69 |
+
bp_update_option( 'bp-disable-account-deletion', 0 );
|
70 |
+
bp_core_delete_account( $user6 );
|
71 |
+
$maybe_user = new WP_User( $user6 );
|
72 |
+
$this->assertEquals( 0, $maybe_user->ID );
|
73 |
+
unset( $maybe_user );
|
74 |
+
|
75 |
+
// Cleanup
|
76 |
+
$this->set_current_user( $current_user );
|
77 |
+
bp_update_option( 'bp-disable-account-deletion', $deletion_disabled );
|
78 |
+
}
|
79 |
+
}
|
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @group members
|
4 |
+
*/
|
5 |
+
class BP_Tests_Members_Template extends BP_UnitTestCase {
|
6 |
+
protected $old_current_user = 0;
|
7 |
+
|
8 |
+
public function setUp() {
|
9 |
+
parent::setUp();
|
10 |
+
|
11 |
+
$this->old_current_user = get_current_user_id();
|
12 |
+
$new_user = $this->factory->user->create( array( 'role' => 'administrator' ) );
|
13 |
+
$this->set_current_user( $new_user );
|
14 |
+
|
15 |
+
}
|
16 |
+
|
17 |
+
public function tearDown() {
|
18 |
+
parent::tearDown();
|
19 |
+
$this->set_current_user( $this->old_current_user );
|
20 |
+
}
|
21 |
+
|
22 |
+
public function test_bp_has_members_include_on_user_page() {
|
23 |
+
$u1 = $this->create_user();
|
24 |
+
$u2 = $this->create_user();
|
25 |
+
|
26 |
+
$this->go_to( bp_core_get_user_domain( $u1 ) );
|
27 |
+
|
28 |
+
global $members_template;
|
29 |
+
bp_has_members( array(
|
30 |
+
'include' => array( $u1, $u2 ),
|
31 |
+
) );
|
32 |
+
|
33 |
+
$users = is_array( $members_template->members ) ? array_values( $members_template->members ) : array();
|
34 |
+
$user_ids = wp_list_pluck( $users, 'ID' );
|
35 |
+
sort( $user_ids );
|
36 |
+
|
37 |
+
$shouldbe = array( $u1, $u2 );
|
38 |
+
sort( $shouldbe );
|
39 |
+
|
40 |
+
$this->assertEquals( $user_ids, $shouldbe );
|
41 |
+
}
|
42 |
+
|
43 |
+
public function test_bp_has_members_friendship_requests() {
|
44 |
+
$u1 = $this->create_user();
|
45 |
+
$u2 = $this->create_user();
|
46 |
+
|
47 |
+
$this->setUp_wp_mail();
|
48 |
+
friends_add_friend( $u1, $u2 );
|
49 |
+
$this->tearDown_wp_mail();
|
50 |
+
|
51 |
+
$old_user = get_current_user_id();
|
52 |
+
$this->set_current_user( $u2 );
|
53 |
+
|
54 |
+
$this->go_to( bp_core_get_user_domain( $u2 ) . bp_get_friends_slug() . '/requests/' );
|
55 |
+
$this->restore_admins();
|
56 |
+
|
57 |
+
global $members_template;
|
58 |
+
bp_has_members( array(
|
59 |
+
'include' => bp_get_friendship_requests( $u2 ),
|
60 |
+
) );
|
61 |
+
|
62 |
+
$requests = is_array( $members_template->members ) ? array_values( $members_template->members ) : array();
|
63 |
+
$request_ids = wp_list_pluck( $requests, 'ID' );
|
64 |
+
$this->assertEquals( $request_ids, array( $u1 ) );
|
65 |
+
|
66 |
+
$this->set_current_user( $old_user );
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* @group bp_has_members
|
71 |
+
* @group friends
|
72 |
+
* @ticket BP5071
|
73 |
+
*/
|
74 |
+
public function test_bp_has_members_friendship_requests_with_no_requests() {
|
75 |
+
$u1 = $this->create_user();
|
76 |
+
$u2 = $this->create_user();
|
77 |
+
|
78 |
+
$old_user = get_current_user_id();
|
79 |
+
$this->set_current_user( $u2 );
|
80 |
+
|
81 |
+
// For some reason, in all the user switching, the cache gets
|
82 |
+
// confused. Never comes up when BP runs normally, because the
|
83 |
+
// loggedin_user doesn't change on a pageload. @todo Fix for
|
84 |
+
// real in BP
|
85 |
+
wp_cache_delete( 'bp_user_domain_' . $u2, 'bp' );
|
86 |
+
|
87 |
+
$this->go_to( bp_core_get_user_domain( $u2 ) . bp_get_friends_slug() . '/requests/' );
|
88 |
+
$this->restore_admins();
|
89 |
+
|
90 |
+
global $members_template;
|
91 |
+
bp_has_members( array(
|
92 |
+
'include' => bp_get_friendship_requests( $u2 ),
|
93 |
+
) );
|
94 |
+
|
95 |
+
$requests = is_array( $members_template->members ) ? array_values( $members_template->members ) : array();
|
96 |
+
$request_ids = wp_list_pluck( $requests, 'ID' );
|
97 |
+
$this->assertEquals( array(), $request_ids );
|
98 |
+
|
99 |
+
$this->set_current_user( $old_user );
|
100 |
+
}
|
101 |
+
|
102 |
+
}
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @group activity
|
4 |
+
* @group routing
|
5 |
+
*/
|
6 |
+
class BP_Tests_Routing_Activity extends BP_UnitTestCase {
|
7 |
+
protected $old_current_user = 0;
|
8 |
+
|
9 |
+
public function setUp() {
|
10 |
+
parent::setUp();
|
11 |
+
|
12 |
+
$this->old_current_user = get_current_user_id();
|
13 |
+
$this->set_current_user( $this->factory->user->create( array( 'role' => 'subscriber' ) ) );
|
14 |
+
}
|
15 |
+
|
16 |
+
public function tearDown() {
|
17 |
+
parent::tearDown();
|
18 |
+
$this->set_current_user( $this->old_current_user );
|
19 |
+
}
|
20 |
+
|
21 |
+
function test_activity_directory() {
|
22 |
+
$this->go_to( bp_get_activity_directory_permalink() );
|
23 |
+
$this->assertEquals( bp_get_activity_root_slug(), bp_current_component() );
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Can't test using bp_activity_get_permalink(); see bp_activity_action_permalink_router().
|
28 |
+
*/
|
29 |
+
function test_activity_permalink() {
|
30 |
+
$a = $this->factory->activity->create();
|
31 |
+
$activity = $this->factory->activity->get_object_by_id( $a );
|
32 |
+
|
33 |
+
$url = bp_core_get_user_domain( $activity->user_id ) . bp_get_activity_slug() . '/' . $activity->id . '/';
|
34 |
+
$this->go_to( $url );
|
35 |
+
$this->assertTrue( bp_is_single_activity() );
|
36 |
+
}
|
37 |
+
|
38 |
+
function test_member_activity() {
|
39 |
+
$this->go_to( bp_core_get_user_domain( bp_loggedin_user_id() ) . bp_get_activity_slug() );
|
40 |
+
$this->assertTrue( bp_is_user_activity() );
|
41 |
+
}
|
42 |
+
|
43 |
+
function test_member_activity_mentions() {
|
44 |
+
$this->go_to( bp_core_get_user_domain( bp_loggedin_user_id() ) . bp_get_activity_slug() . '/mentions' );
|
45 |
+
$this->assertTrue( bp_is_user_activity() );
|
46 |
+
}
|
47 |
+
|
48 |
+
function test_member_activity_favourites() {
|
49 |
+
$this->go_to( bp_core_get_user_domain( bp_loggedin_user_id() ) . bp_get_activity_slug() . '/favorites' );
|
50 |
+
$this->assertTrue( bp_is_user_activity() );
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* @group friends
|
55 |
+
*/
|
56 |
+
function test_member_activity_friends() {
|
57 |
+
$this->go_to( bp_core_get_user_domain( bp_loggedin_user_id() ) . bp_get_activity_slug() . '/' . bp_get_friends_slug() );
|
58 |
+
$this->assertTrue( bp_is_user_friends_activity() );
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* @group groups
|
63 |
+
*/
|
64 |
+
function test_member_activity_groups() {
|
65 |
+
$this->go_to( bp_core_get_user_domain( bp_loggedin_user_id() ) . bp_get_activity_slug() . '/' . bp_get_groups_slug() );
|
66 |
+
$this->assertTrue( bp_is_user_groups_activity() );
|
67 |
+
}
|
68 |
+
}
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @group routing
|
4 |
+
*/
|
5 |
+
class BP_Tests_Routing_Anonymous extends BP_UnitTestCase {
|
6 |
+
protected $old_current_user = 0;
|
7 |
+
|
8 |
+
public function setUp() {
|
9 |
+
parent::setUp();
|
10 |
+
|
11 |
+
$this->old_current_user = get_current_user_id();
|
12 |
+
$this->set_current_user( 0 );
|
13 |
+
}
|
14 |
+
|
15 |
+
public function tearDown() {
|
16 |
+
parent::tearDown();
|
17 |
+
$this->set_current_user( $this->old_current_user );
|
18 |
+
}
|
19 |
+
|
20 |
+
function test_wordpress_page() {
|
21 |
+
$this->go_to( '/' );
|
22 |
+
$this->assertEmpty( bp_current_component() );
|
23 |
+
}
|
24 |
+
|
25 |
+
function test_nav_menu() {
|
26 |
+
$this->go_to( '/' );
|
27 |
+
$this->assertEmpty( buddypress()->bp_nav );
|
28 |
+
}
|
29 |
+
}
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @group core
|
4 |
+
* @group routing
|
5 |
+
*/
|
6 |
+
class BP_Tests_Routing_Core extends BP_UnitTestCase {
|
7 |
+
protected $old_current_user = 0;
|
8 |
+
|
9 |
+
public function setUp() {
|
10 |
+
parent::setUp();
|
11 |
+
|
12 |
+
$this->old_current_user = get_current_user_id();
|
13 |
+
$this->set_current_user( $this->factory->user->create( array( 'role' => 'subscriber' ) ) );
|
14 |
+
}
|
15 |
+
|
16 |
+
public function tearDown() {
|
17 |
+
parent::tearDown();
|
18 |
+
$this->set_current_user( $this->old_current_user );
|
19 |
+
}
|
20 |
+
|
21 |
+
function test_wordpress_page() {
|
22 |
+
$this->go_to( '/' );
|
23 |
+
$this->assertEmpty( bp_current_component() );
|
24 |
+
}
|
25 |
+
|
26 |
+
function test_nav_menu() {
|
27 |
+
$this->go_to( '/' );
|
28 |
+
$this->assertArrayHasKey( 'activity', buddypress()->bp_nav );
|
29 |
+
$this->assertArrayHasKey( 'profile', buddypress()->bp_nav );
|
30 |
+
}
|
31 |
+
}
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @group friends
|
4 |
+
* @group routing
|
5 |
+
*/
|
6 |
+
class BP_Tests_Routing_Friends extends BP_UnitTestCase {
|
7 |
+
protected $old_current_user = 0;
|
8 |
+
|
9 |
+
public function setUp() {
|
10 |
+
parent::setUp();
|
11 |
+
|
12 |
+
$this->old_current_user = get_current_user_id();
|
13 |
+
$this->set_current_user( $this->factory->user->create( array( 'role' => 'subscriber' ) ) );
|
14 |
+
}
|
15 |
+
|
16 |
+
public function tearDown() {
|
17 |
+
parent::tearDown();
|
18 |
+
$this->set_current_user( $this->old_current_user );
|
19 |
+
}
|
20 |
+
|
21 |
+
function test_member_friends() {
|
22 |
+
$this->go_to( bp_core_get_user_domain( bp_loggedin_user_id() ) . bp_get_friends_slug() );
|
23 |
+
$this->assertTrue( bp_is_user_friends() );
|
24 |
+
}
|
25 |
+
|
26 |
+
function test_member_friends_requests() {
|
27 |
+
$this->go_to( bp_core_get_user_domain( bp_loggedin_user_id() ) . bp_get_friends_slug() . '/requests' );
|
28 |
+
$this->assertTrue( bp_is_user_friend_requests() );
|
29 |
+
}
|
30 |
+
}
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @group groups
|
4 |
+
* @group routing
|
5 |
+
*/
|
6 |
+
class BP_Tests_Routing_Groups extends BP_UnitTestCase {
|
7 |
+
protected $old_current_user = 0;
|
8 |
+
|
9 |
+
public function setUp() {
|
10 |
+
parent::setUp();
|
11 |
+
|
12 |
+
$this->old_current_user = get_current_user_id();
|
13 |
+
$this->set_current_user( $this->factory->user->create( array( 'role' => 'subscriber' ) ) );
|
14 |
+
}
|
15 |
+
|
16 |
+
public function tearDown() {
|
17 |
+
parent::tearDown();
|
18 |
+
$this->set_current_user( $this->old_current_user );
|
19 |
+
}
|
20 |
+
|
21 |
+
function test_member_groups() {
|
22 |
+
$this->go_to( bp_core_get_user_domain( bp_loggedin_user_id() ) . bp_get_groups_slug() );
|
23 |
+
$this->assertTrue( bp_is_user_groups() );
|
24 |
+
}
|
25 |
+
|
26 |
+
function test_member_groups_invitations() {
|
27 |
+
$this->go_to( bp_core_get_user_domain( bp_loggedin_user_id() ) . bp_get_groups_slug() . '/invites' );
|
28 |
+
$this->assertTrue( bp_is_user_groups() && bp_is_current_action( 'invites' ) );
|
29 |
+
}
|
30 |
+
}
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @group members
|
4 |
+
* @group routing
|
5 |
+
*/
|
6 |
+
class BP_Tests_Routing_Members extends BP_UnitTestCase {
|
7 |
+
protected $old_current_user = 0;
|
8 |
+
|
9 |
+
public function setUp() {
|
10 |
+
parent::setUp();
|
11 |
+
|
12 |
+
$this->old_current_user = get_current_user_id();
|
13 |
+
$this->set_current_user( $this->factory->user->create( array( 'user_login' => 'paulgibbs', 'role' => 'subscriber' ) ) );
|
14 |
+
}
|
15 |
+
|
16 |
+
public function tearDown() {
|
17 |
+
parent::tearDown();
|
18 |
+
$this->set_current_user( $this->old_current_user );
|
19 |
+
}
|
20 |
+
|
21 |
+
function test_members_directory() {
|
22 |
+
$this->go_to( bp_get_members_directory_permalink() );
|
23 |
+
$this->assertEquals( bp_get_members_root_slug(), bp_current_component() );
|
24 |
+
}
|
25 |
+
|
26 |
+
function test_member_permalink() {
|
27 |
+
$this->go_to( bp_core_get_user_domain( bp_loggedin_user_id() ) );
|
28 |
+
$this->assertTrue( bp_is_my_profile() );
|
29 |
+
}
|
30 |
+
}
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @group messages
|
4 |
+
* @group routing
|
5 |
+
*/
|
6 |
+
class BP_Tests_Routing_Messages extends BP_UnitTestCase {
|
7 |
+
protected $old_current_user = 0;
|
8 |
+
|
9 |
+
public function setUp() {
|
10 |
+
parent::setUp();
|
11 |
+
|
12 |
+
$this->old_current_user = get_current_user_id();
|
13 |
+
$this->set_current_user( $this->factory->user->create( array( 'role' => 'subscriber' ) ) );
|
14 |
+
}
|
15 |
+
|
16 |
+
public function tearDown() {
|
17 |
+
parent::tearDown();
|
18 |
+
$this->set_current_user( $this->old_current_user );
|
19 |
+
}
|
20 |
+
|
21 |
+
function test_member_messages() {
|
22 |
+
$this->go_to( bp_core_get_user_domain( bp_loggedin_user_id() ) . bp_get_messages_slug() );
|
23 |
+
$this->assertTrue( bp_is_messages_inbox() );
|
24 |
+
}
|
25 |
+
|
26 |
+
function test_member_messages_sentbox() {
|
27 |
+
$this->go_to( bp_core_get_user_domain( bp_loggedin_user_id() ) . bp_get_messages_slug() . '/sentbox' );
|
28 |
+
$this->assertTrue( bp_is_messages_sentbox() );
|
29 |
+
}
|
30 |
+
|
31 |
+
function test_member_messages_compose() {
|
32 |
+
$this->go_to( bp_core_get_user_domain( bp_loggedin_user_id() ) . bp_get_messages_slug() . '/compose' );
|
33 |
+
$this->assertTrue( bp_is_messages_compose_screen() );
|
34 |
+
}
|
35 |
+
|
36 |
+
function test_member_messages_notices() {
|
37 |
+
$this->go_to( bp_core_get_user_domain( bp_loggedin_user_id() ) . bp_get_messages_slug() . '/notices' );
|
38 |
+
$this->assertTrue( bp_is_notices() );
|
39 |
+
}
|
40 |
+
}
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @group settings
|
4 |
+
* @group routing
|
5 |
+
*/
|
6 |
+
class BP_Tests_Routing_Settings extends BP_UnitTestCase {
|
7 |
+
protected $old_current_user = 0;
|
8 |
+
|
9 |
+
public function setUp() {
|
10 |
+
parent::setUp();
|
11 |
+
|
12 |
+
$this->old_current_user = get_current_user_id();
|
13 |
+
$this->set_current_user( $this->factory->user->create( array( 'role' => 'subscriber' ) ) );
|
14 |
+
}
|
15 |
+
|
16 |
+
public function tearDown() {
|
17 |
+
parent::tearDown();
|
18 |
+
$this->set_current_user( $this->old_current_user );
|
19 |
+
}
|
20 |
+
|
21 |
+
function test_member_settings() {
|
22 |
+
$this->go_to( bp_core_get_user_domain( bp_loggedin_user_id() ) . bp_get_settings_slug() );
|
23 |
+
$this->assertTrue( bp_is_user_settings_general() );
|
24 |
+
}
|
25 |
+
|
26 |
+
function test_member_settings_notifications() {
|
27 |
+
$this->go_to( bp_core_get_user_domain( bp_loggedin_user_id() ) . bp_get_settings_slug() . '/notifications' );
|
28 |
+
$this->assertTrue( bp_is_user_settings_notifications() );
|
29 |
+
}
|
30 |
+
|
31 |
+
// @todo How best to test this?
|
32 |
+
/*function bp_is_user_settings_account_capbilities() {
|
33 |
+
$this->go_to( bp_core_get_user_domain( bp_loggedin_user_id() ) . bp_get_settings_slug() . '/capabilities' );
|
34 |
+
}*/
|
35 |
+
|
36 |
+
function bp_is_user_settings_account_delete() {
|
37 |
+
$this->go_to( bp_core_get_user_domain( bp_loggedin_user_id() ) . bp_get_settings_slug() . '/delete-account' );
|
38 |
+
$this->assertTrue( bp_is_user_settings_account_delete() );
|
39 |
+
}
|
40 |
+
}
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @group xprofile
|
4 |
+
* @group routing
|
5 |
+
*/
|
6 |
+
class BP_Tests_Routing_XProfile extends BP_UnitTestCase {
|
7 |
+
protected $old_current_user = 0;
|
8 |
+
|
9 |
+
public function setUp() {
|
10 |
+
parent::setUp();
|
11 |
+
|
12 |
+
$this->old_current_user = get_current_user_id();
|
13 |
+
$this->set_current_user( $this->factory->user->create( array( 'role' => 'subscriber' ) ) );
|
14 |
+
}
|
15 |
+
|
16 |
+
public function tearDown() {
|
17 |
+
parent::tearDown();
|
18 |
+
$this->set_current_user( $this->old_current_user );
|
19 |
+
}
|
20 |
+
|
21 |
+
function test_member_profile() {
|
22 |
+
$this->go_to( bp_core_get_user_domain( bp_loggedin_user_id() ) . buddypress()->profile->slug );
|
23 |
+
$this->assertTrue( bp_is_user_profile() );
|
24 |
+
}
|
25 |
+
|
26 |
+
function test_member_profile_edit() {
|
27 |
+
$this->go_to( bp_core_get_user_domain( bp_loggedin_user_id() ) . buddypress()->profile->slug . '/edit' );
|
28 |
+
$this->assertTrue( bp_is_user_profile_edit() );
|
29 |
+
}
|
30 |
+
|
31 |
+
function test_member_profile_change_avatar() {
|
32 |
+
$this->go_to( bp_core_get_user_domain( bp_loggedin_user_id() ) . buddypress()->profile->slug . '/change-avatar' );
|
33 |
+
$this->assertTrue( bp_is_user_change_avatar() );
|
34 |
+
}
|
35 |
+
}
|
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @group url
|
4 |
+
*/
|
5 |
+
class BP_Tests_URL extends BP_UnitTestCase {
|
6 |
+
protected $old_current_user = 0;
|
7 |
+
|
8 |
+
public function setUp() {
|
9 |
+
parent::setUp();
|
10 |
+
|
11 |
+
$this->old_current_user = get_current_user_id();
|
12 |
+
$this->set_current_user( $this->factory->user->create( array( 'role' => 'subscriber' ) ) );
|
13 |
+
}
|
14 |
+
|
15 |
+
public function tearDown() {
|
16 |
+
parent::tearDown();
|
17 |
+
$this->set_current_user( $this->old_current_user );
|
18 |
+
}
|
19 |
+
|
20 |
+
function test_bp_core_ajax_url() {
|
21 |
+
$forced = force_ssl_admin();
|
22 |
+
|
23 |
+
// (1) HTTPS off
|
24 |
+
force_ssl_admin( false );
|
25 |
+
$_SERVER['HTTPS'] = 'off';
|
26 |
+
|
27 |
+
// (1a) Front-end
|
28 |
+
$this->go_to( '/' );
|
29 |
+
$this->assertEquals( bp_core_ajax_url(), get_site_url( bp_get_root_blog_id(), '/wp-admin/admin-ajax.php', 'http' ) );
|
30 |
+
|
31 |
+
// (1b) Dashboard
|
32 |
+
$this->go_to( '/wp-admin' );
|
33 |
+
$this->assertEquals( bp_core_ajax_url(), get_site_url( bp_get_root_blog_id(), '/wp-admin/admin-ajax.php', 'http' ) );
|
34 |
+
|
35 |
+
// (2) FORCE_SSL_ADMIN
|
36 |
+
force_ssl_admin( true );
|
37 |
+
|
38 |
+
// (2a) Front-end
|
39 |
+
$this->go_to( '/' );
|
40 |
+
$this->assertEquals( bp_core_ajax_url(), get_site_url( bp_get_root_blog_id(), '/wp-admin/admin-ajax.php', 'http' ) );
|
41 |
+
|
42 |
+
// (2b) Dashboard
|
43 |
+
$this->go_to( '/wp-admin' );
|
44 |
+
$this->assertEquals( bp_core_ajax_url(), get_site_url( bp_get_root_blog_id(), '/wp-admin/admin-ajax.php', 'https' ) );
|
45 |
+
|
46 |
+
force_ssl_admin( $forced );
|
47 |
+
|
48 |
+
// (3) Multisite, root blog other than 1
|
49 |
+
if ( is_multisite() ) {
|
50 |
+
$original_root_blog = bp_get_root_blog_id();
|
51 |
+
$blog_id = $this->factory->blog->create();
|
52 |
+
buddypress()->root_blog_id = $blog_id;
|
53 |
+
|
54 |
+
switch_to_blog( $blog_id );
|
55 |
+
$blog_details = get_blog_details();
|
56 |
+
|
57 |
+
$this->go_to( $blog_details->path );
|
58 |
+
$this->assertEquals( $blog_details->siteurl . '/wp-admin/admin-ajax.php', bp_core_ajax_url() );
|
59 |
+
|
60 |
+
restore_current_blog();
|
61 |
+
buddypress()->root_blog_id = $original_root_blog;
|
62 |
+
}
|
63 |
+
|
64 |
+
}
|
65 |
+
}
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @group xprofile
|
4 |
+
* @group BP_XProfile_Field
|
5 |
+
*/
|
6 |
+
class BP_Tests_BP_XProfile_XProfile_TestCases extends BP_UnitTestCase {
|
7 |
+
public function setUp() {
|
8 |
+
parent::setUp();
|
9 |
+
}
|
10 |
+
|
11 |
+
public function tearDown() {
|
12 |
+
parent::tearDown();
|
13 |
+
}
|
14 |
+
|
15 |
+
public function test_can_delete_save() {
|
16 |
+
$group = $this->factory->xprofile_group->create();
|
17 |
+
$field = $this->factory->xprofile_field->create( array(
|
18 |
+
'field_group_id' => $group->id,
|
19 |
+
'type' => 'textbox',
|
20 |
+
) );
|
21 |
+
|
22 |
+
$f = new BP_XProfile_Field( $field->id );
|
23 |
+
$f->can_delete = 0;
|
24 |
+
$f->save();
|
25 |
+
|
26 |
+
$f2 = new BP_XProfile_Field( $field->id );
|
27 |
+
$this->assertEquals( '0', $f2->can_delete );
|
28 |
+
}
|
29 |
+
}
|
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @group xprofile
|
5 |
+
* @group functions
|
6 |
+
*/
|
7 |
+
class BP_Tests_XProfile_Functions extends BP_UnitTestCase {
|
8 |
+
public function setUp() {
|
9 |
+
parent::setUp();
|
10 |
+
}
|
11 |
+
|
12 |
+
public function tearDown() {
|
13 |
+
parent::tearDown();
|
14 |
+
}
|
15 |
+
|
16 |
+
public function test_get_hidden_field_types_for_user_loggedout() {
|
17 |
+
$duser = $this->create_user();
|
18 |
+
|
19 |
+
$old_current_user = bp_loggedin_user_id();
|
20 |
+
$this->set_current_user( 0 );
|
21 |
+
|
22 |
+
$this->assertEquals( array( 'friends', 'loggedin', 'adminsonly' ), bp_xprofile_get_hidden_field_types_for_user( $duser, bp_loggedin_user_id() ) );
|
23 |
+
|
24 |
+
$this->set_current_user( $old_current_user );
|
25 |
+
}
|
26 |
+
|
27 |
+
public function test_get_hidden_field_types_for_user_loggedin() {
|
28 |
+
$duser = $this->create_user();
|
29 |
+
$cuser = $this->create_user();
|
30 |
+
|
31 |
+
$old_current_user = bp_loggedin_user_id();
|
32 |
+
$this->set_current_user( $cuser );
|
33 |
+
|
34 |
+
$this->assertEquals( array( 'friends', 'adminsonly' ), bp_xprofile_get_hidden_field_types_for_user( $duser, bp_loggedin_user_id() ) );
|
35 |
+
|
36 |
+
$this->set_current_user( $old_current_user );
|
37 |
+
}
|
38 |
+
|
39 |
+
public function test_get_hidden_field_types_for_user_friends() {
|
40 |
+
$duser = $this->create_user();
|
41 |
+
$cuser = $this->create_user();
|
42 |
+
friends_add_friend( $duser, $cuser, true );
|
43 |
+
|
44 |
+
$old_current_user = bp_loggedin_user_id();
|
45 |
+
$this->set_current_user( $cuser );
|
46 |
+
|
47 |
+
$this->assertEquals( array( 'adminsonly' ), bp_xprofile_get_hidden_field_types_for_user( $duser, bp_loggedin_user_id() ) );
|
48 |
+
|
49 |
+
$this->set_current_user( $old_current_user );
|
50 |
+
}
|
51 |
+
|
52 |
+
public function test_get_hidden_field_types_for_user_admin() {
|
53 |
+
$duser = $this->create_user();
|
54 |
+
$cuser = $this->create_user();
|
55 |
+
$this->grant_bp_moderate( $cuser );
|
56 |
+
|
57 |
+
$old_current_user = bp_loggedin_user_id();
|
58 |
+
$this->set_current_user( $cuser );
|
59 |
+
|
60 |
+
$this->assertEquals( array(), bp_xprofile_get_hidden_field_types_for_user( $duser, bp_loggedin_user_id() ) );
|
61 |
+
|
62 |
+
$this->revoke_bp_moderate( $cuser );
|
63 |
+
$this->set_current_user( $old_current_user );
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* @group bp_xprofile_update_meta
|
68 |
+
* @ticket BP5180
|
69 |
+
*/
|
70 |
+
public function test_bp_xprofile_update_meta_with_line_breaks() {
|
71 |
+
$g = $this->factory->xprofile_group->create();
|
72 |
+
$f = $this->factory->xprofile_field->create( array(
|
73 |
+
'field_group_id' => $g->id,
|
74 |
+
'type' => 'textbox',
|
75 |
+
) );
|
76 |
+
|
77 |
+
$meta_value = 'Foo!
|
78 |
+
|
79 |
+
Bar!';
|
80 |
+
bp_xprofile_update_meta( $f->id, 'field', 'linebreak_field', $meta_value );
|
81 |
+
$this->assertEquals( $meta_value, bp_xprofile_get_meta( $f->id, 'field', 'linebreak_field' ) );
|
82 |
+
}
|
83 |
+
}
|