Grant access to create a new layout by common group settings
@return GrantResult
11695
private function GrantCreateLayout()
    {
        $groups = $this->GetGroups();
        foreach ($groups as $group)
        {
            if ($group->GetCreateLayouts())
            {
                return GrantResult::Allowed();
            }
        }
        return GrantResult::NoAccess();
    }
491188
public function getPermission()
    {
        $this->request->allowMethod(['ajax']);

        $group_or_user = isset($this->request->data['group_or_user']) ? $this->request->data['group_or_user'] : null;
        $group_or_user_id = isset($this->request->data['group_or_user_id']) ? $this->request->data['group_or_user_id'] : null;

        $ugp = $this->UserGroupPermission->find()
            ->select(['permission_id','allow'])
            ->where(
                [
                    'group_or_user_id' => $group_or_user_id,
                    'group_or_user' => $group_or_user
                ])->toArray();

        $response = (!empty($ugp) && !is_null($ugp)) ? $ugp : 'fail';

        $this->set(compact('response'));
        $this->set('_serialize', ['response']);
        $this->render('Acl.Ajax/ajax_response', false);
    }
13176
public function create()
	{
		// Element fields, so don´t use parent construct method
		$GLOBALS['TL_DCA']['tl_content']['palettes'][$this->element] .= ',protected';
		$GLOBALS['TL_DCA']['tl_content']['fields']['protected']['eval']['tl_class'] = 'clr'; // push to new row (clear)

		// The groups field
		if (!$this->canChangeGroups)
		{
			if(($key = array_search('protected', $GLOBALS['TL_DCA']['tl_content']['palettes']['__selector__'])) !== false) {
				unset($GLOBALS['TL_DCA']['tl_content']['palettes']['__selector__'][$key]);
			}
			
			unset($GLOBALS['TL_DCA']['tl_content']['subpalettes']['protected']);
			
			$GLOBALS['TL_DCA']['tl_content']['fields']['protected']['eval']['submitOnChange'] = false;
			
			// Overwrite the elements groups with groups from the pattern
			$db = Database::getInstance();
			$db->prepare("UPDATE tl_content SET groups=? WHERE id=?")
			   ->execute($this->groups, $this->cid);
		}
		
		// The guests field
		if ($this->canChangeGuests)
		{
			$GLOBALS['TL_DCA']['tl_content']['palettes'][$this->element] .= ',guests';
		}
	}
1055256
public function addGroup()
    {
        $conditions = func_get_args();
        $arr        = array();

        foreach ($conditions as $condition) {
            if (is_array($condition) and count($condition) >= 2) {
                $this->add($condition[0], $condition[1], $condition[2]);

                end($this->_conditions);
                $arr[] = array(key($this->_conditions) => current($this->_conditions));
                array_pop($this->_conditions);
            }
        }

        $this->_conditions[] = $arr;

        return $this;
    }
1333413
public function filterByAssignable()
    {
        if (Config::get('concrete.permissions.model') != 'simple') {
            // there's gotta be a more reasonable way than this but right now i'm not sure what that is.
            $excludeGroupIDs = [GUEST_GROUP_ID, REGISTERED_GROUP_ID];
            $db = Loader::db();
            $r = $db->executeQuery('select gID from ' . $db->getDatabasePlatform()->quoteSingleIdentifier('Groups') . ' where gID > ?', [REGISTERED_GROUP_ID]);
            while ($row = $r->FetchRow()) {
                $g = Group::getByID($row['gID']);
                $gp = new Permissions($g);
                if (!$gp->canAssignGroup()) {
                    $excludeGroupIDs[] = $row['gID'];
                }
            }
            $this->query->andWhere(
                $this->query->expr()->notIn('g.gId', array_map([$db, 'quote'], $excludeGroupIDs))
            );
        }
    }
