• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP bp_activity_mark_as_spam函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中bp_activity_mark_as_spam函数的典型用法代码示例。如果您正苦于以下问题:PHP bp_activity_mark_as_spam函数的具体用法?PHP bp_activity_mark_as_spam怎么用?PHP bp_activity_mark_as_spam使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了bp_activity_mark_as_spam函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: wangguard_bp_activity_spam_all_user_data

function wangguard_bp_activity_spam_all_user_data($user_id = 0)
{
    global $bp, $wpdb;
    // Do not delete user data unless a logged in user says so
    if (empty($user_id)) {
        return false;
    }
    // Get all the user's activities.
    $activities = bp_activity_get(array('display_comments' => 'stream', 'filter' => array('user_id' => $user_id), 'show_hidden' => true));
    // Mark each as spam
    foreach ((array) $activities['activities'] as $activity) {
        // Create an activity object
        $activity_obj = new BP_Activity_Activity();
        foreach ($activity as $k => $v) {
            $activity_obj->{$k} = $v;
        }
        // Mark as spam
        bp_activity_mark_as_spam($activity_obj);
        /*
         * If Akismet is present, update the activity history meta.
         *
         * This is usually taken care of when BP_Activity_Activity::save() happens, but
         * as we're going to be updating all the activity statuses directly, for efficency,
         * we need to update manually.
         */
        if (!empty($bp->activity->akismet)) {
            $bp->activity->akismet->update_activity_spam_meta($activity_obj);
        }
        // Tidy up
        unset($activity_obj);
    }
    // Mark all of this user's activities as spam
    $wpdb->query($wpdb->prepare("UPDATE {$bp->activity->table_name} SET is_spam = 1 WHERE user_id = %d", $user_id));
    // Call an action for plugins to use
    do_action('bp_activity_spam_all_user_data', $user_id, $activities['activities']);
}
开发者ID:kd5ytx,项目名称:Empirical-Wordpress,代码行数:36,代码来源:wangguard-buddypress.php


示例2: bp_activity_admin_load


//.........这里部分代码省略.........
            //	continue;
            // Get the activity from the database
            $activity = new BP_Activity_Activity($activity_id);
            if (empty($activity->component)) {
                $errors[] = $activity_id;
                continue;
            }
            switch ($doaction) {
                case 'delete':
                    if ('activity_comment' == $activity->type) {
                        bp_activity_delete_comment($activity->item_id, $activity->id);
                    } else {
                        bp_activity_delete(array('id' => $activity->id));
                    }
                    $deleted++;
                    break;
                case 'ham':
                    /**
                     * Remove moderation and blacklist checks in case we want to ham an activity
                     * which contains one of these listed keys.
                     */
                    remove_action('bp_activity_before_save', 'bp_activity_check_moderation_keys', 2, 1);
                    remove_action('bp_activity_before_save', 'bp_activity_check_blacklist_keys', 2, 1);
                    bp_activity_mark_as_ham($activity);
                    $result = $activity->save();
                    // Check for any error during activity save
                    if (!$result) {
                        $errors[] = $activity->id;
                    } else {
                        $unspammed++;
                    }
                    break;
                case 'spam':
                    bp_activity_mark_as_spam($activity);
                    $result = $activity->save();
                    // Check for any error during activity save
                    if (!$result) {
                        $errors[] = $activity->id;
                    } else {
                        $spammed++;
                    }
                    break;
                default:
                    break;
            }
            // Release memory
            unset($activity);
        }
        /**
         * Fires before redirect for plugins to do something with activity.
         *
         * Passes an activity array counts how many were spam, not spam, deleted, and IDs that were errors.
         *
         * @since BuddyPress (1.6.0)
         *
         * @param array  $value        Array holding spam, not spam, deleted counts, error IDs.
         * @param string $redirect_to  URL to redirect to.
         * @param array  $activity_ids Original array of activity IDs.
         */
        do_action('bp_activity_admin_action_after', array($spammed, $unspammed, $deleted, $errors), $redirect_to, $activity_ids);
        // Add arguments to the redirect URL so that on page reload, we can easily display what we've just done.
        if ($spammed) {
            $redirect_to = add_query_arg('spammed', $spammed, $redirect_to);
        }
        if ($unspammed) {
            $redirect_to = add_query_arg('unspammed', $unspammed, $redirect_to);
开发者ID:un1coin,项目名称:ovn-space,代码行数:67,代码来源:bp-activity-admin.php


示例3: bp_legacy_theme_spam_activity

/**
 * AJAX spam an activity item or comment
 *
 * @return mixed String on error, void on success
 * @since BuddyPress (1.6)
 */
function bp_legacy_theme_spam_activity()
{
    $bp = buddypress();
    // Bail if not a POST action
    if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
        return;
    }
    // Check that user is logged in, Activity Streams are enabled, and Akismet is present.
    if (!is_user_logged_in() || !bp_is_active('activity') || empty($bp->activity->akismet)) {
        exit('-1');
    }
    // Check an item ID was passed
    if (empty($_POST['id']) || !is_numeric($_POST['id'])) {
        exit('-1');
    }
    // Is the current user allowed to spam items?
    if (!bp_activity_user_can_mark_spam()) {
        exit('-1');
    }
    // Load up the activity item
    $activity = new BP_Activity_Activity((int) $_POST['id']);
    if (empty($activity->component)) {
        exit('-1');
    }
    // Check nonce
    check_admin_referer('bp_activity_akismet_spam_' . $activity->id);
    /** This action is documented in bp-activity/bp-activity-actions.php */
    do_action('bp_activity_before_action_spam_activity', $activity->id, $activity);
    // Mark as spam
    bp_activity_mark_as_spam($activity);
    $activity->save();
    /** This action is documented in bp-activity/bp-activity-actions.php */
    do_action('bp_activity_action_spam_activity', $activity->id, $activity->user_id);
    exit;
}
开发者ID:kosir,项目名称:thatcamp-org,代码行数:41,代码来源:buddypress-functions.php


