/**
 * Delete an activity item related to the Friends component.
 *
 * @since 1.0.0
 *
 * @param array $args {
 *     An array of arguments for the item to delete.
 *     @type int    $item_id ID of the 'item' associated with the activity item.
 *                           For Friends activity items, this is usually the user ID of one
 *                           of the friends.
 *     @type string $type    The 'type' of the activity item (eg
 *                           'friendship_accepted').
 *     @type int    $user_id ID of the user associated with the activity item.
 * }
 * @return bool True on success, false on failure.
 */
function friends_delete_activity($args)
{
    if (!bp_is_active('activity')) {
        return;
    }
    bp_activity_delete_by_item_id(array('component' => buddypress()->friends->id, 'item_id' => $args['item_id'], 'type' => $args['type'], 'user_id' => $args['user_id']));
}
Esempio n. 2
0
function friends_delete_activity($args)
{
    global $bp;
    if (bp_is_active('activity')) {
        extract((array) $args);
        bp_activity_delete_by_item_id(array('item_id' => $item_id, 'component' => $bp->friends->id, 'type' => $type, 'user_id' => $user_id));
    }
}
/**
 * Deletes activity for a user within the profile component so that
 * it will be removed from the users activity stream and sitewide stream (if installed)
 *
 * @package BuddyPress XProfile
 * @param $args Array containing all variables used after extract() call
 * @global object $bp Global BuddyPress settings object
 * @uses bp_activity_delete() Deletes an entry to the activity component tables for a specific activity
 */
function xprofile_delete_activity($args = '')
{
    global $bp;
    if (bp_is_active('activity')) {
        extract($args);
        bp_activity_delete_by_item_id(array('item_id' => $item_id, 'component' => $bp->profile->id, 'type' => $type, 'user_id' => $user_id, 'secondary_item_id' => $secondary_item_id));
    }
}
Esempio n. 4
0
function bp_blogs_delete_activity($args = true)
{
    global $bp;
    if (bp_is_active('activity')) {
        $defaults = array('item_id' => false, 'component' => $bp->blogs->id, 'type' => false, 'user_id' => false, 'secondary_item_id' => false);
        $params = wp_parse_args($args, $defaults);
        extract($params, EXTR_SKIP);
        bp_activity_delete_by_item_id(array('item_id' => $item_id, 'component' => $component, 'type' => $type, 'user_id' => $user_id, 'secondary_item_id' => $secondary_item_id));
    }
}
function bp_group_management_delete_group($group_id)
{
    global $bp;
    $group = new BP_Groups_Group($group_id);
    if (!$group->delete()) {
        return false;
    }
    /* Delete all group activity from activity streams */
    if (function_exists('bp_activity_delete_by_item_id')) {
        bp_activity_delete_by_item_id(array('item_id' => $group_id, 'component' => $bp->groups->id));
    }
    // Remove all outstanding invites for this group
    groups_delete_all_group_invites($group_id);
    // Remove all notifications for any user belonging to this group
    bp_core_delete_all_notifications_by_type($group_id, $bp->groups->slug);
    do_action('groups_delete_group', $group_id);
    return true;
}
Esempio n. 6
0
function groups_update_group_forum_topic($topic_id, $topic_title, $topic_text, $topic_tags = false)
{
    global $bp;
    $topic_title = apply_filters('group_forum_topic_title_before_save', $topic_title);
    $topic_text = apply_filters('group_forum_topic_text_before_save', $topic_text);
    if ($topic = bp_forums_update_topic(array('topic_title' => $topic_title, 'topic_text' => $topic_text, 'topic_id' => $topic_id, 'topic_tags' => $topic_tags))) {
        // Update the activity stream item
        if (bp_is_active('activity')) {
            bp_activity_delete_by_item_id(array('item_id' => $bp->groups->current_group->id, 'secondary_item_id' => $topic_id, 'component' => $bp->groups->id, 'type' => 'new_forum_topic'));
        }
        $activity_action = sprintf(__('%1$s started the forum topic %2$s in the group %3$s', 'buddypress'), bp_core_get_userlink($topic->topic_poster), '<a href="' . bp_get_group_permalink($bp->groups->current_group) . 'forum/topic/' . $topic->topic_slug . '/">' . esc_attr($topic->topic_title) . '</a>', '<a href="' . bp_get_group_permalink($bp->groups->current_group) . '">' . esc_attr($bp->groups->current_group->name) . '</a>');
        $activity_content = bp_create_excerpt($topic_text);
        // Record this in activity streams
        groups_record_activity(array('action' => apply_filters_ref_array('groups_activity_new_forum_topic_action', array($activity_action, $topic_text, &$topic)), 'content' => apply_filters_ref_array('groups_activity_new_forum_topic_content', array($activity_content, $topic_text, &$topic)), 'primary_link' => apply_filters('groups_activity_new_forum_topic_primary_link', bp_get_group_permalink($bp->groups->current_group) . 'forum/topic/' . $topic->topic_slug . '/'), 'type' => 'new_forum_topic', 'item_id' => (int) $bp->groups->current_group->id, 'user_id' => (int) $topic->topic_poster, 'secondary_item_id' => $topic->topic_id, 'recorded_time ' => $topic->topic_time));
        do_action_ref_array('groups_update_group_forum_topic', array(&$topic));
        return $topic;
    }
    return false;
}
/**
 * Delete a group and all of its associated meta
 *
 * @global object $bp BuddyPress global settings
 * @param int $group_id
 * @since 1.0
 */
