ILIAS  release_4-3 Revision
 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 
56  // catch hack attempts
57  if ($_SESSION["AccountId"] == ANONYMOUS_USER_ID)
58  {
59  $this->ilias->raiseError($this->lng->txt("msg_not_available_for_anon"),$this->ilias->error_obj->MESSAGE);
60  }
61  $this->cmdClass = $_GET['cmdClass'];
62 
63  //$tree->useCache(false);
64 
65  $this->action_menu = new ilAdvancedSelectionListGUI();
66  }
67 
71  function &executeCommand()
72  {
73  global $ilUser, $ilSetting, $rbacsystem;
74 
75  $next_class = $this->ctrl->getNextClass();
76  $this->ctrl->setReturn($this, "show");
77 
78  $this->tpl->addCss(ilUtil::getStyleSheetLocation('filesystem','delos.css','Services/Calendar'));
79 
80 
81  // check whether password of user have to be changed
82  // due to first login or password of user is expired
83  if( ($ilUser->isPasswordChangeDemanded() || $ilUser->isPasswordExpired())
84  && $next_class != "ilpersonalsettingsgui"
85  )
86  {
87  $this->ctrl->redirectByClass("ilpersonalsettingsgui");
88  }
89 
90  // check whether personal profile of user is incomplete
91  if ($ilUser->getProfileIncomplete() && $next_class != "ilpersonalprofilegui" && !($ilUser->isPasswordChangeDemanded() || $ilUser->isPasswordExpired()))
92  {
93  $this->ctrl->redirectByClass("ilpersonalprofilegui");
94  }
95 
96 
97  // read last active subsection
98  if (isset($_GET['PDHistory']) && $_GET['PDHistory'])
99  {
100  $next_class = $this->__loadNextClass();
101  }
102  $this->__storeLastClass($next_class);
103 
104 
105  // check for permission to view contacts
106  if (
107  $next_class == 'ilmailaddressbookgui' && ($this->ilias->getSetting("disable_contacts") ||
108  (
109  !$this->ilias->getSetting("disable_contacts_require_mail") &&
110  !$rbacsystem->checkAccess('internal_mail', ilMailGlobalServices::getMailObjectRefId())
111  ))
112  ) // if
113  {
114  $next_class = '';
115  ilUtil::sendFailure($this->lng->txt('no_permission'));
116  }
117 
118  switch($next_class)
119  {
120  case "ilbookmarkadministrationgui":
121  if ($ilSetting->get('disable_bookmarks'))
122  {
123  ilUtil::sendFailure($this->lng->txt('permission_denied'), true);
124  ilUtil::redirect('ilias.php?baseClass=ilPersonalDesktopGUI');
125  return;
126  }
127  include_once("./Services/Bookmarks/classes/class.ilBookmarkAdministrationGUI.php");
128  $bookmark_gui = new ilBookmarkAdministrationGUI();
129  if ($bookmark_gui->getMode() == 'tree') {
130  $this->getTreeModeTemplates();
131  } else {
132  $this->getStandardTemplates();
133  }
134  $this->setTabs();
135  $ret =& $this->ctrl->forwardCommand($bookmark_gui);
136  break;
137 
138  // profile
139  case "ilpersonalprofilegui":
140  $this->getStandardTemplates();
141  $this->setTabs();
142  include_once("./Services/User/classes/class.ilPersonalProfileGUI.php");
143  $profile_gui = new ilPersonalProfileGUI();
144  $ret =& $this->ctrl->forwardCommand($profile_gui);
145  break;
146 
147  // settings
148  case "ilpersonalsettingsgui":
149  $this->getStandardTemplates();
150  $this->setTabs();
151  include_once("./Services/User/classes/class.ilPersonalSettingsGUI.php");
152  $settings_gui = new ilPersonalSettingsGUI();
153  $ret =& $this->ctrl->forwardCommand($settings_gui);
154  break;
155 
156  // profile
157  case "ilobjusergui":
158  include_once('./Services/User/classes/class.ilObjUserGUI.php');
159  $user_gui = new ilObjUserGUI("",$_GET["user"], false, false);
160  $ret =& $this->ctrl->forwardCommand($user_gui);
161  break;
162 
163  case 'ilcalendarpresentationgui':
164  $this->getStandardTemplates();
165  $this->displayHeader();
166  $this->tpl->setTitle($this->lng->txt("calendar"));
167  $this->setTabs();
168  include_once('./Services/Calendar/classes/class.ilCalendarPresentationGUI.php');
169  $cal = new ilCalendarPresentationGUI();
170  $ret = $this->ctrl->forwardCommand($cal);
171  $this->tpl->show();
172  break;
173 
174  // pd notes
175  case "ilpdnotesgui":
176  if ($ilSetting->get('disable_notes'))
177  {
178  ilUtil::sendFailure($this->lng->txt('permission_denied'), true);
179  ilUtil::redirect('ilias.php?baseClass=ilPersonalDesktopGUI');
180  return;
181  }
182 
183  $this->getStandardTemplates();
184  $this->setTabs();
185  include_once("./Services/Notes/classes/class.ilPDNotesGUI.php");
186  $pd_notes_gui = new ilPDNotesGUI();
187  $ret =& $this->ctrl->forwardCommand($pd_notes_gui);
188  break;
189 
190  // pd news
191  case "ilpdnewsgui":
192  $this->getStandardTemplates();
193  $this->setTabs();
194  include_once("./Services/News/classes/class.ilPDNewsGUI.php");
195  $pd_news_gui = new ilPDNewsGUI();
196  $ret =& $this->ctrl->forwardCommand($pd_news_gui);
197  break;
198 
199  case "illearningprogressgui":
200  $this->getStandardTemplates();
201  $this->setTabs();
202  include_once './Services/Tracking/classes/class.ilLearningProgressGUI.php';
204  $ret =& $this->ctrl->forwardCommand($new_gui);
205 
206  break;
207 
208  case "ilcolumngui":
209  $this->getStandardTemplates();
210  $this->setTabs();
211  include_once("./Services/Block/classes/class.ilColumnGUI.php");
212  $column_gui = new ilColumnGUI("pd");
213  $this->initColumn($column_gui);
214  $this->show();
215  break;
216 
217  // contacts
218  case 'ilmailaddressbookgui':
219  $this->getStandardTemplates();
220  $this->setTabs();
221  $this->tpl->setTitle($this->lng->txt("mail_addressbook"));
222 
223  include_once 'Services/Contact/classes/class.ilMailAddressbookGUI.php';
224  $mailgui = new ilMailAddressbookGUI();
225  $ret = $this->ctrl->forwardCommand($mailgui);
226  break;
227 
228  case 'ilpersonalworkspacegui':
229  $this->getStandardTemplates();
230  $this->setTabs();
231  include_once 'Services/PersonalWorkspace/classes/class.ilPersonalWorkspaceGUI.php';
232  $wsgui = new ilPersonalWorkspaceGUI();
233  $ret = $this->ctrl->forwardCommand($wsgui);
234  $this->tpl->show();
235  break;
236 
237  case 'ilobjportfoliogui':
238  $this->getStandardTemplates();
239  $this->setTabs();
240  include_once 'Services/Portfolio/classes/class.ilObjPortfolioGUI.php';
241  $pfgui = new ilObjPortfolioGUI();
242  $ret = $this->ctrl->forwardCommand($pfgui);
243  $this->tpl->show();
244  break;
245 
246  case 'ilpersonalskillsgui':
247  $this->setTabs();
248  include_once './Services/Skill/classes/class.ilPersonalSkillsGUI.php';
249  $skgui = new ilPersonalSkillsGUI();
250  $this->getStandardTemplates();
251  $ret = $this->ctrl->forwardCommand($skgui);
252  $this->tpl->show();
253  break;
254 
255  case 'redirect':
256  $this->redirect();
257  break;
258 
259  default:
260  $this->getStandardTemplates();
261  $this->setTabs();
262  $cmd = $this->ctrl->getCmd("show");
263  $this->$cmd();
264  break;
265  }
266  $ret = null;
267  return $ret;
268  }
269 
273  public function redirect()
274  {
275  if(is_array($_GET))
276  {
277  foreach($_GET as $key => $val)
278  {
279  if(substr($key, 0, strlen('param_')) == 'param_')
280  {
281  $this->ctrl->setParameterByClass($_GET['redirectClass'], substr($key, strlen('param_')), $val);
282  }
283  }
284  }
285  ilUtil::redirect($this->ctrl->getLinkTargetByClass($_GET['redirectClass'], $_GET['redirectCmd'], '', true));
286  }
287 
292  {
293  $this->tpl->getStandardTemplate();
294  // add template for content
295 // $this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
296 // $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
297  }
298 
303  {
304  // add template for content
305  $this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
306  $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
307  }
308 
312  function show()
313  {
314 
315  // preload block settings
316  include_once("Services/Block/classes/class.ilBlockSetting.php");
318 
319  // add template for content
320  $this->pd_tpl = new ilTemplate("tpl.usr_personaldesktop.html", true, true, "Services/PersonalDesktop");
321  $this->tpl->getStandardTemplate();
322 
323  // display infopanel if something happened
325 
326  //$this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.png"),
327  // $this->lng->txt("personal_desktop"));
328 // $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.png"),
329 // "");
330  $this->tpl->setTitle($this->lng->txt("overview"));
331  $this->tpl->setVariable("IMG_SPACE", ilUtil::getImagePath("spacer.png", false));
332 
333  $this->tpl->setContent($this->getCenterColumnHTML());
334  $this->tpl->setRightContent($this->getRightColumnHTML());
335  $this->tpl->setLeftContent($this->getLeftColumnHTML());
336 
337  if(count($this->action_menu->getItems()))
338  {
343  global $tpl, $lng;
344 
345  $this->action_menu->setAsynch(false);
346  $this->action_menu->setAsynchUrl('');
347  $this->action_menu->setListTitle($lng->txt('actions'));
348  $this->action_menu->setId('act_pd');
349  $this->action_menu->setSelectionHeaderClass('small');
350  $this->action_menu->setItemLinkClass('xsmall');
351  $this->action_menu->setLinksMode('il_ContainerItemCommand2');
352  $this->action_menu->setHeaderIcon(ilAdvancedSelectionListGUI::DOWN_ARROW_DARK);
353  $this->action_menu->setUseImages(false);
354 
355  $htpl = new ilTemplate('tpl.header_action.html', true, true, 'Services/Repository');
356  $htpl->setVariable('ACTION_DROP_DOWN', $this->action_menu->getHTML());
357 
358  $tpl->setHeaderActionMenu($htpl->get());
359  }
360 
361  $this->tpl->show();
362  }
363 
364 
369  {
370  global $ilCtrl, $ilPluginAdmin;
371 
372  include_once("Services/Block/classes/class.ilColumnGUI.php");
373  $column_gui = new ilColumnGUI("pd", IL_COL_CENTER);
374  $this->initColumn($column_gui);
375 
376  if ($ilCtrl->getNextClass() == "ilcolumngui" &&
377  $column_gui->getCmdSide() == IL_COL_CENTER)
378  {
379  $html = $ilCtrl->forwardCommand($column_gui);
380  }
381  else
382  {
383  if (!$ilCtrl->isAsynch())
384  {
385  if ($column_gui->getScreenMode() != IL_SCREEN_SIDE)
386  {
387  // right column wants center
388  if ($column_gui->getCmdSide() == IL_COL_RIGHT)
389  {
390  $column_gui = new ilColumnGUI("pd", IL_COL_RIGHT);
391  $this->initColumn($column_gui);
392  $html = $ilCtrl->forwardCommand($column_gui);
393  }
394  // left column wants center
395  if ($column_gui->getCmdSide() == IL_COL_LEFT)
396  {
397  $column_gui = new ilColumnGUI("pd", IL_COL_LEFT);
398  $this->initColumn($column_gui);
399  $html = $ilCtrl->forwardCommand($column_gui);
400  }
401  }
402  else
403  {
404  $html = "";
405 
406  // user interface plugin slot + default rendering
407  include_once("./Services/UIComponent/classes/class.ilUIHookProcessor.php");
408  $uip = new ilUIHookProcessor("Services/PersonalDesktop", "center_column",
409  array("personal_desktop_gui" => $this));
410  if (!$uip->replaced())
411  {
412  $html = $ilCtrl->getHTML($column_gui);
413  }
414  $html = $uip->getHTML($html);
415 
416  }
417  }
418  }
419  return $html;
420  }
421 
426  {
427  global $ilUser, $lng, $ilCtrl, $ilPluginAdmin;
428 
429  include_once("Services/Block/classes/class.ilColumnGUI.php");
430  $column_gui = new ilColumnGUI("pd", IL_COL_RIGHT);
431  $this->initColumn($column_gui);
432 
433  if ($column_gui->getScreenMode() == IL_SCREEN_FULL)
434  {
435  return "";
436  }
437 
438  if ($ilCtrl->getNextClass() == "ilcolumngui" &&
439  $column_gui->getCmdSide() == IL_COL_RIGHT &&
440  $column_gui->getScreenMode() == IL_SCREEN_SIDE)
441  {
442  $html = $ilCtrl->forwardCommand($column_gui);
443  }
444  else
445  {
446  if (!$ilCtrl->isAsynch())
447  {
448  $html = "";
449 
450  // user interface plugin slot + default rendering
451  include_once("./Services/UIComponent/classes/class.ilUIHookProcessor.php");
452  $uip = new ilUIHookProcessor("Services/PersonalDesktop", "right_column",
453  array("personal_desktop_gui" => $this));
454  if (!$uip->replaced())
455  {
456  $html = $ilCtrl->getHTML($column_gui);
457  }
458  $html = $uip->getHTML($html);
459  }
460  }
461 
462  return $html;
463  }
464 
468  function getLeftColumnHTML()
469  {
470  global $ilUser, $lng, $ilCtrl, $ilPluginAdmin;
471 
472  include_once("Services/Block/classes/class.ilColumnGUI.php");
473  $column_gui = new ilColumnGUI("pd", IL_COL_LEFT);
474  $this->initColumn($column_gui);
475 
476  if ($column_gui->getScreenMode() == IL_SCREEN_FULL)
477  {
478  return "";
479  }
480 
481  if ($ilCtrl->getNextClass() == "ilcolumngui" &&
482  $column_gui->getCmdSide() == IL_COL_LEFT &&
483  $column_gui->getScreenMode() == IL_SCREEN_SIDE)
484  {
485  $html = $ilCtrl->forwardCommand($column_gui);
486  }
487  else
488  {
489  if (!$ilCtrl->isAsynch())
490  {
491  $html = "";
492 
493  // user interface plugin slot + default rendering
494  include_once("./Services/UIComponent/classes/class.ilUIHookProcessor.php");
495  $uip = new ilUIHookProcessor("Services/PersonalDesktop", "left_column",
496  array("personal_desktop_gui" => $this));
497  if (!$uip->replaced())
498  {
499  $html = $ilCtrl->getHTML($column_gui);
500  }
501  $html = $uip->getHTML($html);
502  }
503  }
504 
505  return $html;
506  }
507 
509  {
510  // add template for content
511  $this->pd_tpl = new ilTemplate("tpl.usr_personaldesktop.html", true, true, "Services/PersonalDesktop");
512  $this->tpl->getStandardTemplate();
513 
514  // display infopanel if something happened
516 
517  //$this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.png"),
518  // $this->lng->txt("personal_desktop"));
519  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.png"),
520  "");
521  $this->tpl->setTitle($this->lng->txt("personal_desktop"));
522  $this->tpl->setVariable("IMG_SPACE", ilUtil::getImagePath("spacer.png", false));
523  }
524 
525 
529  function removeMember()
530  {
531  global $err_msg;
532  if (strlen($err_msg) > 0)
533  {
534  $this->ilias->raiseError($this->lng->txt($err_msg),$this->ilias->error_obj->MESSAGE);
535  }
536  $this->show();
537  }
538 
543  {
544  include_once("Services/Mail/classes/class.ilPDSysMessageBlockGUI.php");
545  $sys_block = new ilPDSysMessageBlockGUI("ilpersonaldesktopgui", "show");
546  return $sys_block->getHTML();
547  }
548 
559  function multiarray_sort ($array, $key_sort)
560  {
561  if ($array) {
562  $key_sorta = explode(";", $key_sort);
563 
564  $multikeys = array_keys($array);
565  $keys = array_keys($array[$multikeys[0]]);
566 
567  for($m=0; $m < count($key_sorta); $m++) {
568  $nkeys[$m] = trim($key_sorta[$m]);
569  }
570  $n += count($key_sorta);
571 
572  for($i=0; $i < count($keys); $i++){
573  if(!in_array($keys[$i], $key_sorta)) {
574  $nkeys[$n] = $keys[$i];
575  $n += "1";
576  }
577  }
578 
579  for($u=0;$u<count($array); $u++) {
580  $arr = $array[$multikeys[$u]];
581  for($s=0; $s<count($nkeys); $s++) {
582  $k = $nkeys[$s];
583  $output[$multikeys[$u]][$k] = $array[$multikeys[$u]][$k];
584  }
585  }
586  sort($output);
587  return $output;
588  }
589  }
590 
594  function setTabs()
595  {
596  global $ilHelp;
597 
598  $ilHelp->setScreenIdComponent("pd");
599  }
600 
604  function jumpToMemberships()
605  {
606  global $ilSetting, $ilUser;
607 
608  if ($ilSetting->get('disable_my_memberships') == 0)
609  {
610  $ilUser->writePref('pd_view', 1);
611  }
612  $this->show();
613  }
614 
619  {
620  global $ilSetting, $ilUser;
621 
622  if ($ilSetting->get('disable_my_offers') == 0)
623  {
624  $ilUser->writePref('pd_view', 0);
625  }
626  $this->show();
627  }
628 
629 
633  function jumpToProfile()
634  {
635  $this->ctrl->redirectByClass("ilpersonalprofilegui");
636  }
637 
641  function jumpToPortfolio()
642  {
643  // incoming back link from shared resource
644  $cmd = "";
645  if($_REQUEST["dsh"])
646  {
647  $this->ctrl->setParameterByClass("ilobjportfoliogui", "user", $_REQUEST["dsh"]);
648  $cmd = "showOther";
649  }
650 
651  // used for goto links
652  if($_GET["prt_id"])
653  {
654  $this->ctrl->setParameterByClass("ilobjportfoliogui", "prt_id", $_GET["prt_id"]);
655  $this->ctrl->redirectByClass("ilobjportfoliogui", "preview");
656  }
657  else
658  {
659  $this->ctrl->redirectByClass("ilobjportfoliogui", $cmd);
660  }
661  }
662 
666  function jumpToSettings()
667  {
668  $this->ctrl->redirectByClass("ilpersonalsettingsgui");
669  }
670 
674  function jumpToBookmarks()
675  {
676  if ($this->ilias->getSetting("disable_bookmarks"))
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("ilbookmarkadministrationgui");
684  }
685 
689  function jumpToNotes()
690  {
691  if ($this->ilias->getSetting('disable_notes'))
692  {
693  ilUtil::sendFailure($this->lng->txt('permission_denied'), true);
694  ilUtil::redirect('ilias.php?baseClass=ilPersonalDesktopGUI');
695  return;
696  }
697 
698  $this->ctrl->redirectByClass("ilpdnotesgui");
699  }
700 
704  function jumpToNews()
705  {
706  $this->ctrl->redirectByClass("ilpdnewsgui");
707  }
708 
712  function jumpToLP()
713  {
714  $this->ctrl->redirectByClass("illearningprogressgui");
715  }
716 
720  function jumpToCalendar()
721  {
722  $this->ctrl->redirectByClass("ilcalendarpresentationgui");
723  }
724 
728  function jumpToContacts()
729  {
730  $this->ctrl->redirectByClass("ilmailaddressbookgui");
731  }
732 
736  function jumpToWorkspace()
737  {
738  // incoming back link from shared resource
739  $cmd = "";
740  if($_REQUEST["dsh"])
741  {
742  $this->ctrl->setParameterByClass("ilpersonalworkspacegui", "user", $_REQUEST["dsh"]);
743  $cmd = "share";
744  }
745 
746  if($_REQUEST["wsp_id"])
747  {
748  $this->ctrl->setParameterByClass("ilpersonalworkspacegui", "wsp_id", (int)$_REQUEST["wsp_id"]);
749  }
750 
751  if($_REQUEST["gtp"])
752  {
753  $this->ctrl->setParameterByClass("ilpersonalworkspacegui", "gtp", (int)$_REQUEST["gtp"]);
754  }
755 
756  $this->ctrl->redirectByClass("ilpersonalworkspacegui", $cmd);
757  }
758 
762  function jumpToSkills()
763  {
764  $this->ctrl->redirectByClass("ilpersonalskillsgui");
765  }
766 
767  function __loadNextClass()
768  {
769  $stored_classes = array('ilpersonaldesktopgui',
770  'ilpersonalprofilegui',
771  'ilpdnotesgui',
772  'ilcalendarpresentationgui',
773  'ilbookmarkadministrationgui',
774  'illearningprogressgui');
775 
776  if(isset($_SESSION['il_pd_history']) and in_array($_SESSION['il_pd_history'],$stored_classes))
777  {
778  return $_SESSION['il_pd_history'];
779  }
780  else
781  {
782  $this->ctrl->getNextClass($this);
783  }
784  }
785  function __storeLastClass($a_class)
786  {
787  $_SESSION['il_pd_history'] = $a_class;
788  $this->cmdClass = $a_class;
789  }
790 
795  function initColumn($a_column_gui)
796  {
797  $pd_set = new ilSetting("pd");
798  if ($pd_set->get("enable_block_moving"))
799  {
800  $a_column_gui->setEnableMovement(true);
801  }
802  $a_column_gui->setActionMenu($this->action_menu);
803  }
804 
808  function displayHeader()
809  {
810  //$this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.png"),
811  // $this->lng->txt("personal_desktop"));
812 // $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.png"),
813 // "");
814  $this->tpl->setTitle($this->lng->txt("personal_desktop"));
815  }
816 
817 
818 }
819 ?>