ILIAS  eassessment Revision 61809
 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 
21 {
22  var $tpl;
23  var $lng;
24  var $ilias;
25 
26  var $cmdClass = '';
27 
32  {
33  global $ilias, $tpl, $lng, $rbacsystem, $ilCtrl, $ilMainMenu, $ilUser, $tree;
34 
35 
36  $this->tpl =& $tpl;
37  $this->lng =& $lng;
38  $this->ilias =& $ilias;
39  $this->ctrl =& $ilCtrl;
40 
41  $ilCtrl->setContext($ilUser->getId(),
42  "user");
43 
44  $ilMainMenu->setActive("desktop");
45  $this->lng->loadLanguageModule("pdesk");
46 
47  // catch hack attempts
48  if ($_SESSION["AccountId"] == ANONYMOUS_USER_ID)
49  {
50  $this->ilias->raiseError($this->lng->txt("msg_not_available_for_anon"),$this->ilias->error_obj->MESSAGE);
51  }
52  $this->cmdClass = $_GET['cmdClass'];
53 
54  //$tree->useCache(false);
55  }
56 
60  function &executeCommand()
61  {
62  global $ilUser, $ilSetting, $rbacsystem;
63 
64  $next_class = $this->ctrl->getNextClass();
65  $this->ctrl->setReturn($this, "show");
66 
67  $this->tpl->addCss(ilUtil::getStyleSheetLocation('filesystem','delos.css','Services/Calendar'));
68 
69 
70  // check whether personal profile of user is incomplete
71  if ($ilUser->getProfileIncomplete() && $next_class != "ilpersonalprofilegui")
72  {
73  $this->ctrl->redirectByClass("ilpersonalprofilegui");
74  }
75 
76  // check whether password of user have to be changed
77  // due to first login or password of user is expired
78  if( ($ilUser->isPasswordChangeDemanded() || $ilUser->isPasswordExpired())
79  && $next_class != "ilpersonalprofilegui"
80  )
81  {
82  $this->ctrl->redirectByClass("ilpersonalprofilegui");
83  }
84 
85  // read last active subsection
86  if (isset($_GET['PDHistory']) && $_GET['PDHistory'])
87  {
88  $next_class = $this->__loadNextClass();
89  }
90  $this->__storeLastClass($next_class);
91 
92 
93  // check for permission to view contacts
94  include_once "Services/Mail/classes/class.ilMail.php";
95  $mail = new ilMail($_SESSION["AccountId"]);
96  if (
97  $next_class == 'ilmailaddressbookgui' && ($this->ilias->getSetting("disable_contacts") ||
98  (
99  !$this->ilias->getSetting("disable_contacts_require_mail") &&
100  !$rbacsystem->checkAccess('mail_visible',$mail->getMailObjectReferenceId())
101  ))
102  ) // if
103  {
104  $next_class = '';
105  ilUtil::sendFailure($this->lng->txt('no_permission'));
106  }
107  switch($next_class)
108  {
109  //Feedback
110  case "ilfeedbackgui":
111  $this->getStandardTemplates();
112  $this->setTabs();
113  $this->tpl->setTitle($this->lng->txt("personal_desktop"));
114  //$this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"),
115  // $this->lng->txt("personal_desktop"));
116  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"),
117  "");
118 
119  include_once("Services/Feedback/classes/class.ilFeedbackGUI.php");
120  $feedback_gui = new ilFeedbackGUI();
121  $ret =& $this->ctrl->forwardCommand($feedback_gui);
122  break;
123  // bookmarks
124  case "ilbookmarkadministrationgui":
125  if ($ilSetting->get('disable_bookmarks'))
126  {
127  ilUtil::sendFailure($this->lng->txt('permission_denied'), true);
128  ilUtil::redirect('ilias.php?baseClass=ilPersonalDesktopGUI');
129  return;
130  }
131 
132  include_once("./Services/PersonalDesktop/classes/class.ilBookmarkAdministrationGUI.php");
133  $bookmark_gui = new ilBookmarkAdministrationGUI();
134  if ($bookmark_gui->getMode() == 'tree') {
135  $this->getTreeModeTemplates();
136  } else {
137  $this->getStandardTemplates();
138  }
139  $this->setTabs();
140  $ret =& $this->ctrl->forwardCommand($bookmark_gui);
141  break;
142 
143  // profile
144  case "ilpersonalprofilegui":
145  $this->getStandardTemplates();
146  $this->setTabs();
147  include_once("./Services/User/classes/class.ilPersonalProfileGUI.php");
148  $profile_gui = new ilPersonalProfileGUI();
149  $ret =& $this->ctrl->forwardCommand($profile_gui);
150  break;
151 
152  // profile
153  case "ilobjusergui":
154  include_once('./Services/User/classes/class.ilObjUserGUI.php');
155  $user_gui = new ilObjUserGUI("",$_GET["user"], false, false);
156  $ret =& $this->ctrl->forwardCommand($user_gui);
157  break;
158 
159  case 'ilcalendarpresentationgui':
160  $this->getStandardTemplates();
161  $this->displayHeader();
162  $this->setTabs();
163  include_once('./Services/Calendar/classes/class.ilCalendarPresentationGUI.php');
164  $cal = new ilCalendarPresentationGUI();
165  $ret = $this->ctrl->forwardCommand($cal);
166  $this->tpl->show();
167  break;
168 
169  // pd notes
170  case "ilpdnotesgui":
171  if ($ilSetting->get('disable_notes'))
172  {
173  ilUtil::sendFailure($this->lng->txt('permission_denied'), true);
174  ilUtil::redirect('ilias.php?baseClass=ilPersonalDesktopGUI');
175  return;
176  }
177 
178  $this->getStandardTemplates();
179  $this->setTabs();
180  include_once("./Services/Notes/classes/class.ilPDNotesGUI.php");
181  $pd_notes_gui = new ilPDNotesGUI();
182  $ret =& $this->ctrl->forwardCommand($pd_notes_gui);
183  break;
184 
185  // pd news
186  case "ilpdnewsgui":
187  $this->getStandardTemplates();
188  $this->setTabs();
189  include_once("./Services/News/classes/class.ilPDNewsGUI.php");
190  $pd_news_gui = new ilPDNewsGUI();
191  $ret =& $this->ctrl->forwardCommand($pd_news_gui);
192  break;
193 
194  case "illearningprogressgui":
195  $this->getStandardTemplates();
196  $this->setTabs();
197  include_once './Services/Tracking/classes/class.ilLearningProgressGUI.php';
199  $ret =& $this->ctrl->forwardCommand($new_gui);
200 
201  break;
202 
203  case "ilcolumngui":
204  $this->getStandardTemplates();
205  $this->setTabs();
206  include_once("./Services/Block/classes/class.ilColumnGUI.php");
207  $column_gui = new ilColumnGUI("pd");
208  $this->initColumn($column_gui);
209  $this->show();
210  break;
211 
212  // contacts
213  case 'ilmailaddressbookgui':
214  $this->getStandardTemplates();
215  $this->setTabs();
216  $this->tpl->setTitle($this->lng->txt("personal_desktop"));
217  //$this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"),
218  // $this->lng->txt("personal_desktop"));
219  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"),
220  "");
221  include_once 'Services/Contact/classes/class.ilMailAddressbookGUI.php';
222  $mailgui = new ilMailAddressbookGUI();
223  $ret = $this->ctrl->forwardCommand($mailgui);
224  break;
225  case 'redirect':
226  $this->redirect();
227  break;
228  default:
229  $this->getStandardTemplates();
230  $this->setTabs();
231  $cmd = $this->ctrl->getCmd("show");
232  $this->$cmd();
233  break;
234  }
235  $ret = null;
236  return $ret;
237  }
238 
242  public function redirect()
243  {
244  if(is_array($_GET))
245  {
246  foreach($_GET as $key => $val)
247  {
248  if(substr($key, 0, strlen('param_')) == 'param_')
249  {
250  $this->ctrl->setParameterByClass($_GET['redirectClass'], substr($key, strlen('param_')), $val);
251  }
252  }
253  }
254  ilUtil::redirect($this->ctrl->getLinkTargetByClass($_GET['redirectClass'], $_GET['redirectCmd'], '', true));
255  }
256 
261  {
262  $this->tpl->getStandardTemplate();
263  // add template for content
264 // $this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
265 // $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
266  }
267 
272  {
273  // add template for content
274  //$this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_tree_content.html");
275  $this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
276  $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
277  }
278 
282  function show()
283  {
284 
285  // preload block settings
286  include_once("Services/Block/classes/class.ilBlockSetting.php");
288 
289  // add template for content
290  $this->pd_tpl = new ilTemplate("tpl.usr_personaldesktop.html", true, true);
291  $this->tpl->getStandardTemplate();
292 
293  // display infopanel if something happened
295 
296  //$this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"),
297  // $this->lng->txt("personal_desktop"));
298  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"),
299  "");
300  $this->tpl->setTitle($this->lng->txt("personal_desktop"));
301  $this->tpl->setVariable("IMG_SPACE", ilUtil::getImagePath("spacer.gif", false));
302 
303  $this->tpl->setContent($this->getCenterColumnHTML());
304  $this->tpl->setRightContent($this->getRightColumnHTML());
305  $this->tpl->setLeftContent($this->getLeftColumnHTML());
306  $this->tpl->show();
307  }
308 
309 
314  {
315  global $ilCtrl;
316 
317  include_once("Services/Block/classes/class.ilColumnGUI.php");
318  $column_gui = new ilColumnGUI("pd", IL_COL_CENTER);
319  $this->initColumn($column_gui);
320 
321  if ($ilCtrl->getNextClass() == "ilcolumngui" &&
322  $column_gui->getCmdSide() == IL_COL_CENTER)
323  {
324  $html = $ilCtrl->forwardCommand($column_gui);
325  }
326  else
327  {
328  if (!$ilCtrl->isAsynch())
329  {
330  if ($column_gui->getScreenMode() != IL_SCREEN_SIDE)
331  {
332  // right column wants center
333  if ($column_gui->getCmdSide() == IL_COL_RIGHT)
334  {
335  $column_gui = new ilColumnGUI("pd", IL_COL_RIGHT);
336  $this->initColumn($column_gui);
337  $html = $ilCtrl->forwardCommand($column_gui);
338  }
339  // left column wants center
340  if ($column_gui->getCmdSide() == IL_COL_LEFT)
341  {
342  $column_gui = new ilColumnGUI("pd", IL_COL_LEFT);
343  $this->initColumn($column_gui);
344  $html = $ilCtrl->forwardCommand($column_gui);
345  }
346  }
347  else
348  {
349  $html = $ilCtrl->getHTML($column_gui);
350  }
351  }
352  }
353  return $html;
354  }
355 
360  {
361  global $ilUser, $lng, $ilCtrl;
362 
363  include_once("Services/Block/classes/class.ilColumnGUI.php");
364  $column_gui = new ilColumnGUI("pd", IL_COL_RIGHT);
365  $this->initColumn($column_gui);
366 
367  if ($column_gui->getScreenMode() == IL_SCREEN_FULL)
368  {
369  return "";
370  }
371 
372  if ($ilCtrl->getNextClass() == "ilcolumngui" &&
373  $column_gui->getCmdSide() == IL_COL_RIGHT &&
374  $column_gui->getScreenMode() == IL_SCREEN_SIDE)
375  {
376  $html = $ilCtrl->forwardCommand($column_gui);
377  }
378  else
379  {
380  if (!$ilCtrl->isAsynch())
381  {
382  $html = $ilCtrl->getHTML($column_gui);
383  }
384  }
385 
386  return $html;
387  }
388 
392  function getLeftColumnHTML()
393  {
394  global $ilUser, $lng, $ilCtrl;
395 
396  include_once("Services/Block/classes/class.ilColumnGUI.php");
397  $column_gui = new ilColumnGUI("pd", IL_COL_LEFT);
398  $this->initColumn($column_gui);
399 
400  if ($column_gui->getScreenMode() == IL_SCREEN_FULL)
401  {
402  return "";
403  }
404 
405  if ($ilCtrl->getNextClass() == "ilcolumngui" &&
406  $column_gui->getCmdSide() == IL_COL_LEFT &&
407  $column_gui->getScreenMode() == IL_SCREEN_SIDE)
408  {
409  $html = $ilCtrl->forwardCommand($column_gui);
410  }
411  else
412  {
413  if (!$ilCtrl->isAsynch())
414  {
415  $html = $ilCtrl->getHTML($column_gui);
416  }
417  }
418 
419  return $html;
420  }
421 
423  {
424  // add template for content
425  $this->pd_tpl = new ilTemplate("tpl.usr_personaldesktop.html", true, true);
426  $this->tpl->getStandardTemplate();
427 
428  // display infopanel if something happened
430 
431  //$this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"),
432  // $this->lng->txt("personal_desktop"));
433  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"),
434  "");
435  $this->tpl->setTitle($this->lng->txt("personal_desktop"));
436  $this->tpl->setVariable("IMG_SPACE", ilUtil::getImagePath("spacer.gif", false));
437  }
438 
439 
443  function removeMember()
444  {
445  global $err_msg;
446  if (strlen($err_msg) > 0)
447  {
448  $this->ilias->raiseError($this->lng->txt($err_msg),$this->ilias->error_obj->MESSAGE);
449  }
450  $this->show();
451  }
452 
457  {
458  include_once("Services/Mail/classes/class.ilPDSysMessageBlockGUI.php");
459  $sys_block = new ilPDSysMessageBlockGUI("ilpersonaldesktopgui", "show");
460  return $sys_block->getHTML();
461  }
462 
463 
467  function displayFeedback()
468  {
469  include_once("./Services/Feedback/classes/class.ilPDFeedbackBlockGUI.php");
470  $fb_block = new ilPDFeedbackBlockGUI("ilpersonaldesktopgui", "show");
471  return $fb_block->getHTML();
472 
473  include_once('Services/Feedback/classes/class.ilFeedbackGUI.php');
474  $feedback_gui = new ilFeedbackGUI();
475  return $feedback_gui->getPDFeedbackListHTML();
476  }
477 
488  function multiarray_sort ($array, $key_sort)
489  {
490  if ($array) {
491  $key_sorta = explode(";", $key_sort);
492 
493  $multikeys = array_keys($array);
494  $keys = array_keys($array[$multikeys[0]]);
495 
496  for($m=0; $m < count($key_sorta); $m++) {
497  $nkeys[$m] = trim($key_sorta[$m]);
498  }
499  $n += count($key_sorta);
500 
501  for($i=0; $i < count($keys); $i++){
502  if(!in_array($keys[$i], $key_sorta)) {
503  $nkeys[$n] = $keys[$i];
504  $n += "1";
505  }
506  }
507 
508  for($u=0;$u<count($array); $u++) {
509  $arr = $array[$multikeys[$u]];
510  for($s=0; $s<count($nkeys); $s++) {
511  $k = $nkeys[$s];
512  $output[$multikeys[$u]][$k] = $array[$multikeys[$u]][$k];
513  }
514  }
515  sort($output);
516  return $output;
517  }
518  }
519 
523  function setTabs()
524  {
525  global $ilCtrl, $ilSetting, $ilTabs, $rbacsystem;
526 
527 // $this->tpl->addBlockFile("TABS", "tabs", "tpl.tabs.html");
528 
529  $script_name = basename($_SERVER["SCRIPT_NAME"]);
530 
531  $command = "";
532  if (isset($_GET["cmd"]))
533  {
534  $command = $_GET["cmd"];
535  }
536 
537  if (preg_match("/whois/", $command))
538  {
539  $who_is_online = true;
540  }
541 
542  // to do: use ilTabsGUI here!
543 
544  // personal desktop home
545  $ilTabs->addTarget("overview", $this->ctrl->getLinkTarget($this));
546  if ((strtolower($_GET["baseClass"]) == "ilpersonaldesktopgui" &&
547  (strtolower($this->cmdClass) == "ilpersonaldesktopgui" ||
548  $this->cmdClass == "" || (strtolower($this->cmdClass)) == "ilfeedbackgui"
549  || $ilCtrl->getNextClass() == "ilcolumngui")))
550  {
551  $ilTabs->setTabActive("overview");
552  }
553 
554  // user profile
555  $ilTabs->addTarget("personal_profile", $this->ctrl->getLinkTargetByClass("ilPersonalProfileGUI"));
556  if (strtolower($this->cmdClass) == "ilpersonalprofilegui")
557  {
558  $ilTabs->setTabActive("personal_profile");
559  }
560 
561 
562  if ($_SESSION["AccountId"] != ANONYMOUS_USER_ID)
563  {
564  // news
565  if ($ilSetting->get("block_activated_news"))
566  {
567  $ilTabs->addTarget("news", $this->ctrl->getLinkTargetByClass("ilpdnewsgui"));
568  if ($ilCtrl->getNextClass() == "ilpdnewsgui")
569  {
570  $ilTabs->setTabActive("news");
571  }
572  }
573 
574  // new calendar
575  include_once('./Services/Calendar/classes/class.ilCalendarSettings.php');
576  $settings = ilCalendarSettings::_getInstance();
577  if($settings->isEnabled())
578  {
579  $ilTabs->addTarget("calendar", $this->ctrl->getLinkTargetByClass("ilcalendarpresentationgui"));
580  if (strtolower($this->cmdClass) == "ilcalendarpresentationgui")
581  {
582  $ilTabs->setTabActive("calendar");
583  }
584  }
585 
586  // private notes
587  if (!$this->ilias->getSetting("disable_notes"))
588  {
589  $ilTabs->addTarget("notes_and_comments", $this->ctrl->getLinkTargetByClass("ilpdnotesgui"));
590  if (strtolower($this->cmdClass) == "ilpdnotesgui" ||
591  strtolower($this->cmdClass) == "ilnotegui")
592  {
593  $ilTabs->setTabActive("notes_and_comments");
594  }
595  }
596 
597  // user bookmarks
598  if (!$this->ilias->getSetting("disable_bookmarks"))
599  {
600  $ilTabs->addTarget("bookmarks", $this->ctrl->getLinkTargetByClass("ilbookmarkadministrationgui"));
601  if (strtolower($this->cmdClass) == "ilbookmarkadministrationgui")
602  {
603  $ilTabs->setTabActive("bookmarks");
604  }
605  }
606 
607  // contacts
608  include_once "Services/Mail/classes/class.ilMail.php";
609  $mail = new ilMail($_SESSION["AccountId"]);
610 
611  if (!$this->ilias->getSetting("disable_contacts") && ($this->ilias->getSetting("disable_contacts_require_mail") || $rbacsystem->checkAccess('mail_visible',$mail->getMailObjectReferenceId())))
612  {
613  $ilTabs->addTarget("mail_addressbook", $this->ctrl->getLinkTargetByClass("ilmailaddressbookgui"));
614  if (strtolower($this->cmdClass) == "ilmailaddressbookgui")
615  {
616  $ilTabs->setTabActive("mail_addressbook");
617  }
618  }
619  }
620 
621  // Learning Progress
622  include_once("Services/Tracking/classes/class.ilObjUserTracking.php");
624  {
625  $ilTabs->addTarget("learning_progress", $this->ctrl->getLinkTargetByClass("ilLearningProgressGUI"));
626  $cmd_classes = array('illplistofobjectsgui','illplistofsettingsgui','illearningprogressgui','illplistofprogressgui');
627  if (in_array(strtolower($this->cmdClass),$cmd_classes))
628  {
629  $ilTabs->setTabActive("learning_progress");
630  }
631  }
632  }
633 
637  function jumpToProfile()
638  {
639  $this->ctrl->redirectByClass("ilpersonalprofilegui");
640  }
641 
645  function jumpToBookmarks()
646  {
647  if ($this->ilias->getSetting("disable_bookmarks"))
648  {
649  ilUtil::sendFailure($this->lng->txt('permission_denied'), true);
650  ilUtil::redirect('ilias.php?baseClass=ilPersonalDesktopGUI');
651  return;
652  }
653 
654  $this->ctrl->redirectByClass("ilbookmarkadministrationgui");
655  }
656 
660  function jumpToNotes()
661  {
662  if ($this->ilias->getSetting('disable_notes'))
663  {
664  ilUtil::sendFailure($this->lng->txt('permission_denied'), true);
665  ilUtil::redirect('ilias.php?baseClass=ilPersonalDesktopGUI');
666  return;
667  }
668 
669  $this->ctrl->redirectByClass("ilpdnotesgui");
670  }
671 
675  function jumpToNews()
676  {
677  $this->ctrl->redirectByClass("ilpdnewsgui");
678  }
679 
683  function jumpToLP()
684  {
685  $this->ctrl->redirectByClass("illearningprogressgui");
686  }
687 
688  function __loadNextClass()
689  {
690  $stored_classes = array('ilpersonaldesktopgui',
691  'ilpersonalprofilegui',
692  'ilpdnotesgui',
693  'ilcalendarpresentationgui',
694  'ilbookmarkadministrationgui',
695  'illearningprogressgui');
696 
697  if(isset($_SESSION['il_pd_history']) and in_array($_SESSION['il_pd_history'],$stored_classes))
698  {
699  return $_SESSION['il_pd_history'];
700  }
701  else
702  {
703  $this->ctrl->getNextClass($this);
704  }
705  }
706  function __storeLastClass($a_class)
707  {
708  $_SESSION['il_pd_history'] = $a_class;
709  $this->cmdClass = $a_class;
710  }
711 
715  function initColumn($a_column_gui)
716  {
717  $pd_set = new ilSetting("pd");
718  if ($pd_set->get("enable_block_moving"))
719  {
720  $a_column_gui->setEnableMovement(true);
721  }
722  }
723 
727  function displayHeader()
728  {
729  //$this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"),
730  // $this->lng->txt("personal_desktop"));
731  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"),
732  "");
733  $this->tpl->setTitle($this->lng->txt("personal_desktop"));
734  }
735 
736 
737 }
738 ?>