58 if (self::$instance) {
59 return self::$instance;
69 self::$user_role_cache = array();
70 self::$_paCache = null;
71 self::$_checkAccessOfUserCache = null;
100 $ilBench->start(
"RBAC",
"system_checkAccess");
104 $ilBench->stop(
"RBAC",
"system_checkAccess");
114 $rbacreview = $DIC[
'rbacreview'];
115 $ilObjDataCache = $DIC[
'ilObjDataCache'];
116 $ilDB = $DIC[
'ilDB'];
120 $cacheKey = $a_user_id .
':' . $a_operations .
':' . $a_ref_id .
':' .
$a_type;
123 if (!is_array(self::$_checkAccessOfUserCache)) {
124 self::$_checkAccessOfUserCache = array();
128 if (array_key_exists($cacheKey, self::$_checkAccessOfUserCache)) {
129 return self::$_checkAccessOfUserCache[$cacheKey];
141 if (count(self::$_checkAccessOfUserCache) < 1000) {
142 self::$_checkAccessOfUserCache[$cacheKey] =
true;
152 if (in_array(SYSTEM_ROLE_ID, $roles)) {
155 if (count(self::$_checkAccessOfUserCache) < 1000) {
156 self::$_checkAccessOfUserCache[$cacheKey] =
true;
161 if (!isset($a_operations)
or !isset($a_ref_id)) {
162 $GLOBALS[
'DIC'][
'ilLog']->logStack();
163 $this->ilErr->raiseError(get_class($this) .
"::checkAccess(): Missing parameter! " .
164 "ref_id: " . $a_ref_id .
" operations: " . $a_operations, $this->ilErr->WARNING);
167 if (!is_string($a_operations)) {
168 $GLOBALS[
'DIC'][
'ilLog']->logStack();
169 $this->ilErr->raiseError(get_class($this) .
"::checkAccess(): Wrong datatype for operations!", $this->ilErr->WARNING);
173 $paCacheKey = $a_user_id .
':' . $a_ref_id;
174 if (!is_array(self::$_paCache)) {
175 self::$_paCache = array();
178 if (array_key_exists($paCacheKey, self::$_paCache)) {
180 $ops = self::$_paCache[$paCacheKey];
183 $q =
"SELECT * FROM rbac_pa " .
184 "WHERE ref_id = " .
$ilDB->quote($a_ref_id,
'integer');
186 $r = $this->ilDB->query($q);
191 if (in_array(
$row->rol_id, $roles)) {
192 $ops = array_merge($ops, unserialize(stripslashes(
$row->ops_id)));
196 if (count(self::$_paCache) < 1000) {
197 self::$_paCache[$paCacheKey] = $ops;
201 $operations = explode(
",", $a_operations);
202 foreach ($operations as $operation) {
203 if ($operation ==
"create") {
205 $this->ilErr->raiseError(
206 get_class($this) .
"::CheckAccess(): Expect a type definition for checking a 'create' permission",
207 $this->ilErr->WARNING
215 if (!in_array($ops_id, (array) $ops)) {
219 if (count(self::$_checkAccessOfUserCache) < 1000) {
220 self::$_checkAccessOfUserCache[$cacheKey] =
false;
228 if (count(self::$_checkAccessOfUserCache) < 1000) {
230 self::$_checkAccessOfUserCache[$cacheKey] =
true;
245 $ilDB = $DIC[
'ilDB'];
247 if (!is_array($a_ref_ids)) {
252 foreach ($a_ref_ids as $ref_id) {
253 if (!isset(self::$_paCache[$a_user_id .
":" . $ref_id])) {
255 $ops[$ref_id] = array();
256 $ref_ids[] = $ref_id;
260 if (count($ref_ids) > 0) {
263 $q =
"SELECT * FROM rbac_pa " .
264 "WHERE " .
$ilDB->in(
"ref_id", $ref_ids,
false,
"integer");
266 $r = $this->ilDB->query($q);
269 if (in_array(
$row->rol_id, $roles[
$row->ref_id])) {
270 $ops[
$row->ref_id] = array_merge(
272 unserialize(stripslashes(
$row->ops_id))
276 foreach ($a_ref_ids as $ref_id) {
278 if (!isset(self::$_paCache[$a_user_id .
":" . $ref_id])) {
279 self::$_paCache[$a_user_id .
":" . $ref_id] = $ops[$ref_id];
297 $ilDB = $DIC[
'ilDB'];
301 $query =
'SELECT ops_id FROM rbac_operations ' .
302 'WHERE operation = ' .
$ilDB->quote($a_operation,
'text');
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') .
" ";
314 $ops = array_merge($ops, unserialize(
$row->ops_id));
316 return in_array($ops_id, $ops);
323 $ilObjDataCache = $DIC[
'ilObjDataCache'];
327 if ($this->mem_view[
'active']
and $a_user_id ==
$ilUser->getId()) {
328 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))) {
334 return $a_operations;
338 foreach (explode(
",", $a_operations) as $operation) {
339 if ($operation !=
'cat_administrate_users' and $operation !=
'edit_permission' and $operation !=
'edit_learning_progress' and $operation !=
'read_learning_progress' and !preg_match(
'/^create/', $operation)) {
342 if (!strlen($new_ops)) {
343 $new_ops = $operation;
345 $new_ops .= (
',' . $operation);
364 $rbacreview = $DIC[
'rbacreview'];
367 if ($this->mem_view[
'active']
and $a_usr_id ==
$ilUser->getId()) {
369 if (in_array($a_ref_id, $this->mem_view[
'items'])
and $this->mem_view[
'role']) {
371 return array($this->mem_view[
'role']);
375 if (isset(self::$user_role_cache[$a_usr_id])
and is_array(self::$user_role_cache)) {
376 return self::$user_role_cache[$a_usr_id];
381 return self::$user_role_cache[$a_usr_id] = $rbacreview->assignedRoles($a_usr_id);
390 include_once
'./Services/Container/classes/class.ilMemberViewSettings.php';
395 isset(
$_GET[
'mv']) &&
399 $settings->toggleActivation((
int)
$_GET[
'ref_id'],
false);
402 isset(
$_GET[
'mv']) &&
406 $settings->toggleActivation((
int) $_GET[
'ref_id'],
true);
412 if (!$settings->isActive()) {
413 $this->mem_view[
'active'] =
false;
414 $this->mem_view[
'items'] = array();
415 $this->mem_view[
'role'] = 0;
419 $tree = $DIC[
'tree'];
421 $this->mem_view[
'active'] =
true;
422 $this->mem_view[
'items'] =
$tree->getSubTreeIds($settings->getContainer());
423 $this->mem_view[
'items'] = array_merge($this->mem_view[
'items'], array($settings->getContainer()));
425 include_once
'./Services/Membership/classes/class.ilParticipants.php';
433 if (!in_array($a_role_id, self::$user_role_cache[$a_usr_id])) {
434 self::$user_role_cache[$a_usr_id][] = $a_role_id;
440 $paCacheKey = $a_usr_id .
':' . $a_ref_id;
441 unset(self::$_paCache[$paCacheKey]);
class ilRbacSystem system function like checkAccess, addActiveRole ...
const PEAR_ERROR_CALLBACK
static $_checkAccessOfUserCache
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)
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.
if(!file_exists(getcwd() . '/ilias.ini.php'))
registration confirmation script for ilias
foreach($_POST as $key=> $value) $res
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="")
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)
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
__construct()
Constructor public.