@api public

 Load the registered roles into Sipity::Role
186473
def persist_registered_roles!
      @roles.each do |name, description|
        Sipity::Role.find_or_create_by!(name: name).tap do |role|
          role.description = description
          role.save!
        end
      end
    end
458728
def child(role)
      @cached_children ||= {}
      @cached_children[role.to_sym] ||= self.children.where(:role => role).first || :nil
      @cached_children[role.to_sym] == :nil ? nil : @cached_children[role.to_sym]
    end
1119290
def add_role(self, role_obj):
        
        role_node = role_obj.get_node()
        self.node.append(role_node)
807828
public function load_current_settings() {
        global $DB;
        // Load the current settings.
        $this->allowed = array();
        foreach ($this->roles as $role) {
            // Make an array $role->id => false. This is probably too clever for its own good.
            $this->allowed[$role->id] = array_combine(array_keys($this->roles), array_fill(0, count($this->roles), false));
        }
        $rs = $DB->get_recordset($this->tablename);
        foreach ($rs as $allow) {
            $this->allowed[$allow->roleid][$allow->{$this->targetcolname}] = true;
        }
        $rs->close();
    }
993416
private void init(List<CmsRole> roles) {

        CmsRole.applySystemRoleOrder(roles);
        m_menu = new CmsContextMenu();
        m_menu.setAsTableContextMenu(this);

        m_container = new IndexedContainer();

        for (TableProperty prop : TableProperty.values()) {
            m_container.addContainerProperty(prop, prop.getType(), prop.getDefault());
            setColumnHeader(prop, prop.getName());
        }
        setContainerDataSource(m_container);
        setItemIconPropertyId(TableProperty.Icon);
        setRowHeaderMode(RowHeaderMode.ICON_ONLY);

        setColumnWidth(null, 40);
        setSelectable(true);

        setVisibleColumns(TableProperty.Name, TableProperty.OU);

        for (CmsRole role : roles) {

            Item item = m_container.addItem(role);
            item.getItemProperty(TableProperty.Name).setValue(role.getName(A_CmsUI.get().getLocale()));
            item.getItemProperty(TableProperty.Description).setValue(role.getDescription(A_CmsUI.get().getLocale()));
            item.getItemProperty(TableProperty.OU).setValue(role.getOuFqn());
        }

        addItemClickListener(new ItemClickListener() {

            private static final long serialVersionUID = 4807195510202231174L;

            public void itemClick(ItemClickEvent event) {

                setValue(null);
                select(event.getItemId());
                if (event.getButton().equals(MouseButton.RIGHT) || (event.getPropertyId() == null)) {
                    m_menu.setEntries(
                        getMenuEntries(),
                        Collections.singleton(((CmsRole)getValue()).getId().getStringValue()));
                    m_menu.openForTable(event, event.getItemId(), event.getPropertyId(), CmsRoleTable.this);
                } else if (event.getButton().equals(MouseButton.LEFT)
                    && event.getPropertyId().equals(TableProperty.Name)) {
                    updateApp((CmsRole)getValue());
                }

            }

        });
        setCellStyleGenerator(new CellStyleGenerator() {

            private static final long serialVersionUID = 1L;

            public String getStyle(Table source, Object itemId, Object propertyId) {

                if (TableProperty.Name.equals(propertyId)) {
                    return " " + OpenCmsTheme.HOVER_COLUMN;
                }

                return "";
            }
        });
        setVisibleColumns(TableProperty.Name, TableProperty.Description, TableProperty.OU);
    }
93516
def initialize__(cls):
        
        [cls.new(level=r[0], name=r[1]) for r in cls.ROLES]
1054752
def set_roles(role, reason = nil)
      role_ids = role_id_array(role)
      API::Server.update_member(@bot.token, @server.id, @user.id, roles: role_ids, reason: reason)
    end
457247
def roles
      return [] if get_roles.nil?
      x = [get_roles].flatten.map do |role|
        role.respond_to?(:to_sym) ? role.to_sym : role
      end    
      x.first.kind_of?(Set) ? x.first.to_a : x
    end
1343204
protected function addRole()
    {
        if (!$this->isError()) {
            $id = $this->role->add($this->getSubmitted());
            if (empty($id)) {
                $this->errorAndExit($this->text('Unexpected result'));
            }
            $this->line($id);
        }
    }
1289678
public function addRole($role, array $resources = [])
    {
        if ($role instanceof RoleInterface) {
            $this->roles[$role->getName()] = $role;
        } else {
            $role = new Role($role, $resources);
            $this->roles[$role->getName()] = $role;
        }
    }
873250
private function load()
    {
        foreach ($this->resources as $key => $resource) {
            if (!$resource instanceof PuliResource) {
                $this->resources[$key] = $this->repo->get($resource);
            }
        }

        $this->loaded = true;
    }
1306718
def roles(*roles)
      opts = roles.last.is_a?(Hash) ? roles.pop : {}
      self.valid_roles = roles.flatten.map(&:to_sym)
      unless (opts[:dynamic] == false)
        self.define_dynamic_queries(self.valid_roles)
      end
    end
1359013
private function _initAcl()
    {
        $this->_acl = new \MUtil_Acl();

        if (get_class(self::$_instanceOfSelf)!=='Gems_Roles') {
            throw new \Gems_Exception_Coding("Don't use project specific roles file anymore, you can now do so by using the gems_roles tabel and setup->roles from the interface.");
        }
        // Probeer eerst uit db in te lezen met fallback als dat niet lukt
        try {
            $this->loadDbAcl();

        } catch (\Exception $e) {

            \Gems_Log::getLogger()->logError($e);

            // Reset all roles
            unset($this->_acl);
            $this->_acl = new \MUtil_Acl();

            //Voeg standaard rollen en privileges in
            $this->loadDefaultRoles();
            $this->loadDefaultPrivileges();
        }

        // Now allow 'master' all access, except for the actions that have the
        // nologin privilege (->the login action)
        if (!$this->_acl->hasRole('master')) {
            //Add role if not already present
            $this->_acl->addRole('master');
        }
        $this->_acl->allow('master');
        $this->_acl->deny('master', null, 'pr.nologin');
    }
986421
def assign(self, role):
        ''''''
        if role.owner_id != self.id:
            return self.roles.add(role)
1064168
def roles_to_embed *roles
      roles.flatten.inject([]) do |res, role| 
        res << create_role(role)
        res
      end
    end
190496
protected function initRegistries()
    {
        $this->roleRegistry = new Registry();
        $this->resourceRegistry = new Registry();
        $this->permissionRegistry = new Registry();
        $this->globalRegistry = new GlobalRegistry();
    }
564554
private function buildRoleMap() {
		
		$this->mappedRoleNames = [];

		foreach ($this->hierarchy as $parent => $roles) {

			$roles = array_map('strtolower', $roles);
			$this->mappedRoleNames[$parent] = $roles;
			$additionalRoles = $roles;
			$foundParent = [];

			// check for every role, whether there are other roles below it

			while ($role = array_shift($additionalRoles)) {

				if (!isset($this->hierarchy[$role])) {
					
					// role has no further sub-roles defined

					continue;
				}
		
				$foundParent[] = $role;
		
				foreach ($this->hierarchy[$role] as $roleToAdd) {
					$this->mappedRoleNames[$parent][] = $roleToAdd;
				}

				foreach (array_diff($this->hierarchy[$role], $foundParent) as $roleToAdd) {

					$additionalRoles[] = $roleToAdd;

				}
			}
		
			$this->mappedRoleNames[$parent] = array_unique($this->mappedRoleNames[$parent]);

		}
		
	}