ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilCalendarBlockGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2008 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/Block/classes/class.ilBlockGUI.php");
25 include_once './Services/Calendar/classes/class.ilCalendarCategories.php';
26 
41 {
42  public $ctrl = null;
43  protected $mode;
44  protected $display_mode;
45 
46  static $block_type = "cal";
47  static $st_data;
48 
54  function ilCalendarBlockGUI($a_skip_init = false)
55  {
56  global $ilCtrl, $lng, $ilUser, $tpl, $ilHelp;
57 
59 
60  $this->ctrl = $ilCtrl;
61  $this->setImage(ilUtil::getImagePath("icon_cals_s.png"));
62 
63  $lng->loadLanguageModule("dateplaner");
64  $ilHelp->addHelpSection("cal_block");
65 
66  include_once("./Services/News/classes/class.ilNewsItem.php");
67 
68  $ilCtrl->saveParameter($this, 'bkid');
69 
70  if (!$a_skip_init)
71  {
72  $this->initCategories();
73  $this->setBlockId($ilCtrl->getContextObjId());
74  }
75 
76  $this->setLimit(5); // @todo: needed?
77 
78  // alex: original detail level 1 did not work anymore
79  $this->setAvailableDetailLevels(1);
80  $this->setEnableNumInfo(false);
81 
82  if(!isset($_GET["bkid"]))
83  {
84  $title = $lng->txt("calendar");
85  }
86  else
87  {
88  $title = $lng->txt("cal_consultation_hours_for")." ".ilObjUser::_lookupFullname($_GET["bkid"]);
89  }
90 
91  $this->setTitle($title);
92  //$this->setData($data);
93  $this->allow_moving = false;
94  //$this->handleView();
95 
96  include_once('Services/Calendar/classes/class.ilDate.php');
97  include_once('Services/Calendar/classes/class.ilCalendarUserSettings.php');
98 
99  $seed_str = "";
100  if ((!isset($_GET["seed"]) || $_GET["seed"] == "") &&
101  isset($_SESSION["il_cal_block_".$this->getBlockType()."_".$this->getBlockId()."_seed"]))
102  {
103  $seed_str = $_SESSION["il_cal_block_".$this->getBlockType()."_".$this->getBlockId()."_seed"];
104  }
105  else if (isset($_GET["seed"]))
106  {
107  $seed_str = $_GET["seed"];
108  }
109 
110  if (isset($_GET["seed"]) && $_GET["seed"] != "")
111  {
112  $_SESSION["il_cal_block_".$this->getBlockType()."_".$this->getBlockId()."_seed"]
113  = $_GET["seed"];
114  }
115 
116  if ($seed_str == "")
117  {
118  $this->seed = new ilDate(time(),IL_CAL_UNIX); // @todo: check this
119  }
120  else
121  {
122  $this->seed = new ilDate($seed_str,IL_CAL_DATE); // @todo: check this
123  }
124  $this->user_settings = ilCalendarUserSettings::_getInstanceByUserId($ilUser->getId());
125 
126  $tpl->addCSS("./Services/Calendar/css/calendar.css");
127  // @todo: this must work differently...
128  $tpl->addCSS("./Services/Calendar/templates/default/delos.css");
129 
130  $mode = $ilUser->getPref("il_pd_cal_mode");
131  $this->display_mode = $mode ? $mode : "mmon";
132  }
133 
139  static function getBlockType()
140  {
141  return self::$block_type;
142  }
143 
149  static function isRepositoryObject()
150  {
151  return false;
152  }
153 
157  static function getScreenMode()
158  {
159  global $ilCtrl;
160 
161  $cmd_class = $ilCtrl->getCmdClass();
162 
163  if ($cmd_class == "ilcalendarappointmentgui" ||
164  $cmd_class == "ilcalendardaygui" ||
165  $cmd_class == "ilcalendarweekgui" ||
166  $cmd_class == "ilcalendarmonthgui" ||
167  $cmd_class == "ilcalendarinboxgui" ||
168  $cmd_class == "ilconsultationhoursgui" ||
169  $_GET['cmd'] == 'showCalendarSubscription')
170  {
171  return IL_SCREEN_CENTER;
172  }
173 
174  switch($ilCtrl->getCmd())
175  {
176  case "kkk":
177  // return IL_SCREEN_CENTER;
178  // return IL_SCREEN_FULL;
179 
180  default:
181  //return IL_SCREEN_SIDE;
182  break;
183  }
184  }
185 
189  function &executeCommand()
190  {
191  global $ilCtrl,$ilTabs;
192 
193  $next_class = $ilCtrl->getNextClass();
194  $cmd = $ilCtrl->getCmd("getHTML");
195 
196  $this->setSubTabs();
197 
198  switch ($next_class)
199  {
200  case "ilcalendarappointmentgui":
201  include_once('./Services/Calendar/classes/class.ilCalendarAppointmentGUI.php');
202  $app_gui = new ilCalendarAppointmentGUI($this->seed,$this->seed);
203  $ilCtrl->forwardCommand($app_gui);
204  break;
205 
206  case "ilcalendardaygui":
207  $ilTabs->setSubTabActive('app_day');
208  include_once('./Services/Calendar/classes/class.ilCalendarDayGUI.php');
209  $day_gui = new ilCalendarDayGUI($this->seed);
210  $ilCtrl->forwardCommand($day_gui);
211  break;
212 
213  case "ilcalendarweekgui":
214  $ilTabs->setSubTabActive('app_week');
215  include_once('./Services/Calendar/classes/class.ilCalendarWeekGUI.php');
216  $week_gui = new ilCalendarWeekGUI($this->seed);
217  $ilCtrl->forwardCommand($week_gui);
218  break;
219 
220  case "ilcalendarmonthgui":
221  $ilTabs->setSubTabActive('app_month');
222  include_once('./Services/Calendar/classes/class.ilCalendarMonthGUI.php');
223  $month_gui = new ilCalendarMonthGUI($this->seed);
224  $ilCtrl->forwardCommand($month_gui);
225  break;
226 
227  case "ilcalendarinboxgui":
228  include_once('./Services/Calendar/classes/class.ilCalendarInboxGUI.php');
229  $inbox = new ilCalendarInboxGUI($this->seed);
230  $ilCtrl->forwardCommand($inbox);
231  break;
232 
233  case "ilconsultationhoursgui":
234  include_once('./Services/Calendar/classes/ConsultationHours/class.ilConsultationHoursGUI.php');
235  $hours = new ilConsultationHoursGUI($this->seed);
236  $ilCtrl->forwardCommand($hours);
237  break;
238 
239  default:
240  return $this->$cmd();
241  }
242  }
243 
249  public function setEnableEdit($a_enable_edit = 0)
250  {
251  $this->enable_edit = $a_enable_edit;
252  }
253 
259  public function getEnableEdit()
260  {
261  return $this->enable_edit;
262  }
263 
267  function fillDataSection()
268  {
269  // alex: changed from > 1 to > 0 - original detail level 1 did not work anymore
270  if ($this->getCurrentDetailLevel() > 0 && $this->display_mode != "mmon")
271  {
272  $this->setColSpan(1);
273  $this->tpl->addBlockFile("BLOCK_ROW", "block_row","tpl.pd_event_list.html", "Services/Calendar");
274 
276  }
277  else
278  {
279  // alex: changed from > 1 to > 0 - original detail level 1 did not work anymore
280  if ($this->getCurrentDetailLevel() > 0)
281  {
282  $tpl = new ilTemplate("tpl.calendar_block.html", true, true,
283  "Services/Calendar");
284 
285  $this->addMiniMonth($tpl);
286  $this->setDataSection($tpl->get());
287  }
288  else
289  {
290  $this->setDataSection($this->getOverview());
291  }
292  }
293  }
294 
299  function addMiniMonth($a_tpl)
300  {
301  global $ilCtrl, $lng,$ilUser;
302 
303  // weekdays
304  include_once('Services/Calendar/classes/class.ilCalendarUtil.php');
305  $a_tpl->setCurrentBlock('month_header_col');
306  $a_tpl->setVariable('TXT_WEEKDAY', $lng->txt("cal_week_abbrev"));
307  $a_tpl->parseCurrentBlock();
308  for($i = (int) $this->user_settings->getWeekStart();$i < (7 + (int) $this->user_settings->getWeekStart());$i++)
309  {
310  $a_tpl->setCurrentBlock('month_header_col');
311  $a_tpl->setVariable('TXT_WEEKDAY',ilCalendarUtil::_numericDayToString($i,false));
312  $a_tpl->parseCurrentBlock();
313  }
314 
315  if(isset($_GET["bkid"]))
316  {
317  $user_id = $_GET["bkid"];
318  $disable_empty = true;
319  }
320  else
321  {
322  $user_id = $ilUser->getId();
323  $disable_empty = false;
324  }
325  include_once('Services/Calendar/classes/class.ilCalendarSchedule.php');
326  $this->scheduler = new ilCalendarSchedule($this->seed,ilCalendarSchedule::TYPE_MONTH,$user_id,$disable_empty);
327  $this->scheduler->addSubitemCalendars(true);
328  $this->scheduler->calculate();
329 
330  $counter = 0;
331  foreach(ilCalendarUtil::_buildMonthDayList($this->seed->get(IL_CAL_FKT_DATE,'m'),
332  $this->seed->get(IL_CAL_FKT_DATE,'Y'),
333  $this->user_settings->getWeekStart())->get() as $date)
334  {
335  $counter++;
336 
337  $events = $this->scheduler->getByDay($date,$ilUser->getTimeZone());
338  $has_events = (bool)count($events);
339  if($has_events || !$disable_empty)
340  {
341  $a_tpl->setCurrentBlock('month_col_link');
342  }
343  else
344  {
345  $a_tpl->setCurrentBlock('month_col_no_link');
346  }
347 
348  if($disable_empty)
349  {
350  if(!$has_events)
351  {
352  $a_tpl->setVariable('DAY_CLASS','calminiinactive');
353  }
354  else
355  {
356  $week_has_events = true;
357  include_once 'Services/Booking/classes/class.ilBookingEntry.php';
358  foreach($events as $event)
359  {
360  $booking = new ilBookingEntry($event['event']->getContextId());
361  if($booking->hasBooked($event['event']->getEntryId()))
362  {
363  $a_tpl->setVariable('DAY_CLASS','calminiapp');
364  break;
365  }
366  }
367  }
368  }
369  elseif($has_events)
370  {
371  $week_has_events = true;
372  $a_tpl->setVariable('DAY_CLASS','calminiapp');
373  }
374 
375 
376  $day = $date->get(IL_CAL_FKT_DATE,'j');
377  $month = $date->get(IL_CAL_FKT_DATE,'n');
378 
379  $month_day = $day;
380 
381  $ilCtrl->clearParametersByClass('ilcalendardaygui');
382  $ilCtrl->setParameterByClass('ilcalendardaygui','seed',$date->get(IL_CAL_DATE));
383  $a_tpl->setVariable('OPEN_DAY_VIEW', $ilCtrl->getLinkTargetByClass('ilcalendardaygui',''));
384  $ilCtrl->clearParametersByClass('ilcalendardaygui');
385 
386  $a_tpl->setVariable('MONTH_DAY',$month_day);
387 
388  $a_tpl->parseCurrentBlock();
389 
390 
391  $a_tpl->setCurrentBlock('month_col');
392 
393  include_once('./Services/Calendar/classes/class.ilCalendarUtil.php');
394  if(ilCalendarUtil::_isToday($date))
395  {
396  $a_tpl->setVariable('TD_CLASS','calminitoday');
397  }
398  #elseif(ilDateTime::_equals($date,$this->seed,IL_CAL_DAY))
399  #{
400  # $a_tpl->setVariable('TD_CLASS','calmininow');
401  #}
402  elseif(ilDateTime::_equals($date,$this->seed,IL_CAL_MONTH))
403  {
404  $a_tpl->setVariable('TD_CLASS','calministd');
405  }
406  elseif(ilDateTime::_before($date,$this->seed,IL_CAL_MONTH))
407  {
408  $a_tpl->setVariable('TD_CLASS','calminiprev');
409  }
410  else
411  {
412  $a_tpl->setVariable('TD_CLASS','calmininext');
413  }
414 
415  $a_tpl->parseCurrentBlock();
416 
417 
418  if($counter and !($counter % 7))
419  {
420  if(!$disable_empty || $week_has_events)
421  {
422  $a_tpl->setCurrentBlock('month_row_link');
423  $ilCtrl->clearParametersByClass('ilcalendarweekgui');
424  $ilCtrl->setParameterByClass('ilcalendarweekgui','seed',$date->get(IL_CAL_DATE));
425  $a_tpl->setVariable('OPEN_WEEK_VIEW', $ilCtrl->getLinkTargetByClass('ilcalendarweekgui',''));
426  $ilCtrl->clearParametersByClass('ilcalendarweekgui');
427  }
428  else
429  {
430  $a_tpl->setCurrentBlock('month_row_no_link');
431  $a_tpl->setVariable('WEEK_CLASS', 'calminiinactive');
432  }
433  $a_tpl->setVariable('WEEK',
434  $date->get(IL_CAL_FKT_DATE,'W'));
435  $a_tpl->parseCurrentBlock();
436 
437  $a_tpl->setCurrentBlock('month_row');
438  $a_tpl->setVariable('TD_CLASS','calminiweek');
439  $a_tpl->parseCurrentBlock();
440 
441  $week_has_events = false;
442  }
443  }
444  $a_tpl->setCurrentBlock('mini_month');
445  $a_tpl->setVariable('TXT_MONTH_OVERVIEW', $lng->txt("cal_month_overview"));
446  $a_tpl->setVariable('TXT_MONTH',
447  $lng->txt('month_'.$this->seed->get(IL_CAL_FKT_DATE,'m').'_long').
448  ' '.$this->seed->get(IL_CAL_FKT_DATE,'Y'));
449  $myseed = clone($this->seed);
450  $ilCtrl->setParameterByClass('ilcalendarmonthgui','seed',$myseed->get(IL_CAL_DATE));
451  $a_tpl->setVariable('OPEN_MONTH_VIEW',$ilCtrl->getLinkTargetByClass('ilcalendarmonthgui',''));
452 
453  $myseed->increment(ilDateTime::MONTH, -1);
454  $ilCtrl->setParameter($this,'seed',$myseed->get(IL_CAL_DATE));
455 
456  $a_tpl->setVariable('BL_TYPE', $this->getBlockType());
457  $a_tpl->setVariable('BL_ID', $this->getBlockId());
458 
459  $a_tpl->setVariable('PREV_MONTH',
460  $ilCtrl->getLinkTarget($this, "setSeed"));
461  $a_tpl->setVariable('PREV_MONTH_ASYNC',
462  $ilCtrl->getLinkTarget($this, "setSeed", "", true));
463 
464  $myseed->increment(ilDateTime::MONTH, 2);
465  $ilCtrl->setParameter($this,'seed',$myseed->get(IL_CAL_DATE));
466  $a_tpl->setVariable('NEXT_MONTH',
467  $ilCtrl->getLinkTarget($this, "setSeed"));
468  $a_tpl->setVariable('NEXT_MONTH_ASYNC',
469  $ilCtrl->getLinkTarget($this, "setSeed", "", true));
470 
471  $ilCtrl->setParameter($this, 'seed', "");
472  $a_tpl->parseCurrentBlock();
473  }
474 
478  function getHTML()
479  {
480  global $ilCtrl, $lng, $ilUser,$ilAccess;
481 
482  if ($this->getCurrentDetailLevel() == 0)
483  {
484  return "";
485  }
486 
487  // add edit commands
488  #if ($this->getEnableEdit())
489 
492  {
493  $this->addBlockCommand(
494  $this->ctrl->getLinkTarget($this,'showCalendarSubscription'),
495  $lng->txt('ical_export'),
496  '',
497  ilUtil::getImagePath('ical.png','Services/Calendar'),
498  true
499  );
500  }
501 
502 
503  if($this->mode == ilCalendarCategories::MODE_REPOSITORY)
504  {
505  if(!isset($_GET["bkid"]))
506  {
507  if($ilAccess->checkAccess('edit_event','',(int) $_GET['ref_id']))
508  {
509  $ilCtrl->setParameter($this, "add_mode", "block");
510  $this->addBlockCommand(
511  $ilCtrl->getLinkTargetByClass("ilCalendarAppointmentGUI",
512  "add"),
513  $lng->txt("add_appointment"));
514  $ilCtrl->setParameter($this, "add_mode", "");
515  }
516 
517  global $ilObjDataCache;
518 
519  include_once "Modules/Course/classes/class.ilCourseParticipants.php";
520  $obj_id = $ilObjDataCache->lookupObjId((int) $_GET['ref_id']);
521  $participants = ilCourseParticipants::_getInstanceByObjId($obj_id);
522  $users = array_unique(array_merge($participants->getTutors(), $participants->getAdmins()));
523 
524  include_once 'Services/Booking/classes/class.ilBookingEntry.php';
525  $users = ilBookingEntry::isBookable($users, $obj_id);
526  if($users)
527  {
528  foreach($users as $user_id)
529  {
530  if(!isset($_GET["bkid"]) || $_GET["bkid"] != $user_id)
531  {
532  $ilCtrl->setParameter($this, "bkid", $user_id);
533  $this->addBlockCommand(
534  $ilCtrl->getLinkTargetByClass("ilCalendarMonthGUI",
535  ""),
536  $lng->txt("cal_consultation_hours_for").' '.ilObjUser::_lookupFullname($user_id));
537  }
538  }
539  $ilCtrl->setParameter($this, "bkid", "");
540  }
541  }
542  else
543  {
544  $ilCtrl->setParameter($this, "bkid", "");
545  $this->addBlockCommand(
546  $ilCtrl->getLinkTarget($this),
547  $lng->txt("back"));
548  $ilCtrl->setParameter($this, "bkid", (int)$_GET["bkid"]);
549  }
550  }
551 
552  if ($this->getProperty("settings") == true)
553  {
554  $this->addBlockCommand(
555  $ilCtrl->getLinkTarget($this, "editSettings"),
556  $lng->txt("settings"));
557  }
558 
559  $ilCtrl->setParameterByClass("ilcolumngui", "seed", isset($_GET["seed"]) ? $_GET["seed"] : "");
560  $ret = parent::getHTML();
561  $ilCtrl->setParameterByClass("ilcolumngui", "seed", "");
562 
563  return $ret;
564  }
565 
569  function getOverview()
570  {
571  global $ilUser, $lng, $ilCtrl;
572 
573  include_once('./Services/Calendar/classes/class.ilCalendarSchedule.php');
574  $schedule = new ilCalendarSchedule($this->seed,ilCalendarSchedule::TYPE_INBOX);
575  $events = $schedule->getChangedEvents(true);
576 
577  $ilCtrl->setParameterByClass('ilcalendarinboxgui', 'changed', 1);
578  $link = '<a href='.$ilCtrl->getLinkTargetByClass('ilcalendarinboxgui','').'>';
579  $ilCtrl->setParameterByClass('ilcalendarinboxgui', 'changed', '');
580  $text = '<div class="small">'.((int) count($events))." ".$lng->txt("cal_changed_events_header")."</div>";
581  $end_link = '</a>';
582 
583  return $link.$text.$end_link;
584  }
585 
586  function addCloseCommand($a_content_block)
587  {
588  global $lng, $ilCtrl;
589 
590  $a_content_block->addHeaderCommand($ilCtrl->getParentReturn($this),
591  $lng->txt("close"), true);
592  }
593 
601  protected function initCategories()
602  {
604 
605  include_once('./Services/Calendar/classes/class.ilCalendarCategories.php');
606 
607  if(!isset($_GET['bkid']))
608  {
610  }
611  else
612  {
614  }
615  }
616 
622  protected function setSubTabs()
623  {
624  global $ilTabs;
625 
626  $ilTabs->clearSubTabs();
627  return true;
628 
629  // TODO: needs another switch
630  if($_GET['ref_id'])
631  {
632 
633  $ilTabs->addSubTabTarget('app_day',$this->ctrl->getLinkTargetByClass('ilCalendarDayGUI',''));
634  $ilTabs->addSubTabTarget('app_week',$this->ctrl->getLinkTargetByClass('ilCalendarWeekGUI',''));
635  $ilTabs->addSubTabTarget('app_month',$this->ctrl->getLinkTargetByClass('ilCalendarMonthGUI',''));
636  }
637  return true;
638  }
639 
643  function setSeed()
644  {
645  global $ilCtrl, $ilUser;
646 
647  //$ilUser->writePref("il_pd_bkm_mode", 'flat');
648  $_SESSION["il_cal_block_".$this->getBlockType()."_".$this->getBlockId()."_seed"] =
649  $_GET["seed"];
650  if ($ilCtrl->isAsynch())
651  {
652  echo $this->getHTML();
653  exit;
654  }
655  else
656  {
657  $this->returnToUpperContext();
658  }
659  }
660 
665  {
666  global $ilCtrl;
667 
668  $ilCtrl->returnToParent($this);
669  }
670 
671 
672  public function showCalendarSubscription()
673  {
674  global $lng, $ilUser;
675 
676  $tpl = new ilTemplate('tpl.show_calendar_subscription.html',true,true,'Services/Calendar');
677 
678  $tpl->setVariable('TXT_TITLE',$lng->txt('cal_subscription_header'));
679  $tpl->setVariable('TXT_INFO',$lng->txt('cal_subscription_info'));
680  $tpl->setVariable('TXT_CAL_URL',$lng->txt('cal_subscription_url'));
681 
682  include_once './Services/Calendar/classes/class.ilCalendarAuthenticationToken.php';
683 
684  switch($this->mode)
685  {
689  $calendar = 0;
690  break;
691 
692  default:
694  // TODO: calendar id
695  $calendar = ilObject::_lookupObjId((int) $_GET['ref_id']);
696  break;
697  }
698  if($hash = ilCalendarAuthenticationToken::lookupAuthToken($ilUser->getId(), $selection, $calendar))
699  {
700 
701  }
702  else
703  {
704  $token = new ilCalendarAuthenticationToken($ilUser->getId());
705  $token->setSelectionType($selection);
706  $token->setCalendar($calendar);
707  $hash = $token->add();
708  }
709  $url = ILIAS_HTTP_PATH.'/calendar.php?client_id='.CLIENT_ID.'&token='.$hash;
710 
711  $tpl->setVariable('VAL_CAL_URL',$url);
712  $tpl->setVariable('VAL_CAL_URL_TXT',$url);
713 
714  include_once("./Services/PersonalDesktop/classes/class.ilPDContentBlockGUI.php");
715  $content_block = new ilPDContentBlockGUI();
716  $content_block->setContent($tpl->get());
717  $content_block->setTitle($lng->txt("calendar"));
718  #$content_block->setImage(ilUtil::getImagePath("icon_news.png"));
719  $content_block->addHeaderCommand($this->ctrl->getParentReturn($this),
720  $lng->txt("selected_items_back"));
721 
722  return $content_block->getHTML();
723 
724  }
725 
726  function fillFooter()
727  {
728  global $ilCtrl, $lng, $ilUser;
729 
730  $this->setFooterLinks();
731  $this->fillFooterLinks();
732  $this->tpl->setVariable("FCOLSPAN", $this->getColSpan());
733  if ($this->tpl->blockExists("block_footer"))
734  {
735  $this->tpl->setCurrentBlock("block_footer");
736  $this->tpl->parseCurrentBlock();
737  }
738  }
739 
740  function setFooterLinks()
741  {
742  global $ilCtrl, $lng;
743 
744  // alex: changed from < 2 to < 1 - original detail level 1 did not work anymore
745  if ($this->getCurrentDetailLevel() < 1)
746  {
747  return;
748  }
749 
750 // if ($this->display_mode == 'mmon')
751 // {
752 // $this->addFooterLink($lng->txt("month"));
753 
754  $this->addFooterLink($lng->txt("cal_upcoming_events_header"),
755  $ilCtrl->getLinkTarget($this, "setPdModeEvents"),
756  $ilCtrl->getLinkTarget($this, "setPdModeEvents", "", true),
757  "block_".$this->getBlockType()."_".$this->block_id,
758  false, false, ($this->display_mode != 'mmon'));
759 
760 // }
761 // else
762 // {
763  $this->addFooterLink( $lng->txt("app_month"),
764  $ilCtrl->getLinkTarget($this, "setPdModeMonth"),
765  $ilCtrl->getLinkTarget($this, "setPdModeMonth", "", true),
766  "block_".$this->getBlockType()."_".$this->block_id,
767  false, false, ($this->display_mode == 'mmon'));
768 
769 // $this->addFooterLink($lng->txt("cal_upcoming_events_header"));
770 // }
771  }
772 
773  function setPdModeEvents()
774  {
775  global $ilUser, $ilCtrl;
776 
777  $ilUser->writePref("il_pd_cal_mode", "evt");
778  $this->display_mode = "evt";
779  if ($ilCtrl->isAsynch())
780  {
781  echo $this->getHTML();
782  exit;
783  }
784  else
785  {
786  $ilCtrl->redirectByClass("ilpersonaldesktopgui", "show");
787  }
788  }
789 
790  function setPdModeMonth()
791  {
792  global $ilUser, $ilCtrl;
793 
794  $ilUser->writePref("il_pd_cal_mode", "mmon");
795  $this->display_mode = "mmon";
796  if ($ilCtrl->isAsynch())
797  {
798  echo $this->getHTML();
799  exit;
800  }
801  else
802  {
803  $ilCtrl->redirectByClass("ilpersonaldesktopgui", "show");
804  }
805  }
806 
807  function getData()
808  {
809  global $ilCtrl, $lng;
810 
811  $seed = new ilDate(date('Y-m-d',time()),IL_CAL_DATE);
812 
813  include_once('./Services/Calendar/classes/class.ilCalendarSchedule.php');
815  $schedule->addSubitemCalendars(true); // #12007
816  $schedule->setEventsLimit(20);
817  $schedule->calculate();
818  $events = $schedule->getScheduledEvents(); // #13809
819 
820  $data = array();
821  if(sizeof($events))
822  {
823  foreach($events as $item)
824  {
825  $start = $item["dstart"];
826  $end = $item["dend"];
827  if($item["fullday"])
828  {
829  $start = new ilDate($start, IL_CAL_UNIX);
830  $end = new ilDate($end, IL_CAL_UNIX);
831  }
832  else
833  {
834  $start = new ilDateTime($start, IL_CAL_UNIX);
835  $end = new ilDateTime($end, IL_CAL_UNIX);
836  }
837 
838  $ilCtrl->clearParametersByClass('ilcalendardaygui');
839  $ilCtrl->setParameterByClass('ilcalendardaygui','seed', $start->get(IL_CAL_DATE));
840  $link = $ilCtrl->getLinkTargetByClass('ilcalendardaygui','');
841  $ilCtrl->clearParametersByClass('ilcalendardaygui');
842 
843  $data[] = array(
844  "date" => ilDatePresentation::formatPeriod($start, $end),
845  "title" => $item["event"]->getPresentationTitle(),
846  "url" => $link
847  );
848  }
849 
850  $this->setEnableNumInfo(true);
851  }
852  else
853  {
854  $data[] = array(
855  "date" => $lng->txt("msg_no_search_result"),
856  "title" => "",
857  "url" => ""
858  );
859 
860  $this->setEnableNumInfo(false);
861  }
862 
863  return $data;
864  }
865 }
866 
867 ?>