|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
class NotificationController extends BaseController { |
|
4
|
|
|
|
|
5
|
|
|
public function unread_notifications() { |
|
6
|
|
|
$type = Input::get('data'); //type to indicate whether global,task or message notification |
|
|
|
|
|
|
7
|
|
|
/* |
|
8
|
|
|
* get notofications,task notifications,global notifications contents ... |
|
9
|
|
|
*/ |
|
10
|
|
|
if ($type == "messages") { |
|
11
|
|
|
$unReadMessages = DB::table('messages') |
|
12
|
|
|
->select(DB::raw('count(from_user_id) as fromCount'), 'personal_conversations.*','team_channels.id as team_id', 'messages.*', 'users_from.first_name as from_first_name', 'users_from.first_name as from_last_name') |
|
13
|
|
|
->leftJoin('personal_conversations', 'messages.id', '=', 'personal_conversations.message_id') |
|
14
|
|
|
->leftJoin('team_channels', 'team_channels.id', '=', 'personal_conversations.team_channel_id') |
|
15
|
|
|
->leftJoin('users as users_from', 'users_from.id', '=', 'personal_conversations.from_user_id') |
|
16
|
|
|
->where('personal_conversations.read_status', '=', 1) |
|
17
|
|
|
->where('personal_conversations.to_user_id', '=', Auth::user()->id)->groupBy('from_user_id')->orderBy('messages.id', 'desc')->get(); |
|
18
|
|
|
$unReadMessages = array_reverse($unReadMessages); |
|
19
|
|
|
|
|
20
|
|
|
$data = array($unReadMessages, "type" => $type); |
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
|
|
if ($type == "general") { |
|
24
|
|
|
$unReadGeneralMessages = DB::table('team_conversations_read_status') |
|
25
|
|
|
->select(DB::raw('count(team_conversations_read_status.message_id) as messageCount'), 'team_channels.channel_view_name', 'team_channels.id') |
|
26
|
|
|
->leftJoin('team_channels', 'team_channels.id', '=', 'team_conversations_read_status.team_channel_id') |
|
27
|
|
|
->where('team_conversations_read_status.user_id', '=', Auth::user()->id) |
|
28
|
|
|
->where('team_conversations_read_status.read_status', '=', 1) |
|
29
|
|
|
->groupBy('team_channels.channel_view_name')->orderBy('team_conversations_read_status.message_id', 'desc')->get(); |
|
30
|
|
|
$unReadGeneralMessages = array_reverse($unReadGeneralMessages); |
|
31
|
|
|
|
|
32
|
|
|
$data = array($unReadGeneralMessages, "type" => $type); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
if ($type == "join") { |
|
36
|
|
|
$unReadJoinMessages = DB::table('invitation_notification') |
|
37
|
|
|
->select(DB::raw('count(invitation_notification.new_user) as userCount'), 'team_channels.channel_view_name', 'team_channels.team_channel_id', 'users.first_name', 'users.last_name', 'users.id as user_id', 'team_channels.id as team_id') |
|
38
|
|
|
->leftJoin('team_channels', 'team_channels.id', '=', 'invitation_notification.team_id') |
|
39
|
|
|
->leftJoin('users', 'users.id', '=', 'invitation_notification.new_user') |
|
40
|
|
|
->where('invitation_notification.team_user', '=', Auth::user()->id) |
|
41
|
|
|
->where('invitation_notification.new_user', '!=', Auth::user()->id) |
|
42
|
|
|
->where('invitation_notification.read_status', '=', 1) |
|
43
|
|
|
->groupBy('invitation_notification.new_user') |
|
44
|
|
|
->orderBy('invitation_notification.created_at', 'desc')->get(); |
|
45
|
|
|
$unReadJoinMessages = array_reverse($unReadJoinMessages); |
|
46
|
|
|
|
|
47
|
|
|
$data = array($unReadJoinMessages, "type" => $type); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
return View::make('templates/notification_content')->with("data", $data); |
|
|
|
|
|
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
public function update_status() { |
|
54
|
|
|
$type = Input::get('data'); //type to indicate whether global,task or message notification |
|
55
|
|
|
|
|
56
|
|
|
switch ($type) { |
|
57
|
|
|
case "messages" : $fromUserId = Input::get('fromUserId'); |
|
58
|
|
|
$toUserId = Input::get('toUserId'); |
|
59
|
|
|
if ($type == "messages") { |
|
60
|
|
|
DB::table('personal_conversations') |
|
61
|
|
|
->where('from_user_id', $fromUserId) |
|
62
|
|
|
->where('to_user_id', $toUserId) |
|
63
|
|
|
->update(array('read_status' => 0)); |
|
64
|
|
|
} |
|
65
|
|
|
break; |
|
66
|
|
View Code Duplication |
case "general": |
|
|
|
|
|
|
67
|
|
|
$teamId = explode("_",Input::get('teamId')); |
|
68
|
|
|
|
|
69
|
|
|
DB::table('team_conversations_read_status') |
|
70
|
|
|
->where('user_id', Auth::user()->id) |
|
71
|
|
|
->where('team_channel_id', $teamId[1]) |
|
72
|
|
|
->update(array('read_status' => 0)); |
|
73
|
|
|
break; |
|
74
|
|
|
|
|
75
|
|
View Code Duplication |
case "join": |
|
|
|
|
|
|
76
|
|
|
$teamId = explode("_",Input::get('teamId')); |
|
77
|
|
|
|
|
78
|
|
|
DB::table('invitation_notification') |
|
79
|
|
|
->where('team_user', Auth::user()->id) |
|
80
|
|
|
->where('team_id', $teamId[1]) |
|
81
|
|
|
->where('new_user', $teamId[0]) |
|
82
|
|
|
->update(array('read_status' => 0)); |
|
83
|
|
|
} |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
} |
|
87
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths