ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilObjRole Class Reference

Class ilObjRole. More...

+ Inheritance diagram for ilObjRole:
+ Collaboration diagram for ilObjRole:

Public Member Functions

 ilObjRole ($a_id=0, $a_call_by_reference=false)
 Constructor public.
 toggleAssignUsersStatus ($a_assign_users)
 getAssignUsersStatus ()
 _getAssignUsersStatus ($a_role_id)
 read ()
 loads "role" from database private
 assignData ($a_data)
 loads a record "role" from array public
 update ()
 updates a record "role" and write it into database public
 create ()
 create
 setAllowRegister ($a_allow_register)
 set allow_register of role
 getAllowRegister ()
 get allow_register
 _lookupRegisterAllowed ()
 get all roles that are activated in user registration
 _lookupAllowRegister ($a_role_id)
 check whether role is allowed in user registration or not
 setParent ($a_parent_ref)
 set reference id of parent object this is neccessary for non RBAC protected objects!!!
 getParent ()
 get reference id of parent object
 delete ()
 delete role and all related data
 getCountMembers ()
 _getTranslation ($a_role_title)
 _updateAuthMode ($a_roles)
 _getAuthMode ($a_role_id)
 __getPermissionDefinitions ()
- Public Member Functions inherited from ilObject
 ilObject ($a_id=0, $a_reference=true)
 Constructor public.
 withReferences ()
 determines wehter objects are referenced or not (got ref ids or not)
 read ($a_force_db=false)
 read object data from db into object
 getId ()
 get object id public
 setId ($a_id)
 set object id public
 setRefId ($a_id)
 set reference id public
 getRefId ()
 get reference id public
 getType ()
 get object type public
 setType ($a_type)
 set object type public
 getPresentationTitle ()
 get presentation title Normally same as title Overwritten for sessions
 getTitle ()
 get object title public
 getUntranslatedTitle ()
 get untranslated object title public
 setTitle ($a_title)
 set object title
 getDescription ()
 get object description
 setDescription ($a_desc)
 set object description
 getLongDescription ()
 get object long description (stored in object_description)
 getImportId ()
 get import id
 setImportId ($a_import_id)
 set import id
 _lookupObjIdByImportId ($a_import_id)
 getOwner ()
 get object owner
 getOwnerName ()
 _lookupOwnerName ($a_owner_id)
 lookup owner name for owner id
 setOwner ($a_owner)
 set object owner
 getCreateDate ()
 get create date public
 getLastUpdateDate ()
 get last update date public
 setObjDataRecord ($a_record)
 set object_data record (note: this method should only be called from the ilObjectFactory class)
 MDUpdateListener ($a_element)
 Meta data update listener.
 createMetaData ()
 create meta data entry
 updateMetaData ()
 update meta data entry
 deleteMetaData ()
 delete meta data entry
 updateOwner ()
 update owner of object in db
 _getIdForImportId ($a_import_id)
 get current object id for import id (static)
 _getAllReferences ($a_id)
 get all reference ids of object
 _lookupTitle ($a_id)
 lookup object title
 _lookupDescription ($a_id)
 lookup object description
 _lookupLastUpdate ($a_id, $a_as_string=false)
 lookup last update
 _getLastUpdateOfObjects ($a_objs)
 Get last update for a set of media objects.
 _lookupObjId ($a_id)
 _setDeletedDate ($a_ref_id)
 only called in ilTree::saveSubTree
 _resetDeletedDate ($a_ref_id)
 only called in ilObjectGUI::insertSavedNodes
 _writeTitle ($a_obj_id, $a_title)
 write title to db (static)
 _writeDescription ($a_obj_id, $a_desc)
 write description to db (static)
 _writeImportId ($a_obj_id, $a_import_id)
 write import id to db (static)
 _lookupType ($a_id, $a_reference=false)
 lookup object type
 _isInTrash ($a_ref_id)
 checks wether object is in trash
 _hasUntrashedReference ($a_obj_id)
 checks wether an object has at least one reference that is not in trash
 _lookupObjectId ($a_ref_id)
 lookup object id
 _getObjectsDataForType ($a_type, $a_omit_trash=false)
 get all objects of a certain type
 putInTree ($a_parent_ref)
 maybe this method should be in tree object!?
 setPermissions ($a_parent_ref)
 set permissions of object
 createReference ()
 creates reference for object
 countReferences ()
 count references of object
 initDefaultRoles ()
 init default roles settings Purpose of this function is to create a local role folder and local roles, that are needed depending on the object type If you want to setup default local roles you MUST overwrite this method in derived object classes (see ilObjForum for an example) public
 createRoleFolder ()
 creates a local role folder
 notify ($a_event, $a_ref_id, $a_parent_non_rbac_id, $a_node_id, $a_params=0)
 notifys an object about an event occured Based on the event passed, each object may decide how it reacts.
 setRegisterMode ($a_bool)
 isUserRegistered ($a_user_id=0)
 requireRegistration ()
 getXMLZip ()
 getHTMLDirectory ()
 cloneObject ($a_target_id, $a_copy_id=0)
 Clone object permissions, put in tree ...
 appendCopyInfo ($a_target_id, $a_copy_id)
 Prepend Copy info if object with same name exists in that container.
 cloneDependencies ($a_target_id, $a_copy_id)
 Clone object dependencies.
 cloneMetaData ($target_obj)
 Copy meta data.

