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