ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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{
17 protected $ctrl;
18 protected $lng;
19 protected $node_id;
20 protected $access_handler;
21 protected $footer;
22
25 const PERMISSION_ALL = -5;
26
27
28 function __construct($a_node_id, $a_access_handler, $a_is_portfolio = false, $a_footer = null)
29 {
30 global $ilCtrl, $lng;
31
32 $this->ctrl = $ilCtrl;
33 $this->lng = $lng;
34 $this->node_id = $a_node_id;
35 $this->access_handler = $a_access_handler;
36 $this->is_portfolio = (bool)$a_is_portfolio;
37 $this->footer = $a_footer;
38 }
39
40 function executeCommand()
41 {
42 global $ilTabs, $tpl;
43
44 $next_class = $this->ctrl->getNextClass($this);
45 $cmd = $this->ctrl->getCmd();
46
47 switch($next_class)
48 {
49 case "ilmailsearchcoursesgui";
50 $ilTabs->setBackTarget($this->lng->txt("back"),
51 $this->ctrl->getLinkTarget($this, "share"));
52 include_once('Services/Contact/classes/class.ilMailSearchCoursesGUI.php');
53 $csearch = new ilMailSearchCoursesGUI($this->access_handler, $this->node_id);
54 $this->ctrl->setReturn($this, 'share');
55 $this->ctrl->forwardCommand($csearch);
56
57 $this->setObjectTitle();
58 break;
59
60 case "ilmailsearchgroupsgui";
61 $ilTabs->setBackTarget($this->lng->txt("back"),
62 $this->ctrl->getLinkTarget($this, "share"));
63 include_once('Services/Contact/classes/class.ilMailSearchGroupsGUI.php');
64 $gsearch = new ilMailSearchGroupsGUI($this->access_handler, $this->node_id);
65 $this->ctrl->setReturn($this, 'share');
66 $this->ctrl->forwardCommand($gsearch);
67
68 $this->setObjectTitle();
69 break;
70
71 case "ilmailsearchgui";
72 $ilTabs->setBackTarget($this->lng->txt("back"),
73 $this->ctrl->getLinkTarget($this, "share"));
74 include_once('Services/Contact/classes/class.ilMailSearchGUI.php');
75 $usearch = new ilMailSearchGUI($this->access_handler, $this->node_id);
76 $this->ctrl->setReturn($this, 'share');
77 $this->ctrl->forwardCommand($usearch);
78
79 $this->setObjectTitle();
80 break;
81
82 case "ilsingleusersharegui";
83 $ilTabs->setBackTarget($this->lng->txt("back"),
84 $this->ctrl->getLinkTarget($this, "share"));
85 include_once('Services/PersonalWorkspace/classes/class.ilSingleUserShareGUI.php');
86 $ushare = new ilSingleUserShareGUI($this->access_handler, $this->node_id);
87 $this->ctrl->setReturn($this, 'share');
88 $this->ctrl->forwardCommand($ushare);
89
90 $this->setObjectTitle();
91 break;
92
93 case "ilpublicuserprofilegui";
94 $ilTabs->clearTargets();
95 $ilTabs->setBackTarget($this->lng->txt("back"),
96 $this->ctrl->getLinkTarget($this, "share"));
97
98 include_once('./Services/User/classes/class.ilPublicUserProfileGUI.php');
99 $prof = new ilPublicUserProfileGUI($_REQUEST["user"]);
100 $prof->setBackUrl($this->ctrl->getLinkTarget($this, "share"));
101 $tpl->setContent($prof->getHTML());
102 break;
103
104 default:
105 // $this->prepareOutput();
106 if(!$cmd)
107 {
108 $cmd = "share";
109 }
110 return $this->$cmd();
111 }
112
113 return true;
114 }
115
121 protected function setObjectTitle()
122 {
123 global $tpl;
124
125 if(!$this->is_portfolio)
126 {
127 $obj_id = $this->access_handler->getTree()->lookupObjectId($this->node_id);
128 }
129 else
130 {
131 $obj_id = $this->node_id;
132 }
133 $tpl->setTitle(ilObject::_lookupTitle($obj_id));
134 }
135
136 protected function getAccessHandler()
137 {
139 }
140
141 protected function share()
142 {
143 global $ilToolbar, $tpl, $ilUser, $ilSetting;
144
145 $options = array();
146 $options["user"] = $this->lng->txt("wsp_set_permission_single_user");
147
148 include_once 'Modules/Group/classes/class.ilGroupParticipants.php';
149 $grp_ids = ilGroupParticipants::_getMembershipByType($ilUser->getId(), 'grp');
150 if(sizeof($grp_ids))
151 {
152 $options["group"] = $this->lng->txt("wsp_set_permission_group");
153 }
154
155 include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
156 $crs_ids = ilCourseParticipants::_getMembershipByType($ilUser->getId(), 'crs');
157 if(sizeof($crs_ids))
158 {
159 $options["course"] = $this->lng->txt("wsp_set_permission_course");
160 }
161
162 if(!$this->getAccessHandler()->hasRegisteredPermission($this->node_id))
163 {
164 $options["registered"] = $this->lng->txt("wsp_set_permission_registered");
165 }
166
167 if($ilSetting->get("enable_global_profiles"))
168 {
169 if(!$this->getAccessHandler()->hasGlobalPasswordPermission($this->node_id))
170 {
171 $options["password"] = $this->lng->txt("wsp_set_permission_all_password");
172 }
173
174 if(!$this->getAccessHandler()->hasGlobalPermission($this->node_id))
175 {
176 $options["all"] = $this->lng->txt("wsp_set_permission_all");
177 }
178 }
179
180 include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
181 $actions = new ilSelectInputGUI("", "action");
182 $actions->setOptions($options);
183 $ilToolbar->addStickyItem($actions);
184
185 $ilToolbar->setFormAction($this->ctrl->getFormAction($this));
186
187 include_once "Services/UIComponent/Button/classes/class.ilSubmitButton.php";
188 $button = ilSubmitButton::getInstance();
189 $button->setCaption("add");
190 $button->setCommand("addpermissionhandler");
191 $ilToolbar->addStickyItem($button);
192
193 include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessTableGUI.php";
194 $table = new ilWorkspaceAccessTableGUI($this, "share", $this->node_id, $this->getAccessHandler());
195 $tpl->setContent($table->getHTML().$this->footer);
196 }
197
198 public function addPermissionHandler()
199 {
200 switch($_REQUEST["action"])
201 {
202 case "user":
203
204 include_once './Services/User/classes/class.ilUserAccountSettings.php';
205 if(ilUserAccountSettings::getInstance()->isUserAccessRestricted())
206 {
207 $this->ctrl->redirectByClass("ilsingleusersharegui");
208 }
209 else
210 {
211 $this->ctrl->setParameterByClass("ilmailsearchgui", "ref", "wsp");
212 $this->ctrl->redirectByClass("ilmailsearchgui");
213 }
214
215 case "group":
216 $this->ctrl->setParameterByClass("ilmailsearchgroupsgui", "ref", "wsp");
217 $this->ctrl->redirectByClass("ilmailsearchgroupsgui");
218
219 case "course":
220 $this->ctrl->setParameterByClass("ilmailsearchcoursesgui", "ref", "wsp");
221 $this->ctrl->redirectByClass("ilmailsearchcoursesgui");
222
223 case "registered":
224 $this->getAccessHandler()->addPermission($this->node_id, self::PERMISSION_REGISTERED);
225 ilUtil::sendSuccess($this->lng->txt("wsp_permission_registered_info"), true);
226 $this->ctrl->redirect($this, "share");
227
228 case "password":
229 $this->showPasswordForm();
230 break;
231
232 case "all":
233 $this->getAccessHandler()->addPermission($this->node_id, self::PERMISSION_ALL);
234 ilUtil::sendSuccess($this->lng->txt("wsp_permission_all_info"), true);
235 $this->ctrl->redirect($this, "share");
236 }
237 }
238
239 public function removePermission()
240 {
241 if($_REQUEST["obj_id"])
242 {
243 $this->getAccessHandler()->removePermission($this->node_id, (int)$_REQUEST["obj_id"]);
244 ilUtil::sendSuccess($this->lng->txt("wsp_permission_removed"), true);
245 }
246
247 $this->ctrl->redirect($this, "share");
248 }
249
250 protected function initPasswordForm()
251 {
252 include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
253 $form = new ilPropertyFormGUI();
254 $form->setFormAction($this->ctrl->getFormAction($this));
255 $form->setTitle($this->lng->txt("wsp_set_permission_all_password"));
256
257 $password = new ilPasswordInputGUI($this->lng->txt("password"), "password");
258 $password->setRequired(true);
259 $form->addItem($password);
260
261 $form->addCommandButton('savepasswordform', $this->lng->txt("save"));
262 $form->addCommandButton('share', $this->lng->txt("cancel"));
263
264 return $form;
265 }
266
267 protected function showPasswordForm(ilPropertyFormGUI $a_form = null)
268 {
269 global $tpl;
270
271 if(!$a_form)
272 {
273 $a_form = $this->initPasswordForm();
274 }
275 $tpl->setContent($a_form->getHTML());
276 }
277
278 protected function savePasswordForm()
279 {
280 $form = $this->initPasswordForm();
281 if($form->checkInput())
282 {
283 $this->getAccessHandler()->addPermission($this->node_id,
284 self::PERMISSION_ALL_PASSWORD, md5($form->getInput("password")));
285 ilUtil::sendSuccess($this->lng->txt("wsp_permission_all_pw_info"), true);
286 $this->ctrl->redirect($this, "share");
287 }
288
289 $form->setValuesByPost();
290 $this->showPasswordForm($form);
291 }
292}
293
294?>
global $tpl
Definition: ilias.php:8
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
$cmd
Definition: sahs_server.php:35
if(!is_array($argv)) $options
$ilUser
Definition: imgupload.php:18