ILIAS  Release_3_10_x_branch Revision 61812
 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-2005 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 
40 {
41  var $tpl;
42  var $lng;
43  var $ilias;
44 
45  var $cmdClass = '';
46 
51  {
52  global $ilias, $tpl, $lng, $rbacsystem, $ilCtrl, $ilMainMenu, $ilUser, $tree;
53 
54 
55  $this->tpl =& $tpl;
56  $this->lng =& $lng;
57  $this->ilias =& $ilias;
58  $this->ctrl =& $ilCtrl;
59 
60  $ilCtrl->setContext($ilUser->getId(),
61  "user");
62 
63  $ilMainMenu->setActive("desktop");
64  $this->lng->loadLanguageModule("pdesk");
65 
66  // catch hack attempts
67  if ($_SESSION["AccountId"] == ANONYMOUS_USER_ID)
68  {
69  $this->ilias->raiseError($this->lng->txt("msg_not_available_for_anon"),$this->ilias->error_obj->MESSAGE);
70  }
71  $this->cmdClass = $_GET['cmdClass'];
72 
73  //$tree->useCache(false);
74  }
75 
79  function &executeCommand()
80  {
81  global $ilUser, $ilSetting;
82 
83  $next_class = $this->ctrl->getNextClass();
84  $this->ctrl->setReturn($this, "show");
85 
86  $this->tpl->addCss(ilUtil::getStyleSheetLocation('filesystem','delos.css','Services/Calendar'));
87 
88 
89  // check whether personal profile of user is incomplete
90  if ($ilUser->getProfileIncomplete() && $next_class != "ilpersonalprofilegui")
91  {
92  $this->ctrl->redirectByClass("ilpersonalprofilegui");
93  }
94 
95  // check whether password of user have to be changed due to first login
96  if( $ilUser->isPasswordChangeDemanded() && $next_class != "ilpersonalprofilegui" )
97  {
98  ilUtil::sendInfo( $this->lng->txt('password_change_on_first_login_demand'), true );
99 
100  $this->ctrl->redirectByClass("ilpersonalprofilegui");
101  }
102 
103  // check whether password of user is expired
104  if( $ilUser->isPasswordExpired() && $next_class != "ilpersonalprofilegui" )
105  {
106  $msg = $this->lng->txt('password_expired');
107  $password_age = $ilUser->getPasswordAge();
108 
109  ilUtil::sendInfo( sprintf($msg,$password_age), true );
110 
111  $this->ctrl->redirectByClass("ilpersonalprofilegui");
112  }
113 
114  // read last active subsection
115  if($_GET['PDHistory'])
116  {
117  $next_class = $this->__loadNextClass();
118  }
119  $this->__storeLastClass($next_class);
120 
121  switch($next_class)
122  {
123  //Feedback
124  case "ilfeedbackgui":
125  $this->getStandardTemplates();
126  $this->setTabs();
127  $this->tpl->setTitle($this->lng->txt("personal_desktop"));
128  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"),
129  $this->lng->txt("personal_desktop"));
130 
131  include_once("Services/Feedback/classes/class.ilFeedbackGUI.php");
132  $feedback_gui = new ilFeedbackGUI();
133  $ret =& $this->ctrl->forwardCommand($feedback_gui);
134  break;
135  // bookmarks
136  case "ilbookmarkadministrationgui":
137  if ($ilSetting->get('disable_bookmarks'))
138  {
139  ilUtil::sendInfo($this->lng->txt('permission_denied'), true);
140  ilUtil::redirect('ilias.php?baseClass=ilPersonalDesktopGUI');
141  return;
142  }
143 
144  include_once("./Services/PersonalDesktop/classes/class.ilBookmarkAdministrationGUI.php");
145  $bookmark_gui = new ilBookmarkAdministrationGUI();
146  if ($bookmark_gui->getMode() == 'tree') {
147  $this->getTreeModeTemplates();
148  } else {
149  $this->getStandardTemplates();
150  }
151  $this->setTabs();
152  $ret =& $this->ctrl->forwardCommand($bookmark_gui);
153  break;
154 
155  // profile
156  case "ilpersonalprofilegui":
157  $this->getStandardTemplates();
158  $this->setTabs();
159  include_once("./Services/User/classes/class.ilPersonalProfileGUI.php");
160  $profile_gui = new ilPersonalProfileGUI();
161  $ret =& $this->ctrl->forwardCommand($profile_gui);
162  break;
163 
164  // profile
165  case "ilobjusergui":
166  include_once('./Services/User/classes/class.ilObjUserGUI.php');
167  $user_gui = new ilObjUserGUI("",$_GET["user"], false, false);
168  $ret =& $this->ctrl->forwardCommand($user_gui);
169  break;
170 
171  case 'ilcalendarpresentationgui':
172  $this->getStandardTemplates();
173  $this->displayHeader();
174  $this->setTabs();
175  include_once('./Services/Calendar/classes/class.ilCalendarPresentationGUI.php');
176  $cal = new ilCalendarPresentationGUI();
177  $ret = $this->ctrl->forwardCommand($cal);
178  $this->tpl->show();
179  break;
180 
181  // pd notes
182  case "ilpdnotesgui":
183  if ($ilSetting->get('disable_notes'))
184  {
185  ilUtil::sendInfo($this->lng->txt('permission_denied'), true);
186  ilUtil::redirect('ilias.php?baseClass=ilPersonalDesktopGUI');
187  return;
188  }
189 
190  $this->getStandardTemplates();
191  $this->setTabs();
192  include_once("./Services/Notes/classes/class.ilPDNotesGUI.php");
193  $pd_notes_gui = new ilPDNotesGUI();
194  $ret =& $this->ctrl->forwardCommand($pd_notes_gui);
195  break;
196 
197  // pd news
198  case "ilpdnewsgui":
199  $this->getStandardTemplates();
200  $this->setTabs();
201  include_once("./Services/News/classes/class.ilPDNewsGUI.php");
202  $pd_news_gui = new ilPDNewsGUI();
203  $ret =& $this->ctrl->forwardCommand($pd_news_gui);
204  break;
205 
206  case "illearningprogressgui":
207  $this->getStandardTemplates();
208  $this->setTabs();
209  include_once './Services/Tracking/classes/class.ilLearningProgressGUI.php';
211  $ret =& $this->ctrl->forwardCommand($new_gui);
212 
213  break;
214 
215  case "ilcolumngui":
216  $this->getStandardTemplates();
217  $this->setTabs();
218  include_once("./Services/Block/classes/class.ilColumnGUI.php");
219  $column_gui = new ilColumnGUI("pd");
220  $this->initColumn($column_gui);
221  $this->show();
222  break;
223 
224  default:
225  $this->getStandardTemplates();
226  $this->setTabs();
227  $cmd = $this->ctrl->getCmd("show");
228  $this->$cmd();
229  break;
230  }
231  return true;
232  }
233 
238  {
239  // add template for content
240  $this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
241  $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
242  $this->tpl->addBlockFile("LOCATOR", "locator", "tpl.locator.html");
243  }
244 
249  {
250  // add template for content
251  //$this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_tree_content.html");
252  $this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
253  $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
254  $this->tpl->addBlockFile("LOCATOR", "locator", "tpl.locator.html");
255  }
256 
260  function show()
261  {
262 
263  // add template for content
264  $this->pd_tpl = new ilTemplate("tpl.usr_personaldesktop.html", true, true);
265  $this->tpl->getStandardTemplate();
266 
267  // catch feedback message
269 
270  // display infopanel if something happened
272 
273  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"),
274  $this->lng->txt("personal_desktop"));
275  $this->tpl->setTitle($this->lng->txt("personal_desktop"));
276  $this->tpl->setVariable("IMG_SPACE", ilUtil::getImagePath("spacer.gif", false));
277 
278  $this->tpl->setContent($this->getCenterColumnHTML());
279  $this->tpl->setRightContent($this->getRightColumnHTML());
280  $this->tpl->setLeftContent($this->getLeftColumnHTML());
281  $this->tpl->show();
282  }
283 
284 
289  {
290  global $ilCtrl;
291 
292  include_once("Services/Block/classes/class.ilColumnGUI.php");
293  $column_gui = new ilColumnGUI("pd", IL_COL_CENTER);
294  $this->initColumn($column_gui);
295 
296  if ($ilCtrl->getNextClass() == "ilcolumngui" &&
297  $column_gui->getCmdSide() == IL_COL_CENTER)
298  {
299  $html = $ilCtrl->forwardCommand($column_gui);
300  }
301  else
302  {
303  if (!$ilCtrl->isAsynch())
304  {
305  if ($column_gui->getScreenMode() != IL_SCREEN_SIDE)
306  {
307  // right column wants center
308  if ($column_gui->getCmdSide() == IL_COL_RIGHT)
309  {
310  $column_gui = new ilColumnGUI("pd", IL_COL_RIGHT);
311  $this->initColumn($column_gui);
312  $html = $ilCtrl->forwardCommand($column_gui);
313  }
314  // left column wants center
315  if ($column_gui->getCmdSide() == IL_COL_LEFT)
316  {
317  $column_gui = new ilColumnGUI("pd", IL_COL_LEFT);
318  $this->initColumn($column_gui);
319  $html = $ilCtrl->forwardCommand($column_gui);
320  }
321  }
322  else
323  {
324  $html = $ilCtrl->getHTML($column_gui);
325  }
326  }
327  }
328  return $html;
329  }
330 
335  {
336  global $ilUser, $lng, $ilCtrl;
337 
338  include_once("Services/Block/classes/class.ilColumnGUI.php");
339  $column_gui = new ilColumnGUI("pd", IL_COL_RIGHT);
340  $this->initColumn($column_gui);
341 
342  if ($ilCtrl->getNextClass() == "ilcolumngui" &&
343  $column_gui->getCmdSide() == IL_COL_RIGHT &&
344  $column_gui->getScreenMode() == IL_SCREEN_SIDE)
345  {
346  $html = $ilCtrl->forwardCommand($column_gui);
347  }
348  else
349  {
350  if (!$ilCtrl->isAsynch())
351  {
352  $html = $ilCtrl->getHTML($column_gui);
353  }
354  }
355 
356  return $html;
357  }
358 
362  function getLeftColumnHTML()
363  {
364  global $ilUser, $lng, $ilCtrl;
365 
366  include_once("Services/Block/classes/class.ilColumnGUI.php");
367  $column_gui = new ilColumnGUI("pd", IL_COL_LEFT);
368  $this->initColumn($column_gui);
369 
370  if ($ilCtrl->getNextClass() == "ilcolumngui" &&
371  $column_gui->getCmdSide() == IL_COL_LEFT &&
372  $column_gui->getScreenMode() == IL_SCREEN_SIDE)
373  {
374  $html = $ilCtrl->forwardCommand($column_gui);
375  }
376  else
377  {
378  if (!$ilCtrl->isAsynch())
379  {
380  $html = $ilCtrl->getHTML($column_gui);
381  }
382  }
383 
384  return $html;
385  }
386 
388  {
389  // add template for content
390  $this->pd_tpl = new ilTemplate("tpl.usr_personaldesktop.html", true, true);
391  $this->tpl->getStandardTemplate();
392 
393  // catch feedback message
395 
396  // display infopanel if something happened
398 
399  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"),
400  $this->lng->txt("personal_desktop"));
401  $this->tpl->setTitle($this->lng->txt("personal_desktop"));
402  $this->tpl->setVariable("IMG_SPACE", ilUtil::getImagePath("spacer.gif", false));
403  }
404 
408  function dropItem()
409  {
410  global $ilUser;
411 
412  $ilUser->dropDesktopItem($_GET["item_ref_id"], $_GET["type"]);
413  $this->show();
414  }
415 
419  function addItem()
420  {
421  global $ilUser;
422 
423  $ilUser->addDesktopItem($_GET["item_ref_id"], $_GET["type"]);
424  $this->show();
425  }
426 
430  function removeMember()
431  {
432  global $err_msg;
433  if (strlen($err_msg) > 0)
434  {
435  $this->ilias->raiseError($this->lng->txt($err_msg),$this->ilias->error_obj->MESSAGE);
436  }
437  $this->show();
438  }
439 
444  {
445  include_once("Services/Mail/classes/class.ilPDSysMessageBlockGUI.php");
446  $sys_block = new ilPDSysMessageBlockGUI("ilpersonaldesktopgui", "show");
447  return $sys_block->getHTML();
448  }
449 
450 
454  function displayFeedback()
455  {
456  include_once("./Services/Feedback/classes/class.ilPDFeedbackBlockGUI.php");
457  $fb_block = new ilPDFeedbackBlockGUI("ilpersonaldesktopgui", "show");
458  return $fb_block->getHTML();
459 
460  include_once('Services/Feedback/classes/class.ilFeedbackGUI.php');
461  $feedback_gui = new ilFeedbackGUI();
462  return $feedback_gui->getPDFeedbackListHTML();
463  }
464 
475  function multiarray_sort ($array, $key_sort)
476  {
477  if ($array) {
478  $key_sorta = explode(";", $key_sort);
479 
480  $multikeys = array_keys($array);
481  $keys = array_keys($array[$multikeys[0]]);
482 
483  for($m=0; $m < count($key_sorta); $m++) {
484  $nkeys[$m] = trim($key_sorta[$m]);
485  }
486  $n += count($key_sorta);
487 
488  for($i=0; $i < count($keys); $i++){
489  if(!in_array($keys[$i], $key_sorta)) {
490  $nkeys[$n] = $keys[$i];
491  $n += "1";
492  }
493  }
494 
495  for($u=0;$u<count($array); $u++) {
496  $arr = $array[$multikeys[$u]];
497  for($s=0; $s<count($nkeys); $s++) {
498  $k = $nkeys[$s];
499  $output[$multikeys[$u]][$k] = $array[$multikeys[$u]][$k];
500  }
501  }
502  sort($output);
503  return $output;
504  }
505  }
506 
510  function setTabs()
511  {
512  global $ilCtrl, $ilSetting;
513 
514  $this->tpl->addBlockFile("TABS", "tabs", "tpl.tabs.html");
515 
516  $script_name = basename($_SERVER["SCRIPT_NAME"]);
517 
518  $command = $_GET["cmd"] ? $_GET["cmd"] : "";
519 
520  if (ereg("whois",$command))
521  {
522  $who_is_online = true;
523  }
524 
525  // to do: use ilTabsGUI here!
526 
527  // personal desktop home
528  $inc_type = (strtolower($_GET["baseClass"]) == "ilpersonaldesktopgui" &&
529  (strtolower($this->cmdClass) == "ilpersonaldesktopgui" ||
530  $this->cmdClass == "" || (strtolower($this->cmdClass)) == "ilfeedbackgui"
531  || $ilCtrl->getNextClass() == "ilcolumngui"))
532  ? "tabactive"
533  : "tabinactive";
534  $inhalt1[] = array($inc_type, $this->ctrl->getLinkTarget($this), $this->lng->txt("overview"));
535 
536  // user profile
537  $inc_type = (strtolower($this->cmdClass) == "ilpersonalprofilegui")
538  ? "tabactive"
539  : "tabinactive";
540 
541  $inhalt1[] = array($inc_type, $this->ctrl->getLinkTargetByClass("ilPersonalProfileGUI"),
542  $this->lng->txt("personal_profile"));
543 
544  if ($_SESSION["AccountId"] != ANONYMOUS_USER_ID)
545  {
546  // news
547  if ($ilSetting->get("block_activated_news"))
548  {
549  $inc_type = ($ilCtrl->getNextClass() == "ilpdnewsgui")
550  ? "tabactive"
551  : "tabinactive";
552 
553  $inhalt1[] = array($inc_type,
554  $this->ctrl->getLinkTargetByClass("ilpdnewsgui"),
555  $this->lng->txt("news"));
556  }
557 
558  // new calendar
559  include_once('./Services/Calendar/classes/class.ilCalendarSettings.php');
560  $settings = ilCalendarSettings::_getInstance();
561  if($settings->isEnabled())
562  {
563  $inc_type = (strtolower($this->cmdClass) == "ilcalendarpresentationgui")
564  ? "tabactive"
565  : "tabinactive";
566 
567  $inhalt1[] = array($inc_type,
568  $this->ctrl->getLinkTargetByClass("ilcalendarpresentationgui"),
569  $this->lng->txt("calendar"));
570  }
571 
572  // private notes
573  if (!$this->ilias->getSetting("disable_notes"))
574  {
575  $inc_type = (strtolower($this->cmdClass) == "ilpdnotesgui" ||
576  strtolower($this->cmdClass) == "ilnotegui")
577  ? "tabactive"
578  : "tabinactive";
579  $inhalt1[] = array($inc_type,
580  $this->ctrl->getLinkTargetByClass("ilpdnotesgui"),
581  $this->lng->txt("private_notes"));
582  }
583 
584  // user bookmarks
585  if (!$this->ilias->getSetting("disable_bookmarks"))
586  {
587  $inc_type = (strtolower($this->cmdClass) == "ilbookmarkadministrationgui")
588  ? "tabactive"
589  : "tabinactive";
590  $inhalt1[] = array($inc_type,
591  $this->ctrl->getLinkTargetByClass("ilbookmarkadministrationgui"),
592  $this->lng->txt("bookmarks"));
593  }
594  }
595 
596  // Tracking
597 
598  include_once("Services/Tracking/classes/class.ilObjUserTracking.php");
600  {
601  $cmd_classes = array('illplistofobjectsgui','illplistofsettingsgui','illearningprogressgui','illplistofprogressgui');
602  $inc_type = in_array(strtolower($this->cmdClass),$cmd_classes) ? 'tabactive' : 'tabinactive';
603 
604  $inhalt1[] = array($inc_type, $this->ctrl->getLinkTargetByClass("ilLearningProgressGUI"),
605  $this->lng->txt("learning_progress"));
606  }
607 
608  for ( $i=0; $i<sizeof($inhalt1); $i++)
609  {
610  if ($inhalt1[$i][1] != "")
611  { $this->tpl->setCurrentBlock("tab");
612  $this->tpl->setVariable("TAB_TYPE",$inhalt1[$i][0]);
613  $this->tpl->setVariable("TAB_LINK",$inhalt1[$i][1]);
614  $this->tpl->setVariable("TAB_TEXT",$inhalt1[$i][2]);
615  $this->tpl->setVariable("TAB_TARGET",$inhalt1[$i][3]);
616  $this->tpl->parseCurrentBlock();
617  }
618  }
619 
620  $this->tpl->setCurrentBlock("tabs");
621  $this->tpl->parseCurrentBlock();
622  }
623 
627  function jumpToProfile()
628  {
629  $this->ctrl->redirectByClass("ilpersonalprofilegui");
630  }
631 
635  function jumpToBookmarks()
636  {
637  if ($this->ilias->getSetting("disable_bookmarks"))
638  {
639  ilUtil::sendInfo($this->lng->txt('permission_denied'), true);
640  ilUtil::redirect('ilias.php?baseClass=ilPersonalDesktopGUI');
641  return;
642  }
643 
644  $this->ctrl->redirectByClass("ilbookmarkadministrationgui");
645  }
646 
650  function jumpToNotes()
651  {
652  if ($this->ilias->getSetting('disable_notes'))
653  {
654  ilUtil::sendInfo($this->lng->txt('permission_denied'), true);
655  ilUtil::redirect('ilias.php?baseClass=ilPersonalDesktopGUI');
656  return;
657  }
658 
659  $this->ctrl->redirectByClass("ilpdnotesgui");
660  }
661 
665  function jumpToNews()
666  {
667  $this->ctrl->redirectByClass("ilpdnewsgui");
668  }
669 
673  function jumpToLP()
674  {
675  $this->ctrl->redirectByClass("illearningprogressgui");
676  }
677 
678  function __loadNextClass()
679  {
680  $stored_classes = array('ilpersonaldesktopgui',
681  'ilpersonalprofilegui',
682  'ilpdnotesgui',
683  'ilcalendarpresentationgui',
684  'ilbookmarkadministrationgui',
685  'illearningprogressgui');
686 
687  if(isset($_SESSION['il_pd_history']) and in_array($_SESSION['il_pd_history'],$stored_classes))
688  {
689  return $_SESSION['il_pd_history'];
690  }
691  else
692  {
693  $this->ctrl->getNextClass($this);
694  }
695  }
696  function __storeLastClass($a_class)
697  {
698  $_SESSION['il_pd_history'] = $a_class;
699  $this->cmdClass = $a_class;
700  }
701 
705  function initColumn($a_column_gui)
706  {
707  $pd_set = new ilSetting("pd");
708  if ($pd_set->get("enable_block_moving"))
709  {
710  $a_column_gui->setEnableMovement(true);
711  }
712  }
713 
717  function displayHeader()
718  {
719  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"),
720  $this->lng->txt("personal_desktop"));
721  $this->tpl->setTitle($this->lng->txt("personal_desktop"));
722  }
723 
724 
725 }
726 ?>