42 (isset($ilDB)) ? $this->
ilDB =& $ilDB : $this->
ilDB =& $ilias->db;
59 return self::$instance;
69 self::$user_role_cache =
array();
70 self::$_paCache = null;
71 self::$_checkAccessOfUserCache = null;
97 $ilBench->start(
"RBAC",
"system_checkAccess");
101 $ilBench->stop(
"RBAC",
"system_checkAccess");
111 $cacheKey = $a_user_id.
':'.$a_operations.
':'.$a_ref_id.
':'.
$a_type;
114 if (! is_array(self::$_checkAccessOfUserCache)) {
115 self::$_checkAccessOfUserCache =
array();
119 if (array_key_exists($cacheKey, self::$_checkAccessOfUserCache)) {
120 return self::$_checkAccessOfUserCache[$cacheKey];
133 if (count(self::$_checkAccessOfUserCache) < 1000) {
134 self::$_checkAccessOfUserCache[$cacheKey] =
true;
144 if (in_array(SYSTEM_ROLE_ID, $roles))
148 if (count(self::$_checkAccessOfUserCache) < 1000) {
149 self::$_checkAccessOfUserCache[$cacheKey] =
true;
154 if (!isset($a_operations)
or !isset($a_ref_id))
157 $this->ilErr->raiseError(get_class($this).
"::checkAccess(): Missing parameter! ".
158 "ref_id: ".$a_ref_id.
" operations: ".$a_operations,$this->ilErr->WARNING);
161 if (!is_string($a_operations))
164 $this->ilErr->raiseError(get_class($this).
"::checkAccess(): Wrong datatype for operations!",$this->ilErr->WARNING);
168 $paCacheKey = $a_user_id.
':'.$a_ref_id;
169 if (! is_array(self::$_paCache)) {
170 self::$_paCache =
array();
173 if (array_key_exists($paCacheKey, self::$_paCache)) {
175 $ops = self::$_paCache[$paCacheKey];
180 $q =
"SELECT * FROM rbac_pa ".
181 "WHERE ref_id = ".$ilDB->quote($a_ref_id,
'integer');
189 if (in_array(
$row->rol_id, $roles))
191 $ops = array_merge($ops,unserialize(stripslashes(
$row->ops_id)));
195 if (count(self::$_paCache) < 1000)
197 self::$_paCache[$paCacheKey] = $ops;
201 $operations = explode(
",",$a_operations);
202 foreach ($operations as $operation)
204 if ($operation ==
"create")
208 $this->ilErr->raiseError(get_class($this).
"::CheckAccess(): Expect a type definition for checking a 'create' permission",
209 $this->ilErr->WARNING);
218 if (! in_array($ops_id,(
array) $ops))
223 if (count(self::$_checkAccessOfUserCache) < 1000)
225 self::$_checkAccessOfUserCache[$cacheKey] =
false;
233 if (count(self::$_checkAccessOfUserCache) < 1000)
236 self::$_checkAccessOfUserCache[$cacheKey] =
true;
251 if (!is_array($a_ref_ids))
257 foreach ($a_ref_ids as
$ref_id)
259 if (!isset(self::$_paCache[$a_user_id.
":".$ref_id]))
267 if (count($ref_ids) > 0)
271 $q =
"SELECT * FROM rbac_pa ".
272 "WHERE ".$ilDB->in(
"ref_id", $ref_ids,
false,
"integer");
278 if (in_array(
$row->rol_id, $roles[
$row->ref_id]))
280 $ops[
$row->ref_id] = array_merge($ops[
$row->ref_id],
281 unserialize(stripslashes(
$row->ops_id)));
284 foreach ($a_ref_ids as $ref_id)
287 if (!isset(self::$_paCache[$a_user_id.
":".$ref_id]))
309 $query =
'SELECT ops_id FROM rbac_operations '.
310 'WHERE operation = '.$ilDB->quote($a_operation,
'text');
312 while(
$row = $ilDB->fetchObject(
$res))
314 $ops_id =
$row->ops_id;
317 $query =
"SELECT * FROM rbac_pa ".
318 "WHERE rol_id = ".$ilDB->quote($a_rol_id,
'integer').
" ".
319 "AND ref_id = ".$ilDB->quote($a_ref_id,
'integer').
" ";
322 while(
$row = $ilDB->fetchObject(
$res))
324 $ops = array_merge($ops,unserialize(
$row->ops_id));
326 return in_array($ops_id,$ops);
331 global $ilObjDataCache,
$ilUser;
334 if($this->mem_view[
'active']
and $a_user_id == $ilUser->getId())
336 if(in_array($a_ref_id, $this->mem_view[
'items']))
338 return $a_operations;
342 if($a_user_id != $ilObjDataCache->lookupOwner($ilObjDataCache->lookupObjId($a_ref_id)))
344 return $a_operations;
348 foreach(explode(
",",$a_operations) as $operation)
350 if($operation !=
'cat_administrate_users' and $operation !=
'edit_permission' and $operation !=
'edit_learning_progress' and $operation !=
'read_learning_progress' and !preg_match(
'/^create/',$operation))
354 if(!strlen($new_ops))
356 $new_ops = $operation;
360 $new_ops .= (
','.$operation);
381 if($this->mem_view[
'active']
and $a_usr_id == $ilUser->getId())
384 if(in_array($a_ref_id, $this->mem_view[
'items'])
and $this->mem_view[
'role'])
387 return array($this->mem_view[
'role']);
391 if(isset(self::$user_role_cache[$a_usr_id])
and is_array(self::$user_role_cache))
393 return self::$user_role_cache[$a_usr_id];
398 return self::$user_role_cache[$a_usr_id] = $rbacreview->assignedRoles($a_usr_id);
407 include_once
'./Services/Container/classes/class.ilMemberViewSettings.php';
412 isset(
$_GET[
'mv']) &&
417 $settings->toggleActivation((
int)
$_GET[
'ref_id'],
false);
420 isset(
$_GET[
'mv']) &&
426 $settings->toggleActivation((
int) $_GET[
'ref_id'],
true);
432 if(!$settings->isActive())
434 $this->mem_view[
'active'] =
false;
435 $this->mem_view[
'items'] =
array();
436 $this->mem_view[
'role'] = 0;
442 $this->mem_view[
'active'] =
true;
443 $this->mem_view[
'items'] = $tree->getSubTreeIds($settings->getContainer());
444 $this->mem_view[
'items'] = array_merge($this->mem_view[
'items'],
array($settings->getContainer()));
446 include_once
'./Services/Membership/classes/class.ilParticipants.php';
455 if(!in_array($a_role_id, self::$user_role_cache[$a_usr_id]))
457 self::$user_role_cache[$a_usr_id][] = $a_role_id;
463 $paCacheKey = $a_usr_id.
':'.$a_ref_id;
464 unset(self::$_paCache[$paCacheKey]);
class ilRbacSystem system function like checkAccess, addActiveRole ...
const PEAR_ERROR_CALLBACK
static $_checkAccessOfUserCache
query($sql, $a_handle_error=true)
Query.
preloadRbacPaCache($a_ref_ids, $a_user_id)
Preload rbac_pa cache.
resetPACache($a_usr_id, $a_ref_id)
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
addTemporaryRole($a_usr_id, $a_role_id)
static getDefaultMemberRole($a_ref_id)
static resetCaches()
Reset internal caches.
checkPermission($a_ref_id, $a_rol_id, $a_operation)
check if a specific role has the permission '$a_operation' of an object public
checkAccess($a_operations, $a_ref_id, $a_type="")
checkAccess represents the main method of the RBAC-system in ILIAS3 developers want to use With this ...
fetchAssignedRoles($a_usr_id, $a_ref_id)
Fetch assigned roles This method caches the assigned roles per user.
initMemberView()
Init member view.
redirection script todo: (a better solution should control the processing via a xml file) ...
checkAccessOfUser($a_user_id, $a_operations, $a_ref_id, $a_type="")
Create styles array
The data for the language used.
static _getOperationIdByName($a_operation)
get operation id by name of operation public static
static getInstance()
Get instance.
__filterOwnerPermissions($a_user_id, $a_operations, $a_ref_id)
__construct()
Constructor public.