Set the visibility of the menu item and any sub items in accordance
with the specified user role.

@param \Zend_Acl $acl
@param string $userRole
@return \Gems_Menu_MenuAbstract (continuation pattern)
7561
protected function applyAcl(\MUtil_Acl $acl, $userRole)
    {
        foreach ($this->_subItems as $item) {

            $allowed = $item->get('allowed', true);

            if ($allowed && ($privilege = $item->get('privilege'))) {
                $allowed = $acl->isAllowed($userRole, null, $privilege);
            }

            if ($allowed) {
                $item->applyAcl($acl, $userRole);
            } else {
                // As an item can be invisible but allowed,
                // but not disallowed but visible we need to
                // set both.
                $item->set('allowed', false);
                $item->set('visible', false);
                $item->setForChildren('allowed', false);
                $item->setForChildren('visible', false);
            }
        }

        return $this;
    }
1010596
public function setAccessRoles(array $accessRoles)
    {
        foreach ($accessRoles as $role) {
            if (!is_string($role)) {
                throw new \InvalidArgumentException('The role names passed to setAccessRoles() must all be of type string.', 1302172892);
            }
        }
        if ($this->accessRoles !== $accessRoles) {
            $this->accessRoles = $accessRoles;
            $this->addOrUpdate();
        }
    }
352273
function it_can_grant_access_to_roles_by_appending_actions($resourceObject, $groupRules, $groupActionRule)
    {
        $role = $this->getRoleWithName('user');
        $groupRules->update(Argument::any())->shouldBeCalled();
        $groupActionRule->addAction('foo')->shouldBeCalled();
        $this->grantRoleAccess($role, $resourceObject, 'foo');
    }
964655
public function getAllForUser(\ACL $userACL, array $restrictions = [])
    {
        $base_ids = array_keys($userACL->get_granted_base());

        $qb = $this
            ->createQueryBuilder('f');

        $qb->where($qb->expr()->isNull('f.baseId'))
            ->orWhere($qb->expr()->eq('f.public', $qb->expr()->literal(true)));

        if (count($restrictions) > 0 && count($base_ids) > 0) {
            $base_ids = array_intersect($base_ids, $restrictions);
        }

        if (empty($base_ids) && count($restrictions) > 0) {
            $base_ids = $restrictions;
        }

        if (count($base_ids) > 0) {
            $qb->orWhere($qb->expr()->in('f.baseId', $base_ids));
        }

        $qb->orderBy('f.updatedOn', 'DESC');

        return $qb->getQuery()->getResult();
    }
674103
public function assert(
        Acl $acl,
        RoleInterface $role = null,
        ResourceInterface $resource = null,
        $privilege = null
    ) {
        if (!$role instanceof UserInterface || !$resource instanceof JobInterface || 'edit' != $privilege) {
            return false;
        }

        /* @var $resource \Jobs\Entity\JobInterface */
        return $resource->getPermissions()->isGranted($role->getId(), Permissions::PERMISSION_CHANGE)
               || $this->checkOrganizationPermissions($role, $resource)
               || (null === $resource->getUser() && \Auth\Entity\UserInterface::ROLE_ADMIN == $role->getRole());
    }
1038783
public function getRole()
    {
        if ($this->_role === null) {
            $serviceLocator = $this->getServiceLocator();
            // try service locator first
            if ($serviceLocator->has('AclRole')) {
                $this->setRole($serviceLocator->get('AclRole'));
                // try default acl object
            } elseif (self::$_defaultRole !== null) {
                return self::$_defaultRole;

            }
        }

        return $this->_role;
    }
109284
public final void setItsRole(final String pItsRole) {
    this.itsRole = pItsRole;
    if (this.itsId == null) {
      this.itsId = new IdUserRoleTomcat();
    }
    this.itsId.setItsRole(this.itsRole);
  }
