public function checkCurrentUserAccess($roles)
    {
        if ($this->getCurrentUser() === null) {
            return;
        }
        if ($roles instanceof core_kernel_classes_Resource) {
            $roles = [$roles->getUri()];
        }

        if (is_array($roles)) {
            $roles = array_map(function($role) {
                return $role instanceof core_kernel_classes_Resource ? $role->getUri() : $role;
            }, $roles);
        }

        if (in_array(TaoRoles::SYSTEM_ADMINISTRATOR, $roles)
            && !$this->userHasRoles($this->getCurrentUser(), TaoRoles::SYSTEM_ADMINISTRATOR)
        ) {
            throw new common_exception_Error('Permission denied');
        }

        if (in_array(TaoRoles::GLOBAL_MANAGER, $roles)
            && !$this->userHasRoles($this->getCurrentUser(), [TaoRoles::SYSTEM_ADMINISTRATOR, TaoRoles::GLOBAL_MANAGER])
        ) {
            throw new common_exception_Error('Permission denied');
        }
    }
public function checkCurrentUserAccess($roles)
    {
        if ($this->getCurrentUser() === null) {
            return;
        }
        if ($roles instanceof core_kernel_classes_Resource) {
            $roles = [$roles->getUri()];
        }

        if (is_array($roles)) {
            $roles = array_map(function($role) {
                return $role instanceof core_kernel_classes_Resource ? $role->getUri() : $role;
            }, $roles);
        }

        if (in_array(TaoRoles::SYSTEM_ADMINISTRATOR, $roles)
            && !$this->userHasRoles($this->getCurrentUser(), TaoRoles::SYSTEM_ADMINISTRATOR)
        ) {
            throw new common_exception_Error('Permission denied');
        }

        if (in_array(TaoRoles::GLOBAL_MANAGER, $roles)
            && !$this->userHasRoles($this->getCurrentUser(), [TaoRoles::SYSTEM_ADMINISTRATOR, TaoRoles::GLOBAL_MANAGER])
        ) {
            throw new common_exception_Error('Permission denied');
        }
    }
public function checkCurrentUserAccess ( $ roles ) { if ( $ this -> getCurrentUser ( ) === null ) { return ; } if ( $ roles instanceof core_kernel_classes_Resource ) { $ roles = [ $ roles -> getUri ( ) ] ; } if ( is_array ( $ roles ) ) { $ roles = array_map ( function ( $ role ) { return $ role instanceof core_kernel_classes_Resource ? $ role -> getUri ( ) : $ role ; } , $ roles ) ; } if ( in_array ( TaoRoles :: SYSTEM_ADMINISTRATOR , $ roles ) && ! $ this -> userHasRoles ( $ this -> getCurrentUser ( ) , TaoRoles :: SYSTEM_ADMINISTRATOR ) ) { throw new common_exception_Error ( 'Permission denied' ) ; } if ( in_array ( TaoRoles :: GLOBAL_MANAGER , $ roles ) && ! $ this -> userHasRoles ( $ this -> getCurrentUser ( ) , [ TaoRoles :: SYSTEM_ADMINISTRATOR , TaoRoles :: GLOBAL_MANAGER ] ) ) { throw new common_exception_Error ( 'Permission denied' ) ; } }
Thrown an exception if user doesn't have permissions
@param $roles
@throws common_exception_Error
Thrown an exception if user doesn t have permissions