ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 __construct($a_skip_init = false)
55  {
56  global $ilCtrl, $lng, $ilUser, $tpl, $ilHelp;
57 
58  parent::__construct();
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->setRowTemplate("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::lookupBookableUsersForObject($obj_id,$users);
524  foreach($users as $user_id)
525  {
526  if(!isset($_GET["bkid"]))
527  {
528  include_once './Services/Calendar/classes/ConsultationHours/class.ilConsultationHourAppointments.php';
529  $now = new ilDateTime(time(), IL_CAL_UNIX);
530 
531  // default to last booking entry
532  $appointments = ilConsultationHourAppointments::getAppointments($user_id);
533  $next_app = end($appointments);
534  reset($appointments);
535 
536  foreach($appointments as $entry)
537  {
538  // find next entry
539  if(ilDateTime::_before($entry->getStart(), $now, IL_CAL_DAY))
540  {
541  continue;
542  }
543  include_once 'Services/Booking/classes/class.ilBookingEntry.php';
544  $booking_entry = new ilBookingEntry($entry->getContextId());
545  if(!in_array($obj_id, $booking_entry->getTargetObjIds()))
546  {
547  continue;
548  }
549 
550  if(!$booking_entry->isAppointmentBookableForUser($entry->getEntryId(), $GLOBALS['ilUser']->getId()))
551  {
552  continue;
553  }
554  $next_app = $entry;
555  break;
556  }
557 
558  $ilCtrl->setParameter($this, "bkid", $user_id);
559  if($next_app)
560  {
561  $ilCtrl->setParameter(
562  $this,
563  'seed',
564  (string) $next_app->getStart()->get(IL_CAL_DATE)
565  );
566  }
567 
568  $this->addBlockCommand(
569  $ilCtrl->getLinkTargetByClass(
570  "ilCalendarMonthGUI",
571  ""),
572  $lng->txt("cal_consultation_hours_for").' '. ilObjUser::_lookupFullname($user_id)
573  );
574 
575  $this->cal_footer[] = array(
576  'link' => $ilCtrl->getLinkTargetByClass('ilCalendarMonthGUI',''),
577  'txt' => $lng->txt("cal_consultation_hours_for").' '.ilObjUser::_lookupFullname($user_id)
578  );
579 
580  }
581  }
582  $ilCtrl->setParameter($this, "bkid", "");
583  $ilCtrl->setParameter($this, 'seed', '');
584  }
585  else
586  {
587  $ilCtrl->setParameter($this, "bkid", "");
588  $this->addBlockCommand(
589  $ilCtrl->getLinkTarget($this),
590  $lng->txt("back"));
591  $ilCtrl->setParameter($this, "bkid", (int)$_GET["bkid"]);
592  }
593  }
594 
595  if ($this->getProperty("settings") == true)
596  {
597  $this->addBlockCommand(
598  $ilCtrl->getLinkTarget($this, "editSettings"),
599  $lng->txt("settings"));
600  }
601 
602  $ilCtrl->setParameterByClass("ilcolumngui", "seed", isset($_GET["seed"]) ? $_GET["seed"] : "");
603  $ret = parent::getHTML();
604  $ilCtrl->setParameterByClass("ilcolumngui", "seed", "");
605 
606  return $ret;
607  }
608 
612  function getOverview()
613  {
614  global $ilUser, $lng, $ilCtrl;
615 
616  include_once('./Services/Calendar/classes/class.ilCalendarSchedule.php');
617  $schedule = new ilCalendarSchedule($this->seed,ilCalendarSchedule::TYPE_INBOX);
618  $events = $schedule->getChangedEvents(true);
619 
620  $ilCtrl->setParameterByClass('ilcalendarinboxgui', 'changed', 1);
621  $link = '<a href='.$ilCtrl->getLinkTargetByClass('ilcalendarinboxgui','').'>';
622  $ilCtrl->setParameterByClass('ilcalendarinboxgui', 'changed', '');
623  $text = '<div class="small">'.((int) count($events))." ".$lng->txt("cal_changed_events_header")."</div>";
624  $end_link = '</a>';
625 
626  return $link.$text.$end_link;
627  }
628 
629  function addCloseCommand($a_content_block)
630  {
631  global $lng, $ilCtrl;
632 
633  $a_content_block->addHeaderCommand($ilCtrl->getParentReturn($this),
634  $lng->txt("close"), true);
635  }
636 
644  protected function initCategories()
645  {
647 
648  include_once('./Services/Calendar/classes/class.ilCalendarCategories.php');
649 
650  if(!isset($_GET['bkid']))
651  {
653  }
654  else
655  {
656  // display consultation hours only (in course/group)
657  ilCalendarCategories::_getInstance()->setCHUserId((int) $_GET['bkid']);
658  ilCalendarCategories::_getInstance()->initialize(ilCalendarCategories::MODE_CONSULTATION,(int) $_GET['ref_id'],true);
659  }
660  }
661 
667  protected function setSubTabs()
668  {
669  global $ilTabs;
670 
671  $ilTabs->clearSubTabs();
672  return true;
673 
674  // TODO: needs another switch
675  if($_GET['ref_id'])
676  {
677 
678  $ilTabs->addSubTabTarget('app_day',$this->ctrl->getLinkTargetByClass('ilCalendarDayGUI',''));
679  $ilTabs->addSubTabTarget('app_week',$this->ctrl->getLinkTargetByClass('ilCalendarWeekGUI',''));
680  $ilTabs->addSubTabTarget('app_month',$this->ctrl->getLinkTargetByClass('ilCalendarMonthGUI',''));
681  }
682  return true;
683  }
684 
688  function setSeed()
689  {
690  global $ilCtrl, $ilUser;
691 
692  //$ilUser->writePref("il_pd_bkm_mode", 'flat');
693  $_SESSION["il_cal_block_".$this->getBlockType()."_".$this->getBlockId()."_seed"] =
694  $_GET["seed"];
695  if ($ilCtrl->isAsynch())
696  {
697  echo $this->getHTML();
698  exit;
699  }
700  else
701  {
702  $this->returnToUpperContext();
703  }
704  }
705 
710  {
711  global $ilCtrl;
712 
713  $ilCtrl->returnToParent($this);
714  }
715 
716 
717  public function showCalendarSubscription()
718  {
719  global $lng, $ilUser;
720 
721  $tpl = new ilTemplate('tpl.show_calendar_subscription.html',true,true,'Services/Calendar');
722 
723  $tpl->setVariable('TXT_TITLE',$lng->txt('cal_subscription_header'));
724  $tpl->setVariable('TXT_INFO',$lng->txt('cal_subscription_info'));
725  $tpl->setVariable('TXT_CAL_URL',$lng->txt('cal_subscription_url'));
726 
727  include_once './Services/Calendar/classes/class.ilCalendarAuthenticationToken.php';
728 
729  switch($this->mode)
730  {
734  $calendar = 0;
735  break;
736 
737  default:
739  // TODO: calendar id
740  $calendar = ilObject::_lookupObjId((int) $_GET['ref_id']);
741  break;
742  }
743  if($hash = ilCalendarAuthenticationToken::lookupAuthToken($ilUser->getId(), $selection, $calendar))
744  {
745 
746  }
747  else
748  {
749  $token = new ilCalendarAuthenticationToken($ilUser->getId());
750  $token->setSelectionType($selection);
751  $token->setCalendar($calendar);
752  $hash = $token->add();
753  }
754  $url = ILIAS_HTTP_PATH.'/calendar.php?client_id='.CLIENT_ID.'&token='.$hash;
755 
756  $tpl->setVariable('VAL_CAL_URL',$url);
757  $tpl->setVariable('VAL_CAL_URL_TXT',$url);
758 
759  include_once("./Services/PersonalDesktop/classes/class.ilPDContentBlockGUI.php");
760  $content_block = new ilPDContentBlockGUI();
761  $content_block->setContent($tpl->get());
762  $content_block->setTitle($lng->txt("calendar"));
763  $content_block->addHeaderCommand($this->ctrl->getParentReturn($this),
764  $lng->txt("selected_items_back"));
765 
766  return $content_block->getHTML();
767 
768  }
769 
770  function fillFooter()
771  {
772  global $ilCtrl, $lng, $ilUser;
773 
774  // begin-patch ch
775  foreach((array) $this->cal_footer as $link_info)
776  {
777  $this->tpl->setCurrentBlock('data_section');
778  $this->tpl->setVariable('DATA',
779  sprintf('<a href="%s">%s</a>',$link_info['link'],$link_info['txt'])
780 
781  );
782  $this->tpl->parseCurrentBlock();
783  }
784  // end-patch ch
785 
786  $this->setFooterLinks();
787  $this->fillFooterLinks();
788  $this->tpl->setVariable("FCOLSPAN", $this->getColSpan());
789  if ($this->tpl->blockExists("block_footer"))
790  {
791  $this->tpl->setCurrentBlock("block_footer");
792  $this->tpl->parseCurrentBlock();
793  }
794 
795  }
796 
797  function setFooterLinks()
798  {
799  global $ilCtrl, $lng;
800 
801  // alex: changed from < 2 to < 1 - original detail level 1 did not work anymore
802  if ($this->getCurrentDetailLevel() < 1)
803  {
804  return;
805  }
806 
807 // if ($this->display_mode == 'mmon')
808 // {
809 // $this->addFooterLink($lng->txt("month"));
810 
811  $this->addFooterLink($lng->txt("cal_upcoming_events_header"),
812  $ilCtrl->getLinkTarget($this, "setPdModeEvents"),
813  $ilCtrl->getLinkTarget($this, "setPdModeEvents", "", true),
814  "block_".$this->getBlockType()."_".$this->block_id,
815  false, false, ($this->display_mode != 'mmon'));
816 
817 // }
818 // else
819 // {
820  $this->addFooterLink( $lng->txt("app_month"),
821  $ilCtrl->getLinkTarget($this, "setPdModeMonth"),
822  $ilCtrl->getLinkTarget($this, "setPdModeMonth", "", true),
823  "block_".$this->getBlockType()."_".$this->block_id,
824  false, false, ($this->display_mode == 'mmon'));
825 
826 // $this->addFooterLink($lng->txt("cal_upcoming_events_header"));
827 // }
828  }
829 
830  function setPdModeEvents()
831  {
832  global $ilUser, $ilCtrl;
833 
834  $ilUser->writePref("il_pd_cal_mode", "evt");
835  $this->display_mode = "evt";
836  if ($ilCtrl->isAsynch())
837  {
838  echo $this->getHTML();
839  exit;
840  }
841  else
842  {
843  $ilCtrl->redirectByClass("ilpersonaldesktopgui", "show");
844  }
845  }
846 
847  function setPdModeMonth()
848  {
849  global $ilUser, $ilCtrl;
850 
851  $ilUser->writePref("il_pd_cal_mode", "mmon");
852  $this->display_mode = "mmon";
853  if ($ilCtrl->isAsynch())
854  {
855  echo $this->getHTML();
856  exit;
857  }
858  else
859  {
860  $ilCtrl->redirectByClass("ilpersonaldesktopgui", "show");
861  }
862  }
863 
864  function getData()
865  {
866  global $ilCtrl, $lng;
867 
868  $seed = new ilDate(date('Y-m-d',time()),IL_CAL_DATE);
869 
870  include_once('./Services/Calendar/classes/class.ilCalendarSchedule.php');
872  $schedule->addSubitemCalendars(true); // #12007
873  $schedule->setEventsLimit(20);
874  $schedule->calculate();
875  $events = $schedule->getScheduledEvents(); // #13809
876 
877  $data = array();
878  if(sizeof($events))
879  {
880  foreach($events as $item)
881  {
882  $start = $item["dstart"];
883  $end = $item["dend"];
884  if($item["fullday"])
885  {
887  $end = new ilDate($end, IL_CAL_UNIX);
888  }
889  else
890  {
892  $end = new ilDateTime($end, IL_CAL_UNIX);
893  }
894 
895  $ilCtrl->clearParametersByClass('ilcalendardaygui');
896  $ilCtrl->setParameterByClass('ilcalendardaygui','seed',$start->get(IL_CAL_DATE));
897  $link = $ilCtrl->getLinkTargetByClass('ilcalendardaygui','');
898  $ilCtrl->clearParametersByClass('ilcalendardaygui');
899 
900  $data[] = array(
901  "date" => ilDatePresentation::formatPeriod($start, $end),
902  "title" => $item["event"]->getPresentationTitle(),
903  "url" => $link
904  );
905  }
906 
907  $this->setEnableNumInfo(true);
908  }
909  else
910  {
911  $data[] = array(
912  "date" => $lng->txt("msg_no_search_result"),
913  "title" => "",
914  "url" => ""
915  );
916 
917  $this->setEnableNumInfo(false);
918  }
919 
920  return $data;
921  }
922 }
923 
924 ?>
static _buildMonthDayList($a_month, $a_year, $weekstart)
Build a month day list.
Consultation hours editor.
static get($a_type, $a_href="")
Get icon html.
$_SESSION["AccountId"]
addFooterLink($a_text, $a_href="", $a_onclick="", $a_block_id="", $a_top=false, $a_omit_separator=false, $a_checked=false)
Add a footer text/link.
static _numericDayToString($a_day, $a_long=true)
get
setDataSection($a_content)
Call this from overwritten fillDataSection(), if standard row based data is not used.
$_GET["client_id"]
static getScreenMode()
Get Screen Mode for current command.
static _lookupFullname($a_user_id)
Lookup Full Name.
static _getInstanceByUserId($a_user_id)
get singleton instance
static _before(ilDateTime $start, ilDateTime $end, $a_compare_field='', $a_tz='')
compare two dates and check start is before end This method does not consider tz offsets.
static formatPeriod(ilDateTime $start, ilDateTime $end)
Format a period of two date Shows: 14.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
$cmd
Definition: sahs_server.php:35
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
Booking definition.
setEnableEdit($a_enable_edit=0)
Set EnableEdit.
executeCommand()
execute command
fillFooterLinks($a_top=false, $a_numinfo="")
Fill footer links.
addBlockCommand($a_href, $a_text, $a_target="", $a_img="", $a_right_aligned=false, $a_checked=false, $a_html="")
Add Block Command.
static getBlockType()
Get block type.
const IL_CAL_MONTH
setEnableNumInfo($a_enablenuminfo)
Set Enable Item Number Info.
$url
Definition: shib_logout.php:72
const IL_CAL_UNIX
getHTML()
Get bloch HTML code.
global $tpl
Definition: ilias.php:8
global $ilCtrl
Definition: ilias.php:18
$counter
setColSpan($a_colspan)
Set Columns Span.
initCategories()
init categories
const IL_CAL_DAY
static _equals(ilDateTime $start, ilDateTime $end, $a_compare_field='', $a_tz='')
Check if two date are equal.
static lookupBookableUsersForObject($a_obj_id, $a_user_ids)
Consultation hours are offered if 1) consultation hour owner is admin or tutor and no object assignme...
returnToUpperContext()
Return to upper context.
Class for single dates.
fillDataSection()
Fill data section.
setTitle($a_title)
Set Title.
setBlockId($a_block_id=0)
Set Block Id.
static getAppointments($a_user_id)
Get all appointments.
static _lookupObjId($a_id)
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
special template class to simplify handling of ITX/PEAR
setAvailableDetailLevels($a_max, $a_min=0)
Set Available Detail Levels.
const IL_CAL_FKT_DATE
Date and time handling
$ilUser
Definition: imgupload.php:18
addCloseCommand($a_content_block)
const IL_SCREEN_CENTER
static _getInstance($a_usr_id=0)
get singleton instance
Create styles array
The data for the language used.
__construct($a_skip_init=false)
Constructor.
getBlockId()
Get Block Id.
setLimit($a_limit)
Set Limit.
const IL_CAL_DATE
Administrate calendar appointments.
Calendar blocks, displayed in different contexts, e.g.
global $lng
Definition: privfeed.php:17
getEnableEdit()
Get EnableEdit.
static lookupAuthToken($a_user_id, $a_selection, $a_calendar=0)
getColSpan()
Get Columns Span.
$ret
Definition: parser.php:6
$text
static isRepositoryObject()
Is this a repository object.
This class represents a block method of a block.
Handles calendar authentication tokens for external calendar subscriptions.
addMiniMonth($a_tpl)
Add mini version of monthly overview (Maybe extracted to another class, if used in pd calendar tab...
BlockGUI class for (centered) Content on Personal Desktop.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
fillDataSection()
Standard implementation for row based data.
setRowTemplate($a_rowtemplatename, $a_rowtemplatedir="")
Set Row Template Name.
static _isToday($date)
check if a date is today
Presentation day view.
getProperty($a_property)
getCurrentDetailLevel()
Get Current Detail Level.
Represents a list of calendar appointments (including recurring events) for a specific user in a give...