示例4: bp_dtheme_spam_activity

/**
 * AJAX spam an activity item or comment
 *
 * @global BuddyPress $bp The one true BuddyPress instance
 * @return mixed String on error, void on success
 * @since BuddyPress (1.6)
 */
function bp_dtheme_spam_activity()
{
    global $bp;
    // Bail if not a POST action
    if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
        return;
    }
    // Check that user is logged in, Activity Streams are enabled, and Akismet is present.
    if (!is_user_logged_in() || !bp_is_active('activity') || empty($bp->activity->akismet)) {
        exit('-1');
    }
    // Check an item ID was passed
    if (empty($_POST['id']) || !is_numeric($_POST['id'])) {
        exit('-1');
    }
    // Is the current user allowed to spam items?
    if (!bp_activity_user_can_mark_spam()) {
        exit('-1');
    }
    // Load up the activity item
    $activity = new BP_Activity_Activity((int) $_POST['id']);
    if (empty($activity->component)) {
        exit('-1');
    }
    // Check nonce
    check_admin_referer('bp_activity_akismet_spam_' . $activity->id);
    // Call an action before the spamming so plugins can modify things if they want to
    do_action('bp_activity_before_action_spam_activity', $activity->id, $activity);
    // Mark as spam
    bp_activity_mark_as_spam($activity);
    $activity->save();
    do_action('bp_activity_action_spam_activity', $activity->id, $activity->user_id);
    exit;
}
开发者ID:raminjan,项目名称:logicalbones_hug,代码行数:41,代码来源:ajax.php


示例5: bp_blogs_transition_activity_status

/**
 * When a blog comment status transition occurs, update the relevant activity's status.
 *
 * @global object $bp BuddyPress global settings
 * @param string $new_status New comment status.
 * @param string $old_status Previous comment status.
 * @param object $comment Comment data.
 * @since 1.6
 */