function groups_delete_group($group_id)
{
    global $bp;
    // Check the user is the group admin.
    if (!$bp->is_item_admin) {
        return false;
    }
    // Get the group object
    $group = new BP_Groups_Group($group_id);
    if (!$group->delete()) {
        return false;
    }
    do_action('groups_before_delete_group', $group_id);
    // Delete all group activity from activity streams
    if (bp_is_active('activity')) {
        bp_activity_delete_by_item_id(array('item_id' => $group_id, 'component' => $bp->groups->id));
    }
    // Remove all outstanding invites for this group
    groups_delete_all_group_invites($group_id);
    // Remove all notifications for any user belonging to this group
    bp_core_delete_all_notifications_by_type($group_id, $bp->groups->id);
    // Remove forum if component is active and current group has one
    if (bp_is_active('forums') && ($forum_id = groups_get_groupmeta($group_id, 'forum_id'))) {
        do_action('bbpress_init');
        bb_delete_forum($forum_id);
    }
    do_action('groups_delete_group', $group_id);
    return true;
}
Esempio n. 8
0
 /**
  * Wrapper for deleting bbPress actions from BuddyPress activity stream
  *
  * @since bbPress (r3395)
  * @param type $args Array of arguments for bp_activity_add()
  * @uses bbp_get_current_user_id()
  * @uses bp_core_current_time()
  * @uses bbp_parse_args()
  * @uses aplly_filters()
  * @uses bp_activity_add()
  * @return type Activity ID if successful, false if not
  */
 public function delete_activity($args = '')
 {
     // Default activity args
     $defaults = array('item_id' => false, 'component' => $this->component, 'type' => false, 'user_id' => false, 'secondary_item_id' => false);
     $activity = bbp_parse_args($args, $defaults, 'delete_activity');
     // Delete the activity
     bp_activity_delete_by_item_id($activity);
 }
/**
 * Deletes activity for a user within the profile component so that it will be
 * removed from the users activity stream and sitewide stream (if installed).
 *
 * @since 1.0.0
 *
 * @uses bp_activity_delete() Deletes an entry to the activity component tables
 *                            for a specific activity.
 *
 * @param array|string $args Containing all variables used after bp_parse_args() call.
 *
 * @return bool
 */
function xprofile_delete_activity($args = '')
{
    // Bail if activity component is not active.
    if (!bp_is_active('activity')) {
        return false;
    }
    // Parse the arguments.
    $r = bp_parse_args($args, array('component' => buddypress()->profile->id), 'xprofile_delete_activity');
    // Delete the activity item.
    bp_activity_delete_by_item_id($r);
}
/**
 * Delete a group and all of its associated meta
 *
 * @global object $bp BuddyPress global settings
 * @param int $group_id
 * @since BuddyPress (1.0)
 */
function groups_delete_group($group_id)
{
    global $bp;
    // Check the user is the group admin.
    if (!bp_is_item_admin()) {
        return false;
    }
    do_action('groups_before_delete_group', $group_id);
    // Get the group object
    $group = groups_get_group(array('group_id' => $group_id));
    if (!$group->delete()) {
        return false;
    }
    // Delete all group activity from activity streams
    if (bp_is_active('activity')) {
        bp_activity_delete_by_item_id(array('item_id' => $group_id, 'component' => $bp->groups->id));
    }
    // Remove all outstanding invites for this group
    groups_delete_all_group_invites($group_id);
    // Remove all notifications for any user belonging to this group
    bp_core_delete_all_notifications_by_type($group_id, $bp->groups->id);
    do_action('groups_delete_group', $group_id);
    return true;
}
Esempio n. 11
0
function friends_delete_activity( $args ) {
	if ( function_exists('bp_activity_delete_by_item_id') ) {
		extract( (array)$args );
		bp_activity_delete_by_item_id( array( 'item_id' => $item_id, 'component' => $bp->friends->id, 'type' => $type, 'user_id' => $user_id, 'secondary_item_id' => $secondary_item_id ) );
	}
}
/**
 * Deletes activities of a cancelled rendez-vous
 *
 * @package Rendez Vous
 * @subpackage Activity
 *
 * @since Rendez Vous (1.0.0)
 */
