47 public static function getInstance($a_user_id = null, $a_ref_id = null)
53 $a_user_id = $ilUser->getId();
59 if(!isset(self::$instances[$a_user_id][$a_ref_id]))
61 self::$instances[$a_user_id][$a_ref_id] =
new static($a_user_id, $a_ref_id);
63 return self::$instances[$a_user_id][$a_ref_id];
71 $this->context_ids = array();
84 $this->user_id = (int)$a_value;
104 $this->ref_id = (int)$a_value;
152 if(array_key_exists($a_context_type, $this->map))
154 if(!$a_action_sub_id)
156 if(in_array($a_action_id, $this->map[$a_context_type][
"actions"]))
163 if(array_key_exists($a_action_id, $this->map[$a_context_type][
"subactions"]) &&
164 in_array($a_action_sub_id, $this->map[$a_context_type][
"subactions"][$a_action_id]))
180 trigger_error(
"INVALID permission context - ".$a_context_type.
":".$a_context_id.
":".$a_action_id.
":".$a_action_sub_id, E_USER_WARNING);
195 if(!array_key_exists($a_context_type, $this->context_ids))
197 $this->context_ids[$a_context_type] = $this->
readContextIds($a_context_type);
199 return (array)$this->context_ids[$a_context_type];
211 public function hasPermission($a_context_type, $a_context_id, $a_action_id, $a_action_sub_id = null)
215 return $this->
checkPermission($a_context_type, $a_context_id, $a_action_id, $a_action_sub_id);
228 public function hasPermissions($a_context_type, $a_context_id, array $a_action_ids)
232 foreach($a_action_ids as $action_id)
234 if(is_array($action_id))
236 $action_sub_id = $action_id[1];
237 $action_id = $action_id[0];
239 $res[$action_id][$action_sub_id] = $this->
hasPermission($a_context_type, $a_context_id, $action_id, $action_sub_id);
243 $res[$action_id] = $this->
hasPermission($a_context_type, $a_context_id, $action_id);
259 protected function checkPermission($a_context_type, $a_context_id, $a_action_id, $a_action_sub_id = null)
262 $this->
checkPlugins($a_context_type, $a_context_id, $a_action_id, $a_action_sub_id));
275 return $ilAccess->checkAccessOfUser($this->
getUserId(),
"write",
"", $this->
getRefId());
294 protected function checkPlugins($a_context_type, $a_context_id, $a_action_id, $a_action_sub_id = null)
298 if(!is_array($this->plugins))
303 foreach($this->plugins as $plugin)
305 if(!$plugin->checkPermission($this->getUserId(), $a_context_type, $a_context_id, $a_action_id, $a_action_sub_id))