Ejemplo n.º 1
0
 public function hasActionPermission(Action $action, User $user = null)
 {
     if ($user === null) {
         $user = $this->user;
     }
     $permissionTable = $this->getPermissionTable($user);
     return $permissionTable->contains($action->getId());
 }
Ejemplo n.º 2
0
 private function updateActions(Module $model, ModuleSchema $module)
 {
     $actions = [];
     foreach ($module->getActionNames() as $name) {
         $action = $module->getAction($name);
         $a = new Action();
         $a->setName($name);
         $a->setModule($model);
         $a->setTitle($action->getTitle());
         $a->setDescription($action->getDescription());
         $a->setClassName($action->getClass());
         // add acl
         foreach ($action->getAcl() as $group) {
             $a->addGroup($this->getGroup($group));
         }
         $a->save();
         $actions[$name] = $a->getId();
     }
     // remove obsolete actions
     ActionQuery::create()->filterByModule($model)->where('Action.Name NOT IN ?', $module->getActionNames()->toArray())->delete();
     return $actions;
 }
Ejemplo n.º 3
0
 private function installActions(Module $module, $data)
 {
     if (!isset($data['actions'])) {
         return;
     }
     $actions = [];
     foreach ($data['actions'] as $name => $options) {
         $a = new Action();
         $a->setName($name);
         $a->setModule($module);
         if (isset($options['title'])) {
             $a->setTitle($options['title']);
         }
         if (isset($options['description'])) {
             $a->setDescription($options['description']);
         }
         if (isset($options['class'])) {
             $a->setClassName($options['class']);
         }
         // add acl
         if (isset($options['acl'])) {
             foreach ($options['acl'] as $group) {
                 $a->addGroup($this->getGroup($group));
             }
         }
         $a->save();
         $actions[$name] = $a->getId();
     }
     return $actions;
 }
Ejemplo n.º 4
0
 /**
  * Exclude object from result
  *
  * @param   ChildAction $action Object to remove from the list of results
  *
  * @return $this|ChildActionQuery The current query, for fluid interface
  */
 public function prune($action = null)
 {
     if ($action) {
         $this->addUsingAlias(ActionTableMap::COL_ID, $action->getId(), Criteria::NOT_EQUAL);
     }
     return $this;
 }
Ejemplo n.º 5
0
Archivo: Api.php Proyecto: keeko/core
 /**
  * Declares an association between this object and a ChildAction object.
  *
  * @param  ChildAction $v
  * @return $this|\keeko\core\model\Api The current object (for fluent API support)
  * @throws PropelException
  */
 public function setAction(ChildAction $v = null)
 {
     if ($v === null) {
         $this->setActionId(NULL);
     } else {
         $this->setActionId($v->getId());
     }
     $this->aAction = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the ChildAction object, it will not be re-added.
     if ($v !== null) {
         $v->addApi($this);
     }
     return $this;
 }
Ejemplo n.º 6
0
 /**
  * Filter the query by a related \keeko\core\model\Action object
  *
  * @param \keeko\core\model\Action|ObjectCollection $action The related object(s) to use as filter
  * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @throws \Propel\Runtime\Exception\PropelException
  *
  * @return ChildApiQuery The current query, for fluid interface
  */
 public function filterByAction($action, $comparison = null)
 {
     if ($action instanceof \keeko\core\model\Action) {
         return $this->addUsingAlias(ApiTableMap::COL_ACTION_ID, $action->getId(), $comparison);
     } elseif ($action instanceof ObjectCollection) {
         if (null === $comparison) {
             $comparison = Criteria::IN;
         }
         return $this->addUsingAlias(ApiTableMap::COL_ACTION_ID, $action->toKeyValue('PrimaryKey', 'Id'), $comparison);
     } else {
         throw new PropelException('filterByAction() only accepts arguments of type \\keeko\\core\\model\\Action or Collection');
     }
 }