BuddyPress - Version 1.9-beta1

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.

Download this release

Release Info

Developer boonebgorges
Plugin Icon 128x128 BuddyPress
Version 1.9-beta1
Comparing to
See all releases

Code changes from version 1.8.1 to 1.9-beta1

Files changed (81) hide show
  1. bp-activity/bp-activity-actions.php +35 -33
  2. bp-activity/bp-activity-admin.php +173 -114
  3. bp-activity/bp-activity-akismet.php +100 -56
  4. bp-activity/bp-activity-cache.php +10 -9
  5. bp-activity/bp-activity-classes.php +454 -62
  6. bp-activity/bp-activity-filters.php +35 -35
  7. bp-activity/bp-activity-functions.php +402 -261
  8. bp-activity/bp-activity-loader.php +45 -30
  9. bp-activity/bp-activity-notifications.php +13 -13
  10. bp-activity/bp-activity-screens.php +35 -35
  11. bp-activity/bp-activity-template.php +621 -354
  12. bp-blogs/bp-blogs-actions.php +3 -5
  13. bp-blogs/bp-blogs-activity.php +33 -20
  14. bp-blogs/bp-blogs-buddybar.php +7 -8
  15. bp-blogs/bp-blogs-cache.php +11 -12
  16. bp-blogs/bp-blogs-classes.php +197 -28
  17. bp-blogs/bp-blogs-filters.php +9 -7
  18. bp-blogs/bp-blogs-functions.php +272 -45
  19. bp-blogs/bp-blogs-loader.php +48 -33
  20. bp-blogs/bp-blogs-screens.php +41 -28
  21. bp-blogs/bp-blogs-template.php +435 -89
  22. bp-blogs/bp-blogs-widgets.php +26 -1
  23. bp-core/admin/bp-core-actions.php +11 -8
  24. bp-core/admin/bp-core-components.php +14 -2
  25. bp-core/admin/bp-core-functions.php +144 -21
  26. bp-core/admin/bp-core-schema.php +9 -2
  27. bp-core/bp-core-actions.php +11 -5
  28. bp-core/bp-core-admin.php +79 -46
  29. bp-core/bp-core-adminbar.php +16 -15
  30. bp-core/bp-core-avatars.php +202 -99
  31. bp-core/bp-core-buddybar.php +123 -44
  32. bp-core/bp-core-cache.php +31 -14
  33. bp-core/bp-core-caps.php +78 -71
  34. bp-core/bp-core-catchuri.php +102 -64
  35. bp-core/bp-core-classes.php +441 -236
  36. bp-core/bp-core-component.php +197 -65
  37. bp-core/bp-core-cssjs.php +19 -20
  38. bp-core/bp-core-dependency.php +171 -62
  39. bp-core/bp-core-filters.php +181 -80
  40. bp-core/bp-core-functions.php +602 -231
  41. bp-core/bp-core-loader.php +38 -27
  42. bp-core/bp-core-moderation.php +42 -34
  43. bp-core/bp-core-options.php +132 -105
  44. bp-core/bp-core-template-loader.php +86 -57
  45. bp-core/bp-core-template.php +826 -224
  46. bp-core/bp-core-theme-compatibility.php +264 -154
  47. bp-core/bp-core-update.php +104 -43
  48. bp-core/bp-core-widgets.php +205 -5
  49. bp-core/bp-core-wpabstraction.php +61 -23
  50. bp-core/deprecated/1.2.php +6 -0
  51. bp-forums/bp-forums-actions.php +7 -0
  52. bp-forums/bp-forums-bbpress-sa.php +83 -12
  53. bp-forums/bp-forums-filters.php +67 -37
  54. bp-forums/bp-forums-functions.php +299 -49
  55. bp-forums/bp-forums-loader.php +43 -13
  56. bp-forums/bp-forums-screens.php +33 -13
  57. bp-forums/bp-forums-template.php +1029 -74
  58. bp-friends/bp-friends-actions.php +9 -3
  59. bp-friends/bp-friends-activity.php +44 -8
  60. bp-friends/bp-friends-cache.php +13 -5
  61. bp-friends/bp-friends-classes.php +291 -46
  62. bp-friends/bp-friends-filters.php +8 -6
  63. bp-friends/bp-friends-functions.php +232 -7
  64. bp-friends/bp-friends-loader.php +52 -31
  65. bp-friends/bp-friends-notifications.php +20 -0
  66. bp-friends/bp-friends-screens.php +16 -7
  67. bp-friends/bp-friends-template.php +148 -38
  68. bp-friends/bp-friends-widgets.php +251 -0
  69. bp-friends/js/widget-friends.js +49 -0
  70. bp-friends/js/widget-friends.min.js +1 -0
  71. bp-groups/bp-groups-actions.php +47 -22
  72. bp-groups/bp-groups-activity.php +29 -0
  73. bp-groups/bp-groups-admin.php +168 -107
  74. bp-groups/bp-groups-adminbar.php +6 -7
  75. bp-groups/bp-groups-classes.php +135 -93
  76. bp-groups/bp-groups-functions.php +20 -13
  77. bp-groups/bp-groups-loader.php +25 -31
  78. bp-groups/bp-groups-screens.php +37 -16
  79. bp-groups/bp-groups-template.php +63 -35
  80. bp-groups/bp-groups-widgets.php +11 -6
  81. bp-languages/buddypress.pot +645 -548
bp-activity/bp-activity-actions.php CHANGED
@@ -13,7 +13,7 @@
13
  if ( !defined( 'ABSPATH' ) ) exit;
14
 
15
  /**
16
- * Allow core components and dependent plugins to register activity actions
17
  *
18
  * @since BuddyPress (1.2)
19
  *
@@ -25,7 +25,7 @@ function bp_register_activity_actions() {
25
  add_action( 'bp_init', 'bp_register_activity_actions', 8 );
26
 
27
  /**
28
- * Allow core components and dependent plugins to register activity actions
29
  *
30
  * @since BuddyPress (1.2)
31
  *
@@ -38,11 +38,11 @@ add_action( 'bp_init', 'bp_register_activity_actions', 8 );
38
  * @uses bp_core_get_user_domain()
39
  * @uses groups_get_group()
40
  * @uses bp_get_group_permalink()
41
- * @uses apply_filters_ref_array() To call the 'bp_activity_permalink_redirect_url' hook
42
  * @uses bp_core_redirect()
43
  * @uses bp_get_root_domain()
44
  *
45
- * @return bool False on failure
46
  */
