PluginProbe
FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration / 1.13
FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration v1.13
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
fluent-boards / app / Api / Classes / Boards.php

Boards.php in FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration 1.13, at app/Api/Classes/Boards.php

119 lines 2.7 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\Api\Classes;
4
5 defined('ABSPATH') || exit;
6
7 use FluentBoards\App\Models\Board;
8 use FluentBoards\App\Services\BoardService;
9 use FluentBoards\App\Services\Helper;
10 use FluentBoards\App\Services\PermissionManager;
11 use FluentBoards\App\Services\StageService;
12 use FluentBoards\App\Services\LabelService;
13 use FluentBoards\Framework\Support\Arr;
14
15
16 /**
17 * Contacts Class - PHP APi Wrapper
18 *
19 * Contacts API Wrapper Class that can be used as <code>FluentBoardsApi('boards')</code> to get the class instance
20 *
21 * @package FluentBoards\App\Api\Classes
22 * @namespace FluentBoards\App\Api\Classes
23 *
24 * @version 1.0.0
25 */
26 class Boards
27 {
28 private $instance = null;
29
30 private $allowedInstanceMethods = [
31 'all',
32 'get',
33 'find',
34 'first',
35 'paginate'
36 ];
37
38 public function __construct(Board $instance)
39 {
40 $this->instance = $instance;
41 }
42
43 /**
44 * Get Boards
45 *
46 * Use:
47 * <code>FluentBoardsApi('boards')->getBoards();</code>
48 *
49 * @param array $with
50 * @return array|Board Model
51 */
52 public function getBoards($with = [])
53 {
54 $userId = get_current_user_id();
55 $query = Board::where('type', 'to-do')->byAccessUser($userId);
56
57 if ($with) {
58 $query->with($with);
59 }
60
61 $boards = $query->get();
62 return $boards;
63 }
64
65 /**
66 * Get stages by board
67 *
68 * Use:
69 * <code>FluentBoardsApi('boards')->getStagesByBoard($board_id);</code>
70 *
71 * @param int|string $board_id
72 * @return array Model
73 */
74 public function getStagesByBoard($board_id)
75 {
76 if (empty($board_id)) {
77 return [];
78 }
79
80 return Board::with('stages')->where('id', $board_id)->get();
81 }
82
83 public function create($data)
84 {
85 if (empty($data['title'])) {
86 return false;
87 }
88
89 $boardData = $this->boardSanitizeAndValidate($data);
90
91 $boardService = new BoardService();
92 $labelService = new LabelService();
93 $stageService = new StageService();
94
95 $board = $boardService->createBoard($boardData);
96
97 if (!$board) {
98 return false;
99 }
100
101 $labelService->createDefaultLabel($board->id);
102 $stageService->createDefaultStages($board);
103
104 // if board is created from crm contact
105 if (isset($boardData['crm_contact_id'])) {
106 $boardService->updateAssociateMember($boardData['crm_contact_id'], $board->id);
107 }
108 do_action('fluent_boards/board_created', $board);
109
110 return $board;
111 }
112
113 private function boardSanitizeAndValidate($data)
114 {
115 return Helper::sanitizeBoard($data);
116 }
117
118 }
119