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
00061
00068 function delete()
00069 {
00070
00071 if (!parent::delete())
00072 {
00073 return false;
00074 }
00075
00076
00077 global $rbacreview;
00078
00079 $roles = $rbacreview->getRolesOfRoleFolder($this->getRefId());
00080
00081
00082 foreach ($roles as $role_id)
00083 {
00084 $roleObj =& $this->ilias->obj_factory->getInstanceByObjId($role_id);
00085 $roleObj->setParent($this->getRefId());
00086 $roleObj->delete();
00087 unset($roleObj);
00088 }
00089
00090
00091 return true;
00092 }
00093
00102 function createRole($a_title,$a_desc,$a_import_id = 0)
00103 {
00104 global $rbacadmin, $rbacreview;
00105
00106 include_once ("classes/class.ilObjRole.php");
00107 $roleObj = new ilObjRole();
00108 $roleObj->setTitle($a_title);
00109 $roleObj->setDescription($a_desc);
00110
00111 if ($a_import_id != "")
00112 {
00113
00114 $roleObj->setImportId($a_import_id);
00115 }
00116 $roleObj->create();
00117
00118
00119 $rbacadmin->assignRoleToFolder($roleObj->getId(),$this->getRefId(),"y");
00120
00121 return $roleObj;
00122 }
00123
00129 function purge()
00130 {
00131 global $rbacreview, $rbacadmin, $tree;
00132
00133 $local_roles = $rbacreview->getRolesOfRoleFolder($this->getRefId());
00134
00135 if (count($local_roles) == 0)
00136 {
00137 $rbacadmin->revokePermission($this->getRefId());
00138
00139 if ($tree_id = $this->isDeleted())
00140 {
00141 $deleted_tree = new ilTree ($tree_id,- (int) $tree_id);
00142 $deleted_tree->deleteTree($deleted_tree->getNodeData($this->getRefId()));
00143 }
00144 else
00145 {
00146 $tree->deleteTree($tree->getNodeData($this->getRefId()));
00147 }
00148
00149 $this->delete();
00150
00151 return true;
00152 }
00153
00154 return false;
00155 }
00156
00162 function isDeleted()
00163 {
00164 $q = "SELECT tree FROM tree WHERE child= ".$this->ilias->db->quote($this->getRefId())." ";
00165 $row = $this->ilias->db->getRow($q);
00166
00167 if ($row->tree < 0)
00168 {
00169 return $row->tree;
00170 }
00171
00172 return false;
00173 }
00174 }
00175 ?>