ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 const TAB_POSITION_PERMISSION_SETTINGS = "position_permission_settings";
23
24
25 public function __construct($a_gui_obj)
26 {
27 global $ilias, $objDefinition, $tpl, $tree, $ilCtrl, $ilErr, $lng;
28
29 if (!isset($ilErr)) {
30 $ilErr = new ilErrorHandling();
31 $ilErr->setErrorHandling(PEAR_ERROR_CALLBACK, array($ilErr,'errorHandler'));
32 } else {
33 $this->ilErr =&$ilErr;
34 }
35
36 $this->objDefinition =&$objDefinition;
37 $this->tpl =&$tpl;
38 $this->lng =&$lng;
39 $this->lng->loadLanguageModule("rbac");
40
41 $this->ctrl =&$ilCtrl;
42
43 $this->gui_obj = $a_gui_obj;
44
45 $this->roles = array();
46 $this->num_roles = 0;
47 }
48
49
50
51
52
53 // show owner sub tab
54 public function owner()
55 {
56 $this->__initSubTabs("owner");
57
58 include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
60 $form->setFormAction($this->ctrl->getFormAction($this, "owner"));
61 $form->setTitle($this->lng->txt("info_owner_of_object"));
62
63 $login = new ilTextInputGUI($this->lng->txt("login"), "owner");
64 $login->setDataSource($this->ctrl->getLinkTargetByClass(array(get_class($this),
65 'ilRepositorySearchGUI'), 'doUserAutoComplete', '', true));
66 $login->setRequired(true);
67 $login->setSize(50);
68 $login->setInfo($this->lng->txt("chown_warning"));
69 $login->setValue(ilObjUser::_lookupLogin($this->gui_obj->object->getOwner()));
70 $form->addItem($login);
71
72 $form->addCommandButton("changeOwner", $this->lng->txt("change_owner"));
73
74 $this->tpl->setContent($form->getHTML());
75 }
76
77 public function changeOwner()
78 {
79 global $rbacsystem,$ilObjDataCache;
80
81 if (!$user_id = ilObjUser::_lookupId($_POST['owner'])) {
82 ilUtil::sendFailure($this->lng->txt('user_not_known'));
83 $this->owner();
84 return true;
85 }
86
87 // no need to change?
88 if ($user_id != $this->gui_obj->object->getOwner()) {
89 $this->gui_obj->object->setOwner($user_id);
90 $this->gui_obj->object->updateOwner();
91 $ilObjDataCache->deleteCachedEntry($this->gui_obj->object->getId());
92
93 include_once "Services/AccessControl/classes/class.ilRbacLog.php";
94 if (ilRbacLog::isActive()) {
95 ilRbacLog::add(ilRbacLog::CHANGE_OWNER, $this->gui_obj->object->getRefId(), array($user_id));
96 }
97 }
98
99 ilUtil::sendSuccess($this->lng->txt('owner_updated'), true);
100
101 if (!$rbacsystem->checkAccess("edit_permission", $this->gui_obj->object->getRefId())) {
102 $this->ctrl->redirect($this->gui_obj);
103 return true;
104 }
105
106 $this->ctrl->redirect($this, 'owner');
107 return true;
108 }
109
110 // init sub tabs
111 public function __initSubTabs($a_cmd)
112 {
113 global $ilTabs;
114
115 $perm = ($a_cmd == 'perm') ? true : false;
116 $perm_positions = ($a_cmd == ilPermissionGUI::CMD_PERM_POSITIONS) ? true : false;
117 $info = ($a_cmd == 'perminfo') ? true : false;
118 $owner = ($a_cmd == 'owner') ? true : false;
119 $log = ($a_cmd == 'log') ? true : false;
120
121 $ilTabs->addSubTabTarget(
122 "permission_settings",
123 $this->ctrl->getLinkTarget($this, "perm"),
124 "",
125 "",
126 "",
127 $perm
128 );
129
130 if (ilOrgUnitGlobalSettings::getInstance()->isPositionAccessActiveForObject($this->gui_obj->object->getId())) {
131 $ilTabs->addSubTabTarget(self::TAB_POSITION_PERMISSION_SETTINGS, $this->ctrl->getLinkTarget($this, ilPermissionGUI::CMD_PERM_POSITIONS), "", "", "", $perm_positions);
132 }
133
134 $ilTabs->addSubTabTarget(
135 "info_status_info",
136 $this->ctrl->getLinkTargetByClass(array(get_class($this),"ilobjectpermissionstatusgui"), "perminfo"),
137 "",
138 "",
139 "",
140 $info
141 );
142 $ilTabs->addSubTabTarget(
143 "owner",
144 $this->ctrl->getLinkTarget($this, "owner"),
145 "",
146 "",
147 "",
148 $owner
149 );
150
151 include_once "Services/AccessControl/classes/class.ilRbacLog.php";
152 if (ilRbacLog::isActive()) {
153 $ilTabs->addSubTabTarget(
154 "log",
155 $this->ctrl->getLinkTarget($this, "log"),
156 "",
157 "",
158 "",
159 $log
160 );
161 }
162 }
163
164 public function log()
165 {
166 include_once "Services/AccessControl/classes/class.ilRbacLog.php";
167 if (!ilRbacLog::isActive()) {
168 $this->ctrl->redirect($this, "perm");
169 }
170
171 $this->__initSubTabs("log");
172
173 include_once "Services/AccessControl/classes/class.ilRbacLogTableGUI.php";
174 $table = new ilRbacLogTableGUI($this, "log", $this->gui_obj->object->getRefId());
175 $this->tpl->setContent($table->getHTML());
176 }
177
178 public function applyLogFilter()
179 {
180 include_once "Services/AccessControl/classes/class.ilRbacLogTableGUI.php";
181 $table = new ilRbacLogTableGUI($this, "log", $this->gui_obj->object->getRefId());
182 $table->resetOffset();
183 $table->writeFilterToSession();
184 $this->log();
185 }
186
187 public function resetLogFilter()
188 {
189 include_once "Services/AccessControl/classes/class.ilRbacLogTableGUI.php";
190 $table = new ilRbacLogTableGUI($this, "log", $this->gui_obj->object->getRefId());
191 $table->resetOffset();
192 $table->resetFilter();
193 $this->log();
194 }
195}
const PEAR_ERROR_CALLBACK
Definition: PEAR.php:35
$tpl
Definition: ilias.php:10
$_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 sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
global $ilCtrl
Definition: ilias.php:18
$info
Definition: index.php:5
if(empty($password)) $table
Definition: pwgen.php:24
if(isset($_POST['submit'])) $form