ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilObjRoleFolder.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 
25 require_once "./Services/Object/classes/class.ilObject.php";
26 
36 {
43  public function __construct($a_id = 0, $a_call_by_reference = true)
44  {
45  $this->type = "rolf";
46  parent::__construct($a_id, $a_call_by_reference);
47  }
48 
49  public function read()
50  {
51  parent::read();
52 
53  if ($this->getId() != ROLE_FOLDER_ID) {
54  $this->setDescription($this->lng->txt("obj_" . $this->getType() . "_local_desc") . $this->getTitle() . $this->getDescription());
55  $this->setTitle($this->lng->txt("obj_" . $this->getType() . "_local"));
56  }
57  }
58 
59 
66  public function delete()
67  {
68  // always call parent delete function first!!
69  if (!parent::delete()) {
70  return false;
71  }
72 
73  // put here rolefolder specific stuff
74  global $rbacreview;
75 
76  $roles = $rbacreview->getRolesOfRoleFolder($this->getRefId());
77 
78  // FIRST DELETE ALL LOCAL/BASE ROLES OF FOLDER
79  foreach ($roles as $role_id) {
80  $roleObj =&$this->ilias->obj_factory->getInstanceByObjId($role_id);
81  $roleObj->setParent($this->getRefId());
82  $roleObj->delete();
83  unset($roleObj);
84  }
85 
86  // always call parent delete function at the end!!
87  return true;
88  }
89 
98  public function createRole($a_title, $a_desc, $a_import_id = 0)
99  {
100  global $rbacadmin, $rbacreview;
101 
102  include_once("./Services/AccessControl/classes/class.ilObjRole.php");
103  $roleObj = new ilObjRole();
104  $roleObj->setTitle($a_title);
105  $roleObj->setDescription($a_desc);
106  //echo "aaa-1-";
107  if ($a_import_id != "") {
108  //echo "aaa-2-".$a_import_id."-";
109  $roleObj->setImportId($a_import_id);
110  }
111  $roleObj->create();
112 
113  // ...and put the role into local role folder...
114  $rbacadmin->assignRoleToFolder($roleObj->getId(), $this->getRefId(), "y");
115 
116  return $roleObj;
117  }
118 
124  public function purge()
125  {
126  global $rbacreview, $rbacadmin, $tree;
127 
128  $local_roles = $rbacreview->getRolesOfRoleFolder($this->getRefId());
129 
130  if (count($local_roles) == 0) {
131  $rbacadmin->revokePermission($this->getRefId());
132 
133  if ($tree_id = $this->isDeleted()) {
134  $deleted_tree = new ilTree($tree_id, -(int) $tree_id);
135  $deleted_tree->deleteTree($deleted_tree->getNodeData($this->getRefId()));
136  } else {
137  $tree->deleteTree($tree->getNodeData($this->getRefId()));
138  }
139 
140  $this->delete();
141 
142  return true;
143  }
144 
145  return false;
146  }
147 
153  public function isDeleted()
154  {
155  $q = "SELECT tree FROM tree WHERE child= " . $this->ilias->db->quote($this->getRefId()) . " ";
156  $row = $this->ilias->db->getRow($q);
157 
158  if ($row->tree < 0) {
159  return $row->tree;
160  }
161 
162  return false;
163  }
164 } // END class.ilObjRoleFolder
Class ilObjRole.
Class ilObjRoleFolder.
__construct($a_id=0, $a_call_by_reference=true)
Constructor public.
createRole($a_title, $a_desc, $a_import_id=0)
creates a local role in current rolefolder (this object)
isDeleted()
checks if role folder is in trash private
setTitle($a_title)
set object title
getId()
get object id public
getTitle()
get object title public
getDescription()
get object description
redirection script todo: (a better solution should control the processing via a xml file) ...
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
purge()
checks if rolefolder contains any roles.
getRefId()
get reference id public
setDescription($a_desc)
set object description