62 (isset($ilDB)) ? $this->
ilDB =& $ilDB : $this->
ilDB =& $ilias->db;
79 return self::$instance;
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';
421 if(!isset(
$_GET[
'mv']))
431 $settings->toggleActivation((
int)
$_GET[
'ref_id'],
false);
437 $settings->toggleActivation((
int) $_GET[
'ref_id'],
true);
441 if(!$settings->isActive())
443 $this->mem_view[
'active'] =
false;
444 $this->mem_view[
'items'] = array();
445 $this->mem_view[
'role'] = 0;
451 $this->mem_view[
'active'] =
true;
452 $this->mem_view[
'items'] = $tree->getSubTreeIds($settings->getContainer());
453 $this->mem_view[
'items'] = array_merge($this->mem_view[
'items'],array($settings->getContainer()));
454 include_once
'./Services/Membership/classes/class.ilParticipants.php';
463 if(!in_array($a_role_id, self::$user_role_cache[$a_usr_id]))
465 self::$user_role_cache[$a_usr_id][] = $a_role_id;
471 $paCacheKey = $a_usr_id.
':'.$a_ref_id;
472 unset(self::$_paCache[$paCacheKey]);
class ilRbacSystem system function like checkAccess, addActiveRole ...
const PEAR_ERROR_CALLBACK
ilRbacSystem()
Constructor public.
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)
addTemporaryRole($a_usr_id, $a_role_id)
static getDefaultMemberRole($a_ref_id)
checkPermission($a_ref_id, $a_rol_id, $a_operation)
check if a specific role has the permission '$a_operation' of an object public
const DB_FETCHMODE_OBJECT
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="")
if(!file_exists(getcwd().'/ilias.ini.php')) if(isset( $_GET["client_id"]))
registration confirmation script for ilias
static _getOperationIdByName($a_operation)
get operation id by name of operation public static
Error Handling & global info handling uses PEAR error class.
static getInstance()
Get instance.
__filterOwnerPermissions($a_user_id, $a_operations, $a_ref_id)