Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00035 require_once "class.ilObject.php";
00036
00037 class ilObjRoleFolder extends ilObject
00038 {
00045 function ilObjRoleFolder($a_id = 0,$a_call_by_reference = true)
00046 {
00047 $this->type = "rolf";
00048 $this->ilObject($a_id,$a_call_by_reference);
00049 }
00050
00051 function read($a_force_db = false)
00052 {
00053 parent::read();
00054
00055 if ($this->getId() != ROLE_FOLDER_ID)
00056 {
00057 $this->setDescription($this->lng->txt("obj_".$this->getType()."_local_desc").$this->getTitle().$this->getDescription());
00058 $this->setTitle($this->lng->txt("obj_".$this->getType()."_local"));
00059
00060 }
00061 }
00062
00069 function ilClone($a_parent_ref)
00070 {
00071
00072
00073
00074 return false;
00075
00076 global $rbacadmin;
00077
00078
00079 $new_ref_id = parent::ilClone($a_parent_ref);
00080
00081
00082
00083
00084 return $new_ref_id;
00085 }
00086
00093 function delete()
00094 {
00095
00096 if (!parent::delete())
00097 {
00098 return false;
00099 }
00100
00101
00102 global $rbacreview;
00103
00104 $roles = $rbacreview->getRolesOfRoleFolder($this->getRefId());
00105
00106
00107 foreach ($roles as $role_id)
00108 {
00109 $roleObj =& $this->ilias->obj_factory->getInstanceByObjId($role_id);
00110 $roleObj->setParent($this->getRefId());
00111 $roleObj->delete();
00112 unset($roleObj);
00113 }
00114
00115
00116 return true;
00117 }
00118
00127 function createRole($a_title,$a_desc,$a_import_id = 0)
00128 {
00129 global $rbacadmin, $rbacreview;
00130
00131
00132 if ($rbacreview->roleExists($a_title))
00133 {
00134 $this->ilias->raiseError($this->lng->txt("msg_role_exists1")." '".ilUtil::stripSlashes($a_title)."' ".
00135 $this->lng->txt("msg_role_exists2"),$this->ilias->error_obj->MESSAGE);
00136 }
00137
00138 include_once ("classes/class.ilObjRole.php");
00139 $roleObj = new ilObjRole();
00140 $roleObj->setTitle($a_title);
00141 $roleObj->setDescription($a_desc);
00142
00143 if ($a_import_id != "")
00144 {
00145
00146 $roleObj->setImportId($a_import_id);
00147 }
00148 $roleObj->create();
00149
00150
00151 $rbacadmin->assignRoleToFolder($roleObj->getId(),$this->getRefId(),"y");
00152
00153 return $roleObj;
00154 }
00155
00161 function purge()
00162 {
00163 global $rbacreview, $rbacadmin, $tree;
00164
00165 $local_roles = $rbacreview->getRolesOfRoleFolder($this->getRefId());
00166
00167 if (count($local_roles) == 0)
00168 {
00169 $rbacadmin->revokePermission($this->getRefId());
00170
00171 if ($tree_id = $this->isDeleted())
00172 {
00173 $deleted_tree = new ilTree ($tree_id,- (int) $tree_id);
00174 $deleted_tree->deleteTree($deleted_tree->getNodeData($this->getRefId()));
00175 }
00176 else
00177 {
00178 $tree->deleteTree($tree->getNodeData($this->getRefId()));
00179 }
00180
00181 $this->delete();
00182
00183 return true;
00184 }
00185
00186 return false;
00187 }
00188
00194 function isDeleted()
00195 {
00196 $q = "SELECT tree FROM tree WHERE child='".$this->getRefId()."'";
00197 $row = $this->ilias->db->getRow($q);
00198
00199 if ($row->tree < 0)
00200 {
00201 return $row->tree;
00202 }
00203
00204 return false;
00205 }
00206 }
00207 ?>