← All changes
|
app/Services/Integrations/FluentBoards/Bootstrap.php
+18
-2
1.10.01
→
2.5.0
View file →
| @@ -9,8 +9,9 @@ | ||
| 9 | 9 | use FluentBoards\App\Models\Board; |
| 10 | 10 | use FluentBoards\App\Models\User; |
| 11 | 11 | use FluentBoards\App\Services\Constant; |
| 12 | 12 | use FluentBoards\App\Services\NotificationService; |
| 13 | +use FluentBoards\App\Services\PermissionManager as FluentBoardsPermission; | |
| 13 | 14 | use FluentBoards\App\Services\TaskService; |
| 14 | 15 | use FluentBooking\Framework\Support\Arr; |
| 15 | 16 | use FluentBooking\App\Http\Controllers\IntegrationManagerController; |
| 16 | 17 | |
| @@ -79,8 +80,9 @@ | ||
| 79 | 80 | 'description' => '', |
| 80 | 81 | 'position' => 'bottom', |
| 81 | 82 | 'due_at_type' => 'booking', |
| 82 | 83 | 'due_at_days' => 0, |
| 84 | + 'disable_auto_started_at' => false, | |
| 83 | 85 | 'enabled' => true |
| 84 | 86 | ]; |
| 85 | 87 | } |
| 86 | 88 | |
| @@ -179,8 +181,16 @@ | ||
| 179 | 181 | 'tips' => __('Set the due date by entering a number relative to the booking or meeting date. Positive for days after and negative for days before the booking or meeting date.', 'fluent-booking'), |
| 180 | 182 | 'component' => 'number' |
| 181 | 183 | ], |
| 182 | 184 | [ |
| 185 | + 'key' => 'disable_auto_started_at', | |
| 186 | + 'require_list' => false, | |
| 187 | + 'label' => __('Start Date', 'fluent-booking'), | |
| 188 | + 'component' => 'checkbox-single', | |
| 189 | + 'checkbox_label' => __('Do not set a start date on the task', 'fluent-booking'), | |
| 190 | + 'tips' => __('By default, the task start date is set to the booking creation time when a due date is present. Enable this to leave the start date empty.', 'fluent-booking'), | |
| 191 | + ], | |
| 192 | + [ | |
| 183 | 193 | 'key' => 'position', |
| 184 | 194 | 'label' => __('Task Position', 'fluent-booking'), |
| 185 | 195 | 'placeholder' => __('Position', 'fluent-booking'), |
| 186 | 196 | 'component' => 'radio_choice', |
| @@ -232,8 +242,12 @@ | ||
| 232 | 242 | public function getConfigFieldOptions($settings, $calendarEventId) |
| 233 | 243 | { |
| 234 | 244 | $boardId = Arr::get($settings, 'board_config.board_id'); |
| 235 | 245 | |
| 246 | + if ($boardId && !FluentBoardsPermission::userHasBoardPermission($boardId, 'GET')) { | |
| 247 | + $boardId = null; | |
| 248 | + } | |
| 249 | + | |
| 236 | 250 | $data = [ |
| 237 | 251 | 'board_id' => $this->getBoards(), |
| 238 | 252 | 'stage_id' => $boardId ? $this->getStages($boardId) : [], |
| 239 | 253 | 'label_ids' => $boardId ? $this->getBoardLabels($boardId) : [], |
| @@ -248,8 +262,9 @@ | ||
| 248 | 262 | |
| 249 | 263 | private function getBoards() |
| 250 | 264 | { |
| 251 | 265 | $boards = Board::whereNull('archived_at') |
| 266 | + ->whereIn('id', FluentBoardsPermission::getBoardIdsForUser()) | |
| 252 | 267 | ->select('id', 'title') |
| 253 | 268 | ->get(); |
| 254 | 269 | |
| 255 | 270 | $formattedBoards = $boards->mapWithKeys(function ($board) { |
| @@ -352,9 +367,9 @@ | ||
| 352 | 367 | } |
| 353 | 368 | |
| 354 | 369 | public function notify($feed, $booking, $calendarEvent) |
| 355 | 370 | { |
| 356 | - $validData = ['task_title', 'description', 'board_config', 'author_name', 'email', 'position', 'due_at_days', 'due_at_type']; | |
| 371 | + $validData = ['task_title', 'description', 'board_config', 'author_name', 'email', 'position', 'due_at_days', 'due_at_type', 'disable_auto_started_at']; | |
| 357 | 372 | $data = Arr::only($feed['processedValues'], $validData); |
| 358 | 373 | |
| 359 | 374 | $boardId = intval(Arr::get($data, 'board_config.board_id')); |
| 360 | 375 | $stageId = intval(Arr::get($data, 'board_config.stage_id')); |
| @@ -388,9 +403,10 @@ | ||
| 388 | 403 | 'due_at' => $this->convertDueDate($dueAtDays, $dueAtType, $booking->start_time), |
| 389 | 404 | 'source' => 'FluentBooking' |
| 390 | 405 | ]; |
| 391 | 406 | |
| 392 | - $data['started_at'] = $data['due_at'] ? gmdate('Y-m-d H:i:s', strtotime(current_time('mysql'))) : null; // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date | |
| 407 | + $disableAutoStartedAt = Arr::isTrue($feed['processedValues'], 'disable_auto_started_at'); | |
| 408 | + $data['started_at'] = (!$disableAutoStartedAt && $data['due_at']) ? gmdate('Y-m-d H:i:s', strtotime(current_time('mysql'))) : null; // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date | |
| 393 | 409 | |
| 394 | 410 | $existingUser = User::where('user_email', $authorEmail)->first(); |
| 395 | 411 | if ($existingUser) { |
| 396 | 412 | $data['created_by'] = $existingUser->ID; |