Creates a role types array ($this->roleTypes) from information in a taxonomy schema document
@return void
169461
private function createRoleTypesList()
	{
		$nodes = $this->xbrlDocument->children( XBRL_Constants::$standardPrefixes[ STANDARD_PREFIX_SCHEMA ] );
		if ( property_exists( $nodes, 'annotation' ) )
		{
			$annotations = $nodes->annotation;
			foreach ( $annotations as $annotationKey => $annotation )
			{
				if ( property_exists( $annotation, 'appinfo' ) )
				{
					$roleTypes = $annotation->appinfo->children( XBRL_Constants::$standardPrefixes[ STANDARD_PREFIX_LINK ] )->roleType;

					if ( ! count( $roleTypes ) ) continue;

					// Create an array indexing the
					$rolesByUse = array();
					foreach ( $this->roleTypes as $usedOn => $roleType )
					{
						foreach ( $roleType as $roleUri => $roleDetails )
						{
							if ( ! isset( $rolesByUse[ $roleUri ] ) ) $rolesByUse[ $roleUri ] = array();
							if ( in_array( $usedOn, $rolesByUse[ $roleUri ] ) ) continue;
							$rolesByUse[ $roleUri ][] = $usedOn;
						}
					}

					foreach ( $roleTypes as $roleTypesKey => $roleType )
					{
						$id = (string) $roleType->attributes()->id;
						$roleUri = (string) $roleType->attributes()->roleURI;

						if ( $this->isValidating() )
						{
							if ( $id )
							{
								$pattern = "/^" . SchemaTypes::$ncName . "$/u";
								if ( ! preg_match( $pattern, $id, $matches ) )
								{
									$this->log()->taxonomy_validation( "Role Type", "id attribute is not a valid NCName", array( 'id' => $id ) );
								}
							}
							if ( ! $roleUri )
							{
								$this->log()->taxonomy_validation( "Role Type", "roleURI attribute does not exist or is empty", array() );
							}
						}

						$qnames = array();
						$roleUseOnList = array();

						foreach ( $roleType->usedOn as $usedOnKey => /** @var SimpleXMLElement $usedOn  */ $usedOn )
						{
							// This weird use of DOMElement and DOMXPath occurs because SimpleXMLElement does not
							// allow access to namespaces defined on a specific element. The conformance suite
							// test 205.07 includes an example of the prefix 'foo' being defined twice: once on
							// each of two 'usedOn' elements but with different namespace values.  SimpleXMLElement
							// getDocNamespaces() function only picks up the first use of 'foo' which is a problem
							// because then the link usedOn values appear to be the same when they are not.
							// The use of DOMElement allows these uses of 'foo' to be disambiguated.
							$prefixes = array();
							/**
							 * @var DOMElement $el
							 */
							$el = dom_import_simplexml( $usedOn );
							$xpath = new DOMXPath( $el->ownerDocument );
							foreach ( $xpath->query( 'namespace::*', $el ) as $node )
							{
								$prefixes[ str_replace( array( 'xmlns', ':' ), array( '', '' ), $node->nodeName ) ] = $node->nodeValue;
							}
							$qname = qname( (string) $usedOn, $prefixes );
							$qnames[] = (string) $qname;
							if ( is_null( $qname->prefix ) && $qname->namespaceURI == XBRL_Constants::$standardPrefixes[ STANDARD_PREFIX_LINK ] )
							{
								$qname->prefix = STANDARD_PREFIX_LINK;
							}

							if ( $qname->localName == 'label' && ! isset( $this->context->labelRoleRefs[ $roleUri ] ) )
							{
								$this->context->labelRoleRefs[ $roleUri ] = array(
									'type' => 'simple',
									'href' => basename( $this->schemaLocation ) . "#$id",
									'roleUri' => $roleUri,
								);
							}

							$roleUseOnList[] = "{$qname->prefix}:{$qname->localName}";
						}

						$duplicates = array_filter( array_count_values( $qnames ), function( $count ) { return $count > 1; } );

						if ( $duplicates )
						{
							$this->log()->taxonomy_validation( "5.1.3.4", "Used on values in role type definitions should not be duplicated" , array(
								'usedOn' => implode( ", ", array_map( function( $qname ) use( $prefixes ) {
									$q = qname( $qname, $prefixes ); return "{$q->prefix}:{$q->localName}";
								}, array_keys( $duplicates ) ) ) ,
								'roleType' => "'$roleUri'",
							) );
						}

						if ( isset( $rolesByUse[ $roleUri ] ) && count( $rolesByUse[ $roleUri ] ) )
						{
							// Make sure the list of usedOn items are consistent.
							// All of the existing ones MUST be present in the new one.
							if ( count( array_intersect( $rolesByUse[ $roleUri ], $roleUseOnList ) ) != count( $rolesByUse[ $roleUri ] ) )
							{
								$this->log()->taxonomy_validation( "5.1.3.4", "Role types cannot be redefined.  Within a <roleType> element there MUST NOT be S-Equal <usedOn> elements",
									array(
										'role' => $roleUri,
										'usedOn' => implode( ",", $roleUseOnList ),
										'alreadyUsedOn' => implode( ",", $rolesByUse[ $roleUri ] ),
									)
								);
							}
						}

						// Look for the new usedOn entries
						if ( isset( $rolesByUse[ $roleUri ] ) )
						{
							$roleUseOnList = array_diff( $roleUseOnList, $rolesByUse[ $roleUri ] );
						}

						$rt = array(
							'definition' => (string) $roleType->definition,
							'roleURI' => $roleUri,
							'taxonomy' => $this->schemaLocation,
							'id' => $id,
						);

						foreach ( $roleUseOnList as $usedOn )
						{
							if ( ! isset( $this->roleTypes[ $usedOn ] ) )
							{
								$this->roleTypes[ $usedOn ] = array();
							}

							$this->roleTypeIds[ $id ] = "$usedOn/$roleUri";
							$this->roleTypes[ $usedOn ][ $roleUri ] = $rt;
							$rolesByUse[ $roleUri ][] = $usedOn;
						}
					}
				}
			}
		}
	}