Static Public Member Functions

 _search (&$a_search_obj)
 STATIC METHOD search for role data.
static _getRolesByAuthMode ($a_auth_mode)
 Get roles by auth mode.
static _resetAuthMode ($a_auth_mode)
 Reset auth mode to default.
- Static Public Member Functions inherited from ilObject
static _getIdsForTitle ($title, $type= '')
 _exists ($a_id, $a_reference=false)
 checks if an object exists in object_data
static _getObjectsByType ($a_obj_type="")
 Get objects by type.
static _prepareCloneSelection ($a_ref_ids, $new_type)
 Prepare copy wizard object selection.
static _getIcon ($a_obj_id="", $a_size="big", $a_type="", $a_offline=false)

Data Fields

 $parent
 $allow_register
 $assign_users
- Data Fields inherited from ilObject
 $ilias
 $lng
 $id
 $ref_id
 $type
 $title
 $untranslatedTitle
 $desc
 $long_desc
 $owner
 $create_date
 $last_update
 $import_id
 $register = false
 $referenced
 $objectList
 $max_title
 $max_desc
 $add_dots
 $obj_data_record
 object_data record

Detailed Description

Class ilObjRole.

Author
Stefan Meyer smeye.nosp@m.r@da.nosp@m.tabay.nosp@m..de
Version
Id:
class.ilObjRole.php 17227 2008-08-22 14:42:51Z wrandels

Definition at line 34 of file class.ilObjRole.php.

Member Function Documentation

ilObjRole::__getPermissionDefinitions ( )

Definition at line 519 of file class.ilObjRole.php.

References ilObject\$lng, and DB_FETCHMODE_OBJECT.

{
global $ilDB, $lng, $objDefinition;
// build array with all rbac object types
$q = "SELECT ta.typ_id,obj.title,ops.ops_id,ops.operation FROM rbac_ta AS ta ".
"JOIN object_data AS obj ON obj.obj_id=ta.typ_id ".
"JOIN rbac_operations AS ops ON ops.ops_id=ta.ops_id";
$r = $ilDB->query($q);
while ($row = $r->fetchRow(DB_FETCHMODE_OBJECT))
{
if($objDefinition->getDevMode($row->title))
{
continue;
}
// FILTER SUBOJECTS OF adm OBJECT
#if(in_array($row->title,$to_filter))
#{
# continue;
#}
$rbac_objects[$row->typ_id] = array("obj_id" => $row->typ_id,
"type" => $row->title
);
$rbac_operations[$row->typ_id][$row->ops_id] = array(
"ops_id" => $row->ops_id,
"title" => $row->operation,
"name" => $lng->txt($row->title."_".$row->operation)
);
}
return array($rbac_objects,$rbac_operations);
}
ilObjRole::_getAssignUsersStatus (   $a_role_id)

Definition at line 69 of file class.ilObjRole.php.

References $res, and DB_FETCHMODE_OBJECT.

Referenced by ilRbacReview\getGlobalAssignableRoles(), ilObjUserFolderGUI\importUserRoleAssignmentObject(), ilSoapUserAdministration\importUsers(), ilObjUserFolderGUI\importUsersObject(), ilObjUserGUI\initCreate(), and ilSoapUserAdministration\isPermittedRole().

{
global $ilDB;
$query = "SELECT assign_users FROM role_data WHERE role_id = ".$ilDB->quote($a_role_id)." ";
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
return $row->assign_users ? true : false;
}
return false;
}

+ Here is the caller graph for this function:

ilObjRole::_getAuthMode (   $a_role_id)

Definition at line 468 of file class.ilObjRole.php.

{
global $ilDB;
$q = "SELECT auth_mode FROM role_data ".
"WHERE role_id= ".$ilDB->quote($a_role_id)." ";
$r = $ilDB->query($q);
$row = $r->fetchRow();
return $row[0];
}
static ilObjRole::_getRolesByAuthMode (   $a_auth_mode)
static

