62 (isset($ilDB)) ? $this->
ilDB =& $ilDB : $this->
ilDB =& $ilias->db;
107 $ilBench->start(
"RBAC",
"system_checkAccess");
111 $ilBench->stop(
"RBAC",
"system_checkAccess");
121 $cacheKey = $a_user_id.
':'.$a_operations.
':'.$a_ref_id.
':'.$a_type;
124 if (! is_array(self::$_checkAccessOfUserCache)) {
125 self::$_checkAccessOfUserCache = array();
129 if (array_key_exists($cacheKey, self::$_checkAccessOfUserCache)) {
130 return self::$_checkAccessOfUserCache[$cacheKey];
144 if (count(self::$_checkAccessOfUserCache) < 1000) {
145 self::$_checkAccessOfUserCache[$cacheKey] =
true;
155 if (in_array(SYSTEM_ROLE_ID, $roles))
159 if (count(self::$_checkAccessOfUserCache) < 1000) {
160 self::$_checkAccessOfUserCache[$cacheKey] =
true;
165 if (!isset($a_operations) or !isset($a_ref_id))
168 $this->ilErr->raiseError(get_class($this).
"::checkAccess(): Missing parameter! ".
169 "ref_id: ".$a_ref_id.
" operations: ".$a_operations,$this->ilErr->WARNING);
172 if (!is_string($a_operations))
175 $this->ilErr->raiseError(get_class($this).
"::checkAccess(): Wrong datatype for operations!",$this->ilErr->WARNING);
179 $paCacheKey = $a_user_id.
':'.$a_ref_id;
180 if (! is_array(self::$_paCache)) {
181 self::$_paCache = array();
184 if (array_key_exists($paCacheKey, self::$_paCache)) {
186 $ops = self::$_paCache[$paCacheKey];
191 $q =
"SELECT * FROM rbac_pa ".
192 "WHERE ref_id = ".$ilDB->quote($a_ref_id,
'integer');
200 if (in_array(
$row->rol_id, $roles))
202 $ops = array_merge($ops,unserialize(stripslashes(
$row->ops_id)));
206 if (count(self::$_paCache) < 1000)
208 self::$_paCache[$paCacheKey] = $ops;
212 $operations = explode(
",",$a_operations);
213 foreach ($operations as $operation)
215 if ($operation ==
"create")
219 $this->ilErr->raiseError(get_class($this).
"::CheckAccess(): Expect a type definition for checking a 'create' permission",
220 $this->ilErr->WARNING);
229 if (! in_array($ops_id,(array) $ops))
234 if (count(self::$_checkAccessOfUserCache) < 1000)
236 self::$_checkAccessOfUserCache[$cacheKey] =
false;
244 if (count(self::$_checkAccessOfUserCache) < 1000)
247 self::$_checkAccessOfUserCache[$cacheKey] =
true;
262 if (!is_array($a_ref_ids))
268 foreach ($a_ref_ids as
$ref_id)
270 if (!isset(self::$_paCache[$a_user_id.
":".$ref_id]))
278 if (count($ref_ids) > 0)
282 $q =
"SELECT * FROM rbac_pa ".
283 "WHERE ".$ilDB->in(
"ref_id", $ref_ids,
false,
"integer");
289 if (in_array(
$row->rol_id, $roles[
$row->ref_id]))
291 $ops[
$row->ref_id] = array_merge($ops[
$row->ref_id],
292 unserialize(stripslashes(
$row->ops_id)));
295 foreach ($a_ref_ids as $ref_id)
298 if (!isset(self::$_paCache[$a_user_id.
":".$ref_id]))
320 $query =
'SELECT ops_id FROM rbac_operations '.
321 'WHERE operation = '.$ilDB->quote($a_operation,
'text');
323 while(
$row = $ilDB->fetchObject(
$res))
325 $ops_id =
$row->ops_id;
328 $query =
"SELECT * FROM rbac_pa ".
329 "WHERE rol_id = ".$ilDB->quote($a_rol_id,
'integer').
" ".
330 "AND ref_id = ".$ilDB->quote($a_ref_id,
'integer').
" ";
333 while(
$row = $ilDB->fetchObject(
$res))
335 $ops = array_merge($ops,unserialize(
$row->ops_id));
337 return in_array($ops_id,$ops);
342 global $ilObjDataCache,
$ilUser;
345 if($this->mem_view[
'active'] and $a_user_id == $ilUser->getId())
347 if(in_array($a_ref_id, $this->mem_view[
'items']))
349 return $a_operations;
353 if($a_user_id != $ilObjDataCache->lookupOwner($ilObjDataCache->lookupObjId($a_ref_id)))
355 return $a_operations;
359 foreach(explode(
",",$a_operations) as $operation)
361 if($operation !=
'cat_administrate_users' and $operation !=
'edit_permission' and $operation !=
'edit_learning_progress' and !preg_match(
'/^create/',$operation))
365 if(!strlen($new_ops))
367 $new_ops = $operation;
371 $new_ops .= (
','.$operation);
392 if($this->mem_view[
'active'] and $a_usr_id == $ilUser->getId())
395 if(in_array($a_ref_id, $this->mem_view[
'items']) and $this->mem_view[
'role'])
398 return array($this->mem_view[
'role']);
402 if(isset(self::$user_role_cache[$a_usr_id]) and is_array(self::$user_role_cache))
404 return self::$user_role_cache[$a_usr_id];
409 return self::$user_role_cache[$a_usr_id] = $rbacreview->assignedRoles($a_usr_id);
418 include_once
'./Services/Container/classes/class.ilMemberViewSettings.php';
420 if($settings->isEnabled() and isset(
$_GET[
'mv']))
422 $settings->toggleActivation((
int)
$_GET[
'ref_id'], (
int) $_GET[
'mv']);
425 if(!$settings->isActive())
427 $this->mem_view[
'active'] =
false;
428 $this->mem_view[
'items'] = array();
429 $this->mem_view[
'role'] = 0;
435 $this->mem_view[
'active'] =
true;
436 $this->mem_view[
'items'] = $tree->getSubTreeIds($settings->getContainer());
437 $this->mem_view[
'items'] = array_merge($this->mem_view[
'items'],array($settings->getContainer()));
438 include_once
'./Services/Membership/classes/class.ilParticipants.php';
447 if(!in_array($a_role_id, self::$user_role_cache[$a_usr_id]))
449 self::$user_role_cache[$a_usr_id][] = $a_role_id;
455 $paCacheKey = $a_usr_id.
':'.$a_ref_id;
456 unset(self::$_paCache[$paCacheKey]);