function bp_blogs_transition_activity_status($new_status, $old_status, $comment)
{
    global $bp;
    // Check the Activity component is active
    if (!bp_is_active('activity')) {
        return;
    }
    /**
     * Activity currently doesn't have any concept of a trash, or an unapproved/approved state.
     *
     * If a blog comment transitions to a "delete" or "hold" status, delete the activity item.
     * If a blog comment transitions to trashed, or spammed, mark the activity as spam.
     * If a blog comment transitions to approved (and the activity exists), mark the activity as ham.
     * Otherwise, record the comment into the activity stream.
     */
    // This clause was moved in from bp_blogs_remove_comment() in BuddyPress 1.6. It handles delete/hold.
    if (in_array($new_status, array('delete', 'hold'))) {
        return bp_blogs_remove_comment($comment->comment_ID);
    } elseif (in_array($new_status, array('trash', 'spam'))) {
        $action = 'spam_activity';
    } elseif ('approved' == $new_status) {
        $action = 'ham_activity';
    }
    // Get the activity
    $activity_id = bp_activity_get_activity_id(array('component' => $bp->blogs->id, 'item_id' => get_current_blog_id(), 'secondary_item_id' => $comment->comment_ID, 'type' => 'new_blog_comment'));
    // Check activity item exists
    if (!$activity_id) {
        // If no activity exists, but the comment has been approved, record it into the activity table.
        if ('approved' == $new_status) {
            return bp_blogs_record_comment($comment->comment_ID, true);
        }
        return;
    }
    // Create an activity object
    $activity = new BP_Activity_Activity($activity_id);
    if (empty($activity->component)) {
        return;
    }
    // Spam/ham the activity if it's not already in that state
    if ('spam_activity' == $action && !$activity->is_spam) {
        bp_activity_mark_as_spam($activity);
    } elseif ('ham_activity' == $action) {
        bp_activity_mark_as_ham($activity);
    }
    // Add "new_blog_comment" to the whitelisted activity types, so that the activity's Akismet history is generated
    $comment_akismet_history = create_function('$t', '$t[] = "new_blog_comment"; return $t;');
    add_filter('bp_akismet_get_activity_types', $comment_akismet_history);
    // Save the updated activity
    $activity->save();
    // Remove the "new_blog_comment" activity type whitelist so we don't break anything
    remove_filter('bp_akismet_get_activity_types', $comment_akismet_history);
}
开发者ID:vsalx,项目名称:rattieinfo,代码行数:61,代码来源:bp-blogs-functions.php


示例6: bp_activity_check_blacklist_keys

/**
 * Mark the posted activity as spam, if it contains blacklist keywords.
 *
 * @since 1.6.0
 *
 * @param BP_Activity_Activity $activity The activity object to check.
 */
function bp_activity_check_blacklist_keys($activity)
{
    // Only check specific types of activity updates.
    if (!in_array($activity->type, bp_activity_get_moderated_activity_types())) {
        return;
    }
    // Mark as spam.
    if (!bp_core_check_for_blacklist($activity->user_id, '', $activity->content)) {
        bp_activity_mark_as_spam($activity, 'by_blacklist');
    }
}
开发者ID:mawilliamson,项目名称:wordpress,代码行数:18,代码来源:bp-activity-filters.php


示例7: check_activity

 /**
  * Check if the activity item is spam or ham
  *
  * @param BP_Activity_Activity $activity The activity item to check
  * @see http://akismet.com/development/api/
  * @since BuddyPress (1.6)
  * @todo Spam counter?
  * @todo Auto-delete old spam?
  */
 public function check_activity($activity)
 {
     // By default, only handle activity updates and activity comments.
     if (!in_array($activity->type, BP_Akismet::get_activity_types())) {
         return;
     }
     // Make sure last_activity is clear to avoid any confusion
     $this->last_activity = null;
     // Build data package for Akismet
     $activity_data = BP_Akismet::build_akismet_data_package($activity);
     // Check with Akismet to see if this is spam
     $activity_data = $this->send_akismet_request($activity_data, 'check', 'spam');
     // Record this item
     $this->last_activity = $activity;
     // Store a copy of the data that was submitted to Akismet
     $this->last_activity->akismet_submission = $activity_data;
     // Spam
     if ('true' == $activity_data['bp_as_result']) {
         // Action for plugin authors
         do_action_ref_array('bp_activity_akismet_spam_caught', array(&$activity, $activity_data));
         // Mark as spam
         bp_activity_mark_as_spam($activity, 'by_akismet');
     }
     // Update activity meta after a spam check
     add_action('bp_activity_after_save', array($this, 'update_activity_akismet_meta'), 1, 1);
 }
