Beispiel #1
0
 /**
  * @group cache
  */
 public function test_cache_invalidation_all_for_user_on_delete()
 {
     $u = $this->factory->user->create();
     $n1 = $this->factory->notification->create(array('component_name' => 'groups', 'user_id' => $u));
     $this->factory->notification->create(array('component_name' => 'messages', 'user_id' => $u));
     // prime cache
     $count = bp_notifications_get_unread_notification_count($u);
     // just to be sure...
     $this->assertEquals(2, $count, 'Cache count should be 2 before invalidation.');
     // delete
     BP_Notifications_Notification::delete(array('id' => $n1));
     $this->assertFalse(wp_cache_get('all_for_user_' . $u, 'bp_notifications'));
 }
/**
 * Delete all notifications from a user.
 *
 * Used when clearing out all notifications for a user, when deleted or spammed.
 *
 * @todo This function assumes that items with the user_id in the item_id slot
 *       are associated with that user. However, this will only be true with
 *       certain components (such as Friends). Use with caution!
 *
 * @since BuddyPress (1.9.0)
 *
 * @param int $user_id ID of the user whose associated items are being deleted.
 * @param string $component_name Name of the associated component.
 * @param string $component_action Name of the associated action.
 * @return bool True on success, false on failure.
 */
function bp_notifications_delete_notifications_from_user($user_id, $component_name, $component_action)
{
    return BP_Notifications_Notification::delete(array('item_id' => $user_id, 'component_name' => $component_name, 'component_action' => $component_action));
}
/**
 * Delete notifications the user "sent" in case his account was deleted
 *
 * @package WP Idea Stream
 * @subpackage buddypress/notifications
 *
 * @since  2.0.0
 *
 * @param  int $user_id the deleted user id
 * @uses   BP_Notifications_Notification::delete() to delete the notifications
 * @uses   buddypress() to get BuddyPress instance
 * @uses   wp_idea_stream_get_post_type() to get the ideas post type identifier
 */
function wp_idea_stream_buddypress_delete_notifications_by_user($user_id = 0)
{
    if (empty($user_id)) {
        return false;
    }
    // Delete all notification about the rates he gave
    return BP_Notifications_Notification::delete(array('component_name' => buddypress()->ideastream->id, 'component_action' => 'new_' . wp_idea_stream_get_post_type() . '_rate', 'secondary_item_id' => $user_id));
}
 /**
  * delete notification of a comment perticular commnet
  * @param   int     $comment_id
  */
 function remove_comment_notification($comment_id)
 {
     $comment_notification_id = (int) get_comment_meta($comment_id, 'comment_notification_id', true);
     BP_Notifications_Notification::delete(array('id' => $comment_notification_id));
     delete_comment_meta($comment_id, 'comment_notification_id');
 }
Beispiel #5
0
function apoc_delete_all_notifications()
{
    // Get the user data
    $user_id = $_POST['id'];
    // Delete all notifications
    BP_Notifications_Notification::delete(array('user_id' => $user_id));
    die("1");
}
/**
 * Delete a user's notifications when the user is deleted.
 *
 * @since 2.5.0
 *
 * @param int $user_id ID of the user who is about to be deleted.
 * @return int|bool The number of rows deleted, or false on error.
 */
function bp_notifications_delete_notifications_on_user_delete($user_id)
{
    return BP_Notifications_Notification::delete(array('user_id' => $user_id, 'item_id' => false, 'secondary_item_id' => false, 'component_action' => false, 'component_name' => false));
}
/**
 * Remove a user's notification data.
 *
 * @package Rendez Vous
 * @subpackage Notifications
 *
 * @since Rendez Vous (1.0.0)
 */
function rendez_vous_remove_all_user_notifications($user_id = 0)
{
    if (empty($user_id)) {
        return false;
    }
    // delete all notifications user sent to others
    BP_Notifications_Notification::delete(array('secondary_item_id' => $user_id, 'component_name' => buddypress()->rendez_vous->id));
}
 /**
  * Deletes all notifications connected to post if it is deleted.
  * @param array|int $post
  * @return void
  */
 public function delete_notifications($post)
 {
     if (is_object($post)) {
         $post_id = $post->ID;
     } elseif (is_array($post)) {
         $post_id = $post['ID'];
     } elseif (is_numeric($post)) {
         $post_id = $post;
     }
     if (isset($post_id)) {
         BP_Notifications_Notification::delete(array('item_id' => $post_id, 'secondary_item_id' => get_current_blog_id(), 'component_name' => $this->id, 'component_action' => 'new_post_' . $post_id));
     }
 }
/**
 * Delete a notification.
 *
 * @since 1.0.0
 *
 * @param int|bool $user_id The ID of the user associated with the notification.
 * @param int|bool $item_id The ID of the item associated with the notification.
 * @param int|bool $secondary_item_id The ID of the secondary item associated with the notification.
 * @param string|bool $component_action The action associated with the notification.
 */
function crowdmentions_delete_notification($user_id = false, $item_id = false, $secondary_item_id = false, $component_action = false)
{
    $where = array('user_id' => $user_id, 'item_id' => $item_id, 'secondary_item_id' => $secondary_item_id, 'component_action' => $component_action, 'component_name' => crowdmentions_get_component_name());
    BP_Notifications_Notification::delete($where);
}