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/Models/Board.php +42 -11 1.952.1.0 View file →
@@ -32,14 +32,17 @@
32 32 ];
33 33
34 34 protected $appends = ['meta', 'isUserOnlyViewer'];
35 35
36 + /**
37 + * Boot board defaults while preserving empty backgrounds for newly created boards.
38 + */
36 39 public static function boot()
37 40 {
38 41 static::creating(function ($model) {
39 42 $model->created_by = $model->created_by ?: get_current_user_id();
40 43 $model->type = $model->type ?: 'to-do'; // default board type is to-do
41 - $model->background = $model->background ?: $model->randomBackground();
44 + $model->background = $model->background ?: '';
42 45 });
43 46 /* global scope for board type which means only type = to-do will be fetched from everywhere */
44 47 parent::boot();
45 48 static::addGlobalScope('type', function (Builder $builder) {
@@ -216,21 +219,49 @@
216 219 }
217 220
218 221 return $query->whereIn('id', $boardIds);
219 222 }
220 - private function randomBackground()
223 +
224 + /**
225 + * Exclude template boards (settings['is_template'] === true).
226 + * The settings column is serialized text, so both the PHP-serialized
227 + * and JSON representations of the flag are matched.
228 + */
229 + public function scopeExcludeTemplates($query)
221 230 {
222 - $solids = Constant::BOARD_BACKGROUND_DEFAULT_SOLID_COLORS;
223 - $solid = $solids[wp_rand(0, count($solids) - 1)];
231 + return $query->where(function ($query) {
232 + $query->whereNull('settings')
233 + ->orWhere(function ($subQuery) {
234 + $subQuery->where('settings', 'NOT LIKE', '%"is_template";b:1%')
235 + ->where('settings', 'NOT LIKE', '%"is_template":true%');
236 + });
237 + });
238 + }
224 239
225 - return [
226 - 'id' => $solid['id'],
227 - 'is_image' => false,
228 - 'image_url' => null,
229 - 'color' => $solid['value']
230 - ];
240 + /**
241 + * Limit boards to types supported by the currently loaded plugins.
242 + */
243 + public function scopeAvailableInCurrentInstall($query)
244 + {
245 + if (!defined('FLUENT_ROADMAP')) {
246 + return $query->where('type', 'to-do');
247 + }
248 +
249 + return $query;
231 250 }
232 251
252 + /**
253 + * Only template boards (inverse of scopeExcludeTemplates).
254 + */
255 + public function scopeOnlyTemplates($query)
256 + {
257 + return $query->whereNotNull('settings')
258 + ->where(function ($subQuery) {
259 + $subQuery->where('settings', 'LIKE', '%"is_template";b:1%')
260 + ->orWhere('settings', 'LIKE', '%"is_template":true%');
261 + });
262 + }
263 +
233 264 public function getUsers()
234 265 {
235 266 return (new UserService())->allFluentBoardsUsers($this->id);
236 267 }
@@ -314,9 +345,9 @@
314 345 }
315 346
316 347 public function removeBoardFromFolder()
317 348 {
318 - $relation = Relation::where('object_type', 'FluentBoardsPro\App\Models\Folder')
349 + $relation = Relation::where('object_type', Constant::OBJECT_TYPE_FOLDER_BOARD)
319 350 ->where('foreign_id', $this->id)
320 351 ->first();
321 352
322 353 if (!$relation) {