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