47
  function bp_activity_action_permalink_router() {
48
 
@@ -124,7 +124,7 @@ add_action( 'bp_actions', 'bp_activity_action_permalink_router' );
124
  * @uses do_action() Calls 'bp_activity_action_delete_activity' hook to allow actions to be taken after the activity is deleted.
125
  * @uses bp_core_redirect()
126
  *
127
- * @return bool False on failure
128
  */
129
  function bp_activity_action_delete_activity( $activity_id = 0 ) {
130
 
@@ -169,12 +169,13 @@ function bp_activity_action_delete_activity( $activity_id = 0 ) {
169
  add_action( 'bp_actions', 'bp_activity_action_delete_activity' );
170
 
171
  /**
172
- * Mark specific activity item as spam and redirect to previous page
 
 
173
  *
174
  * @global object $bp BuddyPress global settings
175
  * @param int $activity_id Activity id to be deleted. Defaults to 0.
176
- * @return bool False on failure
177
- * @since BuddyPress (1.6)
178
  */
179
  function bp_activity_action_spam_activity( $activity_id = 0 ) {
180
  global $bp;
@@ -241,7 +242,7 @@ add_action( 'bp_actions', 'bp_activity_action_spam_activity' );
241
  * @uses bp_core_redirect()
242
  * @uses apply_filters() To call 'bp_activity_custom_update' hook.
243
  *
244
- * @return bool False on failure
245
  */
246
  function bp_activity_action_post_update() {
247
 
@@ -253,9 +254,15 @@ function bp_activity_action_post_update() {
253
  check_admin_referer( 'post_update', '_wpnonce_post_update' );
254
 
255
  // Get activity info
256
- $content = apply_filters( 'bp_activity_post_update_content', $_POST['whats-new'] );
257
- $object = apply_filters( 'bp_activity_post_update_object', $_POST['whats-new-post-object'] );
258
- $item_id = apply_filters( 'bp_activity_post_update_item_id', $_POST['whats-new-post-in'] );
 
 
 
 
 
 
259
 
260
  // No activity content so provide feedback and redirect
261
  if ( empty( $content ) ) {
@@ -305,7 +312,7 @@ add_action( 'bp_actions', 'bp_activity_action_post_update' );
305
  * @uses bp_activity_new_comment()
306
  * @uses wp_get_referer()
307
  *
308
- * @return bool False on failure
309
  */
310
  function bp_activity_action_post_comment() {
311
 
@@ -353,7 +360,7 @@ add_action( 'bp_actions', 'bp_activity_action_post_comment' );
353
  * @uses bp_core_redirect()
354
  * @uses wp_get_referer()
355
  *
356
- * @return bool False on failure
357
  */
358
  function bp_activity_action_mark_favorite() {
359
 
@@ -387,7 +394,7 @@ add_action( 'bp_actions', 'bp_activity_action_mark_favorite' );
387
  * @uses bp_core_redirect()
388
  * @uses wp_get_referer()
389
  *
390
- * @return bool False on failure
391
  */
392
  function bp_activity_action_remove_favorite() {
393
 
@@ -407,18 +414,17 @@ function bp_activity_action_remove_favorite() {
407
  add_action( 'bp_actions', 'bp_activity_action_remove_favorite' );
408
 
409
  /**
410
- * Load the sitewide feed.
411
  *
412
  * @since BuddyPress (1.0)
413
  *
414
  * @global object $bp BuddyPress global settings
415
- * @global object $wp_query
416
  * @uses bp_is_activity_component()
417
  * @uses bp_is_current_action()
418
  * @uses bp_is_user()
419
  * @uses status_header()
420
  *
421
- * @return bool False on failure
422
  */
423
  function bp_activity_action_sitewide_feed() {
424
  global $bp;
@@ -441,16 +447,15 @@ function bp_activity_action_sitewide_feed() {
441
  add_action( 'bp_actions', 'bp_activity_action_sitewide_feed' );
442
 
443
  /**
444
- * Load a user's personal feed.
445
  *
446
  * @since BuddyPress (1.0)
447
  *
448
- * @global object $wp_query
449
  * @uses bp_is_user_activity()
450
  * @uses bp_is_current_action()
451
  * @uses status_header()
452
  *
453
- * @return bool False on failure
454
  */
455
  function bp_activity_action_personal_feed() {
456
  if ( ! bp_is_user_activity() || ! bp_is_current_action( 'feed' ) ) {
@@ -472,11 +477,10 @@ function bp_activity_action_personal_feed() {
472
  add_action( 'bp_actions', 'bp_activity_action_personal_feed' );
473
 
474
  /**
475
- * Load a user's friends feed.
476
  *
477
  * @since BuddyPress (1.0)
478
  *
479
- * @global object $wp_query
480
  * @uses bp_is_active()
481
  * @uses bp_is_user_activity()
482
  * @uses bp_is_current_action()
@@ -484,7 +488,7 @@ add_action( 'bp_actions', 'bp_activity_action_personal_feed' );
484
  * @uses bp_is_action_variable()
485
  * @uses status_header()
486
  *
487
- * @return bool False on failure
488
  */
489
  function bp_activity_action_friends_feed() {
490
  if ( ! bp_is_active( 'friends' ) || ! bp_is_user_activity() || ! bp_is_current_action( bp_get_friends_slug() ) || ! bp_is_action_variable( 'feed', 0 ) ) {
@@ -506,11 +510,10 @@ function bp_activity_action_friends_feed() {
506
  add_action( 'bp_actions', 'bp_activity_action_friends_feed' );
507
 
508
  /**
509
- * Load a user's my groups feed.
510
  *
511
  * @since BuddyPress (1.2)
512
  *
513
- * @global object $wp_query
514
  * @uses bp_is_active()
515
  * @uses bp_is_user_activity()
516
  * @uses bp_is_current_action()
@@ -518,7 +521,7 @@ add_action( 'bp_actions', 'bp_activity_action_friends_feed' );
518
  * @uses bp_is_action_variable()
519
  * @uses status_header()
520
  *
521
- * @return bool False on failure
522
  */
523
  function bp_activity_action_my_groups_feed() {
524
  if ( ! bp_is_active( 'groups' ) || ! bp_is_user_activity() || ! bp_is_current_action( bp_get_groups_slug() ) || ! bp_is_action_variable( 'feed', 0 ) ) {
@@ -552,13 +555,12 @@ add_action( 'bp_actions', 'bp_activity_action_my_groups_feed' );
552
  *
553
  * @since BuddyPress (1.2)
554
  *
555
- * @global object $wp_query
556
  * @uses bp_is_user_activity()
557
  * @uses bp_is_current_action()
558
  * @uses bp_is_action_variable()
559
  * @uses status_header()
560
  *
561
- * @return bool False on failure
562
  */
563
  function bp_activity_action_mentions_feed() {
564
  if ( ! bp_activity_do_mentions() ) {
@@ -590,13 +592,12 @@ add_action( 'bp_actions', 'bp_activity_action_mentions_feed' );
590
  *
591
  * @since BuddyPress (1.2)
592
  *
593
- * @global object $wp_query
594
  * @uses bp_is_user_activity()
595
  * @uses bp_is_current_action()
596
  * @uses bp_is_action_variable()
597
  * @uses status_header()
598
  *
599
- * @return bool False on failure
600
  */
601
  function bp_activity_action_favorites_feed() {
602
  if ( ! bp_is_user_activity() || ! bp_is_current_action( 'favorites' ) || ! bp_is_action_variable( 'feed', 0 ) ) {
@@ -622,10 +623,11 @@ function bp_activity_action_favorites_feed() {
622
  add_action( 'bp_actions', 'bp_activity_action_favorites_feed' );
623
 
624
  /**
625
- * Loads Akismet
626
  *
627
- * @global object $bp BuddyPress global settings
628
  * @since BuddyPress (1.6)
 
 
629
  */
630
  function bp_activity_setup_akismet() {
631
  global $bp;
13
  if ( !defined( 'ABSPATH' ) ) exit;
14
 
15
  /**
16
+ * Allow core components and dependent plugins to register activity actions.
17
  *
18
  * @since BuddyPress (1.2)
19
  *
25
  add_action( 'bp_init', 'bp_register_activity_actions', 8 );
26
 
27
  /**
28
+ * Catch and route requests for single activity item permalinks.
29
  *
30
  * @since BuddyPress (1.2)
31
  *
38
  * @uses bp_core_get_user_domain()
39
  * @uses groups_get_group()
40
  * @uses bp_get_group_permalink()
41
+ * @uses apply_filters_ref_array() To call the 'bp_activity_permalink_redirect_url' hook.
42
  * @uses bp_core_redirect()
43
  * @uses bp_get_root_domain()
44
  *
45
+ * @return bool False on failure.
46
  */
47
  function bp_activity_action_permalink_router() {
48
 
124
  * @uses do_action() Calls 'bp_activity_action_delete_activity' hook to allow actions to be taken after the activity is deleted.
125
  * @uses bp_core_redirect()
126
  *
127
+ * @return bool False on failure.
128
  */
129
  function bp_activity_action_delete_activity( $activity_id = 0 ) {
130
 
169
  add_action( 'bp_actions', 'bp_activity_action_delete_activity' );
170
 
171
  /**
172
+ * Mark specific activity item as spam and redirect to previous page.
173
+ *
174
+ * @since BuddyPress (1.6)
175
  *
176
  * @global object $bp BuddyPress global settings
177
  * @param int $activity_id Activity id to be deleted. Defaults to 0.
178
+ * @return bool False on failure.
 
179
  */
180
  function bp_activity_action_spam_activity( $activity_id = 0 ) {
181
  global $bp;
242
  * @uses bp_core_redirect()
243
  * @uses apply_filters() To call 'bp_activity_custom_update' hook.
244
  *
245
+ * @return bool False on failure.
246
  */
247
  function bp_activity_action_post_update() {
248
 
254
  check_admin_referer( 'post_update', '_wpnonce_post_update' );
255
 
256
  // Get activity info
257
+ $content = apply_filters( 'bp_activity_post_update_content', $_POST['whats-new'] );
258
+
259
+ if ( ! empty( $_POST['whats-new-post-object'] ) ) {
260
+ $object = apply_filters( 'bp_activity_post_update_object', $_POST['whats-new-post-object'] );
261
+ }
262
+
263
+ if ( ! empty( $_POST['whats-new-post-in'] ) ) {
264
+ $item_id = apply_filters( 'bp_activity_post_update_item_id', $_POST['whats-new-post-in'] );
265
+ }
266
 
267
  // No activity content so provide feedback and redirect
268
  if ( empty( $content ) ) {
312
  * @uses bp_activity_new_comment()
313
  * @uses wp_get_referer()
314
  *
315
+ * @return bool False on failure.
316
  */
317
  function bp_activity_action_post_comment() {
318
 
360
  * @uses bp_core_redirect()
361
  * @uses wp_get_referer()
362
  *
363
+ * @return bool False on failure.
364
  */
365
  function bp_activity_action_mark_favorite() {
366
 
394
  * @uses bp_core_redirect()
395
  * @uses wp_get_referer()
396
  *
397
+ * @return bool False on failure.
398
  */
399
  function bp_activity_action_remove_favorite() {
400
 
414
  add_action( 'bp_actions', 'bp_activity_action_remove_favorite' );
415
 
416
  /**
417
+ * Load the sitewide activity feed.
418
  *
419
  * @since BuddyPress (1.0)
420
  *
421
  * @global object $bp BuddyPress global settings
 
422
  * @uses bp_is_activity_component()
423
  * @uses bp_is_current_action()
424
  * @uses bp_is_user()
425
  * @uses status_header()
426
  *
427
+ * @return bool False on failure.
428
  */
429
  function bp_activity_action_sitewide_feed() {
430
  global $bp;
447
  add_action( 'bp_actions', 'bp_activity_action_sitewide_feed' );
448
 
449
  /**
450
+ * Load a user's personal activity feed.
451
  *
452
  * @since BuddyPress (1.0)
453
  *
 
454
  * @uses bp_is_user_activity()
455
  * @uses bp_is_current_action()
456
  * @uses status_header()
457
  *
458
+ * @return bool False on failure.
459
  */
460
  function bp_activity_action_personal_feed() {
461
  if ( ! bp_is_user_activity() || ! bp_is_current_action( 'feed' ) ) {
477
  add_action( 'bp_actions', 'bp_activity_action_personal_feed' );
478
 
479
  /**
480
+ * Load a user's friends' activity feed.
481
  *
482
  * @since BuddyPress (1.0)
483
  *
 
484
  * @uses bp_is_active()
485
  * @uses bp_is_user_activity()
486
  * @uses bp_is_current_action()
488
  * @uses bp_is_action_variable()
489
  * @uses status_header()
490
  *
491
+ * @return bool False on failure.
492
  */
493
  function bp_activity_action_friends_feed() {
494
  if ( ! bp_is_active( 'friends' ) || ! bp_is_user_activity() || ! bp_is_current_action( bp_get_friends_slug() ) || ! bp_is_action_variable( 'feed', 0 ) ) {
510
  add_action( 'bp_actions', 'bp_activity_action_friends_feed' );
511
 
512
  /**
513
+ * Load the activity feed for a user's groups.
514
  *
515
  * @since BuddyPress (1.2)
516
  *
 
517
  * @uses bp_is_active()
518
  * @uses bp_is_user_activity()
519
  * @uses bp_is_current_action()
521
  * @uses bp_is_action_variable()
522
  * @uses status_header()
523
  *
524
+ * @return bool False on failure.
525
  */
526
  function bp_activity_action_my_groups_feed() {
527
  if ( ! bp_is_active( 'groups' ) || ! bp_is_user_activity() || ! bp_is_current_action( bp_get_groups_slug() ) || ! bp_is_action_variable( 'feed', 0 ) ) {
555
  *
556
  * @since BuddyPress (1.2)
557
  *
 
558
  * @uses bp_is_user_activity()
559
  * @uses bp_is_current_action()
560
  * @uses bp_is_action_variable()
561
  * @uses status_header()
562
  *
563
+ * @return bool False on failure.
564
  */
565
  function bp_activity_action_mentions_feed() {
566
  if ( ! bp_activity_do_mentions() ) {
592
  *
593
  * @since BuddyPress (1.2)
594
  *
 
595
  * @uses bp_is_user_activity()
596
  * @uses bp_is_current_action()
597
  * @uses bp_is_action_variable()
598
  * @uses status_header()
599
  *
600
+ * @return bool False on failure.
601
  */
602
  function bp_activity_action_favorites_feed() {
603
  if ( ! bp_is_user_activity() || ! bp_is_current_action( 'favorites' ) || ! bp_is_action_variable( 'feed', 0 ) ) {
623
  add_action( 'bp_actions', 'bp_activity_action_favorites_feed' );
624
 
625
  /**
626
+ * Loads Akismet filtering for activity.
627
  *
 
628
  * @since BuddyPress (1.6)
629
+ *
630
+ * @global object $bp BuddyPress global settings
631
  */
632
  function bp_activity_setup_akismet() {
633
  global $bp;
bp-activity/bp-activity-admin.php CHANGED
@@ -1,12 +1,12 @@
1
  <?php
2
  /**
3
- * BuddyPress Activity component admin screen
4
  *
5
- * Props to WordPress core for the Comments admin screen, and its contextual help text,
6
- * on which this implementation is heavily based.
7
  *
8
  * @package BuddyPress
9
- * @since BuddyPress (1.6)
10
  * @subpackage Activity
11
  */
12
 
@@ -21,20 +21,17 @@ if ( is_admin() && ! empty( $_REQUEST['page'] ) && 'bp-activity' == $_REQUEST['p
21
  add_filter( 'set-screen-option', 'bp_activity_admin_screen_options', 10, 3 );
22
 
23
  /**
24
- * Registers the Activity component admin screen
25
  *
26
  * @since BuddyPress (1.6)
27
  */
28
  function bp_activity_add_admin_menu() {
29
 
30
- if ( ! bp_current_user_can( 'bp_moderate' ) )
31
- return;
32
-
33
  // Add our screen
34
  $hook = add_menu_page(
35
  __( 'Activity', 'buddypress' ),
36
  __( 'Activity', 'buddypress' ),
37
- 'manage_options',
38
  'bp-activity',
39
  'bp_activity_admin',
40
  'div'
@@ -46,12 +43,16 @@ function bp_activity_add_admin_menu() {
46
  add_action( bp_core_admin_hook(), 'bp_activity_add_admin_menu' );
47
 
48
  /**
49
- * Add activity component to custom menus array
50
  *
51
- * @since BuddyPress (1.7)
 
 
52
  *
53
- * @param array $custom_menus
54
- * @return array
 
 
55
  */
56
  function bp_activity_admin_menu_order( $custom_menus = array() ) {
57
  array_push( $custom_menus, 'bp-activity' );
@@ -60,10 +61,12 @@ function bp_activity_admin_menu_order( $custom_menus = array() ) {
60
  add_filter( 'bp_admin_menu_order', 'bp_activity_admin_menu_order' );
61
 
62
  /**
63
- * AJAX receiver for Activity replies via the admin screen. Adds a new activity
64
- * comment, and returns HTML for a new table row.
65
  *
66
- * @since BuddyPress (1.6)
 
 
 
67
  */
68
  function bp_activity_admin_reply() {
69
  // Check nonce
@@ -91,7 +94,7 @@ function bp_activity_admin_reply() {
91
 
92
  // @todo: Check if user is allowed to create new activity items
93
  // if ( ! current_user_can( 'bp_new_activity' ) )
94
- if ( ! is_super_admin() )
95
  die( '-1' );
96
 
97
  // Add new activity comment
@@ -131,13 +134,15 @@ function bp_activity_admin_reply() {
131
  add_action( 'wp_ajax_bp-activity-admin-reply', 'bp_activity_admin_reply' );
132
 
133
  /**
134
- * Handle save/update of screen options for the Activity component admin screen
 
 
135
  *
136
- * @param string $value Will always be false unless another plugin filters it first.
137
- * @param string $option Screen option name
138
- * @param string $new_value Screen option form value
 
139
  * @return string Option value. False to abandon update.
140
- * @since BuddyPress (1.6)
141
  */
142
  function bp_activity_admin_screen_options( $value, $option, $new_value ) {
143
  if ( 'toplevel_page_bp_activity_per_page' != $option && 'toplevel_page_bp_activity_network_per_page' != $option )
@@ -152,11 +157,12 @@ function bp_activity_admin_screen_options( $value, $option, $new_value ) {
152
  }
153
 
154
  /**
155
- * Hide the advanced edit meta boxes by default, so we don't clutter the scren.
 
 
156
  *
157
- * @param WP_Screen $screen Screen identifier
158
- * @return array Hidden Meta Boxes
159
- * @since BuddyPress (1.0)
160
  */
161
  function bp_activity_admin_edit_hidden_metaboxes( $hidden, $screen ) {
162
  if ( empty( $screen->id ) || 'toplevel_page_bp-activity' != $screen->id && 'toplevel_page_bp-activity_network' != $screen->id )
@@ -170,11 +176,17 @@ function bp_activity_admin_edit_hidden_metaboxes( $hidden, $screen ) {
170
  add_filter( 'default_hidden_meta_boxes', 'bp_activity_admin_edit_hidden_metaboxes', 10, 2 );
171
 
172
  /**
173
- * Set up the admin page before any output is sent. Register contextual help and screen options for this admin page.
174
  *
175
- * @global object $bp BuddyPress global settings
176
- * @global BP_Activity_List_Table $bp_activity_list_table Activity screen list table
177
- * @since BuddyPress (1.6)
 
 
 
 
 
 
178
  */
179
  function bp_activity_admin_load() {
180
  global $bp, $bp_activity_list_table;
@@ -206,7 +218,7 @@ function bp_activity_admin_load() {
206
  'title' => __( 'Item, Link, Type', 'buddypress' ),
207
  'content' =>
208
  '<p>' . __( '<strong>Primary Item/Secondary Item</strong> - These identify the object that created the activity. For example, the fields could reference a comment left on a specific site. Some types of activity may only use one, or none, of these fields.', 'buddypress' ) . '</p>' .
209
- '<p>' . __( '<strong>Link</strong> - Activity generated by blog posts and comments, forum topics and replies, and some plugins, uses the link field for a permalink back to the content item. Some types of activity may not use this field, even if it has been set.', 'buddypress' ) . '</p>' .
210
  '<p>' . __( '<strong>Type</strong> - Each distinct kind of activity has its own type. For example, <code>created_group</code> is used when a group is created and <code>joined_group</code> is used when a user joins a group.', 'buddypress' ) . '</p>' .
211
  '<p>' . __( 'For information about when and how BuddyPress uses all of these settings, see the Managing Activity link in the panel to the side.', 'buddypress' ) . '</p>'
212
  ) );
@@ -521,9 +533,9 @@ function bp_activity_admin_load() {
521
  }
522
 
523
  /**
524
- * Outputs the Activity component admin screens
525
  *
526
- * @since BuddyPress (1.6)
527
  */
528
  function bp_activity_admin() {
529
  // Decide whether to load the index or edit screen
@@ -539,10 +551,9 @@ function bp_activity_admin() {
539
  }
540
 
541
  /**
542
- * Display the single activity edit screen
543
  *
544
- * @global int $screen_layout_columns Number of columns shown on this admin page
545
- * @since BuddyPress (1.6)
546
  */
547
  function bp_activity_admin_edit() {
548
 
@@ -631,10 +642,11 @@ function bp_activity_admin_edit() {
631
  }
632
 
633
  /**
634
- * Status metabox for the Activity admin edit screen
635
  *
636
- * @param object $item Activity item
637
- * @since BuddyPress (1.6)
 
638
  */
639
  function bp_activity_admin_edit_metabox_status( $item ) {
640
  ?>
@@ -686,26 +698,28 @@ function bp_activity_admin_edit_metabox_status( $item ) {
686
  }
687
 
688
  /**
689
- * Primary link metabox for the Activity admin edit screen
690
  *
691
- * @param object $item Activity item
692
- * @since BuddyPress (1.6)
 
693
  */
694
  function bp_activity_admin_edit_metabox_link( $item ) {
695
  ?>
696
 
697
  <label class="screen-reader-text" for="bp-activities-link"><?php _e( 'Link', 'buddypress' ); ?></label>
698
  <input type="url" name="bp-activities-link" value="<?php echo esc_url( $item->primary_link ); ?>" />
699
- <p><?php _e( 'Activity generated by blog posts and comments, forum topics and replies, and some plugins, uses the link field for a permalink back to the content item.', 'buddypress' ); ?></p>
700
 
701
  <?php
702
  }
703
 
704
  /**
705
- * User ID metabox for the Activity admin edit screen
706
  *
707
- * @param object $item Activity item
708
- * @since BuddyPress (1.6)
 
709
  */
710
  function bp_activity_admin_edit_metabox_userid( $item ) {
711
  ?>
@@ -719,9 +733,11 @@ function bp_activity_admin_edit_metabox_userid( $item ) {
719
  /**
720
  * Activity type metabox for the Activity admin edit screen
721
  *
722
- * @global object $bp BuddyPress global settings
723
- * @param object $item Activity item
724
- * @since BuddyPress (1.6)
 
 
725
  */
726
  function bp_activity_admin_edit_metabox_type( $item ) {
727
  global $bp;
@@ -753,10 +769,11 @@ function bp_activity_admin_edit_metabox_type( $item ) {
753
  }
754
 
755
  /**
756
- * Primary item ID/Secondary item ID metabox for the Activity admin edit screen
757
  *
758
- * @param object $item Activity item
759
- * @since BuddyPress (1.6)
 
760
  */
761
  function bp_activity_admin_edit_metabox_itemids( $item ) {
762
  ?>
@@ -776,9 +793,11 @@ function bp_activity_admin_edit_metabox_itemids( $item ) {
776
  /**
777
  * Display the Activity admin index screen, which contains a list of all the activities.
778
  *
779
- * @global BP_Activity_List_Table $bp_activity_list_table Activity screen list table
780
- * @global string $plugin_page
781
- * @since BuddyPress (1.6)
 
 
782
  */
783
  function bp_activity_admin_index() {
784
  global $bp_activity_list_table, $plugin_page;
@@ -908,30 +927,35 @@ function bp_activity_admin_index() {
908
  class BP_Activity_List_Table extends WP_List_Table {
909
 
910
  /**
911
- * What type of view is being displayed? e.g. "All", "Pending", "Approved", "Spam"...
912
  *
913
- * @since BuddyPress (1.6)
914
- */
 
 
 
915
  public $view = 'all';
916
 
917
  /**
918
  * How many activity items have been marked as spam.
919
  *
920
- * @since BuddyPress (1.6)
 
921
  */
922
  public $spam_count = 0;
923
 
924
  /**
925
  * Store activity-to-user-ID mappings for use in the In Response To column.
926
  *
927
- * @since BuddyPress (1.6)
 
928
  */
929
  protected $activity_user_id = array();
930
 
931
  /**
932
- * Constructor
933
  *
934
- * @since BuddyPress (1.6)
935
  */
936
  public function __construct() {
937
 
@@ -940,16 +964,16 @@ class BP_Activity_List_Table extends WP_List_Table {
940
  'ajax' => false,
941
  'plural' => 'activities',
942
  'singular' => 'activity',
 
943
  ) );
944
  }
945
 
946
  /**
947
- * Handle filtering of data, sorting, pagination, and any other data-manipulation required prior to rendering.
948
  *
949
- * @since BuddyPress (1.6)
950
  */
951
  function prepare_items() {
952
- $screen = get_current_screen();
953
 
954
  // Option defaults
955
  $filter = array();
@@ -962,7 +986,7 @@ class BP_Activity_List_Table extends WP_List_Table {
962
  $page = $this->get_pagenum();
963
 
964
  // Set per page from the screen options
965
- $per_page = $this->get_items_per_page( str_replace( '-', '_', "{$screen->id}_per_page" ) );
966
 
967
  // Check if we're on the "Spam" view
968
  if ( !empty( $_REQUEST['activity_status'] ) && 'spam' == $_REQUEST['activity_status'] ) {
@@ -1045,10 +1069,11 @@ class BP_Activity_List_Table extends WP_List_Table {
1045
  }
1046
 
1047
  /**
1048
- * Get an array of all the columns on the page
1049
  *
1050
- * @return array
1051
- * @since BuddyPress (1.6)
 
1052
  */
1053
  function get_column_info() {
1054
  $this->_column_headers = array(
@@ -1061,18 +1086,18 @@ class BP_Activity_List_Table extends WP_List_Table {
1061
  }
1062
 
1063
  /**
1064
- * Displays a message on screen when no items are found (e.g. no search matches)
1065
  *
1066
- * @since BuddyPress (1.6)
1067
  */
1068
  function no_items() {
1069
  _e( 'No activities found.', 'buddypress' );
1070
  }
1071
 
1072
  /**
1073
- * Outputs the Activity data table
1074
  *
1075
- * @since BuddyPress (1.6)
1076
  */
1077
  function display() {
1078
  extract( $this->_args );
@@ -1102,29 +1127,38 @@ class BP_Activity_List_Table extends WP_List_Table {
1102
  }
1103
 
1104
  /**
1105
- * Generates content for a single row of the table
 
 
1106
  *
1107
- * @param object $item The current item
1108
- * @since BuddyPress (1.6)
1109
  */
1110
  function single_row( $item ) {
1111
- static $row_class = '';
 
 
 
 
 
 
1112
 
1113
- if ( empty( $row_class ) ) {
1114
- $row_class = ' class="alternate"';
1115
  } else {
1116
- $row_class = '';
1117
  }
1118
 
1119
- echo '<tr' . $row_class . ' id="activity-' . esc_attr( $item['id'] ) . '" data-parent_id="' . esc_attr( $item['id'] ) . '" data-root_id="' . esc_attr( $item['item_id'] ) . '">';
1120
  echo $this->single_row_columns( $item );
1121
  echo '</tr>';
 
 
1122
  }
1123
 
1124
  /**
1125
  * Get the list of views available on this table (e.g. "all", "spam").
1126
  *
1127
- * @since BuddyPress (1.6)
1128
  */
1129
  function get_views() {
1130
  $url_base = bp_get_admin_url( 'admin.php?page=bp-activity' ); ?>
@@ -1138,11 +1172,12 @@ class BP_Activity_List_Table extends WP_List_Table {
1138
  <?php
1139
  }
1140
 
1141
- /**
1142
- * Get bulk actions
 
 
1143
  *
1144
- * @return array Key/value pairs for the bulk actions dropdown
1145
- * @since BuddyPress (1.6)
1146
  */
1147
  function get_bulk_actions() {
1148
  $actions = array();
@@ -1156,9 +1191,11 @@ class BP_Activity_List_Table extends WP_List_Table {
1156
  /**
1157
  * Get the table column titles.
1158
  *
 
 
1159
  * @see WP_List_Table::single_row_columns()
1160
- * @return array
1161
- * @since BuddyPress (1.6)
1162
  */
1163
  function get_columns() {
1164
  return array(
@@ -1170,11 +1207,15 @@ class BP_Activity_List_Table extends WP_List_Table {
1170
  }
1171
 
1172
  /**
1173
- * Get the column names for sortable columns
 
 
1174
  *
1175
- * @return array
1176
- * @since BuddyPress (1.6)
1177
- * @todo For this to work, BP_Activity_Activity::get() needs updating to supporting ordering by specific fields
 
 
1178
  */
1179
  function get_sortable_columns() {
1180
  return array();
@@ -1185,10 +1226,11 @@ class BP_Activity_List_Table extends WP_List_Table {
1185
  }
1186
 
1187
  /**
1188
- * Markup for the "filter" part of the form (i.e. which activity type to display)
 
 
1189
  *
1190
- * @param string $which 'top' or 'bottom'
1191
- * @since BuddyPress (1.6)
1192
  */
1193
  function extra_tablenav( $which ) {
1194
  if ( 'bottom' == $which )
@@ -1217,22 +1259,26 @@ class BP_Activity_List_Table extends WP_List_Table {
1217
  }
1218
 
1219
  /**
1220
- * Checkbox column
 
 
1221
  *
1222
- * @param array $item A singular item (one full row)
1223
  * @see WP_List_Table::single_row_columns()
1224
- * @since BuddyPress (1.6)
 
1225
  */
1226
  function column_cb( $item ) {
1227
  printf( '<label class="screen-reader-text" for="aid-%1$d">' . __( 'Select activity item %1$d', 'buddypress' ) . '</label><input type="checkbox" name="aid[]" value="%1$d" id="aid-%1$d" />', $item['id'] );
1228
  }
1229
 
1230
  /**
1231
- * Author column
 
 
1232
  *
1233
- * @param array $item A singular item (one full row)
1234
  * @see WP_List_Table::single_row_columns()
1235
- * @since BuddyPress (1.6)
 
1236
  */
1237
  function column_author( $item ) {
1238
  echo '<strong>' . get_avatar( $item['user_id'], '32' ) . ' ' . bp_core_get_userlink( $item['user_id'] ) . '</strong>';
@@ -1243,9 +1289,11 @@ class BP_Activity_List_Table extends WP_List_Table {
1243
  *
1244
  * Called "comment" in the CSS so we can re-use some WP core CSS.
1245
  *
1246
- * @param array $item A singular item (one full row)
 
1247
  * @see WP_List_Table::single_row_columns()
1248
- * @since BuddyPress (1.6)
 
1249
  */
1250
  function column_comment( $item ) {
1251
  // Determine what type of item (row) we're dealing with
@@ -1297,7 +1345,7 @@ class BP_Activity_List_Table extends WP_List_Table {
1297
  $actions = apply_filters( 'bp_activity_admin_comment_row_actions', array_filter( $actions ), $item );
1298
 
1299
  /* translators: 2: activity admin ui date/time */
1300
- printf( __( 'Submitted on <a href="%1$s">%2$s at %3$s</a>', 'buddypress' ), bp_get_root_domain() . '/' . bp_get_activity_root_slug() . '/p/' . $item['id'] . '/', get_date_from_gmt( $item['date_recorded'], get_option( 'date_format' ) ), get_date_from_gmt( $item['date_recorded'], get_option( 'time_format' ) ) );
1301
 
1302
  // End timestamp
1303
  echo '</div>';
@@ -1313,11 +1361,13 @@ class BP_Activity_List_Table extends WP_List_Table {
1313
  }
1314
 
1315
  /**
1316
- * "In response to" column
 
 
1317
  *
1318
- * @param array $item A singular item (one full row)
1319
  * @see WP_List_Table::single_row_columns()
1320
- * @since BuddyPress (1.6)
 
1321
  */
1322
  function column_response( $item ) {
1323
  // Is $item is a root activity?
@@ -1342,10 +1392,15 @@ class BP_Activity_List_Table extends WP_List_Table {
1342
  }
1343
 
1344
  /**
1345
- * A wrapper function for the BP_Activity_List_Table to get the specified activity's user ID.
 
 
 
1346
  *
1347
- * @param int $activity_id Activity ID to retrieve User ID for
1348
- * @since BuddyPress (1.6)
 
 
1349
  */
1350
  protected function get_activity_user_id( $activity_id ) {
1351
  // If there is an existing activity/user ID mapping, just return the user ID.
@@ -1375,11 +1430,15 @@ class BP_Activity_List_Table extends WP_List_Table {
1375
  }
1376
 
1377
  /**
1378
- * Helper function to flatten all activites returned from bp_activity_get() into a single array.
 
 
 
 
 
1379
  *
1380
- * @param array $tree Source array
1381
- * @return array Flattened array
1382
- * @since BuddyPress (1.6)
1383
  */
1384
  public static function flatten_activity_array( $tree ){
1385
  foreach ( (array) $tree as $node ) {
1
  <?php
2
  /**
3
+ * BuddyPress Activity component admin screen.
4
  *
5
+ * Props to WordPress core for the Comments admin screen, and its contextual
6
+ * help text, on which this implementation is heavily based.
7
  *
8
  * @package BuddyPress
9
+ * @since BuddyPress (1.6.0)
10
  * @subpackage Activity
11
  */
12
 
21
  add_filter( 'set-screen-option', 'bp_activity_admin_screen_options', 10, 3 );
22
 
23
  /**
24
+ * Register the Activity component admin screen.
25
  *
26
  * @since BuddyPress (1.6)
27
  */
28
  function bp_activity_add_admin_menu() {
29
 
 
 
 
30
  // Add our screen
31
  $hook = add_menu_page(
32
  __( 'Activity', 'buddypress' ),
33
  __( 'Activity', 'buddypress' ),
34
+ 'bp_moderate',
35
  'bp-activity',
36
  'bp_activity_admin',
37
  'div'
43
  add_action( bp_core_admin_hook(), 'bp_activity_add_admin_menu' );
44
 
45
  /**
46
+ * Add activity component to custom menus array.
47
  *
48
+ * Several BuddyPress components have top-level menu items in the Dashboard,
49
+ * which all appear together in the middle of the Dashboard menu. This function
50
+ * adds the Activity page to the array of these menu items.
51
  *
52
+ * @since BuddyPress (1.7.0)
53
+ *
54
+ * @param array $custom_menus The list of top-level BP menu items.
55
+ * @return array $custom_menus List of top-level BP menu items, with Activity added
56
  */
57
  function bp_activity_admin_menu_order( $custom_menus = array() ) {
58
  array_push( $custom_menus, 'bp-activity' );
61
  add_filter( 'bp_admin_menu_order', 'bp_activity_admin_menu_order' );
62
 
63
  /**
64
+ * AJAX receiver for Activity replies via the admin screen.
 
65
  *
66
+ * Processes requests to add new activity comments, and echoes HTML for a new
67
+ * table row.
68
+ *
69
+ * @since BuddyPress (1.6.0)
70
  */
71
  function bp_activity_admin_reply() {
72
  // Check nonce
94
 
95
  // @todo: Check if user is allowed to create new activity items
96
  // if ( ! current_user_can( 'bp_new_activity' ) )
97
+ if ( ! current_user_can( 'bp_moderate' ) )
98
  die( '-1' );
99
 
100
  // Add new activity comment
134
  add_action( 'wp_ajax_bp-activity-admin-reply', 'bp_activity_admin_reply' );
135
 
136
  /**
137
+ * Handle save/update of screen options for the Activity component admin screen.
138
+ *
139
+ * @since BuddyPress (1.6.0)
140
  *
141
+ * @param string $value Will always be false unless another plugin filters it
142
+ * first.
143
+ * @param string $option Screen option name.
144
+ * @param string $new_value Screen option form value.
145
  * @return string Option value. False to abandon update.
 
146
  */
147
  function bp_activity_admin_screen_options( $value, $option, $new_value ) {
148
  if ( 'toplevel_page_bp_activity_per_page' != $option && 'toplevel_page_bp_activity_network_per_page' != $option )
157
  }
158
 
159
  /**
160
+ * Hide the advanced edit meta boxes by default, so we don't clutter the screen.
161
+ *
162
+ * @since BuddyPress (1.6.0)
163
  *
164
+ * @param WP_Screen $screen Screen identifier.
165
+ * @return array Hidden Meta Boxes.
 
166
  */
167
  function bp_activity_admin_edit_hidden_metaboxes( $hidden, $screen ) {
168
  if ( empty( $screen->id ) || 'toplevel_page_bp-activity' != $screen->id && 'toplevel_page_bp-activity_network' != $screen->id )
176
  add_filter( 'default_hidden_meta_boxes', 'bp_activity_admin_edit_hidden_metaboxes', 10, 2 );
177
 
178
  /**
179
+ * Set up the Activity admin page.
180
  *
181
+ * Does the following:
182
+ * - Register contextual help and screen options for this admin page.
183
+ * - Enqueues scripts and styles
184
+ * - Catches POST and GET requests related to Activity
185
+ *
186
+ * @since BuddyPress (1.6.0)
187
+ *
188
+ * @global object $bp BuddyPress global settings.
189
+ * @global BP_Activity_List_Table $bp_activity_list_table Activity screen list table.
190
  */
191
  function bp_activity_admin_load() {
192
  global $bp, $bp_activity_list_table;
218
  'title' => __( 'Item, Link, Type', 'buddypress' ),
219
  'content' =>
220
  '<p>' . __( '<strong>Primary Item/Secondary Item</strong> - These identify the object that created the activity. For example, the fields could reference a comment left on a specific site. Some types of activity may only use one, or none, of these fields.', 'buddypress' ) . '</p>' .
221
+ '<p>' . __( '<strong>Link</strong> - Activity generated by posts and comments, forum topics and replies, and some plugins, uses the link field for a permalink back to the content item. Some types of activity may not use this field, even if it has been set.', 'buddypress' ) . '</p>' .
222
  '<p>' . __( '<strong>Type</strong> - Each distinct kind of activity has its own type. For example, <code>created_group</code> is used when a group is created and <code>joined_group</code> is used when a user joins a group.', 'buddypress' ) . '</p>' .
223
  '<p>' . __( 'For information about when and how BuddyPress uses all of these settings, see the Managing Activity link in the panel to the side.', 'buddypress' ) . '</p>'
224
  ) );
533
  }
534
 
535
  /**
536
+ * Output the Activity component admin screens.
537
  *
538
+ * @since BuddyPress (1.6.0)
539
  */
540
  function bp_activity_admin() {
541
  // Decide whether to load the index or edit screen
551
  }
552
 
553
  /**
554
+ * Display the single activity edit screen.
555
  *
556
+ * @since BuddyPress (1.6.0)
 
557
  */
558
  function bp_activity_admin_edit() {
559
 
642
  }
643
 
644
  /**
645
+ * Status metabox for the Activity admin edit screen.
646
  *
647
+ * @since BuddyPress (1.6.0)
648
+ *
649
+ * @param object $item Activity item.
650
  */
651
  function bp_activity_admin_edit_metabox_status( $item ) {
652
  ?>
698
  }
699
 
700
  /**
701
+ * Primary link metabox for the Activity admin edit screen.
702
  *
703
+ * @since BuddyPress (1.6.0)
704
+ *
705
+ * @param object $item Activity item.
706
  */
707
  function bp_activity_admin_edit_metabox_link( $item ) {
708
  ?>
709
 
710
  <label class="screen-reader-text" for="bp-activities-link"><?php _e( 'Link', 'buddypress' ); ?></label>
711
  <input type="url" name="bp-activities-link" value="<?php echo esc_url( $item->primary_link ); ?>" />
712
+ <p><?php _e( 'Activity generated by posts and comments, forum topics and replies, and some plugins, uses the link field for a permalink back to the content item.', 'buddypress' ); ?></p>
713
 
714
  <?php
715
  }
716
 
717
  /**
718
+ * User ID metabox for the Activity admin edit screen.
719
  *
720
+ * @since BuddyPress (1.6.0)
721
+ *
722
+ * @param object $item Activity item.
723
  */
724
  function bp_activity_admin_edit_metabox_userid( $item ) {
725
  ?>
733
  /**
734
  * Activity type metabox for the Activity admin edit screen
735
  *
736
+ * @since BuddyPress (1.6.0)
737
+ *
738
+ * @global object $bp BuddyPress global settings.
739
+ *
740
+ * @param object $item Activity item.
741
  */
742
  function bp_activity_admin_edit_metabox_type( $item ) {
743
  global $bp;
769
  }
770
 
771
  /**
772
+ * Primary item ID/Secondary item ID metabox for the Activity admin edit screen.
773
  *
774
+ * @since BuddyPress (1.6.0)
775
+ *
776
+ * @param object $item Activity item.
777
  */
778
  function bp_activity_admin_edit_metabox_itemids( $item ) {
779
  ?>
793
  /**
794
  * Display the Activity admin index screen, which contains a list of all the activities.
795
  *
796
+ * @since BuddyPress (1.6.0)
797
+ *
798
+ * @global BP_Activity_List_Table $bp_activity_list_table Activity screen list
799
+ * table.
800
+ * @global string $plugin_page The current plugin page.
801
  */
802
  function bp_activity_admin_index() {
803
  global $bp_activity_list_table, $plugin_page;
927
  class BP_Activity_List_Table extends WP_List_Table {
928
 
929
  /**
930
+ * What type of view is being displayed?
931
  *
932
+ * e.g. "all", "pending", "approved", "spam"...
933
+ *
934
+ * @since BuddyPress (1.6.0)
935
+ * @var string
936
+ */
937
  public $view = 'all';
938
 
939
  /**
940
  * How many activity items have been marked as spam.
941
  *
942
+ * @since BuddyPress (1.6.0)
943
+ * @var int
944
  */
945
  public $spam_count = 0;
946
 
947
  /**
948
  * Store activity-to-user-ID mappings for use in the In Response To column.
949
  *
950
+ * @since BuddyPress (1.6.0)
951
+ * @var array
952
  */
953
  protected $activity_user_id = array();
954
 
955
  /**
956
+ * Constructor.
957
  *
958
+ * @since BuddyPress (1.6.0)
959
  */
960
  public function __construct() {
961
 
964
  'ajax' => false,
965
  'plural' => 'activities',
966
  'singular' => 'activity',
967
+ 'screen' => get_current_screen(),
968
  ) );
969
  }
970
 
971
  /**
972
+ * Handle filtering of data, sorting, pagination, and any other data manipulation prior to rendering.
973
  *
974
+ * @since BuddyPress (1.6.0)
975
  */
976
  function prepare_items() {
 
977
 
978
  // Option defaults
979
  $filter = array();
986
  $page = $this->get_pagenum();
987
 
988
  // Set per page from the screen options
989
+ $per_page = $this->get_items_per_page( str_replace( '-', '_', "{$this->screen->id}_per_page" ) );
990
 
991
  // Check if we're on the "Spam" view
992
  if ( !empty( $_REQUEST['activity_status'] ) && 'spam' == $_REQUEST['activity_status'] ) {
1069
  }
1070
 
1071
  /**
1072
+ * Get an array of all the columns on the page.
1073
  *
1074
+ * @since BuddyPress (1.6.0)
1075
+ *
1076
+ * @return array Column headers.
1077
  */
1078
  function get_column_info() {
1079
  $this->_column_headers = array(
1086
  }
1087
 
1088
  /**
1089
+ * Display a message on screen when no items are found (e.g. no search matches).
1090
  *
1091
+ * @since BuddyPress (1.6.0)
1092
  */
1093
  function no_items() {
1094
  _e( 'No activities found.', 'buddypress' );
1095
  }
1096
 
1097
  /**
1098
+ * Output the Activity data table.
1099
  *
1100
+ * @since BuddyPress (1.6.0)
1101
  */
1102
  function display() {
1103
  extract( $this->_args );
1127
  }
1128
 
1129
  /**
1130
+ * Generate content for a single row of the table.
1131
+ *
1132
+ * @since BuddyPress (1.6.0)
1133
  *
1134
+ * @param object $item The current item.
 
1135
  */
1136
  function single_row( $item ) {
1137
+ static $even = false;
1138
+
1139
+ if ( $even ) {
1140
+ $row_class = ' class="even"';
1141
+ } else {
1142
+ $row_class = ' class="alternate odd"';
1143
+ }
1144
 
1145
+ if ( 'activity_comment' === $item['type'] ) {
1146
+ $root_id = $item['item_id'];
1147
  } else {
1148
+ $root_id = $item['id'];
1149
  }
1150
 
1151
+ echo '<tr' . $row_class . ' id="activity-' . esc_attr( $item['id'] ) . '" data-parent_id="' . esc_attr( $item['id'] ) . '" data-root_id="' . esc_attr( $root_id ) . '">';
1152
  echo $this->single_row_columns( $item );
1153
  echo '</tr>';
1154
+
1155
+ $even = ! $even;
1156
  }
1157
 
1158
  /**
1159
  * Get the list of views available on this table (e.g. "all", "spam").
1160
  *
1161
+ * @since BuddyPress (1.6.0)
1162
  */
1163
  function get_views() {
1164
  $url_base = bp_get_admin_url( 'admin.php?page=bp-activity' ); ?>
1172
  <?php
1173
  }
1174
 
1175
+ /**
1176
+ * Get bulk actions.
1177
+ *
1178
+ * @since BuddyPress (1.6.0)
1179
  *
1180
+ * @return array Key/value pairs for the bulk actions dropdown.
 
1181
  */
1182
  function get_bulk_actions() {
1183
  $actions = array();
1191
  /**
1192
  * Get the table column titles.
1193
  *
1194
+ * @since BuddyPress (1.6.0)
1195
+ *
1196
  * @see WP_List_Table::single_row_columns()
1197
+ *
1198
+ * @return array The columns to appear in the Activity list table.
1199
  */
1200
  function get_columns() {
1201
  return array(
1207
  }
1208
 
1209
  /**
1210
+ * Get the column names for sortable columns.
1211
+ *
1212
+ * Currently, returns an empty array (no columns are sortable).
1213
  *
1214
+ * @since BuddyPress (1.6.0)
1215
+ * @todo For this to work, BP_Activity_Activity::get() needs updating
1216
+ * to support ordering by specific fields.
1217
+ *
1218
+ * @return array The columns that can be sorted on the Activity screen.
1219
  */
1220
  function get_sortable_columns() {
1221
  return array();
1226
  }
1227
 
1228
  /**
1229
+ * Markup for the "filter" part of the form (i.e. which activity type to display).
1230
+ *
1231
+ * @since BuddyPress (1.6.0)
1232
  *
1233
+ * @param string $which 'top' or 'bottom'.
 
1234
  */
1235
  function extra_tablenav( $which ) {
1236
  if ( 'bottom' == $which )
1259
  }
1260
 
1261
  /**
1262
+ * Checkbox column markup.
1263
+ *
1264
+ * @since BuddyPress (1.6.0)
1265
  *
 
1266
  * @see WP_List_Table::single_row_columns()
1267
+ *
1268
+ * @param array $item A singular item (one full row).
1269
  */
1270
  function column_cb( $item ) {
1271
  printf( '<label class="screen-reader-text" for="aid-%1$d">' . __( 'Select activity item %1$d', 'buddypress' ) . '</label><input type="checkbox" name="aid[]" value="%1$d" id="aid-%1$d" />', $item['id'] );
1272
  }
1273
 
1274
  /**
1275
+ * Author column markup.
1276
+ *
1277
+ * @since BuddyPress (1.6.0)
1278
  *
 
1279
  * @see WP_List_Table::single_row_columns()
1280
+ *
1281
+ * @param array $item A singular item (one full row).
1282
  */
1283
  function column_author( $item ) {
1284
  echo '<strong>' . get_avatar( $item['user_id'], '32' ) . ' ' . bp_core_get_userlink( $item['user_id'] ) . '</strong>';
1289
  *
1290
  * Called "comment" in the CSS so we can re-use some WP core CSS.
1291
  *
1292
+ * @since BuddyPress (1.6.0)
1293
+ *
1294
  * @see WP_List_Table::single_row_columns()
1295
+ *
1296
+ * @param array $item A singular item (one full row).
1297
  */
1298
  function column_comment( $item ) {
1299
  // Determine what type of item (row) we're dealing with
1345
  $actions = apply_filters( 'bp_activity_admin_comment_row_actions', array_filter( $actions ), $item );
1346
 
1347
  /* translators: 2: activity admin ui date/time */
1348
+ printf( __( 'Submitted on <a href="%1$s">%2$s at %3$s</a>', 'buddypress' ), bp_activity_get_permalink( $item['id'] ), get_date_from_gmt( $item['date_recorded'], get_option( 'date_format' ) ), get_date_from_gmt( $item['date_recorded'], get_option( 'time_format' ) ) );
1349
 
1350
  // End timestamp
1351
  echo '</div>';
1361
  }
1362
 
1363
  /**
1364
+ * "In response to" column markup.
1365
+ *
1366
+ * @since BuddyPress (1.6.0)
1367
  *
 
1368
  * @see WP_List_Table::single_row_columns()
1369
+ *
1370
+ * @param array $item A singular item (one full row).
1371
  */
1372
  function column_response( $item ) {
1373
  // Is $item is a root activity?
1392
  }
1393
 
1394
  /**
1395
+ * Get the user id associated with a given activity item.
1396
+ *
1397
+ * Wraps bp_activity_get_specific(), with some additional logic for
1398
+ * avoiding duplicate queries.
1399
  *
1400
+ * @since BuddyPress (1.6.0)
1401
+ *
1402
+ * @param int $activity_id Activity ID to retrieve User ID for.
1403
+ * @return int User ID of the activity item in question.
1404
  */
1405
  protected function get_activity_user_id( $activity_id ) {
1406
  // If there is an existing activity/user ID mapping, just return the user ID.
1430
  }
1431
 
1432
  /**
1433
+ * Flatten the activity array.
1434
+ *
1435
+ * In some cases, BuddyPress gives us a structured tree of activity
1436
+ * items plus their comments. This method converts it to a flat array.
1437
+ *
1438
+ * @since BuddyPress (1.6.0)
1439
  *
1440
+ * @param array $tree Source array.
1441
+ * @return array Flattened array.
 
1442
  */
1443
  public static function flatten_activity_array( $tree ){
1444
  foreach ( (array) $tree as $node ) {
bp-activity/bp-activity-akismet.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
  /**
3
- * Akismet support for BuddyPress' Activity Stream
4
  *
5
  * @package BuddyPress
6
  * @since BuddyPress (1.6)
@@ -10,9 +10,14 @@
10
  // Exit if accessed directly
11
  if ( !defined( 'ABSPATH' ) ) exit;
12
 
 
 
 
 
 
13
  class BP_Akismet {
14
  /**
15
- * The activity last marked as spam
16
  *
17
  * @access protected
18
  * @var BP_Activity_Activity
@@ -21,7 +26,7 @@ class BP_Akismet {
21
  protected $last_activity = null;
22
 
23
  /**
24
- * Constructor
25
  *
26
  * @since BuddyPress (1.6)
27
  */
@@ -30,7 +35,7 @@ class BP_Akismet {
30
  }
31
 
32
  /**
33
- * Hook Akismet into the activity stream
34
  *
35
  * @since BuddyPress (1.6)
36
  */
@@ -64,10 +69,11 @@ class BP_Akismet {
64
  * This function lifted with love from the Akismet WordPress plugin's
65
  * akismet_comment_row_action() function. Thanks!
66
  *
67
- * @param array $actions The hover links
68
- * @param array $activity The activity for the current row being processed
69
- * @return array The hover links
70
  * @since BuddyPress (1.6)
 
 
 
 
71
  */
72
  function comment_row_action( $actions, $activity ) {
73
  $akismet_result = bp_activity_get_meta( $activity['id'], '_bp_akismet_result' );
@@ -110,11 +116,15 @@ class BP_Akismet {
110
  }
111
 
112
  /**
113
- * Adds a nonce to the member profile status form, and to the reply form of each activity stream item.
114
- * This is used by Akismet to help detect spam activity.
 
 
 
115
  *
116
- * @see http://plugins.trac.wordpress.org/ticket/1232
117
  * @since BuddyPress (1.6)
 
 
118
  */
119
  public function add_activity_stream_nonce() {
120
  $form_id = '_bp_as_nonce';
@@ -130,15 +140,24 @@ class BP_Akismet {
130
  }
131
 
132
  /**
133
- * Check the member's latest (activity) update to see if it's the item that was (just) marked as spam.
134
  *
135
- * This can't be done in BP_Akismet::check_activity() due to BP-Default's AJAX implementation; see bp_dtheme_post_update().
 
 
 
 
 
 
 
136
  *
137
- * @param string $content Activity update text
138
- * @param int $user_id User ID
139
- * @param int $activity_id Activity ID
140
- * @see bp_dtheme_post_update()
141
  * @since BuddyPress (1.6)
 
 
 
 
 
 
142
  */
143
  public function check_member_activity_update( $content, $user_id, $activity_id ) {
144
  // By default, only handle activity updates and activity comments.
@@ -211,22 +230,25 @@ class BP_Akismet {
211
  }
212
 
213
  /**
214
- * Get a list of filterable types of activity item that we want Akismet to automatically check for spam.
215
  *
216
- * @return array List of activity types
217
  * @since BuddyPress (1.6)
 
218
  * @static
 
 
219
  */
220
  public static function get_activity_types() {
221
  return apply_filters( 'bp_akismet_get_activity_types', array( 'activity_comment', 'activity_update' ) );
222
  }
223
 
224
  /**
225
- * Mark activity item as spam
 
 
226
  *
227
  * @param BP_Activity_Activity $activity
228
  * @param string $source Either "by_a_person" (e.g. a person has manually marked the activity as spam) or "by_akismet" (automatically spammed).
229
- * @since BuddyPress (1.6)
230
  */
231
  public function mark_as_spam( $activity, $source ) {
232
  // Record this item so we can do some tidyup in BP_Akismet::check_member_activity_update()
@@ -236,11 +258,12 @@ class BP_Akismet {
236
  }
237
 
238
  /**
239
- * Mark activity item as ham
 
 
240
  *
241
  * @param BP_Activity_Activity $activity
242
  * @param string $source Either "by_a_person" (e.g. a person has manually marked the activity as ham) or "by_akismet" (automatically hammed).
243
- * @since BuddyPress (1.6)
244
  */
245
  public function mark_as_ham( $activity, $source ) {
246
  // If the activity was, originally, automatically marked as spam by Akismet, run the @mentions filter as it would have been skipped.
@@ -251,12 +274,14 @@ class BP_Akismet {
251
  }
252
 
253
  /**
254
- * Build a data package for the Akismet service to inspect
255
  *
256
- * @param BP_Activity_Activity $activity
257
- * @see http://akismet.com/development/api/#comment-check
258
  * @since BuddyPress (1.6)
 
 
259
  * @static
 
 
260
  */
261
  public static function build_akismet_data_package( $activity ) {
262
  $userdata = get_userdata( $activity->user_id );
@@ -290,13 +315,15 @@ class BP_Akismet {
290
  }
291
 
292
  /**
293
- * Check if the activity item is spam or ham
294
  *
295
- * @param BP_Activity_Activity $activity The activity item to check
296
- * @see http://akismet.com/development/api/
297
  * @since BuddyPress (1.6)
 
 
298
  * @todo Spam counter?
299
  * @todo Auto-delete old spam?
 
 
300
  */
301
  public function check_activity( $activity ) {
302
  // By default, only handle activity updates and activity comments.
@@ -332,10 +359,11 @@ class BP_Akismet {
332
  }
333
 
334
  /**
335
- * Update activity meta after a manual spam change (user initiated)
336
  *
337
- * @param BP_Activity_Activity $activity The activity to check
338
  * @since BuddyPress (1.6)
 
 
339
  */
340
  public function update_activity_spam_meta( $activity ) {
341
  // By default, only handle activity updates and activity comments.
@@ -348,10 +376,11 @@ class BP_Akismet {
348
  }
349
 
350
  /**
351
- * Update activity meta after a manual ham change (user initiated)
352
  *
353
- * @param BP_Activity_Activity $activity The activity to check
354
  * @since BuddyPress (1.6)
 
 
355
  */
356
  public function update_activity_ham_meta( $activity ) {
357
  // By default, only handle activity updates and activity comments.
@@ -364,10 +393,11 @@ class BP_Akismet {
364
  }
365
 
366
  /**
367
- * Update activity meta after an automatic spam check (not user initiated)
368
  *
369
- * @param BP_Activity_Activity $activity The activity to check
370
  * @since BuddyPress (1.6)
 
 
371
  */
372
  public function update_activity_akismet_meta( $activity ) {
373
  // Check we're dealing with what was last updated by Akismet
@@ -399,16 +429,19 @@ class BP_Akismet {
399
  }
400
 
401
  /**
402
- * Contact Akismet to check if this is spam or ham
 
 
403
  *
404
- * Props to WordPress core Akismet plugin for alot of this
405
  *
406
  * @global string $akismet_api_host
407
  * @global string $akismet_api_port
408
- * @param array $activity_data Packet of information to submit to Akismet
409
- * @param string $check "check" or "submit"
410
- * @param string $spam "spam" or "ham"
411
- * @since BuddyPress (1.6)
 
412
  */
413
  public function send_akismet_request( $activity_data, $check = 'check', $spam = 'spam' ) {
414
  global $akismet_api_host, $akismet_api_port;
@@ -477,10 +510,12 @@ class BP_Akismet {
477
  }
478
 
479
  /**
480
- * Filters user agent when sending to Akismet.
481
  *
482
- * @param string $user_agent
483
  * @since BuddyPress (1.6)
 
 
 
484
  */
485
  public function buddypress_ua( $user_agent ) {
486
  $user_agent = 'BuddyPress/' . bp_get_version() . ' | Akismet/'. constant( 'AKISMET_VERSION' );
@@ -490,8 +525,9 @@ class BP_Akismet {
490
  /**
491
  * Adds a "History" meta box to the activity edit screen.
492
  *
493
- * @param string $screen_action The type of screen that has been requested
494
  * @since BuddyPress (1.6)
 
 
495
  */
496
  function add_history_metabox( $screen_action ) {
497
  // Only proceed if we're on the edit screen
@@ -503,12 +539,14 @@ class BP_Akismet {
503
  }
504
 
505
  /**
506
- * History meta box for the Activity admin edit screen
507
  *
508
- * @param object $item Activity item
509
  * @since BuddyPress (1.6)
510
- * @todo Update activity meta to allow >1 record with the same key (iterate through $history).
511
  * @see http://buddypress.trac.wordpress.org/ticket/3907
 
 
 
512
  */
513
  function history_metabox( $item ) {
514
  $history = BP_Akismet::get_activity_history( $item->id );
@@ -522,12 +560,13 @@ class BP_Akismet {
522
  }
523
 
524
  /**
525
- * Update an activity item's Akismet history
526
  *
527
- * @param int $activity_id Activity item ID
528
- * @param string $message Human-readable description of what's changed
529
- * @param string $event The type of check we were carrying out
530
  * @since BuddyPress (1.6)
 
 
 
 
531
  */
532
  public function update_activity_history( $activity_id = 0, $message = '', $event = '' ) {
533
  $event = array(
@@ -542,11 +581,12 @@ class BP_Akismet {
542
  }
543
 
544
  /**
545
- * Get an activity item's Akismet history
546
  *
547
- * @param int $activity_id Activity item ID
548
- * @return array The activity item's Akismet history
549
  * @since BuddyPress (1.6)
 
 
 
550
  */
551
  public function get_activity_history( $activity_id = 0 ) {
552
  $history = bp_activity_get_meta( $activity_id, '_bp_akismet_history' );
@@ -561,11 +601,15 @@ class BP_Akismet {
561
  }
562
 
563
  /**
564
- * Deletes old spam activity meta data, as _bp_akismet_submission meta can be large.
 
 
 
565
  *
566
- * @global object $bp BuddyPress global settings
567
- * @global wpdb $wpdb WordPress database object
568
  * @since BuddyPress (1.6)
 
 
 
569
  */
570
  function bp_activity_akismet_delete_old_metadata() {
571
  global $bp, $wpdb;
1
  <?php
2
  /**
3
+ * Akismet support for BuddyPress' Activity Stream.
4
  *
5
  * @package BuddyPress
6
  * @since BuddyPress (1.6)
10
  // Exit if accessed directly
11
  if ( !defined( 'ABSPATH' ) ) exit;
12
 
13
+ /**
14
+ * Akismet support for the Activity component.
15
+ *
16
+ * @since BuddyPress (1.6)
17
+ */
18
  class BP_Akismet {
19
  /**
20
+ * The activity last marked as spam.
21
  *
22
  * @access protected
23
  * @var BP_Activity_Activity
26
  protected $last_activity = null;
27
 
28
  /**
29
+ * Constructor.
30
  *
31
  * @since BuddyPress (1.6)
32
  */
35
  }
36
 
37
  /**
38
+ * Hook Akismet into the activity stream.
39
  *
40
  * @since BuddyPress (1.6)
41
  */
69
  * This function lifted with love from the Akismet WordPress plugin's
70
  * akismet_comment_row_action() function. Thanks!
71
  *
 
 
 
72
  * @since BuddyPress (1.6)
73
+ *
74
+ * @param array $actions The hover links.
75
+ * @param array $activity The activity for the current row being processed.
76
+ * @return array The hover links.
77
  */
78
  function comment_row_action( $actions, $activity ) {
79
  $akismet_result = bp_activity_get_meta( $activity['id'], '_bp_akismet_result' );
116
  }
117
 
118
  /**
119
+ * Generate nonces for activity forms.
120
+ *
121
+ * These nonces appear in the member profile status form, as well as in
122
+ * the reply form of each activity item. The nonces are, in turn, used
123
+ * by Akismet to help detect spam activity.
124
  *
 
125
  * @since BuddyPress (1.6)
126
+ *
127
+ * @see http://plugins.trac.wordpress.org/ticket/1232
128
  */
129
  public function add_activity_stream_nonce() {
130
  $form_id = '_bp_as_nonce';
140
  }
141
 
142
  /**
143
+ * Clean up the bp_latest_update usermeta in case of spamming.
144
  *
145
+ * Run just after an update is posted, this method check to see whether
146
+ * the newly created update has been marked as spam by Akismet. If so,
147
+ * the cached update is cleared from the user's 'bp_latest_update'
148
+ * usermeta, ensuring that it won't appear in the member header and
149
+ * elsewhere in the theme.
150
+ *
151
+ * This can't be done in BP_Akismet::check_activity() due to the
152
+ * default AJAX implementation; see bp_dtheme_post_update().
153
  *
 
 
 
 
154
  * @since BuddyPress (1.6)
155
+ *
156
+ * @see bp_dtheme_post_update()
157
+ *
158
+ * @param string $content Activity update text.
159
+ * @param int $user_id User ID.
160
+ * @param int $activity_id Activity ID.
161
  */
162
  public function check_member_activity_update( $content, $user_id, $activity_id ) {
163
  // By default, only handle activity updates and activity comments.
230
  }
231
 
232
  /**
233
+ * Get a filterable list of activity types that Akismet should automatically check for spam.
234
  *
 
235
  * @since BuddyPress (1.6)
236
+ *
237
  * @static
238
+ *
239
+ * @return array List of activity types.
240
  */
241
  public static function get_activity_types() {
242
  return apply_filters( 'bp_akismet_get_activity_types', array( 'activity_comment', 'activity_update' ) );
243
  }
244
 
245
  /**
246
+ * Mark activity item as spam.
247
+ *
248
+ * @since BuddyPress (1.6)
249
  *
250
  * @param BP_Activity_Activity $activity
251
  * @param string $source Either "by_a_person" (e.g. a person has manually marked the activity as spam) or "by_akismet" (automatically spammed).
 
252
  */
253
  public function mark_as_spam( $activity, $source ) {
254
  // Record this item so we can do some tidyup in BP_Akismet::check_member_activity_update()
258
  }
259
 
260
  /**
261
+ * Mark activity item as ham.
262
+ *
263
+ * @since BuddyPress (1.6)
264
  *
265
  * @param BP_Activity_Activity $activity
266
  * @param string $source Either "by_a_person" (e.g. a person has manually marked the activity as ham) or "by_akismet" (automatically hammed).
 
267
  */
268
  public function mark_as_ham( $activity, $source ) {
269
  // If the activity was, originally, automatically marked as spam by Akismet, run the @mentions filter as it would have been skipped.
274
  }
275
 
276
  /**
277
+ * Build a data package for the Akismet service to inspect.
278
  *
 
 
279
  * @since BuddyPress (1.6)
280
+ *
281
+ * @see http://akismet.com/development/api/#comment-check
282
  * @static
283
+ *
284
+ * @param BP_Activity_Activity $activity Activity item data.
285
  */
286
  public static function build_akismet_data_package( $activity ) {
287
  $userdata = get_userdata( $activity->user_id );
315
  }
316
 
317
  /**
318
+ * Check if the activity item is spam or ham.
319
  *
 
 
320
  * @since BuddyPress (1.6)
321
+ *
322
+ * @see http://akismet.com/development/api/
323
  * @todo Spam counter?
324
  * @todo Auto-delete old spam?
325
+ *
326
+ * @param BP_Activity_Activity $activity The activity item to check.
327
  */
328
  public function check_activity( $activity ) {
329
  // By default, only handle activity updates and activity comments.
359
  }
360
 
361
  /**
362
+ * Update activity meta after a manual spam change (user-initiated).
363
  *
 
364
  * @since BuddyPress (1.6)
365
+ *
366
+ * @param BP_Activity_Activity $activity The activity to check.
367
  */
368
  public function update_activity_spam_meta( $activity ) {
369
  // By default, only handle activity updates and activity comments.
376
  }
377
 
378
  /**
379
+ * Update activity meta after a manual ham change (user-initiated).
380
  *
 
381
  * @since BuddyPress (1.6)
382
+ *
383
+ * @param BP_Activity_Activity $activity The activity to check.
384
  */
385
  public function update_activity_ham_meta( $activity ) {
386
  // By default, only handle activity updates and activity comments.
393
  }
394
 
395
  /**
396
+ * Update activity meta after an automatic spam check (not user-initiated).
397
  *
 
398
  * @since BuddyPress (1.6)
399
+ *
400
+ * @param BP_Activity_Activity $activity The activity to check.
401
  */
402
  public function update_activity_akismet_meta( $activity ) {
403
  // Check we're dealing with what was last updated by Akismet
429
  }
430
 
431
  /**
432
+ * Contact Akismet to check if this is spam or ham.
433
+ *
434
+ * Props to WordPress core Akismet plugin for alot of this.
435
  *
436
+ * @since BuddyPress (1.6)
437
  *
438
  * @global string $akismet_api_host
439
  * @global string $akismet_api_port
440
+ *
441
+ * @param array $activity_data Packet of information to submit to Akismet.
442
+ * @param string $check "check" or "submit".
443
+ * @param string $spam "spam" or "ham".
444
+ * @return array $activity_data Activity data, with Akismet data added.
445
  */
446
  public function send_akismet_request( $activity_data, $check = 'check', $spam = 'spam' ) {
447
  global $akismet_api_host, $akismet_api_port;
510
  }
511
 
512
  /**
513
+ * Filters user agent when sending to Akismet to add BuddyPress info.
514
  *
 
515
  * @since BuddyPress (1.6)
516
+ *
517
+ * @param string $user_agent User agent string, as generated by Akismet.
518
+ * @return string $user_agent Modified user agent string.
519
  */
520
  public function buddypress_ua( $user_agent ) {
521
  $user_agent = 'BuddyPress/' . bp_get_version() . ' | Akismet/'. constant( 'AKISMET_VERSION' );
525
  /**
526
  * Adds a "History" meta box to the activity edit screen.
527
  *
 
528
  * @since BuddyPress (1.6)
529
+ *
530
+ * @param string $screen_action The type of screen that has been requested.
531
  */
532
  function add_history_metabox( $screen_action ) {
533
  // Only proceed if we're on the edit screen
539
  }
540
 
541
  /**
542
+ * History meta box for the Activity admin edit screen.
543
  *
 
544
  * @since BuddyPress (1.6)
545
+ *
546
  * @see http://buddypress.trac.wordpress.org/ticket/3907
547
+ * @todo Update activity meta to allow >1 record with the same key (iterate through $history).
548
+ *
549
+ * @param object $item Activity item.
550
  */
551
  function history_metabox( $item ) {
552
  $history = BP_Akismet::get_activity_history( $item->id );
560
  }
561
 
562
  /**
563
+ * Update an activity item's Akismet history.
564
  *
 
 
 
565
  * @since BuddyPress (1.6)
566
+ *
567
+ * @param int $activity_id Activity item ID.
568
+ * @param string $message Human-readable description of what's changed.
569
+ * @param string $event The type of check we were carrying out.
570
  */
571
  public function update_activity_history( $activity_id = 0, $message = '', $event = '' ) {
572
  $event = array(
581
  }
582
 
583
  /**
584
+ * Get an activity item's Akismet history.
585
  *
 
 
586
  * @since BuddyPress (1.6)
587
+ *
588
+ * @param int $activity_id Activity item ID.
589
+ * @return array The activity item's Akismet history.
590
  */
591
  public function get_activity_history( $activity_id = 0 ) {
592
  $history = bp_activity_get_meta( $activity_id, '_bp_akismet_history' );
601
  }
602
 
603
  /**
604
+ * Delete old spam activity meta data
605
+ *
606
+ * This is done as a clean-up mechanism, as _bp_akismet_submission meta can
607
+ * grow to be quite large.
608
  *
 
 
609
  * @since BuddyPress (1.6)
610
+ *
611
+ * @global object $bp BuddyPress global settings.
612
+ * @global wpdb $wpdb WordPress database object.
613
  */
614
  function bp_activity_akismet_delete_old_metadata() {
615
  global $bp, $wpdb;
bp-activity/bp-activity-cache.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
 
3
  /**
4
- * Functions related to the BuddyPress Activity component and the WP Cache
5
  *
6
  * @since BuddyPress (1.6)
7
  */
@@ -10,17 +10,18 @@
10
  if ( !defined( 'ABSPATH' ) ) exit;
11
 
12
  /**
13
- * Slurps up activitymeta
14
  *
15
- * This function is called in two places in the BP_Groups_Group class:
16
- * - in the populate() method, when single group objects are populated
17
  * - in the get() method, when multiple groups are queried
18
  *
19
- * It grabs all groupmeta associated with all of the groups passed in $group_ids and adds it to
20
- * the WP cache. This improves efficiency when using groupmeta inline
 
21
  *
22
- * @param int|str|array $group_ids Accepts a single group_id, or a comma-separated list or array of
23
- * group ids
24
  */
25
  function bp_activity_update_meta_cache( $activity_ids = false ) {
26
  global $bp;
@@ -37,7 +38,7 @@ function bp_activity_update_meta_cache( $activity_ids = false ) {
37
  }
38
 
39
  /**
40
- * Clear the cache for all metadata of a given activity
41
  *
42
  * @param int $activity_id
43
  */
1
  <?php
2
 
3
  /**
4
+ * Functions related to the BuddyPress Activity component and the WP Cache.
5
  *
6
  * @since BuddyPress (1.6)
7
  */
10
  if ( !defined( 'ABSPATH' ) ) exit;
11
 
12
  /**
13
+ * Slurp up activitymeta for a specified set of activity items.
14
  *
15
+ * This function is called in two places in the BP_Activity_Activity class:
16
+ * - in the populate() method, when single activity objects are populated
17
  * - in the get() method, when multiple groups are queried
18
  *
19
+ * It grabs all activitymeta associated with all of the activity items passed
20
+ * in $activity_ids and adds it to the WP cache. This improves efficiency when
21
+ * using querying activitymeta inline.
22
  *
23
+ * @param int|str|array $activity_ids Accepts a single activity ID, or a comma-
24
+ * separated list or array of activity ids
25
  */
26
  function bp_activity_update_meta_cache( $activity_ids = false ) {
27
  global $bp;
38
  }
39
 
40
  /**
41
+ * Clear the cache for all metadata of a given activity.
42
  *
43
  * @param int $activity_id
44
  */
bp-activity/bp-activity-classes.php CHANGED
@@ -9,30 +9,132 @@
9
  // Exit if accessed directly
10
  if ( !defined( 'ABSPATH' ) ) exit;
11
 
 
 
 
 
 
 
 
 
12
  class BP_Activity_Activity {
 
 
 
 
 
 
 
 
13
  var $id;
 
 
 
 
 
 
14
  var $item_id;
 
 
 
 
 
 
15
  var $secondary_item_id;
 
 
 
 
 
 
16
  var $user_id;
 
 
 
 
 
 
17
  var $primary_link;
 
 
 
 
 
 
18
  var $component;
 
 
 
 
 
 
19
  var $type;
 
 
 
 
 
 
20
  var $action;
 
 
 
 
 
 
21
  var $content;
 
 
 
 
 
 
22
  var $date_recorded;
 
 
 
 
 
 
23
  var $hide_sitewide = false;
 
 
 
 
 
 
24
  var $mptt_left;
 
 
 
 
 
 
25
  var $mptt_right;
 
 
 
 
 
 
26
  var $is_spam;
27
 
28
- function __construct( $id = false ) {
 
 
 
 
 
29
  if ( !empty( $id ) ) {
30
  $this->id = $id;
31
  $this->populate();
32
  }
33
  }
34
 
35
- function populate() {
 
 
 
36
  global $wpdb, $bp;
37
 
38
  if ( $row = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} WHERE id = %d", $this->id ) ) ) {
@@ -55,8 +157,13 @@ class BP_Activity_Activity {
55
  }
56
  }
57
 
58
- function save() {
59
- global $wpdb, $bp, $current_user;
 
 
 
 
 
60
 
61
  $this->id = apply_filters_ref_array( 'bp_activity_id_before_save', array( $this->id, &$this ) );
62
  $this->item_id = apply_filters_ref_array( 'bp_activity_item_id_before_save', array( $this->item_id, &$this ) );
@@ -104,15 +211,45 @@ class BP_Activity_Activity {
104
  return true;
105
  }
106
 
107
- // Static Functions
108
 
109
  /**
110
  * Get activity items, as specified by parameters
111
  *
112
- * @param array $args See $defaults for explanation of arguments
113
- * @return array
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
  */
115
- function get( $args = array() ) {
116
  global $wpdb, $bp;
117
 
118
  // Backward compatibility with old method of passing arguments
@@ -295,7 +432,7 @@ class BP_Activity_Activity {
295
  }
296
 
297
  /**
298
- * Get the SQL for the 'meta_query' param in BP_Activity_Activity::get()
299
  *
300
  * We use WP_Meta_Query to do the heavy lifting of parsing the
301
  * meta_query array and creating the necessary SQL clauses. However,
@@ -307,7 +444,7 @@ class BP_Activity_Activity {
307
  *
308
  * @param array $meta_query An array of meta_query filters. See the
309
  * documentation for WP_Meta_Query for details.
310
- * @return array $sql_array 'join' and 'where' clauses
311
  */
312
  public static function get_meta_query_sql( $meta_query = array() ) {
313
  global $wpdb;
@@ -336,10 +473,14 @@ class BP_Activity_Activity {
336
 
337
  /**
338
  * In BuddyPress 1.2.x, this was used to retrieve specific activity stream items (for example, on an activity's permalink page).
 
339
  * As of 1.5.x, use BP_Activity_Activity::get() with an 'in' parameter instead.
340
  *
 
 
341
  * @deprecated 1.5
342
  * @deprecated Use BP_Activity_Activity::get() with an 'in' parameter instead.
 
343
  * @param mixed $activity_ids Array or comma-separated string of activity IDs to retrieve
344
  * @param int $max Maximum number of results to return. (Optional; default is no maximum)
345
  * @param int $page The set of results that the user is viewing. Used in pagination. (Optional; default is 1)
@@ -347,14 +488,26 @@ class BP_Activity_Activity {
347
  * @param string MySQL column sort; ASC or DESC. (Optional; default is DESC)
348
  * @param bool $display_comments Retrieve an activity item's associated comments or not. (Optional; default is false)
349
  * @return array
350
- * @since BuddyPress (1.2)
351
  */
352
- function get_specific( $activity_ids, $max = false, $page = 1, $per_page = 25, $sort = 'DESC', $display_comments = false ) {
353
  _deprecated_function( __FUNCTION__, '1.5', 'Use BP_Activity_Activity::get() with the "in" parameter instead.' );
354
  return BP_Activity_Activity::get( $max, $page, $per_page, $sort, false, false, $display_comments, false, false, $activity_ids );
355
  }
356
 
357
- function get_id( $user_id, $component, $type, $item_id, $secondary_item_id, $action, $content, $date_recorded ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
358
  global $bp, $wpdb;
359
 
360
  $where_args = false;
@@ -391,7 +544,30 @@ class BP_Activity_Activity {
391
  return $wpdb->get_var( "SELECT id FROM {$bp->activity->table_name} {$where_sql}" );
392
  }
393
 
394
- function delete( $args ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
395
  global $wpdb, $bp;
396
 
397
  $defaults = array(
@@ -453,28 +629,73 @@ class BP_Activity_Activity {
453
  // Fetch the activity IDs so we can delete any comments for this activity item
454
  $activity_ids = $wpdb->get_col( "SELECT id FROM {$bp->activity->table_name} {$where_sql}" );
455
 
456
- if ( !$wpdb->query( "DELETE FROM {$bp->activity->table_name} {$where_sql}" ) )
457
  return false;
 
458
 
 
459
  if ( $activity_ids ) {
460
- BP_Activity_Activity::delete_activity_item_comments( $activity_ids );
461
- BP_Activity_Activity::delete_activity_meta_entries( $activity_ids );
 
 
 
 
 
 
 
 
462
 
463
- return $activity_ids;
 
 
 
 
 
464
  }
465
 
466
  return $activity_ids;
467
  }
468
 
469
- function delete_activity_item_comments( $activity_ids = array() ) {
 
 
 
 
 
 
 
 
 
 
 
470
  global $bp, $wpdb;
471
 
 
 
472
  $activity_ids = implode( ',', wp_parse_id_list( $activity_ids ) );
473
 
 
 
 
 
 
 
 
 
 
474
  return $wpdb->query( "DELETE FROM {$bp->activity->table_name} WHERE type = 'activity_comment' AND item_id IN ({$activity_ids})" );
475
  }
476
 
477
- function delete_activity_meta_entries( $activity_ids = array() ) {
 
 
 
 
 
 
 
 
478
  global $bp, $wpdb;
479
 
480
  $activity_ids = implode( ',', wp_parse_id_list( $activity_ids ) );
@@ -487,17 +708,17 @@ class BP_Activity_Activity {
487
  }
488
 
489
  /**
490
- * Append activity comments to their associated activity items
491
  *
492
- * @global wpdb $wpdb WordPress database object
493
- * @param array $activities
494
- * @param bool $spam Optional; 'ham_only' (default), 'spam_only' or 'all'.
495
- * @return array The updated activities with nested comments
496
  * @since BuddyPress (1.2)
 
 
 
 
 
 
497
  */
498
- function append_comments( $activities, $spam = 'ham_only' ) {
499
- global $wpdb;
500
-
501
  $activity_comments = array();
502
 
503
  // Now fetch the activity comments and parse them into the correct position in the activities array.
@@ -515,19 +736,21 @@ class BP_Activity_Activity {
515
  }
516
 
517
  /**
518
- * Get activity comments that are associated with a specific activity ID
519
  *
520
- * @global BuddyPress $bp The one true BuddyPress instance
521
- * @global wpdb $wpdb WordPress database object
522
- * @param int $activity_id Activity ID to fetch comments for
523
- * @param int $left Left-most node boundary
524
- * @param into $right Right-most node boundary
525
- * @param bool $spam Optional; 'ham_only' (default), 'spam_only' or 'all'.
526
- * @param int $top_level_parent_id The id of the root-level parent activity item
527
- * @return array The updated activities with nested comments
528
  * @since BuddyPress (1.2)
 
 
 
 
 
 
 
 
 
 
529
  */
530
- function get_activity_comments( $activity_id, $left, $right, $spam = 'ham_only', $top_level_parent_id = 0 ) {
531
  global $wpdb, $bp;
532
 
533
  if ( empty( $top_level_parent_id ) ) {
@@ -584,7 +807,19 @@ class BP_Activity_Activity {
584
  return $comments;
585
  }
586
 
587
- function rebuild_activity_comment_tree( $parent_id, $left = 1 ) {
 
 
 
 
 
 
 
 
 
 
 
 
588
  global $wpdb, $bp;
589
 
590
  // The right value of this node is the left value + 1
@@ -608,40 +843,65 @@ class BP_Activity_Activity {
608
  return $right + 1;
609
  }
610
 
611
- function get_child_comments( $parent_id ) {
 
 
 
 
 
 
 
 
 
 
 
612
  global $bp, $wpdb;
613
 
614
  return $wpdb->get_results( $wpdb->prepare( "SELECT id FROM {$bp->activity->table_name} WHERE type = 'activity_comment' AND secondary_item_id = %d", $parent_id ) );
615
  }
616
 
617
  /**
618
- * Fetch a list of all components that have activity items recorded
619
  *
620
- * @return array
621
  */
622
- function get_recorded_components() {
623
  global $wpdb, $bp;
624
  return $wpdb->get_col( "SELECT DISTINCT component FROM {$bp->activity->table_name} ORDER BY component ASC" );
625
  }
626
 
627
- function get_sitewide_items_for_feed( $limit = 35 ) {
628
- global $bp;
629
-
 
 
 
 
630
  $activities = bp_activity_get_sitewide( array( 'max' => $limit ) );
631
  $activity_feed = array();
632
 
633
  for ( $i = 0, $count = count( $activities ); $i < $count; ++$i ) {
634
- $title = explode( '<span', $activities[$i]['content'] );
635
- $activity_feed[$i]['title'] = trim( strip_tags( $title[0] ) );
636
- $activity_feed[$i]['link'] = $activities[$i]['primary_link'];
637
- $activity_feed[$i]['description'] = @sprintf( $activities[$i]['content'], '' );
638
- $activity_feed[$i]['pubdate'] = $activities[$i]['date_recorded'];
639
  }
640
 
641
  return $activity_feed;
642
  }
643
 
644
- function get_in_operator_sql( $field, $items ) {
 
 
 
 
 
 
 
 
 
 
645
  global $wpdb;
646
 
647
  // split items at the comma
@@ -665,7 +925,27 @@ class BP_Activity_Activity {
665
  return false;
666
  }
667
 
668
- function get_filter_sql( $filter_array ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
669
 
670
  $filter_sql = array();
671
 
@@ -705,26 +985,53 @@ class BP_Activity_Activity {
705
  return join( ' AND ', $filter_sql );
706
  }
707
 
708
- function get_last_updated() {
 
 
 
 
 
 
 
709
  global $bp, $wpdb;
710
 
711
  return $wpdb->get_var( "SELECT date_recorded FROM {$bp->activity->table_name} ORDER BY date_recorded DESC LIMIT 1" );
712
  }
713
 
714
- function total_favorite_count( $user_id ) {
 
 
 
 
 
 
 
 
715
  if ( !$favorite_activity_entries = bp_get_user_meta( $user_id, 'bp_favorite_activities', true ) )
716
  return 0;
717
 
718
  return count( maybe_unserialize( $favorite_activity_entries ) );
719
  }
720
 
721
- function check_exists_by_content( $content ) {
 
 
 
 
 
 
722
  global $wpdb, $bp;
723
 
724
  return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->activity->table_name} WHERE content = %s", $content ) );
725
  }
726
 
727
- function hide_all_for_user( $user_id ) {
 
 
 
 
 
 
728
  global $wpdb, $bp;
729
 
730
  return $wpdb->get_var( $wpdb->prepare( "UPDATE {$bp->activity->table_name} SET hide_sitewide = 1 WHERE user_id = %d", $user_id ) );
@@ -862,6 +1169,8 @@ class BP_Activity_Feed {
862
 
863
  /**
864
  * Setup and validate the class properties.
 
 
865
  */
866
  protected function setup_properties() {
867
  $this->id = sanitize_title( $this->id );
@@ -874,6 +1183,7 @@ class BP_Activity_Feed {
874
 
875
  $this->activity_args = wp_parse_args( $this->activity_args, array(
876
  'max' => $this->max,
 
877
  'display_comments' => 'stream'
878
  ) );
879
 
@@ -884,6 +1194,8 @@ class BP_Activity_Feed {
884
  *
885
  * Currently, these hooks are used to maintain backwards compatibility with
886
  * the RSS feeds previous to BP 1.8.
 
 
887
  */
888
  protected function setup_hooks() {
889
  add_action( 'bp_activity_feed_rss_attributes', array( $this, 'backpat_rss_attributes' ) );
@@ -893,14 +1205,23 @@ class BP_Activity_Feed {
893
 
894
  /** BACKPAT HOOKS ********************************************************/
895
 
 
 
 
896
  public function backpat_rss_attributes() {
897
  do_action( 'bp_activity_' . $this->id . '_feed' );
898
  }
899
 
 
 
 
900
  public function backpat_channel_elements() {
901
  do_action( 'bp_activity_' . $this->id . '_feed_head' );
902
  }
903