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