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 / UserController.php

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

135 lines 4.1 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\Models\Board;
6 use FluentBoards\App\Models\User;
7 use FluentBoards\App\Services\Helper;
8 use FluentBoards\App\Services\PermissionManager;
9 use FluentBoards\App\Services\UserService;
10 use FluentBoards\Framework\Http\Request\Request;
11 use FluentCrm\App\Models\Subscriber;
12
13
14 class UserController extends Controller
15 {
16 private UserService $userService;
17
18 public function __construct(UserService $userService)
19 {
20 parent::__construct();
21 $this->userService = $userService;
22 }
23
24 public function allFluentBoardsUsers()
25 {
26 return [
27 'users' => $this->userService->allFluentBoardsUsers(),
28 'boards' => Board::select('id', 'title')->orderBy('title', 'ASC')->get()
29 ];
30 }
31
32 public function memberAssociatedTaskUsers($user_id)
33 {
34 try {
35 $uniqueUsers = $this->userService->memberAssociatedTaskUsers($user_id);
36
37 return $this->sendSuccess([
38 'users' => $uniqueUsers['uniqueUsers'],
39 'userWiseBoardDesignation' => $uniqueUsers['userWiseBoardDesignation'],
40 ], 200);
41 } catch (\Exception $e) {
42 return $this->sendError($e->getMessage(), 404);
43 }
44 }
45
46 public function searchFluentBoardsUser(Request $request)
47 {
48 try {
49 $search_input = $request->searchInput . trim('');
50
51 $boardUsers = $this->userService->searchFluentBoardsUser($search_input);
52
53 return $this->sendSuccess($boardUsers, 200);
54 } catch (\Exception $e) {
55 return $this->sendError($e->getMessage(), 404);
56 }
57 }
58
59 public function searchMemberUser(Request $request, $user_id)
60 {
61 try {
62 $search_input = $request->searchInput . trim('');
63 $searchResult = $this->userService->searchMemberUser($search_input, $user_id);
64
65 return $this->sendSuccess([
66 'users' => $searchResult,
67 ], 200);
68 } catch (\Exception $e) {
69 return $this->sendError($e->getMessage(), 404);
70 }
71 }
72
73 public function getMemberAssociatedTasks(Request $request, $user_id)
74 {
75 $requestData = [
76 'page' =>$request->getSafe('page', 'intval'),
77 'taskType' => $request->getSafe('taskType', 'sanitize_text_field'),
78 'boardIds' => $boardIds = $request->getSafe('boardIds'),
79 'orderBy' => $request->getSafe('orderBy', 'sanitize_text_field'),
80 'order' => $request->getSafe('order', 'sanitize_text_field'),
81 ];
82 try {
83 return $this->sendSuccess(
84 $this->userService->getMemberAssociatedTasks($user_id, $requestData)
85 , 200);
86 } catch (\Exception $e) {
87 return $this->sendError($e->getMessage(), 404);
88 }
89 }
90
91 public function getMemberRelatedAcitivies(Request $request, $user_id)
92 {
93 $page = $request->getSafe('page');
94 try {
95 return $this->sendSuccess(
96 $this->userService->getMemberRelatedAcitivies($user_id, $page)
97 , 200);
98 } catch (\Exception $e) {
99 return $this->sendError($e->getMessage(), 404);
100 }
101 }
102
103 public function getMemberInfo($user_id)
104 {
105 $user = User::findOrFail($user_id);
106
107 $user = Helper::sanitizeUserCollections($user);
108
109 $user->fbs_role = PermissionManager::isFluentBoardsAdmin($user_id) ? 'fbs_admin' : 'member';
110
111 $user->is_wp_admin = user_can($user_id, 'manage_options') ? 'yes' : 'no';
112
113 if (defined('FLUENTCRM')) {
114 $subscriber = Subscriber::where('user_id', $user_id)->first();
115 $user->fluentcrm_subscriber = $subscriber ?? null;
116 }
117
118 return [
119 'user' => $user
120 ];
121 }
122
123 public function getMemberBoards($user_id)
124 {
125 try {
126 return $this->sendSuccess(
127 [
128 'boards' => $this->userService->getMemberBoards($user_id)
129 ], 200);
130 } catch (\Exception $e) {
131 return $this->sendError($e->getMessage(), 404);
132 }
133 }
134 }
135