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

PHP bp_activity_delete函数代码示例

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

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



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

示例1: buddyreshare_ajax_delete_reshare

/**
 * Catches an activity to delete if js is enabled
 *
 * @package BP Reshare
 * @since    1.0
 *
 * @uses  check_ajax_referer() for security reasons
 * @uses  bp_activity_get_specific() to fetch the activity to delete
 * @uses  buddyreshare_reset_metas() to reset some metas for the parent activity
 * @uses  bp_activity_delete() to delete the reshare
 */
function buddyreshare_ajax_delete_reshare()
{
    // Bail if not a POST action
    if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
        return;
    }
    check_ajax_referer('buddyreshare_delete', 'nonce');
    $response = array('result' => 'error', 'message' => __('OOps, error while trying to delete your reshare..', 'bp-reshare'));
    $reshare_id = intval($_POST['activity']);
    if (empty($reshare_id)) {
        $response['message'] = __('The reshare was not found.', 'bp-reshare');
        exit(json_encode($response));
    }
    $reshare_to_delete = bp_activity_get_specific(array('activity_ids' => $reshare_id));
    if (empty($reshare_to_delete)) {
        $response['message'] = __('The reshare was not found.', 'bp-reshare');
        exit(json_encode($response));
    }
    $reshare = $reshare_to_delete['activities'][0];
    $reset = buddyreshare_reset_metas($reshare->secondary_item_id, $reshare->user_id);
    if (empty($reset)) {
        $response['message'] = __('Unable to reset the properties of the reshared activity', 'bp-reshare');
        exit(json_encode($response));
    }
    $deleted_reshare = bp_activity_delete(array('type' => 'reshare_update', 'id' => $reshare_id));
    if (!empty($deleted_reshare)) {
        do_action('buddyreshare_reshare_deleted', $reshare_id);
        $response['result'] = 'success';
        $response['message'] = __('Reshare successfully deleted.', 'bp-reshare');
    } else {
        do_action('buddyreshare_reshare_deleted_error', $reshare_id);
    }
    exit(json_encode($response));
}
开发者ID:socialray,项目名称:surfied-2-0,代码行数:45,代码来源:ajax.php


示例2: bp_wire_delete_activity

function bp_wire_delete_activity($args = true)
{
    if (function_exists('bp_activity_delete')) {
        extract($args);
        bp_activity_delete($item_id, $component_name, $component_action, $user_id, $secondary_item_id);
    }
}
开发者ID:alvaropereyra,项目名称:shrekcms,代码行数:7,代码来源:bp-wire.php


示例3: bp_groupblogs_deactivate

/**
 * On deactivation, clear the cron and delete all group RSS activity.
 */
function bp_groupblogs_deactivate()
{
    wp_clear_scheduled_hook('bp_groupblogs_cron');
    /* Remove all external blog activity */
    if (function_exists('bp_activity_delete')) {
        bp_activity_delete(array('type' => 'exb'));
    }
}
开发者ID:rpi-virtuell,项目名称:external-group-blogs,代码行数:11,代码来源:loader.php


示例4: delete_pic_cover_group

function delete_pic_cover_group($activity_id)
{
    global $bp;
    $group_id = $bp->groups->current_group->id;
    $activity_id = $_POST['activity_id'];
    $attachment_id = bp_activity_get_meta($activity_id, 'all_bp_cover_group', true);
    wp_delete_attachment($attachment_id, true);
    groups_delete_groupmeta($group_id, 'bp_cover_group');
    groups_delete_groupmeta($group_id, 'bp_cover_group_position');
    bp_activity_delete(array('id' => $activity_id, 'item_id' => $group_id));
    BP_Activity_Activity::delete_activity_meta_entries($activity_id);
}
开发者ID:aghajoon,项目名称:bp-cover,代码行数:12,代码来源:bp-cover-group.php


示例5: bp_reshare_ajax_delete_reshare

function bp_reshare_ajax_delete_reshare()
{
    check_ajax_referer('_reshare_delete', 'nonce');
    $reshare_id = intval($_POST['activity']);
    $reshare_to_delete = bp_activity_get_specific('activity_ids=' . $reshare_id);
    $reshare = $reshare_to_delete['activities'][0];
    bp_reshare_delete($reshare->secondary_item_id, $reshare->user_id);
    $deleted_reshare = bp_activity_delete(array('type' => 'reshare_update', 'id' => $reshare_id));
    if ($deleted_reshare) {
        echo '1';
    } else {
        _e('OOps, error while trying to delete your reshare..', 'bp-reshare');
    }
    die;
}
开发者ID:KristianI,项目名称:bp-reshare,代码行数:15,代码来源:bp-reshare-ajax.php


示例6: bp_reshare_delete_reshare

/**
* let's delete reshare update if js is disabled
*/
function bp_reshare_delete_reshare()
{
    if (!empty($_GET['delete_reshare']) && is_numeric($_GET['delete_reshare'])) {
        check_admin_referer('_reshare_delete');
        $redirect = remove_query_arg(array('delete_reshare', '_wpnonce'), wp_get_referer());
        $reshare_id = intval($_GET['delete_reshare']);
        $reshare_to_delete = bp_activity_get_specific('activity_ids=' . $reshare_id);
        $reshare = $reshare_to_delete['activities'][0];
        bp_reshare_delete($reshare->secondary_item_id, $reshare->user_id);
        $deleted_reshare = bp_activity_delete(array('type' => 'reshare_update', 'id' => $reshare_id));
        if (!empty($deleted_reshare)) {
            do_action('bp_reshare_handle_nojs_deleted', $reshare_id);
            bp_core_add_message(__('Reshare deleted !', 'bp-reshare'));
            bp_core_redirect($redirect);
        } else {
            do_action('bp_reshare_handle_nojs_missed', $reshare_id);
            bp_core_add_message(__('OOps, error while trying to reshare..', 'bp-reshare'), 'error');
            bp_core_redirect($redirect);
        }
    }
}
开发者ID:KristianI,项目名称:bp-reshare,代码行数:24,代码来源:bp-reshare-actions.php


示例7: bp_cleanup_friendship_activities

/**
 * Remove all hidden friendship activities.
 *
 * @since 2.2.0
 *
 * @uses bp_activity_delete() to delete the corresponding friendship activities.
 */
function bp_cleanup_friendship_activities()
{
    bp_activity_delete(array('component' => buddypress()->friends->id, 'type' => 'friendship_created', 'hide_sitewide' => true));
}
开发者ID:mawilliamson,项目名称:wordpress,代码行数:11,代码来源:bp-core-update.php


示例8: bp_blogs_remove_comment

/**
 * Remove a blog comment activity item from the activity stream.
 *
 * @param int $comment_id ID of the comment to be removed.
 */
function bp_blogs_remove_comment($comment_id)
{
    global $wpdb;
    // activity comments are disabled for blog posts
    // which means that individual activity items exist for blog comments
    if (bp_disable_blogforum_comments()) {
        // Delete the individual activity stream item
        bp_blogs_delete_activity(array('item_id' => $wpdb->blogid, 'secondary_item_id' => $comment_id, 'type' => 'new_blog_comment'));
        // activity comments are enabled for blog posts
        // remove the associated activity item
    } else {
        // get associated activity ID from comment meta
        $activity_id = get_comment_meta($comment_id, 'bp_activity_comment_id', true);
        // delete the associated activity comment
        //
        // also removes child post comments and associated activity comments
        if (!empty($activity_id) && bp_is_active('activity')) {
            // fetch the activity comments for the activity item
            $activity = bp_activity_get(array('in' => $activity_id, 'display_comments' => 'stream'));
            // get all activity comment IDs for the pending deleted item
            if (!empty($activity['activities'])) {
                $activity_ids = bp_activity_recurse_comments_activity_ids($activity);
                $activity_ids[] = $activity_id;
                // delete activity items
                foreach ($activity_ids as $activity_id) {
                    bp_activity_delete(array('id' => $activity_id));
                }
                // remove associated blog comments
                bp_blogs_remove_associated_blog_comments($activity_ids);
                // rebuild activity comment tree
                BP_Activity_Activity::rebuild_activity_comment_tree($activity['activities'][0]->item_id);
            }
        }
    }
    /**
     * Fires after a blog comment activity item was removed from activity stream.
     *
     * @since BuddyPress (1.0.0)
     *
     * @param int $blogid     Item ID for the blog associated with the removed comment.
     * @param int $comment_id ID of the comment being removed.
     * @param int $value      ID of the current logged in user.
     */
    do_action('bp_blogs_remove_comment', $wpdb->blogid, $comment_id, bp_loggedin_user_id());
}
开发者ID:sdh100shaun,项目名称:pantheon,代码行数:50,代码来源:bp-blogs-functions.php


示例9: bp_activity_delete_children

/**
 * Delete an activity comment's children.
 *
 * @since BuddyPress (1.2.0)
 *
 * @uses BP_Activity_Activity::get_child_comments() {@link BP_Activity_Activity}
 * @uses bp_activity_delete_children()
 * @uses bp_activity_delete()
 *
 * @param int $activity_id The ID of the "root" activity, ie the
 *        comment's oldest ancestor.
 * @param int $comment_id The ID of the comment to be deleted.
 */
function bp_activity_delete_children($activity_id, $comment_id)
{
    // Get activity children to delete
    $children = BP_Activity_Activity::get_child_comments($comment_id);
    // Recursively delete all children of this comment.
    if (!empty($children)) {
        foreach ((array) $children as $child) {
            bp_activity_delete_children($activity_id, $child->id);
        }
    }
    // Delete the comment itself
    bp_activity_delete(array('secondary_item_id' => $comment_id, 'type' => 'activity_comment', 'item_id' => $activity_id));
}
开发者ID:eresyyl,项目名称:mk,代码行数:26,代码来源:bp-activity-functions.php


示例10: rtmedia_api_process_remove_comment_request

 /**
  * Delete comment by activity id or media id
  */
 function rtmedia_api_process_remove_comment_request()
 {
     global $wpdb;
     $this->rtmediajsonapifunction->rtmedia_api_verfiy_token();
     $this->rtmediajsonapifunction->rtmedia_api_media_activity_id_missing();
     //Errors Deleting comment
     $ec_comment_not_found = 800007;
     $msg_comment_not_found = __('invalid comment/media id', 'rtmedia');
     $ec_no_comment_id = 800008;
     $msg_no_comment_id = __('no comment id', 'rtmedia');
     $ec_comment_deleted = 800009;
     $msg_comment_deleted = __('comment deleted', 'rtmedia');
     extract($_POST);
     if (empty($comment_id)) {
         echo $this->rtmedia_api_response_object('FALSE', $ec_no_comment_id, $msg_no_comment_id);
         exit;
     }
     $id = rtmedia_media_id($media_id);
     $sql = "SELECT * FROM {$wpdb->comments} WHERE comment_ID = " . $comment_id . " AND comment_post_ID = " . $id . " AND user_id = " . $this->user_id;
     $comments = $wpdb->get_results($sql, ARRAY_A);
     //Delete Comment
     if (!empty($comments)) {
         $comment = new RTMediaComment();
         $activity_id = get_comment_meta($comment_id, 'activity_id', true);
         if (!empty($activity_id)) {
             $activity_deleted = bp_activity_delete_comment($activity_id, $comment_id);
             $delete = bp_activity_delete(array('id' => $activity_id, 'type' => 'activity_comment'));
         }
         $comment_deleted = $comment->rtmedia_comment_model->delete($comment_id);
         if ($comment_deleted) {
             echo $this->rtmedia_api_response_object('TRUE', $ec_comment_deleted, $msg_comment_deleted);
             exit;
         } else {
             echo $this->rtmedia_api_response_object('FALSE', $this->ec_server_error, $this->msg_server_error);
             exit;
         }
     } else {
         echo $this->rtmedia_api_response_object('FALSE', $ec_comment_not_found, $msg_comment_not_found);
         exit;
     }
 }
开发者ID:paulmedwal,项目名称:edxforumspublic,代码行数:44,代码来源:RTMediaJsonApi.php


示例11: bebop_manage_oers

function bebop_manage_oers()
{
    if (bp_is_current_component('bebop') && bp_is_current_action('bebop-manager')) {
        if (isset($_POST['action'])) {
            global $wpdb;
            global $bp;
            $oer_count = 0;
            $success = false;
            //Add OER's to the activity stream.
            if ($_POST['action'] == 'verify') {
                foreach (array_keys($_POST) as $oer) {
                    if ($oer != 'action') {
                        $data = bebop_tables::fetch_individual_oer_data($oer);
                        //go and fetch data from the activity buffer table.
                        if (!empty($data->id)) {
                            $should_users_verify_content = bebop_tables::get_option_value('bebop_' . $data->type . '_content_user_verification');
                            if ($should_users_verify_content != 'no') {
                                global $wpdb;
                                if (!bp_has_activities('action=bebop_oer_plugin&item_id=' . $data->id)) {
                                    $new_activity_item = array('user_id' => $data->user_id, 'component' => 'bebop_oer_plugin', 'type' => $data->type, 'action' => $data->action, 'content' => $data->content, 'item_id' => $data->id, 'date_recorded' => $data->date_recorded, 'hide_sitewide' => $data->hide_sitewide);
                                    if (bp_activity_add($new_activity_item)) {
                                        bebop_tables::update_oer_data($data->id, 'status', 'verified');
                                        bebop_tables::update_oer_data($data->id, 'activity_stream_id', $wpdb->insert_id);
                                        $oer_count++;
                                    } else {
                                        bebop_tables::log_error(__('Activity Stream', 'bebop'), __('Could not update the content status.', 'bebop'));
                                    }
                                } else {
                                    bebop_tables::log_error(__('Activity Stream', 'bebop'), __('This content already exists in the activity stream.', 'bebop'));
                                }
                            }
                            //End if ( $should_users_verify_content != 'no' ) {
                        }
                    }
                }
                //End foreach ( array_keys($_POST) as $oer ) {
                if ($oer_count > 1) {
                    $success = true;
                    $message = __('Resources verified.', 'bebop');
                } else {
                    $success = true;
                    $message = __('Resource verified.', 'bebop');
                }
            } else {
                if ($_POST['action'] == 'delete') {
                    foreach (array_keys($_POST) as $oer) {
                        if ($oer != 'action') {
                            $data = bebop_tables::fetch_individual_oer_data($oer);
                            //go and fetch data from the activity buffer table.
                            if (!empty($data->id)) {
                                //delete the activity, let the filter update the tables.
                                if (!empty($data->activity_stream_id)) {
                                    $should_users_verify_content = bebop_tables::get_option_value('bebop_' . $data->type . '_content_user_verification');
                                    if ($should_users_verify_content != 'no') {
                                        bp_activity_delete(array('id' => $data->activity_stream_id));
                                    }
                                }
                                bebop_tables::update_oer_data($data->id, 'status', 'deleted');
                                $oer_count++;
                            }
                        }
                    }
                    //End foreach ( array_keys( $_POST ) as $oer ) {
                    if ($oer_count > 1) {
                        $success = true;
                        $message = __('Resources deleted.', 'bebop');
                    } else {
                        $success = true;
                        $message = __('Resource deleted.', 'bebop');
                    }
                } else {
                    if ($_POST['action'] == 'undelete') {
                        foreach (array_keys($_POST) as $oer) {
                            $exclude_array = array('action', 'submit');
                            if (!in_array($oer, $exclude_array)) {
                                $data = bebop_tables::fetch_individual_oer_data($oer);
                                //go and fetch data from the activity buffer table.
                                $should_users_verify_content = bebop_tables::get_option_value('bebop_' . $data->type . '_content_user_verification');
                                if ($should_users_verify_content != 'no') {
                                    bebop_tables::update_oer_data($data->id, 'status', 'unverified');
                                    $oer_count++;
                                }
                            }
                        }
                        if ($oer_count > 1) {
                            $success = true;
                            $message = __('Resources undeleted.', 'bebop');
                        } else {
                            $success = true;
                            $message = __('Resource undeleted.', 'bebop');
                        }
                    }
                }
            }
            if ($success) {
                bp_core_add_message($message);
            } else {
                bp_core_add_message(__('We couldnt do that for you. Please try again.', 'bebop'), __('error', 'bebop'));
            }
            bp_core_redirect($bp->loggedin_user->domain . bp_current_component() . '/' . bp_current_action());
//.........这里部分代码省略.........
开发者ID:adisonc,项目名称:MaineLearning,代码行数:101,代码来源:bebop-core.php


示例12: bp_activity_admin_load


//.........这里部分代码省略.........
         *
         * @param array $activity_ids Activity IDs to spam/un-spam/delete.
         */
        $activity_ids = apply_filters('bp_activity_admin_action_activity_ids', $activity_ids);
        // 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;
        // Store any errors that occurs when updating the database items
        $errors = array();
        // "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)) {
                $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:
开发者ID:un1coin,项目名称:ovn-space,代码行数:67,代码来源:bp-activity-admin.php


示例13: test_bp_activity_at_mention_delete_notification

 /**
  * @group bp_notifications_delete_all_notifications_by_type
  * @group bp_activity_at_mention_delete_notification
  */
 public function test_bp_activity_at_mention_delete_notification()
 {
     $this->create_notifications();
     $notifications = BP_Notifications_Notification::get(array('item_id' => $this->a1));
     // Double check it's there
     $this->assertEquals(array($this->a1), wp_list_pluck($notifications, 'item_id'));
     bp_activity_delete(array('id' => $this->a1));
     $notifications = BP_Notifications_Notification::get(array('item_id' => $this->a1));
     $this->assertEmpty($notifications);
 }
开发者ID:JeroenNouws,项目名称:BuddyPress,代码行数:14,代码来源:notifications.php


示例14: bp_friends_delete_activity_on_user_delete

/**
 * Deletes friendship activity items when a user is deleted.
 *
 * @since 2.5.0
 *
 * @param int $user_id The ID of the user being deleted.
 */
function bp_friends_delete_activity_on_user_delete($user_id = 0)
{
    if (!bp_is_active('activity')) {
        return;
    }
    bp_activity_delete(array('component' => buddypress()->friends->id, 'type' => 'friendship_created', 'secondary_item_id' => $user_id));
}
开发者ID:igniterealtime,项目名称:community-plugins,代码行数:14,代码来源:bp-friends-activity.php


示例15: bp_legacy_theme_delete_activity

/**
 * Deletes an Activity item received via a POST request.
 *
 * @return mixed String on error, void on success
 * @since BuddyPress (1.2)
 */
function bp_legacy_theme_delete_activity()
{
    // Bail if not a POST action
    if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
        return;
    }
    // Check the nonce
    check_admin_referer('bp_activity_delete_link');
    if (!is_user_logged_in()) {
        exit('-1');
    }
    if (empty($_POST['id']) || !is_numeric($_POST['id'])) {
        exit('-1');
    }
    $activity = new BP_Activity_Activity((int) $_POST['id']);
    // Check access
    if (!bp_activity_user_can_delete($activity)) {
        exit('-1');
    }
    /** This action is documented in bp-activity/bp-activity-actions.php */
    do_action('bp_activity_before_action_delete_activity', $activity->id, $activity->user_id);
    if (!bp_activity_delete(array('id' => $activity->id, 'user_id' => $activity->user_id))) {
        exit('-1<div id="message" class="error bp-ajax-message"><p>' . __('There was a problem when deleting. Please try again.', 'buddypress') . '</p></div>');
    }
    /** This action is documented in bp-activity/bp-activity-actions.php */
    do_action('bp_activity_action_delete_activity', $activity->id, $activity->user_id);
    exit;
}
开发者ID:kosir,项目名称:thatcamp-org,代码行数:34,代码来源:buddypress-functions.php


示例16: groups_delete_group_forum_post

/**
 * Delete a group forum post and its corresponding activity item.
 *
 * Uses the bundled version of bbPress packaged with BuddyPress.
 *
 * @since BuddyPress (1.1.0)
 *
 * @param int $post_id The ID of the post you want to delete.
 * @param int $topic_id Optional. The topic to which the post belongs. This
 *        value isn't used in the function but is passed along to do_action()
 *        hooks.
 * @return bool True on success.
 */
function groups_delete_group_forum_post($post_id, $topic_id = false)
{
    $action = bp_forums_delete_post(array('post_id' => $post_id));
    if (!empty($action)) {
        do_action('groups_before_delete_group_forum_post', $post_id, $topic_id);
        // Delete the corresponding activity stream item
        if (bp_is_active('activity')) {
            bp_activity_delete(array('item_id' => bp_get_current_group_id(), 'secondary_item_id' => $post_id, 'component' => buddypress()->groups->id, 'type' => 'new_forum_post'));
        }
        do_action('groups_delete_group_forum_post', $post_id, $topic_id);
    }
    return (bool) $action;
}
开发者ID:sdh100shaun,项目名称:pantheon,代码行数:26,代码来源:bp-groups-forums.php


示例17: bp_activity_action_delete_activity

/**
 * Delete specific activity item and redirect to previous page.
 *
 * @since 1.1.0
 *
 * @uses bp_is_activity_component()
 * @uses bp_is_current_action()
 * @uses bp_action_variable()
 * @uses check_admin_referer()
 * @uses bp_activity_user_can_delete()
 * @uses do_action() Calls 'bp_activity_before_action_delete_activity' hook to allow actions to be taken before the activity is deleted.
 * @uses bp_activity_delete()
 * @uses bp_core_add_message()
 * @uses do_action() Calls 'bp_activity_action_delete_activity' hook to allow actions to be taken after the activity is deleted.
 * @uses bp_core_redirect()
 *
 * @param int $activity_id Activity id to be deleted. Defaults to 0.
 * @return bool False on failure.
 */
function bp_activity_action_delete_activity($activity_id = 0)
{
    // Not viewing activity or action is not delete.
    if (!bp_is_activity_component() || !bp_is_current_action('delete')) {
        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;
    }
    // Check the nonce.
    check_admin_referer('bp_activity_delete_link');
    // Load up the activity item.
    $activity = new BP_Activity_Activity($activity_id);
    // Check access.
    if (!bp_activity_user_can_delete($activity)) {
        return false;
    }
    /**
     * Fires before the deletion so plugins can still fetch information about it.
     *
     * @since 1.5.0
     *
     * @param int $activity_id The activity ID.
     * @param int $user_id     The user associated with the activity.
     */
    do_action('bp_activity_before_action_delete_activity', $activity_id, $activity->user_id);
    // Delete the activity item and provide user feedback.
    if (bp_activity_delete(array('id' => $activity_id, 'user_id' => $activity->user_id))) {
        bp_core_add_message(__('Activity deleted successfully', 'buddypress'));
    } else {
        bp_core_add_message(__('There was an error when deleting that activity', 'buddypress'), 'error');
    }
    /**
     * Fires after the deletion so plugins can act afterwards based on the activity.
     *
     * @since 1.1.0
     *
     * @param int $activity_id The activity ID.
     * @param int $user_id     The user associated with the activity.
     */
    do_action('bp_activity_action_delete_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,代码行数:71,代码来源:bp-activity-actions.php


示例18: bp_like_remove_user_like

/**
 * bp_like_remove_user_like()
 *
 * Registers that the user has unliked a given item.
 *
 */
function bp_like_remove_user_like($item_id = '', $type = 'activity')
{
    global $bp;
    if (!$item_id) {
        return false;
    }
    if (!isset($user_id)) {
        $user_id = $bp->loggedin_user->id;
    }
    if ($user_id == 0) {
        echo bp_like_get_text('must_be_logged_in');
        return false;
    }
    if ($type == 'activity') {
        /* Remove this from the users liked activities. */
        $user_likes = get_user_meta($user_id, 'bp_liked_activities', true);
        unset($user_likes[$item_id]);
        update_user_meta($user_id, 'bp_liked_activities', $user_likes);
        /* Update the total number of users who have liked this activity. */
        $users_who_like = bp_activity_get_meta($item_id, 'liked_count', true);
        unset($users_who_like[$user_id]);
        /* If nobody likes the activity, delete the meta for it to save space, otherwise, update the meta */
        if (empty($users_who_like)) {
            bp_activity_delete_meta($item_id, 'liked_count');
        } else {
            bp_activity_update_meta($item_id, 'liked_count', $users_who_like);
        }
        $liked_count = count($users_who_like);
        /* Remove the update on the users profile from when they liked the activity. */
        $update_id = bp_activity_get_activity_id(array('item_id' => $item_id, 'component' => 'bp-like', 'type' => 'activity_liked', 'user_id' => $user_id));
        bp_activity_delete(array('id' => $update_id, 'item_id' => $item_id, 'component' => 'bp-like', 'type' => 'activity_liked', 'user_id' => $user_id));
    } elseif ($type == 'blogpost') {
        /* Remove this from the users liked activities. */
        $user_likes = get_user_meta($user_id, 'bp_liked_blogposts', true);
        unset($user_likes[$item_id]);
        update_user_meta($user_id, 'bp_liked_blogposts', $user_likes);
        /* Update the total number of users who have liked this blog post. */
        $users_who_like = get_post_meta($item_id, 'liked_count', true);
        unset($users_who_like[$user_id]);
        /* If nobody likes the blog post, delete the meta for it to save space, otherwise, update the meta */
        if (empty($users_who_like)) {
            delete_post_meta($item_id, 'liked_count');
        } else {
            update_post_meta($item_id, 'liked_count', $users_who_like);
        }
        $liked_count = count($users_who_like);
        /* Remove the update on the users profile from when they liked the activity. */
        $update_id = bp_activity_get_activity_id(array('item_id' => $item_id, 'component' => 'bp-like', 'type' => 'blogpost_liked', 'user_id' => $user_id));
        bp_activity_delete(array('id' => $update_id, 'item_id' => $item_id, 'component' => 'bp-like', 'type' => 'blogpost_liked', 'user_id' => $user_id));
    }
    echo bp_like_get_text('like');
    if ($liked_count) {
        echo ' (' . $liked_count . ')';
    }
}
开发者ID:Grendel61,项目名称:BuddyPress-Like,代码行数:61,代码来源:like-functions.php


示例19: bp_zoneideas_delete_activity

/**
 * bp_zoneideas_delete_activity()
 *
 * If the activity stream component is installed, this function will delete activity items for your
 * component.
 *
 * You should use this when items are deleted, to keep the activity stream in sync. For zoneideas if a user
 * publishes a new blog post, it would record it in the activity stream. However, if they then make it private
 * or they delete it. You'll want to remove it from the activity stream, otherwise you will get out of sync and
 * bad links.
 */
function bp_zoneideas_delete_activity($args)
{
    if (function_exists('bp_activity_delete')) {
        extract((array) $args);
        bp_activity_delete($item_id, $component_name, $component_action, $user_id, $secondary_item_id);
    }
}
开发者ID:BGCX261,项目名称:zoneideas-svn-to-git,代码行数:18,代码来源:bp-zoneideas.php


示例20: bp_activity_action_delete_activity

/**
 * Delete specific activity item and redirect to previous page.
 *
 * @since BuddyPress (1.1)
 *
 * @param int $activity_id Activity id to be deleted. Defaults to 0.
 *
 * @uses bp_is_activity_component()
 * @uses bp_is_current_action()
 * @uses bp_action_variable()
 * @uses check_admin_referer()
 * @uses bp_activity_user_can_delete()
 * @uses do_action() Calls 'bp_activity_before_action_delete_activity' hook to allow actions to be taken before the activity is deleted.
 * @uses bp_activity_delete()
 * @uses bp_core_add_message()
 * @uses do_action() Calls 'bp_activity_action_delete_activity' hook to allow actions to be taken after the activity is deleted.
 * @uses bp_core_redirect()
 *
 * @return bool False on failure.
 */
function bp_activity_action_delete_activity($activity_id = 0)
{
    // Not viewing activity or action is not delete
    if (!bp_is_activity_component() || !bp_is_current_action('delete')) {
        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;
    }
    // Check the nonce
    check_admin_referer('bp_activity_delete_link');
    // Load up the activity item
    $activity = new BP_Activity_Activity($activity_id);
    // Check access
    if (!bp_activity_user_can_delete($activity)) {
        return false;
    }
    // Call the action before the delete so plugins can still fetch information about it
    do_action('bp_activity_before_action_delete_activity', $activity_id, $activity->user_id);
    // Delete the activity item and provide user feedback
    if (bp_activity_delete(array('id' => $activity_id, 'user_id' => $activity->user_id))) {
        bp_core_add_message(__('Activity deleted successfully', 'buddypress'));
    } else {
        bp_core_add_message(__('There was an error when deleting that activity', 'buddypress'), 'error');
    }
    do_action('bp_activity_action_delete_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,代码行数:57,代码来源:bp-activity-actions.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP bp_activity_delete_by_item_id函数代码示例发布时间:2022-05-24
下一篇:
PHP bp_activity_current_comment函数代码示例发布时间: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