Пример #1
0
 /**
  * Constructor.
  *
  * @param KConfig $config An optional KConfig object with configuration options.
  *
  * @return void
  */
 public function __construct(KConfig $config)
 {
     if (!$config->actor) {
         throw new KException('Actor object is missing');
     }
     $this->_actor = $config->actor;
     parent::__construct($config);
     $query = $this->getService($config->repository)->getQuery()->bind('actorid', $this->_actor->id)->bind('components_set_to_never', $this->getService('repos://site/components.assignment')->getQuery()->columns('id')->where('@col(actortype) = :actortype AND @col(access) = :never'))->bind('actortype', (string) $this->_actor->getEntityDescription()->getInheritanceColumnValue()->getIdentifier())->bind('never', ComComponentsDomainBehaviorAssignable::ACCESS_NEVER)->bind('always', ComComponentsDomainBehaviorAssignable::ACCESS_ALWAYS)->bind('optional', ComComponentsDomainBehaviorAssignable::ACCESS_OPTIONAL);
     $query->link('repos://site/components.assignment', '@col(assignment.component) = @col(component)', array('type' => 'weak'))->enabled(true)->where('@col(id) NOT IN (:components_set_to_never)');
     if ($config->can_enable) {
         $query->where('@col(assignment.actortype) = :actortype AND @col(access) = :optional');
     } else {
         $query->where('((@col(assignment.actortype) = :actortype AND @col(access) = :always) OR @col(assignment.actor.id)  = :actorid OR @col(option) = "com_stories")');
     }
     $config['query'] = $query;
     $this->_object = $this->getService('anahita:domain.entityset', KConfig::unbox($config));
 }
Пример #2
0
 /**
  * Adds a condition for list of components that are assigned to actor
  * 
  * @param ComActorsDomainEntityActor $actor
  * 
  * @return ComComponentsDomainQueryComponent
  */
 public function assignedToActor($actor)
 {
     $actortype = $actor->getEntityDescription()->getInheritanceColumnValue()->getIdentifier();
     $this->where('assignments.actor', '=', $actor)->where('(@col(assignments.actortype) = @quote(' . $actortype . ') AND @col(assignments.access IN (2,1) ))', 'OR');
     return $this;
 }
Пример #3
0
 /**
  * Return whether the component is active for actor. A component is active, if
  * it has been assigned as awlays for the actor type or it has been enabled for the
  * actor.
  *
  * @param ComActorsDomainEntityActor $actor The actor object
  *
  * @return bool
  */
 public function activeForActor($actor)
 {
     $actortype = $actor->getEntityDescription()->getInheritanceColumnValue()->getIdentifier();
     $access = $this->getAssignmentForIdentifier($actortype);
     $return = false;
     if ($access == self::ACCESS_ALWAYS) {
         $return = true;
     } elseif ($access == self::ACCESS_OPTIONAL) {
         $return = $this->enabledForActor($actor);
     }
     return $return;
 }