30 if ($this->roles ===
null)
38 $relationRows = RoleRelationTable::query()
39 ->addSelect(
'ROLE_ID')
45 $this->roles = array_unique(
46 array_column($relationRows,
'ROLE_ID')
65 $permissions = $this->getPermissions();
67 $permissions[$permissionId] = $permissions[$permissionId] ??
null;
69 if (is_array($permissions[$permissionId]))
71 $permissions[$permissionId] =
72 isset($permissions[$permissionId][0])
73 ? (int)$permissions[$permissionId][0]
78 return $permissions[$permissionId];
95 return [PermissionDictionary::VALUE_VARIATION_ALL];
98 $permissions = $this->getPermissions();
99 $permissions[$permissionId] = $permissions[$permissionId] ??
null;
101 return is_array($permissions[$permissionId]) ? $permissions[$permissionId] :
null;
110 private function getPermissions(): array
112 if ($this->permissions !==
null)
114 return $this->permissions;
117 $this->permissions = [];
122 return $this->permissions;
125 $query = PermissionTable::query();
127 $permissions = $query
128 ->addSelect(
"PERMISSION_ID")
130 ->whereIn(
"ROLE_ID",
$roles)
134 while ($permission = $permissions->fetch())
136 $permissionId = $permission[
"PERMISSION_ID"];
137 $value = (int)$permission[
"VALUE"];
139 $permissionDescription = PermissionDictionary::getPermission($permissionId);
140 if ($permissionDescription[
'type'] === PermissionDictionary::TYPE_MULTIVARIABLES)
142 $this->permissions[$permissionId] = $this->permissions[$permissionId] ?? [];
143 if (in_array(PermissionDictionary::VALUE_VARIATION_ALL, $this->permissions[$permissionId],
true))
148 if ($value === PermissionDictionary::VALUE_VARIATION_ALL)
150 $this->permissions[$permissionId] = [$value];
152 elseif (!in_array($value, $this->permissions[$permissionId],
true))
154 $this->permissions[$permissionId][] = $value;
159 $this->permissions[$permissionId] = $this->permissions[$permissionId] ?? 0;
160 if ($value > $this->permissions[$permissionId])
162 $this->permissions[$permissionId] = $value;
167 return $this->permissions;
175 return \CUser::GetUserGroup($this->userId);