Esempio n. 1
0
function dln_get_notifications()
{
    if (!is_user_logged_in()) {
        return false;
    }
    $notifications = bp_notifications_get_notifications_for_user(bp_loggedin_user_id(), 'object');
    if (!$notifications) {
        return null;
    }
    // Assign notification type
    foreach ($notifications as $i => $nof) {
        if (isset($nof->id)) {
            $componen_actions = bp_notifications_get_notification($nof->id);
            switch ($componen_actions->component_name) {
                case 'messages':
                    $notifications[$i]->icon = 'ico-mail-send bgcolor-info';
                    break;
                case 'friends':
                    $notifications[$i]->icon = 'ico-user-plus bgcolor-success';
                    break;
                default:
                    $notifications[$i]->icon = 'ico-notification';
                    break;
            }
        }
    }
    return $notifications;
}
/**
 * Get a specific notification by its ID
 *
 * @deprecated Deprecated since BuddyPress 1.9.0. Use
 *  bp_notifications_get_notification() instead.
 *
 * @since BuddyPress (1.0)
 * @param int $id
 * @return BP_Core_Notification
 */
function bp_core_get_notification($id)
{
    // Bail if notifications is not active
    if (!bp_is_active('notifications')) {
        return false;
    }
    // Trigger the deprecated function notice
    _deprecated_function(__FUNCTION__, '1.9', 'bp_notifications_get_notification()');
    return bp_notifications_get_notification($id);
}
/**
 * Invalidates 'all_for_user_' cache when updating.
 *
 * @since BuddyPress (2.3.0)
 *
 * @param array $update_args See BP_Notifications_Notification::update() for description.
 * @param array $where_args  See BP_Notifications_Notification::update() for description.
 */
function bp_notifications_clear_all_for_user_cache_before_update($update_args, $where_args)
{
    // User ID is passed in where arugments
    if (!empty($where_args['user_id'])) {
        bp_notifications_clear_all_for_user_cache($where_args['user_id']);
        // Get user ID from Notification ID
    } elseif (!empty($where_args['id'])) {
        $n = bp_notifications_get_notification($where_args['id']);
        bp_notifications_clear_all_for_user_cache($n->user_id);
    }
}