diff --git a/app/Controller/DecayingModelController.php b/app/Controller/DecayingModelController.php index 902be881f..b6c6874b9 100644 --- a/app/Controller/DecayingModelController.php +++ b/app/Controller/DecayingModelController.php @@ -386,7 +386,8 @@ class DecayingModelController extends AppController public function getAllDecayingModels() { if ($this->request->is('get') && $this->request->is('ajax')) { - $savedDecayingModels = $this->DecayingModel->fetchAllAllowedModels($this->Auth->user()); + $filters = $this->request->query; + $savedDecayingModels = $this->DecayingModel->fetchAllAllowedModels($this->Auth->user(), true, $filters); $associated_models = $this->DecayingModel->DecayingModelMapping->getAssociatedModels($this->Auth->user()); $associated_types = array(); foreach ($associated_models as $type => $models) { diff --git a/app/Model/DecayingModel.php b/app/Model/DecayingModel.php index 5badb34e9..b24a3a21e 100644 --- a/app/Model/DecayingModel.php +++ b/app/Model/DecayingModel.php @@ -167,7 +167,7 @@ class DecayingModel extends AppModel return !is_null($decaying_model['DecayingModel']['uuid']); } - public function fetchAllAllowedModels($user, $full=true) + public function fetchAllAllowedModels($user, $full=true, $filters=array()) { $conditions = array(); if (!$user['Role']['perm_site_admin']) { @@ -176,6 +176,13 @@ class DecayingModel extends AppModel 'all_orgs' => 1 ); } + if (!empty($filters)) { + if (isset($filters['my_models']) && $filters['my_models']) { + $conditions[] = array('DecayingModel.org_id' => $user['Organisation']['id']); + } elseif (isset($filters['default_models']) && $filters['default_models']) { + $conditions[] = array('not' => array('DecayingModel.uuid' => null)); + } + } $decayingModels = $this->find('all', array( 'conditions' => $conditions, 'include' => $full ? 'DecayingModelMapping' :'' diff --git a/app/View/DecayingModel/decaying_tool.ctp b/app/View/DecayingModel/decaying_tool.ctp index 97a28185f..b4f2f7725 100644 --- a/app/View/DecayingModel/decaying_tool.ctp +++ b/app/View/DecayingModel/decaying_tool.ctp @@ -138,6 +138,17 @@