function friends_screen_requests() { if (bp_is_action_variable('accept', 0) && is_numeric(bp_action_variable(1))) { // Check the nonce check_admin_referer('friends_accept_friendship'); if (friends_accept_friendship(bp_action_variable(1))) { bp_core_add_message(__('Friendship accepted', 'buddypress')); } else { bp_core_add_message(__('Friendship could not be accepted', 'buddypress'), 'error'); } bp_core_redirect(bp_loggedin_user_domain() . bp_current_component() . '/' . bp_current_action()); } elseif (bp_is_action_variable('reject', 0) && is_numeric(bp_action_variable(1))) { // Check the nonce check_admin_referer('friends_reject_friendship'); if (friends_reject_friendship(bp_action_variable(1))) { bp_core_add_message(__('Friendship rejected', 'buddypress')); } else { bp_core_add_message(__('Friendship could not be rejected', 'buddypress'), 'error'); } bp_core_redirect(bp_loggedin_user_domain() . bp_current_component() . '/' . bp_current_action()); } do_action('friends_screen_requests'); if (isset($_GET['new'])) { bp_core_delete_notifications_by_type(bp_loggedin_user_id(), 'friends', 'friendship_request'); } bp_core_load_template(apply_filters('friends_template_requests', 'members/single/home')); }
function friends_clear_friend_notifications() { global $bp; if (isset($_GET['new'])) { bp_core_delete_notifications_by_type(bp_loggedin_user_id(), $bp->friends->id, 'friendship_accepted'); } }
/** * Remove a screen notification for a user. */ function bp_em_remove_screen_notifications() { global $bp; if (function_exists('bp_notifications_delete_notifications_by_type')) { //backwards compat for BP 1.9 bp_notifications_delete_notifications_by_type($bp->loggedin_user->id, $bp->events->slug, 'attending'); } else { bp_core_delete_notifications_by_type($bp->loggedin_user->id, $bp->events->slug, 'attending'); } }
/** * bp_em_screen_two() * * Sets up and displays the screen output for the sub nav item "em/screen-two" */ function bp_em_my_bookings() { global $bp, $EM_Event; //assume any notifications here are considered viewed via this page bp_core_delete_notifications_by_type(get_current_user_id(), 'events', 'pending_booking'); bp_core_delete_notifications_by_type(get_current_user_id(), 'events', 'confirmed_booking'); bp_core_delete_notifications_by_type(get_current_user_id(), 'events', 'cancelled_booking'); em_load_event(); /** * If the user has not Accepted or Rejected anything, then the code above will not run, * we can continue and load the template. */ do_action('bp_em_my_bookings'); add_action('bp_template_title', 'bp_em_my_bookings_title'); add_action('bp_template_content', 'bp_em_my_bookings_content'); /* Finally load the plugin template file. */ bp_core_load_template(apply_filters('bp_core_template_plugin', 'members/single/plugins')); }
function groups_screen_group_admin_requests() { global $bp; if (bp_is_groups_component() && bp_is_action_variable('membership-requests', 0)) { if (!$bp->is_item_admin || 'public' == $bp->groups->current_group->status) { return false; } // Remove any screen notifications bp_core_delete_notifications_by_type(bp_loggedin_user_id(), $bp->groups->id, 'new_membership_request'); $request_action = (string) bp_action_variable(1); $membership_id = (int) bp_action_variable(2); if (!empty($request_action) && !empty($membership_id)) { if ('accept' == $request_action && is_numeric($membership_id)) { // Check the nonce first. if (!check_admin_referer('groups_accept_membership_request')) { return false; } // Accept the membership request if (!groups_accept_membership_request($membership_id)) { bp_core_add_message(__('There was an error accepting the membership request, please try again.', 'buddypress'), 'error'); } else { bp_core_add_message(__('Group membership request accepted', 'buddypress')); } } elseif ('reject' == $request_action && is_numeric($membership_id)) { /* Check the nonce first. */ if (!check_admin_referer('groups_reject_membership_request')) { return false; } // Reject the membership request if (!groups_reject_membership_request($membership_id)) { bp_core_add_message(__('There was an error rejecting the membership request, please try again.', 'buddypress'), 'error'); } else { bp_core_add_message(__('Group membership request rejected', 'buddypress')); } } do_action('groups_group_request_managed', $bp->groups->current_group->id, $request_action, $membership_id); bp_core_redirect(bp_get_group_permalink(groups_get_current_group()) . 'admin/membership-requests/'); } do_action('groups_screen_group_admin_requests', $bp->groups->current_group->id); bp_core_load_template(apply_filters('groups_template_group_admin_requests', 'groups/single/home')); } }
function bp_has_message_threads($args = '') { global $bp, $messages_template; $defaults = array('user_id' => bp_loggedin_user_id(), 'box' => 'inbox', 'per_page' => 10, 'max' => false, 'type' => 'all', 'search_terms' => isset($_REQUEST['s']) ? stripslashes($_REQUEST['s']) : '', 'page_arg' => 'mpage'); $r = wp_parse_args($args, $defaults); extract($r, EXTR_SKIP); if (bp_is_current_action('notices') && !bp_current_user_can('bp_moderate')) { wp_redirect(bp_displayed_user_id()); } else { if (bp_is_current_action('inbox')) { bp_core_delete_notifications_by_type(bp_loggedin_user_id(), $bp->messages->id, 'new_message'); } if (bp_is_current_action('sentbox')) { $box = 'sentbox'; } if (bp_is_current_action('notices')) { $box = 'notices'; } $messages_template = new BP_Messages_Box_Template($user_id, $box, $per_page, $max, $type, $search_terms, $page_arg); } return apply_filters('bp_has_message_threads', $messages_template->has_threads(), $messages_template); }
/** * Removes activity notifications from the notification menu when a user clicks on them and * is taken to a specific screen. * * @since BuddyPress (1.5) * * @global object $bp BuddyPress global settings * @uses bp_core_delete_notifications_by_type() */ function bp_activity_remove_screen_notifications() { global $bp; bp_core_delete_notifications_by_type(bp_loggedin_user_id(), $bp->activity->id, 'new_at_mention'); }
function bp_has_message_threads($args = '') { global $bp, $messages_template; $defaults = array('user_id' => $bp->loggedin_user->id, 'box' => 'inbox', 'per_page' => 10, 'max' => false, 'type' => 'all'); $r = nxt_parse_args($args, $defaults); extract($r, EXTR_SKIP); if ('notices' == $bp->current_action && !is_super_admin()) { nxt_redirect($bp->displayed_user->id); } else { if ('inbox' == $bp->current_action) { bp_core_delete_notifications_by_type($bp->loggedin_user->id, $bp->messages->id, 'new_message'); } if ('sentbox' == $bp->current_action) { $box = 'sentbox'; } if ('notices' == $bp->current_action) { $box = 'notices'; } $messages_template = new BP_Messages_Box_Template($user_id, $box, $per_page, $max, $type); } return apply_filters('bp_has_message_threads', $messages_template->has_threads(), $messages_template); }
/** * Delete notifications when a logged-in user visits their followers page. * * Since 1.2.1, when the "X users are now following you" notification appears, * users will be redirected to the new notifications unread page instead of * the logged-in user's followers page. This is so users can see who followed * them and in the date order in which they were followed. * * For backwards-compatibility, we still keep the old method of redirecting to * the logged-in user's followers page so notifications can be deleted for * older versions of BuddyPress. * * Will probably remove this in a future release. * * @since 1.2.1 */ function bp_follow_notifications_delete_on_followers_page() { if (!isset($_GET['new'])) { return; } if (!is_user_logged_in()) { return; } // BP 1.9+ if (bp_is_active('notifications')) { bp_notifications_delete_notifications_by_type(bp_loggedin_user_id(), $bp->follow->id, 'new_follow'); // BP < 1.9 } elseif (!class_exists('BP_Core_Login_Widget')) { global $bp; bp_core_delete_notifications_by_type(bp_loggedin_user_id(), $bp->follow->id, 'new_follow'); } }
/** * Sets up the Achievement Directory page * * @global object $bp BuddyPress global settings * @global bool $is_member_page If we are under anything with a members slug * @since 2.0 */ function dpa_setup_nav_directory() { global $bp, $is_member_page; if (bp_is_current_component($bp->achievements->slug) && !$bp->current_action && !$bp->current_item && !$is_member_page) { $bp->is_directory = true; if ($bp->loggedin_user->id) { bp_core_delete_notifications_by_type($bp->loggedin_user->id, $bp->achievements->id, 'new_achievement'); } do_action('dpa_setup_nav_directory'); bp_core_load_template(apply_filters('achievements_template_directory', 'achievements/index')); return; } }
/** * Remove a screen notification for a user. */ function bp_em_remove_screen_notifications() { global $bp; bp_core_delete_notifications_by_type($bp->loggedin_user->id, $bp->events->slug, 'attending'); }
function bp_checkins_my_places() { if (isset($_GET['n'])) { bp_core_delete_notifications_by_type(bp_loggedin_user_id(), 'checkins', 'new_comment'); } bp_core_load_template(apply_filters('bp_checkins_my_places', 'bp-checkins-my-places')); if (!bp_checkins_is_bp_default()) { add_filter('bp_get_template_part', 'bp_checkins_user_places_template_part', 10, 3); } }