ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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
52
53 public function __construct($a_node_id, $a_access_handler, $a_is_portfolio = false, $a_footer = null)
54 {
55 global $DIC;
56
57 $this->tabs = $DIC->tabs();
58 $this->tpl = $DIC["tpl"];
59 $this->toolbar = $DIC->toolbar();
60 $this->user = $DIC->user();
61 $this->settings = $DIC->settings();
62 $ilCtrl = $DIC->ctrl();
63 $lng = $DIC->language();
64
65 $this->ctrl = $ilCtrl;
66 $this->lng = $lng;
67 $this->node_id = $a_node_id;
68 $this->access_handler = $a_access_handler;
69 $this->is_portfolio = (bool) $a_is_portfolio;
70 $this->footer = $a_footer;
71 }
72
73 public function executeCommand()
74 {
75 $ilTabs = $this->tabs;
77
78 $next_class = $this->ctrl->getNextClass($this);
79 $cmd = $this->ctrl->getCmd();
80
81 switch ($next_class) {
82 case "ilmailsearchcoursesgui":
83 $ilTabs->setBackTarget(
84 $this->lng->txt("back"),
85 $this->ctrl->getLinkTarget($this, "share")
86 );
87 include_once('Services/Contact/classes/class.ilMailSearchCoursesGUI.php');
88 $csearch = new ilMailSearchCoursesGUI($this->access_handler, $this->node_id);
89 $this->ctrl->setReturn($this, 'share');
90 $this->ctrl->forwardCommand($csearch);
91
92 $this->setObjectTitle();
93 break;
94
95 case "ilmailsearchgroupsgui":
96 $ilTabs->setBackTarget(
97 $this->lng->txt("back"),
98 $this->ctrl->getLinkTarget($this, "share")
99 );
100 include_once('Services/Contact/classes/class.ilMailSearchGroupsGUI.php');
101 $gsearch = new ilMailSearchGroupsGUI($this->access_handler, $this->node_id);
102 $this->ctrl->setReturn($this, 'share');
103 $this->ctrl->forwardCommand($gsearch);
104
105 $this->setObjectTitle();
106 break;
107
108 case "ilmailsearchgui":
109 $ilTabs->setBackTarget(
110 $this->lng->txt("back"),
111 $this->ctrl->getLinkTarget($this, "share")
112 );
113 include_once('Services/Contact/classes/class.ilMailSearchGUI.php');
114 $usearch = new ilMailSearchGUI($this->access_handler, $this->node_id);
115 $this->ctrl->setReturn($this, 'share');
116 $this->ctrl->forwardCommand($usearch);
117
118 $this->setObjectTitle();
119 break;
120
121 case "ilsingleusersharegui":
122 $ilTabs->setBackTarget(
123 $this->lng->txt("back"),
124 $this->ctrl->getLinkTarget($this, "share")
125 );
126 include_once('Services/PersonalWorkspace/classes/class.ilSingleUserShareGUI.php');
127 $ushare = new ilSingleUserShareGUI($this->access_handler, $this->node_id);
128 $this->ctrl->setReturn($this, 'share');
129 $this->ctrl->forwardCommand($ushare);
130
131 $this->setObjectTitle();
132 break;
133
134 case "ilpublicuserprofilegui":
135 $ilTabs->clearTargets();
136 $ilTabs->setBackTarget(
137 $this->lng->txt("back"),
138 $this->ctrl->getLinkTarget($this, "share")
139 );
140
141 include_once('./Services/User/classes/class.ilPublicUserProfileGUI.php');
142 $prof = new ilPublicUserProfileGUI($_REQUEST["user"]);
143 $prof->setBackUrl($this->ctrl->getLinkTarget($this, "share"));
144 $tpl->setContent($prof->getHTML());
145 break;
146
147 default:
148 // $this->prepareOutput();
149 if (!$cmd) {
150 $cmd = "share";
151 }
152 return $this->$cmd();
153 }
154
155 return true;
156 }
157
163 protected function setObjectTitle()
164 {
166
167 if (!$this->is_portfolio) {
168 $obj_id = $this->access_handler->getTree()->lookupObjectId($this->node_id);
169 } else {
170 $obj_id = $this->node_id;
171 }
172 $tpl->setTitle(ilObject::_lookupTitle($obj_id));
173 }
174
175 protected function getAccessHandler()
176 {
178 }
179
180 protected function share()
181 {
182 $ilToolbar = $this->toolbar;
186
187 $options = array();
188 $options["user"] = $this->lng->txt("wsp_set_permission_single_user");
189
190 include_once 'Modules/Group/classes/class.ilGroupParticipants.php';
191 $grp_ids = ilGroupParticipants::_getMembershipByType($ilUser->getId(), 'grp');
192 if (sizeof($grp_ids)) {
193 $options["group"] = $this->lng->txt("wsp_set_permission_group");
194 }
195
196 include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
197 $crs_ids = ilCourseParticipants::_getMembershipByType($ilUser->getId(), 'crs');
198 if (sizeof($crs_ids)) {
199 $options["course"] = $this->lng->txt("wsp_set_permission_course");
200 }
201
202 if (!$this->getAccessHandler()->hasRegisteredPermission($this->node_id)) {
203 $options["registered"] = $this->lng->txt("wsp_set_permission_registered");
204 }
205
206 if ($ilSetting->get("enable_global_profiles")) {
207 if (!$this->getAccessHandler()->hasGlobalPasswordPermission($this->node_id)) {
208 $options["password"] = $this->lng->txt("wsp_set_permission_all_password");
209 }
210
211 if (!$this->getAccessHandler()->hasGlobalPermission($this->node_id)) {
212 $options["all"] = $this->lng->txt("wsp_set_permission_all");
213 }
214 }
215
216 include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
217 $actions = new ilSelectInputGUI("", "action");
218 $actions->setOptions($options);
219 $ilToolbar->addStickyItem($actions);
220
221 $ilToolbar->setFormAction($this->ctrl->getFormAction($this));
222
223 include_once "Services/UIComponent/Button/classes/class.ilSubmitButton.php";
224 $button = ilSubmitButton::getInstance();
225 $button->setCaption("add");
226 $button->setCommand("addpermissionhandler");
227 $ilToolbar->addStickyItem($button);
228
229 include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessTableGUI.php";
230 $table = new ilWorkspaceAccessTableGUI($this, "share", $this->node_id, $this->getAccessHandler());
231 $tpl->setContent($table->getHTML() . $this->footer);
232 }
233
234 public function addPermissionHandler()
235 {
236 switch ($_REQUEST["action"]) {
237 case "user":
238
239 include_once './Services/User/classes/class.ilUserAccountSettings.php';
240 if (ilUserAccountSettings::getInstance()->isUserAccessRestricted()) {
241 $this->ctrl->redirectByClass("ilsingleusersharegui");
242 } else {
243 $this->ctrl->setParameterByClass("ilmailsearchgui", "ref", "wsp");
244 $this->ctrl->redirectByClass("ilmailsearchgui");
245 }
246
247 // no break
248 case "group":
249 $this->ctrl->setParameterByClass("ilmailsearchgroupsgui", "ref", "wsp");
250 $this->ctrl->redirectByClass("ilmailsearchgroupsgui");
251
252 // no break
253 case "course":
254 $this->ctrl->setParameterByClass("ilmailsearchcoursesgui", "ref", "wsp");
255 $this->ctrl->redirectByClass("ilmailsearchcoursesgui");
256
257 // no break
258 case "registered":
259 $this->getAccessHandler()->addPermission($this->node_id, self::PERMISSION_REGISTERED);
260 ilUtil::sendSuccess($this->lng->txt("wsp_permission_registered_info"), true);
261 $this->ctrl->redirect($this, "share");
262
263 // no break
264 case "password":
265 $this->showPasswordForm();
266 break;
267
268 case "all":
269 $this->getAccessHandler()->addPermission($this->node_id, self::PERMISSION_ALL);
270 ilUtil::sendSuccess($this->lng->txt("wsp_permission_all_info"), true);
271 $this->ctrl->redirect($this, "share");
272 }
273 }
274
275 public function removePermission()
276 {
277 if ($_REQUEST["obj_id"]) {
278 $this->getAccessHandler()->removePermission($this->node_id, (int) $_REQUEST["obj_id"]);
279 ilUtil::sendSuccess($this->lng->txt("wsp_permission_removed"), true);
280 }
281
282 $this->ctrl->redirect($this, "share");
283 }
284
285 protected function initPasswordForm()
286 {
287 include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
288 $form = new ilPropertyFormGUI();
289 $form->setFormAction($this->ctrl->getFormAction($this));
290 $form->setTitle($this->lng->txt("wsp_set_permission_all_password"));
291
292 $password = new ilPasswordInputGUI($this->lng->txt("password"), "password");
293 $password->setRequired(true);
294 $form->addItem($password);
295
296 $form->addCommandButton('savepasswordform', $this->lng->txt("save"));
297 $form->addCommandButton('share', $this->lng->txt("cancel"));
298
299 return $form;
300 }
301
302 protected function showPasswordForm(ilPropertyFormGUI $a_form = null)
303 {
305
306 if (!$a_form) {
307 $a_form = $this->initPasswordForm();
308 }
309 $tpl->setContent($a_form->getHTML());
310 }
311
312 protected function savePasswordForm()
313 {
314 $form = $this->initPasswordForm();
315 if ($form->checkInput()) {
316 $this->getAccessHandler()->addPermission(
317 $this->node_id,
318 self::PERMISSION_ALL_PASSWORD,
319 md5($form->getInput("password"))
320 );
321 ilUtil::sendSuccess($this->lng->txt("wsp_permission_all_pw_info"), true);
322 $this->ctrl->redirect($this, "share");
323 }
324
325 $form->setValuesByPost();
326 $this->showPasswordForm($form);
327 }
328}
user()
Definition: user.php:4
if(!isset( $_REQUEST[ 'ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20
An exception for terminatinating execution or to throw for unit testing.
static _lookupTitle($a_id)
lookup object title
static _getMembershipByType($a_usr_id, $a_type, $a_only_member_role=false)
get membership by type Get course or group membership
This class represents a password property in a property form.
This class represents a property form user interface.
GUI class for public user profile presentation.
This class represents a selection list property in a property form.
static getInstance()
Factory.
static getInstance()
Singelton get instance.
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
showPasswordForm(ilPropertyFormGUI $a_form=null)
setObjectTitle()
restore object title
__construct($a_node_id, $a_access_handler, $a_is_portfolio=false, $a_footer=null)
Workspace access handler table GUI class.
global $ilCtrl
Definition: ilias.php:18
global $ilSetting
Definition: privfeed.php:17
$password
Definition: pwgen.php:17
if(empty($password)) $table
Definition: pwgen.php:24
if(isset($_POST['submit'])) $form
global $DIC
Definition: saml.php:7
settings()
Definition: settings.php:2
$ilUser
Definition: imgupload.php:18