Get roles by auth mode.

public

Parameters
stringauth mode

Definition at line 487 of file class.ilObjRole.php.

References $res, and DB_FETCHMODE_OBJECT.

Referenced by ilRadiusSettings\read().

{
global $ilDB;
$query = "SELECT * FROM role_data ".
"WHERE auth_mode = ".$ilDB->quote($a_auth_mode);
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$roles[] = $row->role_id;
}
return $roles ? $roles : array();
}

+ Here is the caller graph for this function:

ilObjRole::_lookupAllowRegister (   $a_role_id)

check whether role is allowed in user registration or not

Parameters
int$a_role_idrole id
Returns
boolean true if role is allowed in user registration

Definition at line 226 of file class.ilObjRole.php.

References DB_FETCHMODE_ASSOC.

Referenced by ilRegistrationGUI\__validateRole(), and ilRegistrationSettingsGUI\editRoles().

{
global $ilDB;
$q = "SELECT * FROM role_data ".
" WHERE role_id =".$ilDB->quote($a_role_id);
$role_set = $ilDB->query($q);
if ($role_rec = $role_set->fetchRow(DB_FETCHMODE_ASSOC))
{
if ($role_rec["allow_register"])
{
return true;
}
}
return false;
}

+ Here is the caller graph for this function:

ilObjRole::_lookupRegisterAllowed ( )

get all roles that are activated in user registration

public

Returns
array array of int: role ids

Definition at line 199 of file class.ilObjRole.php.

References DB_FETCHMODE_ASSOC.

Referenced by ilRegistrationSettingsGUI\__prepareAccessLimitationRoleList(), ilRegistrationSettingsGUI\__prepareRoleList(), ilRegistrationGUI\__showRoleSelection(), ilObjAuthSettingsGUI\authSettingsObject(), ilRegistrationSettingsGUI\editRoleAccessLimitations(), and ilRegistrationSettingsGUI\saveRoleAccessLimitations().

{
global $ilDB;
$q = "SELECT * FROM role_data ".
"LEFT JOIN object_data ON object_data.obj_id = role_data.role_id ".
"WHERE allow_register = 1";
$r = $ilDB->query($q);
$roles = array();
while ($role = $r->fetchRow(DB_FETCHMODE_ASSOC))
{
$roles[] = array("id" => $role["obj_id"],
"title" => $role["title"],
"auth_mode" => $role['auth_mode']);
}
return $roles;
}

+ Here is the caller graph for this function:

static ilObjRole::_resetAuthMode (   $a_auth_mode)
static

Reset auth mode to default.

public

Parameters
stringauth mode

Definition at line 509 of file class.ilObjRole.php.

Referenced by ilRadiusSettings\save().

{
global $ilDB;
$query = "UPDATE role_data SET auth_mode = 'default' WHERE auth_mode = ".$ilDB->quote($a_auth_mode);
$ilDB->query($query);
}

+ Here is the caller graph for this function:

ilObjRole::_search ( $a_search_obj)
static

STATIC METHOD search for role data.

This method is called from class.ilSearch This method used by class.ilSearchGUI.php to a link to the results

Parameters
objectobject of search class public

Definition at line 405 of file class.ilObjRole.php.

References $ilBench, $res, and DB_FETCHMODE_OBJECT.

Referenced by ilSearch\performSearch().

{
global $ilBench;
// NO CLASS VARIABLES IN STATIC METHODS
$where_condition = $a_search_obj->getWhereCondition("like",array("title","description"));
//$in = $a_search_obj->getInStatement("ore.ref_id");
$query = "SELECT obj_id FROM object_data AS od ".
$where_condition." ".
"AND od.type = 'role' ";
$ilBench->start("Search", "ilObjRole_search");
$res = $a_search_obj->ilias->db->query($query);
$ilBench->stop("Search", "ilObjRole_search");
$counter = 0;
while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$result_data[$counter++]["id"] = $row->obj_id;
}
return $result_data ? $result_data : array();
}

+ Here is the caller graph for this function:

ilObjRole::_updateAuthMode (   $a_roles)

Definition at line 455 of file class.ilObjRole.php.

Referenced by ilRadiusSettings\save(), and ilObjAuthSettingsGUI\updateAuthRolesObject().

{
global $ilDB;
foreach ($a_roles as $role_id => $auth_mode)
{
$q = "UPDATE role_data SET ".
"auth_mode= ".$ilDB->quote($auth_mode)." ".
"WHERE role_id= ".$ilDB->quote($role_id)." ";
$ilDB->query($q);
}
}

