PluginProbe
FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration / 2.1.0
FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration v2.1.0
2.1.0 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 All 42 releases
← All changes | app/Http/Controllers/LabelController.php +40 -32 1.122.1.0 View file →
@@ -19,8 +19,9 @@
19 19 }
20 20
21 21 public function getLabelsByBoard($board_id)
22 22 {
23 + $board_id = absint($board_id);
23 24 try {
24 25 $labels = $this->labelService->getLabelsByBoard($board_id);
25 26
26 27 return $this->sendSuccess([
@@ -26,14 +27,15 @@
26 27 return $this->sendSuccess([
27 28 'labels' => $labels,
28 29 ], 200);
29 30 } catch(\Exception $e) {
30 - return $this->sendError($e->getMessage(), 404);
31 + return $this->sendError($e->getMessage(), 400);
31 32 }
32 33 }
33 34
34 35 public function getLabelsByBoardUsedInTasks($board_id)
35 36 {
37 + $board_id = absint($board_id);
36 38 try {
37 39 $labels = $this->labelService->getLabelsByBoardUsedInTasks($board_id);
38 40
39 41 return $this->sendSuccess([
@@ -39,23 +41,27 @@
39 41 return $this->sendSuccess([
40 42 'labels' => $labels,
41 43 ], 200);
42 44 } catch(\Exception $e) {
43 - return $this->sendError($e->getMessage(), 404);
45 + return $this->sendError($e->getMessage(), 400);
44 46 }
45 47 }
46 48
47 49 public function createLabel(Request $request, $board_id)
48 50 {
49 - $labelData = $this->labelSanitizeAndValidate($request->all(), [
50 - 'bg_color' => 'required|string',
51 - 'color' => 'required|string',
51 + $board_id = absint($board_id);
52 + $labelData = Helper::sanitizeLabel($request->only(['bg_color', 'color', 'color_preset', 'label']));
53 + $hasPreset = !empty($labelData['color_preset']);
54 + $labelData = $this->validate($labelData, [
55 + 'bg_color' => $hasPreset ? 'nullable|string' : 'required|string',
56 + 'color' => $hasPreset ? 'nullable|string' : 'required|string',
57 + 'color_preset' => 'nullable|string',
52 58 'label' => 'nullable|string',
53 59 ]);
54 60
55 61 try {
56 62 $label = $this->labelService->createLabel($labelData, $board_id);
57 - do_action('fluent_boards/board_label', $label, Constant::ACTIVITY_ACTION_CREATED);
63 + do_action('fluent_boards/board_label_created', $label);
58 64
59 65 return $this->sendSuccess([
60 66 'message' => __('Label has been created', 'fluent-boards'),
61 67 'label' => $label,
@@ -66,20 +72,20 @@
66 72 }
67 73
68 74 public function createLabelForTask(Request $request, $board_id)
69 75 {
76 + $board_id = absint($board_id);
70 77 $requestData = [
71 - 'task_id' => $request->taskId,
72 - 'boardTerm_id' => (int) $request->labelId,
78 + 'task_id' => $request->getSafe('taskId', 'intval'),
79 + 'board_term_id' => $request->getSafe('labelId', 'intval'),
73 80 ];
74 81
75 82 $labelData = $this->labelSanitizeAndValidate($requestData, [
76 83 'task_id' => 'required|integer',
77 - 'boardTerm_id' => 'required|integer',
84 + 'board_term_id' => 'required|integer',
78 85 ]);
79 86 try {
80 - $label = $this->labelService->createLabelForTask($labelData);
81 -// do_action('fluent_boards/label_manage_for_task_activity', $label->task_id, 'added');
87 + $label = $this->labelService->createLabelForTask($labelData, $board_id);
82 88
83 89 return $this->sendSuccess([
84 90 'message' => __('Label has been added', 'fluent-boards'),
85 91 'label' => $label,
@@ -90,27 +96,32 @@
90 96 }
91 97
92 98 public function getLabelsByTask($board_id, $task_id)
93 99 {
100 + $board_id = absint($board_id);
101 + $task_id = absint($task_id);
94 102 try {
95 - $labels = $this->labelService->getLabelsByTask($task_id);
103 + $labels = $this->labelService->getLabelsByTask($task_id, $board_id);
96 104
97 105 return $this->sendSuccess([
98 106 'labels' => $labels,
99 107 ], 200);
100 108 } catch(\Exception $e) {
101 - return $this->sendError($e->getMessage(), 404);
109 + return $this->sendError($e->getMessage(), 400);
102 110 }
103 111 }
104 112
105 113 public function deleteLabelOfTask($board_id, $task_id, $label_id)
106 114 {
115 + $board_id = absint($board_id);
116 + $task_id = absint($task_id);
117 + $label_id = absint($label_id);
107 118 try {
108 - $this->labelService->deleteLabelOfTask($task_id, $label_id);
119 + $this->labelService->deleteLabelOfTask($task_id, $label_id, $board_id);
109 120
110 121 return $this->sendSuccess([
111 122 'message' => __('Label has been deleted', 'fluent-boards'),
112 - ], 201);
123 + ], 200);
113 124 } catch (\Exception $e) {
114 125 return $this->sendError($e->getMessage(), 400);
115 126 }
116 127 }
@@ -116,25 +127,17 @@
116 127 }
117 128
118 129 public function deleteLabelOfBoard($board_id, $label_id)
119 130 {
131 + $board_id = absint($board_id);
132 + $label_id = absint($label_id);
120 133 try {
134 + $this->labelService->deleteLabelOfBoard($label_id, $board_id);
121 135
122 - $label = Label::findOrFail($label_id);
123 -
124 - if (count($label->tasks) > 0) {
125 - return $this->sendError([
126 - 'message' => __("You can't delete. This label used in task.", 'fluent-boards'),
127 - 'type' => 'warning',
128 - ]);
129 - }
130 -
131 - $this->labelService->deleteLabelOfBoard($label_id);
132 -
133 136 return $this->sendSuccess([
134 137 'message' => __('Label has been deleted', 'fluent-boards'),
135 138 'type' => 'success',
136 - ], 201);
139 + ], 200);
137 140 } catch (\Exception $e) {
138 141 return $this->sendError($e->getMessage(), 400);
139 142 }
140 143 }
@@ -140,16 +143,21 @@
140 143 }
141 144
142 145 public function editLabelofBoard(Request $request, $board_id, $label_id)
143 146 {
144 - $labelData = $this->labelSanitizeAndValidate($request->all(), [
145 - 'bg_color' => 'required|string',
146 - 'color' => 'required|string',
147 + $board_id = absint($board_id);
148 + $label_id = absint($label_id);
149 + $labelData = Helper::sanitizeLabel($request->only(['bg_color', 'color', 'color_preset', 'label']));
150 + $isCustomSelection = array_key_exists('color_preset', $labelData) && $labelData['color_preset'] === '';
151 + $labelData = $this->validate($labelData, [
152 + 'bg_color' => $isCustomSelection ? 'required|string' : 'nullable|string',
153 + 'color' => $isCustomSelection ? 'required|string' : 'nullable|string',
154 + 'color_preset' => 'nullable|string',
147 155 'label' => 'nullable|string',
148 156 ]);
149 157 try {
150 - $label = $this->labelService->editLabelofBoard($labelData, $label_id);
151 - do_action('fluent_boards/board_label', $label, Constant::ACTIVITY_ACTION_UPDATED);
158 + $label = $this->labelService->editLabelofBoard($labelData, $label_id, $board_id);
159 + do_action('fluent_boards/board_label_updated', $label);
152 160
153 161 return $this->sendSuccess([
154 162 'message' => __('Label has been updated', 'fluent-boards'),
155 163 'label' => $label,