ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 
4 include_once('./Modules/Portfolio/classes/class.ilObjPortfolio.php');
5 
17 {
21  protected $lng;
22 
26  protected $user;
27 
31  protected $ctrl;
32 
36  protected $tpl;
37 
41  protected $tabs;
42 
46  protected $help;
47 
51  protected $locator;
52 
56  protected $toolbar;
57 
61  protected $settings;
62 
63  protected $user_id; // [int]
64  protected $access_handler; // [ilPortfolioAccessHandler]
65 
66  public function __construct()
67  {
68  global $DIC;
69 
70  $this->lng = $DIC->language();
71  $this->user = $DIC->user();
72  $this->ctrl = $DIC->ctrl();
73  $this->tpl = $DIC["tpl"];
74  $this->tabs = $DIC->tabs();
75  $this->help = $DIC["ilHelp"];
76  $this->locator = $DIC["ilLocator"];
77  $this->toolbar = $DIC->toolbar();
78  $this->settings = $DIC->settings();
79  $lng = $DIC->language();
80  $ilUser = $DIC->user();
81 
82  $lng->loadLanguageModule("prtf");
83  $lng->loadLanguageModule("user");
84 
85  include_once('./Modules/Portfolio/classes/class.ilPortfolioAccessHandler.php');
86  $this->access_handler = new ilPortfolioAccessHandler();
87 
88  $this->user_id = $ilUser->getId();
89  }
90 
91  public function executeCommand()
92  {
94  $lng = $this->lng;
95  $tpl = $this->tpl;
96  $ilTabs = $this->tabs;
97 
98  $next_class = $ilCtrl->getNextClass($this);
99  $cmd = $ilCtrl->getCmd("show");
100 
101  $tpl->setTitle($lng->txt("portfolio"));
102  $tpl->setTitleIcon(
103  ilUtil::getImagePath("icon_prtf.svg"),
104  $lng->txt("portfolio")
105  );
106 
107  switch ($next_class) {
108  case "ilobjportfoliogui":
109 
110  include_once('./Modules/Portfolio/classes/class.ilObjPortfolioGUI.php');
111  $gui = new ilObjPortfolioGUI((int) $_REQUEST["prt_id"]);
112 
113  if ($cmd != "preview") {
114  $this->setLocator();
115 
116  if ((int) $_GET["exc_back_ref_id"] > 0) {
117  include_once("./Services/Link/classes/class.ilLink.php");
118  $ilTabs->setBack2Target($lng->txt("obj_exc"), ilLink::_getLink((int) $_GET["exc_back_ref_id"]));
119  } else {
120  $ilTabs->setBack2Target($lng->txt("prtf_tab_portfolios"), $ilCtrl->getLinkTarget($this, "show"));
121  }
122  }
123 
124  $ilCtrl->forwardCommand($gui);
125  break;
126 
127  default:
128  $this->setLocator();
129  $this->setTabs();
130  $this->$cmd();
131  break;
132  }
133 
134  return true;
135  }
136 
137  public function setTabs()
138  {
139  $ilTabs = $this->tabs;
140  $lng = $this->lng;
142  $ilHelp = $this->help;
143 
144  $ilHelp->setScreenIdComponent("prtf");
145 
146  $ilTabs->addTab(
147  "mypf",
148  $lng->txt("prtf_tab_portfolios"),
149  $ilCtrl->getLinkTarget($this)
150  );
151 
152  $ilTabs->addTab(
153  "otpf",
154  $lng->txt("prtf_tab_other_users"),
155  $ilCtrl->getLinkTarget($this, "showotherFilter")
156  );
157 
158  $ilTabs->activateTab("mypf");
159  }
160 
161  protected function setLocator()
162  {
163  $ilLocator = $this->locator;
164  $lng = $this->lng;
166  $tpl = $this->tpl;
167 
168  $ilLocator->addItem(
169  $lng->txt("portfolio"),
170  $ilCtrl->getLinkTarget($this, "show")
171  );
172 
173  $tpl->setLocator();
174  }
175 
176  protected function checkAccess($a_permission, $a_portfolio_id = null)
177  {
178  if ($a_portfolio_id) {
179  return $this->access_handler->checkAccess($a_permission, "", $a_portfolio_id);
180  }
181  // currently only object-based permissions
182  return true;
183  }
184 
185 
186  //
187  // LIST INCL. ACTIONS
188  //
189 
190  protected function show()
191  {
192  $tpl = $this->tpl;
193  $lng = $this->lng;
194  $ilToolbar = $this->toolbar;
196 
197  include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
198  $button = ilLinkButton::getInstance();
199  $button->setCaption("prtf_add_portfolio");
200  $button->setUrl($ilCtrl->getLinkTargetByClass("ilObjPortfolioGUI", "create"));
201  $ilToolbar->addButtonInstance($button);
202 
203  include_once "Modules/Portfolio/classes/class.ilPortfolioTableGUI.php";
204  $table = new ilPortfolioTableGUI($this, "show", $this->user_id);
205 
206  include_once "Services/DiskQuota/classes/class.ilDiskQuotaHandler.php";
207 
208  $tpl->setContent($table->getHTML() . ilDiskQuotaHandler::getStatusLegend());
209  }
210 
211  protected function saveTitles()
212  {
214  $lng = $this->lng;
215 
216  foreach ($_POST["title"] as $id => $title) {
217  if (trim($title)) {
218  if ($this->checkAccess("write", $id)) {
219  $portfolio = new ilObjPortfolio($id, false);
220  $portfolio->setTitle(ilUtil::stripSlashes($title));
221 
222  if (is_array($_POST["online"]) && in_array($id, $_POST["online"])) {
223  $portfolio->setOnline(true);
224  } else {
225  $portfolio->setOnline(false);
226  }
227 
228  $portfolio->update();
229  }
230  }
231  }
232 
233  ilUtil::sendSuccess($lng->txt("saved_successfully"), true);
234  $ilCtrl->redirect($this, "show");
235  }
236 
237  protected function confirmPortfolioDeletion()
238  {
240  $tpl = $this->tpl;
241  $lng = $this->lng;
242 
243  if (!is_array($_POST["prtfs"]) || count($_POST["prtfs"]) == 0) {
244  ilUtil::sendInfo($lng->txt("no_checkbox"), true);
245  $ilCtrl->redirect($this, "show");
246  } else {
247  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
248  $cgui = new ilConfirmationGUI();
249  $cgui->setFormAction($ilCtrl->getFormAction($this));
250  $cgui->setHeaderText($lng->txt("prtf_sure_delete_portfolios"));
251  $cgui->setCancel($lng->txt("cancel"), "show");
252  $cgui->setConfirm($lng->txt("delete"), "deletePortfolios");
253 
254  foreach ($_POST["prtfs"] as $id) {
255  $cgui->addItem("prtfs[]", $id, ilObjPortfolio::_lookupTitle($id));
256  }
257 
258  $tpl->setContent($cgui->getHTML());
259  }
260  }
261 
262  protected function deletePortfolios()
263  {
264  $lng = $this->lng;
266 
267  if (is_array($_POST["prtfs"])) {
268  foreach ($_POST["prtfs"] as $id) {
269  if ($this->checkAccess("write", $id)) {
270  $portfolio = new ilObjPortfolio($id, false);
271  if ($portfolio->getOwner() == $this->user_id) {
272  $this->access_handler->removePermission($id);
273  $portfolio->delete();
274  }
275  }
276  }
277  }
278  ilUtil::sendSuccess($lng->txt("prtf_portfolio_deleted"), true);
279  $ilCtrl->redirect($this, "show");
280  }
281 
282 
283  //
284  // DEFAULT PORTFOLIO (aka profile)
285  //
286 
287  protected function unsetDefault()
288  {
290  $lng = $this->lng;
292 
293  if ($this->checkAccess("write")) {
294  // #12845
295  $ilUser->setPref("public_profile", "n");
296  $ilUser->writePrefs();
297 
298  ilObjPortfolio::setUserDefault($this->user_id);
299  ilUtil::sendSuccess($lng->txt("prtf_unset_default_share_info"), true);
300  }
301  $ilCtrl->redirect($this, "show");
302  }
303 
307  protected function setDefaultConfirmation()
308  {
310  $lng = $this->lng;
311  $tpl = $this->tpl;
312  $ilTabs = $this->tabs;
314 
315  $prtf_id = (int) $_REQUEST["prt_id"];
316 
317  if ($prtf_id && $this->checkAccess("write")) {
318  // if already shared, no need to ask again
319  if ($this->access_handler->hasRegisteredPermission($prtf_id) ||
320  $this->access_handler->hasGlobalPermission($prtf_id)) {
321  return $this->setDefault($prtf_id);
322  }
323 
324  $ilTabs->clearTargets();
325  $ilTabs->setBackTarget(
326  $lng->txt("cancel"),
327  $ilCtrl->getLinkTarget($this, "show")
328  );
329 
330  $ilCtrl->setParameter($this, "prt_id", $prtf_id);
331 
332  // #20310
333  if (!$ilSetting->get("enable_global_profiles")) {
334  $ilCtrl->redirect($this, "setDefaultRegistered");
335  }
336 
337  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
338  $cgui = new ilConfirmationGUI();
339  $cgui->setFormAction($ilCtrl->getFormAction($this));
340  $cgui->setHeaderText($lng->txt("prtf_set_default_publish_confirmation"));
341  $cgui->setCancel($lng->txt("prtf_set_default_publish_global"), "setDefaultGlobal");
342  $cgui->setConfirm($lng->txt("prtf_set_default_publish_registered"), "setDefaultRegistered");
343  $tpl->setContent($cgui->getHTML());
344 
345  return;
346  }
347 
348  $ilCtrl->redirect($this, "show");
349  }
350 
351  protected function setDefaultGlobal()
352  {
354 
355  $prtf_id = (int) $_REQUEST["prt_id"];
356  if ($prtf_id && $this->checkAccess("write")) {
357  $this->access_handler->addPermission($prtf_id, ilWorkspaceAccessGUI::PERMISSION_ALL);
358  $this->setDefault($prtf_id);
359  }
360  $ilCtrl->redirect($this, "show");
361  }
362 
363  protected function setDefaultRegistered()
364  {
366 
367  $prtf_id = (int) $_REQUEST["prt_id"];
368  if ($prtf_id && $this->checkAccess("write")) {
369  $this->access_handler->addPermission($prtf_id, ilWorkspaceAccessGUI::PERMISSION_REGISTERED);
370  $this->setDefault($prtf_id);
371  }
372  $ilCtrl->redirect($this, "show");
373  }
374 
375  protected function setDefault($a_prtf_id)
376  {
378  $lng = $this->lng;
380 
381  if ($a_prtf_id && $this->checkAccess("write")) {
382  // #12845
383  if ($this->access_handler->hasGlobalPermission($a_prtf_id)) {
384  $ilUser->setPref("public_profile", "g");
385  $ilUser->writePrefs();
386  } elseif ($this->access_handler->hasRegisteredPermission($a_prtf_id)) {
387  $ilUser->setPref("public_profile", "y");
388  $ilUser->writePrefs();
389  } else {
390  return;
391  }
392  ilObjPortfolio::setUserDefault($this->user_id, $a_prtf_id);
393  ilUtil::sendSuccess($lng->txt("settings_saved"), true);
394  }
395  $ilCtrl->redirect($this, "show");
396  }
397 
398 
399  //
400  // SHARE
401  //
402 
403  protected function showOtherFilter()
404  {
405  $this->showOther(false);
406  }
407 
408  protected function showOther($a_load_data = true)
409  {
410  $tpl = $this->tpl;
411  $ilTabs = $this->tabs;
412 
413  $ilTabs->activateTab("otpf");
414 
415  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceShareTableGUI.php";
416  $tbl = new ilWorkspaceShareTableGUI($this, "showOther", $this->access_handler, null, $a_load_data);
417  $tpl->setContent($tbl->getHTML());
418  }
419 
420  protected function applyShareFilter()
421  {
422  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceShareTableGUI.php";
423  $tbl = new ilWorkspaceShareTableGUI($this, "showOther", $this->access_handler);
424  $tbl->resetOffset();
425  $tbl->writeFilterToSession();
426 
427  $this->showOther();
428  }
429 
430  protected function resetShareFilter()
431  {
432  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceShareTableGUI.php";
433  $tbl = new ilWorkspaceShareTableGUI($this, "showOther", $this->access_handler);
434  $tbl->resetOffset();
435  $tbl->resetFilter();
436 
437  $this->showOther();
438  }
439 }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
checkAccess($a_permission, $a_portfolio_id=null)
static _lookupTitle($a_id)
global $DIC
Definition: saml.php:7
$_GET["client_id"]
$tbl
Definition: example_048.php:81
if(!array_key_exists('StateId', $_REQUEST)) $id
Portfolio repository gui class.
user()
Definition: user.php:4
global $ilCtrl
Definition: ilias.php:18
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
Workspace share handler table GUI class.
Portfolio view gui class.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static setUserDefault($a_user_id, $a_portfolio_id=null)
Set the user default portfolio.
$ilUser
Definition: imgupload.php:18
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
settings()
Definition: settings.php:2
global $ilSetting
Definition: privfeed.php:17
Access handler for portfolio.
if(empty($password)) $table
Definition: pwgen.php:24
$_POST["username"]
Confirmation screen class.
setDefaultConfirmation()
Confirm sharing when setting default.