Finds and returns the new role id by old id.

@param int $oldRoleId

@return int|null
186311
protected function getNewRoleId($oldRoleId)
    {
        if (empty($oldRoleId)) {
            return null;
        }

        $roles = $this->package->getResourceFromZip('system/role.json');
        $roleName = null;
        foreach ($roles as $role) {
            if ($oldRoleId === $role['id']) {
                $roleName = $role['name'];
                break;
            }
        }

        if (!empty($roleName)) {
            $newRole = Role::whereName($roleName)->first(['id']);
            if (!empty($newRole)) {
                return $newRole->id;
            }
        }

        return null;
    }
768660
public function getGatewayCustomerId($uid)
    {
		$result = 0;
		$user   = $this->findUser( $uid );
		if (! is_null($user)) {
			$result = intval($user->getGatewayCustomerId());
		}

		return $result;
	}
308838
public function GetForRole($RoleID = '', $Offset = '0', $Limit = '50') {
      if (!is_array($RoleID))
         $RoleID = array($RoleID);
      
      $Offset = is_numeric($Offset) ? $Offset : 0;
      if ($Offset < 0)
         $Offset = 0;

      $Limit = is_numeric($Limit) ? $Limit : 0;
      if ($Limit < 0)
         $Limit = 0;
      
      $this->ActivityQuery();
      $Result = $this->SQL
         ->Join('UserRole ur', 'a.ActivityUserID = ur.UserID')
         ->WhereIn('ur.RoleID', $RoleID)
         ->Where('t.Public', '1')
         ->OrderBy('a.DateInserted', 'desc')
         ->Limit($Limit, $Offset)
         ->Get();
         
      $this->EventArguments['Data'] =& $Result;
      $this->FireEvent('AfterGet');
      
      return $Result;
   }
895525
public function getRole(string $id = null): array
    {
        if ($id) {
            if (is_numeric($id)) {
                $filter = array_filter($this->role, function ($row) use ($id) { return $row['id'] == $id; });
                return (array) array_pop($filter);
            }
            return (array) ($this->role[$id] ?? []);
        }
        return $this->role;
    }
1073330
public function checkRole( $role, $parent = null )
    {
        if ( null === $role )
        {
            return null;
        }

        if ( $role instanceof Acl\Role\RoleInterface )
        {
            $role = $role->getRoleId();
        }

        $acl = $this->getAcl();

        if ( ! $acl->hasRole( $role ) )
        {
            if ( null === $parent )
            {
                $parent = $this->getParentId( $role );
            }
            elseif ( $parent instanceof Acl\Role\RoleInterface )
            {
                $parent = $parent->getRoleId();
            }

            $parent = $this->checkRole( $parent );
            $acl->addRole( $role, (array) $parent );

            $matches    = array();
            $structures = array();

            if ( preg_match( '/^(\d+)$/', $role, $matches ) ) //group
            {
                $structures = $this->getMapper()
                                   ->findAllByGroupId( $matches[1] );
            }
            else if ( preg_match( '/^(\d+)\.(\d+)$/', $role, $matches ) ) //user
            {
                $structures = $this->getMapper()
                                   ->findAllByUserId( $matches[2] );

                $resource = 'user.group.' . $matches[1] .
                            '.identity.' . $matches[2];

                $this->checkResource( $resource );
                $acl->allow( $role, $resource );
            }

            foreach ( $structures as $structure )
            {
                $this->checkResource( $structure->resource );
                $acl->allow( $role, $structure->resource, $structure->privilege );
            }
        }

        return $role;
    }
1104224
public function setRoleId($v)
    {
        if ($v !== null && is_numeric($v)) {
            $v = (int) $v;
        }

        if ($this->role_id !== $v) {
            $this->role_id = $v;
            $this->modifiedColumns[] = UserRolePeer::ROLE_ID;
        }

        if ($this->aRole !== null && $this->aRole->getId() !== $v) {
            $this->aRole = null;
        }


        return $this;
    }
1120871
public function getRelativeRoleName($role)
    {
        $roles = $this->collectRelativeRoles();
        if (isset($roles[$role])) {
            return $roles[$role];
        }
    }
1075363
public function getRole($identifier)
    {
        $role = null;
        try {
            $role = $this->roleService->loadRoleByIdentifier($identifier);
        } catch (ApiExceptions\NotFoundException $e) {
            // Role not found, do nothing, returns null
        }

        return $role;
    }
1303596
public function loadRoleAssignment($roleAssignmentId)
    {
        $data = $this->roleGateway->loadRoleAssignment($roleAssignmentId);

        if (empty($data)) {
            throw new NotFound('roleAssignment', $roleAssignmentId);
        }

        return $this->mapper->mapRoleAssignments($data)[0];
    }
191148
public function getRoleUser($uid) {

        if (empty($this->roleUser)){

            $role_user_data = $this->config['auth_cache'] ? Session::get($this->getRoleUserKey()) : [];

            if (empty($role_user_data) || !is_array($role_user_data)){

                $where = [];
                $where['user_id'] = $uid;
                $role_user_list = Db::name($this->config['role_user'])
                    ->field('role_id')
                    ->where($where)
                    ->select();

                $role_user_data = array_column($role_user_list,'role_id');

                //dump($role_user_data);

                if (empty($role_user_data)) return false;

                if ($this->config['auth_cache'])
                    Session::set($this->getRoleUserKey(),$role_user_data);
            }

            $this->roleUser = $role_user_data;

        }

        return $this->roleUser;
    }
690651
public function getRole()
    {
        if ( null === $this->role )
        {
            $auth = $this->getAuthenticationService();

            if ( $auth->hasIdentity() )
            {
                $this->role = $auth->getIdentity();
            }
            else
            {
                $this->role = new Acl\Role\GenericRole( self::ROLE_GUEST_ID );
            }
        }

        return $this->role;
    }
349062
public function add_expiredroles(array $roleids) : expired_context {
        $existing = $this->get('expiredroles');
        $newvalue = array_merge($existing, $roleids);

        $this->set('expiredroles', $newvalue);

        return $this;
    }
183212
public function getRole($uri)
    {
        $returnValue = null;

        if(!empty($uri)){
        	$returnValue = new core_kernel_classes_Resource($uri);
        }

        return $returnValue;
    }
584441
protected function findRole($role)
    {
        // Try to see if we have a role registered for the given
        // key so we can determine the role's inheritances.
        if (array_key_exists($role, $this->roles)) {
            return $this->roles[$role];
        }

        // If we couldn't find a registered role for the
        // given key, just return a new role object.
        return new SimpleRole($role);
    }
1116771
protected function getListRole()
    {
        $id = $this->getParam(0);

        if (!isset($id)) {
            return $this->role->getList(array('limit' => $this->getLimit()));
        }

        if (empty($id) || !is_numeric($id)) {
            $this->errorAndExit($this->text('Invalid argument'));
        }

        $result = $this->role->get($id);

        if (empty($result)) {
            $this->errorAndExit($this->text('Unexpected result'));
        }

        return array($result);
    }
778429
public static function getRoleId($role)
    {
        $map = [
            self::ENUM_ROLE_ADMIN => self::ENUM_ROLE_ADMIN_ID,
            self::ENUM_ROLE_USER  => self::ENUM_ROLE_USER_ID,
        ];

        // do not check if key exist deliberately. If wrong role is given it will cause an error.
        return $map[$role];
    }
1191624
protected function _getRoleIds()
    {
        $ids = [];
        if (!$this->has('roles')) {
            return $ids;
        }
        foreach ($this->roles as $k => $role) {
            $ids[] = $role->id;
        }

        return $ids;
    }