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/BoardController.php +39 -4 2.0.152.1.0 View file →
@@ -350,8 +350,10 @@
350 350 if (!empty($backgroundData)) {
351 351 $boardData['background'] = $backgroundData;
352 352 }
353 353
354 + $this->validateRequestedLabelPresets($request->get('labels'));
355 +
354 356 $board = $this->boardService->createBoard($boardData);
355 357 $this->createBoardLabelsFromRequest($request, $board->id);
356 358 $this->addBoardMembersFromRequest($request, $board->id);
357 359 $type = ucfirst($boardData['type']);
@@ -445,20 +447,53 @@
445 447
446 448 foreach ($labels as $label) {
447 449 $labelData = Helper::sanitizeLabel((array) $label);
448 450
449 - if (empty($labelData['label']) && empty($labelData['bg_color'])) {
451 + if (empty($labelData['label']) && empty($labelData['bg_color']) && empty($labelData['color_preset'])) {
450 452 continue;
451 453 }
452 454
453 - $this->labelService->createLabel([
455 + $labelPayload = [
454 456 'label' => $labelData['label'] ?? '',
455 457 'bg_color' => $labelData['bg_color'] ?? '#f3f4f6',
456 458 'color' => $labelData['color'] ?? '#1B2533',
457 - ], $boardId);
459 + ];
460 +
461 + if (array_key_exists('color_preset', $labelData)) {
462 + $labelPayload['color_preset'] = $labelData['color_preset'];
463 + }
464 +
465 + $this->labelService->createLabel($labelPayload, $boardId);
458 466 }
459 467 }
460 468
469 + /**
470 + * Reject unsupported label preset ids before creating any board records.
471 + *
472 + * @param mixed $labels
473 + * @return void
474 + * @throws \Exception
475 + */
476 + private function validateRequestedLabelPresets($labels)
477 + {
478 + if (!is_array($labels)) {
479 + return;
480 + }
481 +
482 + foreach ($labels as $label) {
483 + $labelData = Helper::sanitizeLabel((array) $label);
484 + $presetId = $labelData[Constant::LABEL_COLOR_PRESET_SETTING] ?? null;
485 +
486 + if ($presetId === null || $presetId === '') {
487 + continue;
488 + }
489 +
490 + if (!is_string($presetId) || !Constant::getLabelColorPreset($presetId)) {
491 + throw new \Exception(esc_html__('Invalid label color preset', 'fluent-boards'));
492 + }
493 + }
494 + }
495 +
461 496 private function addBoardMembersFromRequest(Request $request, $boardId)
462 497 {
463 498 $memberIds = $request->get('member_ids');
464 499
@@ -532,8 +567,9 @@
532 567 $this->boardService->updateRecentBoards($board_id);
533 568
534 569 $board->labelColor = Constant::TRELLO_COLOR_MAP;
535 570 $board->labelColorText = Constant::TEXT_COLOR_MAP;
571 + $board->labelColorPresets = Constant::LABEL_COLOR_PRESETS;
536 572
537 573 $board->users = Helper::sanitizeUserCollections($board->users);
538 574 $board->owner = Helper::sanitizeUserCollections($board->owner);
539 575
@@ -722,9 +758,8 @@
722 758
723 759 $formattedUsers[] = [
724 760 'ID' => $user->ID,
725 761 'display_name' => $name,
726 - 'user_login' => $user->user_login,
727 762 'email' => $user->user_email,
728 763 'photo' => fluent_boards_user_avatar($user->user_email, $name),
729 764 'role' => $this->boardUserRole($boardRelation),
730 765 'is_super' => in_array($user->ID, $superAdminIds),