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 +64 -9 2.0.02.1.0 View file →
@@ -228,9 +228,12 @@
228 228 {
229 229 $boards = $this->boardService->getRecentBoards();
230 230
231 231 if (!$boards || $boards->isEmpty()) {
232 - $boards = Board::where('type', 'to-do')->excludeTemplates()->byAccessUser(get_current_user_id())
232 + $boards = Board::whereNull('archived_at')
233 + ->excludeTemplates()
234 + ->availableInCurrentInstall()
235 + ->byAccessUser(get_current_user_id())
233 236 ->limit(4)
234 237 ->withCount('completedTasks')
235 238 ->with(['stages', 'users'])
236 239 ->get();
@@ -347,8 +350,10 @@
347 350 if (!empty($backgroundData)) {
348 351 $boardData['background'] = $backgroundData;
349 352 }
350 353
354 + $this->validateRequestedLabelPresets($request->get('labels'));
355 +
351 356 $board = $this->boardService->createBoard($boardData);
352 357 $this->createBoardLabelsFromRequest($request, $board->id);
353 358 $this->addBoardMembersFromRequest($request, $board->id);
354 359 $type = ucfirst($boardData['type']);
@@ -442,20 +447,53 @@
442 447
443 448 foreach ($labels as $label) {
444 449 $labelData = Helper::sanitizeLabel((array) $label);
445 450
446 - if (empty($labelData['label']) && empty($labelData['bg_color'])) {
451 + if (empty($labelData['label']) && empty($labelData['bg_color']) && empty($labelData['color_preset'])) {
447 452 continue;
448 453 }
449 454
450 - $this->labelService->createLabel([
455 + $labelPayload = [
451 456 'label' => $labelData['label'] ?? '',
452 457 'bg_color' => $labelData['bg_color'] ?? '#f3f4f6',
453 458 'color' => $labelData['color'] ?? '#1B2533',
454 - ], $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);
455 466 }
456 467 }
457 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 +
458 496 private function addBoardMembersFromRequest(Request $request, $boardId)
459 497 {
460 498 $memberIds = $request->get('member_ids');
461 499
@@ -529,8 +567,9 @@
529 567 $this->boardService->updateRecentBoards($board_id);
530 568
531 569 $board->labelColor = Constant::TRELLO_COLOR_MAP;
532 570 $board->labelColorText = Constant::TEXT_COLOR_MAP;
571 + $board->labelColorPresets = Constant::LABEL_COLOR_PRESETS;
533 572
534 573 $board->users = Helper::sanitizeUserCollections($board->users);
535 574 $board->owner = Helper::sanitizeUserCollections($board->owner);
536 575
@@ -545,8 +584,18 @@
545 584 }
546 585
547 586 public function update(Request $request, $board_id)
548 587 {
588 + // Board identity (title/description) is manager-only. This action shares the
589 + // `update` name with CommentController@update under the same policy group, so the
590 + // guard lives here rather than in a SingleBoardPolicy::update() method that would
591 + // also block ordinary members from editing their own comments.
592 + if (!PermissionManager::isBoardManager(absint($board_id))) {
593 + return $this->sendError([
594 + 'message' => __('You do not have permission to edit this board.', 'fluent-boards'),
595 + ], 403);
596 + }
597 +
549 598 $boardData = $this->boardSanitizeAndValidate($request->only(['title', 'description']), [
550 599 'title' => 'required|string',
551 600 'description' => 'nullable|string',
552 601 ]);
@@ -709,9 +758,8 @@
709 758
710 759 $formattedUsers[] = [
711 760 'ID' => $user->ID,
712 761 'display_name' => $name,
713 - 'user_login' => $user->user_login,
714 762 'email' => $user->user_email,
715 763 'photo' => fluent_boards_user_avatar($user->user_email, $name),
716 764 'role' => $this->boardUserRole($boardRelation),
717 765 'is_super' => in_array($user->ID, $superAdminIds),
@@ -800,15 +848,22 @@
800 848 }
801 849
802 850 public function addMembersInBoard(Request $request, $board_id)
803 851 {
804 - $memberId = $request->getSafe('memberId');
805 - $isViewerOnly = $request->getSafe('isViewerOnly');
852 + $memberId = $request->getSafe('memberId', 'intval');
853 + $isViewerOnly = $request->getSafe('isViewerOnly', 'sanitize_text_field');
806 854 $member = $this->boardService->addMembersInBoard($board_id, $memberId, $isViewerOnly);
855 +
856 + if ($member === null) {
857 + return $this->sendError([
858 + 'message' => __('User not found.', 'fluent-boards'),
859 + ], 404);
860 + }
861 +
807 862 if (!$member) {
808 863 return $this->sendError([
809 864 'message' => __('User already a member', 'fluent-boards'),
810 - ], 304);
865 + ], 409);
811 866 }
812 867
813 868
814 869 return [
@@ -932,9 +987,9 @@
932 987 'reset' => true,
933 988 ];
934 989 } elseif ($request->image_url) {
935 990 $backgroundData = $this->boardSanitizeAndValidate($request->all(), [
936 - "id" => 'required',
991 + 'id' => 'required|integer',
937 992 'image_url' => 'required|string|url',
938 993 ]);
939 994 } elseif ($request->color) {
940 995 $backgroundData = $this->boardSanitizeAndValidate($request->all(), [