function rendez_vous_delete_item_activities($rendez_vous_id = 0, $rendez_vous = null)
{
    if (empty($rendez_vous_id)) {
        return;
    }
    $rendez_vous_status = 'publish';
    if (is_a($rendez_vous, 'WP_Post')) {
        $rendez_vous_status = $rendez_vous->post_status;
    } else {
        if (is_a($rendez_vous, 'Rendez_Vous_Item')) {
            $rendez_vous_status = $rendez_vous->status;
        }
    }
    // No need to delete activities in case of drafts
    if (!empty($rendez_vous) && 'draft' == $rendez_vous_status) {
        return;
    }
    $types = array('new_rendez_vous', 'updated_rendez_vous');
    $args = apply_filters('rendez_vous_delete_item_activities_args', array('item_id' => $rendez_vous_id, 'component' => buddypress()->rendez_vous->id));
    foreach ($types as $type) {
        $args['type'] = $type;
        bp_activity_delete_by_item_id($args);
    }
}
/**
 * Delete a blog-related activity stream item.
 *
 * @since 1.0.0
 *
 * @see bp_activity_delete() for description of parameters.
 *
 * @param array|string $args {
 *     See {@link bp_activity_delete()} for complete description of arguments.
 *     The arguments listed here have different default values from
 *     bp_activity_add().
 *     @type string $component Default: 'blogs'.
 * }
 * @return bool True on success, false on failure.
 */
function bp_blogs_delete_activity($args = '')
{
    $r = bp_parse_args($args, array('item_id' => false, 'component' => buddypress()->blogs->id, 'type' => false, 'user_id' => false, 'secondary_item_id' => false));
    bp_activity_delete_by_item_id($r);
}
/**
 * Remove an activity item when a comment about a post type is deleted.
 *
 * @since 2.5.0
 *
 * @param  int    $comment_id           ID of the comment.
 * @param  object $activity_post_object The post type tracking args object.
 *
 * @return bool True on success. False on error.
 */
function bp_activity_post_type_remove_comment($comment_id = 0, $activity_post_object = null)
{
    if (empty($activity_post_object)) {
        $comment = get_comment($comment_id);
        if (!$comment) {
            return;
        }
        $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
    $activity_comment_object = $activity_post_object->comments_tracking;
    if (empty($activity_comment_object->action_id)) {
        return false;
    }
    $deleted = false;
    if (bp_disable_blogforum_comments()) {
        $deleted = bp_activity_delete_by_item_id(array('item_id' => get_current_blog_id(), 'secondary_item_id' => $comment_id, 'component' => $activity_comment_object->component_id, 'type' => $activity_comment_object->action_id, 'user_id' => false));
    }
    /**
     * Fires after the custom post type comment activity was removed.
     *
     * @since 2.5.0
     *
     * @param bool       $deleted              True if the activity was deleted false otherwise
     * @param WP_Comment $comment              Comment object.
     * @param object     $activity_post_object The post type tracking args object.
     * @param string     $value                The post type comment activity type.
     */
    do_action('bp_activity_post_type_remove_comment', $deleted, $comment_id, $activity_post_object, $activity_comment_object->action_id);
    return $deleted;
}
Esempio n. 15
0
/**
 * When a blog is spammed, archived, or deleted, delete the corresponding group
 *
 * @param int
 */
function thatcamp_delete_group_for_blog($blog_id)
{
    global $bp;
    $group_id = thatcamp_get_blog_group($blog_id);
    // do it manually, to avoid groups_delete_group() cap check
    do_action('groups_before_delete_group', $group_id);
    // Get the group object
    $group = groups_get_group(array('group_id' => $group_id));
    if (!$group->delete()) {
        return false;
    }
    // Delete all group activity from activity streams
    if (bp_is_active('activity')) {
        bp_activity_delete_by_item_id(array('item_id' => $group_id, 'component' => $bp->groups->id));
    }
    // Remove all outstanding invites for this group
    groups_delete_all_group_invites($group_id);
    // Remove all notifications for any user belonging to this group
    bp_core_delete_all_notifications_by_type($group_id, $bp->groups->id);
    do_action('groups_delete_group', $group_id);
}
Esempio n. 16
0
/**
 * Delete a blog-related activity stream item.
 *
 * @since BuddyPress (1.0.0)
 *
 * @see bp_activity_delete() for description of parameters.
 *
 * @param array $args {
 *     See {@link bp_activity_delete()} for complete description of arguments.
 *     The arguments listed here have different default values from
 *     bp_activity_add().
 *     @type string $component Default: 'blogs'.
 * }
 * @return bool True on success, false on failure.
 */
function bp_blogs_delete_activity( $args = '' ) {

	// Bail if activity is not active
	if ( ! bp_is_active( 'activity' ) ) {
		return false;
	}

	$r = bp_parse_args( $args, array(
		'item_id'           => false,
		'component'         => buddypress()->blogs->id,
		'type'              => false,
		'user_id'           => false,
		'secondary_item_id' => false
	) );

	bp_activity_delete_by_item_id( $r );
}
 /**
  * Wrapper for deleting Achievements actions from the BuddyPress activity stream.
  *
  * @param array $args Array of arguments for bp_activity_add().
  * @return int|bool Activity ID if successful, false if not.
  * @since Achievements (3.2)
  */
 public function delete_activity($args = array())
 {
     $activity = dpa_parse_args($args, array('component' => $this->component, 'item_id' => false, 'secondary_item_id' => false, 'type' => false, 'user_id' => false), 'delete_activity');
     bp_activity_delete_by_item_id($activity);
 }
/**
 * Delete all group activity from activity streams
 *
 * @since BuddyPress (1.9.0)
 */
function bp_groups_delete_group_delete_all_activity($group_id)
{
    if (bp_is_active('activity')) {
        bp_activity_delete_by_item_id(array('item_id' => $group_id, 'component' => buddypress()->groups->id));
    }
}
Esempio n. 19
0
/**
 * bp_group_documents_delete_activity()
 *
 * Deletes a previously recorded activity - useful for making sure there are no broken links
 * if soemthing is deleted.
 */
function bp_group_documents_delete_activity($args = true)
{
    global $bp;
    if (function_exists('bp_activity_delete_by_item_id')) {
        $defaults = array('item_id' => false, 'component_name' => 'groups', 'component_action' => false, 'user_id' => false, 'secondary_item_id' => false);
        $r = wp_parse_args($args, $defaults);
        extract($r, EXTR_SKIP);
        bp_activity_delete_by_item_id(array('item_id' => $item_id, 'component_name' => $component_name, 'component_action' => $component_action, 'user_id' => $user_id, 'secondary_item_id' => $secondary_item_id));
    }
}
Esempio n. 20
0
 /**
  * @group bp_activity_delete_by_item_id
  */
 public function test_bp_activity_delete_by_item_id()
 {
     $args = array('user_id' => 5, 'component' => 'foo', 'type' => 'bar', 'item_id' => 12, 'secondary_item_id' => 44);
     $a = $this->factory->activity->create($args);
     $this->assertTrue(bp_activity_delete_by_item_id($args));
     $found = bp_activity_get_specific(array('activity_ids' => array($a)));
     $this->assertSame(array(), $found['activities']);
 }
/**
 * Unpublish an activity for the custom post type.
 *
 * @since 2.2.0
 *
 * @param  int     $post_id ID of the post being unpublished.
 * @param  WP_Post $post    Post object.
 * @return bool True on success, false on failure.
 */
function bp_activity_post_type_unpublish($post_id = 0, $post = null)
{
    if (!is_a($post, 'WP_Post')) {
        return;
    }
    // Get the post type tracking args.
    $activity_post_object = bp_activity_get_post_type_tracking_args($post->post_type);
    if (empty($activity_post_object->action_id)) {
        return;
    }
    if (empty($post_id)) {
        $post_id = $post->ID;
    }
    $delete_activity_args = array('item_id' => get_current_blog_id(), 'secondary_item_id' => $post_id, 'component' => $activity_post_object->component_id, 'type' => $activity_post_object->action_id, 'user_id' => false);
    $deleted = bp_activity_delete_by_item_id($delete_activity_args);
    /**
     * Fires after the unpublishing for the custom post type.
     *
     * @since 2.2.0
     *
     * @param array   $delete_activity_args Array of arguments for activity deletion.
     * @param WP_Post $post                 Post object.
     * @param bool    $activity             Whether or not the activity was successfully deleted.
     */
    do_action('bp_activity_post_type_unpublished', $delete_activity_args, $post, $deleted);
    return $deleted;
}
Esempio n. 22
0
function bp_links_delete_link($link_id)
{
    global $bp;
    // Check the user is the link admin.
    if (false === bp_link_is_admin()) {
        return false;
    }
    // Get the link object
    $link = new BP_Links_Link($link_id);
    if (!$link->delete()) {
        return false;
    }
    /* Delete all link activity from activity streams */
    if (function_exists('bp_activity_delete_by_item_id')) {
        bp_activity_delete_by_item_id(array('item_id' => $link->id, 'component_name' => bp_links_id()));
    }
    // Remove all notifications for any user belonging to this link
    bp_core_delete_all_notifications_by_type($link_id, bp_links_id());
    do_action('bp_links_delete_link', $link_id);
    return true;
}