379300
def add_role_type_info(self, role_type, config):
    
    rt_config = config_to_api_list(config)
    rt_config['roleType'] = role_type

    if self.config is None:
      self.config = { }
    if not self.config.has_key(ROLETYPES_CFG_KEY):
      self.config[ROLETYPES_CFG_KEY] = [ ]
    self.config[ROLETYPES_CFG_KEY].append(rt_config)
971263
public function getTypes()
    {
        $types = array();

        $typeStrings = $this->soapClient->__getTypes();
        foreach ($typeStrings as $typeString) {
            $type = new TypeNode($typeString);
            $element = $this->findTypeElement($type->getName());
            if (!empty($element)) {
                $type->setElement($this->document, $element);
            }

            $types[] = $type;
        }

        return $types;
    }
679645
public function createCrud()
    {
        $fieldTypes        = FieldsDescriber::types();
        $fieldValidation   = FieldsDescriber::validation();
        $defaultValuesCbox = FieldsDescriber::default_cbox();
        $menusSelect       = Menu::whereNotIn('menu_type', [2, 3])->pluck('title', 'id');
        $roles             = Role::all();
        $parentsSelect     = Menu::where('menu_type', 2)->pluck('title', 'id')->prepend('-- no parent --', '');
        // Get columns for relationship
        $models = [];
        foreach (Menu::whereNotIn('menu_type', [2, 3])->get() as $menu) {
            // We are having a default User model
            if ($menu->title == 'User' && $menu->is_menu == 0) {
                $tableName = 'users';
            } else {
                $tableName = strtolower($menu->name);
            }
            $models[$menu->id] = Schema::getColumnListing($tableName);
        }

        return view("qa::menus.createCrud",
            compact('fieldTypes', 'fieldValidation', 'defaultValuesCbox', 'menusSelect', 'models', 'parentsSelect',
                'roles'));
    }
479993
private function createDummyContent()
    {
        $this->info("Creating default roles...");
        UserGroup::createDefaultRoles();
        $this->advanceBar();

        $this->info("Creating admin user...");
        $this->createAdminUser();
        $this->advanceBar();

        // Create Default Language
        $this->info("Creating default language...");
        factory(\App\Models\Language::class)->create(
            [
            'name' => $this->PRIMARY_LANGUAGE->name,
            'nativeName' => $this->PRIMARY_LANGUAGE->nativeName,
            'slug' => $this->PRIMARY_LANGUAGE->slug,
            'isDefault' => true
            ]
        );
        $this->advanceBar();

        $this->info("Creating default post types...");
        (new \PostTypeSeeder())->createDefaultPostTypes();
        $this->advanceBar();

        // Create tags example
        $this->info("Creating example tags...");
        (new \TagSeeder())->run(20, null, true);
        $this->advanceBar();

        // Create a category
        $this->info("Creating an example category...");
        $categoryObj = new \CategorySeeder();
        $categoryObj->exampleTitles = true;
        $categoryObj->run(3, null);
        $this->advanceBar();

        $this->info("Creating example posts...");
        (new \PostSeeder())->run(0, 5, '', 0, 0, 0, false);
        $this->advanceBar();

        // Create default permalinks
        $this->info("Creating default permalinks...");
        (new \PermalinksTableSeeder())->run();
        $this->advanceBar();

        // Creating settings
        $this->info("Saving settings...");
        $this->setSettings();
        $this->advanceBar();

        // Create Primary Menu
        $this->info("Creating primary Menu...");
        $menuSeeder = new \MenuSeeder();
        $menu = $menuSeeder->createPrimaryMenu();
        $menuSeeder->addHomepageToPrimaryMenu($menu);
        $menuSeeder->addAboutToPrimaryMenu($menu);
        $menuSeeder->addCategoryToMenu($menu);
        $this->advanceBar();

        return $this;
    }
1219644
protected function createComponentRolesList(): DataGrid
	{
		$grid = $this->dataGridFactory->create();

		$grid->setDataSource($this->orm->aclRoles->findRoles($this->viewSuperadmin));

		$grid->addColumnText('title', 'cms.permissions.role')
			->setEditableInputType('text')
			->setEditableCallback([$this, 'setRoleTitle']);

		$grid->addColumnText('name', 'cms.permissions.name')
			->setEditableInputType('text')
			->setEditableCallback([$this, 'setRoleName']);

		$grid->addColumnText('parent', 'cms.permissions.parent')
			->setRenderer(function (AclRole $role) {
				if (!empty($role->parent)) {
					return $role->parent->title;
				}
				return null;
			})
			->setEditableInputTypeSelect([0 => $this->translate('form.none')] + $this->orm->aclRoles->fetchPairs($this->viewSuperadmin))
			->setEditableCallback([$this, 'setRoleParent']);

		$grid->addAction('edit', null, 'editRolePermissions')
			->setIcon('pencil')
			->setTitle('default.edit');

		$grid->addAction('delete', null, 'deleteRole!')
			->setIcon('trash')
			->setTitle('default.delete')
			->setClass('btn btn-xs btn-danger ajax')
			->setConfirm(function (AclRole $role) {
				return $this->translate('cms.permissions.confirmDeleteRole', 1, ['name' => $role->title]);
			});

		$add = $grid->addInlineAdd()
			->setPositionTop()
			->setTitle('cms.permissions.addRole');
		$add->onControlAdd[] = [$this, 'roleForm'];
		$add->onSubmit[] = [$this, 'addRole'];

		$grid->addGroupAction('default.delete')->onSelect[] = [$this, 'deleteRoles'];

		return $grid;
	}
1041567
public function requireDefaultRecords()
    {
        $records = (array) Config::inst()->get(get_class($this), 'default_records');
        foreach ($records as $name) {
            $type = TaxonomyType::get()->filter('Name', $name)->first();
            if (!$type) {
                $type = TaxonomyType::create(array('Name' => $name));
                $type->write();
            }
        }
    }
1364356
protected function createSchema()
    {
        $schema = new ModelSchema("tblAuthenticationRole");
        $schema->addColumn(
            new AutoIncrementColumn("RoleID"),
            new StringColumn("RoleName", 40)
        );

        $schema->labelColumnName = "RoleName";

        return $schema;
    }
907989
public function getRolesForUserCreation(): array
    {
        $roles = [];

        if (auth()->check()) {
            /** @var HCUser $user */
            $user = auth()->user();

            if ($user->isSuperAdmin()) {
                $roles = HCAclRole::select('id', 'name as label')->orderBy('name')->get()->toArray();
            } else {
                foreach ($user->roles as $role) {
                    $roles[] = [
                        'id' => $role->id,
                        'label' => $role->name,
                    ];
                }
            }
        }

        return $roles;
    }
362250
protected function initialisation()
	{
		foreach($this->table_schema as $name => $prop)
		{
			$this->columns[] = 't.' . $name;
			$this->filter_columns[] = $name;
			if( $this->check_type )
			{
				$this->setType($prop["type"], $name);
			}
		}
	}
741457
protected static function createGeneral()
	{
	    $roleModel = new \erdiko\users\models\Role;
        $roleGeneral = $roleModel->findByName('general');
        if (empty($roleGeneral)) {
            throw new \Exception('Role general not found.');
        }

		$entity = new entity();
		$entity->setId( 0 );
		$entity->setRole( $roleGeneral->getId() );
		$entity->setName( 'user' );
		$entity->setEmail( 'user' );
		return $entity;
	}
607575
public function roleListAction()
    {
        $roles = $this->roleManager->getAllPlatformRoles();
        $counts = [];

        foreach ($roles as $role) {
            $counts[$role->getName()] = $this->roleManager->countUsersByRoleIncludingGroup($role);
        }

        return array('roles' => $roles, 'counts' => $counts);
    }
825383
public function newAction() {

        $entity = new Role();

        $form = $this->createCreateForm($entity);

        return array(
            'entity' => $entity,
            'form' => $form->createView(),
        );
    }
414105
public function run()
    {
        /*
         * Role Types
         *
         */
        $RoleItems = [
            [
                'name'        => 'Admin',
                'slug'        => 'admin',
                'description' => 'Admin Role',
                'level'       => 5,
            ],
            [
                'name'        => 'User',
                'slug'        => 'user',
                'description' => 'User Role',
                'level'       => 1,
            ],
            [
                'name'        => 'Unverified',
                'slug'        => 'unverified',
                'description' => 'Unverified Role',
                'level'       => 0,
            ],
        ];

        /*
         * Add Role Items
         *
         */
        echo "\e[32mSeeding:\e[0m DefaultRoleItemsTableSeeder\r\n";
        foreach ($RoleItems as $RoleItem) {
            $newRoleItem = config('roles.models.role')::where('slug', '=', $RoleItem['slug'])->first();
            if ($newRoleItem === null) {
                $newRoleItem = config('roles.models.role')::create([
                    'name'          => $RoleItem['name'],
                    'slug'          => $RoleItem['slug'],
                    'description'   => $RoleItem['description'],
                    'level'         => $RoleItem['level'],
                ]);
                echo "\e[32mSeeding:\e[0m DefaultRoleItemsTableSeeder - Role:".$RoleItem['slug']."\r\n";
            }
        }
    }
1313645
public function process_roles_role($data) {

        if (!$this->has_xml_writer()) {
            $this->open_xml_writer('roles.xml');
            $this->xmlwriter->begin_tag('roles_definition');
        }
        if (!isset($data['nameincourse'])) {
            $data['nameincourse'] = null;
        }
        $this->write_xml('role', $data, array('role/id'));
    }
758162
public function loadRoles()
    {
        $data = $this->roleGateway->loadRoles();

        $roles = $this->mapper->mapRoles($data);
        foreach ($roles as $role) {
            foreach ($role->policies as $policy) {
                $this->limitationConverter->toSPI($policy);
            }
        }

        return $roles;
    }
167514
public function DefaultRoles() {
      $this->Permission('Garden.Settings.Manage');
      $this->AddSideMenu('');

      $this->Title(T('Default Roles'));

      // Load roles for dropdowns.
      $RoleModel = new RoleModel();
      $this->SetData('RoleData', $RoleModel->Get());

      if ($this->Form->AuthenticatedPostBack() === FALSE) {
         // Get a list of default member roles from the config.
         $DefaultRoles = C('Garden.Registration.DefaultRoles');
         $this->Form->SetValue('DefaultRoles', $DefaultRoles);

         // Get the guest roles.
         $GuestRolesData = $RoleModel->GetByUserID(0);
         $GuestRoles = ConsolidateArrayValuesByKey($GuestRolesData, 'RoleID');
         $this->Form->SetValue('GuestRoles', $GuestRoles);

         // The applicant role.
         $ApplicantRoleID = C('Garden.Registration.ApplicantRoleID', '');
         $this->Form->SetValue('ApplicantRoleID', $ApplicantRoleID);
      } else {
         $DefaultRoles = $this->Form->GetFormValue('DefaultRoles');
         $ApplicantRoleID = $this->Form->GetFormValue('ApplicantRoleID');
         SaveToConfig(array(
            'Garden.Registration.DefaultRoles' => $DefaultRoles,
            'Garden.Registration.ApplicantRoleID' => $ApplicantRoleID));

         $GuestRoles = $this->Form->GetFormValue('GuestRoles');
         $UserModel = new UserModel();
         $UserModel->SaveRoles(0, $GuestRoles, FALSE);

         $this->InformMessage(T("Saved"));
      }

      $this->Render();
   }