47 public static function getInstance($a_user_id = null, $a_ref_id = null)
56 $a_ref_id = (int) $_REQUEST[
"ref_id"];
58 if (!isset(self::$instances[$a_user_id][$a_ref_id])) {
59 self::$instances[$a_user_id][$a_ref_id] =
new static($a_user_id, $a_ref_id);
61 return self::$instances[$a_user_id][$a_ref_id];
69 $this->context_ids = array();
82 $this->user_id = (int) $a_value;
102 $this->ref_id = (int) $a_value;
150 if (array_key_exists($a_context_type, $this->map)) {
151 if (!$a_action_sub_id) {
152 if (in_array($a_action_id, $this->map[$a_context_type][
"actions"])) {
156 if (array_key_exists($a_action_id, $this->map[$a_context_type][
"subactions"]) &&
157 in_array($a_action_sub_id, $this->map[$a_context_type][
"subactions"][$a_action_id])) {
170 trigger_error(
"INVALID permission context - " . $a_context_type .
":" . $a_context_id .
":" . $a_action_id .
":" . $a_action_sub_id, E_USER_WARNING);
185 if (!array_key_exists($a_context_type, $this->context_ids)) {
186 $this->context_ids[$a_context_type] = $this->
readContextIds($a_context_type);
188 return (array) $this->context_ids[$a_context_type];
200 public function hasPermission($a_context_type, $a_context_id, $a_action_id, $a_action_sub_id = null)
203 return $this->
checkPermission($a_context_type, $a_context_id, $a_action_id, $a_action_sub_id);
216 public function hasPermissions($a_context_type, $a_context_id, array $a_action_ids)
220 foreach ($a_action_ids as $action_id) {
221 if (is_array($action_id)) {
222 $action_sub_id = $action_id[1];
223 $action_id = $action_id[0];
225 $res[$action_id][$action_sub_id] = $this->
hasPermission($a_context_type, $a_context_id, $action_id, $action_sub_id);
227 $res[$action_id] = $this->
hasPermission($a_context_type, $a_context_id, $action_id);
243 protected function checkPermission($a_context_type, $a_context_id, $a_action_id, $a_action_sub_id = null)
246 $this->
checkPlugins($a_context_type, $a_context_id, $a_action_id, $a_action_sub_id));
257 $ilAccess = $DIC->access();
260 return $ilAccess->checkAccessOfUser($this->
getUserId(),
"write",
"", $this->
getRefId());
279 protected function checkPlugins($a_context_type, $a_context_id, $a_action_id, $a_action_sub_id = null)
283 if (!is_array($this->plugins)) {
287 foreach ($this->plugins as
$plugin) {
288 if (!$plugin->checkPermission($this->getUserId(), $a_context_type, $a_context_id, $a_action_id, $a_action_sub_id)) {
302 $accepted_types = [
'cat',
'crs',
'sess',
'grp',
'iass',
'exc'];
305 $adv_md_types = $obj_def->getAdvancedMetaDataTypes();
307 $valid_accepted_types = array();
308 foreach ($adv_md_types as $idx => $value) {
309 if (in_array($value[
'obj_type'], $accepted_types) || in_array($value[
'sub_type'], $accepted_types)) {
310 array_push($valid_accepted_types, $value[
'obj_type']);
314 return $valid_accepted_types;
static getInstance($a_user_id=null, $a_ref_id=null)
Factory.
hasPermissions($a_context_type, $a_context_id, array $a_action_ids)
Check permissions.
Claiming permission helper base class.
checkPermission($a_context_type, $a_context_id, $a_action_id, $a_action_sub_id=null)
Check permission (helper: rbac, plugins)
readContextIds($a_context_type)
Get all context ids for context type (from DB, is cached)
getActivePlugins()
Get active plugins (for current slot)
buildPermissionMap()
Build map of context and actions.
hasPermission($a_context_type, $a_context_id, $a_action_id, $a_action_sub_id=null)
Check permission.
reset()
Reset (internal caches)
parses the objects.xml it handles the xml-description of all ilias objects
foreach($_POST as $key=> $value) $res
checkRBAC()
Check permission against RBAC.
isValidContextAndAction($a_context_type, $a_context_id, $a_action_id, $a_action_sub_id=null)
Check if given combination of context and action is valid.
setRefId($a_value)
Set ref id.
checkPlugins($a_context_type, $a_context_id, $a_action_id, $a_action_sub_id=null)
Check permission against plugins.
__construct($a_user_id, $a_ref_id)
Constructor.
setUserId($a_value)
Set user id.
getValidContextIds($a_context_type)
Get context ids for context type (uses cache)