Esempio n. 1
0
 /**
  * Get related descendants of current model.
  *
  * @param {?string} $collection Collection identifier of the relation, defaults to the model's collection name.
  */
 protected function descendants($collection = null)
 {
     if ($collection === null) {
         $collection = $this->collectionName();
     }
     return Relation::getDescendants($this->identity(), $collection);
 }
Esempio n. 2
0
 /**
  * @protected
  *
  * Load task contents, remove task scripts.
  */
 function afterLoad()
 {
     // unpack uuid
     $this->uuid = util::unpackUuid($this->uuid);
     $this->nextTask = util::unpackUuid($this->nextTask);
     // note: Only users with access to nextTask has view permission.
     if (!$this->__isSuperUser) {
         // 1. Group:User
         $res = (array) @$this->__request->user->groups;
         // 2. Task:Group
         $res = Relation::getAncestors($res, Task::GROUP_RELATION);
         // 3. Task
         $res = Relation::getDescendants($res, 'Task');
         // 4. UUID comparison
         if (!in_array($this->nextTask, $res)) {
             return $this->data(array());
         }
     }
     // load task details, do not expose internal scripts
     $taskInstance = new TaskInstance();
     $this->tasks = array_map(removes('order'), $taskInstance->find(array('uuid' => $this->children($taskInstance::WORK_RELATION), '@sorter' => ['order'])));
     unset($taskInstance);
     $res = parent::afterLoad();
     // lock the item after load
     $this->_immutable = true;
     return $res;
 }