forked from buckyroberts/Social-Network
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotification_object.php
More file actions
45 lines (40 loc) · 1.69 KB
/
Copy pathnotification_object.php
File metadata and controls
45 lines (40 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
require(dirname(__FILE__) . '/includes/bootstrap.php');
if(!($userID = buckys_is_logged_in())){
echo MSG_INVALID_REQUEST;
exit;
}
$notificationLimit = 5;
//This module will make the notifications as read.
$result = ['success' => 1, 'content' => ''];
$type = isset($_REQUEST['type']) ? strtolower($_REQUEST['type']) : null;
if(isset($_POST['action']) && $_POST['action'] == 'read'){
switch($type){
case 'my':
BuckysActivity::markReadNotifications($userID);
$notiData = BuckysActivity::getNotifications($userID, $notificationLimit, 0);
$result['content'] = render_footer_link_content($type, $notiData, false);
break;
case 'forum':
BuckysForumNotification::makeNotificationsToRead($userID);
$notiData = BuckysForumNotification::getNewNotifications($userID, 0, $notificationLimit);
$result['content'] = render_footer_link_content($type, $notiData, false);
break;
case 'trade':
$tradeNotiIns = new BuckysTradeNotification();
$tradeNotiIns->markAsRead($userID);
$notiData = $tradeNotiIns->getReceivedMessages($userID, null, 0, $notificationLimit);
$result['content'] = render_footer_link_content($type, $notiData, false);
break;
case 'shop':
$shopNotiIns = new BuckysShopNotification();
$shopNotiIns->markAsRead($userID);
$notiData = $shopNotiIns->getReceivedMessages($userID, null, 0, $notificationLimit);
$result['content'] = render_footer_link_content($type, $notiData, false);
break;
}
echo json_encode($result);
exit;
}
echo MSG_INVALID_REQUEST;
exit;