function luna_ajax_fetch_notifications() { if (empty($_POST['_nonce'])) { luna_send_json_error(-1); } $response = array(); if (false === LunaNonces::verify($_POST['_nonce'], 'fetch-notifications-nonce')) { $response['nonces_expired'] = true; luna_send_json($response); } global $luna_user; $notifications = get_user_unviewed_notifications($luna_user['id']); if (!empty($notifications)) { luna_send_json_success($notifications); } luna_send_json_error(); }
if (!$db->num_rows($result)) { message(__('Bad request. The link you followed is incorrect, outdated or you are simply not allowed to hang around here.', 'luna'), false, '404 Not Found'); } $user = $db->fetch_assoc($result); $user_username = luna_htmlspecialchars($user['username']); $avatar_field = generate_avatar_markup($id); $avatar_user_card = draw_user_avatar($id); if ($action == 'readnoti') { set_user_notifications_viewed($id); confirm_referrer('notifications.php'); redirect('notifications.php?id=' . $id); } elseif ($action == 'delnoti') { delete_user_notifications($id, $viewed = 1); confirm_referrer('notifications.php'); redirect('notifications.php?id=' . $id); } $viewed_notifications = array(); $unviewed_notifications = array(); $num_viewed = has_viewed_notifications(); $num_unviewed = has_unviewed_notifications(); if ($num_viewed) { $viewed_notifications = get_user_viewed_notifications(); } if ($num_unviewed) { $unviewed_notifications = get_user_unviewed_notifications(); } $page_title = array(luna_htmlspecialchars($luna_config['o_board_title']) . ' / ' . __('Profile', 'luna')); define('FORUM_ACTIVE_PAGE', 'me'); require load_page('header.php'); require load_page('notifications.php'); require load_page('footer.php');