ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilPermission2GUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4
17{
18 protected $gui_obj = null;
19 protected $ilErr = null;
20 protected $ctrl = null;
21 protected $lng = null;
22 protected $tpl;
23 const TAB_POSITION_PERMISSION_SETTINGS = "position_permission_settings";
24
25
26 public function __construct($a_gui_obj)
27 {
28 global $DIC;
29
30 $ilias = $DIC['ilias'];
31 $objDefinition = $DIC['objDefinition'];
32 $tpl = $DIC['tpl'];
33 $tree = $DIC['tree'];
34 $ilCtrl = $DIC['ilCtrl'];
35 $ilErr = $DIC['ilErr'];
36 $lng = $DIC['lng'];
37
38 if (!isset($ilErr)) {
39 $ilErr = new ilErrorHandling();
40 $ilErr->setErrorHandling(PEAR_ERROR_CALLBACK, array($ilErr,'errorHandler'));
41 } else {
42 $this->ilErr = &$ilErr;
43 }
44
45 $this->objDefinition = &$objDefinition;
46 $this->tpl = &$tpl;
47 $this->lng = &$lng;
48 $this->lng->loadLanguageModule("rbac");
49
50 $this->ctrl = &$ilCtrl;
51
52 $this->gui_obj = $a_gui_obj;
53
54 $this->roles = array();
55 $this->num_roles = 0;
56 }
57
58
59
60
61
62 // show owner sub tab
63 public function owner()
64 {
65 $this->__initSubTabs("owner");
66
67 include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
68 $form = new ilPropertyFormGUI();
69 $form->setFormAction($this->ctrl->getFormAction($this, "owner"));
70 $form->setTitle($this->lng->txt("info_owner_of_object"));
71
72 $login = new ilTextInputGUI($this->lng->txt("login"), "owner");
73 $login->setDataSource($this->ctrl->getLinkTargetByClass(array(get_class($this),
74 'ilRepositorySearchGUI'), 'doUserAutoComplete', '', true));
75 $login->setRequired(true);
76 $login->setSize(50);
77 $login->setInfo($this->lng->txt("chown_warning"));
78 $login->setValue(ilObjUser::_lookupLogin($this->gui_obj->object->getOwner()));
79 $form->addItem($login);
80
81 $form->addCommandButton("changeOwner", $this->lng->txt("change_owner"));
82
83 $this->tpl->setContent($form->getHTML());
84 }
85
86 public function changeOwner()
87 {
88 global $DIC;
89
90 $rbacsystem = $DIC['rbacsystem'];
91 $ilObjDataCache = $DIC['ilObjDataCache'];
92
93 if (!$user_id = ilObjUser::_lookupId($_POST['owner'])) {
94 ilUtil::sendFailure($this->lng->txt('user_not_known'));
95 $this->owner();
96 return true;
97 }
98
99 // no need to change?
100 if ($user_id != $this->gui_obj->object->getOwner()) {
101 $this->gui_obj->object->setOwner($user_id);
102 $this->gui_obj->object->updateOwner();
103 $ilObjDataCache->deleteCachedEntry($this->gui_obj->object->getId());
104
105 include_once "Services/AccessControl/classes/class.ilRbacLog.php";
106 if (ilRbacLog::isActive()) {
107 ilRbacLog::add(ilRbacLog::CHANGE_OWNER, $this->gui_obj->object->getRefId(), array($user_id));
108 }
109 }
110
111 ilUtil::sendSuccess($this->lng->txt('owner_updated'), true);
112
113 if (!$rbacsystem->checkAccess("edit_permission", $this->gui_obj->object->getRefId())) {
114 $this->ctrl->redirect($this->gui_obj);
115 return true;
116 }
117
118 $this->ctrl->redirect($this, 'owner');
119 return true;
120 }
121
122 // init sub tabs
123 public function __initSubTabs($a_cmd)
124 {
125 global $DIC;
126
127 $ilTabs = $DIC['ilTabs'];
128
129 $perm = ($a_cmd == 'perm') ? true : false;
130 $perm_positions = ($a_cmd == ilPermissionGUI::CMD_PERM_POSITIONS) ? true : false;
131 $info = ($a_cmd == 'perminfo') ? true : false;
132 $owner = ($a_cmd == 'owner') ? true : false;
133 $log = ($a_cmd == 'log') ? true : false;
134
135 $ilTabs->addSubTabTarget(
136 "permission_settings",
137 $this->ctrl->getLinkTarget($this, "perm"),
138 "",
139 "",
140 "",
141 $perm
142 );
143
144 if (ilOrgUnitGlobalSettings::getInstance()->isPositionAccessActiveForObject($this->gui_obj->object->getId())) {
145 $ilTabs->addSubTabTarget(self::TAB_POSITION_PERMISSION_SETTINGS, $this->ctrl->getLinkTarget($this, ilPermissionGUI::CMD_PERM_POSITIONS), "", "", "", $perm_positions);
146 }
147
148 $ilTabs->addSubTabTarget(
149 "info_status_info",
150 $this->ctrl->getLinkTargetByClass(array(get_class($this),"ilobjectpermissionstatusgui"), "perminfo"),
151 "",
152 "",
153 "",
154 $info
155 );
156 $ilTabs->addSubTabTarget(
157 "owner",
158 $this->ctrl->getLinkTarget($this, "owner"),
159 "",
160 "",
161 "",
162 $owner
163 );
164
165 include_once "Services/AccessControl/classes/class.ilRbacLog.php";
166 if (ilRbacLog::isActive()) {
167 $ilTabs->addSubTabTarget(
168 "rbac_log",
169 $this->ctrl->getLinkTarget($this, "log"),
170 "",
171 "",
172 "",
173 $log
174 );
175 }
176 }
177
178 public function log()
179 {
180 include_once "Services/AccessControl/classes/class.ilRbacLog.php";
181 if (!ilRbacLog::isActive()) {
182 $this->ctrl->redirect($this, "perm");
183 }
184
185 $this->__initSubTabs("log");
186
187 include_once "Services/AccessControl/classes/class.ilRbacLogTableGUI.php";
188 $table = new ilRbacLogTableGUI($this, "log", $this->gui_obj->object->getRefId());
189 $this->tpl->setContent($table->getHTML());
190 }
191
192 public function applyLogFilter()
193 {
194 include_once "Services/AccessControl/classes/class.ilRbacLogTableGUI.php";
195 $table = new ilRbacLogTableGUI($this, "log", $this->gui_obj->object->getRefId());
196 $table->resetOffset();
197 $table->writeFilterToSession();
198 $this->log();
199 }
200
201 public function resetLogFilter()
202 {
203 include_once "Services/AccessControl/classes/class.ilRbacLogTableGUI.php";
204 $table = new ilRbacLogTableGUI($this, "log", $this->gui_obj->object->getRefId());
205 $table->resetOffset();
206 $table->resetFilter();
207 $this->log();
208 }
209}
const PEAR_ERROR_CALLBACK
Definition: PEAR.php:35
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
static _lookupLogin($a_user_id)
lookup login
static _lookupId($a_user_str)
Lookup id by login.
Class ilPermissionGUI RBAC related output.
This class represents a property form user interface.
Class ilRbacLogTableGUI.
static add($a_action, $a_ref_id, array $a_diff, $a_source_ref_id=false)
const CHANGE_OWNER
static isActive()
This class represents a text property in a property form.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$login
Definition: cron.php:13
global $DIC
Definition: goto.php:24
$log
Definition: result.php:15