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