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
00025 require_once "class.ilObject.php";
00026
00035 class ilObjRoleFolder extends ilObject
00036 {
00043 function ilObjRoleFolder($a_id = 0,$a_call_by_reference = true)
00044 {
00045 $this->type = "rolf";
00046 $this->ilObject($a_id,$a_call_by_reference);
00047 }
00048
00049 function read($a_force_db = false)
00050 {
00051 parent::read();
00052
00053 if ($this->getId() != ROLE_FOLDER_ID)
00054 {
00055 $this->setDescription($this->lng->txt("obj_".$this->getType()."_local_desc").$this->getTitle().$this->getDescription());
00056 $this->setTitle($this->lng->txt("obj_".$this->getType()."_local"));
00057
00058 }
00059 }
00060
00067 function ilClone($a_parent_ref)
00068 {
00069
00070
00071
00072 return false;
00073
00074 global $rbacadmin;
00075
00076
00077 $new_ref_id = parent::ilClone($a_parent_ref);
00078
00079
00080
00081
00082 return $new_ref_id;
00083 }
00084
00091 function delete()
00092 {
00093
00094 if (!parent::delete())
00095 {
00096 return false;
00097 }
00098
00099
00100 global $rbacreview;
00101
00102 $roles = $rbacreview->getRolesOfRoleFolder($this->getRefId());
00103
00104
00105 foreach ($roles as $role_id)
00106 {
00107 $roleObj =& $this->ilias->obj_factory->getInstanceByObjId($role_id);
00108 $roleObj->setParent($this->getRefId());
00109 $roleObj->delete();
00110 unset($roleObj);
00111 }
00112
00113
00114 return true;
00115 }
00116
00125 function createRole($a_title,$a_desc,$a_import_id = 0)
00126 {
00127 global $rbacadmin, $rbacreview;
00128
00129
00130 if ($rbacreview->roleExists($a_title))
00131 {
00132 $this->ilias->raiseError($this->lng->txt("msg_role_exists1")." '".ilUtil::stripSlashes($a_title)."' ".
00133 $this->lng->txt("msg_role_exists2"),$this->ilias->error_obj->MESSAGE);
00134 }
00135
00136 include_once ("classes/class.ilObjRole.php");
00137 $roleObj = new ilObjRole();
00138 $roleObj->setTitle($a_title);
00139 $roleObj->setDescription($a_desc);
00140
00141 if ($a_import_id != "")
00142 {
00143
00144 $roleObj->setImportId($a_import_id);
00145 }
00146 $roleObj->create();
00147
00148
00149 $rbacadmin->assignRoleToFolder($roleObj->getId(),$this->getRefId(),"y");
00150
00151 return $roleObj;
00152 }
00153
00159 function purge()
00160 {
00161 global $rbacreview, $rbacadmin, $tree;
00162
00163 $local_roles = $rbacreview->getRolesOfRoleFolder($this->getRefId());
00164
00165 if (count($local_roles) == 0)
00166 {
00167 $rbacadmin->revokePermission($this->getRefId());
00168
00169 if ($tree_id = $this->isDeleted())
00170 {
00171 $deleted_tree = new ilTree ($tree_id,- (int) $tree_id);
00172 $deleted_tree->deleteTree($deleted_tree->getNodeData($this->getRefId()));
00173 }
00174 else
00175 {
00176 $tree->deleteTree($tree->getNodeData($this->getRefId()));
00177 }
00178
00179 $this->delete();
00180
00181 return true;
00182 }
00183
00184 return false;
00185 }
00186
00192 function isDeleted()
00193 {
00194 $q = "SELECT tree FROM tree WHERE child='".$this->getRefId()."'";
00195 $row = $this->ilias->db->getRow($q);
00196
00197 if ($row->tree < 0)
00198 {
00199 return $row->tree;
00200 }
00201
00202 return false;
00203 }
00204 }
00205 ?>