1065124
public function grant() {
        $aro_id = isset($this->request->params['named']['aro_id']) ? $this->request->params['named']['aro_id'] : null;
        $aco_id = isset($this->request->params['named']['aco_id']) ? $this->request->params['named']['aco_id'] : null;

        if (!$aro_id || !$aco_id) {
            throw new BadRequestException(__d('admin', 'Invalid ARO/ACO IDs'));
        }

        $aro = $this->Aro->getById($aro_id);
        $aco = $this->Aco->getById($aco_id);

        if (!$aro || !$aco) {
            throw new NotFoundException(__d('admin', 'Invalid ARO/ACO Records'));
        }

        $aroAlias = $aro['RequestObject']['alias'];
        $acoAlias = $aco['ControlObject']['alias'];

        if (!empty($aro['Parent']['alias'])) {
            $aroAlias = $aro['Parent']['alias'] . '/' . $aroAlias;
        }

        if ($this->Acl->allow($aroAlias, $acoAlias)) {
            $this->AdminToolbar->logAction(ActionLog::CREATE, $this->Permission, $this->Acl->adapter()->Permission->id, sprintf('Granted %s access to %s', $aroAlias, $acoAlias));
            $this->AdminToolbar->setFlashMessage(__d('admin', 'Successfully granted %s permission to %s', array($aroAlias, $acoAlias)));
        } else {
            $this->AdminToolbar->setFlashMessage(__d('admin', 'Failed to grant %s permission to %s', array($aroAlias, $acoAlias)), 'is-error');
        }

        $this->redirect(array('action' => 'index'));
    }
161706
def create_direito_grupo_equipamento(self):
        """"""
        return DireitoGrupoEquipamento(
            self.networkapi_url,
            self.user,
            self.password,
            self.user_ldap)
354616
public function createButtonGroup()
    {
        $node = new Group();
        $this->childNodes->push($node);

        return $this->childNodes->last();
    }
828922
public function addGroup() {
		$nb=sizeof($this->elements);
		$bg=new HtmlButtongroups($this->identifier."-buttongroups-".$nb);
		$this->elements []=$bg;
		return $bg;
	}
51036
public function init() {

		parent::init();

		// Permission
		$this->crudPermission = CmnGlobal::PERM_GROUP_ADMIN;

		// Config
		$this->type		= CoreGlobal::TYPE_USER;
		$this->apixBase	= 'community/user';

		// Sidebar
		$this->sidebar	= [ 'parent' => 'sidebar-community', 'child' => 'user' ];

		// Return Url
		$this->returnUrl = Url::previous( 'community-users' );
		$this->returnUrl = isset( $this->returnUrl ) ? $this->returnUrl : Url::toRoute( [ '/sfcore/user/user/all' ], true );

		// Breadcrumbs
		$this->breadcrumbs = [
			'base' => [
				[ 'label' => 'Home', 'url' => Url::toRoute( '/dashboard' ) ]
			],
			'all' => [ [ 'label' => 'Users' ] ],
			'create' => [ [ 'label' => 'Users', 'url' => $this->returnUrl ], [ 'label' => 'Add' ] ],
			'update' => [ [ 'label' => 'Users', 'url' => $this->returnUrl ], [ 'label' => 'Update' ] ],
			'delete' => [ [ 'label' => 'Users', 'url' => $this->returnUrl ], [ 'label' => 'Delete' ] ],
			'gallery' => [ [ 'label' => 'Users', 'url' => $this->returnUrl ], [ 'label' => 'Gallery' ] ]
		];
	}
602744
protected function load_hd_grant()
    {

        if ($this->_rights_records_preview) {
            return $this;
        }

        try {
            $tmp_rights = $this->get_data_from_cache(self::CACHE_RIGHTS_RECORDS);
            $this->_rights_records_preview = $tmp_rights['preview'];
            $this->_rights_records_document = $tmp_rights['document'];

            return $this;
        } catch (\Exception $e) {

        }
        $sql = "SELECT sbas_id, record_id, preview, document FROM records_rights WHERE usr_id = :usr_id";

        $stmt = $this->app->getApplicationBox()->get_connection()->prepare($sql);
        $stmt->execute([':usr_id' => $this->user->getId()]);
        $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
        $stmt->closeCursor();
        unset($stmt);

        $this->_rights_records_preview = [];
        $this->_rights_records_document = [];

        foreach ($rs as $row) {
            $currentid = $row["sbas_id"] . "_" . $row["record_id"];
            if ($row['document'] == '1')
                $this->_rights_records_document[$currentid] = $currentid;
            $this->_rights_records_preview[$currentid] = $currentid;
        }

        $datas = [
            'preview'  => $this->_rights_records_preview,
            'document' => $this->_rights_records_document
        ];

        $this->set_data_to_cache($datas, self::CACHE_RIGHTS_RECORDS);

        return $this;
    }
