ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilPersonalDesktopGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 include_once './Services/User/classes/class.ilObjUser.php';
6 include_once "Services/Mail/classes/class.ilMail.php";
7 include_once 'Services/Mail/classes/class.ilMailGlobalServices.php';
8 include_once 'Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php';
9 
25 {
26  var $tpl;
27  var $lng;
28  var $ilias;
29 
30  var $cmdClass = '';
31 
35  protected $action_menu;
36 
41  {
42  global $ilias, $tpl, $lng, $rbacsystem, $ilCtrl, $ilMainMenu, $ilUser, $tree;
43 
44 
45  $this->tpl =& $tpl;
46  $this->lng =& $lng;
47  $this->ilias =& $ilias;
48  $this->ctrl =& $ilCtrl;
49 
50  $ilCtrl->setContext($ilUser->getId(),
51  "user");
52 
53  $ilMainMenu->setActive("desktop");
54  $this->lng->loadLanguageModule("pdesk");
55  $this->lng->loadLanguageModule("pd"); // #16813
56 
57  // catch hack attempts
58  if ($_SESSION["AccountId"] == ANONYMOUS_USER_ID)
59  {
60  $this->ilias->raiseError($this->lng->txt("msg_not_available_for_anon"),$this->ilias->error_obj->MESSAGE);
61  }
62  $this->cmdClass = $_GET['cmdClass'];
63 
64  //$tree->useCache(false);
65 
66  $this->action_menu = new ilAdvancedSelectionListGUI();
67  }
68 
72  function &executeCommand()
73  {
74  global $ilSetting, $rbacsystem;
75 
76  $next_class = $this->ctrl->getNextClass();
77  $this->ctrl->setReturn($this, "show");
78 
79  $this->tpl->addCss(ilUtil::getStyleSheetLocation('filesystem','delos.css','Services/Calendar'));
80 
81  // read last active subsection
82  if (isset($_GET['PDHistory']) && $_GET['PDHistory'])
83  {
84  $next_class = $this->__loadNextClass();
85  }
86  $this->__storeLastClass($next_class);
87 
88 
89  // check for permission to view contacts
90  if (
91  $next_class == 'ilmailaddressbookgui' && ($this->ilias->getSetting("disable_contacts") ||
92  (
93  !$this->ilias->getSetting("disable_contacts_require_mail") &&
94  !$rbacsystem->checkAccess('internal_mail', ilMailGlobalServices::getMailObjectRefId())
95  ))
96  ) // if
97  {
98  $next_class = '';
99  ilUtil::sendFailure($this->lng->txt('no_permission'));
100  }
101 
102  switch($next_class)
103  {
104  case "ilbookmarkadministrationgui":
105  if ($ilSetting->get('disable_bookmarks'))
106  {
107  ilUtil::sendFailure($this->lng->txt('permission_denied'), true);
108  ilUtil::redirect('ilias.php?baseClass=ilPersonalDesktopGUI');
109  return;
110  }
111  include_once("./Services/Bookmarks/classes/class.ilBookmarkAdministrationGUI.php");
112  $bookmark_gui = new ilBookmarkAdministrationGUI();
113  if ($bookmark_gui->getMode() == 'tree') {
114  $this->getTreeModeTemplates();
115  } else {
116  $this->getStandardTemplates();
117  }
118  $this->setTabs();
119  $ret =& $this->ctrl->forwardCommand($bookmark_gui);
120  break;
121 
122  // profile
123  case "ilpersonalprofilegui":
124  $this->getStandardTemplates();
125  $this->setTabs();
126  include_once("./Services/User/classes/class.ilPersonalProfileGUI.php");
127  $profile_gui = new ilPersonalProfileGUI();
128  $ret =& $this->ctrl->forwardCommand($profile_gui);
129  break;
130 
131  // settings
132  case "ilpersonalsettingsgui":
133  $this->getStandardTemplates();
134  $this->setTabs();
135  include_once("./Services/User/classes/class.ilPersonalSettingsGUI.php");
136  $settings_gui = new ilPersonalSettingsGUI();
137  $ret =& $this->ctrl->forwardCommand($settings_gui);
138  break;
139 
140  // profile
141  case "ilobjusergui":
142  include_once('./Services/User/classes/class.ilObjUserGUI.php');
143  $user_gui = new ilObjUserGUI("",$_GET["user"], false, false);
144  $ret =& $this->ctrl->forwardCommand($user_gui);
145  break;
146 
147  case 'ilcalendarpresentationgui':
148  $this->getStandardTemplates();
149  $this->displayHeader();
150  $this->tpl->setTitle($this->lng->txt("calendar"));
151  $this->setTabs();
152  include_once('./Services/Calendar/classes/class.ilCalendarPresentationGUI.php');
153  $cal = new ilCalendarPresentationGUI();
154  $ret = $this->ctrl->forwardCommand($cal);
155  $this->tpl->show();
156  break;
157 
158  // pd notes
159  case "ilpdnotesgui":
160  if ($ilSetting->get('disable_notes'))
161  {
162  ilUtil::sendFailure($this->lng->txt('permission_denied'), true);
163  ilUtil::redirect('ilias.php?baseClass=ilPersonalDesktopGUI');
164  return;
165  }
166 
167  $this->getStandardTemplates();
168  $this->setTabs();
169  include_once("./Services/Notes/classes/class.ilPDNotesGUI.php");
170  $pd_notes_gui = new ilPDNotesGUI();
171  $ret =& $this->ctrl->forwardCommand($pd_notes_gui);
172  break;
173 
174  // pd news
175  case "ilpdnewsgui":
176  $this->getStandardTemplates();
177  $this->setTabs();
178  include_once("./Services/News/classes/class.ilPDNewsGUI.php");
179  $pd_news_gui = new ilPDNewsGUI();
180  $ret =& $this->ctrl->forwardCommand($pd_news_gui);
181  break;
182 
183  case "illearningprogressgui":
184  $this->getStandardTemplates();
185  $this->setTabs();
186  include_once './Services/Tracking/classes/class.ilLearningProgressGUI.php';
188  $ret =& $this->ctrl->forwardCommand($new_gui);
189 
190  break;
191 
192  case "ilcolumngui":
193  $this->getStandardTemplates();
194  $this->setTabs();
195  include_once("./Services/Block/classes/class.ilColumnGUI.php");
196  $column_gui = new ilColumnGUI("pd");
197  $this->initColumn($column_gui);
198  $this->show();
199  break;
200 
201  // contacts
202  case 'ilmailaddressbookgui':
203  $this->getStandardTemplates();
204  $this->setTabs();
205  $this->tpl->setTitle($this->lng->txt("mail_addressbook"));
206 
207  include_once 'Services/Contact/classes/class.ilMailAddressbookGUI.php';
208  $mailgui = new ilMailAddressbookGUI();
209  $ret = $this->ctrl->forwardCommand($mailgui);
210  break;
211 
212  case 'ilpersonalworkspacegui':
213  $this->getStandardTemplates();
214  $this->setTabs();
215  include_once 'Services/PersonalWorkspace/classes/class.ilPersonalWorkspaceGUI.php';
216  $wsgui = new ilPersonalWorkspaceGUI();
217  $ret = $this->ctrl->forwardCommand($wsgui);
218  $this->tpl->show();
219  break;
220 
221  case 'ilportfoliorepositorygui':
222  $this->getStandardTemplates();
223  $this->setTabs();
224  include_once 'Modules/Portfolio/classes/class.ilPortfolioRepositoryGUI.php';
225  $pfgui = new ilPortfolioRepositoryGUI();
226  $ret = $this->ctrl->forwardCommand($pfgui);
227  $this->tpl->show();
228  break;
229 
230  case 'ilpersonalskillsgui':
231  $this->setTabs();
232  include_once './Services/Skill/classes/class.ilPersonalSkillsGUI.php';
233  $skgui = new ilPersonalSkillsGUI();
234  $this->getStandardTemplates();
235  $ret = $this->ctrl->forwardCommand($skgui);
236  $this->tpl->show();
237  break;
238 
239  case 'redirect':
240  $this->redirect();
241  break;
242 
243  default:
244  $this->getStandardTemplates();
245  $this->setTabs();
246  $cmd = $this->ctrl->getCmd("show");
247  $this->$cmd();
248  break;
249  }
250  $ret = null;
251  return $ret;
252  }
253 
257  public function redirect()
258  {
259  if(is_array($_GET))
260  {
261  foreach($_GET as $key => $val)
262  {
263  if(substr($key, 0, strlen('param_')) == 'param_')
264  {
265  $this->ctrl->setParameterByClass($_GET['redirectClass'], substr($key, strlen('param_')), $val);
266  }
267  }
268  }
269  ilUtil::redirect($this->ctrl->getLinkTargetByClass($_GET['redirectClass'], $_GET['redirectCmd'], '', true));
270  }
271 
276  {
277  $this->tpl->getStandardTemplate();
278  // add template for content
279 // $this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
280 // $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
281  }
282 
287  {
288  // add template for content
289  $this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
290  $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
291  }
292 
296  function show()
297  {
298 
299  // preload block settings
300  include_once("Services/Block/classes/class.ilBlockSetting.php");
302 
303  // add template for content
304  $this->pd_tpl = new ilTemplate("tpl.usr_personaldesktop.html", true, true, "Services/PersonalDesktop");
305  $this->tpl->getStandardTemplate();
306 
307  // display infopanel if something happened
309 
310  $this->tpl->setTitle($this->lng->txt("overview"));
311  $this->tpl->setVariable("IMG_SPACE", ilUtil::getImagePath("spacer.png", false));
312 
313  $this->tpl->setContent($this->getCenterColumnHTML());
314  $this->tpl->setRightContent($this->getRightColumnHTML());
315  $this->tpl->setLeftContent($this->getLeftColumnHTML());
316 
317  if(count($this->action_menu->getItems()))
318  {
323  global $tpl, $lng;
324 
325  $this->action_menu->setAsynch(false);
326  $this->action_menu->setAsynchUrl('');
327  $this->action_menu->setListTitle($lng->txt('actions'));
328  $this->action_menu->setId('act_pd');
329  $this->action_menu->setSelectionHeaderClass('small');
330  $this->action_menu->setItemLinkClass('xsmall');
331  $this->action_menu->setLinksMode('il_ContainerItemCommand2');
332  $this->action_menu->setHeaderIcon(ilAdvancedSelectionListGUI::DOWN_ARROW_DARK);
333  $this->action_menu->setUseImages(false);
334 
335  $htpl = new ilTemplate('tpl.header_action.html', true, true, 'Services/Repository');
336  $htpl->setVariable('ACTION_DROP_DOWN', $this->action_menu->getHTML());
337 
338  $tpl->setHeaderActionMenu($htpl->get());
339  }
340 
341  $this->tpl->show();
342  }
343 
344 
349  {
350  global $ilCtrl, $ilPluginAdmin;
351 
352  include_once("Services/Block/classes/class.ilColumnGUI.php");
353  $column_gui = new ilColumnGUI("pd", IL_COL_CENTER);
354  $this->initColumn($column_gui);
355 
356  if ($ilCtrl->getNextClass() == "ilcolumngui" &&
357  $column_gui->getCmdSide() == IL_COL_CENTER)
358  {
359  $html = $ilCtrl->forwardCommand($column_gui);
360  }
361  else
362  {
363  if (!$ilCtrl->isAsynch())
364  {
365  if ($column_gui->getScreenMode() != IL_SCREEN_SIDE)
366  {
367  // right column wants center
368  if ($column_gui->getCmdSide() == IL_COL_RIGHT)
369  {
370  $column_gui = new ilColumnGUI("pd", IL_COL_RIGHT);
371  $this->initColumn($column_gui);
372  $html = $ilCtrl->forwardCommand($column_gui);
373  }
374  // left column wants center
375  if ($column_gui->getCmdSide() == IL_COL_LEFT)
376  {
377  $column_gui = new ilColumnGUI("pd", IL_COL_LEFT);
378  $this->initColumn($column_gui);
379  $html = $ilCtrl->forwardCommand($column_gui);
380  }
381  }
382  else
383  {
384  $html = "";
385 
386  // user interface plugin slot + default rendering
387  include_once("./Services/UIComponent/classes/class.ilUIHookProcessor.php");
388  $uip = new ilUIHookProcessor("Services/PersonalDesktop", "center_column",
389  array("personal_desktop_gui" => $this));
390  if (!$uip->replaced())
391  {
392  $html = $ilCtrl->getHTML($column_gui);
393  }
394  $html = $uip->getHTML($html);
395 
396  }
397  }
398  }
399  return $html;
400  }
401 
406  {
407  global $ilUser, $lng, $ilCtrl, $ilPluginAdmin;
408 
409  include_once("Services/Block/classes/class.ilColumnGUI.php");
410  $column_gui = new ilColumnGUI("pd", IL_COL_RIGHT);
411  $this->initColumn($column_gui);
412 
413  if ($column_gui->getScreenMode() == IL_SCREEN_FULL)
414  {
415  return "";
416  }
417 
418  if ($ilCtrl->getNextClass() == "ilcolumngui" &&
419  $column_gui->getCmdSide() == IL_COL_RIGHT &&
420  $column_gui->getScreenMode() == IL_SCREEN_SIDE)
421  {
422  $html = $ilCtrl->forwardCommand($column_gui);
423  }
424  else
425  {
426  if (!$ilCtrl->isAsynch())
427  {
428  $html = "";
429 
430  // user interface plugin slot + default rendering
431  include_once("./Services/UIComponent/classes/class.ilUIHookProcessor.php");
432  $uip = new ilUIHookProcessor("Services/PersonalDesktop", "right_column",
433  array("personal_desktop_gui" => $this));
434  if (!$uip->replaced())
435  {
436  $html = $ilCtrl->getHTML($column_gui);
437  }
438  $html = $uip->getHTML($html);
439  }
440  }
441 
442  return $html;
443  }
444 
448  function getLeftColumnHTML()
449  {
450  global $ilUser, $lng, $ilCtrl, $ilPluginAdmin;
451 
452  include_once("Services/Block/classes/class.ilColumnGUI.php");
453  $column_gui = new ilColumnGUI("pd", IL_COL_LEFT);
454  $this->initColumn($column_gui);
455 
456  if ($column_gui->getScreenMode() == IL_SCREEN_FULL)
457  {
458  return "";
459  }
460 
461  if ($ilCtrl->getNextClass() == "ilcolumngui" &&
462  $column_gui->getCmdSide() == IL_COL_LEFT &&
463  $column_gui->getScreenMode() == IL_SCREEN_SIDE)
464  {
465  $html = $ilCtrl->forwardCommand($column_gui);
466  }
467  else
468  {
469  if (!$ilCtrl->isAsynch())
470  {
471  $html = "";
472 
473  // user interface plugin slot + default rendering
474  include_once("./Services/UIComponent/classes/class.ilUIHookProcessor.php");
475  $uip = new ilUIHookProcessor("Services/PersonalDesktop", "left_column",
476  array("personal_desktop_gui" => $this));
477  if (!$uip->replaced())
478  {
479  $html = $ilCtrl->getHTML($column_gui);
480  }
481  $html = $uip->getHTML($html);
482  }
483  }
484 
485  return $html;
486  }
487 
489  {
490  // add template for content
491  $this->pd_tpl = new ilTemplate("tpl.usr_personaldesktop.html", true, true, "Services/PersonalDesktop");
492  $this->tpl->getStandardTemplate();
493 
494  // display infopanel if something happened
496 
497  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd.svg"));
498  $this->tpl->setTitle($this->lng->txt("personal_desktop"));
499  $this->tpl->setVariable("IMG_SPACE", ilUtil::getImagePath("spacer.png", false));
500  }
501 
502 
506  function removeMember()
507  {
508  global $err_msg;
509  if (strlen($err_msg) > 0)
510  {
511  $this->ilias->raiseError($this->lng->txt($err_msg),$this->ilias->error_obj->MESSAGE);
512  }
513  $this->show();
514  }
515 
520  {
521  include_once("Services/Mail/classes/class.ilPDSysMessageBlockGUI.php");
522  $sys_block = new ilPDSysMessageBlockGUI("ilpersonaldesktopgui", "show");
523  return $sys_block->getHTML();
524  }
525 
536  function multiarray_sort ($array, $key_sort)
537  {
538  if ($array) {
539  $key_sorta = explode(";", $key_sort);
540 
541  $multikeys = array_keys($array);
542  $keys = array_keys($array[$multikeys[0]]);
543 
544  for($m=0; $m < count($key_sorta); $m++) {
545  $nkeys[$m] = trim($key_sorta[$m]);
546  }
547  $n += count($key_sorta);
548 
549  for($i=0; $i < count($keys); $i++){
550  if(!in_array($keys[$i], $key_sorta)) {
551  $nkeys[$n] = $keys[$i];
552  $n += "1";
553  }
554  }
555 
556  for($u=0;$u<count($array); $u++) {
557  $arr = $array[$multikeys[$u]];
558  for($s=0; $s<count($nkeys); $s++) {
559  $k = $nkeys[$s];
560  $output[$multikeys[$u]][$k] = $array[$multikeys[$u]][$k];
561  }
562  }
563  sort($output);
564  return $output;
565  }
566  }
567 
571  function setTabs()
572  {
573  global $ilHelp;
574 
575  $ilHelp->setScreenIdComponent("pd");
576  }
577 
581  public function jumpToMemberships()
582  {
586  global $ilSetting;
587 
588  if(!$ilSetting->get('disable_my_memberships'))
589  {
590  require_once 'Services/PersonalDesktop/classes/class.ilPDSelectedItemsBlockGUI.php';
592  }
593 
594  $this->show();
595  }
596 
600  public function jumpToSelectedItems()
601  {
605  global $ilSetting;
606 
607  if(!$ilSetting->get('disable_my_offers'))
608  {
609  require_once 'Services/PersonalDesktop/classes/class.ilPDSelectedItemsBlockGUI.php';
611  }
612 
613  $this->show();
614  }
615 
616 
620  function jumpToProfile()
621  {
622  $this->ctrl->redirectByClass("ilpersonalprofilegui");
623  }
624 
625  function jumpToPortfolio()
626  {
627  // incoming back link from shared resource
628  $cmd = "";
629  if($_REQUEST["dsh"])
630  {
631  $this->ctrl->setParameterByClass("ilportfoliorepositorygui", "shr_id", $_REQUEST["dsh"]);
632  $cmd = "showOther";
633  }
634 
635  // used for goto links
636  if($_GET["prt_id"])
637  {
638  $this->ctrl->setParameterByClass("ilobjportfoliogui", "prt_id", (int)$_GET["prt_id"]);
639  $this->ctrl->setParameterByClass("ilobjportfoliogui", "gtp", (int)$_GET["gtp"]);
640  $this->ctrl->redirectByClass(array("ilportfoliorepositorygui", "ilobjportfoliogui"), "preview");
641  }
642  else
643  {
644  $this->ctrl->redirectByClass("ilportfoliorepositorygui", $cmd);
645  }
646  }
647 
651  function jumpToSettings()
652  {
653  $this->ctrl->redirectByClass("ilpersonalsettingsgui");
654  }
655 
659  function jumpToBookmarks()
660  {
661  if ($this->ilias->getSetting("disable_bookmarks"))
662  {
663  ilUtil::sendFailure($this->lng->txt('permission_denied'), true);
664  ilUtil::redirect('ilias.php?baseClass=ilPersonalDesktopGUI');
665  return;
666  }
667 
668  $this->ctrl->redirectByClass("ilbookmarkadministrationgui");
669  }
670 
674  function jumpToNotes()
675  {
676  if ($this->ilias->getSetting('disable_notes'))
677  {
678  ilUtil::sendFailure($this->lng->txt('permission_denied'), true);
679  ilUtil::redirect('ilias.php?baseClass=ilPersonalDesktopGUI');
680  return;
681  }
682 
683  $this->ctrl->redirectByClass("ilpdnotesgui");
684  }
685 
689  function jumpToNews()
690  {
691  $this->ctrl->redirectByClass("ilpdnewsgui");
692  }
693 
697  function jumpToLP()
698  {
699  $this->ctrl->redirectByClass("illearningprogressgui");
700  }
701 
705  function jumpToCalendar()
706  {
707  $this->ctrl->redirectByClass("ilcalendarpresentationgui");
708  }
709 
713  function jumpToContacts()
714  {
715  $this->ctrl->redirectByClass("ilmailaddressbookgui");
716  }
717 
721  function jumpToWorkspace()
722  {
723  // incoming back link from shared resource
724  $cmd = "";
725  if($_REQUEST["dsh"])
726  {
727  $this->ctrl->setParameterByClass("ilpersonalworkspacegui", "shr_id", $_REQUEST["dsh"]);
728  $cmd = "share";
729  }
730 
731  if($_REQUEST["wsp_id"])
732  {
733  $this->ctrl->setParameterByClass("ilpersonalworkspacegui", "wsp_id", (int)$_REQUEST["wsp_id"]);
734  }
735 
736  if($_REQUEST["gtp"])
737  {
738  $this->ctrl->setParameterByClass("ilpersonalworkspacegui", "gtp", (int)$_REQUEST["gtp"]);
739  }
740 
741  $this->ctrl->redirectByClass("ilpersonalworkspacegui", $cmd);
742  }
743 
747  function jumpToSkills()
748  {
749  $this->ctrl->redirectByClass("ilpersonalskillsgui");
750  }
751 
752  function __loadNextClass()
753  {
754  $stored_classes = array('ilpersonaldesktopgui',
755  'ilpersonalprofilegui',
756  'ilpdnotesgui',
757  'ilcalendarpresentationgui',
758  'ilbookmarkadministrationgui',
759  'illearningprogressgui');
760 
761  if(isset($_SESSION['il_pd_history']) and in_array($_SESSION['il_pd_history'],$stored_classes))
762  {
763  return $_SESSION['il_pd_history'];
764  }
765  else
766  {
767  $this->ctrl->getNextClass($this);
768  }
769  }
770  function __storeLastClass($a_class)
771  {
772  $_SESSION['il_pd_history'] = $a_class;
773  $this->cmdClass = $a_class;
774  }
775 
780  function initColumn($a_column_gui)
781  {
782  $pd_set = new ilSetting("pd");
783  if ($pd_set->get("enable_block_moving"))
784  {
785  $a_column_gui->setEnableMovement(true);
786  }
787  $a_column_gui->setActionMenu($this->action_menu);
788  }
789 
793  function displayHeader()
794  {
795  $this->tpl->setTitle($this->lng->txt("personal_desktop"));
796  }
797 
798 
799 }
800 ?>