Authorizes whether the viewer can pubilsh anything within this component or not.

@param AnCommandContext $context

@return bool
773138
protected function _authorizeAction(AnCommandContext $context)
    {
        $method = '_authorize'.ucfirst($context->action);

        $ret = self::AUTH_NOT_IMPLEMENTED;

        if (method_exists($this, $method)) {
            $ret = $this->$method($context->resource);
        } elseif ($context->actor) {
            //check if it's enabled and assigned
            if ($this->_entity->isAssignable()) {
                $ret = $this->_entity->activeForActor($context->actor);
            }
        }

        return $ret;
    }
361371
protected function _authorizeAddComment($context)
    {
        if (isset($this->_entity->object)) {
            if (is_array($this->_entity->object)) {
                return false;
            }

            if (!$this->_entity->object->isAuthorizer()) {
                return false;
            }

            return $this->_entity->object->authorize('add.comment');
        } else {
            return false;
        }
    }
1334462
protected function _actionUnlead(AnCommandContext $context)
    {
        $this->getResponse()->status = AnHttpResponse::RESET_CONTENT;
        $this->getItem()->removeLeader($this->actor);

        return $this->getItem();
    }
110658
protected function _authorizeEdit($context)
    {
        if ($this->_viewer->guest()) {
            return false;
        }

        if ($this->_viewer->admin()) {
            return true;
        }

        return false;
    }
751706
public function isGroupCenterPresentOnce(ExecutionContextInterface $context)
    {
        $groupCentersIds = array();
        foreach ($this->getGroupCenters() as $groupCenter) {
            if (in_array($groupCenter->getId(), $groupCentersIds)) {
                $context->buildViolation("The user has already those permissions")
                        ->addViolation();
                
            } else {
                $groupCentersIds[] = $groupCenter->getId();
            }
        }
    }
862216
protected function _authorizeUnfollow(AnCommandContext $context)
    {
        //if the viewer is not following then return false;
        //Riddle : How can you unfollow an actor that you are not following
        if (!$this->_viewer->following($this->_entity)) {
            return false;
        }

        //if entity is adminitrable and the viewer is an admin and there are only one admin. then the viewer can't unfollow
        if (
            $this->_entity->isAdministrable() &&
            $this->_entity->administratorIds->offsetExists($this->_viewer->id)
        ) {
            return ($this->_entity->administratorIds->count() >= 2);
        }

        return true;
    }
911885
protected function _actionEdit(AnCommandContext $context)
    {
        $data = $context->data;

        dispatch_plugin('user.onBeforeEditPerson', array('data' => $context->data));

        //dont' set the usertype yet, until we find the conditions are met
        $usertype = null;

        if ($data->usertype) {
            $usertype = $data->usertype;
            unset($context->data->usertype);
        }

        if ($data->password) {
            $_SESSION['reset_password_prompt'] = 0;
        }

        $person = parent::_actionEdit($context);

        //add the validations here
        $this->getRepository()
        ->getValidator()
        ->addValidation('givenName', 'required')
        ->addValidation('familyName', 'required')
        ->addValidation('username', 'uniqueness')
        ->addValidation('email', 'uniqueness');

        if ($person->validate() === false) {
            throw new AnErrorException($person->getErrors(), AnHttpResponse::BAD_REQUEST);
        }

        //now check to see if usertype can be set, otherwise the value is unchanged
        if (in_array($usertype, $this->_allowed_user_types) && $person->authorize('changeUsertype')) {
            $person->usertype = $usertype;
        }

        $person->timestamp();

        dispatch_plugin('user.onAfterEditPerson', array('person' => $person));

        $this->setMessage('LIB-AN-PROMPT-UPDATE-SUCCESS', 'success');

        $edit = ($data->password && $data->username) ? 'account' : $this->_request->edit;
        $url = sprintf($person->getURL(false)."&get=settings&edit=%s", $edit);
        $context->response->setRedirect(route($url));

        return $person;
    }
