62 (isset($ilDB)) ? $this->
ilDB =& $ilDB : $this->
ilDB =& $ilias->db;
107 $ilBench->start(
"RBAC",
"system_checkAccess");
111 $ilBench->stop(
"RBAC",
"system_checkAccess");
118 global $ilUser, $rbacreview,$ilObjDataCache,
$ilDB,
$ilLog;
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")
222 $this->ilErr->raiseError(get_class($this).
"::CheckAccess(): Expect a type definition for checking a 'create' permission",
223 $this->ilErr->WARNING);
232 if (! in_array($ops_id,(array) $ops))
237 if (count(self::$_checkAccessOfUserCache) < 1000)
239 self::$_checkAccessOfUserCache[$cacheKey] =
false;
247 if (count(self::$_checkAccessOfUserCache) < 1000)
250 self::$_checkAccessOfUserCache[$cacheKey] =
true;
265 if (!is_array($a_ref_ids))
271 foreach ($a_ref_ids as
$ref_id)
273 if (!isset(self::$_paCache[$a_user_id.
":".$ref_id]))
281 if (count($ref_ids) > 0)
285 $q =
"SELECT * FROM rbac_pa ".
286 "WHERE ".$ilDB->in(
"ref_id", $ref_ids,
false,
"integer");
292 if (in_array(
$row->rol_id, $roles[
$row->ref_id]))
294 $ops[
$row->ref_id] = array_merge($ops[
$row->ref_id],
295 unserialize(stripslashes(
$row->ops_id)));
298 foreach ($a_ref_ids as $ref_id)
319 $query =
'SELECT ops_id FROM rbac_operations '.
320 'WHERE operation = '.$ilDB->quote($a_operation,
'text');
322 while(
$row = $ilDB->fetchObject(
$res))
324 $ops_id =
$row->ops_id;
327 $query =
"SELECT * FROM rbac_pa ".
328 "WHERE rol_id = ".$ilDB->quote($a_rol_id,
'integer').
" ".
329 "AND ref_id = ".$ilDB->quote($a_ref_id,
'integer').
" ";
332 while(
$row = $ilDB->fetchObject(
$res))
334 $ops = array_merge($ops,unserialize(
$row->ops_id));
336 return in_array($ops_id,$ops);
341 global $ilObjDataCache,$ilUser;
344 if($this->mem_view[
'active'] and $a_user_id == $ilUser->getId())
346 if(in_array($a_ref_id, $this->mem_view[
'items']))
348 return $a_operations;
352 if($a_user_id != $ilObjDataCache->lookupOwner($ilObjDataCache->lookupObjId($a_ref_id)))
354 return $a_operations;
358 foreach(explode(
",",$a_operations) as $operation)
360 if($operation !=
'cat_administrate_users' and $operation !=
'edit_permission' and !preg_match(
'/^create/',$operation))
364 if(!strlen($new_ops))
366 $new_ops = $operation;
370 $new_ops .= (
','.$operation);
388 global $ilUser,$rbacreview;
391 if($this->mem_view[
'active'] and $a_usr_id == $ilUser->getId())
394 if(in_array($a_ref_id, $this->mem_view[
'items']) and $this->mem_view[
'role'])
397 return array($this->mem_view[
'role']);
401 if(isset(self::$user_role_cache[$a_usr_id]) and is_array(self::$user_role_cache))
403 return self::$user_role_cache[$a_usr_id];
408 return self::$user_role_cache[$a_usr_id] = $rbacreview->assignedRoles($a_usr_id);
417 include_once
'./Services/Container/classes/class.ilMemberViewSettings.php';
419 if($settings->isEnabled() and isset(
$_GET[
'mv']))
421 $settings->toggleActivation((
int)
$_GET[
'ref_id'], (
int) $_GET[
'mv']);
424 if(!$settings->isActive())
426 $this->mem_view[
'active'] =
false;
427 $this->mem_view[
'items'] = array();
428 $this->mem_view[
'role'] = 0;
434 $this->mem_view[
'active'] =
true;
435 $this->mem_view[
'items'] = $tree->getSubTreeIds($settings->getContainer());
436 $this->mem_view[
'items'] = array_merge($this->mem_view[
'items'],array($settings->getContainer()));
437 include_once
'./Services/Membership/classes/class.ilParticipants.php';