ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilPortfolioRepositoryGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once('./Modules/Portfolio/classes/class.ilObjPortfolio.php');
5
17{
18 protected $user_id; // [int]
19 protected $access_handler; // [ilPortfolioAccessHandler]
20
21 public function __construct()
22 {
23 global $lng, $ilUser;
24
25 $lng->loadLanguageModule("prtf");
26 $lng->loadLanguageModule("user");
27
28 include_once('./Modules/Portfolio/classes/class.ilPortfolioAccessHandler.php');
29 $this->access_handler = new ilPortfolioAccessHandler();
30
31 $this->user_id = $ilUser->getId();
32 }
33
34 public function executeCommand()
35 {
36 global $ilCtrl, $lng, $tpl, $ilTabs;
37
38 $next_class = $ilCtrl->getNextClass($this);
39 $cmd = $ilCtrl->getCmd("show");
40
41 $tpl->setTitle($lng->txt("portfolio"));
42 $tpl->setTitleIcon(ilUtil::getImagePath("icon_prtf.svg"),
43 $lng->txt("portfolio"));
44
45 switch($next_class)
46 {
47 case "ilobjportfoliogui":
48 if($cmd != "preview")
49 {
50 $this->setLocator();
51
52 $ilTabs->setBack2Target($lng->txt("prtf_tab_portfolios"),
53 $ilCtrl->getLinkTarget($this, "show"));
54 }
55 include_once('./Modules/Portfolio/classes/class.ilObjPortfolioGUI.php');
56 $gui = new ilObjPortfolioGUI($_REQUEST["prt_id"]);
57 $ilCtrl->forwardCommand($gui);
58 break;
59
60 default:
61 $this->setLocator();
62 $this->setTabs();
63 $this->$cmd();
64 break;
65 }
66
67 return true;
68 }
69
70 public function setTabs()
71 {
72 global $ilTabs, $lng, $ilCtrl, $ilHelp;
73
74 $ilHelp->setScreenIdComponent("prtf");
75
76 $ilTabs->addTab("mypf", $lng->txt("prtf_tab_portfolios"),
77 $ilCtrl->getLinkTarget($this));
78
79 $ilTabs->addTab("otpf", $lng->txt("prtf_tab_other_users"),
80 $ilCtrl->getLinkTarget($this, "showotherFilter"));
81
82 $ilTabs->activateTab("mypf");
83 }
84
85 protected function setLocator()
86 {
87 global $ilLocator, $lng, $ilCtrl, $tpl;
88
89 $ilLocator->addItem($lng->txt("portfolio"),
90 $ilCtrl->getLinkTarget($this, "show"));
91
92 $tpl->setLocator();
93 }
94
95 protected function checkAccess($a_permission, $a_portfolio_id = null)
96 {
97 if($a_portfolio_id)
98 {
99 return $this->access_handler->checkAccess($a_permission, "", $a_portfolio_id);
100 }
101 // currently only object-based permissions
102 return true;
103 }
104
105
106 //
107 // LIST INCL. ACTIONS
108 //
109
110 protected function show()
111 {
112 global $tpl, $lng, $ilToolbar, $ilCtrl;
113
114 include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
115 $button = ilLinkButton::getInstance();
116 $button->setCaption("prtf_add_portfolio");
117 $button->setUrl($ilCtrl->getLinkTargetByClass("ilObjPortfolioGUI", "create"));
118 $ilToolbar->addButtonInstance($button);
119
120 include_once "Modules/Portfolio/classes/class.ilPortfolioTableGUI.php";
121 $table = new ilPortfolioTableGUI($this, "show", $this->user_id);
122
123 include_once "Services/DiskQuota/classes/class.ilDiskQuotaHandler.php";
124
125 $tpl->setContent($table->getHTML().ilDiskQuotaHandler::getStatusLegend());
126 }
127
128 protected function saveTitles()
129 {
130 global $ilCtrl, $lng;
131
132 foreach($_POST["title"] as $id => $title)
133 {
134 if(trim($title))
135 {
136 if($this->checkAccess("write", $id))
137 {
138 $portfolio = new ilObjPortfolio($id, false);
139 $portfolio->setTitle(ilUtil::stripSlashes($title));
140
141 if(is_array($_POST["online"]) && in_array($id, $_POST["online"]))
142 {
143 $portfolio->setOnline(true);
144 }
145 else
146 {
147 $portfolio->setOnline(false);
148 }
149
150 $portfolio->update();
151 }
152 }
153 }
154
155 ilUtil::sendSuccess($lng->txt("saved_successfully"), true);
156 $ilCtrl->redirect($this, "show");
157 }
158
159 protected function confirmPortfolioDeletion()
160 {
161 global $ilCtrl, $tpl, $lng;
162
163 if (!is_array($_POST["prtfs"]) || count($_POST["prtfs"]) == 0)
164 {
165 ilUtil::sendInfo($lng->txt("no_checkbox"), true);
166 $ilCtrl->redirect($this, "show");
167 }
168 else
169 {
170 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
171 $cgui = new ilConfirmationGUI();
172 $cgui->setFormAction($ilCtrl->getFormAction($this));
173 $cgui->setHeaderText($lng->txt("prtf_sure_delete_portfolios"));
174 $cgui->setCancel($lng->txt("cancel"), "show");
175 $cgui->setConfirm($lng->txt("delete"), "deletePortfolios");
176
177 foreach ($_POST["prtfs"] as $id)
178 {
179 $cgui->addItem("prtfs[]", $id, ilObjPortfolio::_lookupTitle($id));
180 }
181
182 $tpl->setContent($cgui->getHTML());
183 }
184 }
185
186 protected function deletePortfolios()
187 {
188 global $lng, $ilCtrl;
189
190 if (is_array($_POST["prtfs"]))
191 {
192 foreach ($_POST["prtfs"] as $id)
193 {
194 if($this->checkAccess("write", $id))
195 {
196 $portfolio = new ilObjPortfolio($id, false);
197 if ($portfolio->getOwner() == $this->user_id)
198 {
199 $this->access_handler->removePermission($id);
200 $portfolio->delete();
201 }
202 }
203 }
204 }
205 ilUtil::sendSuccess($lng->txt("prtf_portfolio_deleted"), true);
206 $ilCtrl->redirect($this, "show");
207 }
208
209
210 //
211 // DEFAULT PORTFOLIO (aka profile)
212 //
213
214 protected function unsetDefault()
215 {
216 global $ilCtrl, $lng, $ilUser;
217
218 if($this->checkAccess("write"))
219 {
220 // #12845
221 $ilUser->setPref("public_profile", "n");
222 $ilUser->writePrefs();
223
224 ilObjPortfolio::setUserDefault($this->user_id);
225 ilUtil::sendSuccess($lng->txt("prtf_unset_default_share_info"), true);
226 }
227 $ilCtrl->redirect($this, "show");
228 }
229
233 protected function setDefaultConfirmation()
234 {
235 global $ilCtrl, $lng, $tpl, $ilTabs, $ilSetting;
236
237 $prtf_id = (int)$_REQUEST["prt_id"];
238
239 if($prtf_id && $this->checkAccess("write"))
240 {
241 // if already shared, no need to ask again
242 if($this->access_handler->hasRegisteredPermission($prtf_id) ||
243 $this->access_handler->hasGlobalPermission($prtf_id))
244 {
245 return $this->setDefault($prtf_id);
246 }
247
248 $ilTabs->clearTargets();
249 $ilTabs->setBackTarget($lng->txt("cancel"),
250 $ilCtrl->getLinkTarget($this, "show"));
251
252 $ilCtrl->setParameter($this, "prt_id", $prtf_id);
253
254 // #20310
255 if(!$ilSetting->get("enable_global_profiles"))
256 {
257 $ilCtrl->redirect($this, "setDefaultRegistered");
258 }
259
260 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
261 $cgui = new ilConfirmationGUI();
262 $cgui->setFormAction($ilCtrl->getFormAction($this));
263 $cgui->setHeaderText($lng->txt("prtf_set_default_publish_confirmation"));
264 $cgui->setCancel($lng->txt("prtf_set_default_publish_global"), "setDefaultGlobal");
265 $cgui->setConfirm($lng->txt("prtf_set_default_publish_registered"), "setDefaultRegistered");
266 $tpl->setContent($cgui->getHTML());
267
268 return;
269 }
270
271 $ilCtrl->redirect($this, "show");
272 }
273
274 protected function setDefaultGlobal()
275 {
276 global $ilCtrl;
277
278 $prtf_id = (int)$_REQUEST["prt_id"];
279 if($prtf_id && $this->checkAccess("write"))
280 {
281 $this->access_handler->addPermission($prtf_id, ilWorkspaceAccessGUI::PERMISSION_ALL);
282 $this->setDefault($prtf_id);
283 }
284 $ilCtrl->redirect($this, "show");
285 }
286
287 protected function setDefaultRegistered()
288 {
289 global $ilCtrl;
290
291 $prtf_id = (int)$_REQUEST["prt_id"];
292 if($prtf_id && $this->checkAccess("write"))
293 {
294 $this->access_handler->addPermission($prtf_id, ilWorkspaceAccessGUI::PERMISSION_REGISTERED);
295 $this->setDefault($prtf_id);
296 }
297 $ilCtrl->redirect($this, "show");
298 }
299
300 protected function setDefault($a_prtf_id)
301 {
302 global $ilCtrl, $lng, $ilUser;
303
304 if($a_prtf_id && $this->checkAccess("write"))
305 {
306 // #12845
307 if($this->access_handler->hasGlobalPermission($a_prtf_id))
308 {
309 $ilUser->setPref("public_profile", "g");
310 $ilUser->writePrefs();
311 }
312 else if($this->access_handler->hasRegisteredPermission($a_prtf_id))
313 {
314 $ilUser->setPref("public_profile", "y");
315 $ilUser->writePrefs();
316 }
317 else
318 {
319 return;
320 }
321 ilObjPortfolio::setUserDefault($this->user_id, $a_prtf_id);
322 ilUtil::sendSuccess($lng->txt("settings_saved"), true);
323 }
324 $ilCtrl->redirect($this, "show");
325 }
326
327
328 //
329 // SHARE
330 //
331
332 protected function showOtherFilter()
333 {
334 $this->showOther(false);
335 }
336
337 protected function showOther($a_load_data = true)
338 {
339 global $tpl, $ilTabs;
340
341 $ilTabs->activateTab("otpf");
342
343 include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceShareTableGUI.php";
344 $tbl = new ilWorkspaceShareTableGUI($this, "showOther", $this->access_handler, null, $a_load_data);
345 $tpl->setContent($tbl->getHTML());
346 }
347
348 protected function applyShareFilter()
349 {
350 include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceShareTableGUI.php";
351 $tbl = new ilWorkspaceShareTableGUI($this, "showOther", $this->access_handler);
352 $tbl->resetOffset();
353 $tbl->writeFilterToSession();
354
355 $this->showOther();
356 }
357
358 protected function resetShareFilter()
359 {
360 include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceShareTableGUI.php";
361 $tbl = new ilWorkspaceShareTableGUI($this, "showOther", $this->access_handler);
362 $tbl->resetOffset();
363 $tbl->resetFilter();
364
365 $this->showOther();
366 }
367}
368
369?>
global $tpl
Definition: ilias.php:8
Confirmation screen class.
static getInstance()
Factory.
Portfolio view gui class.
static setUserDefault($a_user_id, $a_portfolio_id=null)
Set the user default portfolio.
static _lookupTitle($a_id)
lookup object title
Access handler for portfolio.
Portfolio repository gui class.
setDefaultConfirmation()
Confirm sharing when setting default.
checkAccess($a_permission, $a_portfolio_id=null)
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
Workspace share handler table GUI class.
$_POST['username']
Definition: cron.php:12
$tbl
Definition: example_048.php:81
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:40
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
global $ilUser
Definition: imgupload.php:15