Exemple #1
0
function ajax_navigation_func()
{
    $notifyAmount = bp_notifications_get_unread_notification_count(bp_loggedin_user_id());
    $messageAmount = messages_get_unread_count();
    $friendRequests = bp_friend_get_total_requests_count();
    $groups = groups_get_invites_for_user(bp_loggedin_user_id());
    $groupInvites = $groups['total'];
    $navigationData = array('notifyAmount' => $notifyAmount, 'messageAmount' => $messageAmount, 'friendRequests' => $friendRequests, 'groupInvites' => $groupInvites);
    echo json_encode($navigationData);
    die;
}
/**
 * Output the total friendship request count for a given user.
 *
 * @see bp_friend_get_total_requests_count() for description of arguments.
 *
 * @param int $user_id See {@link bp_friend_get_total_requests_count().
 */
function bp_friend_total_requests_count($user_id = 0)
{
    echo bp_friend_get_total_requests_count($user_id);
}
/**
 * Sending a heartbeat for notification updates
 * 
 * @since Boss 1.0.0 
 *
 */
function buddyboss_notification_count_heartbeat($response, $data, $screen_id)
{
    if (function_exists("bp_friend_get_total_requests_count")) {
        $friend_request_count = bp_friend_get_total_requests_count();
    }
    if (function_exists("bp_notifications_get_all_notifications_for_user")) {
        $notifications = bp_notifications_get_all_notifications_for_user(get_current_user_id());
    }
    $notification_count = count($notifications);
    if (function_exists("bp_notifications_get_all_notifications_for_user")) {
        $notifications = bp_notifications_get_notifications_for_user(get_current_user_id());
        foreach ((array) $notifications as $notification) {
            $notification_content .= $notification;
        }
        if (empty($notification_content)) {
            $notification_content = '<a href="' . bp_loggedin_user_domain() . '' . BP_NOTIFICATIONS_SLUG . '/">' . __("No new notifications", "buddypress") . '</a>';
        }
    }
    if (function_exists("messages_get_unread_count")) {
        $unread_message_count = messages_get_unread_count();
    }
    $response['bb_notification_count'] = array('friend_request' => @intval($friend_request_count), 'notification' => @intval($notification_count), 'notification_content' => @$notification_content, 'unread_message' => @intval($unread_message_count));
    return $response;
}