function deleteArticlesNotification() { global $bp; $user_id = $bp->loggedin_user->id; $item_id = $_POST['item_id']; $component_name = 'social_articles'; $component_action = $_POST['action_id']; bp_core_delete_notifications_by_item_id($user_id, $item_id, $component_name, $component_action); die; }
function bp_checkins_single_place_check_access() { if (bp_checkins_if_single_place()) { global $wp_query, $bp; $redirect = bp_get_checkins_places_home(); $check_places = wp_cache_get('single_query', 'bp_checkins_single'); if (false === $check_places) { $check_places = new BP_Checkins_Place(); $check_places->get(array('p' => bp_action_variable(0))); } $place_id = $check_places->query->post->ID; if (empty($place_id)) { bp_core_add_message(__('OOps, looks like this place does not exist ! You can try to search for it or browse categories', 'bp-checkins'), 'error'); bp_core_redirect($redirect); } else { if (bp_is_active('groups')) { // 1. check for group access !! $group_id = get_post_meta($place_id, '_bpci_group_id', true); $bp->groups->current_group = new BP_Groups_Group($group_id); if (isset($bp->groups->current_group->status) && 'public' != $bp->groups->current_group->status) { if (!is_user_logged_in() || !groups_is_user_member($bp->loggedin_user->id, $group_id)) { bp_core_add_message(__('OOps, looks like this place is private ! You can try to search for another one or browse categories', 'bp-checkins'), 'error'); bp_core_redirect($redirect); } } } // 2. check for live type to load the timer on the client side ! if ("live" == get_post_meta($place_id, 'bpci_places_is_live', true)) { $start = get_post_meta($place_id, 'bpci_places_live_start', true); $end = get_post_meta($place_id, 'bpci_places_live_end', true); $start = strtotime($start); $end = strtotime($end); $now = current_time('timestamp'); if ($end >= $now && $now >= $start) { add_filter('bp_get_the_body_class', 'bp_checkins_body_class_is_live'); } } add_filter('bp_get_the_body_class', 'bp_checkins_body_class_is_single_place'); // 3. Check for notifications if (isset($_GET['n'])) { bp_core_delete_notifications_by_item_id($bp->loggedin_user->id, $place_id, 'checkins', 'new_comment'); } } } }
function groups_delete_invite($user_id, $group_id) { global $bp; $delete = BP_Groups_Member::delete_invite($user_id, $group_id); if ($delete) { bp_core_delete_notifications_by_item_id($user_id, $group_id, $bp->groups->id, 'group_invite'); } return $delete; }
function friends_reject_friendship($friendship_id) { global $bp; $friendship = new BP_Friends_Friendship($friendship_id, true, false); if (!$friendship->is_confirmed && BP_Friends_Friendship::reject($friendship_id)) { // Remove the friend request notice bp_core_delete_notifications_by_item_id($friendship->friend_user_id, $friendship->initiator_user_id, $bp->friends->id, 'friendship_request'); do_action_ref_array('friends_friendship_rejected', array($friendship_id, &$friendship)); return true; } return false; }
/** * Marks a compliment as read when 'bpc_read' is set. * * @since 0.0.2 * @package BuddyPress_Compliments * * @global object $bp BuddyPress instance. */ function bp_compliments_notifications_mark_compliments_as_read() { if (!bp_is_user() || !is_user_logged_in()) { return; } if (!isset($_GET['bpc_read']) || !isset($_GET['bpc_sender_id'])) { return; } $compliment_id = false; if (isset($_GET['c_id'])) { $compliment_id = (int) strip_tags(esc_sql($_GET['c_id'])); } $sender_id = (int) strip_tags(esc_sql($_GET['bpc_sender_id'])); if (!is_int($sender_id)) { return; } // mark notification as read if (bp_is_active('notifications')) { bp_notifications_mark_notifications_by_item_id(bp_loggedin_user_id(), $sender_id, buddypress()->compliments->id, 'new_compliment'); // check if we're not on BP 1.9 // if so, delete notification since marked functionality doesn't exist } elseif (!class_exists('BP_Core_Login_Widget')) { global $bp; bp_core_delete_notifications_by_item_id(bp_loggedin_user_id(), $sender_id, buddypress()->compliments->id, 'new_compliment'); } // Redirect if ($compliment_id) { bp_core_redirect(bp_displayed_user_domain() . BP_COMPLIMENTS_SLUG . '/?c_id=' . $compliment_id); } else { bp_core_redirect(bp_displayed_user_domain() . BP_COMPLIMENTS_SLUG . '/'); } }
/** * Mark notification as read when a logged-in user visits their follower's profile. * * This is a new feature in BuddyPress 1.9. * * @since 1.2.1 */ function bp_follow_notifications_mark_follower_profile_as_read() { if (!isset($_GET['bpf_read'])) { return; } // mark notification as read if (bp_is_active('notifications')) { bp_notifications_mark_notifications_by_item_id(bp_loggedin_user_id(), bp_displayed_user_id(), buddypress()->follow->id, 'new_follow'); // check if we're not on BP 1.9 // if so, delete notification since marked functionality doesn't exist } elseif (!class_exists('BP_Core_Login_Widget')) { global $bp; bp_core_delete_notifications_by_item_id(bp_loggedin_user_id(), bp_displayed_user_id(), $bp->follow->id, 'new_follow'); } }
/** * @since 1.0.3 * it is not used any more because qwe are linking to threaded view * Remove notification for group forum posts/new topic */ function ac_notifier_remove_notification_for_topic() { global $bp; //is group & group forum active ? if (!(bp_is_active("groups") && bp_is_active("forums"))) { return; } //if either group or forum is not actuive do not do anything //check if we are on single topic screen, right? if (bp_is_group_forum_topic() && is_user_logged_in()) { $topic_id = bp_forums_get_topic_id_from_slug($bp->action_variables[1]); //get id from slug $topic = get_topic($topic_id); $group_id = $bp->groups->current_group->id; //find activity id for this topic $activity_id = bp_activity_get_activity_id(array('user_id' => $topic->poster_id, 'component' => $bp->groups->id, 'type' => "new_forum_topic", "item_id" => $group_id, 'secondary_item_id' => $topic_id)); //remove notification for new topic comments: easy if (!empty($activity_id)) { bp_core_delete_notifications_by_item_id($bp->loggedin_user->id, $activity_id, $bp->ac_notifier->id, 'new_activity_comment_' . $activity_id); } $posts = ac_notifier_get_forum_post_ids($topic_id); if (!empty($posts)) { //find all activities for the post $activities = ac_notifier_get_activity_ids(array("item_id" => $group_id, "secondary_ids" => $posts, "component" => $bp->groups->id, "type" => "new_forum_post")); //pass the array foreach ((array) $activities as $ac_id) { bp_core_delete_notifications_by_item_id($bp->loggedin_user->id, $ac_id, $bp->ac_notifier->id, 'new_activity_comment_' . $ac_id); } } } }
/** * Loads an Achievement's home (or activity stream) page. * * @global object $bp BuddyPress global settings * @since 2.0 */ function dpa_screen_achievement_activity() { global $bp; if ($bp->loggedin_user->id) { bp_core_delete_notifications_by_item_id($bp->loggedin_user->id, $bp->achievements->current_achievement->id, $bp->achievements->id, 'new_achievement'); } do_action('dpa_screen_achievement_activity'); bp_core_load_template(apply_filters('dpa_screen_achievement_activity_template', 'achievements/single/home')); }