725945
public function setupAcl() {
        $adminAlias = Configure::read('Admin.aliases.administrator');

        $this->out(sprintf('Administrator Role: <info>%s</info>', $adminAlias));

        $answer = mb_strtoupper($this->in('Is this correct?', array('Y', 'N')));

        if ($answer === 'N') {
            $this->out('<warning>Configure the role through Admin.aliases.administrator</warning>');
            return false;
        }

        $admin = $this->RequestObject->addObject($adminAlias);
        $userModel = ClassRegistry::init($this->usersModel, true);

        // Fetch user
        $this->out('What user would you like to give admin access?');
        $user_id = $this->findUser();

        // Give access
        $result = $this->RequestObject->addChildObject(
            $this->user[$userModel->alias][$userModel->displayField],
            $admin['RequestObject']['id'],
            $this->usersModel,
            $user_id);

        if (!$result) {
            $this->err('<error>Failed to give user admin access</error>');
            return false;
        }

        $this->out('<success>Access granted, proceeding...</success>');
        $this->plugin('Admin');
        $this->plugin(Configure::read('Admin.coreName'));

        return true;
    }
141914
public function userCan($user_id, string $role, string $permission, $callback = null) : bool
    {
        // Usuário permamentemente liberado
        $root_user = config('acl.root_user');
        if ($user_id == $root_user) {
            \Acl\Core::traceCurrentAbilityOrigin('config');
            \Acl\Core::traceCurrentAbility($role, $permission, true);
            return true;
        }

        // Existem permissões setadas?
        $user_abilities = (new UsersPermissionsService)->getPermissionsByUserID($user_id, $role);
        if ($user_abilities === null) {
            \Acl\Core::traceCurrentAbility($role, $permission, false);
            return false;
        }

        // create,read,update ou delete == yes?
        $result = (isset($user_abilities['permissions']) && $user_abilities['permissions'][$permission] == 'yes');

        // Existe uma verificação adicional
        if ($result == true && $callback != null && is_callable($callback) && $callback() !== true) {
            \Acl\Core::traceCurrentAbilityOrigin('callback');
            \Acl\Core::traceCurrentAbility($role, $permission, false);
            return false;
        }

        \Acl\Core::traceCurrentAbility($role, $permission, $result);

        return $result;
    }
1277907
def add_acl(self, scope, user, permission):
        
        return self.send('plugin.acl.addAcl', scope, user, permission)
328882
public function getContextualAcl()
    {
        $acl = $this->getRules();
        if (!$acl->hasRole($this->getContextId())) {
            $contextRoles = $this->getContext()->getRoles();
            if ($contextRoles instanceof RoleBucket) {
                $contextRoles = $contextRoles->toArray();
            }
            $acl->addRole(new Role($this->getContextId()), $contextRoles);
        }
        return $acl;
    }
494884
public function getAcl(string $idRole = null, string $idResource = null): array
    {
        if ($idRole) {
            $callback = function ($row) use ($idRole, $idResource) {
                if ($idRole && $idResource) {
                    return $row['id_role'] == $idRole && $row['id_resource'] == $idResource;
                }
                if ($idRole) {
                    return $row['id_role'] == $idRole;
                }
                return true;
            };
            return array_filter($this->acl, $callback);
        }
        return $this->acl;
    }
38898
public function addChild(Acl $child)
    {
        $rules = $child->getRule();
        foreach ($rules as $rule) {
            $this->rules[] = $rule;
        }
        return $this;
    }
1023968
public function hasRole($requestedRole) {
		$roles = $this->user($this->getConfig('roleField'));
		if (is_null($roles)) {
			return false;
		}

		return $this->_checkRoles($requestedRole, $roles);
	}
553750
protected function setBreadcrumbEditUserRole()
    {
        $breadcrumbs = array();

        $breadcrumbs[] = array(
            'url' => $this->url('admin'),
            'text' => $this->text('Dashboard')
        );

        $breadcrumbs[] = array(
            'text' => $this->text('Roles'),
            'url' => $this->url('admin/user/role')
        );

        $this->setBreadcrumbs($breadcrumbs);
    }
36616
public function addRole($role, $parents = null)
    {
        $this->getAcl()->addRole($role, $parents);
        return $this;
    }
1250877
public function setupAcl()
    {
        $this->insertRoles($this->findRoles())
            ->insertResources($this->findResources())
            ->insertPrivileges($this->findPrivileges());

        $this->loaded = true;

        return $this;
    }