本文整理汇总了PHP中bp_activity_delete函数的典型用法代码示例。如果您正苦于以下问题:PHP bp_activity_delete函数的具体用法?PHP bp_activity_delete怎么用?PHP bp_activity_delete使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bp_activity_delete函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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));
}
示例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);
}
}
示例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'));
}
}
示例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);
}
示例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;
}
示例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);
}
}
}
示例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));
}
示例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());
}
示例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));
}
示例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;
}
}
示例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());
//.........这里部分代码省略.........
示例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:
示例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);
}
示例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));
}
示例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;
}