689320
protected function _afterEntityInstantiate(AnCommandContext $context)
    {
        $data = $context->data;

        if ($data->portrait) {
            $this->setPortrait($data->portrait);
        }
    }
913934
protected function _authorizeAdd(AnCommandContext $context)
    {
        $can_publish = get_config_value($this->_entity->component, 'can_publish', self::CAN_ADD_ADMIN);

        switch ($can_publish) {
            case self::CAN_ADD_ADMIN :
                return $this->_viewer->admin();
            case self::CAN_ADD_SPECIAL :
                return $this->_viewer->usertype != 'Registered' && !$this->_viewer->guest();
            case self::CAN_ADD_ALL :
                return !$this->_viewer->guest();
            default :
                return false;
        }
    }
116369
public function canCreate($member = null, $context = [])
    {
        $extended = $this->extend('canCreate', $member);
        if ($extended && $extended !== null) {
            return $extended;
        }

        return true;
    }
999109
protected function _canShowContent($sContentIdent)
    {
        return !($this->isEnabledPrivateSales() &&
            !$this->getUser() && !in_array($sContentIdent, $this->_aPsAllowedContents)
        );
    }
1042163
protected function _actionRead(AnCommandContext $context)
    {
        if ($this->invitetoken) {

            $token = $this->getRepository()->find(array('value' => $this->invitetoken));
            $this->getToolbar('menubar')->setTitle(null);

            if (!$token || !isset($token->inviter)) {
                throw new LibBaseControllerExceptionNotFound('Token not found');
                return;
            }

            if ($this->viewer->guest()) {
                AnRequest::set('session.invite_token', $token->value);
            }

            $this->setItem($token);

        } else {
            $service = pick($this->service, 'facebook');
            $token = $this->getRepository()->getEntity()->reset();
            AnRequest::set('session.invite_token', $token->value);
            $this->getView()->value($token->value);
            return $this->getView()->display();
        }
    }
663562
protected function _actionSetPrivacy(AnCommandContext $context)
    {
        if ($this->hasBehavior('privatable')) {
            $this->getBehavior('privatable')->execute('action.setprivacy', $context);
        }

        $data = $context->data;

        if ($data->access != 'followers') {
            $data->allowFollowRequest = false;
        }

        $this->getItem()->allowFollowRequest = (bool) $data->allowFollowRequest;
    }
112303
function isUsable(?\CharlotteDunois\Livia\Commands\Context $context = null) {
        if($context === null) {
            return $this->globalEnabled;
        }
        
        if($this->guildOnly && $context->message->guild === null) {
            return false;
        }
        
        return ($this->isEnabledIn($context->message->guild) && $this->hasPermission($context) === true);
    }
863060
protected function _actionGetaccesstoken($context)
    {
        $this->getBehavior('oauthorizable')->execute('action.getaccesstoken', $context);
        
        if ($token = $this->getAPI()->getToken()) {
            $context->response->setRedirect('view=login');
            return true;
        }
        
        $context->response->setRedirect(route('option=com_people&view=session'));
    }
790852
protected function _afterEntityInstantiate(AnCommandContext $context)
    {
        $data = $context->data;

        if ($data->cover) {
            $this->setCover($data->cover);
        }
    }
306003
protected function _authorizeVote($context)
    {
        if ($this->_viewer->guest()) {
            return false;
        }

        //if the owner has blocked the viewer or the other way around, return false

        if ($this->_entity instanceof ComBaseDomainEntityComment) {
            $owner = $this->_entity->parent->owner;
        } elseif ($this->_entity->isOwnable()) {
            $owner = $this->_entity->owner;
        } elseif (is_person($this->_entity)) {
            $owner = $this->_entity;
        }

        if ($owner && ($owner->blocking($this->_viewer) || $this->_viewer->blocking($owner))) {
            return false;
        }

        return $this->_entity->isVotable();
    }