1092626
private function AddUserGroupField()
    {
        $name = 'UserGroup';
        $field = new Select($name, '');
        
        $field->AddOption('', Trans('Core.LayoutForm.NoGroup'));
        if ($this->layout->Exists() && $this->layout->GetUserGroup())
        {
            $field->SetValue($this->layout->GetUserGroup()->GetID());
        }
        DBSelectUtil::AddUserGroupOptions($field);
        $this->AddField($field);
    }
449436
public function pagePermissionsAction()
    {

        $view = new ViewModel();
        //fixes rendering site's header and footer in the dialog
        $view->setTerminal(true);

        /** @var \Rcm\Entity\Site $currentSite */
        $currentSite = $this->getServiceLocator()->get(
            \Rcm\Service\CurrentSite::class
        );

        $currentSiteId = $currentSite->getSiteId();

        $sourcePageName = $this->getEvent()
            ->getRouteMatch()
            ->getParam(
                'rcmPageName',
                'index'
            );

        $pageType = $this->getEvent()
            ->getRouteMatch()
            ->getParam(
                'rcmPageType',
                'n'
            );

        /** @var ResourceName $resourceName */
        $resourceName = $this->getServiceLocator()->get(
            ResourceName::class
        );

        $resourceId = $resourceName->get(
            ResourceName::RESOURCE_SITES,
            $currentSiteId,
            ResourceName::RESOURCE_PAGES,
            $pageType,
            $sourcePageName
        );

        /** @var \RcmUser\Acl\Service\AclDataService $aclDataService */
        $aclDataService = $this->getServiceLocator()->get(
            \RcmUser\Acl\Service\AclDataService::class
        );

        //getting all set rules by resource Id
        $rules = $aclDataService->getRulesByResource($resourceId)->getData();

        //getting list of all dynamically created roles
        $allRoles = $aclDataService->getNamespacedRoles()->getData();

        $rolesHasRules = [];

        foreach ($rules as $setRuleFor) {
            //getting only the ones that are allow
            if ($setRuleFor->getRule() == 'allow') {
                $rolesHasRules[] = $setRuleFor->getRoleId();
            }
        }

        $selectedRoles = [];

        foreach ($allRoles as $key => $role) {
            $roleId = $role->getRoleId();
            if (in_array($roleId, $rolesHasRules)) {
                $selectedRoles[$roleId] = $role;
            }
        }

        $data = [
            'siteId' => $currentSiteId,
            'pageType' => $pageType,
            'pageName' => $sourcePageName,
            'roles' => $allRoles,
            'selectedRoles' => $selectedRoles,
        ];

        $view->setVariable('data', $data);

        $view->setVariable(
            'rcmPageName',
            $sourcePageName
        );
        $view->setVariable(
            'rcmPageType',
            $pageType
        );

        return $view;
    }
132429
protected function getPermission()
    {
        // Get the display name.  This will go in the 'label' field.
        $label = ucwords($this->ask('Specify the display name for a new permission'));

        $name = null;

        // Make sure we get a valid key name for the permission.
        while (is_null($name)) {
            $name = $this->ask('What should the key name be set to?', Str::slug($label));

            // Make sure they approve the details for the new permission.
            if ($this->confirm("Your permission will be added as: \n\tLabel: $label \n\tName:  $name\nSave this permission?", true)) {
                $data = [
                    'name'       => $name,
                    'label'      => $label,
                    'created_at' => date('Y-m-d H:i:s'),
                ];

                // Add it to the database or detail an error has occurred and a new name needs to be supplied.
                try {
                    $this->db->table('rbac_permissions')->insert($data);
                } catch (QueryException $exception) {
                    $this->error('That name is already taken.  Please choose another.');

                    $name = null;
                    continue;
                }

                // Add the permission to our list.
                $this->permissions[] = (object)$data;

                $this->comment('Added!');
            } else {
                return true;
            }
        }

        // Allow them the chance to add another one.
        return $this->confirm('Add another permission?', true);
    }
