Public Member Functions | |
ilRbacSystem () | |
Constructor 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 method you check the permissions a use may have due to its roles on an specific object. | |
checkAccessOfUser ($a_user_id, $a_operations, $a_ref_id, $a_type="") | |
checkPermission ($a_ref_id, $a_rol_id, $a_operation) | |
check if a specific role has the permission '$a_operation' of an object public | |
checkPreconditions ($a_operations, $a_ref_id, $a_user_id="") | |
Data Fields | |
$ilias |
Definition at line 36 of file class.ilRbacSystem.php.
ilRbacSystem::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 method you check the permissions a use may have due to its roles on an specific object.
The first parameter are the operation(s) the user must have The second & third parameter specifies the object where the operation(s) may apply to The last parameter is only required, if you ask for the 'create' operation. Here you specify the object type which you want to create.
example: $rbacSystem->checkAccess("visible,read",23); Here you ask if the user is allowed to see ('visible') and access the object by reading it ('read'). The reference_id is 23 in the tree structure.
public
string | one or more operations, separated by commas (i.e.: visible,read,join) | |
integer | the child_id in tree (usually a reference_id, no object_id !!) | |
string | the type definition abbreviation (i.e.: frm,grp,crs) |
Definition at line 83 of file class.ilRbacSystem.php.
References $ilBench, $ilUser, $result, and checkAccessOfUser().
{ global $ilUser,$ilBench; $ilBench->start("RBAC", "system_checkAccess"); $result = $this->checkAccessOfUser($ilUser->getId(), $a_operations, $a_ref_id, $a_type); $ilBench->stop("RBAC", "system_checkAccess"); return $result; }
ilRbacSystem::checkAccessOfUser | ( | $ | a_user_id, | |
$ | a_operations, | |||
$ | a_ref_id, | |||
$ | a_type = "" | |||
) |
Definition at line 96 of file class.ilRbacSystem.php.
References $_SESSION, $ilUser, $ops, $ops_id, $q, $rbacreview, $roles, $row, checkPreconditions(), and getOperationId().
Referenced by checkAccess().
{ global $ilUser, $rbacreview; // get roles if ($a_user_id == $ilUser->getId()) { $roles = $_SESSION["RoleId"]; } else { $roles = $rbacreview->assignedRoles($a_user_id); } // exclude system role from rbac if (in_array(SYSTEM_ROLE_ID, $roles)) { return true; } if (!isset($a_operations) or !isset($a_ref_id)) { $this->ilErr->raiseError(get_class($this)."::checkAccess(): Missing parameter! ". "ref_id: ".$a_ref_id." operations: ".$a_operations,$this->ilErr->WARNING); } if (!is_string($a_operations)) { $this->ilErr->raiseError(get_class($this)."::checkAccess(): Wrong datatype for operations!",$this->ilErr->WARNING); } $operations = explode(",",$a_operations); if(!$this->checkPreconditions($operations, $a_ref_id, $a_user_id)) { return false; } foreach ($operations as $operation) { if ($operation == "create") { if (empty($a_type)) { $this->ilErr->raiseError(get_class($this)."::CheckAccess(): Expect a type definition for checking a 'create' permission", $this->ilErr->WARNING); } $ops_id = getOperationId($operation."_".$a_type); } else { $ops_id = getOperationId($operation); } // Um nur eine Abfrage zu haben $in = " IN ('"; $in .= implode("','", $roles); $in .= "')"; $q = "SELECT * FROM rbac_pa ". "WHERE rol_id ".$in." ". "AND ref_id = '".$a_ref_id."' "; $r = $this->ilDB->query($q); $ops = array(); while ($row = $r->fetchRow(DB_FETCHMODE_OBJECT)) { $ops = array_merge($ops,unserialize(stripslashes($row->ops_id))); } if (in_array($ops_id,$ops)) { continue; } else { return false; } } return true; }
ilRbacSystem::checkPermission | ( | $ | a_ref_id, | |
$ | a_rol_id, | |||
$ | a_operation | |||
) |
check if a specific role has the permission '$a_operation' of an object public
integer | reference id of object | |
integer | role id | |
string | the permission to check |
Definition at line 188 of file class.ilRbacSystem.php.
References $ops, $ops_id, $q, and $row.
{ $ops = array(); $q = "SELECT ops_id FROM rbac_operations ". "WHERE operation ='".$a_operation."'"; $r = $this->ilDB->query($q); while($row = $r->fetchRow(DB_FETCHMODE_OBJECT)) { $ops_id = $row->ops_id; } $q = "SELECT * FROM rbac_pa ". "WHERE rol_id = '".$a_rol_id."' ". "AND ref_id = '".$a_ref_id."' "; $r = $this->ilDB->query($q); while ($row = $r->fetchRow(DB_FETCHMODE_OBJECT)) { $ops = array_merge($ops,unserialize(stripslashes($row->ops_id))); } return in_array($ops_id,$ops); }
ilRbacSystem::checkPreconditions | ( | $ | a_operations, | |
$ | a_ref_id, | |||
$ | a_user_id = "" | |||
) |
Definition at line 215 of file class.ilRbacSystem.php.
References $query, $res, $row, $type, and ilObjectFactory::getInstanceByRefId().
Referenced by checkAccessOfUser().
{ if ($a_user_id == "") { $a_user_id = $this->ilias->account->getId(); } // get obj_type $query = "SELECT type FROM object_data AS obd,object_reference AS obr ". "WHERE obd.obj_id = obr.obj_id AND ". "obr.ref_id = '".$a_ref_id."'"; $res = $this->ilDB->query($query); while($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) { $type = $row->type; } switch($type) { case "crs": if(in_array('visible',$a_operations) or in_array('join',$a_operations) or in_array('leave',$a_operations)) { return true; } $tmp_obj =& ilObjectFactory::getInstanceByRefId($a_ref_id); $tmp_obj->initCourseMemberObject(); // CHECK COURSE SPECIFIC THINGS if(!$tmp_obj->members_obj->hasAccess($a_user_id)) { unset($tmp_obj); return false; } unset($tmp_obj); return true; default: return true; } }
ilRbacSystem::ilRbacSystem | ( | ) |
Constructor public.
Definition at line 44 of file class.ilRbacSystem.php.
References $ilErr, $ilias, and if.
{ global $ilDB,$ilErr,$ilias; $this->ilias =& $ilias; // set db & error handler (isset($ilDB)) ? $this->ilDB =& $ilDB : $this->ilDB =& $ilias->db; if (!isset($ilErr)) { $ilErr = new ilErrorHandling(); $ilErr->setErrorHandling(PEAR_ERROR_CALLBACK,array($ilErr,'errorHandler')); } else { $this->ilErr =& $ilErr; } }
ilRbacSystem::$ilias |
Definition at line 38 of file class.ilRbacSystem.php.
Referenced by ilRbacSystem().