PluginProbe
FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration / 1.21
FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration v1.21
2.0.15 2.0.12 2.0.10 2.0.4 2.0.1 2.0.0 1.95.3 1.95.2 1.95 1.91.6 trunk 1.11 1.12 1.13 1.20 1.21 1.22 1.23 1.30 1.31 1.32 1.35 1.40 1.41 1.45 All 41 releases
fluent-boards / app / Http / Controllers / NotificationController.php

NotificationController.php in FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration 1.21, at app/Http/Controllers/NotificationController.php

110 lines 3.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentBoards\App\Http\Controllers;
4
5 use FluentBoards\App\Services\NotificationService;
6 use FluentBoards\Framework\Http\Request\Request;
7
8 class NotificationController extends Controller
9 {
10 private $notificationService;
11
12 public function __construct(NotificationService $notificationService)
13 {
14 parent::__construct();
15 $this->notificationService = $notificationService;
16 }
17 public function getAllNotifications(Request $request)
18 {
19 $data = $request->all();
20 try {
21 $per_page = isset($data['per_page']) ? $data['per_page'] : 20;
22 $page = isset($data['page']) ? $data['page'] : 1;
23 $data = $this->notificationService->getAllNotifications($per_page, $page);
24
25 return $this->sendSuccess($data, 200);
26 } catch (\Exception $e) {
27 return $this->sendError($e->getMessage(), 404);
28 }
29 }
30 public function getAllUnreadNotifications(Request $request)
31 {
32 $data = $request->all();
33 try {
34 $per_page = isset($data['per_page']) ? $data['per_page'] : 20;
35 $page = isset($data['page']) ? $data['page'] : 1;
36 return $this->sendSuccess(
37 $this->notificationService->getAllUnreadNotifications($per_page, $page),
38 200);
39 } catch (\Exception $e) {
40 return $this->sendError($e->getMessage(), 404);
41 }
42 }
43
44 public function newNotificationNumber()
45 {
46 try {
47 $unread_notifications = $this->notificationService->newNotificationNumber();
48
49 return $this->sendSuccess([
50 'total_unread' => $unread_notifications,
51 ], 200);
52 } catch (\Exception $e) {
53 return $this->sendError($e->getMessage(), 404);
54 }
55 }
56
57 public function getBoardNotificationSettings($board_id)
58 {
59 try {
60 $userId = get_current_user_id();
61 $currentSettings = [];
62 $boardSettings = $this->notificationService->getBoardNotificationSettingsOfUser($board_id, $userId);
63 if ($boardSettings && $boardSettings->preferences) {
64 $currentSettings = maybe_unserialize($boardSettings->preferences);
65 }
66
67 return $this->sendSuccess([
68 'currentSettings' => $currentSettings,
69 ], 200);
70 } catch (\Exception $e) {
71 return $this->sendError($e->getMessage(), 404);
72 }
73 }
74
75 public function updateBoardNotificationSettings(Request $request, $board_id)
76 {
77 try {
78 $newSettings = $request->get('updatedSettings');
79
80
81 $this->notificationService->updateBoardNotificationSettings($newSettings, $board_id);
82 return $this->sendSuccess([
83 'message' => __('Board notification settings has been updated', 'fluent-boards'),
84 ], 200);
85 } catch (\Exception $e) {
86 return $this->sendError($e->getMessage(), 404);
87 }
88 }
89
90 public function readNotification(Request $request)
91 {
92 try{
93 $notificationId = $request->getSafe('notification_id');
94
95 if ( $notificationId ) {
96 $notification = $this->notificationService->markNotificationRead( $notificationId );
97 } else {
98 $notification = $this->notificationService->markAllRead();
99 }
100
101 return $this->sendSuccess([
102 'message' => __('Notification is updated', 'fluent-boards'),
103 'notification' => $notification
104 ], 200);
105
106 } catch (\Exception $e) {
107 return $this->sendError($e->getMessage(), 404);
108 }
109 }
110 }