Changeset 5262 for trunk/bp-activity/bp-activity-functions.php
- Timestamp:
- 11/01/2011 11:21:59 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-activity/bp-activity-functions.php
r5259 r5262 692 692 function bp_activity_get( $args = '' ) { 693 693 $defaults = array( 694 'max' => false, // Maximum number of results to return695 'page' => 1, // page 1 without a per_page will result in no pagination.696 'per_page' => false, // results per page697 'sort' => 'DESC', // sort ASC or DESC698 'display_comments' => false, // false for no comments. 'stream' for within stream display, 'threaded' for below each activity item699 700 'search_terms' => false, // Pass search terms as a string701 'show_hidden' => false, // Show activity items that are hidden site-wide?702 'exclude' => false, // Comma-separated list of activity IDs to exclude703 'in' => false, // Comma-separated list or array of activity IDs to which you want to limit the query704 ' hide_spam' => true, // Don't retrieve items marked as spam?694 'max' => false, // Maximum number of results to return 695 'page' => 1, // page 1 without a per_page will result in no pagination. 696 'per_page' => false, // results per page 697 'sort' => 'DESC', // sort ASC or DESC 698 'display_comments' => false, // false for no comments. 'stream' for within stream display, 'threaded' for below each activity item 699 700 'search_terms' => false, // Pass search terms as a string 701 'show_hidden' => false, // Show activity items that are hidden site-wide? 702 'exclude' => false, // Comma-separated list of activity IDs to exclude 703 'in' => false, // Comma-separated list or array of activity IDs to which you want to limit the query 704 'spam' => 'ham_only', // 'ham_only' (default), 'spam_only' or 'all'. 705 705 706 706 /** … … 720 720 721 721 // Attempt to return a cached copy of the first page of sitewide activity. 722 if ( 1 == (int)$page && empty( $max ) && empty( $search_terms ) && empty( $filter ) && 'DESC' == $sort && empty( $exclude )) {722 if ( 1 == (int)$page && empty( $max ) && empty( $search_terms ) && empty( $filter ) && empty( $exclude ) && empty( $in ) && 'DESC' == $sort && empty( $exclude ) && 'ham_only' == $spam ) { 723 723 if ( !$activity = wp_cache_get( 'bp_activity_sitewide_front', 'bp' ) ) { 724 $activity = BP_Activity_Activity::get( $max, $page, $per_page, $sort, $search_terms, $filter, $display_comments, $show_hidden, false, false, $ hide_spam );724 $activity = BP_Activity_Activity::get( $max, $page, $per_page, $sort, $search_terms, $filter, $display_comments, $show_hidden, false, false, $spam ); 725 725 wp_cache_set( 'bp_activity_sitewide_front', $activity, 'bp' ); 726 726 } 727 727 728 728 } else { 729 $activity = BP_Activity_Activity::get( $max, $page, $per_page, $sort, $search_terms, $filter, $display_comments, $show_hidden, $exclude, $in, $ hide_spam );729 $activity = BP_Activity_Activity::get( $max, $page, $per_page, $sort, $search_terms, $filter, $display_comments, $show_hidden, $exclude, $in, $spam ); 730 730 } 731 731 … … 748 748 function bp_activity_get_specific( $args = '' ) { 749 749 $defaults = array( 750 'activity_ids' => false, // A single activity_id or array of IDs.751 'display_comments' => false, // true or false to display threaded comments for these specific activity items752 ' hide_spam' => false, // Retrieve items marked as spam753 ' max' => false, // Maximum number of results to return754 'p age' => 1, // page 1 without a per_page will result in no pagination.755 ' per_page' => false, // results per page756 's how_hidden' => true, // When fetching specific items, show all757 's ort' => 'DESC', // sort ASC or DESC750 'activity_ids' => false, // A single activity_id or array of IDs. 751 'display_comments' => false, // true or false to display threaded comments for these specific activity items 752 'max' => false, // Maximum number of results to return 753 'page' => 1, // page 1 without a per_page will result in no pagination. 754 'per_page' => false, // results per page 755 'show_hidden' => true, // When fetching specific items, show all 756 'sort' => 'DESC', // sort ASC or DESC 757 'spam' => 'ham_only', // Retrieve items marked as spam 758 758 ); 759 759 $r = wp_parse_args( $args, $defaults ); 760 760 extract( $r, EXTR_SKIP ); 761 761 762 return apply_filters( 'bp_activity_get_specific', BP_Activity_Activity::get( $max, $page, $per_page, $sort, false, false, $display_comments, $show_hidden, false, $activity_ids, $ hide_spam ) );762 return apply_filters( 'bp_activity_get_specific', BP_Activity_Activity::get( $max, $page, $per_page, $sort, false, false, $display_comments, $show_hidden, false, $activity_ids, $spam ) ); 763 763 } 764 764 … … 1327 1327 } 1328 1328 1329 /** 1330 * Convenience function to control whether the current user is allowed to mark activity items as spam 1331 * 1332 * @global object $bp BuddyPress global settings 1333 * @return bool True if user is allowed to mark activity items as spam 1334 * @since 1.6 1335 * @static 1336 */ 1337 function bp_activity_user_can_mark_spam() { 1338 global $bp; 1339 return apply_filters( 'bp_activity_user_can_mark_spam', $bp->loggedin_user->is_site_admin ); 1340 } 1341 1342 /** 1343 * Mark activity item as spam 1344 * 1345 * @global object $bp BuddyPress global settings 1346 * @param BP_Activity_Activity $activity 1347 * @param string $source Optional; default is "by_a_person" (e.g. a person has manually marked the activity as spam). 1348 * @since 1.6 1349 */ 1350 function bp_activity_mark_as_spam( &$activity, $source = 'by_a_person' ) { 1351 global $bp; 1352 1353 $activity->is_spam = 1; 1354 1355 // Clear the activity stream first page cache 1356 wp_cache_delete( 'bp_activity_sitewide_front', 'bp' ); 1357 1358 // Clear the activity comment cache for this activity item 1359 wp_cache_delete( 'bp_activity_comments_' . $activity->id, 'bp' ); 1360 1361 // If Akismet is active, and this was a manual spam/ham request, stop Akismet checking the activity 1362 if ( 'by_a_person' == $source && !empty( $bp->activity->akismet ) ) { 1363 remove_action( 'bp_activity_before_save', array( $bp->activity->akismet, 'check_activity' ), 1, 1 ); 1364 1365 // Build data package for Akismet 1366 $activity_data = BP_Akismet::build_akismet_data_package( $activity ); 1367 1368 // Tell Akismet this is spam 1369 $activity_data = $bp->activity->akismet->send_akismet_request( $activity_data, 'submit', 'spam' ); 1370 1371 // Update meta 1372 add_action( 'bp_activity_after_save', array( $bp->activity->akismet, 'update_activity_spam_meta' ), 1, 1 ); 1373 } 1374 1375 do_action( 'bp_activity_mark_as_spam', $activity, $source ); 1376 } 1377 1378 /** 1379 * Mark activity item as ham 1380 * 1381 * @global object $bp BuddyPress global settings 1382 * @param BP_Activity_Activity $activity 1383 * @param string $source Optional; default is "by_a_person" (e.g. a person has manually marked the activity as spam). 1384 * @since 1.6 1385 */ 1386 function bp_activity_mark_as_ham( &$activity, $source = 'by_a_person' ) { 1387 global $bp; 1388 1389 $activity->is_spam = 0; 1390 1391 // Clear the activity stream first page cache 1392 wp_cache_delete( 'bp_activity_sitewide_front', 'bp' ); 1393 1394 // Clear the activity comment cache for this activity item 1395 wp_cache_delete( 'bp_activity_comments_' . $activity->id, 'bp' ); 1396 1397 // If Akismet is active, and this was a manual spam/ham request, stop Akismet checking the activity 1398 if ( 'by_a_person' == $source && !empty( $bp->activity->akismet ) ) { 1399 remove_action( 'bp_activity_before_save', array( $bp->activity->akismet, 'check_activity' ), 1, 1 ); 1400 1401 // Build data package for Akismet 1402 $activity_data = BP_Akismet::build_akismet_data_package( $activity ); 1403 1404 // Tell Akismet this is spam 1405 $activity_data = $bp->activity->akismet->send_akismet_request( $activity_data, 'submit', 'ham' ); 1406 1407 // Update meta 1408 add_action( 'bp_activity_after_save', array( $bp->activity->akismet, 'update_activity_ham_meta' ), 1, 1 ); 1409 } 1410 1411 //DJPAULTODO: Run bp_activity_at_name_filter() somehow... but not twice, if we can help it. Maybe check if it was auto-spammed by Akismet? 1412 do_action( 'bp_activity_mark_as_ham', $activity, $source ); 1413 } 1414 1415 1329 1416 /** Embeds *******************************************************************/ 1330 1417
Note: See TracChangeset
for help on using the changeset viewer.