开发者ID:pyropictures,项目名称:wordpress-plugins,代码行数:35,代码来源:bp-activity-akismet.php


示例8: check_activity

 /**
  * Check if the activity item is spam or ham.
  *
  * @since 1.6.0
  *
  * @see http://akismet.com/development/api/
  * @todo Spam counter?
  * @todo Auto-delete old spam?
  *
  * @param BP_Activity_Activity $activity The activity item to check.
  */
 public function check_activity($activity)
 {
     // By default, only handle activity updates and activity comments.
     if (!in_array($activity->type, BP_Akismet::get_activity_types())) {
         return;
     }
     // Make sure last_activity is clear to avoid any confusion.
     $this->last_activity = null;
     // Build data package for Akismet.
     $activity_data = BP_Akismet::build_akismet_data_package($activity);
     // Check with Akismet to see if this is spam.
     $activity_data = $this->send_akismet_request($activity_data, 'check', 'spam');
     // Record this item.
     $this->last_activity = $activity;
     // Store a copy of the data that was submitted to Akismet.
     $this->last_activity->akismet_submission = $activity_data;
     // Spam.
     if ('true' == $activity_data['bp_as_result']) {
         /**
          * Fires after an activity item has been proven to be spam, but before officially being marked as spam.
          *
          * @since 1.6.0
          *
          * @param BP_Activity_Activity $activity      The activity item proven to be spam.
          * @param array                $activity_data Array of activity data for item including
          *                                            Akismet check results data.
          */
         do_action_ref_array('bp_activity_akismet_spam_caught', array(&$activity, $activity_data));
         // Mark as spam.
         bp_activity_mark_as_spam($activity, 'by_akismet');
     }
     // Update activity meta after a spam check.
     add_action('bp_activity_after_save', array($this, 'update_activity_akismet_meta'), 1, 1);
 }
开发者ID:JeroenNouws,项目名称:BuddyPress,代码行数:45,代码来源:bp-activity-akismet.php


示例9: bp_activity_action_spam_activity

/**
 * Mark specific activity item as spam and redirect to previous page.
 *
 * @since 1.6.0
 *
 * @param int $activity_id Activity id to be deleted. Defaults to 0.
 * @return bool False on failure.
 */
function bp_activity_action_spam_activity($activity_id = 0)
{
    $bp = buddypress();
    // Not viewing activity, or action is not spam, or Akismet isn't present.
    if (!bp_is_activity_component() || !bp_is_current_action('spam') || empty($bp->activity->akismet)) {
        return false;
    }
    if (empty($activity_id) && bp_action_variable(0)) {
        $activity_id = (int) bp_action_variable(0);
    }
    // Not viewing a specific activity item.
    if (empty($activity_id)) {
        return false;
    }
    // Is the current user allowed to spam items?
    if (!bp_activity_user_can_mark_spam()) {
        return false;
    }
    // Load up the activity item.
    $activity = new BP_Activity_Activity($activity_id);
    if (empty($activity->id)) {
        return false;
    }
    // Check nonce.
    check_admin_referer('bp_activity_akismet_spam_' . $activity->id);
    /**
     * Fires before the marking activity as spam so plugins can modify things if they want to.
     *
     * @since 1.6.0
     *
     * @param int    $activity_id Activity ID to be marked as spam.
     * @param object $activity    Activity object for the ID to be marked as spam.
     */
    do_action('bp_activity_before_action_spam_activity', $activity->id, $activity);
    // Mark as spam.
    bp_activity_mark_as_spam($activity);
    $activity->save();
    // Tell the user the spamming has been successful.
    bp_core_add_message(__('The activity item has been marked as spam and is no longer visible.', 'buddypress'));
    /**
     * Fires after the marking activity as spam so plugins can act afterwards based on the activity.
     *
     * @since 1.6.0
     *
     * @param int $activity_id Activity ID that was marked as spam.
     * @param int $user_id     User ID associated with activity.
     */
    do_action('bp_activity_action_spam_activity', $activity_id, $activity->user_id);
    // Check for the redirect query arg, otherwise let WP handle things.
    if (!empty($_GET['redirect_to'])) {
        bp_core_redirect(esc_url($_GET['redirect_to']));
    } else {
        bp_core_redirect(wp_get_referer());
    }
}
开发者ID:swissspidy,项目名称:BuddyPress,代码行数:63,代码来源:bp-activity-actions.php


