| @@ -222,8 +222,30 @@ | ||
| 222 | 222 | { |
| 223 | 223 | return $this->belongsTo(Board::class, 'board_id', 'id'); |
| 224 | 224 | } |
| 225 | 225 | |
| 226 | + /** | |
| 227 | + * Exclude tasks that belong to template boards. | |
| 228 | + */ | |
| 229 | + public function scopeExcludeTemplateBoards($query) | |
| 230 | + { | |
| 231 | + return $query->whereHas('board', function ($boardQuery) { | |
| 232 | + $boardQuery->excludeTemplates(); | |
| 233 | + }); | |
| 234 | + } | |
| 235 | + | |
| 236 | + /** | |
| 237 | + * Limit tasks to active, non-template boards available in this install. | |
| 238 | + */ | |
| 239 | + public function scopeOnActiveAvailableBoards($query) | |
| 240 | + { | |
| 241 | + return $query->whereHas('board', function ($boardQuery) { | |
| 242 | + $boardQuery->whereNull('archived_at') | |
| 243 | + ->excludeTemplates() | |
| 244 | + ->availableInCurrentInstall(); | |
| 245 | + }); | |
| 246 | + } | |
| 247 | + | |
| 226 | 248 | public function assignees() |
| 227 | 249 | { |
| 228 | 250 | return $this->belongsToMany( |
| 229 | 251 | User::class, |
| @@ -250,8 +272,13 @@ | ||
| 250 | 272 | } |
| 251 | 273 | |
| 252 | 274 | public function attachments() //may not need in future |
| 253 | 275 | { |
| 276 | + if (!defined('FLUENT_BOARDS_PRO_VERSION')) { | |
| 277 | + return $this->hasMany(Attachment::class, 'id', 'id') | |
| 278 | + ->where('id', 0); | |
| 279 | + } | |
| 280 | + | |
| 254 | 281 | return $this->hasMany(TaskAttachment::class, |
| 255 | 282 | 'object_id', 'id') |
| 256 | 283 | ->where('object_type', Constant::OBJECT_TYPE_TASK); |
| 257 | 284 | } |
| @@ -369,8 +396,14 @@ | ||
| 369 | 396 | |
| 370 | 397 | public function createTask($data) |
| 371 | 398 | { |
| 372 | 399 | $data = apply_filters('fluent_boards/before_task_create', $data); |
| 400 | + | |
| 401 | + // Keep newly-created tasks unprioritized unless a priority is explicitly selected. | |
| 402 | + if (!array_key_exists('priority', $data)) { | |
| 403 | + $data['priority'] = ''; | |
| 404 | + } | |
| 405 | + | |
| 373 | 406 | $createdTask = Task::create($data); |
| 374 | 407 | |
| 375 | 408 | if ( ! empty($data['assignees'])) { |
| 376 | 409 | $assignees = array_filter(array_map('intval', $data['assignees'])); |
| @@ -844,9 +877,9 @@ | ||
| 844 | 877 | 'priority' => [ |
| 845 | 878 | 'field' => __('Priority', 'fluent-boards'), |
| 846 | 879 | 'type' => 'text', |
| 847 | 880 | 'rules' => 'optional', |
| 848 | - 'description' => __('Priority of the task (low | medium | high). Example: "medium" ', 'fluent-boards'), | |
| 881 | + 'description' => __('Priority of the task (urgent | high | medium | low). Leave empty for no priority. Example: "medium" ', 'fluent-boards'), | |
| 849 | 882 | ], |
| 850 | 883 | 'due_at' => [ |
| 851 | 884 | 'field' => __('Due Date', 'fluent-boards'), |
| 852 | 885 | 'type' => 'date', |