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/Modules/MCP/Tools/BoardTools.php +42 -0 2.0.12.1.0 View file →
@@ -5,8 +5,9 @@
5 5 use FluentBoards\App\Models\Board;
6 6 use FluentBoards\App\Models\Stage;
7 7 use FluentBoards\App\Modules\MCP\Helpers\MCPHelper;
8 8 use FluentBoards\App\Services\BoardService;
9 +use FluentBoards\App\Services\Constant;
9 10 use FluentBoards\App\Services\FolderService;
10 11 use FluentBoards\App\Services\Helper;
11 12 use FluentBoards\App\Services\LabelService;
12 13 use FluentBoards\App\Services\PermissionManager;
@@ -118,8 +119,13 @@
118 119 if (is_wp_error($memberIds)) {
119 120 return $memberIds;
120 121 }
121 122
123 + $labelPresetValidation = self::validateLabelPresets($params['labels'] ?? null);
124 + if (is_wp_error($labelPresetValidation)) {
125 + return $labelPresetValidation;
126 + }
127 +
122 128 $description = isset($params['description']) ? MCPHelper::sanitizeMarkdown($params['description']) : '';
123 129
124 130 $boardData = Helper::sanitizeBoard([
125 131 'title' => $title,
@@ -342,8 +348,9 @@
342 348 $labelData = Helper::sanitizeLabel([
343 349 'label' => $label['title'] ?? ($label['label'] ?? ''),
344 350 'bg_color' => $label['bg_color'] ?? '',
345 351 'color' => $label['color'] ?? '',
352 + 'color_preset' => $label['color_preset'] ?? '',
346 353 ]);
347 354
348 355 if (empty($labelData['label']) && empty($labelData['bg_color'])) {
349 356 continue;
@@ -352,10 +359,45 @@
352 359 $labelService->createLabel([
353 360 'label' => $labelData['label'] ?? '',
354 361 'bg_color' => !empty($labelData['bg_color']) ? $labelData['bg_color'] : '#f3f4f6',
355 362 'color' => !empty($labelData['color']) ? $labelData['color'] : '#1B2533',
363 + 'color_preset' => $labelData['color_preset'] ?? '',
356 364 ], $boardId);
357 365 }
366 + }
367 +
368 + /**
369 + * Validate label preset ids before the board is persisted.
370 + *
371 + * @param mixed $labels
372 + * @return true|\WP_Error
373 + */
374 + private static function validateLabelPresets($labels)
375 + {
376 + if (!is_array($labels)) {
377 + return true;
378 + }
379 +
380 + foreach ($labels as $label) {
381 + if (!is_array($label)) {
382 + continue;
383 + }
384 +
385 + $labelData = Helper::sanitizeLabel([
386 + Constant::LABEL_COLOR_PRESET_SETTING => $label[Constant::LABEL_COLOR_PRESET_SETTING] ?? null,
387 + ]);
388 + $presetId = $labelData[Constant::LABEL_COLOR_PRESET_SETTING] ?? null;
389 +
390 + if ($presetId === null || $presetId === '') {
391 + continue;
392 + }
393 +
394 + if (!is_string($presetId) || !Constant::getLabelColorPreset($presetId)) {
395 + return MCPHelper::error('invalid_param', __('Invalid label color preset', 'fluent-boards'));
396 + }
397 + }
398 +
399 + return true;
358 400 }
359 401
360 402 private static function addBoardMembers($boardService, $boardId, $memberIds)
361 403 {