checkPermissions() публичный Метод

checkPermissions(object $obj, bool $modify = false, $errorMessage='') checkPermissions(int $roleId, string $permissionId = null, $errorMessage='')
public checkPermissions ( $args )
Пример #1
0
 /**
  * Permissions won't check if object has environment scope and role Acl::RESOURCE_ANALYTICS_ACCOUNT
  * {@inheritdoc}
  * @see ApiController::checkPermissions()
  */
 public function checkPermissions(...$args)
 {
     if ($this->getScope() === ScopeInterface::SCOPE_ENVIRONMENT && isset($args[0]) && $args[0] == Acl::RESOURCE_ANALYTICS_ACCOUNT && empty($args[1])) {
         return;
     }
     parent::checkPermissions(...$args);
 }
Пример #2
0
 /**
  * Deletes farm's global variable
  *
  * @param   int     $farmId Numeric identifier of the Farm
  * @param   string  $name   Name of variable
  *
  * @return  ResultEnvelope
  *
  * @throws  ApiErrorException
  * @throws  ModelException
  */
 public function deleteVariableAction($farmId, $name)
 {
     parent::checkPermissions(Acl::RESOURCE_GLOBAL_VARIABLES_ENVIRONMENT, Acl::PERM_GLOBAL_VARIABLES_ENVIRONMENT_MANAGE);
     $this->getFarm($farmId, Acl::PERM_FARMS_MANAGE);
     $fetch = $this->getGlobalVariable($farmId, $name, $this->getVariableInstance());
     $variable = FarmGlobalVariable::findPk($farmId, $name);
     if (empty($fetch)) {
         throw new ApiErrorException(404, ErrorMessage::ERR_OBJECT_NOT_FOUND, "Requested Global Variable does not exist.");
     } else {
         if (empty($variable)) {
             throw new ApiErrorException(403, ErrorMessage::ERR_SCOPE_VIOLATION, "You can only delete Global Variables declared in Farm scope.");
         }
     }
     $variable->delete();
     return $this->result(null);
 }
Пример #3
0
 /**
  * Throws an exception if the user does not have sufficient permissions for projects
  * If the argument just one we will checks all the existing variants of access to projects
  * checkPermissions(int $roleId, string $permissionId = null)
  *
  * @param ...$args
  * @throws ApiInsufficientPermissionsException
  */
 public function checkPermissions(...$args)
 {
     if (isset($args[0]) && $args[0] == Acl::RESOURCE_ANALYTICS_PROJECTS_ACCOUNT && empty($args[1])) {
         if (!($this->hasPermissions(...$args) || $this->hasPermissions(Acl::RESOURCE_OWN_FARMS, Acl::PERM_FARMS_CREATE) || $this->hasPermissions(Acl::RESOURCE_FARMS, Acl::PERM_FARMS_PROJECTS) || $this->hasPermissions(Acl::RESOURCE_TEAM_FARMS, Acl::PERM_FARMS_PROJECTS) || $this->hasPermissions(Acl::RESOURCE_OWN_FARMS, Acl::PERM_FARMS_PROJECTS))) {
             throw new ApiInsufficientPermissionsException(isset($args[2]) ? $args[2] : null);
         }
     } else {
         parent::checkPermissions(...$args);
     }
 }