示例10: bp_activity_action_spam_activity

/**
 * Mark specific activity item as spam and redirect to previous page.
 *
 * @since BuddyPress (1.6)
 *
 * @global object $bp BuddyPress global settings
 * @param int $activity_id Activity id to be deleted. Defaults to 0.
 * @return bool False on failure.
 */
function bp_activity_action_spam_activity($activity_id = 0)
{
    global $bp;
    // Not viewing activity, or action is not spam, or Akismet isn't present
    if (!bp_is_activity_component() || !bp_is_current_action('spam') || empty($bp->activity->akismet)) {
        return false;
    }
    if (empty($activity_id) && bp_action_variable(0)) {
        $activity_id = (int) bp_action_variable(0);
    }
    // Not viewing a specific activity item
    if (empty($activity_id)) {
        return false;
    }
    // Is the current user allowed to spam items?
    if (!bp_activity_user_can_mark_spam()) {
        return false;
    }
    // Load up the activity item
    $activity = new BP_Activity_Activity($activity_id);
    if (empty($activity->id)) {
        return false;
    }
    // Check nonce
    check_admin_referer('bp_activity_akismet_spam_' . $activity->id);
    // Call an action before the spamming so plugins can modify things if they want to
    do_action('bp_activity_before_action_spam_activity', $activity->id, $activity);
    // Mark as spam
    bp_activity_mark_as_spam($activity);
    $activity->save();
    // Tell the user the spamming has been succesful
    bp_core_add_message(__('The activity item has been marked as spam and is no longer visible.', 'buddypress'));
    do_action('bp_activity_action_spam_activity', $activity_id, $activity->user_id);
    // Check for the redirect query arg, otherwise let WP handle things
    if (!empty($_GET['redirect_to'])) {
        bp_core_redirect(esc_url($_GET['redirect_to']));
    } else {
        bp_core_redirect(wp_get_referer());
    }
}
开发者ID:eresyyl,项目名称:mk,代码行数:49,代码来源:bp-activity-actions.php


示例11: bp_activity_spam_all_user_data

/**
 * Mark all of the user's activity as spam.
 *
 * @since 1.6.0
 *
 * @global object $wpdb WordPress database access object.
 *
 * @param int $user_id ID of the user whose activity is being spammed.
 * @return bool
 */
function bp_activity_spam_all_user_data($user_id = 0)
{
    global $wpdb;
    // Do not delete user data unless a logged in user says so.
    if (empty($user_id) || !is_user_logged_in()) {
        return false;
    }
    // Get all the user's activities.
    $activities = bp_activity_get(array('display_comments' => 'stream', 'filter' => array('user_id' => $user_id), 'show_hidden' => true));
    $bp = buddypress();
    // Mark each as spam.
    foreach ((array) $activities['activities'] as $activity) {
        // Create an activity object.
        $activity_obj = new BP_Activity_Activity();
        foreach ($activity as $k => $v) {
            $activity_obj->{$k} = $v;
        }
        // Mark as spam.
        bp_activity_mark_as_spam($activity_obj);
        /*
         * If Akismet is present, update the activity history meta.
         *
         * This is usually taken care of when BP_Activity_Activity::save() happens, but
         * as we're going to be updating all the activity statuses directly, for efficiency,
         * we need to update manually.
         */
        if (!empty($bp->activity->akismet)) {
            $bp->activity->akismet->update_activity_spam_meta($activity_obj);
        }
        // Tidy up.
        unset($activity_obj);
    }
    // Mark all of this user's activities as spam.
    $wpdb->query($wpdb->prepare("UPDATE {$bp->activity->table_name} SET is_spam = 1 WHERE user_id = %d", $user_id));
    /**
     * Fires after all activity data from a user has been marked as spam.
     *
     * @since 1.6.0
     *
     * @param int   $user_id    ID of the user whose activity is being marked as spam.
     * @param array $activities Array of activity items being marked as spam.
     */
    do_action('bp_activity_spam_all_user_data', $user_id, $activities['activities']);
}
开发者ID:humanmade,项目名称:BuddyPress,代码行数:54,代码来源:bp-activity-functions.php


