PluginProbe
FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration / 1.91.6
FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration v1.91.6
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 / Services / Intergrations / FluentCRM / DeepIntegration.php

DeepIntegration.php in FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration 1.91.6, at app/Services/Intergrations/FluentCRM/DeepIntegration.php

83 lines 2.3 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\Services\Intergrations\FluentCRM;
4
5
6 use FluentBoards\App\Models\Board;
7 use FluentBoards\App\Models\Task;
8 use FluentBoards\App\Models\TaskMeta;
9 use FluentBoards\App\Models\User;
10 use FluentBoards\App\Services\PermissionManager;
11
12 class DeepIntegration
13 {
14 public function init()
15 {
16 add_filter('fluentcrm_ajax_options_boards', [$this, 'getBoards'], 10, 3);
17 add_filter('fluentcrm_ajax_options_task_templates', [$this, 'getTaskTemplates'], 10, 3);
18 }
19
20 public function getBoards($records, $search, $includeIds)
21 {
22 $query = Board::select(['id', 'title']);
23
24 if (!empty($search)) {
25 $query->where('title', 'like', "%$search%");
26 }
27
28 $boards = $query->orderBy('title', 'ASC')->get();
29
30 return $this->getFormattedBoards($boards);
31 }
32
33 public function getFormattedBoards($boards)
34 {
35 $formattedBoards = [];
36 foreach ($boards as $board) {
37 $formattedBoards[] = [
38 'id' => strval($board->id),
39 'title' => $board->title
40 ];
41 }
42 return $formattedBoards;
43 }
44
45 public function getTaskTemplates($records, $search, $includeIds)
46 {
47 if (!defined('FLUENT_BOARDS_PRO')) {
48 return [];
49 }
50
51 $userId = get_current_user_id();
52 $currentUser = User::find($userId);
53
54 $relatedBoardsQuery = Board::query();
55
56 if (!PermissionManager::isAdmin($userId)) {
57 $relatedBoardsQuery->whereIn('id', $currentUser->whichBoards->pluck('id'));
58 }
59
60 $templateTaskIds = TaskMeta::where('key', 'is_template')->where('value', 'yes')->pluck('task_id');
61 $query = Task::whereIn('id', $templateTaskIds)
62 ->where('archived_at', null)
63 ->whereIn('board_id', $relatedBoardsQuery->pluck('id'))
64 ->with('assignees', 'labels');
65
66
67 if (!empty($search)) {
68 $query->where('title', 'like', "%$search%");
69 }
70
71 $templateTasks = $query->orderBy('title', 'ASC')->get();
72
73 $formattedTemplateTasks = [];
74 foreach ($templateTasks as $task) {
75 $formattedTemplateTasks[] = [
76 'id' => strval($task->id),
77 'title' => $task->title
78 ];
79 }
80 return $formattedTemplateTasks;
81 }
82 }
83