721639
public static function map()
    {
        $permissions = [];

        foreach (static::get() as $permission) {
            $permissions[$permission->permission][] = (string) $permission->group_id;
        }

        return $permissions;
    }
321062
public function init() {

		parent::init();

		// Permission
		$this->crudPermission = CmnGlobal::PERM_GROUP_ADMIN;

		// Config
		$this->title		= 'Group';
		$this->type			= CmnGlobal::TYPE_GROUP;
		$this->templateType	= CmnGlobal::TYPE_GROUP;
		$this->apixBase		= 'community/group/category';
		$this->parentPath	= '/community/group/category';

		// Sidebar
		$this->sidebar = [ 'parent' => 'sidebar-community', 'child' => 'group-category' ];

		// Return Url
		$this->returnUrl = Url::previous( 'group-categories' );
		$this->returnUrl = isset( $this->returnUrl ) ? $this->returnUrl : Url::toRoute( [ '/community/group/category/all' ], true );

		// Breadcrumbs
		$this->breadcrumbs	= [
			'base' => [
				[ 'label' => 'Home', 'url' => Url::toRoute( '/dashboard' ) ]
			],
			'all' => [ [ 'label' => 'Group Categories' ] ],
			'create' => [ [ 'label' => 'Group Categories', 'url' => $this->returnUrl ], [ 'label' => 'Add' ] ],
			'update' => [ [ 'label' => 'Group Categories', 'url' => $this->returnUrl ], [ 'label' => 'Update' ] ],
			'delete' => [ [ 'label' => 'Group Categories', 'url' => $this->returnUrl ], [ 'label' => 'Delete' ] ],
			'gallery' => [ [ 'label' => 'Group Categories', 'url' => $this->returnUrl ], [ 'label' => 'Gallery' ] ],
			'data' => [ [ 'label' => 'Group Categories', 'url' => $this->returnUrl ], [ 'label' => 'Data' ] ],
			'config' => [ [ 'label' => 'Group Categories', 'url' => $this->returnUrl ], [ 'label' => 'Config' ] ],
			'settings' => [ [ 'label' => 'Group Categories', 'url' => $this->returnUrl ], [ 'label' => 'Settings' ] ]
		];
	}
1069656
public function createAction()
	{
		$this->isPostRequest();

		$page = new GroupPage();

		$localeId = $this->getCurrentLocale()->getId();

		$localization = Localization::factory($page, $localeId);
		/* @var $localization \Supra\Package\Cms\Entity\GroupLocalization */

		$title = trim($this->getRequestParameter('title', ''));

		if (empty($title)) {
			throw new CmsException(null, 'Group title cannot be empty.');
		}

		$localization->setTitle($title);

		$parentLocalizationId = $this->getRequestParameter('parent_id');

		if (empty($parentLocalizationId)) {
			throw new \UnexpectedValueException(
					'Parent ID is empty while it is not allowed Group to be root.'
			);
		}

		$parentLocalization = $this->getEntityManager()
					->find(Localization::CN(), $parentLocalizationId);

		if ($parentLocalization === null) {
			throw new CmsException(null, sprintf(
					'Specified parent page [%s] not found.',
					$parentLocalizationId
			));
		}

		$entityManager = $this->getEntityManager();

		$entityManager->transactional(function (EntityManager $entityManager) use ($page, $localization, $parentLocalization) {

			$this->lockNestedSet($page);

			$entityManager->persist($page);
			$entityManager->persist($localization);

			if ($parentLocalization) {
				$page->moveAsLastChildOf($parentLocalization->getMaster());
			}

			$this->unlockNestedSet($page);
		});

		return new SupraJsonResponse($this->loadNodeMainData($localization));
	}