示例12: bp_activity_transition_post_type_comment_status

/**
 * When a post type comment status transition occurs, update the relevant activity's status.
 *
 * @since 2.5.0
 *
 * @param string     $new_status New comment status.
 * @param string     $old_status Previous comment status.
 * @param WP_Comment $comment Comment data.
 */
function bp_activity_transition_post_type_comment_status($new_status, $old_status, $comment)
{
    $post_type = get_post_type($comment->comment_post_ID);
    if (!$post_type) {
        return;
    }
    // Get the post type tracking args.
    $activity_post_object = bp_activity_get_post_type_tracking_args($post_type);
    // Bail if the activity type does not exist
    if (empty($activity_post_object->comments_tracking->action_id)) {
        return false;
        // Set the $activity_comment_object
    } else {
        $activity_comment_object = $activity_post_object->comments_tracking;
    }
    // Init an empty activity ID
    $activity_id = 0;
    /**
     * Activity currently doesn't have any concept of a trash, or an unapproved/approved state.
     *
     * If a blog comment transitions to a "delete" or "hold" status, delete the activity item.
     * If a blog comment transitions to trashed, or spammed, mark the activity as spam.
     * If a blog comment transitions to approved (and the activity exists), mark the activity as ham.
     * If a blog comment transitions to unapproved (and the activity exists), mark the activity as spam.
     * Otherwise, record the comment into the activity stream.
     */
    // This clause handles delete/hold.
    if (in_array($new_status, array('delete', 'hold'))) {
        return bp_activity_post_type_remove_comment($comment->comment_ID, $activity_post_object);
        // These clauses handle trash, spam, and un-spams.
    } elseif (in_array($new_status, array('trash', 'spam', 'unapproved'))) {
        $action = 'spam_activity';
    } elseif ('approved' == $new_status) {
        $action = 'ham_activity';
    }
    // Get the activity
    if (bp_disable_blogforum_comments()) {
        $activity_id = bp_activity_get_activity_id(array('component' => $activity_comment_object->component_id, 'item_id' => get_current_blog_id(), 'secondary_item_id' => $comment->comment_ID, 'type' => $activity_comment_object->action_id));
    } else {
        $activity_id = get_comment_meta($comment->comment_ID, 'bp_activity_comment_id', true);
    }
    /**
     * Leave a chance to plugins to manage activity comments differently.
     *
     * @since  2.5.0
     *
     * @param bool        $value       True to override BuddyPress management.
     * @param string      $post_type   The post type name.
     * @param int         $activity_id The post type activity (0 if not found).
     * @param string      $new_status  The new status of the post type comment.
     * @param string      $old_status  The old status of the post type comment.
     * @param WP_Comment  $comment Comment data.
     */
    if (true === apply_filters('bp_activity_pre_transition_post_type_comment_status', false, $post_type, $activity_id, $new_status, $old_status, $comment)) {
        return false;
    }
    // Check activity item exists
    if (empty($activity_id)) {
        // If no activity exists, but the comment has been approved, record it into the activity table.
        if ('approved' == $new_status) {
            return bp_activity_post_type_comment($comment->comment_ID, true, $activity_post_object);
        }
        return;
    }
    // Create an activity object
    $activity = new BP_Activity_Activity($activity_id);
    if (empty($activity->component)) {
        return;
    }
    // Spam/ham the activity if it's not already in that state
    if ('spam_activity' === $action && !$activity->is_spam) {
        bp_activity_mark_as_spam($activity);
    } elseif ('ham_activity' == $action) {
        bp_activity_mark_as_ham($activity);
    }
    // Add "new_post_type_comment" to the whitelisted activity types, so that the activity's Akismet history is generated
    $post_type_comment_action = $activity_comment_object->action_id;
    $comment_akismet_history = create_function('$t', '$t[] = $post_type_comment_action; return $t;');
    add_filter('bp_akismet_get_activity_types', $comment_akismet_history);
    // Make sure the activity change won't edit the comment if sync is on
    remove_action('bp_activity_before_save', 'bp_blogs_sync_activity_edit_to_post_comment', 20);
    // Save the updated activity
    $activity->save();
    // Restore the action
    add_action('bp_activity_before_save', 'bp_blogs_sync_activity_edit_to_post_comment', 20);
    // Remove the "new_blog_comment" activity type whitelist so we don't break anything
    remove_filter('bp_akismet_get_activity_types', $comment_akismet_history);
}
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:97,代码来源:bp-activity-actions.php


