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