Skip to:
Content

BuddyPress.org

Changeset 5262


Ignore:
Timestamp:
11/01/2011 11:21:59 PM (15 years ago)
Author:
djpaul
Message:

Second pass of Akismet support for the Activity component. See #3660

Location:
trunk
Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-activity/bp-activity-actions.php

    r5259 r5262  
    195195
    196196        // Is the current user allowed to spam items?
    197         if ( !BP_Akismet::user_can_mark_spam() )
     197        if ( !bp_activity_user_can_mark_spam() )
    198198                return false;
    199199
     
    210210
    211211        // Mark as spam
    212         $bp->activity->akismet->mark_as_spam( $activity );
     212        bp_activity_mark_as_spam( $activity );
    213213        $activity->save();
    214214
  • trunk/bp-activity/bp-activity-akismet.php

    r5259 r5262  
    4747                add_action( 'bp_activity_before_save',     array( $this, 'check_activity' ), 1, 1 );
    4848
    49                 // Update activity meta after a spam check
    50                 add_action( 'bp_activity_after_save',      array( $this, 'update_activity_meta' ), 1, 1 );
    51 
    5249                // Tidy up member's latest (activity) update
    5350                add_action( 'bp_activity_posted_update',   array( $this, 'check_member_activity_update' ), 1, 3 );
     51
     52                // Hooks to extend Activity core spam/ham functions for Akismet
     53                add_action( 'bp_activity_mark_as_spam',    array( $this, 'mark_as_spam' ), 10, 2 );
     54                add_action( 'bp_activity_mark_as_ham',     array( $this, 'mark_as_ham' ),  10, 2 );
     55
     56                // Hook into the Activity wp-admin screen
     57                //add_action( 'bp_activity_admin_comment_row_actions', array( $this, 'add_activity_status_row' ), 10, 2 );
    5458        }
    5559
     
    9094                        return;
    9195
    92                 // Was this $activity_id just marked as spam?
    93                 if ( !$this->last_activity->id || $activity_id != $this->last_activity->id )
     96                // Was this $activity_id just marked as spam? If not, bail out.
     97                if ( !$this->last_activity->id || $activity_id != $this->last_activity->id || 'false' == $this->last_activity->akismet_submission['bp_as_result'] )
    9498                        return;
    9599
     
    103107         * This function is intended to be used inside the activity stream loop.
    104108         *
    105          * @since 1.2
     109         * @since 1.6
    106110         */
    107111        public function add_activity_spam_button() {
    108                 if ( !BP_Akismet::user_can_mark_spam() )
     112                if ( !bp_activity_user_can_mark_spam() )
    109113                        return;
    110114
     
    131135         * This function is intended to be used inside the activity stream loop.
    132136         *
    133          * @since 1.2
     137         * @since 1.6
    134138         */
    135139        public function add_activity_comment_spam_button() {
    136                 if ( !BP_Akismet::user_can_mark_spam() )
     140                if ( !bp_activity_user_can_mark_spam() )
    137141                        return;
    138142
     
    156160
    157161        /**
    158          * Convenience function to control whether the current user is allowed to mark activity items as spam
    159          *
    160          * @global object $bp BuddyPress global settings
    161          * @return bool True if user is allowed to mark activity items as spam
    162          * @since 1.6
    163          * @static
    164          */
    165         public static function user_can_mark_spam() {
    166                 global $bp;
    167                 return apply_filters( 'bp_activity_akismet_user_can_mark_spam', $bp->loggedin_user->is_site_admin );
    168         }
    169 
    170         /**
    171162         * Get a list of filterable types of activity item that we want Akismet to automatically check for spam.
    172163         *
     
    183174         *
    184175         * @param BP_Activity_Activity $activity
    185          * @since 1.6
    186          */
    187         public function mark_as_spam( &$activity ) {
    188                 $activity->is_spam = 1;
    189 
     176         * @param string $source Either "by_a_person" (e.g. a person has manually marked the activity as spam) or "by_akismet" (automatically spammed).
     177         * @since 1.6
     178         */
     179        public function mark_as_spam( $activity, $source ) {
    190180                // Record this item so we can do some tidyup in BP_Akismet::check_member_activity_update()
    191181                $this->last_activity = $activity;
    192182
    193                 // Clear the activity stream first page cache
    194                 wp_cache_delete( 'bp_activity_sitewide_front', 'bp' );
    195 
    196                 // Clear the activity comment cache for this activity item
    197                 wp_cache_delete( 'bp_activity_comments_' . $activity->id, 'bp' );
    198 
    199                 do_action( 'bp_activity_akismet_mark_as_spam', $activity );
     183                do_action( 'bp_activity_akismet_mark_as_spam', $activity, $source );
    200184        }
    201185
     
    204188         *
    205189         * @param BP_Activity_Activity $activity
    206          * @since 1.6
    207          */
    208         public function mark_as_ham( &$activity ) {
    209                 $activity->is_spam = 0;
    210 
    211                 // Clear the activity stream first page cache
    212                 wp_cache_delete( 'bp_activity_sitewide_front', 'bp' );
    213 
    214                 // Clear the activity comment cache for this activity item
    215                 wp_cache_delete( 'bp_activity_comments_' . $activity->id, 'bp' );
    216 
    217                 //bp_activity_delete_meta( $activity->id, 'bpla_spam' );
    218                 do_action( 'bp_activity_akismet_mark_as_ham', $activity );
    219 
     190         * @param string $source Either "by_a_person" (e.g. a person has manually marked the activity as spam) or "by_akismet" (automatically spammed).
     191         * @since 1.6
     192         */
     193        public function mark_as_ham( $activity, $source ) {
    220194                //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?
     195
     196                do_action( 'bp_activity_akismet_mark_as_ham', $activity, $source );
    221197        }
    222198
    223199        /**
    224          * Check if the activity item is spam or ham
    225          *
    226          * @param BP_Activity_Activity $activity The activity item to check
    227          * @see http://akismet.com/development/api/
    228          * @since 1.6
    229          * @todo Spam counter?
    230          * @todo Auto-delete old spam?
    231          */
    232         public function check_activity( $activity ) {
    233                 // By default, only handle activity updates and activity comments.
    234                 if ( !in_array( $activity->type, BP_Akismet::get_activity_types() ) )
    235                         return;
    236 
    237                 $this->last_activity = null;
    238                 $userdata            = get_userdata( $activity->user_id );
    239 
    240                 // Build up a data package for the Akismet service to inspect
     200         * Build a data package for the Akismet service to inspect
     201         *
     202         * @param BP_Activity_Activity $activity
     203         * @see http://akismet.com/development/api/#comment-check
     204         * @since 1.6
     205         * @static
     206         */
     207        public static function build_akismet_data_package( $activity ) {
     208                $userdata = get_userdata( $activity->user_id );
     209
    241210                $activity_data                          = array();
    242211                $activity_data['akismet_comment_nonce'] = 'inactive';
     
    264233                        $activity_data['akismet_comment_nonce'] = wp_verify_nonce( $_POST["_bp_as_nonce_{$activity->secondary_item_id}"], "_bp_as_nonce_{$userdata->ID}_{$activity->secondary_item_id}" ) ? 'passed' : 'failed';
    265234
     235                return apply_filters( 'bp_akismet_build_akismet_data_package', $activity_data, $activity );
     236        }
     237
     238        /**
     239         * Check if the activity item is spam or ham
     240         *
     241         * @param BP_Activity_Activity $activity The activity item to check
     242         * @see http://akismet.com/development/api/
     243         * @since 1.6
     244         * @todo Spam counter?
     245         * @todo Auto-delete old spam?
     246         */
     247        public function check_activity( $activity ) {
     248                // By default, only handle activity updates and activity comments.
     249                if ( !in_array( $activity->type, BP_Akismet::get_activity_types() ) )
     250                        return;
     251
     252                // Make sure last_activity is clear to avoid any confusion
     253                $this->last_activity = null;
     254
     255                // Build data package for Akismet
     256                $activity_data = BP_Akismet::build_akismet_data_package( $activity );
     257
    266258                // Check with Akismet to see if this is spam
    267                 $activity_data = $this->maybe_spam( $activity_data );
     259                $activity_data = $this->send_akismet_request( $activity_data, 'check', 'spam' );
    268260
    269261                // Record this item
     
    279271
    280272                        // Mark as spam
    281                         $this->mark_as_spam( $activity );
     273                        bp_activity_mark_as_spam( $activity, 'by_akismet' );
    282274                }
    283         }
    284 
    285         /**
    286          * Update activity meta after a spam check
    287          *
     275
     276                // Update activity meta after a spam check
     277                add_action( 'bp_activity_after_save', array( $this, 'update_activity_akismet_meta' ), 1, 1 );
     278        }
     279
     280        /**
     281         * Update activity meta after a manual spam change (user initiated)
     282         *
     283         * @global object $bp BuddyPress global settings
    288284         * @param BP_Activity_Activity $activity The activity to check
    289285         * @since 1.6
    290286         */
    291         public function update_activity_meta( $activity ) {
     287        public function update_activity_spam_meta( $activity ) {
     288                global $bp;
     289
     290                // By default, only handle activity updates and activity comments.
     291                if ( !in_array( $activity->type, BP_Akismet::get_activity_types() ) )
     292                        return;
     293
     294                $this->update_activity_history( $activity->id, sprintf( __( '%s reported this activity as spam', 'buddypress' ), $bp->loggedin_user->fullname ), 'report-spam' );
     295                bp_activity_update_meta( $activity->id, '_bp_akismet_user_result', 'true' );
     296                bp_activity_update_meta( $activity->id, '_bp_akismet_user', $bp->loggedin_user->fullname );
     297        }
     298
     299        /**
     300         * Update activity meta after a manual ham change (user initiated)
     301         *
     302         * @global object $bp BuddyPress global settings
     303         * @param BP_Activity_Activity $activity The activity to check
     304         * @since 1.6
     305         */
     306        public function update_activity_ham_meta( $activity ) {
     307                global $bp;
     308
     309                // By default, only handle activity updates and activity comments.
     310                if ( !in_array( $activity->type, BP_Akismet::get_activity_types() ) )
     311                        return;
     312
     313                $this->update_activity_history( $activity->id, sprintf( __( '%s reported this activity as not spam', 'buddypress' ), $bp->loggedin_user->fullname ), 'report-ham' );
     314                bp_activity_update_meta( $activity->id, '_bp_akismet_user_result', 'false' );
     315                bp_activity_update_meta( $activity->id, '_bp_akismet_user', $bp->loggedin_user->fullname );
     316        }
     317
     318        /**
     319         * Update activity meta after an automatic spam check (not user initiated)
     320         *
     321         * @param BP_Activity_Activity $activity The activity to check
     322         * @since 1.6
     323         */
     324        public function update_activity_akismet_meta( $activity ) {
    292325                // Check we're dealing with what was last updated by Akismet
    293326                if ( empty( $this->last_activity ) || !empty( $this->last_activity ) && $activity->id != $this->last_activity->id )
     
    330363         * @since 1.6
    331364         */
    332         protected function maybe_spam( $activity_data, $check = 'check', $spam = 'spam' ) {
     365        public function send_akismet_request( $activity_data, $check = 'check', $spam = 'spam' ) {
    333366                global $akismet_api_host, $akismet_api_port;
    334367
     
    481514         * @since 1.6
    482515         */
    483         private function update_activity_history( $activity_id = 0, $message = '', $event = '' ) {
     516        public function update_activity_history( $activity_id = 0, $message = '', $event = '' ) {
    484517                $event = array(
    485518                        'event'   => $event,
  • trunk/bp-activity/bp-activity-classes.php

    r5259 r5262  
    9999
    100100        // Static Functions
    101         function get( $max = false, $page = 1, $per_page = 25, $sort = 'DESC', $search_terms = false, $filter = false, $display_comments = false, $show_hidden = false, $exclude = false, $in = false, $hide_spam = true ) {
     101        function get( $max = false, $page = 1, $per_page = 25, $sort = 'DESC', $search_terms = false, $filter = false, $display_comments = false, $show_hidden = false, $exclude = false, $in = false, $spam = 'ham_only' ) {
    102102                global $wpdb, $bp;
    103103
     
    111111
    112112                // Spam
    113                 if ( $hide_spam )
     113                if ( 'ham_only' == $spam )
    114114                        $where_conditions['spam_sql'] = 'a.is_spam = 0';
     115                elseif ( 'spam_only' == $spam )
     116                        $where_conditions['spam_sql'] = 'a.is_spam = 1';
    115117
    116118                // Searching
     
    191193
    192194                if ( $activities && $display_comments )
    193                         $activities = BP_Activity_Activity::append_comments( $activities, $hide_spam );
     195                        $activities = BP_Activity_Activity::append_comments( $activities, $spam );
    194196
    195197                // If $max is set, only return up to the max results
     
    362364         * @global wpdb $wpdb WordPress database object
    363365         * @param array $activities
    364          * @param bool $hide_spam Optional. Defaults to true (don't retrieve spammed items).
     366         * @param bool $spam Optional; 'ham_only' (default), 'spam_only' or 'all'.
    365367         * @return array The updated activities with nested comments
    366368         * @since 1.2
    367369         */
    368         function append_comments( $activities, $hide_spam = true ) {
     370        function append_comments( $activities, $spam = 'ham_only' ) {
    369371                global $bp, $wpdb;
    370372
     
    374376                foreach( (array)$activities as $activity ) {
    375377                        if ( 'activity_comment' != $activity->type && $activity->mptt_left && $activity->mptt_right )
    376                                 $activity_comments[$activity->id] = BP_Activity_Activity::get_activity_comments( $activity->id, $activity->mptt_left, $activity->mptt_right, $hide_spam );
     378                                $activity_comments[$activity->id] = BP_Activity_Activity::get_activity_comments( $activity->id, $activity->mptt_left, $activity->mptt_right, $spam );
    377379                }
    378380
     
    393395         * @param int $left Left-most node boundary
    394396         * @param into $right Right-most node boundary
    395          * @param bool $hide_spam Optional. Defaults to true (don't retrieve spammed items).
     397         * @param bool $spam Optional; 'ham_only' (default), 'spam_only' or 'all'.
    396398         * @return array The updated activities with nested comments
    397399         * @since 1.2
    398400         */
    399         function get_activity_comments( $activity_id, $left, $right, $hide_spam = true ) {
     401        function get_activity_comments( $activity_id, $left, $right, $spam = 'ham_only' ) {
    400402                global $wpdb, $bp;
    401403
     
    413415
    414416                        // Don't retrieve activity comments marked as spam
    415                         if ( $hide_spam )
     417                        if ( 'ham_only' == $spam )
    416418                                $spam_sql = 'AND a.is_spam = 0';
     419                        elseif ( 'spam_only' == $spam )
     420                                $spam_sql = 'AND a.is_spam = 1';
    417421                        else
    418422                                $spam_sql = '';
    419423
    420                         $sql = apply_filters( 'bp_activity_comments_user_join_filter', $wpdb->prepare( "SELECT a.*, u.user_email, u.user_nicename, u.user_login, u.display_name{$fullname_select} FROM {$bp->activity->table_name} a, {$wpdb->users} u{$fullname_from} WHERE u.ID = a.user_id {$fullname_where} AND a.type = 'activity_comment' ${spam_sql} AND a.item_id = %d AND a.mptt_left BETWEEN %d AND %d ORDER BY a.date_recorded ASC", $activity_id, $left, $right ), $activity_id, $left, $right, $hide_spam );
     424                        $sql = apply_filters( 'bp_activity_comments_user_join_filter', $wpdb->prepare( "SELECT a.*, u.user_email, u.user_nicename, u.user_login, u.display_name{$fullname_select} FROM {$bp->activity->table_name} a, {$wpdb->users} u{$fullname_from} WHERE u.ID = a.user_id {$fullname_where} AND a.type = 'activity_comment' ${spam_sql} AND a.item_id = %d AND a.mptt_left BETWEEN %d AND %d ORDER BY a.date_recorded ASC", $activity_id, $left, $right ), $activity_id, $left, $right, $spam_sql );
    421425
    422426                        // Retrieve all descendants of the $root node
  • trunk/bp-activity/bp-activity-functions.php

    r5259 r5262  
    692692function bp_activity_get( $args = '' ) {
    693693        $defaults = array(
    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                 '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'.
    705705
    706706                /**
     
    720720
    721721        // 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 ) {
    723723                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 );
    725725                        wp_cache_set( 'bp_activity_sitewide_front', $activity, 'bp' );
    726726                }
    727727
    728728        } 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 );
    730730        }
    731731
     
    748748function bp_activity_get_specific( $args = '' ) {
    749749        $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 items
    752                 'hide_spam'        => false,  // Retrieve items marked as spam
    753                 'max'              => false,  // Maximum number of results to return
    754                 'page'             => 1,      // page 1 without a per_page will result in no pagination.
    755                 'per_page'         => false,  // results per page
    756                 'show_hidden'      => true,   // When fetching specific items, show all
    757                 'sort'             => 'DESC', // sort ASC or DESC
     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 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
    758758        );
    759759        $r = wp_parse_args( $args, $defaults );
    760760        extract( $r, EXTR_SKIP );
    761761
    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 ) );
    763763}
    764764
     
    13271327}
    13281328
     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 */
     1337function 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 */
     1350function 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 */
     1386function 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
    13291416/** Embeds *******************************************************************/
    13301417
  • trunk/bp-activity/bp-activity-loader.php

    r5259 r5262  
    5454                if ( defined( 'AKISMET_VERSION' ) && ( !empty( $akismet_key ) || defined( 'WPCOM_API_KEY' ) ) )
    5555                        $includes[] = 'akismet';
     56
     57                if ( is_admin() )
     58                        $includes[] = 'admin';
    5659
    5760                parent::includes( $includes );
  • trunk/bp-activity/bp-activity-template.php

    r5259 r5262  
    105105        var $full_name;
    106106
    107         function __construct( $page, $per_page, $max, $include, $sort, $filter, $search_terms, $display_comments, $show_hidden, $exclude = false, $in = false, $hide_spam = true ) {
     107        function __construct( $page, $per_page, $max, $include, $sort, $filter, $search_terms, $display_comments, $show_hidden, $exclude = false, $in = false, $spam = 'ham_only' ) {
    108108                global $bp;
    109109
     
    119119                // Fetch specific activity items based on ID's
    120120                if ( !empty( $include ) )
    121                         $this->activities = bp_activity_get_specific( array( 'activity_ids' => explode( ',', $include ), 'max' => $max, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'sort' => $sort, 'display_comments' => $display_comments, 'show_hidden' => $show_hidden, 'hide_spam' => $hide_spam ) );
     121                        $this->activities = bp_activity_get_specific( array( 'activity_ids' => explode( ',', $include ), 'max' => $max, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'sort' => $sort, 'display_comments' => $display_comments, 'show_hidden' => $show_hidden, 'spam' => $spam ) );
    122122
    123123                // Fetch all activity items
    124124                else
    125                         $this->activities = bp_activity_get( array( 'display_comments' => $display_comments, 'max' => $max, 'per_page' => $this->pag_num, 'page' => $this->pag_page, 'sort' => $sort, 'search_terms' => $search_terms, 'filter' => $filter, 'show_hidden' => $show_hidden, 'exclude' => $exclude, 'in' => $in, 'hide_spam' => $hide_spam ) );
     125                        $this->activities = bp_activity_get( array( 'display_comments' => $display_comments, 'max' => $max, 'per_page' => $this->pag_num, 'page' => $this->pag_page, 'sort' => $sort, 'search_terms' => $search_terms, 'filter' => $filter, 'show_hidden' => $show_hidden, 'exclude' => $exclude, 'in' => $in, 'spam' => $spam ) );
    126126
    127127                if ( !$max || $max >= (int)$this->activities['total'] )
     
    299299                'max'              => false,        // max number to return
    300300                'show_hidden'      => $show_hidden, // Show activity items that are hidden site-wide?
    301                 'hide_spam'        => true,         // Don't retrieve items marked as spam?
     301                'spam'             => 'ham_only',   // Hide spammed items
    302302
    303303                // Scope - pre-built activity filters for a user (friends/groups/favorites/mentions)
     
    384384
    385385        // If specific activity items have been requested, override the $hide_spam argument. This prevents backpat errors with AJAX.
    386         if ( !empty( $include ) && $hide_spam )
    387                 $hide_spam = false;
    388 
    389         $activities_template = new BP_Activity_Template( $page, $per_page, $max, $include, $sort, $filter, $search_terms, $display_comments, $show_hidden, $exclude, $in, $hide_spam );
     386        if ( !empty( $include ) && 'ham_only' == $spam )
     387                $spam = 'all';
     388
     389        $activities_template = new BP_Activity_Template( $page, $per_page, $max, $include, $sort, $filter, $search_terms, $display_comments, $show_hidden, $exclude, $in, $spam );
    390390
    391391        return apply_filters( 'bp_has_activities', $activities_template->has_activities(), $activities_template );
  • trunk/bp-core/bp-core-cssjs.php

    r4961 r5262  
    2727                ul#adminmenu li.toplevel_page_bp-general-settings:hover .wp-menu-image a,
    2828                ul#adminmenu li.toplevel_page_bp-general-settings.wp-has-current-submenu .wp-menu-image a {
     29                        background-position: -1px 0;
     30                }
     31
     32                /* Activity Icon */
     33                ul#adminmenu li.toplevel_page_bp-activity-settings .wp-menu-image a img { display: none; }
     34                ul#adminmenu li.toplevel_page_bp-activity-settings .wp-menu-image a { background-image: url( <?php echo plugins_url( 'buddypress/bp-core/images/admin_menu_icon.png' ) ?> ) !important; background-position: -1px -32px; }
     35                ul#adminmenu li.toplevel_page_bp-activity-settings:hover .wp-menu-image a,
     36                ul#adminmenu li.toplevel_page_bp-activity-settings.wp-has-current-submenu .wp-menu-image a {
    2937                        background-position: -1px 0;
    3038                }
  • trunk/bp-themes/bp-default/_inc/ajax.php

    r5259 r5262  
    340340
    341341        // Is the current user allowed to spam items?
    342         if ( !BP_Akismet::user_can_mark_spam() )
     342        if ( !bp_activity_user_can_mark_spam() )
    343343                return false;
    344344
     
    357357
    358358        // Mark as spam
    359         $bp->activity->akismet->mark_as_spam( $activity );
     359        bp_activity_mark_as_spam( $activity );
    360360        $activity->save();
    361361
Note: See TracChangeset for help on using the changeset viewer.