ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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
25require_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 $DIC;
75
76 $rbacreview = $DIC['rbacreview'];
77
78 $roles = $rbacreview->getRolesOfRoleFolder($this->getRefId());
79
80 // FIRST DELETE ALL LOCAL/BASE ROLES OF FOLDER
81 foreach ($roles as $role_id) {
82 $roleObj = &$this->ilias->obj_factory->getInstanceByObjId($role_id);
83 $roleObj->setParent($this->getRefId());
84 $roleObj->delete();
85 unset($roleObj);
86 }
87
88 // always call parent delete function at the end!!
89 return true;
90 }
91
100 public function createRole($a_title, $a_desc, $a_import_id = 0)
101 {
102 global $DIC;
103
104 $rbacadmin = $DIC['rbacadmin'];
105 $rbacreview = $DIC['rbacreview'];
106
107 include_once("./Services/AccessControl/classes/class.ilObjRole.php");
108 $roleObj = new ilObjRole();
109 $roleObj->setTitle($a_title);
110 $roleObj->setDescription($a_desc);
111 //echo "aaa-1-";
112 if ($a_import_id != "") {
113 //echo "aaa-2-".$a_import_id."-";
114 $roleObj->setImportId($a_import_id);
115 }
116 $roleObj->create();
117
118 // ...and put the role into local role folder...
119 $rbacadmin->assignRoleToFolder($roleObj->getId(), $this->getRefId(), "y");
120
121 return $roleObj;
122 }
123
129 public function purge()
130 {
131 global $DIC;
132
133 $rbacreview = $DIC['rbacreview'];
134 $rbacadmin = $DIC['rbacadmin'];
135 $tree = $DIC['tree'];
136
137 $local_roles = $rbacreview->getRolesOfRoleFolder($this->getRefId());
138
139 if (count($local_roles) == 0) {
140 $rbacadmin->revokePermission($this->getRefId());
141
142 if ($tree_id = $this->isDeleted()) {
143 $deleted_tree = new ilTree($tree_id, -(int) $tree_id);
144 $deleted_tree->deleteTree($deleted_tree->getNodeData($this->getRefId()));
145 } else {
146 $tree->deleteTree($tree->getNodeData($this->getRefId()));
147 }
148
149 $this->delete();
150
151 return true;
152 }
153
154 return false;
155 }
156
162 public function isDeleted()
163 {
164 $q = "SELECT tree FROM tree WHERE child= " . $this->ilias->db->quote($this->getRefId()) . " ";
165 $row = $this->ilias->db->getRow($q);
166
167 if ($row->tree < 0) {
168 return $row->tree;
169 }
170
171 return false;
172 }
173} // END class.ilObjRoleFolder
An exception for terminatinating execution or to throw for unit testing.
Class ilObjRoleFolder.
createRole($a_title, $a_desc, $a_import_id=0)
creates a local role in current rolefolder (this object)
read()
read object data from db into object
isDeleted()
checks if role folder is in trash @access private
purge()
checks if rolefolder contains any roles.
__construct($a_id=0, $a_call_by_reference=true)
Constructor @access public.
Class ilObjRole.
Class ilObject Basic functions for all objects.
setTitle($a_title)
set object title
setDescription($a_desc)
set object description
getRefId()
get reference id @access public
getId()
get object id @access public
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
$row
redirection script todo: (a better solution should control the processing via a xml file)
global $DIC
Definition: saml.php:7