43 public static function getInstance(
int $a_user_id,
int $a_ref_id): self
45 if (!isset(self::$instances[$a_user_id][$a_ref_id])) {
46 self::$instances[$a_user_id][$a_ref_id] =
new static($a_user_id, $a_ref_id);
48 return self::$instances[$a_user_id][$a_ref_id];
56 $this->context_ids = array();
64 $this->user_id = $a_value;
72 protected function setRefId(
int $a_value): void
74 $this->ref_id = $a_value;
88 abstract protected function readContextIds(
int $a_context_type): array;
103 string $a_context_id,
105 ?
int $a_action_sub_id = null
109 if (array_key_exists($a_context_type, $this->map)) {
110 if (!$a_action_sub_id) {
111 if (in_array($a_action_id, $this->map[$a_context_type][
"actions"])) {
115 if (array_key_exists($a_action_id, $this->map[$a_context_type][
"subactions"]) &&
116 in_array($a_action_sub_id, $this->map[$a_context_type][
"subactions"][$a_action_id])) {
129 trigger_error(
"INVALID permission context - " . $a_context_type .
":" . $a_context_id .
":" . $a_action_id .
":" . $a_action_sub_id, E_USER_WARNING);
142 if (!array_key_exists($a_context_type, $this->context_ids)) {
143 $this->context_ids[$a_context_type] = $this->
readContextIds($a_context_type);
145 return (array) $this->context_ids[$a_context_type];
153 string $a_context_id,
155 ?
int $a_action_sub_id = null
158 return $this->
checkPermission($a_context_type, $a_context_id, $a_action_id, $a_action_sub_id);
167 public function hasPermissions(
int $a_context_type,
string $a_context_id, array $a_action_ids): array
171 foreach ($a_action_ids as $action_id) {
172 if (is_array($action_id)) {
173 $action_sub_id = $action_id[1];
174 $action_id = $action_id[0];
176 $res[$action_id][$action_sub_id] = $this->
hasPermission($a_context_type, $a_context_id, $action_id, $action_sub_id);
178 $res[$action_id] = $this->
hasPermission($a_context_type, $a_context_id, $action_id);
190 string $a_context_id,
192 ?
int $a_action_sub_id = null
195 $this->
checkPlugins($a_context_type, (
string) $a_context_id, $a_action_id, $a_action_sub_id));
204 $ilAccess = $DIC->access();
207 return $ilAccess->checkAccessOfUser($this->
getUserId(),
"write",
"", $this->
getRefId());
220 string $a_context_id,
222 ?
int $a_action_sub_id = null
226 if (!is_array($this->plugins)) {
230 foreach ($this->plugins as
$plugin) {
231 $a_action_sub_id = is_null($a_action_sub_id)
234 if (!$plugin->checkPermission($this->getUserId(), $a_context_type, $a_context_id, $a_action_id, $a_action_sub_id)) {
248 $accepted_types = [
'cat',
'crs',
'sess',
'grp',
'iass',
'exc'];
251 $adv_md_types = $obj_def->getAdvancedMetaDataTypes();
253 $valid_accepted_types = array();
254 foreach ($adv_md_types as $value) {
255 if (in_array($value[
'obj_type'], $accepted_types) || in_array($value[
'sub_type'], $accepted_types)) {
256 array_push($valid_accepted_types, $value[
'obj_type']);
260 return $valid_accepted_types;
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getValidContextIds(int $a_context_type)
Get context ids for context type (uses cache)
checkPermission(int $a_context_type, string $a_context_id, int $a_action_id, ?int $a_action_sub_id=null)
Check permission (helper: rbac, plugins)
hasPermissions(int $a_context_type, string $a_context_id, array $a_action_ids)
Check permissions.
getActivePlugins()
Get active plugins (for current slot)
buildPermissionMap()
Build map of context and actions.
reset()
Reset (internal caches)
parses the objects.xml it handles the xml-description of all ilias objects
checkRBAC()
Check permission against RBAC.
hasPermission(int $a_context_type, string $a_context_id, int $a_action_id, ?int $a_action_sub_id=null)
Check permission.
readContextIds(int $a_context_type)
Get all context ids for context type (from DB, is cached)
isValidContextAndAction(int $a_context_type, string $a_context_id, int $a_action_id, ?int $a_action_sub_id=null)
Check if given combination of context and action is valid.
static getInstance(int $a_user_id, int $a_ref_id)
__construct(int $a_user_id, int $a_ref_id)
checkPlugins(int $a_context_type, string $a_context_id, int $a_action_id, ?int $a_action_sub_id=null)
Check permission against plugins.
const SUBACTION_UNDEFINED