示例13: bp_activity_admin_load

/**
 * Set up the admin page before any output is sent. Register contextual help and screen options for this admin page.
 *
 * @global BP_Activity_List_Table $bp_activity_list_table Activity screen list table
 * @since 1.6
 */
function bp_activity_admin_load()
{
    global $bp_activity_list_table;
    // per_page screen option
    add_screen_option('per_page', array('label' => _x('Activities', 'Activity items per page (screen options)', 'buddypress')));
    // Help panel - text
    add_contextual_help(get_current_screen(), '<p>' . __('You can manage activities made on your site similar to the way you manage comments and other content. This screen is customizable in the same ways as other management screens, and you can act on activities using the on-hover action links or the Bulk Actions.', 'buddypress') . '</p>' . '<p>' . __('There are many different types of activities. Some are generated by BuddyPress automatically, and others are entered directly by a user in the form of status update. To help manage the different activity types, use the filter dropdown box to switch between them.', 'buddypress') . '</p>' . '<p>' . __('In the Activity column, above each activity it says &#8220;Submitted on,&#8221; followed by the date and time the activity item was generated on your site. Clicking on the date/time link will take you to that activity on your live site. Hovering over any activity gives you options to reply, edit, spam mark, or delete that activity.', 'buddypress') . '</p>' . '<p>' . __('In the In Response To column, the text is the name of the user who generated the activity, and a link to the activity on your live site. The small bubble with the number in it shows how many other activities are related to this one; these are usually comments. Clicking the bubble will filter the activity screen to show only related activity items.', 'buddypress') . '</p>');
    // Help panel - sidebar links
    get_current_screen()->set_help_sidebar('<p><strong>' . __('For more information:', 'buddypress') . '</strong></p>' . '<p>' . __('<a href="http://buddypress.org/support/">Support Forums</a>', 'buddypress') . '</p>');
    // Create the Activity screen list table
    $bp_activity_list_table = new BP_Activity_List_Table();
    // Handle spam/un-spam/delete of activities
    $doaction = $bp_activity_list_table->current_action();
    if ($doaction && 'edit' != $doaction) {
        // Build redirection URL
        $redirect_to = remove_query_arg(array('aid', 'deleted', 'spammed', 'unspammed'), wp_get_referer());
        $redirect_to = add_query_arg('paged', $bp_activity_list_table->get_pagenum(), $redirect_to);
        // Get activity IDs
        $activity_ids = array_map('absint', (array) $_REQUEST['aid']);
        // Is this a bulk request?
        if ('bulk_' == substr($doaction, 0, 5) && !empty($_REQUEST['aid'])) {
            // Check this is a valid form submission
            check_admin_referer('bulk-activities');
            // Trim 'bulk_' off the action name to avoid duplicating a ton of code
            $doaction = substr($doaction, 5);
            // This is a request to delete, spam, or un-spam, a single item.
        } elseif (!empty($_REQUEST['aid'])) {
            // Check this is a valid form submission
            check_admin_referer('spam-activity_' . $activity_ids[0]);
        }
        // Initialise counters for how many of each type of item we perform an action on
        $deleted = $spammed = $unspammed = 0;
        // "We'd like to shoot the monster, could you move, please?"
        foreach ($activity_ids as $activity_id) {
            // @todo: Check the permissions on each
            //if ( ! current_user_can( 'bp_edit_activity', $activity_id ) )
            //	continue;
            // Get the activity from the database
            $activity = new BP_Activity_Activity($activity_id);
            if (empty($activity->component)) {
                continue;
            }
            switch ($doaction) {
                case 'delete':
                    if ('activity_comment' == $activity->type) {
                        bp_activity_delete_comment($activity->item_id, $activity->id);
                    } else {
                        bp_activity_delete(array('id' => $activity->id));
                    }
                    $deleted++;
                    break;
                case 'ham':
                    bp_activity_mark_as_ham($activity);
                    $activity->save();
                    break;
                case 'spam':
                    bp_activity_mark_as_spam($activity);
                    $activity->save();
                    $spammed++;
                    break;
                default:
                    break;
            }
            // Release memory
            unset($activity);
        }
        // Add arguments to the redirect URL so that on page reload, we can easily display what we've just done.
        if ($spammed) {
            $redirect_to = add_query_arg('spammed', $spammed, $redirect_to);
        }
        if ($unspammed) {
            $redirect_to = add_query_arg('unspammed', $unspammed, $redirect_to);
        }
        if ($deleted) {
            $redirect_to = add_query_arg('deleted', $deleted, $redirect_to);
        }
        // Redirect
        wp_redirect($redirect_to);
        exit;
        // If a referrer and a nonce is supplied, but no action, redirect back.
    } elseif (!empty($_GET['_wp_http_referer'])) {
        wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI'])));
        exit;
    }
}
开发者ID:newington,项目名称:buddypress,代码行数:91,代码来源:bp-activity-admin.php