+ Here is the caller graph for this function:

ilObjRole::assignData (   $a_data)

loads a record "role" from array public

Parameters
arrayroledata

Definition at line 114 of file class.ilObjRole.php.

References setAllowRegister(), ilObject\setDescription(), ilObject\setTitle(), ilUtil\stripSlashes(), and toggleAssignUsersStatus().

Referenced by read().

{
$this->setTitle(ilUtil::stripSlashes($a_data["title"]));
$this->setDescription(ilUtil::stripslashes($a_data["desc"]));
$this->setAllowRegister($a_data["allow_register"]);
$this->toggleAssignUsersStatus($a_data['assign_users']);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjRole::create ( )

create

public

Returns
integer object id

Reimplemented from ilObject.

Definition at line 151 of file class.ilObjRole.php.

References ilObject\$id, getAllowRegister(), and getAssignUsersStatus().

{
global $ilDB;
$this->id = parent::create();
$q = "INSERT INTO role_data ".
"(role_id,allow_register,assign_users) ".
"VALUES ".
"(".$ilDB->quote($this->id).",".$ilDB->quote($this->getAllowRegister()).",".$ilDB->quote($this->getAssignUsersStatus()).")";
$this->ilias->db->query($q);
return $this->id;
}

+ Here is the call graph for this function:

ilObjRole::delete ( )

delete role and all related data

public

Returns
boolean true if all object data were removed; false if only a references were removed

Reimplemented from ilObject.

Definition at line 275 of file class.ilObjRole.php.

References ilLDAPRoleGroupMappingSettings\_deleteByRole(), ilObject\_exists(), DB_FETCHMODE_OBJECT, ilObject\getId(), and getParent().

{
global $rbacadmin, $rbacreview,$ilDB;
$role_folders = $rbacreview->getFoldersAssignedToRole($this->getId());
if ($rbacreview->isAssignable($this->getId(),$this->getParent()))
{
// do not delete a global role, if the role is the last
// role a user is assigned to.
//
// Performance improvement: In the code section below, we
// only need to consider _global_ roles. We don't need
// to check for _local_ roles, because a user who has
// a local role _always_ has a global role too.
$last_role_user_ids = array();
if ($this->getParent() == ROLE_FOLDER_ID)
{
// The role is a global role: check if
// we find users who aren't assigned to any
// other global role than this one.
$user_ids = $rbacreview->assignedUsers($this->getId());
foreach ($user_ids as $user_id)
{
// get all roles each user has
$role_ids = $rbacreview->assignedRoles($user_id);
// is last role?
if (count($role_ids) == 1)
{
$last_role_user_ids[] = $user_id;
}
}
}
// users with last role found?
if (count($last_role_user_ids) > 0)
{
foreach ($last_role_user_ids as $user_id)
{
//echo "<br>last role for user id:".$user_id.":";
// GET OBJECT TITLE
$tmp_obj = $this->ilias->obj_factory->getInstanceByObjId($user_id);
$user_names[] = $tmp_obj->getFullname();
unset($tmp_obj);
}
// TODO: This check must be done in rolefolder object because if multiple
// roles were selected the other roles are still deleted and the system does not
// give any feedback about this.
$users = implode(', ',$user_names);
$this->ilias->raiseError($this->lng->txt("msg_user_last_role1")." ".
$users."<br/>".$this->lng->txt("msg_user_last_role2"),$this->ilias->error_obj->WARNING);
}
else
{
// IT'S A BASE ROLE
$rbacadmin->deleteRole($this->getId(),$this->getParent());
// Delete ldap role group mappings
include_once('./Services/LDAP/classes/class.ilLDAPRoleGroupMappingSettings.php');
// delete object_data entry
// delete role_data entry
$q = "DELETE FROM role_data WHERE role_id = ".$ilDB->quote($this->getId())." ";
$this->ilias->db->query($q);
include_once './classes/class.ilRoleDesktopItem.php';
$role_desk_item_obj =& new ilRoleDesktopItem($this->getId());
$role_desk_item_obj->deleteAll();
}
}
else
{
// linked local role: INHERITANCE WAS STOPPED, SO DELETE ONLY THIS LOCAL ROLE
$rbacadmin->deleteLocalRole($this->getId(),$this->getParent());
}
// purge empty rolefolders
//
// Performance improvement: We filter out all role folders
// which still contain roles, _before_ we attempt to purge them.
// This is faster than attempting to purge all role folders,
// and let function purge() of the role folder find out, if
// purging is possible.
$q = "SELECT DISTINCT parent FROM rbac_fa ".
"WHERE parent IN (".implode(',',$role_folders).")";
$r = $ilDB->query($q);
$non_empty_role_folders = array();
while ($row = $r->fetchRow(DB_FETCHMODE_OBJECT))
{
$non_empty_role_folders[] = $row->parent;
}
$role_folders = array_diff($role_folders,$non_empty_role_folders);
// Attempt to purge the role folders
foreach ($role_folders as $rolf)
{
if (ilObject::_exists($rolf,true))
{
$rolfObj = $this->ilias->obj_factory->getInstanceByRefId($rolf);
$rolfObj->purge();
unset($roleObj);
}
}
return true;
}

+ Here is the call graph for this function:

ilObjRole::getAllowRegister ( )

get allow_register

public

Returns
integer

Definition at line 188 of file class.ilObjRole.php.

References $allow_register.

Referenced by create().

{
}

+ Here is the caller graph for this function:

ilObjRole::getAssignUsersStatus ( )

Definition at line 64 of file class.ilObjRole.php.

References $assign_users.

Referenced by create(), and update().

{
}

+ Here is the caller graph for this function:

ilObjRole::getCountMembers ( )

Definition at line 390 of file class.ilObjRole.php.

{
global $rbacreview;
return count($rbacreview->assignedUsers($this->getId()));
}
ilObjRole::getParent ( )

get reference id of parent object

public

Returns
integer ref_id of parent object

Definition at line 263 of file class.ilObjRole.php.

References $parent.

Referenced by delete().

{
return $this->parent;
}

+ Here is the caller graph for this function:

ilObjRole::ilObjRole (   $a_id = 0,
  $a_call_by_reference = false 
)

Constructor public.

Parameters
integerreference_id or object_id
booleantreat the id as reference_id (true) or object_id (false)

Definition at line 54 of file class.ilObjRole.php.

References ilObject\ilObject().

{
$this->type = "role";
$this->ilObject($a_id,$a_call_by_reference);
}

+ Here is the call graph for this function:

ilObjRole::read ( )

loads "role" from database private

Definition at line 87 of file class.ilObjRole.php.

References $data, assignData(), and DB_FETCHMODE_ASSOC.

Referenced by update().

{
global $ilDB;
$q = "SELECT * FROM role_data WHERE role_id= ".$ilDB->quote($this->id)." ";
$r = $this->ilias->db->query($q);
if ($r->numRows() > 0)
{
$data = $r->fetchRow(DB_FETCHMODE_ASSOC);
// fill member vars in one shot
$this->assignData($data);
}
else
{
$this->ilias->raiseError("<b>Error: There is no dataset with id ".$this->id."!</b><br />class: ".get_class($this)."<br />Script: ".__FILE__."<br />Line: ".__LINE__, $this->ilias->FATAL);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjRole::setAllowRegister (   $a_allow_register)

set allow_register of role

public

Parameters
integer

Definition at line 172 of file class.ilObjRole.php.

Referenced by assignData().

{
if (empty($a_allow_register))
{
$a_allow_register == 0;
}
$this->allow_register = (int) $a_allow_register;
}

+ Here is the caller graph for this function:

ilObjRole::setParent (   $a_parent_ref)

set reference id of parent object this is neccessary for non RBAC protected objects!!!

public

Parameters
integerref_id of parent object

Definition at line 252 of file class.ilObjRole.php.

{
$this->parent = $a_parent_ref;
}
ilObjRole::toggleAssignUsersStatus (   $a_assign_users)

Definition at line 60 of file class.ilObjRole.php.

Referenced by assignData().

{
$this->assign_users = (int) $a_assign_users;
}

+ Here is the caller graph for this function:

ilObjRole::update ( )

updates a record "role" and write it into database public

Reimplemented from ilObject.

Definition at line 126 of file class.ilObjRole.php.

References getAssignUsersStatus(), and read().

{
global $ilDB;
$q = "UPDATE role_data SET ".
"allow_register= ".$ilDB->quote($this->allow_register).", ".
"assign_users = ".$ilDB->quote($this->getAssignUsersStatus())." ".
"WHERE role_id= ".$ilDB->quote($this->id)." ";
$this->ilias->db->query($q);
$this->read();
return true;
}

+ Here is the call graph for this function:

Field Documentation

ilObjRole::$allow_register

Definition at line 45 of file class.ilObjRole.php.

Referenced by getAllowRegister().

ilObjRole::$assign_users

Definition at line 46 of file class.ilObjRole.php.

Referenced by getAssignUsersStatus().

ilObjRole::$parent

Definition at line 43 of file class.ilObjRole.php.

Referenced by getParent().


The documentation for this class was generated from the following file: