ILIAS  Release_4_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 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2009 ILIAS open source, University of Cologne |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License |
10 | as published by the Free Software Foundation; either version 2 |
11 | of the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 +-----------------------------------------------------------------------------+
22 */
23 
24 include_once './Services/User/classes/class.ilObjUser.php';
25 include_once "Services/Mail/classes/class.ilMail.php";
26 
27 
28 
42 {
43  var $tpl;
44  var $lng;
45  var $ilias;
46 
47  var $cmdClass = '';
48 
53  {
54  global $ilias, $tpl, $lng, $rbacsystem, $ilCtrl, $ilMainMenu, $ilUser, $tree;
55 
56 
57  $this->tpl =& $tpl;
58  $this->lng =& $lng;
59  $this->ilias =& $ilias;
60  $this->ctrl =& $ilCtrl;
61 
62  $ilCtrl->setContext($ilUser->getId(),
63  "user");
64 
65  $ilMainMenu->setActive("desktop");
66  $this->lng->loadLanguageModule("pdesk");
67 
68  // catch hack attempts
69  if ($_SESSION["AccountId"] == ANONYMOUS_USER_ID)
70  {
71  $this->ilias->raiseError($this->lng->txt("msg_not_available_for_anon"),$this->ilias->error_obj->MESSAGE);
72  }
73  $this->cmdClass = $_GET['cmdClass'];
74 
75  //$tree->useCache(false);
76  }
77 
81  function &executeCommand()
82  {
83  global $ilUser, $ilSetting, $rbacsystem;
84 
85  $next_class = $this->ctrl->getNextClass();
86  $this->ctrl->setReturn($this, "show");
87 
88  $this->tpl->addCss(ilUtil::getStyleSheetLocation('filesystem','delos.css','Services/Calendar'));
89 
90 
91  // check whether personal profile of user is incomplete
92  if ($ilUser->getProfileIncomplete() && $next_class != "ilpersonalprofilegui")
93  {
94  $this->ctrl->redirectByClass("ilpersonalprofilegui");
95  }
96 
97  // check whether password of user have to be changed
98  // due to first login or password of user is expired
99  if( ($ilUser->isPasswordChangeDemanded() || $ilUser->isPasswordExpired())
100  && $next_class != "ilpersonalprofilegui"
101  )
102  {
103  $this->ctrl->redirectByClass("ilpersonalprofilegui");
104  }
105 
106  // read last active subsection
107  if($_GET['PDHistory'])
108  {
109  $next_class = $this->__loadNextClass();
110  }
111  $this->__storeLastClass($next_class);
112 
113 
114  // check for permission to view contacts
115  include_once "Services/Mail/classes/class.ilMail.php";
116  $mail = new ilMail($_SESSION["AccountId"]);
117  if (
118  $next_class == 'ilmailaddressbookgui' && ($this->ilias->getSetting("disable_contacts") ||
119  (
120  !$this->ilias->getSetting("disable_contacts_require_mail") &&
121  !$rbacsystem->checkAccess('mail_visible',$mail->getMailObjectReferenceId())
122  ))
123  ) // if
124  {
125  $next_class = '';
126  ilUtil::sendFailure($this->lng->txt('no_permission'));
127  }
128 
129  switch($next_class)
130  {
131  //Feedback
132  case "ilfeedbackgui":
133  $this->getStandardTemplates();
134  $this->setTabs();
135  $this->tpl->setTitle($this->lng->txt("personal_desktop"));
136  //$this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"),
137  // $this->lng->txt("personal_desktop"));
138  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"),
139  "");
140 
141  include_once("Services/Feedback/classes/class.ilFeedbackGUI.php");
142  $feedback_gui = new ilFeedbackGUI();
143  $ret =& $this->ctrl->forwardCommand($feedback_gui);
144  break;
145  // bookmarks
146  case "ilbookmarkadministrationgui":
147  if ($ilSetting->get('disable_bookmarks'))
148  {
149  ilUtil::sendFailure($this->lng->txt('permission_denied'), true);
150  ilUtil::redirect('ilias.php?baseClass=ilPersonalDesktopGUI');
151  return;
152  }
153 
154  include_once("./Services/PersonalDesktop/classes/class.ilBookmarkAdministrationGUI.php");
155  $bookmark_gui = new ilBookmarkAdministrationGUI();
156  if ($bookmark_gui->getMode() == 'tree') {
157  $this->getTreeModeTemplates();
158  } else {
159  $this->getStandardTemplates();
160  }
161  $this->setTabs();
162  $ret =& $this->ctrl->forwardCommand($bookmark_gui);
163  break;
164 
165  // profile
166  case "ilpersonalprofilegui":
167  $this->getStandardTemplates();
168  $this->setTabs();
169  include_once("./Services/User/classes/class.ilPersonalProfileGUI.php");
170  $profile_gui = new ilPersonalProfileGUI();
171  $ret =& $this->ctrl->forwardCommand($profile_gui);
172  break;
173 
174  // profile
175  case "ilobjusergui":
176  include_once('./Services/User/classes/class.ilObjUserGUI.php');
177  $user_gui = new ilObjUserGUI("",$_GET["user"], false, false);
178  $ret =& $this->ctrl->forwardCommand($user_gui);
179  break;
180 
181  case 'ilcalendarpresentationgui':
182  $this->getStandardTemplates();
183  $this->displayHeader();
184  $this->setTabs();
185  include_once('./Services/Calendar/classes/class.ilCalendarPresentationGUI.php');
186  $cal = new ilCalendarPresentationGUI();
187  $ret = $this->ctrl->forwardCommand($cal);
188  $this->tpl->show();
189  break;
190 
191  // pd notes
192  case "ilpdnotesgui":
193  if ($ilSetting->get('disable_notes'))
194  {
195  ilUtil::sendFailure($this->lng->txt('permission_denied'), true);
196  ilUtil::redirect('ilias.php?baseClass=ilPersonalDesktopGUI');
197  return;
198  }
199 
200  $this->getStandardTemplates();
201  $this->setTabs();
202  include_once("./Services/Notes/classes/class.ilPDNotesGUI.php");
203  $pd_notes_gui = new ilPDNotesGUI();
204  $ret =& $this->ctrl->forwardCommand($pd_notes_gui);
205  break;
206 
207  // pd news
208  case "ilpdnewsgui":
209  $this->getStandardTemplates();
210  $this->setTabs();
211  include_once("./Services/News/classes/class.ilPDNewsGUI.php");
212  $pd_news_gui = new ilPDNewsGUI();
213  $ret =& $this->ctrl->forwardCommand($pd_news_gui);
214  break;
215 
216  case "illearningprogressgui":
217  $this->getStandardTemplates();
218  $this->setTabs();
219  include_once './Services/Tracking/classes/class.ilLearningProgressGUI.php';
221  $ret =& $this->ctrl->forwardCommand($new_gui);
222 
223  break;
224 
225  case "ilcolumngui":
226  $this->getStandardTemplates();
227  $this->setTabs();
228  include_once("./Services/Block/classes/class.ilColumnGUI.php");
229  $column_gui = new ilColumnGUI("pd");
230  $this->initColumn($column_gui);
231  $this->show();
232  break;
233 
234  // contacts
235  case 'ilmailaddressbookgui':
236  $this->getStandardTemplates();
237  $this->setTabs();
238  $this->tpl->setTitle($this->lng->txt("personal_desktop"));
239  //$this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"),
240  // $this->lng->txt("personal_desktop"));
241  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"),
242  "");
243  include_once 'Services/Contact/classes/class.ilMailAddressbookGUI.php';
244  $mailgui = new ilMailAddressbookGUI();
245  $ret = $this->ctrl->forwardCommand($mailgui);
246  break;
247  case 'redirect':
248  $this->redirect();
249  break;
250  default:
251  $this->getStandardTemplates();
252  $this->setTabs();
253  $cmd = $this->ctrl->getCmd("show");
254  $this->$cmd();
255  break;
256  }
257  return true;
258  }
259 
263  public function redirect()
264  {
265  if(is_array($_GET))
266  {
267  foreach($_GET as $key => $val)
268  {
269  if(substr($key, 0, strlen('param_')) == 'param_')
270  {
271  $this->ctrl->setParameterByClass($_GET['redirectClass'], substr($key, strlen('param_')), $val);
272  }
273  }
274  }
275  ilUtil::redirect($this->ctrl->getLinkTargetByClass($_GET['redirectClass'], $_GET['redirectCmd']));
276  }
277 
282  {
283  $this->tpl->getStandardTemplate();
284  // add template for content
285 // $this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
286 // $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
287  }
288 
293  {
294  // add template for content
295  //$this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_tree_content.html");
296  $this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
297  $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
298  }
299 
303  function show()
304  {
305 
306  // add template for content
307  $this->pd_tpl = new ilTemplate("tpl.usr_personaldesktop.html", true, true);
308  $this->tpl->getStandardTemplate();
309 
310  // display infopanel if something happened
312 
313  //$this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"),
314  // $this->lng->txt("personal_desktop"));
315  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"),
316  "");
317  $this->tpl->setTitle($this->lng->txt("personal_desktop"));
318  $this->tpl->setVariable("IMG_SPACE", ilUtil::getImagePath("spacer.gif", false));
319 
320  $this->tpl->setContent($this->getCenterColumnHTML());
321  $this->tpl->setRightContent($this->getRightColumnHTML());
322  $this->tpl->setLeftContent($this->getLeftColumnHTML());
323  $this->tpl->show();
324  }
325 
326 
331  {
332  global $ilCtrl;
333 
334  include_once("Services/Block/classes/class.ilColumnGUI.php");
335  $column_gui = new ilColumnGUI("pd", IL_COL_CENTER);
336  $this->initColumn($column_gui);
337 
338  if ($ilCtrl->getNextClass() == "ilcolumngui" &&
339  $column_gui->getCmdSide() == IL_COL_CENTER)
340  {
341  $html = $ilCtrl->forwardCommand($column_gui);
342  }
343  else
344  {
345  if (!$ilCtrl->isAsynch())
346  {
347  if ($column_gui->getScreenMode() != IL_SCREEN_SIDE)
348  {
349  // right column wants center
350  if ($column_gui->getCmdSide() == IL_COL_RIGHT)
351  {
352  $column_gui = new ilColumnGUI("pd", IL_COL_RIGHT);
353  $this->initColumn($column_gui);
354  $html = $ilCtrl->forwardCommand($column_gui);
355  }
356  // left column wants center
357  if ($column_gui->getCmdSide() == IL_COL_LEFT)
358  {
359  $column_gui = new ilColumnGUI("pd", IL_COL_LEFT);
360  $this->initColumn($column_gui);
361  $html = $ilCtrl->forwardCommand($column_gui);
362  }
363  }
364  else
365  {
366  $html = $ilCtrl->getHTML($column_gui);
367  }
368  }
369  }
370  return $html;
371  }
372 
377  {
378  global $ilUser, $lng, $ilCtrl;
379 
380  include_once("Services/Block/classes/class.ilColumnGUI.php");
381  $column_gui = new ilColumnGUI("pd", IL_COL_RIGHT);
382  $this->initColumn($column_gui);
383 
384  if ($ilCtrl->getNextClass() == "ilcolumngui" &&
385  $column_gui->getCmdSide() == IL_COL_RIGHT &&
386  $column_gui->getScreenMode() == IL_SCREEN_SIDE)
387  {
388  $html = $ilCtrl->forwardCommand($column_gui);
389  }
390  else
391  {
392  if (!$ilCtrl->isAsynch())
393  {
394  $html = $ilCtrl->getHTML($column_gui);
395  }
396  }
397 
398  return $html;
399  }
400 
404  function getLeftColumnHTML()
405  {
406  global $ilUser, $lng, $ilCtrl;
407 
408  include_once("Services/Block/classes/class.ilColumnGUI.php");
409  $column_gui = new ilColumnGUI("pd", IL_COL_LEFT);
410  $this->initColumn($column_gui);
411 
412  if ($ilCtrl->getNextClass() == "ilcolumngui" &&
413  $column_gui->getCmdSide() == IL_COL_LEFT &&
414  $column_gui->getScreenMode() == IL_SCREEN_SIDE)
415  {
416  $html = $ilCtrl->forwardCommand($column_gui);
417  }
418  else
419  {
420  if (!$ilCtrl->isAsynch())
421  {
422  $html = $ilCtrl->getHTML($column_gui);
423  }
424  }
425 
426  return $html;
427  }
428 
430  {
431  // add template for content
432  $this->pd_tpl = new ilTemplate("tpl.usr_personaldesktop.html", true, true);
433  $this->tpl->getStandardTemplate();
434 
435  // display infopanel if something happened
437 
438  //$this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"),
439  // $this->lng->txt("personal_desktop"));
440  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"),
441  "");
442  $this->tpl->setTitle($this->lng->txt("personal_desktop"));
443  $this->tpl->setVariable("IMG_SPACE", ilUtil::getImagePath("spacer.gif", false));
444  }
445 
446 
450  function removeMember()
451  {
452  global $err_msg;
453  if (strlen($err_msg) > 0)
454  {
455  $this->ilias->raiseError($this->lng->txt($err_msg),$this->ilias->error_obj->MESSAGE);
456  }
457  $this->show();
458  }
459 
464  {
465  include_once("Services/Mail/classes/class.ilPDSysMessageBlockGUI.php");
466  $sys_block = new ilPDSysMessageBlockGUI("ilpersonaldesktopgui", "show");
467  return $sys_block->getHTML();
468  }
469 
470 
474  function displayFeedback()
475  {
476  include_once("./Services/Feedback/classes/class.ilPDFeedbackBlockGUI.php");
477  $fb_block = new ilPDFeedbackBlockGUI("ilpersonaldesktopgui", "show");
478  return $fb_block->getHTML();
479 
480  include_once('Services/Feedback/classes/class.ilFeedbackGUI.php');
481  $feedback_gui = new ilFeedbackGUI();
482  return $feedback_gui->getPDFeedbackListHTML();
483  }
484 
495  function multiarray_sort ($array, $key_sort)
496  {
497  if ($array) {
498  $key_sorta = explode(";", $key_sort);
499 
500  $multikeys = array_keys($array);
501  $keys = array_keys($array[$multikeys[0]]);
502 
503  for($m=0; $m < count($key_sorta); $m++) {
504  $nkeys[$m] = trim($key_sorta[$m]);
505  }
506  $n += count($key_sorta);
507 
508  for($i=0; $i < count($keys); $i++){
509  if(!in_array($keys[$i], $key_sorta)) {
510  $nkeys[$n] = $keys[$i];
511  $n += "1";
512  }
513  }
514 
515  for($u=0;$u<count($array); $u++) {
516  $arr = $array[$multikeys[$u]];
517  for($s=0; $s<count($nkeys); $s++) {
518  $k = $nkeys[$s];
519  $output[$multikeys[$u]][$k] = $array[$multikeys[$u]][$k];
520  }
521  }
522  sort($output);
523  return $output;
524  }
525  }
526 
530  function setTabs()
531  {
532  global $ilCtrl, $ilSetting, $ilTabs, $rbacsystem;
533 
534 // $this->tpl->addBlockFile("TABS", "tabs", "tpl.tabs.html");
535 
536  $script_name = basename($_SERVER["SCRIPT_NAME"]);
537 
538  $command = $_GET["cmd"] ? $_GET["cmd"] : "";
539 
540  if (ereg("whois",$command))
541  {
542  $who_is_online = true;
543  }
544 
545  // to do: use ilTabsGUI here!
546 
547  // personal desktop home
548  $ilTabs->addTarget("overview", $this->ctrl->getLinkTarget($this));
549  if ((strtolower($_GET["baseClass"]) == "ilpersonaldesktopgui" &&
550  (strtolower($this->cmdClass) == "ilpersonaldesktopgui" ||
551  $this->cmdClass == "" || (strtolower($this->cmdClass)) == "ilfeedbackgui"
552  || $ilCtrl->getNextClass() == "ilcolumngui")))
553  {
554  $ilTabs->setTabActive("overview");
555  }
556 
557  // user profile
558  $ilTabs->addTarget("personal_profile", $this->ctrl->getLinkTargetByClass("ilPersonalProfileGUI"));
559  if (strtolower($this->cmdClass) == "ilpersonalprofilegui")
560  {
561  $ilTabs->setTabActive("personal_profile");
562  }
563 
564 
565  if ($_SESSION["AccountId"] != ANONYMOUS_USER_ID)
566  {
567  // news
568  if ($ilSetting->get("block_activated_news"))
569  {
570  $ilTabs->addTarget("news", $this->ctrl->getLinkTargetByClass("ilpdnewsgui"));
571  if ($ilCtrl->getNextClass() == "ilpdnewsgui")
572  {
573  $ilTabs->setTabActive("news");
574  }
575  }
576 
577  // new calendar
578  include_once('./Services/Calendar/classes/class.ilCalendarSettings.php');
579  $settings = ilCalendarSettings::_getInstance();
580  if($settings->isEnabled())
581  {
582  $ilTabs->addTarget("calendar", $this->ctrl->getLinkTargetByClass("ilcalendarpresentationgui"));
583  if (strtolower($this->cmdClass) == "ilcalendarpresentationgui")
584  {
585  $ilTabs->setTabActive("calendar");
586  }
587  }
588 
589  // private notes
590  if (!$this->ilias->getSetting("disable_notes"))
591  {
592  $ilTabs->addTarget("notes_and_comments", $this->ctrl->getLinkTargetByClass("ilpdnotesgui"));
593  if (strtolower($this->cmdClass) == "ilpdnotesgui" ||
594  strtolower($this->cmdClass) == "ilnotegui")
595  {
596  $ilTabs->setTabActive("notes_and_comments");
597  }
598  }
599 
600  // user bookmarks
601  if (!$this->ilias->getSetting("disable_bookmarks"))
602  {
603  $ilTabs->addTarget("bookmarks", $this->ctrl->getLinkTargetByClass("ilbookmarkadministrationgui"));
604  if (strtolower($this->cmdClass) == "ilbookmarkadministrationgui")
605  {
606  $ilTabs->setTabActive("bookmarks");
607  }
608  }
609 
610  // contacts
611  include_once "Services/Mail/classes/class.ilMail.php";
612  $mail =& new ilMail($_SESSION["AccountId"]);
613 
614  if (!$this->ilias->getSetting("disable_contacts") && ($this->ilias->getSetting("disable_contacts_require_mail") || $rbacsystem->checkAccess('mail_visible',$mail->getMailObjectReferenceId())))
615  {
616  $ilTabs->addTarget("mail_addressbook", $this->ctrl->getLinkTargetByClass("ilmailaddressbookgui"));
617  if (strtolower($this->cmdClass) == "ilmailaddressbookgui")
618  {
619  $ilTabs->setTabActive("mail_addressbook");
620  }
621  }
622  }
623 
624  // Learning Progress
625  include_once("Services/Tracking/classes/class.ilObjUserTracking.php");
627  {
628  $ilTabs->addTarget("learning_progress", $this->ctrl->getLinkTargetByClass("ilLearningProgressGUI"));
629  $cmd_classes = array('illplistofobjectsgui','illplistofsettingsgui','illearningprogressgui','illplistofprogressgui');
630  if (in_array(strtolower($this->cmdClass),$cmd_classes))
631  {
632  $ilTabs->setTabActive("learning_progress");
633  }
634  }
635  }
636 
640  function jumpToProfile()
641  {
642  $this->ctrl->redirectByClass("ilpersonalprofilegui");
643  }
644 
648  function jumpToBookmarks()
649  {
650  if ($this->ilias->getSetting("disable_bookmarks"))
651  {
652  ilUtil::sendFailure($this->lng->txt('permission_denied'), true);
653  ilUtil::redirect('ilias.php?baseClass=ilPersonalDesktopGUI');
654  return;
655  }
656 
657  $this->ctrl->redirectByClass("ilbookmarkadministrationgui");
658  }
659 
663  function jumpToNotes()
664  {
665  if ($this->ilias->getSetting('disable_notes'))
666  {
667  ilUtil::sendFailure($this->lng->txt('permission_denied'), true);
668  ilUtil::redirect('ilias.php?baseClass=ilPersonalDesktopGUI');
669  return;
670  }
671 
672  $this->ctrl->redirectByClass("ilpdnotesgui");
673  }
674 
678  function jumpToNews()
679  {
680  $this->ctrl->redirectByClass("ilpdnewsgui");
681  }
682 
686  function jumpToLP()
687  {
688  $this->ctrl->redirectByClass("illearningprogressgui");
689  }
690 
691  function __loadNextClass()
692  {
693  $stored_classes = array('ilpersonaldesktopgui',
694  'ilpersonalprofilegui',
695  'ilpdnotesgui',
696  'ilcalendarpresentationgui',
697  'ilbookmarkadministrationgui',
698  'illearningprogressgui');
699 
700  if(isset($_SESSION['il_pd_history']) and in_array($_SESSION['il_pd_history'],$stored_classes))
701  {
702  return $_SESSION['il_pd_history'];
703  }
704  else
705  {
706  $this->ctrl->getNextClass($this);
707  }
708  }
709  function __storeLastClass($a_class)
710  {
711  $_SESSION['il_pd_history'] = $a_class;
712  $this->cmdClass = $a_class;
713  }
714 
718  function initColumn($a_column_gui)
719  {
720  $pd_set = new ilSetting("pd");
721  if ($pd_set->get("enable_block_moving"))
722  {
723  $a_column_gui->setEnableMovement(true);
724  }
725  }
726 
730  function displayHeader()
731  {
732  //$this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"),
733  // $this->lng->txt("personal_desktop"));
734  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"),
735  "");
736  $this->tpl->setTitle($this->lng->txt("personal_desktop"));
737  }
738 
739 
740 }
741 ?>