42 (isset($ilDB)) ? $this->
ilDB =& $ilDB : $this->
ilDB =& $ilias->db;
87 $ilBench->start(
"RBAC",
"system_checkAccess");
91 $ilBench->stop(
"RBAC",
"system_checkAccess");
101 $cacheKey = $a_user_id.
':'.$a_operations.
':'.$a_ref_id.
':'.$a_type;
104 if (! is_array(self::$_checkAccessOfUserCache)) {
105 self::$_checkAccessOfUserCache = array();
109 if (array_key_exists($cacheKey, self::$_checkAccessOfUserCache)) {
110 return self::$_checkAccessOfUserCache[$cacheKey];
124 if (count(self::$_checkAccessOfUserCache) < 1000) {
125 self::$_checkAccessOfUserCache[$cacheKey] =
true;
135 if (in_array(SYSTEM_ROLE_ID, $roles))
139 if (count(self::$_checkAccessOfUserCache) < 1000) {
140 self::$_checkAccessOfUserCache[$cacheKey] =
true;
145 if (!isset($a_operations) or !isset($a_ref_id))
148 $this->ilErr->raiseError(get_class($this).
"::checkAccess(): Missing parameter! ".
149 "ref_id: ".$a_ref_id.
" operations: ".$a_operations,$this->ilErr->WARNING);
152 if (!is_string($a_operations))
155 $this->ilErr->raiseError(get_class($this).
"::checkAccess(): Wrong datatype for operations!",$this->ilErr->WARNING);
159 $paCacheKey = $a_user_id.
':'.$a_ref_id;
160 if (! is_array(self::$_paCache)) {
161 self::$_paCache = array();
164 if (array_key_exists($paCacheKey, self::$_paCache)) {
166 $ops = self::$_paCache[$paCacheKey];
171 $q =
"SELECT * FROM rbac_pa ".
172 "WHERE ref_id = ".$ilDB->quote($a_ref_id,
'integer');
180 if (in_array(
$row->rol_id, $roles))
182 $ops = array_merge($ops,unserialize(stripslashes(
$row->ops_id)));
186 if (count(self::$_paCache) < 1000)
188 self::$_paCache[$paCacheKey] = $ops;
192 $operations = explode(
",",$a_operations);
193 foreach ($operations as $operation)
195 if ($operation ==
"create")
199 $this->ilErr->raiseError(get_class($this).
"::CheckAccess(): Expect a type definition for checking a 'create' permission",
200 $this->ilErr->WARNING);
209 if (! in_array($ops_id,(array) $ops))
214 if (count(self::$_checkAccessOfUserCache) < 1000)
216 self::$_checkAccessOfUserCache[$cacheKey] =
false;
224 if (count(self::$_checkAccessOfUserCache) < 1000)
227 self::$_checkAccessOfUserCache[$cacheKey] =
true;
242 if (!is_array($a_ref_ids))
248 foreach ($a_ref_ids as
$ref_id)
250 if (!isset(self::$_paCache[$a_user_id.
":".$ref_id]))
258 if (count($ref_ids) > 0)
262 $q =
"SELECT * FROM rbac_pa ".
263 "WHERE ".$ilDB->in(
"ref_id", $ref_ids,
false,
"integer");
269 if (in_array(
$row->rol_id, $roles[
$row->ref_id]))
271 $ops[
$row->ref_id] = array_merge($ops[
$row->ref_id],
272 unserialize(stripslashes(
$row->ops_id)));
275 foreach ($a_ref_ids as $ref_id)
278 if (!isset(self::$_paCache[$a_user_id.
":".$ref_id]))
300 $query =
'SELECT ops_id FROM rbac_operations '.
301 'WHERE operation = '.$ilDB->quote($a_operation,
'text');
303 while(
$row = $ilDB->fetchObject(
$res))
305 $ops_id =
$row->ops_id;
308 $query =
"SELECT * FROM rbac_pa ".
309 "WHERE rol_id = ".$ilDB->quote($a_rol_id,
'integer').
" ".
310 "AND ref_id = ".$ilDB->quote($a_ref_id,
'integer').
" ";
313 while(
$row = $ilDB->fetchObject(
$res))
315 $ops = array_merge($ops,unserialize(
$row->ops_id));
317 return in_array($ops_id,$ops);
322 global $ilObjDataCache,
$ilUser;
325 if($this->mem_view[
'active'] and $a_user_id == $ilUser->getId())
327 if(in_array($a_ref_id, $this->mem_view[
'items']))
329 return $a_operations;
333 if($a_user_id != $ilObjDataCache->lookupOwner($ilObjDataCache->lookupObjId($a_ref_id)))
335 return $a_operations;
339 foreach(explode(
",",$a_operations) as $operation)
341 if($operation !=
'cat_administrate_users' and $operation !=
'edit_permission' and $operation !=
'edit_learning_progress' and $operation !=
'read_learning_progress' and !preg_match(
'/^create/',$operation))
345 if(!strlen($new_ops))
347 $new_ops = $operation;
351 $new_ops .= (
','.$operation);
372 if($this->mem_view[
'active'] and $a_usr_id == $ilUser->getId())
375 if(in_array($a_ref_id, $this->mem_view[
'items']) and $this->mem_view[
'role'])
378 return array($this->mem_view[
'role']);
382 if(isset(self::$user_role_cache[$a_usr_id]) and is_array(self::$user_role_cache))
384 return self::$user_role_cache[$a_usr_id];
389 return self::$user_role_cache[$a_usr_id] = $rbacreview->assignedRoles($a_usr_id);
398 include_once
'./Services/Container/classes/class.ilMemberViewSettings.php';
400 if($settings->isEnabled() and isset(
$_GET[
'mv']))
402 $settings->toggleActivation((
int)
$_GET[
'ref_id'], (
int) $_GET[
'mv']);
405 if(!$settings->isActive())
407 $this->mem_view[
'active'] =
false;
408 $this->mem_view[
'items'] = array();
409 $this->mem_view[
'role'] = 0;
415 $this->mem_view[
'active'] =
true;
416 $this->mem_view[
'items'] = $tree->getSubTreeIds($settings->getContainer());
417 $this->mem_view[
'items'] = array_merge($this->mem_view[
'items'],array($settings->getContainer()));
418 include_once
'./Services/Membership/classes/class.ilParticipants.php';
427 if(!in_array($a_role_id, self::$user_role_cache[$a_usr_id]))
429 self::$user_role_cache[$a_usr_id][] = $a_role_id;
435 $paCacheKey = $a_usr_id.
':'.$a_ref_id;
436 unset(self::$_paCache[$paCacheKey]);