示例14: test_bp_blogs_sync_activity_edit_to_post_comment_spam_activity_comment_unspam_post_comment

 /**
  * @group bp_blogs_sync_activity_edit_to_post_comment
  * @group post_type_comment_activities
  */
 public function test_bp_blogs_sync_activity_edit_to_post_comment_spam_activity_comment_unspam_post_comment()
 {
     $old_user = get_current_user_id();
     $u = $this->factory->user->create();
     $this->set_current_user($u);
     $userdata = get_userdata($u);
     // let's use activity comments instead of single "new_blog_comment" activity items
     add_filter('bp_disable_blogforum_comments', '__return_false');
     // create the blog post
     $post_id = $this->factory->post->create(array('post_status' => 'publish', 'post_type' => 'post', 'post_title' => 'Test activity comment to post comment'));
     // grab the activity ID for the activity comment
     $a1 = bp_activity_get_activity_id(array('type' => 'new_blog_post', 'component' => buddypress()->blogs->id, 'filter' => array('item_id' => get_current_blog_id(), 'secondary_item_id' => $post_id)));
     $a2 = bp_activity_new_comment(array('content' => 'the generated comment should be spamed/unspamed once the activity comment is spamed/unspamed', 'user_id' => $u, 'activity_id' => $a1));
     $c = bp_activity_get_meta($a2, 'bp_blogs_post_comment_id');
     $activity = new BP_Activity_Activity($a2);
     bp_activity_mark_as_spam($activity);
     $activity->save();
     wp_unspam_comment($c);
     $post_comments = get_comments(array('post_id' => $post_id, 'status' => 'approve'));
     $comment = reset($post_comments);
     $this->assertTrue((int) $comment->comment_ID === (int) bp_activity_get_meta($a2, 'bp_blogs_post_comment_id'), 'The comment ID should be in the activity meta');
     $this->assertTrue((int) $a2 === (int) get_comment_meta($comment->comment_ID, 'bp_activity_comment_id', true), 'The activity ID should be in the comment meta');
     // reset
     remove_filter('bp_disable_blogforum_comments', '__return_false');
     $this->set_current_user($old_user);
 }
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:30,代码来源:activity.php



注:本文中的bp_activity_mark_as_spam函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP bp_activity_new_comment函数代码示例发布时间:2022-05-24
下一篇:
PHP bp_activity_mark_as_ham函数代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap