ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilWorkspaceAccessGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
16 {
20  protected $tabs;
21 
25  protected $tpl;
26 
30  protected $toolbar;
31 
35  protected $user;
36 
40  protected $settings;
41 
42  protected $ctrl;
43  protected $lng;
44  protected $node_id;
45  protected $access_handler;
46  protected $footer;
47 
50  const PERMISSION_ALL = -5;
51 
55  protected $blocking_message = "";
56 
57  public function __construct($a_node_id, $a_access_handler, $a_is_portfolio = false, $a_footer = null)
58  {
59  global $DIC;
60 
61  $this->tabs = $DIC->tabs();
62  $this->tpl = $DIC["tpl"];
63  $this->toolbar = $DIC->toolbar();
64  $this->user = $DIC->user();
65  $this->settings = $DIC->settings();
66  $ilCtrl = $DIC->ctrl();
67  $lng = $DIC->language();
68 
69  $this->ctrl = $ilCtrl;
70  $this->lng = $lng;
71  $this->node_id = $a_node_id;
72  $this->access_handler = $a_access_handler;
73  $this->is_portfolio = (bool) $a_is_portfolio;
74  $this->footer = $a_footer;
75  }
76 
82  public function setBlockingMessage($a_val)
83  {
84  $this->blocking_message = $a_val;
85  }
86 
92  public function getBlockingMessage()
93  {
95  }
96 
97 
98  public function executeCommand()
99  {
100  $ilTabs = $this->tabs;
101  $tpl = $this->tpl;
102 
103  $next_class = $this->ctrl->getNextClass($this);
104  $cmd = $this->ctrl->getCmd();
105 
106  switch ($next_class) {
107  case "ilmailsearchcoursesgui":
108  $ilTabs->setBackTarget(
109  $this->lng->txt("back"),
110  $this->ctrl->getLinkTarget($this, "share")
111  );
112  include_once('Services/Contact/classes/class.ilMailSearchCoursesGUI.php');
113  $csearch = new ilMailSearchCoursesGUI($this->access_handler, $this->node_id);
114  $this->ctrl->setReturn($this, 'share');
115  $this->ctrl->forwardCommand($csearch);
116 
117  $this->setObjectTitle();
118  break;
119 
120  case "ilmailsearchgroupsgui":
121  $ilTabs->setBackTarget(
122  $this->lng->txt("back"),
123  $this->ctrl->getLinkTarget($this, "share")
124  );
125  include_once('Services/Contact/classes/class.ilMailSearchGroupsGUI.php');
126  $gsearch = new ilMailSearchGroupsGUI($this->access_handler, $this->node_id);
127  $this->ctrl->setReturn($this, 'share');
128  $this->ctrl->forwardCommand($gsearch);
129 
130  $this->setObjectTitle();
131  break;
132 
133  case "ilmailsearchgui":
134  $ilTabs->setBackTarget(
135  $this->lng->txt("back"),
136  $this->ctrl->getLinkTarget($this, "share")
137  );
138  include_once('Services/Contact/classes/class.ilMailSearchGUI.php');
139  $usearch = new ilMailSearchGUI($this->access_handler, $this->node_id);
140  $this->ctrl->setReturn($this, 'share');
141  $this->ctrl->forwardCommand($usearch);
142 
143  $this->setObjectTitle();
144  break;
145 
146  case "ilsingleusersharegui":
147  $ilTabs->setBackTarget(
148  $this->lng->txt("back"),
149  $this->ctrl->getLinkTarget($this, "share")
150  );
151  include_once('Services/PersonalWorkspace/classes/class.ilSingleUserShareGUI.php');
152  $ushare = new ilSingleUserShareGUI($this->access_handler, $this->node_id);
153  $this->ctrl->setReturn($this, 'share');
154  $this->ctrl->forwardCommand($ushare);
155 
156  $this->setObjectTitle();
157  break;
158 
159  case "ilpublicuserprofilegui":
160  $ilTabs->clearTargets();
161  $ilTabs->setBackTarget(
162  $this->lng->txt("back"),
163  $this->ctrl->getLinkTarget($this, "share")
164  );
165 
166  include_once('./Services/User/classes/class.ilPublicUserProfileGUI.php');
167  $prof = new ilPublicUserProfileGUI($_REQUEST["user"]);
168  $prof->setBackUrl($this->ctrl->getLinkTarget($this, "share"));
169  $tpl->setContent($prof->getHTML());
170  break;
171 
172  default:
173  // $this->prepareOutput();
174  if (!$cmd) {
175  $cmd = "share";
176  }
177  return $this->$cmd();
178  }
179 
180  return true;
181  }
182 
188  protected function setObjectTitle()
189  {
190  $tpl = $this->tpl;
191 
192  if (!$this->is_portfolio) {
193  $obj_id = $this->access_handler->getTree()->lookupObjectId($this->node_id);
194  } else {
195  $obj_id = $this->node_id;
196  }
197  $tpl->setTitle(ilObject::_lookupTitle($obj_id));
198  }
199 
200  protected function getAccessHandler()
201  {
202  return $this->access_handler;
203  }
204 
205  protected function share()
206  {
207  $ilToolbar = $this->toolbar;
208  $tpl = $this->tpl;
211 
212 
213  // blocking message
214  if ($this->getBlockingMessage() != "") {
215  $tpl->setContent($this->getBlockingMessage());
216  return;
217  }
218 
219  $options = array();
220  $options["user"] = $this->lng->txt("wsp_set_permission_single_user");
221 
222  include_once 'Modules/Group/classes/class.ilGroupParticipants.php';
223  $grp_ids = ilGroupParticipants::_getMembershipByType($ilUser->getId(), 'grp');
224  if (sizeof($grp_ids)) {
225  $options["group"] = $this->lng->txt("wsp_set_permission_group");
226  }
227 
228  include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
229  $crs_ids = ilCourseParticipants::_getMembershipByType($ilUser->getId(), 'crs');
230  if (sizeof($crs_ids)) {
231  $options["course"] = $this->lng->txt("wsp_set_permission_course");
232  }
233 
234  if (!$this->getAccessHandler()->hasRegisteredPermission($this->node_id)) {
235  $options["registered"] = $this->lng->txt("wsp_set_permission_registered");
236  }
237 
238  if ($ilSetting->get("enable_global_profiles")) {
239  if (!$this->getAccessHandler()->hasGlobalPasswordPermission($this->node_id)) {
240  $options["password"] = $this->lng->txt("wsp_set_permission_all_password");
241  }
242 
243  if (!$this->getAccessHandler()->hasGlobalPermission($this->node_id)) {
244  $options["all"] = $this->lng->txt("wsp_set_permission_all");
245  }
246  }
247 
248  include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
249  $actions = new ilSelectInputGUI("", "action");
250  $actions->setOptions($options);
251  $ilToolbar->addStickyItem($actions);
252 
253  $ilToolbar->setFormAction($this->ctrl->getFormAction($this));
254 
255  include_once "Services/UIComponent/Button/classes/class.ilSubmitButton.php";
256  $button = ilSubmitButton::getInstance();
257  $button->setCaption("add");
258  $button->setCommand("addpermissionhandler");
259  $ilToolbar->addStickyItem($button);
260 
261  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessTableGUI.php";
262  $table = new ilWorkspaceAccessTableGUI($this, "share", $this->node_id, $this->getAccessHandler());
263  $tpl->setContent($table->getHTML() . $this->footer);
264  }
265 
266  public function addPermissionHandler()
267  {
268  switch ($_REQUEST["action"]) {
269  case "user":
270 
271  include_once './Services/User/classes/class.ilUserAccountSettings.php';
272  if (ilUserAccountSettings::getInstance()->isUserAccessRestricted()) {
273  $this->ctrl->redirectByClass("ilsingleusersharegui");
274  } else {
275  $this->ctrl->setParameterByClass("ilmailsearchgui", "ref", "wsp");
276  $this->ctrl->redirectByClass("ilmailsearchgui");
277  }
278 
279  // no break
280  case "group":
281  $this->ctrl->setParameterByClass("ilmailsearchgroupsgui", "ref", "wsp");
282  $this->ctrl->redirectByClass("ilmailsearchgroupsgui");
283 
284  // no break
285  case "course":
286  $this->ctrl->setParameterByClass("ilmailsearchcoursesgui", "ref", "wsp");
287  $this->ctrl->redirectByClass("ilmailsearchcoursesgui");
288 
289  // no break
290  case "registered":
291  $this->getAccessHandler()->addPermission($this->node_id, self::PERMISSION_REGISTERED);
292  ilUtil::sendSuccess($this->lng->txt("wsp_permission_registered_info"), true);
293  $this->ctrl->redirect($this, "share");
294 
295  // no break
296  case "password":
297  $this->showPasswordForm();
298  break;
299 
300  case "all":
301  $this->getAccessHandler()->addPermission($this->node_id, self::PERMISSION_ALL);
302  ilUtil::sendSuccess($this->lng->txt("wsp_permission_all_info"), true);
303  $this->ctrl->redirect($this, "share");
304  }
305  }
306 
307  public function removePermission()
308  {
309  if ($_REQUEST["obj_id"]) {
310  $this->getAccessHandler()->removePermission($this->node_id, (int) $_REQUEST["obj_id"]);
311  ilUtil::sendSuccess($this->lng->txt("wsp_permission_removed"), true);
312  }
313 
314  $this->ctrl->redirect($this, "share");
315  }
316 
317  protected function initPasswordForm()
318  {
319  include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
320  $form = new ilPropertyFormGUI();
321  $form->setFormAction($this->ctrl->getFormAction($this));
322  $form->setTitle($this->lng->txt("wsp_set_permission_all_password"));
323 
324  $password = new ilPasswordInputGUI($this->lng->txt("password"), "password");
325  $password->setRequired(true);
326  $form->addItem($password);
327 
328  $form->addCommandButton('savepasswordform', $this->lng->txt("save"));
329  $form->addCommandButton('share', $this->lng->txt("cancel"));
330 
331  return $form;
332  }
333 
334  protected function showPasswordForm(ilPropertyFormGUI $a_form = null)
335  {
336  $tpl = $this->tpl;
337 
338  if (!$a_form) {
339  $a_form = $this->initPasswordForm();
340  }
341  $tpl->setContent($a_form->getHTML());
342  }
343 
344  protected function savePasswordForm()
345  {
346  $form = $this->initPasswordForm();
347  if ($form->checkInput()) {
348  $this->getAccessHandler()->addPermission(
349  $this->node_id,
350  self::PERMISSION_ALL_PASSWORD,
351  md5($form->getInput("password"))
352  );
353  ilUtil::sendSuccess($this->lng->txt("wsp_permission_all_pw_info"), true);
354  $this->ctrl->redirect($this, "share");
355  }
356 
357  $form->setValuesByPost();
358  $this->showPasswordForm($form);
359  }
360 }
__construct($a_node_id, $a_access_handler, $a_is_portfolio=false, $a_footer=null)
settings()
Definition: settings.php:2
This class represents a selection list property in a property form.
This class represents a property form user interface.
global $DIC
Definition: saml.php:7
setObjectTitle()
restore object title
static _getMembershipByType($a_usr_id, $a_type, $a_only_member_role=false)
get membership by type Get course or group membership
static _lookupTitle($a_id)
lookup object title
user()
Definition: user.php:4
global $ilCtrl
Definition: ilias.php:18
GUI class for public user profile presentation.
if(isset($_POST['submit'])) $form
getBlockingMessage()
Get blocking message.
This class represents a password property in a property form.
$ilUser
Definition: imgupload.php:18
ACL access handler GUI.
$password
Definition: cron.php:14
global $ilSetting
Definition: privfeed.php:17
static getInstance()
Singelton get instance.
showPasswordForm(ilPropertyFormGUI $a_form=null)
Workspace access handler table GUI class.
if(empty($password)) $table
Definition: pwgen.php:24
setBlockingMessage($a_val)
Set blocking message.