/**
  * Book an appointment. All checks (assignment possible, max booking) must be done before
  * @param type $a_usr_id
  * @param type $a_app_id
  * @return bool
  */
 public static function bookAppointment($a_usr_id, $a_app_id)
 {
     global $lng;
     // Create new default consultation hour calendar
     include_once './Services/Language/classes/class.ilLanguageFactory.php';
     $cal_lang = ilLanguageFactory::_getLanguage($lng->getDefaultLanguage());
     $cal_lang->loadLanguageModule('dateplaner');
     include_once './Services/Calendar/classes/class.ilCalendarUtil.php';
     include_once './Services/Calendar/classes/class.ilCalendarCategory.php';
     $ch = ilCalendarUtil::initDefaultCalendarByType(ilCalendarCategory::TYPE_CH, $a_usr_id, $cal_lang->txt('cal_ch_personal_ch'), true);
     // duplicate appointment
     include_once './Services/Calendar/classes/class.ilCalendarEntry.php';
     $app = new ilCalendarEntry($a_app_id);
     $personal_app = clone $app;
     $personal_app->save();
     // assign appointment to category
     include_once './Services/Calendar/classes/class.ilCalendarCategoryAssignments.php';
     $assignment = new ilCalendarCategoryAssignments($personal_app->getEntryId());
     $assignment->addAssignment($ch->getCategoryID());
     // book appointment
     include_once './Services/Booking/classes/class.ilBookingEntry.php';
     $booking = new ilBookingEntry($app->getContextId());
     $booking->book($app->getEntryId(), $a_usr_id);
     return true;
 }
 /**
  * Create new ILIAS account
  *
  * @access public
  * 
  * @param string external username
  */
 public function create($a_username, $a_userdata = array())
 {
     $a_userdata = $this->parseFullname($a_userdata);
     $this->writer->xmlStartTag('Users');
     // Single users
     // Required fields
     // Create user
     $this->writer->xmlStartTag('User', array('Action' => 'Insert'));
     $this->writer->xmlElement('Login', array(), $new_name = ilAuthUtils::_generateLogin($a_username));
     // Assign to role only for new users
     $this->writer->xmlElement('Role', array('Id' => $this->settings->getDefaultRole(), 'Type' => 'Global', 'Action' => 'Assign'), '');
     if (isset($a_userdata['email'])) {
         $this->writer->xmlElement('Email', array(), $a_userdata['email']);
     }
     if (isset($a_userdata['postcode'])) {
         $this->writer->xmlElement('PostalCode', array(), $a_userdata['postcode']);
     }
     if (isset($a_userdata['dob']) and $a_userdata['dob']) {
         $this->writer->xmlElement('Birthday', array(), $a_userdata['dob']);
     }
     if (isset($a_userdata['gender'])) {
         $this->writer->xmlElement('Gender', array(), strtolower($a_userdata['gender']));
     }
     if (isset($a_userdata['title'])) {
         $this->writer->xmlElement('Title', array(), $a_userdata['title']);
     }
     if (isset($a_userdata['firstname'])) {
         $this->writer->xmlElement('Firstname', array(), $a_userdata['firstname']);
     }
     if (isset($a_userdata['lastname'])) {
         $this->writer->xmlElement('Lastname', array(), $a_userdata['lastname']);
     }
     $this->writer->xmlElement('Active', array(), "true");
     $this->writer->xmlElement('TimeLimitOwner', array(), 7);
     $this->writer->xmlElement('TimeLimitUnlimited', array(), 1);
     $this->writer->xmlElement('TimeLimitFrom', array(), time());
     $this->writer->xmlElement('TimeLimitUntil', array(), time());
     $this->writer->xmlElement('AuthMode', array('type' => 'openid'), 'openid');
     $this->writer->xmlElement('ExternalAccount', array(), $a_username);
     $this->writer->xmlEndTag('User');
     $this->writer->xmlEndTag('Users');
     $this->log->write('OpenId: Started creation of user: '******'./Services/User/classes/class.ilUserImportParser.php';
     $importParser = new ilUserImportParser();
     $importParser->setXMLContent($this->writer->xmlDumpMem(false));
     $importParser->setRoleAssignment(array($this->settings->getDefaultRole() => $this->settings->getDefaultRole()));
     $importParser->setFolderId(7);
     $importParser->startParsing();
     // Assign timezone
     if (isset($a_userdata['timezone'])) {
         include_once './Services/Calendar/classes/class.ilCalendarUtil.php';
         $tzs = ilCalendarUtil::_getShortTimeZoneList();
         if (isset($tzs[$a_userdata['timezone']])) {
             $usr_id = ilObjUser::_lookupId($new_name);
             ilObjUser::_writePref($usr_id, 'user_tz', $a_userdata['timezone']);
         }
     }
     return $new_name;
 }
 protected function viewToolbar($a_is_initial = false)
 {
     global $ilToolbar, $lng, $ilCtrl;
     $current_figure = (int) $_POST["fig"];
     $current_time_frame = (string) $_POST["tfr"];
     $current_scope = (int) $_POST["scp"];
     include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
     $view = new ilSelectInputGUI($lng->txt("wiki_stat_figure"), "fig");
     $view->setOptions($this->page_id ? ilWikiStat::getFigureOptionsPage() : ilWikiStat::getFigureOptions());
     if ($current_figure) {
         $view->setValue($current_figure);
     } else {
         if ($a_is_initial) {
             // default
             $current_figure = $this->page_id ? ilWikiStat::KEY_FIGURE_WIKI_PAGE_CHANGES : ilWikiStat::KEY_FIGURE_WIKI_NUM_PAGES;
         }
     }
     $ilToolbar->addInputItem($view, true);
     $options = array();
     include_once "Services/Calendar/classes/class.ilCalendarUtil.php";
     $lng->loadLanguageModule("dateplaner");
     foreach (ilWikiStat::getAvailableMonths($this->wiki_id) as $month) {
         $parts = explode("-", $month);
         $options[$month] = ilCalendarUtil::_numericMonthToString((int) $parts[1]) . " " . $parts[0];
     }
     krsort($options);
     $tframe = new ilSelectInputGUI($lng->txt("month"), "tfr");
     $tframe->setOptions($options);
     if ($current_time_frame) {
         $tframe->setValue($current_time_frame);
     } else {
         if ($a_is_initial) {
             $current_time_frame = array_shift(array_keys($options));
             // default
         }
     }
     $ilToolbar->addInputItem($tframe, true);
     $scope = new ilSelectInputGUI($lng->txt("wiki_stat_scope"), "scp");
     $scope->setOptions(array(1 => "1 " . $lng->txt("month"), 2 => "2 " . $lng->txt("months"), 3 => "3 " . $lng->txt("months"), 4 => "4 " . $lng->txt("months"), 5 => "5 " . $lng->txt("months"), 6 => "6 " . $lng->txt("months")));
     if ($current_scope) {
         $scope->setValue($current_scope);
     } else {
         if ($a_is_initial) {
             $current_scope = 1;
             // default
         }
     }
     $ilToolbar->addInputItem($scope, true);
     $ilToolbar->setFormAction($ilCtrl->getFormAction($this, "view"));
     $ilToolbar->addFormButton($lng->txt("show"), "view");
     if ($current_figure && $current_time_frame && $current_scope) {
         $ilToolbar->addSeparator();
         $ilToolbar->addFormButton($lng->txt("export"), "export");
         return array("figure" => $current_figure, "month" => $current_time_frame, "scope" => $current_scope);
     }
 }
 /**
  * getHTML
  *
  * @access public
  * 
  */
 public function getHTML()
 {
     global $lng;
     $this->tpl = new ilTemplate('tpl.navigation_header.html', true, true, 'Services/Calendar');
     $this->incrementDate(-2);
     $num = 0;
     do {
         switch ($this->increment) {
             case ilDateTime::DAY:
                 $this->tpl->setVariable('NAV_NAME_' . ++$num, ilCalendarUtil::_numericDayToString($this->seed->get(IL_CAL_FKT_DATE, 'w')));
                 break;
             case ilDateTime::WEEK:
                 $this->tpl->setVariable('NAV_NAME_' . ++$num, $this->lng->txt('week') . ' ' . $this->seed->get(IL_CAL_FKT_DATE, 'W'));
                 break;
             case ilDateTime::MONTH:
                 if ($num == 2) {
                     $this->tpl->setVariable('NAV_NAME_' . ++$num, $this->lng->txt('month_' . $this->seed->get(IL_CAL_FKT_DATE, 'm') . '_long') . ' ' . $this->seed->get(IL_CAL_FKT_DATE, 'Y'));
                 } else {
                     $this->tpl->setVariable('NAV_NAME_' . ++$num, $this->lng->txt('month_' . $this->seed->get(IL_CAL_FKT_DATE, 'm') . '_long'));
                 }
                 break;
         }
         $this->ctrl->setParameterByClass(get_class($this->cmdClass), 'seed', $this->seed->get(IL_CAL_DATE));
         $this->tpl->setVariable('NAV_LINK_' . $num, $this->ctrl->getLinkTarget($this->cmdClass, $this->cmd));
         // $this->ctrl->clearParametersByClass(get_class($this->cmdClass));
         $this->ctrl->setParameterByClass(get_class($this->cmdClass), 'seed', '');
         $this->incrementDate(1);
     } while ($num < 6);
     // header
     switch ($this->increment) {
         case ilDateTime::DAY:
             $this->tpl->setVariable('TXT_SELECT_TITLE', $lng->txt("cal_day_selection"));
             $this->tpl->setVariable('TXT_VIEW_HEAD', $lng->txt("cal_day_overview"));
             break;
         case ilDateTime::WEEK:
             $this->tpl->setVariable('TXT_SELECT_TITLE', $lng->txt("cal_week_selection"));
             $this->tpl->setVariable('TXT_VIEW_HEAD', $lng->txt("cal_week_overview"));
             break;
         case ilDateTime::MONTH:
             $this->tpl->setVariable('TXT_SELECT_TITLE', $lng->txt("cal_month_selection"));
             $this->tpl->setVariable('TXT_VIEW_HEAD', $lng->txt("cal_month_overview"));
             break;
     }
     $this->tpl->setVariable('TXT_SELECTED', $lng->txt("stat_selected"));
     return $this->tpl->get();
 }
 /**
  * Insert property html
  *
  */
 function render()
 {
     global $lng, $ilUser;
     $tpl = new ilTemplate("tpl.prop_datetime.html", true, true, "Services/Form");
     $lng->loadLanguageModule("jscalendar");
     require_once "./Services/Calendar/classes/class.ilCalendarUtil.php";
     ilCalendarUtil::initJSCalendar();
     if (strlen($this->getActivationPostVar())) {
         $tpl->setCurrentBlock('prop_date_activation');
         $tpl->setVariable('CHECK_ENABLED_DATE', $this->getActivationPostVar());
         $tpl->setVariable('TXT_DATE_ENABLED', $this->activation_title);
         $tpl->setVariable('CHECKED_ENABLED', $this->activation_checked ? 'checked="checked"' : '');
         $tpl->setVariable('CHECKED_DISABLED', $this->getDisabled() ? 'disabled="disabled" ' : '');
         $tpl->parseCurrentBlock();
     }
     if ($this->getMode() == self::MODE_SELECT) {
         if (is_a($this->getDate(), 'ilDate')) {
             $date_info = $this->getDate()->get(IL_CAL_FKT_GETDATE, '', 'UTC');
         } elseif (is_a($this->getDate(), 'ilDateTime')) {
             $date_info = $this->getDate()->get(IL_CAL_FKT_GETDATE, '', $ilUser->getTimeZone());
         } else {
             $this->setDate(new ilDateTime(time(), IL_CAL_UNIX));
             $date_info = $this->getDate()->get(IL_CAL_FKT_GETDATE, '', $ilUser->getTimeZone());
         }
         // display invalid input again
         if (is_array($this->invalid_input)) {
             $date_info['year'] = $this->invalid_input['y'];
             $date_info['mon'] = $this->invalid_input['m'];
             $date_info['mday'] = $this->invalid_input['d'];
         }
     }
     if ($this->getMode() == self::MODE_SELECT) {
         $tpl->setCurrentBlock("prop_date_input_select_setup");
         $tpl->setVariable("INPUT_FIELDS_DATE", $this->getPostVar() . "[date]");
         $tpl->parseCurrentBlock();
         $tpl->setCurrentBlock("prop_date");
         $tpl->setVariable("DATE_SELECT", ilUtil::makeDateSelect($this->getPostVar() . "[date]", $date_info['year'], $date_info['mon'], $date_info['mday'], $this->startyear, true, array('disabled' => $this->getDisabled()), $this->getShowEmpty()));
     } else {
         $value = $this->getDate();
         if ($value) {
             $value = substr($this->getDate()->get(IL_CAL_DATETIME), 0, 10);
             $day = substr($value, 8, 2);
             $month = substr($value, 5, 2);
             $year = substr($value, 0, 4);
         }
         switch ($ilUser->getDateFormat()) {
             case ilCalendarSettings::DATE_FORMAT_DMY:
                 if ($value) {
                     $value = date("d.m.Y", mktime(0, 0, 0, $month, $day, $year));
                 }
                 $format = "%d.%m.%Y";
                 $input_hint = $lng->txt("dd_mm_yyyy");
                 break;
             case ilCalendarSettings::DATE_FORMAT_YMD:
                 if ($value) {
                     $value = date("Y-m-d", mktime(0, 0, 0, $month, $day, $year));
                 }
                 $format = "%Y-%m-%d";
                 $input_hint = $lng->txt("yyyy_mm_dd");
                 break;
             case ilCalendarSettings::DATE_FORMAT_MDY:
                 if ($value) {
                     $value = date("m/d/Y", mktime(0, 0, 0, $month, $day, $year));
                 }
                 $format = "%m/%d/%Y";
                 $input_hint = $lng->txt("mm_dd_yyyy");
                 break;
         }
         $tpl->setCurrentBlock("prop_date_input_field");
         $tpl->setVariable("DATE_ID", $this->getPostVar());
         $tpl->setVariable("DATE_VALUE", $value);
         $tpl->setVariable("DISABLED", $this->getDisabled() ? " disabled=\"disabled\"" : "");
         $tpl->parseCurrentBlock();
         $tpl->setCurrentBlock("prop_date_input_field_info");
         $tpl->setVariable("TXT_INPUT_FORMAT", $input_hint);
         $tpl->parseCurrentBlock();
         $tpl->setCurrentBlock("prop_date_input_field_setup");
         $tpl->setVariable("DATE_ID", $this->getPostVar());
         $tpl->setVariable("DATE_FIELD_FORMAT", $format);
         $tpl->parseCurrentBlock();
     }
     $tpl->setCurrentBlock("prop_date");
     include_once "./Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php";
     $tpl->setVariable("IMG_DATE_CALENDAR", ilGlyphGUI::get(ilGlyphGUI::CALENDAR, $lng->txt("open_calendar")));
     $tpl->setVariable("DATE_ID", $this->getPostVar());
     include_once './Services/Calendar/classes/class.ilCalendarUserSettings.php';
     $tpl->setVariable('DATE_FIRST_DAY', ilCalendarUserSettings::_getInstance()->getWeekStart());
     $tpl->parseCurrentBlock();
     if ($this->getShowTime()) {
         if ($this->getMode() == self::MODE_INPUT) {
             $value = $this->getDate();
             if ($value) {
                 if (!$this->getShowSeconds()) {
                     $value = substr($value->get(IL_CAL_DATETIME), 11, 5);
                     if ($ilUser->getTimeFormat() == ilCalendarSettings::TIME_FORMAT_12) {
                         $value = date("g:ia", mktime(substr($value, 0, 2), substr($value, 3, 2)));
                     }
                 } else {
                     $value = substr($value->get(IL_CAL_DATETIME), 11, 8);
                     if ($ilUser->getTimeFormat() == ilCalendarSettings::TIME_FORMAT_12) {
                         $value = date("g:i:sa", mktime(substr($value, 0, 2), substr($value, 3, 2), substr($value, 6, 2)));
                     }
                 }
             }
             $tpl->setCurrentBlock("prop_time_input_field");
             $tpl->setVariable("DATE_ID", $this->getPostVar());
             $tpl->setVariable("TIME_VALUE", $value);
             $tpl->setVariable("DISABLED", $this->getDisabled() ? " disabled=\"disabled\"" : "");
             $tpl->parseCurrentBlock();
         }
         $tpl->setCurrentBlock("prop_time");
         if ($this->getMode() == self::MODE_SELECT) {
             $tpl->setVariable("TIME_SELECT", ilUtil::makeTimeSelect($this->getPostVar() . "[time]", !$this->getShowSeconds(), $date_info['hours'], $date_info['minutes'], $date_info['seconds'], true, array('minute_steps' => $this->getMinuteStepSize(), 'disabled' => $this->getDisabled())));
         }
         $tpl->setVariable("TXT_TIME", $this->getShowSeconds() ? "(" . $lng->txt("hh_mm_ss") . ")" : "(" . $lng->txt("hh_mm") . ")");
         $tpl->parseCurrentBlock();
     }
     return $tpl->get();
 }
 /**
  * Add mini version of monthly overview
  * (Maybe extracted to another class, if used in pd calendar tab
  */
 function addMiniMonth($a_tpl)
 {
     global $ilCtrl, $lng, $ilUser;
     // weekdays
     include_once 'Services/Calendar/classes/class.ilCalendarUtil.php';
     $a_tpl->setCurrentBlock('month_header_col');
     $a_tpl->setVariable('TXT_WEEKDAY', $lng->txt("cal_week_abbrev"));
     $a_tpl->parseCurrentBlock();
     for ($i = (int) $this->user_settings->getWeekStart(); $i < 7 + (int) $this->user_settings->getWeekStart(); $i++) {
         $a_tpl->setCurrentBlock('month_header_col');
         $a_tpl->setVariable('TXT_WEEKDAY', ilCalendarUtil::_numericDayToString($i, false));
         $a_tpl->parseCurrentBlock();
     }
     include_once 'Services/Calendar/classes/class.ilCalendarSchedule.php';
     $this->scheduler = new ilCalendarSchedule($this->seed, ilCalendarSchedule::TYPE_MONTH);
     $this->scheduler->calculate();
     $counter = 0;
     foreach (ilCalendarUtil::_buildMonthDayList($this->seed->get(IL_CAL_FKT_DATE, 'm'), $this->seed->get(IL_CAL_FKT_DATE, 'Y'), $this->user_settings->getWeekStart())->get() as $date) {
         $counter++;
         //$this->showEvents($date);
         $a_tpl->setCurrentBlock('month_col');
         if (count($this->scheduler->getByDay($date, $ilUser->getTimeZone()))) {
             $a_tpl->setVariable('DAY_CLASS', 'calminiapp');
             #$a_tpl->setVariable('TD_CLASS','calminiapp');
         }
         include_once './Services/Calendar/classes/class.ilCalendarUtil.php';
         if (ilCalendarUtil::_isToday($date)) {
             $a_tpl->setVariable('TD_CLASS', 'calminitoday');
         } elseif (ilDateTime::_equals($date, $this->seed, IL_CAL_MONTH)) {
             $a_tpl->setVariable('TD_CLASS', 'calministd');
         } elseif (ilDateTime::_before($date, $this->seed, IL_CAL_MONTH)) {
             $a_tpl->setVariable('TD_CLASS', 'calminiprev');
         } else {
             $a_tpl->setVariable('TD_CLASS', 'calmininext');
         }
         $day = $date->get(IL_CAL_FKT_DATE, 'j');
         $month = $date->get(IL_CAL_FKT_DATE, 'n');
         $month_day = $day;
         $ilCtrl->clearParametersByClass('ilcalendardaygui');
         $ilCtrl->setParameterByClass('ilcalendardaygui', 'seed', $date->get(IL_CAL_DATE));
         $a_tpl->setVariable('OPEN_DAY_VIEW', $ilCtrl->getLinkTargetByClass('ilcalendardaygui', ''));
         $ilCtrl->clearParametersByClass('ilcalendardaygui');
         $a_tpl->setVariable('MONTH_DAY', $month_day);
         //$this->tpl->setVariable('NEW_SRC',ilUtil::getImagePath('new.png','calendar'));
         //$this->tpl->setVariable('NEW_ALT',$this->lng->txt('cal_new_app'));
         //$this->ctrl->clearParametersByClass('ilcalendarappointmentgui');
         //$this->ctrl->setParameterByClass('ilcalendarappointmentgui','seed',$date->get(IL_CAL_DATE));
         //$this->tpl->setVariable('ADD_LINK',$this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui','add'));
         //$this->tpl->setVariable('OPEN_SRC',ilUtil::getImagePath('open.png','calendar'));
         $a_tpl->parseCurrentBlock();
         if ($counter and !($counter % 7)) {
             $a_tpl->setCurrentBlock('month_row');
             $ilCtrl->clearParametersByClass('ilcalendarweekgui');
             $ilCtrl->setParameterByClass('ilcalendarweekgui', 'seed', $date->get(IL_CAL_DATE));
             $a_tpl->setVariable('OPEN_WEEK_VIEW', $ilCtrl->getLinkTargetByClass('ilcalendarweekgui', ''));
             $ilCtrl->clearParametersByClass('ilcalendarweekgui');
             $a_tpl->setVariable('TD_CLASS', 'calminiweek');
             $a_tpl->setVariable('WEEK', $date->get(IL_CAL_FKT_DATE, 'W'));
             $a_tpl->parseCurrentBlock();
         }
     }
     $a_tpl->setCurrentBlock('mini_month');
     $a_tpl->setVariable('TXT_MONTH_OVERVIEW', $lng->txt("cal_month_overview"));
     $a_tpl->setVariable('TXT_MONTH', $lng->txt('month_' . $this->seed->get(IL_CAL_FKT_DATE, 'm') . '_long') . ' ' . $this->seed->get(IL_CAL_FKT_DATE, 'Y'));
     $myseed = clone $this->seed;
     $ilCtrl->setParameterByClass('ilcalendarmonthgui', 'seed', $myseed->get(IL_CAL_DATE));
     $a_tpl->setVariable('OPEN_MONTH_VIEW', $ilCtrl->getLinkTargetByClass('ilcalendarmonthgui', ''));
     $myseed->increment(ilDateTime::MONTH, -1);
     $ilCtrl->setParameter($this->getParentObject(), 'seed', $myseed->get(IL_CAL_DATE));
     //$a_tpl->setVariable('BL_TYPE', $this->getBlockType());
     //$a_tpl->setVariable('BL_ID', $this->getBlockId());
     $a_tpl->setVariable('PREV_MONTH', $ilCtrl->getLinkTarget($this->getParentObject(), ""));
     $myseed->increment(ilDateTime::MONTH, 2);
     $ilCtrl->setParameter($this->getParentObject(), 'seed', $myseed->get(IL_CAL_DATE));
     $a_tpl->setVariable('NEXT_MONTH', $ilCtrl->getLinkTarget($this->getParentObject(), ""));
     $ilCtrl->setParameter($this->getParentObject(), 'seed', "");
     $a_tpl->parseCurrentBlock();
 }
 /**
  * show appointment
  *
  * @access protected
  * @param array appointment
  */
 protected function showAppointment($a_app)
 {
     global $ilUser;
     $this->tpl->setCurrentBlock('panel_code');
     $this->tpl->setVariable('NUM', $this->num_appointments);
     $this->tpl->parseCurrentBlock();
     if (!$ilUser->prefs["screen_reader_optimization"]) {
         $this->tpl->setCurrentBlock('app');
     } else {
         $this->tpl->setCurrentBlock('scrd_app');
     }
     include_once './Services/Calendar/classes/class.ilCalendarAppointmentPanelGUI.php';
     $this->tpl->setVariable('PANEL_DATA', ilCalendarAppointmentPanelGUI::_getInstance($this->seed)->getHTML($a_app));
     $this->tpl->setVariable('PANEL_NUM', $this->num_appointments);
     $this->tpl->setVariable('APP_ROWSPAN', $a_app['rowspan']);
     $this->tpl->setVariable('APP_TITLE', $a_app['event']->getPresentationTitle(false));
     switch ($this->user_settings->getTimeFormat()) {
         case ilCalendarSettings::TIME_FORMAT_24:
             $title = $a_app['event']->getStart()->get(IL_CAL_FKT_DATE, 'H:i', $this->timezone);
             break;
         case ilCalendarSettings::TIME_FORMAT_12:
             $title = $a_app['event']->getStart()->get(IL_CAL_FKT_DATE, 'h:ia', $this->timezone);
             break;
     }
     // add end time for screen readers
     if ($ilUser->prefs["screen_reader_optimization"]) {
         switch ($this->user_settings->getTimeFormat()) {
             case ilCalendarSettings::TIME_FORMAT_24:
                 $title .= "-" . $a_app['event']->getEnd()->get(IL_CAL_FKT_DATE, 'H:i', $this->timezone);
                 break;
             case ilCalendarSettings::TIME_FORMAT_12:
                 $title .= "-" . $a_app['event']->getEnd()->get(IL_CAL_FKT_DATE, 'h:ia', $this->timezone);
                 break;
         }
     }
     // booking
     if ($a_app['category_type'] == ilCalendarCategory::TYPE_CH) {
         include_once 'Services/Booking/classes/class.ilBookingEntry.php';
         $entry = new ilBookingEntry($a_app['event']->getContextId());
         if ($entry) {
             $title .= ' ' . $a_app['event']->getTitle();
             if ($entry->isOwner()) {
                 $max = (int) $entry->getNumberOfBookings();
                 $current = (int) $entry->getCurrentNumberOfBookings($a_app['event']->getEntryId());
                 if ($max > 1) {
                     $title .= ' (' . $current . '/' . $max . ')';
                 } else {
                     if ($current == $max) {
                         $title .= ' (' . $this->lng->txt('cal_booked_out') . ')';
                     } else {
                         $title .= ' (' . $this->lng->txt('cal_book_free') . ')';
                     }
                 }
             } else {
                 if ($entry->hasBooked($a_app['event']->getEntryId())) {
                     $title .= ' (' . $this->lng->txt('cal_date_booked') . ')';
                 }
             }
         }
     } else {
         $title .= ' ' . $a_app['event']->getPresentationTitle(false);
     }
     $this->tpl->setVariable('APP_TITLE', $title);
     $color = $this->app_colors->getColorByAppointment($a_app['event']->getEntryId());
     $this->tpl->setVariable('APP_BGCOLOR', $color);
     $this->tpl->setVariable('APP_COLOR', ilCalendarUtil::calculateFontColor($color));
     $this->ctrl->clearParametersByClass('ilcalendarappointmentgui');
     $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'seed', $this->seed->get(IL_CAL_DATE));
     $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'app_id', $a_app['event']->getEntryId());
     $this->tpl->setVariable('APP_EDIT_LINK', $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'edit'));
     $this->tpl->parseCurrentBlock();
     $this->num_appointments++;
 }
 /**
  * Init Javascript Calendar.
  */
 static function initJSCalendar()
 {
     global $tpl, $lng;
     if (self::$init_done == "done") {
         return;
     }
     $lng->loadLanguageModule("jscalendar");
     $tpl->addBlockFile("CALENDAR_LANG_JAVASCRIPT", "calendar_javascript", "tpl.calendar.html", "Services/Calendar");
     $tpl->setCurrentBlock("calendar_javascript");
     $tpl->setVariable("FULL_SUNDAY", $lng->txt("l_su"));
     $tpl->setVariable("FULL_MONDAY", $lng->txt("l_mo"));
     $tpl->setVariable("FULL_TUESDAY", $lng->txt("l_tu"));
     $tpl->setVariable("FULL_WEDNESDAY", $lng->txt("l_we"));
     $tpl->setVariable("FULL_THURSDAY", $lng->txt("l_th"));
     $tpl->setVariable("FULL_FRIDAY", $lng->txt("l_fr"));
     $tpl->setVariable("FULL_SATURDAY", $lng->txt("l_sa"));
     $tpl->setVariable("SHORT_SUNDAY", $lng->txt("s_su"));
     $tpl->setVariable("SHORT_MONDAY", $lng->txt("s_mo"));
     $tpl->setVariable("SHORT_TUESDAY", $lng->txt("s_tu"));
     $tpl->setVariable("SHORT_WEDNESDAY", $lng->txt("s_we"));
     $tpl->setVariable("SHORT_THURSDAY", $lng->txt("s_th"));
     $tpl->setVariable("SHORT_FRIDAY", $lng->txt("s_fr"));
     $tpl->setVariable("SHORT_SATURDAY", $lng->txt("s_sa"));
     $tpl->setVariable("FULL_JANUARY", $lng->txt("l_01"));
     $tpl->setVariable("FULL_FEBRUARY", $lng->txt("l_02"));
     $tpl->setVariable("FULL_MARCH", $lng->txt("l_03"));
     $tpl->setVariable("FULL_APRIL", $lng->txt("l_04"));
     $tpl->setVariable("FULL_MAY", $lng->txt("l_05"));
     $tpl->setVariable("FULL_JUNE", $lng->txt("l_06"));
     $tpl->setVariable("FULL_JULY", $lng->txt("l_07"));
     $tpl->setVariable("FULL_AUGUST", $lng->txt("l_08"));
     $tpl->setVariable("FULL_SEPTEMBER", $lng->txt("l_09"));
     $tpl->setVariable("FULL_OCTOBER", $lng->txt("l_10"));
     $tpl->setVariable("FULL_NOVEMBER", $lng->txt("l_11"));
     $tpl->setVariable("FULL_DECEMBER", $lng->txt("l_12"));
     $tpl->setVariable("SHORT_JANUARY", $lng->txt("s_01"));
     $tpl->setVariable("SHORT_FEBRUARY", $lng->txt("s_02"));
     $tpl->setVariable("SHORT_MARCH", $lng->txt("s_03"));
     $tpl->setVariable("SHORT_APRIL", $lng->txt("s_04"));
     $tpl->setVariable("SHORT_MAY", $lng->txt("s_05"));
     $tpl->setVariable("SHORT_JUNE", $lng->txt("s_06"));
     $tpl->setVariable("SHORT_JULY", $lng->txt("s_07"));
     $tpl->setVariable("SHORT_AUGUST", $lng->txt("s_08"));
     $tpl->setVariable("SHORT_SEPTEMBER", $lng->txt("s_09"));
     $tpl->setVariable("SHORT_OCTOBER", $lng->txt("s_10"));
     $tpl->setVariable("SHORT_NOVEMBER", $lng->txt("s_11"));
     $tpl->setVariable("SHORT_DECEMBER", $lng->txt("s_12"));
     $tpl->setVariable("ABOUT_CALENDAR", $lng->txt("about_calendar"));
     $tpl->setVariable("ABOUT_CALENDAR_LONG", $lng->txt("about_calendar_long"));
     $tpl->setVariable("ABOUT_TIME_LONG", $lng->txt("about_time"));
     $tpl->setVariable("PREV_YEAR", $lng->txt("prev_year"));
     $tpl->setVariable("PREV_MONTH", $lng->txt("prev_month"));
     $tpl->setVariable("GO_TODAY", $lng->txt("go_today"));
     $tpl->setVariable("NEXT_MONTH", $lng->txt("next_month"));
     $tpl->setVariable("NEXT_YEAR", $lng->txt("next_year"));
     $tpl->setVariable("SEL_DATE", $lng->txt("select_date"));
     $tpl->setVariable("DRAG_TO_MOVE", $lng->txt("drag_to_move"));
     $tpl->setVariable("PART_TODAY", $lng->txt("part_today"));
     $tpl->setVariable("DAY_FIRST", $lng->txt("day_first"));
     $tpl->setVariable("CLOSE", $lng->txt("close"));
     $tpl->setVariable("TODAY", $lng->txt("today"));
     $tpl->setVariable("TIME_PART", $lng->txt("time_part"));
     $tpl->setVariable("DEF_DATE_FORMAT", $lng->txt("def_date_format"));
     $tpl->setVariable("TT_DATE_FORMAT", $lng->txt("tt_date_format"));
     $tpl->setVariable("WK", $lng->txt("wk"));
     $tpl->setVariable("TIME", $lng->txt("time"));
     $tpl->parseCurrentBlock();
     $tpl->setCurrentBlock("CalendarJS");
     $tpl->setVariable("LOCATION_JAVASCRIPT_CALENDAR", "./Services/Calendar/js/calendar.js");
     $tpl->setVariable("LOCATION_JAVASCRIPT_CALENDAR_SETUP", "./Services/Calendar/js/calendar-setup.js");
     $tpl->setVariable("LOCATION_JAVASCRIPT_CALENDAR_STYLESHEET", "./Services/Calendar/css/calendar.css");
     $tpl->parseCurrentBlock();
     self::$init_done = "done";
 }
 /**
  * Build navigation block
  *
  * @param array $items
  * @param string $a_list_cmd
  * @param string $a_posting_cmd
  * @param bool $a_link_template
  * @param bool $a_show_inactive
  * @return string
  */
 function renderNavigation(array $items, $a_list_cmd = "render", $a_posting_cmd = "preview", $a_link_template = null, $a_show_inactive = false)
 {
     global $ilCtrl, $ilSetting;
     $max_detail_postings = 10;
     $wtpl = new ilTemplate("tpl.blog_list_navigation.html", true, true, "Modules/Blog");
     $wtpl->setVariable("NAVIGATION_TITLE", $this->lng->txt("blog_navigation"));
     $ilCtrl->setParameter($this, "blpg", "");
     include_once "Services/Calendar/classes/class.ilCalendarUtil.php";
     $counter = 0;
     foreach ($items as $month => $postings) {
         $month_name = ilCalendarUtil::_numericMonthToString((int) substr($month, 5)) . " " . substr($month, 0, 4);
         if (!$a_link_template) {
             $ilCtrl->setParameter($this, "bmn", $month);
             $month_url = $ilCtrl->getLinkTarget($this, $a_list_cmd);
         } else {
             $month_url = $this->buildExportLink($a_link_template, "list", $month);
         }
         // list postings for month
         if ($counter < $max_detail_postings) {
             foreach ($postings as $id => $posting) {
                 $is_active = ilBlogPosting::_lookupActive($id, "blp");
                 if (!$is_active && !$a_show_inactive) {
                     continue;
                 }
                 $counter++;
                 $caption = $posting["title"];
                 if (!$a_link_template) {
                     $ilCtrl->setParameterByClass("ilblogpostinggui", "bmn", $month);
                     $ilCtrl->setParameterByClass("ilblogpostinggui", "blpg", $id);
                     $url = $ilCtrl->getLinkTargetByClass("ilblogpostinggui", $a_posting_cmd);
                 } else {
                     $url = $this->buildExportLink($a_link_template, "posting", $id);
                 }
                 if (!$is_active) {
                     $wtpl->setVariable("NAV_ITEM_DRAFT", $this->lng->txt("blog_draft"));
                 } else {
                     if ($this->object->hasApproval() && !$posting["approved"]) {
                         $wtpl->setVariable("NAV_ITEM_APPROVAL", $this->lng->txt("blog_needs_approval"));
                     }
                 }
                 $wtpl->setCurrentBlock("navigation_item");
                 $wtpl->setVariable("NAV_ITEM_URL", $url);
                 $wtpl->setVariable("NAV_ITEM_CAPTION", $caption);
                 $wtpl->parseCurrentBlock();
             }
             $wtpl->setCurrentBlock("navigation_month_details");
             $wtpl->setVariable("NAV_MONTH", $month_name);
             $wtpl->setVariable("URL_MONTH", $month_url);
             $wtpl->parseCurrentBlock();
         } else {
             $wtpl->setCurrentBlock("navigation_month");
             $wtpl->setVariable("MONTH_NAME", $month_name);
             $wtpl->setVariable("URL_MONTH", $month_url);
             $wtpl->setVariable("MONTH_COUNT", sizeof($postings));
             $wtpl->parseCurrentBlock();
         }
     }
     $ilCtrl->setParameter($this, "bmn", $this->month);
     $ilCtrl->setParameterByClass("ilblogpostinggui", "bmn", "");
     // authors
     if ($this->id_type == self::REPOSITORY_NODE_ID) {
         $authors = array();
         foreach ($this->items as $month => $items) {
             foreach ($items as $item) {
                 if (($a_show_inactive || ilBlogPosting::_lookupActive($item["id"], "blp")) && $item["author"]) {
                     $authors[] = $item["author"];
                 }
             }
         }
         $authors = array_unique($authors);
         if (sizeof($authors) > 1) {
             include_once "Services/User/classes/class.ilUserUtil.php";
             $list = array();
             foreach ($authors as $user_id) {
                 if ($user_id) {
                     $ilCtrl->setParameter($this, "ath", $user_id);
                     $url = $ilCtrl->getLinkTarget($this, $a_list_cmd);
                     $ilCtrl->setParameter($this, "ath", "");
                     $name = ilUserUtil::getNamePresentation($user_id, true);
                     $idx = trim(strip_tags($name)) . "///" . $user_id;
                     // #10934
                     $list[$idx] = array($name, $url);
                 }
             }
             ksort($list);
             $wtpl->setVariable("AUTHORS_TITLE", $this->lng->txt("blog_authors"));
             $wtpl->setCurrentBlock("author");
             foreach ($list as $author) {
                 $wtpl->setVariable("TXT_AUTHOR", $author[0]);
                 $wtpl->setVariable("URL_AUTHOR", $author[1]);
                 $wtpl->parseCurrentBlock();
             }
         }
     }
     if (!$a_link_template) {
         // keywords
         $may_edit_keywords = $_GET["blpg"] && $this->mayContribute($_GET["blpg"]) && !$a_link_template && $a_list_cmd != "preview" && $a_list_cmd != "gethtml";
         $keywords = $this->getKeywords($a_show_inactive, $_GET["blpg"]);
         if ($keywords || $may_edit_keywords) {
             $wtpl->setVariable("KEYWORDS_TITLE", $this->lng->txt("blog_keywords"));
             if ($keywords) {
                 $max = max($keywords);
                 include_once "Services/Tagging/classes/class.ilTagging.php";
                 $wtpl->setCurrentBlock("keyword");
                 foreach ($keywords as $keyword => $counter) {
                     $ilCtrl->setParameter($this, "kwd", $keyword);
                     $url = $ilCtrl->getLinkTarget($this, $a_list_cmd);
                     $ilCtrl->setParameter($this, "kwd", "");
                     $wtpl->setVariable("TXT_KEYWORD", $keyword);
                     $wtpl->setVariable("SIZE_KEYWORD", ilTagging::calculateFontSize($counter, $max));
                     $wtpl->setVariable("URL_KEYWORD", $url);
                     $wtpl->parseCurrentBlock();
                 }
             } else {
                 $wtpl->setVariable("TXT_NO_KEYWORDS", $this->lng->txt("blog_no_keywords"));
             }
             if ($may_edit_keywords) {
                 $ilCtrl->setParameterByClass("ilblogpostinggui", "blpg", $_GET["blpg"]);
                 $wtpl->setVariable("URL_EDIT_KEYWORDS", $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "editKeywords"));
                 $ilCtrl->setParameterByClass("ilblogpostinggui", "blpg", "");
                 $wtpl->setVariable("TXT_EDIT_KEYWORDS", $this->lng->txt("blog_edit_keywords"));
             }
         }
         // rss
         if ($this->object->hasRSS() && $ilSetting->get('enable_global_profiles') && $a_list_cmd == "preview") {
             // #10827
             $blog_id = $this->node_id;
             if ($this->id_type != self::WORKSPACE_NODE_ID) {
                 $blog_id .= "_cll";
             }
             $url = ILIAS_HTTP_PATH . "/feed.php?blog_id=" . $blog_id . "&client_id=" . rawurlencode(CLIENT_ID);
             $wtpl->setCurrentBlock("rss");
             $wtpl->setVariable("URL_RSS", $url);
             $wtpl->setVariable("IMG_RSS", ilUtil::getImagePath("rss.png"));
             $wtpl->parseCurrentBlock();
         }
     }
     return $wtpl->get();
 }
 /**
  * init period of events
  *
  * @access protected
  * @param ilDate seed
  * @return
  */
 protected function initPeriod(ilDate $seed)
 {
     switch ($this->type) {
         case self::TYPE_DAY:
             $this->start = clone $seed;
             $this->end = clone $seed;
             $this->start->increment(IL_CAL_DAY, -2);
             $this->end->increment(IL_CAL_DAY, 2);
             break;
         case self::TYPE_WEEK:
             $this->start = clone $seed;
             $start_info = $this->start->get(IL_CAL_FKT_GETDATE, '', 'UTC');
             $day_diff = $this->weekstart - $start_info['isoday'];
             if ($day_diff == 7) {
                 $day_diff = 0;
             }
             $this->start->increment(IL_CAL_DAY, $day_diff);
             $this->start->increment(IL_CAL_DAY, -1);
             $this->end = clone $this->start;
             $this->end->increment(IL_CAL_DAY, 9);
             break;
         case self::TYPE_MONTH:
             $year_month = $seed->get(IL_CAL_FKT_DATE, 'Y-m', 'UTC');
             list($year, $month) = explode('-', $year_month);
             $this->start = new ilDate($year_month . '-01', IL_CAL_DATE);
             $this->start->increment(IL_CAL_DAY, -6);
             $this->end = new ilDate($year_month . '-' . ilCalendarUtil::_getMaxDayOfMonth($year, $month), IL_CAL_DATE);
             $this->end->increment(IL_CAL_DAY, 6);
             break;
         case self::TYPE_INBOX:
             $this->start = $seed;
             $this->end = clone $this->start;
             $this->end->increment(IL_CAL_MONTH, 3);
             break;
     }
     return true;
 }
 protected function addTimezone()
 {
     if ($this->getUserSettings()->getExportTimeZoneType() == ilCalendarUserSettings::CAL_EXPORT_TZ_UTC) {
         return;
     }
     $this->writer->addLine('X-WR-TIMEZONE:' . $GLOBALS['ilUser']->getTimeZone());
     include_once './Services/Calendar/classes/class.ilCalendarUtil.php';
     $tzid_file = ilCalendarUtil::getZoneInfoFile($GLOBALS['ilUser']->getTimeZone());
     if (!is_file($tzid_file)) {
         $tzid_file = ilCalendarUtil::getZoneInfoFile('Europe/Berlin');
     }
     $reader = fopen($tzid_file, 'r');
     while ($line = fgets($reader)) {
         $line = str_replace("\n", '', $line);
         $this->writer->addLine($line);
     }
 }
 /**
  * Insert property html
  *
  */
 public function render()
 {
     global $lng, $ilUser;
     $tpl = new ilTemplate("tpl.prop_datetime_duration.html", true, true, "Services/Form");
     // Init start
     if (is_a($this->getStart(), 'ilDate')) {
         $start_info = $this->getStart()->get(IL_CAL_FKT_GETDATE, '', 'UTC');
     } elseif (is_a($this->getStart(), 'ilDateTime')) {
         $start_info = $this->getStart()->get(IL_CAL_FKT_GETDATE, '', $ilUser->getTimeZone());
     } else {
         $this->setStart(new ilDateTime(time(), IL_CAL_UNIX));
         $start_info = $this->getStart()->get(IL_CAL_FKT_GETDATE, '', $ilUser->getTimeZone());
     }
     // display invalid input again
     if (is_array($this->invalid_input['start'])) {
         $start_info['year'] = $this->invalid_input['start']['y'];
         $start_info['mon'] = $this->invalid_input['start']['m'];
         $start_info['mday'] = $this->invalid_input['start']['d'];
     }
     // Init end
     if (is_a($this->getEnd(), 'ilDate')) {
         $end_info = $this->getEnd()->get(IL_CAL_FKT_GETDATE, '', 'UTC');
     } elseif (is_a($this->getEnd(), 'ilDateTime')) {
         $end_info = $this->getEnd()->get(IL_CAL_FKT_GETDATE, '', $ilUser->getTimeZone());
     } else {
         $this->setEnd(new ilDateTime(time(), IL_CAL_UNIX));
         $end_info = $this->getEnd()->get(IL_CAL_FKT_GETDATE, '', $ilUser->getTimeZone());
     }
     // display invalid input again
     if (is_array($this->invalid_input['end'])) {
         $end_info['year'] = $this->invalid_input['end']['y'];
         $end_info['mon'] = $this->invalid_input['end']['m'];
         $end_info['mday'] = $this->invalid_input['end']['d'];
     }
     $lng->loadLanguageModule("jscalendar");
     require_once "./Services/Calendar/classes/class.ilCalendarUtil.php";
     ilCalendarUtil::initJSCalendar();
     if (strlen($this->getActivationPostVar())) {
         $tpl->setCurrentBlock('prop_date_activation');
         $tpl->setVariable('CHECK_ENABLED_DATE', $this->getActivationPostVar());
         $tpl->setVariable('TXT_DATE_ENABLED', $this->activation_title);
         $tpl->setVariable('CHECKED_ENABLED', $this->activation_checked ? 'checked="checked"' : '');
         $tpl->setVariable('CHECKED_DISABLED', $this->getDisabled() ? 'disabled="disabled" ' : '');
         $tpl->parseCurrentBlock();
     }
     if (strlen($this->getStartText())) {
         $tpl->setVariable('TXT_START', $this->getStartText());
     }
     if (strlen($this->getEndText())) {
         $tpl->setVariable('TXT_END', $this->getEndText());
     }
     // Toggle fullday
     if ($this->enabledToggleFullTime()) {
         $tpl->setCurrentBlock('toggle_fullday');
         $tpl->setVariable('FULLDAY_POSTVAR', $this->getPostVar());
         $tpl->setVariable('FULLDAY_TOGGLE_NAME', $this->getPostVar() . '[fulltime]');
         $tpl->setVariable('FULLDAY_TOGGLE_CHECKED', $this->toggle_fulltime_checked ? 'checked="checked"' : '');
         $tpl->setVariable('FULLDAY_TOGGLE_DISABLED', $this->getDisabled() ? 'disabled="disabled"' : '');
         $tpl->setVariable('TXT_TOGGLE_FULLDAY', $this->toggle_fulltime_txt);
         $tpl->parseCurrentBlock();
     }
     $tpl->setVariable('POST_VAR', $this->getPostVar());
     include_once "./Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php";
     $tpl->setVariable("IMG_START_CALENDAR", ilGlyphGUI::get(ilGlyphGUI::CALENDAR, $lng->txt("open_calendar")));
     $tpl->setVariable("START_ID", $this->getPostVar());
     $tpl->setVariable("DATE_ID_START", $this->getPostVar());
     $tpl->setVariable("INPUT_FIELDS_START", $this->getPostVar() . "[start][date]");
     include_once './Services/Calendar/classes/class.ilCalendarUserSettings.php';
     $tpl->setVariable('DATE_FIRST_DAY', ilCalendarUserSettings::_getInstance()->getWeekStart());
     $tpl->setVariable("START_SELECT", ilUtil::makeDateSelect($this->getPostVar() . "[start][date]", $start_info['year'], $start_info['mon'], $start_info['mday'], $this->getStartYear(), true, array('disabled' => $this->getDisabled(), 'select_attributes' => array('onchange' => 'ilUpdateEndDate();')), $this->getShowEmpty()));
     include_once "./Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php";
     $tpl->setVariable("IMG_END_CALENDAR", ilGlyphGUI::get(ilGlyphGUI::CALENDAR, $lng->txt("open_calendar")));
     $tpl->setVariable("END_ID", $this->getPostVar());
     $tpl->setVariable("DATE_ID_END", $this->getPostVar());
     $tpl->setVariable("INPUT_FIELDS_END", $this->getPostVar() . "[end][date]");
     $tpl->setVariable("END_SELECT", ilUtil::makeDateSelect($this->getPostVar() . "[end][date]", $end_info['year'], $end_info['mon'], $end_info['mday'], $this->getStartYear(), true, array('disabled' => $this->getDisabled()), $this->getShowEmpty()));
     if ($this->getShowTime()) {
         $tpl->setCurrentBlock("show_start_time");
         $tpl->setVariable("START_TIME_SELECT", ilUtil::makeTimeSelect($this->getPostVar() . "[start][time]", !$this->getShowSeconds(), $start_info['hours'], $start_info['minutes'], $start_info['seconds'], true, array('minute_steps' => $this->getMinuteStepSize(), 'disabled' => $this->getDisabled(), 'select_attributes' => array('onchange' => 'ilUpdateEndDate();'))));
         $tpl->setVariable("TXT_START_TIME", $this->getShowSeconds() ? "(" . $lng->txt("hh_mm_ss") . ")" : "(" . $lng->txt("hh_mm") . ")");
         $tpl->parseCurrentBlock();
         $tpl->setCurrentBlock("show_end_time");
         $tpl->setVariable("END_TIME_SELECT", ilUtil::makeTimeSelect($this->getPostVar() . "[end][time]", !$this->getShowSeconds(), $end_info['hours'], $end_info['minutes'], $end_info['seconds'], true, array('minute_steps' => $this->getMinuteStepSize(), 'disabled' => $this->getDisabled())));
         $tpl->setVariable("TXT_END_TIME", $this->getShowSeconds() ? "(" . $lng->txt("hh_mm_ss") . ")" : "(" . $lng->txt("hh_mm") . ")");
         $tpl->parseCurrentBlock();
     }
     if ($this->getShowTime()) {
         $tpl->setVariable("DELIM", "<br />");
     }
     return $tpl->get();
 }
 /**
  * Book object for date
  * 
  * @param int $a_object_id
  * @param int $a_from timestamp
  * @param int $a_to timestamp
  */
 function processBooking($a_object_id, $a_from = null, $a_to = null)
 {
     global $ilUser;
     include_once 'Modules/BookingManager/classes/class.ilBookingReservation.php';
     $reservation = new ilBookingReservation();
     $reservation->setObjectId($a_object_id);
     $reservation->setUserId($ilUser->getID());
     $reservation->setFrom($a_from);
     $reservation->setTo($a_to);
     $reservation->save();
     if ($a_from) {
         $this->lng->loadLanguageModule('dateplaner');
         include_once 'Services/Calendar/classes/class.ilCalendarUtil.php';
         include_once 'Services/Calendar/classes/class.ilCalendarCategory.php';
         $def_cat = ilCalendarUtil::initDefaultCalendarByType(ilCalendarCategory::TYPE_BOOK, $ilUser->getId(), $this->lng->txt('cal_ch_personal_book'), true);
         include_once 'Modules/BookingManager/classes/class.ilBookingObject.php';
         $object = new ilBookingObject($a_object_id);
         include_once 'Services/Calendar/classes/class.ilCalendarEntry.php';
         $entry = new ilCalendarEntry();
         $entry->setStart(new ilDateTime($a_from, IL_CAL_UNIX));
         $entry->setEnd(new ilDateTime($a_to, IL_CAL_UNIX));
         $entry->setTitle($this->lng->txt('book_cal_entry') . ' ' . $object->getTitle());
         $entry->setContextId($reservation->getId());
         $entry->save();
         include_once 'Services/Calendar/classes/class.ilCalendarCategoryAssignments.php';
         $assignment = new ilCalendarCategoryAssignments($entry->getEntryId());
         $assignment->addAssignment($def_cat->getCategoryId());
     }
 }
 /**
  * 
  *
  * @access protected
  * @param
  * @return
  */
 protected function buildYearlyByDaySelection($tpl)
 {
     $tpl->setVariable('TXT_ON_THE', $this->lng->txt('cal_on_the'));
     $chosen_num_day = 1;
     $chosen_day = 'MO';
     $chosen = false;
     foreach ($this->recurrence->getBYDAYList() as $byday) {
         if (preg_match('/^(-?\\d)([A-Z][A-Z])/', $byday, $parsed) === 1) {
             $chosen = true;
             $chosen_num_day = $parsed[1];
             $chosen_day = $parsed[2];
         }
     }
     $num_options = array(1 => $this->lng->txt('cal_first'), 2 => $this->lng->txt('cal_second'), 3 => $this->lng->txt('cal_third'), 4 => $this->lng->txt('cal_fourth'), 5 => $this->lng->txt('cal_fifth'), -1 => $this->lng->txt('cal_last'));
     $tpl->setVariable('SELECT_BYDAY_NUM_YEARLY', ilUtil::formSelect($chosen_num_day, 'yearly_byday_num', $num_options, false, true, '', '', array('onchange' => "ilUpdateSubTypeSelection('sub_yearly_radio_1');")));
     $days = array(0 => 'SU', 1 => 'MO', 2 => 'TU', 3 => 'WE', 4 => 'TH', 5 => 'FR', 6 => 'SA', 7 => 'SU');
     for ($i = (int) $this->user_settings->getWeekStart(); $i < 7 + (int) $this->user_settings->getWeekStart(); $i++) {
         $days_select[$days[$i]] = ilCalendarUtil::_numericDayToString($i);
     }
     $tpl->setVariable('SELECT_BYDAY_DAY_YEARLY', ilUtil::formSelect($chosen_day, 'yearly_byday', $days_select, false, true, '', '', array('onchange' => "ilUpdateSubTypeSelection('sub_yearly_radio_1');")));
     $chosen = false;
     $chosen_month = 1;
     foreach ($this->recurrence->getBYMONTHList() as $month) {
         if ($this->recurrence->getBYMONTHDAYList()) {
             $chosen_month = $month;
             $chosen = true;
             break;
         }
     }
     $options = array();
     for ($m = 1; $m < 13; $m++) {
         $options[$m] = ilCalendarUtil::_numericMonthToString($m);
     }
     $tpl->setVariable('SELECT_BYMONTH_BYDAY', ilUtil::formSelect($chosen_month, 'yearly_bymonth_byday', $options, false, true, '', '', array('onchange' => "ilUpdateSubTypeSelection('sub_yearly_radio_1');")));
 }
 /**
  * Build navigation by date block
  *
  * @param array $a_items
  * @param string $a_list_cmd
  * @param string $a_posting_cmd
  * @param bool $a_link_template
  * @param bool $a_show_inactive
  * @return string
  */
 protected function renderNavigationByDate(array $a_items, $a_list_cmd = "render", $a_posting_cmd = "preview", $a_link_template = null, $a_show_inactive = false)
 {
     global $ilCtrl;
     // gather page active status
     foreach ($a_items as $month => $postings) {
         foreach (array_keys($postings) as $id) {
             $active = ilBlogPosting::_lookupActive($id, "blp");
             if (!$a_show_inactive && !$active) {
                 unset($a_items[$month][$id]);
             } else {
                 $a_items[$month][$id]["active"] = $active;
             }
         }
         if (!sizeof($a_items[$month])) {
             unset($a_items[$month]);
         }
     }
     // list month (incl. postings)
     if ($this->object->getNavMode() == ilObjBlog::NAV_MODE_LIST || $a_link_template) {
         $max_detail_postings = $this->object->getNavModeListPostings();
         $max_months = $this->object->getNavModeListMonths();
         $wtpl = new ilTemplate("tpl.blog_list_navigation_by_date.html", true, true, "Modules/Blog");
         $ilCtrl->setParameter($this, "blpg", "");
         include_once "Services/Calendar/classes/class.ilCalendarUtil.php";
         $counter = $mon_counter = $last_year = 0;
         foreach ($a_items as $month => $postings) {
             if (!$a_link_template && $max_months && $mon_counter >= $max_months) {
                 break;
             }
             $add_year = false;
             $year = substr($month, 0, 4);
             if (!$last_year || $year != $last_year) {
                 // #13562
                 $add_year = true;
                 $last_year = $year;
             }
             $mon_counter++;
             $month_name = ilCalendarUtil::_numericMonthToString((int) substr($month, 5));
             if (!$a_link_template) {
                 $ilCtrl->setParameter($this, "bmn", $month);
                 $month_url = $ilCtrl->getLinkTarget($this, $a_list_cmd);
             } else {
                 $month_url = $this->buildExportLink($a_link_template, "list", $month);
             }
             // list postings for month
             if ($counter < $max_detail_postings) {
                 if ($add_year) {
                     $wtpl->setCurrentBlock("navigation_year_details");
                     $wtpl->setVariable("YEAR", $year);
                     $wtpl->parseCurrentBlock();
                 }
                 foreach ($postings as $id => $posting) {
                     if ($max_detail_postings && $counter >= $max_detail_postings) {
                         break;
                     }
                     $counter++;
                     $caption = $posting["title"];
                     if (!$a_link_template) {
                         $ilCtrl->setParameterByClass("ilblogpostinggui", "bmn", $month);
                         $ilCtrl->setParameterByClass("ilblogpostinggui", "blpg", $id);
                         $url = $ilCtrl->getLinkTargetByClass("ilblogpostinggui", $a_posting_cmd);
                     } else {
                         $url = $this->buildExportLink($a_link_template, "posting", $id);
                     }
                     if (!$posting["active"]) {
                         $wtpl->setVariable("NAV_ITEM_DRAFT", $this->lng->txt("blog_draft"));
                     } else {
                         if ($this->object->hasApproval() && !$posting["approved"]) {
                             $wtpl->setVariable("NAV_ITEM_APPROVAL", $this->lng->txt("blog_needs_approval"));
                         }
                     }
                     $wtpl->setCurrentBlock("navigation_item");
                     $wtpl->setVariable("NAV_ITEM_URL", $url);
                     $wtpl->setVariable("NAV_ITEM_CAPTION", $caption);
                     $wtpl->parseCurrentBlock();
                 }
                 $wtpl->setCurrentBlock("navigation_month_details");
                 $wtpl->setVariable("NAV_MONTH", $month_name);
                 $wtpl->setVariable("URL_MONTH", $month_url);
                 $wtpl->parseCurrentBlock();
             } else {
                 if ($add_year) {
                     $wtpl->setCurrentBlock("navigation_year");
                     $wtpl->setVariable("YEAR", $year);
                     $wtpl->parseCurrentBlock();
                 }
                 $wtpl->setCurrentBlock("navigation_month");
                 $wtpl->setVariable("MONTH_NAME", $month_name);
                 $wtpl->setVariable("URL_MONTH", $month_url);
                 $wtpl->setVariable("MONTH_COUNT", sizeof($postings));
                 $wtpl->parseCurrentBlock();
             }
         }
         $ilCtrl->setParameter($this, "bmn", $this->month);
         $ilCtrl->setParameterByClass("ilblogpostinggui", "bmn", "");
         return $wtpl->get();
     } else {
         $wtpl = new ilTemplate("tpl.blog_list_navigation_month.html", true, true, "Modules/Blog");
         $ilCtrl->setParameter($this, "blpg", "");
         include_once "Services/Calendar/classes/class.ilCalendarUtil.php";
         $month_options = array();
         foreach ($a_items as $month => $postings) {
             $month_name = ilCalendarUtil::_numericMonthToString((int) substr($month, 5)) . " " . substr($month, 0, 4);
             $month_options[$month] = $month_name;
             if ($month == $this->month) {
                 if (!$a_link_template) {
                     $ilCtrl->setParameter($this, "bmn", $month);
                     $month_url = $ilCtrl->getLinkTarget($this, $a_list_cmd);
                 } else {
                     $month_url = $this->buildExportLink($a_link_template, "list", $month);
                 }
                 foreach ($postings as $id => $posting) {
                     $caption = $posting["title"];
                     if (!$a_link_template) {
                         $ilCtrl->setParameterByClass("ilblogpostinggui", "bmn", $month);
                         $ilCtrl->setParameterByClass("ilblogpostinggui", "blpg", $id);
                         $url = $ilCtrl->getLinkTargetByClass("ilblogpostinggui", $a_posting_cmd);
                     } else {
                         $url = $this->buildExportLink($a_link_template, "posting", $id);
                     }
                     if (!$posting["active"]) {
                         $wtpl->setVariable("NAV_ITEM_DRAFT", $this->lng->txt("blog_draft"));
                     } else {
                         if ($this->object->hasApproval() && !$posting["approved"]) {
                             $wtpl->setVariable("NAV_ITEM_APPROVAL", $this->lng->txt("blog_needs_approval"));
                         }
                     }
                     $wtpl->setCurrentBlock("navigation_item");
                     $wtpl->setVariable("NAV_ITEM_URL", $url);
                     $wtpl->setVariable("NAV_ITEM_CAPTION", $caption);
                     $wtpl->parseCurrentBlock();
                 }
                 $wtpl->setCurrentBlock("navigation_month_details");
                 if ($_GET["blpg"]) {
                     $wtpl->setVariable("NAV_MONTH", $month_name);
                     $wtpl->setVariable("URL_MONTH", $month_url);
                 }
                 $wtpl->parseCurrentBlock();
             }
         }
         if (!$_GET["blpg"]) {
             $wtpl->setCurrentBlock("option_bl");
             foreach ($month_options as $value => $caption) {
                 $wtpl->setVariable("OPTION_VALUE", $value);
                 $wtpl->setVariable("OPTION_CAPTION", $caption);
                 if ($value == $this->month) {
                     $wtpl->setVariable("OPTION_SEL", ' selected="selected"');
                 }
                 $wtpl->parseCurrentBlock();
             }
             $wtpl->setVariable("FORM_ACTION", $ilCtrl->getFormAction($this, $a_list_cmd));
         }
         $ilCtrl->setParameter($this, "bmn", $this->month);
         $ilCtrl->setParameterByClass("ilblogpostinggui", "bmn", "");
         return $wtpl->get();
     }
 }
 /**
  * 
  * Show events
  *
  * @access protected
  */
 protected function showEvents(ilDate $date)
 {
     global $tree, $ilUser;
     $count = 0;
     foreach ($this->scheduler->getByDay($date, $this->timezone) as $item) {
         $this->tpl->setCurrentBlock('panel_code');
         $this->tpl->setVariable('NUM', $this->num_appointments);
         $this->tpl->parseCurrentBlock();
         // milestone icon
         if ($item['event']->isMilestone()) {
             $this->tpl->setCurrentBlock('fullday_ms_icon');
             $this->tpl->setVariable('ALT_FD_MS', $this->lng->txt("cal_milestone"));
             $this->tpl->setVariable('SRC_FD_MS', ilUtil::getImagePath("icon_ms.svg"));
             $this->tpl->parseCurrentBlock();
         }
         $this->tpl->setCurrentBlock('il_event');
         include_once './Services/Calendar/classes/class.ilCalendarAppointmentPanelGUI.php';
         $this->tpl->setVariable('PANEL_DATA', ilCalendarAppointmentPanelGUI::_getInstance($this->seed)->getHTML($item));
         $this->tpl->setVariable('PANEL_NUM', $this->num_appointments);
         $this->ctrl->clearParametersByClass('ilcalendarappointmentgui');
         $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'app_id', $item['event']->getEntryId());
         $this->tpl->setVariable('EVENT_EDIT_LINK', $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'edit'));
         $this->tpl->setVariable('EVENT_NUM', $item['event']->getEntryId());
         $compl = $item['event']->isMilestone() && $item['event']->getCompletion() > 0 ? " (" . $item['event']->getCompletion() . "%)" : "";
         if ($item['event']->isFullDay()) {
             $title = $item['event']->getPresentationTitle() . $compl;
         } else {
             switch ($this->user_settings->getTimeFormat()) {
                 case ilCalendarSettings::TIME_FORMAT_24:
                     $title = $item['event']->getStart()->get(IL_CAL_FKT_DATE, 'H:i', $this->timezone);
                     break;
                 case ilCalendarSettings::TIME_FORMAT_12:
                     $title = $item['event']->getStart()->get(IL_CAL_FKT_DATE, 'h:ia', $this->timezone);
                     break;
             }
             $title .= ' ' . $item['event']->getPresentationTitle();
         }
         $this->tpl->setVariable('EVENT_TITLE', $title);
         $color = $this->app_colors->getColorByAppointment($item['event']->getEntryId());
         $this->tpl->setVariable('EVENT_BGCOLOR', $color);
         $this->tpl->setVariable('EVENT_ADD_STYLES', $item['event']->getPresentationStyle());
         $this->tpl->setVariable('EVENT_FONTCOLOR', ilCalendarUtil::calculateFontColor($color));
         $this->tpl->parseCurrentBlock();
         $this->num_appointments++;
         $count++;
     }
     return $count;
 }
 /**
  * Init general settings form.
  *
  */
 public function initGeneralSettingsForm()
 {
     global $lng, $ilUser, $styleDefinition, $ilSetting;
     include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
     $this->form = new ilPropertyFormGUI();
     // language
     if ($this->userSettingVisible("language")) {
         $languages = $this->lng->getInstalledLanguages();
         $options = array();
         foreach ($languages as $lang_key) {
             $options[$lang_key] = ilLanguage::_lookupEntry($lang_key, "meta", "meta_l_" . $lang_key);
         }
         $si = new ilSelectInputGUI($this->lng->txt("language"), "language");
         $si->setOptions($options);
         $si->setValue($ilUser->getLanguage());
         $si->setDisabled($ilSetting->get("usr_settings_disable_language"));
         $this->form->addItem($si);
     }
     // skin/style
     include_once "./Services/Style/classes/class.ilObjStyleSettings.php";
     if ($this->userSettingVisible("skin_style")) {
         $templates = $styleDefinition->getAllTemplates();
         if (is_array($templates)) {
             $si = new ilSelectInputGUI($this->lng->txt("skin_style"), "skin_style");
             $options = array();
             foreach ($templates as $template) {
                 // get styles information of template
                 $styleDef = new ilStyleDefinition($template["id"]);
                 $styleDef->startParsing();
                 $styles = $styleDef->getStyles();
                 foreach ($styles as $style) {
                     if (!ilObjStyleSettings::_lookupActivatedStyle($template["id"], $style["id"])) {
                         continue;
                     }
                     $options[$template["id"] . ":" . $style["id"]] = $styleDef->getTemplateName() . " / " . $style["name"];
                 }
             }
             $si->setOptions($options);
             $si->setValue($ilUser->skin . ":" . $ilUser->prefs["style"]);
             $si->setDisabled($ilSetting->get("usr_settings_disable_skin_style"));
             $this->form->addItem($si);
         }
     }
     // screen reader optimization
     if ($this->userSettingVisible("screen_reader_optimization")) {
         $cb = new ilCheckboxInputGUI($this->lng->txt("user_screen_reader_optimization"), "screen_reader_optimization");
         $cb->setChecked($ilUser->prefs["screen_reader_optimization"]);
         $cb->setDisabled($ilSetting->get("usr_settings_disable_screen_reader_optimization"));
         $cb->setInfo($this->lng->txt("user_screen_reader_optimization_info"));
         $this->form->addItem($cb);
     }
     // hits per page
     if ($this->userSettingVisible("hits_per_page")) {
         $si = new ilSelectInputGUI($this->lng->txt("hits_per_page"), "hits_per_page");
         $hits_options = array(10, 15, 20, 30, 40, 50, 100, 9999);
         $options = array();
         foreach ($hits_options as $hits_option) {
             $hstr = $hits_option == 9999 ? $this->lng->txt("no_limit") : $hits_option;
             $options[$hits_option] = $hstr;
         }
         $si->setOptions($options);
         $si->setValue($ilUser->prefs["hits_per_page"]);
         $si->setDisabled($ilSetting->get("usr_settings_disable_hits_per_page"));
         $this->form->addItem($si);
     }
     // Users Online
     if ($this->userSettingVisible("show_users_online")) {
         $si = new ilSelectInputGUI($this->lng->txt("show_users_online"), "show_users_online");
         $options = array("y" => $this->lng->txt("users_online_show_y"), "associated" => $this->lng->txt("users_online_show_associated"), "n" => $this->lng->txt("users_online_show_n"));
         $si->setOptions($options);
         $si->setValue($ilUser->prefs["show_users_online"]);
         $si->setDisabled($ilSetting->get("usr_settings_disable_show_users_online"));
         $this->form->addItem($si);
     }
     // Store last visited
     $lv = new ilSelectInputGUI($this->lng->txt("user_store_last_visited"), "store_last_visited");
     $options = array(0 => $this->lng->txt("user_lv_keep_entries"), 1 => $this->lng->txt("user_lv_keep_only_for_session"), 2 => $this->lng->txt("user_lv_do_not_store"));
     $lv->setOptions($options);
     $lv->setValue((int) $ilUser->prefs["store_last_visited"]);
     $this->form->addItem($lv);
     // hide_own_online_status
     if ($this->userSettingVisible("hide_own_online_status")) {
         $cb = new ilCheckboxInputGUI($this->lng->txt("hide_own_online_status"), "hide_own_online_status");
         $cb->setChecked($ilUser->prefs["hide_own_online_status"] == "y");
         $cb->setDisabled($ilSetting->get("usr_settings_disable_hide_own_online_status"));
         $this->form->addItem($cb);
     }
     include_once 'Services/Authentication/classes/class.ilSessionReminder.php';
     if (ilSessionReminder::isGloballyActivated()) {
         $cb = new ilCheckboxInputGUI($this->lng->txt('session_reminder'), 'session_reminder_enabled');
         $cb->setInfo($this->lng->txt('session_reminder_info'));
         $cb->setValue(1);
         $cb->setChecked((int) $ilUser->getPref('session_reminder_enabled'));
         $expires = ilSession::getSessionExpireValue();
         $lead_time_gui = new ilNumberInputGUI($this->lng->txt('session_reminder_lead_time'), 'session_reminder_lead_time');
         $lead_time_gui->setInfo(sprintf($this->lng->txt('session_reminder_lead_time_info'), ilFormat::_secondsToString($expires, true)));
         $min_value = ilSessionReminder::MIN_LEAD_TIME;
         $max_value = max($min_value, (int) $expires / 60 - 1);
         $current_user_value = $ilUser->getPref('session_reminder_lead_time');
         if ($current_user_value < $min_value || $current_user_value > $max_value) {
             $current_user_value = ilSessionReminder::SUGGESTED_LEAD_TIME;
         }
         $value = min(max($min_value, $current_user_value), $max_value);
         $lead_time_gui->setValue($value);
         $lead_time_gui->setSize(3);
         $lead_time_gui->setMinValue($min_value);
         $lead_time_gui->setMaxValue($max_value);
         $cb->addSubItem($lead_time_gui);
         $this->form->addItem($cb);
     }
     // calendar settings (copied here to be reachable when calendar is inactive)
     // they cannot be hidden/deactivated
     include_once 'Services/Calendar/classes/class.ilCalendarUserSettings.php';
     include_once 'Services/Calendar/classes/class.ilCalendarUtil.php';
     $lng->loadLanguageModule("dateplaner");
     $user_settings = ilCalendarUserSettings::_getInstanceByUserId($ilUser->getId());
     $select = new ilSelectInputGUI($lng->txt('cal_user_timezone'), 'timezone');
     $select->setOptions(ilCalendarUtil::_getShortTimeZoneList());
     $select->setInfo($lng->txt('cal_timezone_info'));
     $select->setValue($user_settings->getTimeZone());
     $this->form->addItem($select);
     $year = date("Y");
     $select = new ilSelectInputGUI($lng->txt('cal_user_date_format'), 'date_format');
     $select->setOptions(array(ilCalendarSettings::DATE_FORMAT_DMY => '31.10.' . $year, ilCalendarSettings::DATE_FORMAT_YMD => $year . "-10-31", ilCalendarSettings::DATE_FORMAT_MDY => "10/31/" . $year));
     $select->setInfo($lng->txt('cal_date_format_info'));
     $select->setValue($user_settings->getDateFormat());
     $this->form->addItem($select);
     $select = new ilSelectInputGUI($lng->txt('cal_user_time_format'), 'time_format');
     $select->setOptions(array(ilCalendarSettings::TIME_FORMAT_24 => '13:00', ilCalendarSettings::TIME_FORMAT_12 => '1:00pm'));
     $select->setInfo($lng->txt('cal_time_format_info'));
     $select->setValue($user_settings->getTimeFormat());
     $this->form->addItem($select);
     // starting point
     include_once "Services/User/classes/class.ilUserUtil.php";
     if (ilUserUtil::hasPersonalStartingPoint()) {
         $this->lng->loadLanguageModule("administration");
         $si = new ilRadioGroupInputGUI($this->lng->txt("adm_user_starting_point"), "usr_start");
         $si->setRequired(true);
         $si->setInfo($this->lng->txt("adm_user_starting_point_info"));
         foreach (ilUserUtil::getPossibleStartingPoints() as $value => $caption) {
             $si->addOption(new ilRadioOption($caption, $value));
         }
         $si->setValue(ilUserUtil::getPersonalStartingPoint());
         $this->form->addItem($si);
         // starting point: repository object
         $repobj = new ilRadioOption($lng->txt("adm_user_starting_point_object"), ilUserUtil::START_REPOSITORY_OBJ);
         $repobj_id = new ilTextInputGUI($lng->txt("adm_user_starting_point_ref_id"), "usr_start_ref_id");
         $repobj_id->setRequired(true);
         $repobj_id->setSize(5);
         if ($si->getValue() == ilUserUtil::START_REPOSITORY_OBJ) {
             $start_ref_id = ilUserUtil::getPersonalStartingObject();
             $repobj_id->setValue($start_ref_id);
             if ($start_ref_id) {
                 $start_obj_id = ilObject::_lookupObjId($start_ref_id);
                 if ($start_obj_id) {
                     $repobj_id->setInfo($lng->txt("obj_" . ilObject::_lookupType($start_obj_id)) . ": " . ilObject::_lookupTitle($start_obj_id));
                 }
             }
         }
         $repobj->addSubItem($repobj_id);
         $si->addOption($repobj);
     }
     // selector for unicode characters
     global $ilSetting;
     if ($ilSetting->get('char_selector_availability') > 0) {
         require_once 'Services/UIComponent/CharSelector/classes/class.ilCharSelectorGUI.php';
         $char_selector = new ilCharSelectorGUI(ilCharSelectorConfig::CONTEXT_USER);
         $char_selector->getConfig()->setAvailability($ilUser->getPref('char_selector_availability'));
         $char_selector->getConfig()->setDefinition($ilUser->getPref('char_selector_definition'));
         $char_selector->addFormProperties($this->form);
         $char_selector->setFormValues($this->form);
     }
     $this->form->addCommandButton("saveGeneralSettings", $lng->txt("save"));
     $this->form->setTitle($lng->txt("general_settings"));
     $this->form->setFormAction($this->ctrl->getFormAction($this));
 }
 /**
  * Insert property html
  *
  */
 function render()
 {
     global $lng, $ilUser;
     $tpl = new ilTemplate("tpl.prop_datetime.html", true, true, "Services/Form");
     if (is_object($this->getDate())) {
         $date_info = $this->getDate()->get(IL_CAL_FKT_GETDATE, '', 'UTC');
     } else {
         $date_info = array('year' => $_POST[$this->getPostVar()]['date']['y'], 'mon' => $_POST[$this->getPostVar()]['date']['m'], 'mday' => $_POST[$this->getPostVar()]['date']['d']);
     }
     $lng->loadLanguageModule("jscalendar");
     require_once "./Services/Calendar/classes/class.ilCalendarUtil.php";
     ilCalendarUtil::initJSCalendar();
     if (strlen($this->getActivationPostVar())) {
         $tpl->setCurrentBlock('prop_date_activation');
         $tpl->setVariable('CHECK_ENABLED_DATE', $this->getActivationPostVar());
         $tpl->setVariable('TXT_DATE_ENABLED', $this->activation_title);
         $tpl->setVariable('CHECKED_ENABLED', $this->activation_checked ? 'checked="checked"' : '');
         $tpl->setVariable('CHECKED_DISABLED', $this->getDisabled() ? 'disabled="disabled" ' : '');
         $tpl->parseCurrentBlock();
     }
     if ($this->getShowDate()) {
         $tpl->setCurrentBlock("prop_date");
         $tpl->setVariable("IMG_DATE_CALENDAR", ilUtil::getImagePath("calendar.png"));
         $tpl->setVariable("TXT_DATE_CALENDAR", $lng->txt("open_calendar"));
         $tpl->setVariable("DATE_ID", $this->getPostVar());
         $tpl->setVariable("INPUT_FIELDS_DATE", $this->getPostVar() . "[date]");
         include_once './Services/Calendar/classes/class.ilCalendarUserSettings.php';
         $tpl->setVariable('DATE_FIRST_DAY', ilCalendarUserSettings::_getInstance()->getWeekStart());
         $tpl->setVariable("DATE_SELECT", ilUtil::makeDateSelect($this->getPostVar() . "[date]", $date_info['year'], $date_info['mon'], $date_info['mday'], $this->startyear, true, array('disabled' => $this->getDisabled()), $this->getShowEmpty()));
         $tpl->parseCurrentBlock();
     }
     return $tpl->get();
 }
 /**
  * show settings table
  *
  * @access public
  * @return
  */
 public function initSettingsForm()
 {
     if (is_object($this->form)) {
         return true;
     }
     include_once 'Services/Calendar/classes/class.ilCalendarUtil.php';
     include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
     $this->form = new ilPropertyFormGUI();
     $this->form->setFormAction($this->ctrl->getFormAction($this, 'save'));
     $this->form->setTitle($this->lng->txt('cal_user_settings'));
     $this->form->addCommandButton('save', $this->lng->txt('save'));
     $this->form->addCommandButton('cancel', $this->lng->txt('cancel'));
     $select = new ilSelectInputGUI($this->lng->txt('cal_user_timezone'), 'timezone');
     $select->setOptions(ilCalendarUtil::_getShortTimeZoneList());
     $select->setInfo($this->lng->txt('cal_timezone_info'));
     $select->setValue($this->user_settings->getTimeZone());
     $this->form->addItem($select);
     $export_type = new ilRadioGroupInputGUI($this->lng->txt('cal_export_timezone'), 'export_tz');
     $export_type->setValue($this->user_settings->getExportTimeZoneType());
     $export_tz = new ilRadioOption($this->lng->txt('cal_export_timezone_tz'), ilCalendarUserSettings::CAL_EXPORT_TZ_TZ);
     $export_type->addOption($export_tz);
     $export_utc = new ilRadioOption($this->lng->txt('cal_export_timezone_utc'), ilCalendarUserSettings::CAL_EXPORT_TZ_UTC);
     $export_type->addOption($export_utc);
     $this->form->addItem($export_type);
     $year = date("Y");
     $select = new ilSelectInputGUI($this->lng->txt('cal_user_date_format'), 'date_format');
     $select->setOptions(array(ilCalendarSettings::DATE_FORMAT_DMY => '31.10.' . $year, ilCalendarSettings::DATE_FORMAT_YMD => $year . "-10-31", ilCalendarSettings::DATE_FORMAT_MDY => "10/31/" . $year));
     $select->setInfo($this->lng->txt('cal_date_format_info'));
     $select->setValue($this->user_settings->getDateFormat());
     $this->form->addItem($select);
     $select = new ilSelectInputGUI($this->lng->txt('cal_user_time_format'), 'time_format');
     $select->setOptions(array(ilCalendarSettings::TIME_FORMAT_24 => '13:00', ilCalendarSettings::TIME_FORMAT_12 => '1:00pm'));
     $select->setInfo($this->lng->txt('cal_time_format_info'));
     $select->setValue($this->user_settings->getTimeFormat());
     $this->form->addItem($select);
     // Week/Month View
     $week_month = new ilFormSectionHeaderGUI();
     $week_month->setTitle($this->lng->txt('cal_week_month_view'));
     $this->form->addItem($week_month);
     $radio = new ilRadioGroupInputGUI($this->lng->txt('cal_week_start'), 'weekstart');
     $radio->setValue($this->user_settings->getWeekStart());
     $option = new ilRadioOption($this->lng->txt('l_su'), 0);
     $radio->addOption($option);
     $option = new ilRadioOption($this->lng->txt('l_mo'), 1);
     $radio->addOption($option);
     $this->form->addItem($radio);
     // Day/Week View
     $week_month = new ilFormSectionHeaderGUI();
     $week_month->setTitle($this->lng->txt('cal_day_week_view'));
     $this->form->addItem($week_month);
     $day_start = new ilSelectInputGUI($this->lng->txt('cal_day_start'), 'dst');
     $day_start->setOptions(ilCalendarUtil::getHourSelection($this->user_settings->getTimeFormat()));
     $day_start->setValue($this->user_settings->getDayStart());
     $this->form->addItem($day_start);
     $day_end = new ilSelectInputGUI($this->lng->txt('cal_day_end'), 'den');
     $day_end->setOptions(ilCalendarUtil::getHourSelection($this->user_settings->getTimeFormat()));
     $day_end->setValue($this->user_settings->getDayEnd());
     $this->form->addItem($day_end);
 }
 /**
  * show appointment
  *
  * @access protected
  * @param array appointment
  */
 protected function showAppointment($a_app)
 {
     global $ilUser;
     $this->tpl->setCurrentBlock('panel_code');
     $this->tpl->setVariable('NUM', $this->num_appointments);
     $this->tpl->parseCurrentBlock();
     if (!$ilUser->prefs["screen_reader_optimization"]) {
         $this->tpl->setCurrentBlock('app');
     } else {
         $this->tpl->setCurrentBlock('scrd_app');
     }
     include_once './Services/Calendar/classes/class.ilCalendarAppointmentPanelGUI.php';
     $this->tpl->setVariable('PANEL_DATA', ilCalendarAppointmentPanelGUI::_getInstance($this->seed)->getHTML($a_app));
     $this->tpl->setVariable('PANEL_NUM', $this->num_appointments);
     $this->tpl->setVariable('APP_ROWSPAN', $a_app['rowspan']);
     $this->tpl->setVariable('APP_TITLE', $a_app['event']->getPresentationTitle(false));
     switch ($this->user_settings->getTimeFormat()) {
         case ilCalendarSettings::TIME_FORMAT_24:
             $title = $a_app['event']->getStart()->get(IL_CAL_FKT_DATE, 'H:i', $this->timezone);
             break;
         case ilCalendarSettings::TIME_FORMAT_12:
             $title = $a_app['event']->getStart()->get(IL_CAL_FKT_DATE, 'h:ia', $this->timezone);
             break;
     }
     // add end time for screen readers
     if ($ilUser->prefs["screen_reader_optimization"]) {
         switch ($this->user_settings->getTimeFormat()) {
             case ilCalendarSettings::TIME_FORMAT_24:
                 $title .= "-" . $a_app['event']->getEnd()->get(IL_CAL_FKT_DATE, 'H:i', $this->timezone);
                 break;
             case ilCalendarSettings::TIME_FORMAT_12:
                 $title .= "-" . $a_app['event']->getEnd()->get(IL_CAL_FKT_DATE, 'h:ia', $this->timezone);
                 break;
         }
     }
     $title .= ' ' . $a_app['event']->getPresentationTitle(false);
     $this->tpl->setVariable('APP_TITLE', $title);
     $color = $this->app_colors->getColorByAppointment($a_app['event']->getEntryId());
     $this->tpl->setVariable('APP_BGCOLOR', $color);
     $this->tpl->setVariable('APP_COLOR', ilCalendarUtil::calculateFontColor($color));
     $this->tpl->setVariable('APP_ADD_STYLES', $a_app['event']->getPresentationStyle());
     $this->ctrl->clearParametersByClass('ilcalendarappointmentgui');
     $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'seed', $this->seed->get(IL_CAL_DATE));
     $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'app_id', $a_app['event']->getEntryId());
     $this->tpl->setVariable('APP_EDIT_LINK', $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'edit'));
     $this->tpl->parseCurrentBlock();
     $this->num_appointments++;
 }
 /**
  * Init basic settings form.
  */
 public function initBasicSettingsForm($a_install = false)
 {
     global $lng, $ilCtrl;
     include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
     $this->form = new ilPropertyFormGUI();
     // webspace dir
     $ne = new ilNonEditableValueGUI($lng->txt("data_directory_in_ws"), "webspace_dir");
     if ($a_install) {
         $ne->setInfo($this->lng->txt("data_directory_in_ws_info"));
     }
     $cwd = ilUtil::isWindows() ? str_replace("\\", "/", getcwd()) : getcwd();
     $ne->setValue($cwd . "/data");
     $this->form->addItem($ne);
     // data dir
     if ($a_install) {
         $ti = new ilTextInputGUI($lng->txt("data_directory_outside_ws"), "datadir_path");
         $ti->setInfo($lng->txt("data_directory_info"));
         $ti->setRequired(true);
         $this->form->addItem($ti);
     } else {
         $ne = new ilNonEditableValueGUI($lng->txt("data_directory_outside_ws"), "data_dir");
         $this->form->addItem($ne);
     }
     $lvext = ilUtil::isWindows() ? "_win" : "";
     // logging
     $sh = new ilFormSectionHeaderGUI();
     $sh->setTitle($lng->txt("logging"));
     $this->form->addItem($sh);
     // path to log file
     $ti = new ilTextInputGUI($lng->txt("log_path"), "log_path");
     $ti->setInfo($lng->txt("log_path_comment" . $lvext));
     $this->form->addItem($ti);
     // disable logging
     $cb = new ilCheckboxInputGUI($lng->txt("disable_logging"), "chk_log_status");
     $this->form->addItem($cb);
     // server settings
     $sh = new ilFormSectionHeaderGUI();
     $sh->setTitle($lng->txt("server_settings"));
     $this->form->addItem($sh);
     // time zone
     include_once "./Services/Calendar/classes/class.ilCalendarUtil.php";
     $si = new ilSelectInputGUI($lng->txt("time_zone"), "time_zone");
     $si->setOptions(array_merge(array("" => "-- " . $lng->txt("please_select") . " --"), ilCalendarUtil::_getShortTimeZoneList()));
     $si->setRequired(true);
     $this->form->addItem($si);
     // required 3rd party tools
     $sh = new ilFormSectionHeaderGUI();
     $sh->setTitle($lng->txt("3rd_party_software_req"));
     $this->form->addItem($sh);
     // convert path
     $ti = new ilTextInputGUI($lng->txt("convert_path"), "convert_path");
     $ti->setInfo($lng->txt("convert_path_comment" . $lvext));
     $ti->setRequired(true);
     $this->form->addItem($ti);
     // zip path
     $ti = new ilTextInputGUI($lng->txt("zip_path"), "zip_path");
     $ti->setInfo($lng->txt("zip_path_comment" . $lvext));
     $ti->setRequired(true);
     $this->form->addItem($ti);
     // unzip path
     $ti = new ilTextInputGUI($lng->txt("unzip_path"), "unzip_path");
     $ti->setInfo($lng->txt("unzip_path_comment" . $lvext));
     $ti->setRequired(true);
     $this->form->addItem($ti);
     // optional 3rd party tools
     $sh = new ilFormSectionHeaderGUI();
     $sh->setTitle($lng->txt("3rd_party_software_opt"));
     $this->form->addItem($sh);
     // ghostscript path
     $ti = new ilTextInputGUI($lng->txt("ghostscript_path"), "ghostscript_path");
     $ti->setInfo($lng->txt("ghostscript_path_comment" . $lvext));
     $this->form->addItem($ti);
     // java path
     $ti = new ilTextInputGUI($lng->txt("java_path"), "java_path");
     $ti->setInfo($lng->txt("java_path_comment" . $lvext));
     $this->form->addItem($ti);
     // htmldoc path
     $ti = new ilTextInputGUI($lng->txt("htmldoc_path"), "htmldoc_path");
     $ti->setInfo($lng->txt("htmldoc_path_comment" . $lvext));
     $this->form->addItem($ti);
     // ffmpeg path
     $ti = new ilTextInputGUI($lng->txt("ffmpeg_path"), "ffmpeg_path");
     $ti->setInfo($lng->txt("ffmpeg_path_comment"));
     $this->form->addItem($ti);
     // latex
     $ti = new ilTextInputGUI($lng->txt("url_to_latex"), "latex_url");
     $ti->setInfo($lng->txt("latex_url_comment"));
     $this->form->addItem($ti);
     // virus scanner
     $options = array("none" => $lng->txt("none"), "sophos" => $lng->txt("sophos"), "antivir" => $lng->txt("antivir"), "clamav" => $lng->txt("clamav"));
     $si = new ilSelectInputGUI($lng->txt("virus_scanner"), "vscanner_type");
     $si->setOptions($options);
     $this->form->addItem($si);
     // scan command
     $ti = new ilTextInputGUI($lng->txt("scan_command"), "scan_command");
     $this->form->addItem($ti);
     // clean command
     $ti = new ilTextInputGUI($lng->txt("clean_command"), "clean_command");
     $this->form->addItem($ti);
     if ($a_install) {
         $sh = new ilFormSectionHeaderGUI();
         $sh->setTitle($lng->txt("master_password"));
         $this->form->addItem($sh);
         // password
         $pi = new ilPasswordInputGUI($lng->txt("password"), "password");
         $pi->setRequired(true);
         $pi->setSkipSyntaxCheck(true);
         $pi->setInfo($lng->txt("password_info"));
         $this->form->addItem($pi);
     }
     if ($a_install) {
         $this->form->addCommandButton("saveBasicSettings", $lng->txt("save"));
     } else {
         $this->form->addCommandButton("updateBasicSettings", $lng->txt("save"));
         $this->form->addCommandButton("determineToolsPath", $lng->txt("determine_tools_paths"));
     }
     $this->form->setTitle($lng->txt("data_directories"));
     $this->form->setFormAction("setup.php?cmd=gateway");
     if ($a_install) {
         $det = $this->determineTools();
         $this->form->setValuesByArray($det);
     }
 }
 /**
  * Book object for date
  * 
  * @param int $a_object_id
  * @param int $a_from timestamp
  * @param int $a_to timestamp
  * @param int $a_group_id 
  * @return int
  */
 function processBooking($a_object_id, $a_from = null, $a_to = null, $a_group_id = null)
 {
     global $ilUser, $ilAccess;
     // #11995
     if (!$ilAccess->checkAccess('read', '', $this->object->getRefId())) {
         $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"), $this->ilias->error_obj->MESSAGE);
     }
     include_once 'Modules/BookingManager/classes/class.ilBookingReservation.php';
     $reservation = new ilBookingReservation();
     $reservation->setObjectId($a_object_id);
     $reservation->setUserId($ilUser->getID());
     $reservation->setFrom($a_from);
     $reservation->setTo($a_to);
     $reservation->setGroupId($a_group_id);
     $reservation->save();
     if ($a_from) {
         $this->lng->loadLanguageModule('dateplaner');
         include_once 'Services/Calendar/classes/class.ilCalendarUtil.php';
         include_once 'Services/Calendar/classes/class.ilCalendarCategory.php';
         $def_cat = ilCalendarUtil::initDefaultCalendarByType(ilCalendarCategory::TYPE_BOOK, $ilUser->getId(), $this->lng->txt('cal_ch_personal_book'), true);
         include_once 'Modules/BookingManager/classes/class.ilBookingObject.php';
         $object = new ilBookingObject($a_object_id);
         include_once 'Services/Calendar/classes/class.ilCalendarEntry.php';
         $entry = new ilCalendarEntry();
         $entry->setStart(new ilDateTime($a_from, IL_CAL_UNIX));
         $entry->setEnd(new ilDateTime($a_to, IL_CAL_UNIX));
         $entry->setTitle($this->lng->txt('book_cal_entry') . ' ' . $object->getTitle());
         $entry->setContextId($reservation->getId());
         $entry->save();
         include_once 'Services/Calendar/classes/class.ilCalendarCategoryAssignments.php';
         $assignment = new ilCalendarCategoryAssignments($entry->getEntryId());
         $assignment->addAssignment($def_cat->getCategoryId());
     }
     return $reservation->getId();
 }
 /**
  * Format a date
  * @access public
  * @param object $date ilDate or ilDateTime
  * @return string date presentation in user specific timezone and language 
  * @static
  */
 public static function formatDate(ilDateTime $date)
 {
     global $lng, $ilUser;
     if ($date->isNull()) {
         return self::getLanguage()->txt('no_date');
     }
     $has_time = !is_a($date, 'ilDate');
     // Converting pure dates to user timezone might return wrong dates
     if ($has_time) {
         $date_info = $date->get(IL_CAL_FKT_GETDATE, '', $ilUser->getTimeZone());
     } else {
         $date_info = $date->get(IL_CAL_FKT_GETDATE, '', 'UTC');
     }
     if (self::isToday($date) and self::useRelativeDates()) {
         $date_str = self::getLanguage()->txt('today');
     } elseif (self::isTomorrow($date) and self::useRelativeDates()) {
         $date_str = self::getLanguage()->txt('tomorrow');
     } elseif (self::isYesterday($date) and self::useRelativeDates()) {
         $date_str = self::getLanguage()->txt('yesterday');
     } else {
         include_once './Services/Calendar/classes/class.ilCalendarUtil.php';
         $date_str = $date->get(IL_CAL_FKT_DATE, 'd') . '. ' . ilCalendarUtil::_numericMonthToString($date_info['mon'], false) . ' ' . $date_info['year'];
     }
     if (!$has_time) {
         return $date_str;
     }
     switch ($ilUser->getTimeFormat()) {
         case ilCalendarSettings::TIME_FORMAT_24:
             return $date_str . ', ' . $date->get(IL_CAL_FKT_DATE, 'H:i', $ilUser->getTimeZone());
         case ilCalendarSettings::TIME_FORMAT_12:
             return $date_str . ', ' . $date->get(IL_CAL_FKT_DATE, 'g:ia', $ilUser->getTimeZone());
     }
 }
 /**
  * get a list of month days
  *
  * @access protected
  * @param
  * @return
  */
 protected function getMonthWeekDays($year, $month)
 {
     static $month_days = array();
     if (isset($month_days[$year][$month])) {
         return $month_days[$year][$month];
     }
     $month_str = $month < 10 ? '0' . $month : $month;
     $begin_month = new ilDate($year . '-' . $month_str . '-01', IL_CAL_DATE);
     $begin_month_info = $begin_month->get(IL_CAL_FKT_GETDATE);
     $days = array(0 => 'SU', 1 => 'MO', 2 => 'TU', 3 => 'WE', 4 => 'TH', 5 => 'FR', 6 => 'SA');
     for ($i = 0; $i < $begin_month_info['wday']; $i++) {
         next($days);
     }
     for ($i = $begin_month_info['yday']; $i < $begin_month_info['yday'] + ilCalendarUtil::_getMaxDayOfMonth($year, $month); $i++) {
         if (($current_day = current($days)) == false) {
             $current_day = reset($days);
         }
         $month_days[$year][$month][$current_day][] = $i;
         next($days);
     }
     return $month_days[$year][$month];
 }
 /**
  * Init settings property form
  *
  * @access protected
  */
 protected function initFormSettings()
 {
     if (is_object($this->form)) {
         return true;
     }
     include_once 'Services/Calendar/classes/class.ilCalendarUtil.php';
     include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
     $this->form = new ilPropertyFormGUI();
     $this->form->setFormAction($this->ctrl->getFormAction($this));
     $this->form->setTitle($this->lng->txt('cal_global_settings'));
     $this->form->addCommandButton('save', $this->lng->txt('save'));
     #$this->form->addCommandButton('cancel',$this->lng->txt('cancel'));
     $check = new ilCheckboxInputGUI($this->lng->txt('enable_calendar'), 'enable');
     $check->setValue(1);
     $check->setChecked($this->settings->isEnabled() ? true : false);
     $this->form->addItem($check);
     $server_tz = new ilNonEditableValueGUI($this->lng->txt('cal_server_tz'));
     $server_tz->setValue(ilTimeZone::_getDefaultTimeZone());
     $this->form->addItem($server_tz);
     $select = new ilSelectInputGUI($this->lng->txt('cal_def_timezone'), 'default_timezone');
     $select->setOptions(ilCalendarUtil::_getShortTimeZoneList());
     $select->setInfo($this->lng->txt('cal_def_timezone_info'));
     $select->setValue($this->settings->getDefaultTimeZone());
     $this->form->addItem($select);
     $year = date("Y");
     $select = new ilSelectInputGUI($this->lng->txt('cal_def_date_format'), 'default_date_format');
     $select->setOptions(array(ilCalendarSettings::DATE_FORMAT_DMY => '31.10.' . $year, ilCalendarSettings::DATE_FORMAT_YMD => $year . "-10-31", ilCalendarSettings::DATE_FORMAT_MDY => "10/31/" . $year));
     $select->setInfo($this->lng->txt('cal_def_date_format_info'));
     $select->setValue($this->settings->getDefaultDateFormat());
     $this->form->addItem($select);
     $select = new ilSelectInputGUI($this->lng->txt('cal_def_time_format'), 'default_time_format');
     $select->setOptions(array(ilCalendarSettings::TIME_FORMAT_24 => '13:00', ilCalendarSettings::TIME_FORMAT_12 => '1:00pm'));
     $select->setInfo($this->lng->txt('cal_def_time_format_info'));
     $select->setValue($this->settings->getDefaultTimeFormat());
     $this->form->addItem($select);
     // Weekstart
     $radio = new ilRadioGroupInputGUI($this->lng->txt('cal_def_week_start'), 'default_week_start');
     $radio->setValue($this->settings->getDefaultWeekStart());
     $option = new ilRadioOption($this->lng->txt('l_su'), 0);
     $radio->addOption($option);
     $option = new ilRadioOption($this->lng->txt('l_mo'), 1);
     $radio->addOption($option);
     $this->form->addItem($radio);
     // Day start
     $day_start = new ilSelectInputGUI($this->lng->txt('cal_day_start'), 'dst');
     $day_start->setOptions(ilCalendarUtil::getHourSelection($this->settings->getDefaultTimeFormat()));
     $day_start->setValue($this->settings->getDefaultDayStart());
     $this->form->addItem($day_start);
     $day_end = new ilSelectInputGUI($this->lng->txt('cal_day_end'), 'den');
     $day_end->setOptions(ilCalendarUtil::getHourSelection($this->settings->getDefaultTimeFormat()));
     $day_end->setValue($this->settings->getDefaultDayEnd());
     $this->form->addItem($day_end);
     $sync = new ilCheckboxInputGUI($this->lng->txt('cal_webcal_sync'), 'webcal');
     $sync->setValue(1);
     $sync->setChecked($this->settings->isWebCalSyncEnabled());
     $sync->setInfo($this->lng->txt('cal_webcal_sync_info'));
     $sync_min = new ilNumberInputGUI('', 'webcal_hours');
     $sync_min->setSize(2);
     $sync_min->setMaxLength(3);
     $sync_min->setValue($this->settings->getWebCalSyncHours());
     $sync_min->setSuffix($this->lng->txt('hours'));
     $sync->addSubItem($sync_min);
     $this->form->addItem($sync);
     // enable milestone planning in groups
     $mil = new ilFormSectionHeaderGUI();
     $mil->setTitle($this->lng->txt('cal_milestone_settings'));
     $this->form->addItem($mil);
     $checkm = new ilCheckboxInputGUI($this->lng->txt('cal_enable_group_milestones'), 'enable_grp_milestones');
     $checkm->setValue(1);
     $checkm->setChecked($this->settings->getEnableGroupMilestones() ? true : false);
     $checkm->setInfo($this->lng->txt('cal_enable_group_milestones_desc'));
     $this->form->addItem($checkm);
     // Consultation hours
     $con = new ilFormSectionHeaderGUI();
     $con->setTitle($this->lng->txt('cal_ch_form_header'));
     $this->form->addItem($con);
     $ch = new ilCheckboxInputGUI($this->lng->txt('cal_ch_form'), 'ch');
     $ch->setInfo($this->lng->txt('cal_ch_form_info'));
     $ch->setValue(1);
     $ch->setChecked($this->settings->areConsultationHoursEnabled());
     $this->form->addItem($ch);
     // repository visibility default
     $rep = new ilFormSectionHeaderGUI();
     $rep->setTitle($GLOBALS['lng']->txt('cal_setting_global_vis_repos'));
     $this->form->addItem($rep);
     $crs = new ilCheckboxInputGUI($GLOBALS['lng']->txt('cal_setting_global_crs_vis'), 'visible_crs');
     $crs->setInfo($GLOBALS['lng']->txt('cal_setting_global_crs_vis_info'));
     $crs->setValue(1);
     $crs->setInfo($GLOBALS['lng']->txt('cal_setting_global_crs_vis_info'));
     $crs->setChecked($this->settings->isCourseCalendarEnabled());
     $this->form->addItem($crs);
     $grp = new ilCheckboxInputGUI($GLOBALS['lng']->txt('cal_setting_global_grp_vis'), 'visible_grp');
     $grp->setInfo($GLOBALS['lng']->txt('cal_setting_global_grp_vis_info'));
     $grp->setValue(1);
     $grp->setInfo($GLOBALS['lng']->txt('cal_setting_global_grp_vis_info'));
     $grp->setChecked($this->settings->isGroupCalendarEnabled());
     $this->form->addItem($grp);
     // Notifications
     $not = new ilFormSectionHeaderGUI();
     $not->setTitle($this->lng->txt('notifications'));
     $this->form->addItem($not);
     $cgn = new ilCheckboxInputGUI($this->lng->txt('cal_notification'), 'cn');
     $cgn->setOptionTitle($this->lng->txt('cal_notification_crsgrp'));
     $cgn->setValue(1);
     $cgn->setChecked($this->settings->isNotificationEnabled());
     $cgn->setInfo($this->lng->txt('cal_adm_notification_info'));
     $this->form->addItem($cgn);
     $cnu = new ilCheckboxInputGUI('', 'cnu');
     $cnu->setOptionTitle($this->lng->txt('cal_notification_users'));
     $cnu->setValue(1);
     $cnu->setChecked($this->settings->isUserNotificationEnabled());
     $cnu->setInfo($this->lng->txt('cal_adm_notification_user_info'));
     $this->form->addItem($cnu);
     // Registration
     $book = new ilFormSectionHeaderGUI();
     $book->setTitle($this->lng->txt('cal_registrations'));
     $this->form->addItem($book);
     $cgn = new ilCheckboxInputGUI($this->lng->txt('cal_cg_registrations'), 'cgr');
     $cgn->setValue(1);
     $cgn->setChecked($this->settings->isCGRegistrationEnabled());
     $cgn->setInfo($this->lng->txt('cal_cg_registration_info'));
     $this->form->addItem($cgn);
     // Synchronisation cache
     $sec = new ilFormSectionHeaderGUI();
     $sec->setTitle($this->lng->txt('cal_cache_settings'));
     $this->form->addItem($sec);
     $cache = new ilRadioGroupInputGUI($this->lng->txt('cal_sync_cache'), 'sync_cache');
     $cache->setValue((int) $this->settings->isSynchronisationCacheEnabled());
     $cache->setInfo($this->lng->txt('cal_sync_cache_info'));
     $cache->setRequired(true);
     $sync_cache = new ilRadioOption($this->lng->txt('cal_sync_disabled'), 0);
     $cache->addOption($sync_cache);
     $sync_cache = new ilRadioOption($this->lng->txt('cal_sync_enabled'), 1);
     $cache->addOption($sync_cache);
     $cache_t = new ilNumberInputGUI('', 'sync_cache_time');
     $cache_t->setValue($this->settings->getSynchronisationCacheMinutes());
     $cache_t->setMinValue(0);
     $cache_t->setSize(3);
     $cache_t->setMaxLength(3);
     $cache_t->setSuffix($this->lng->txt('form_minutes'));
     $sync_cache->addSubItem($cache_t);
     $this->form->addItem($cache);
     // Calendar cache
     $cache = new ilRadioGroupInputGUI($this->lng->txt('cal_cache'), 'cache');
     $cache->setValue((int) $this->settings->isCacheUsed());
     $cache->setInfo($this->lng->txt('cal_cache_info'));
     $cache->setRequired(true);
     $sync_cache = new ilRadioOption($this->lng->txt('cal_cache_disabled'), 0);
     $cache->addOption($sync_cache);
     $sync_cache = new ilRadioOption($this->lng->txt('cal_cache_enabled'), 1);
     $cache->addOption($sync_cache);
     $cache_t = new ilNumberInputGUI('', 'cache_time');
     $cache_t->setValue($this->settings->getCacheMinutes());
     $cache_t->setMinValue(0);
     $cache_t->setSize(3);
     $cache_t->setMaxLength(3);
     $cache_t->setSuffix($this->lng->txt('form_minutes'));
     $sync_cache->addSubItem($cache_t);
     $this->form->addItem($cache);
 }
 protected function exportCSV(array $a_data, $a_scale)
 {
     global $lng, $ilClientIniFile, $ilUser;
     ilDatePresentation::setUseRelativeDates(false);
     include_once './Services/Link/classes/class.ilLink.php';
     include_once "./Services/Utilities/classes/class.ilCSVWriter.php";
     $csv = new ilCSVWriter();
     $csv->setSeparator(";");
     $now = time();
     // meta
     $meta = array($lng->txt("trac_name_of_installation") => $ilClientIniFile->readVariable('client', 'name'), $lng->txt("trac_report_date") => ilDatePresentation::formatDate(new ilDateTime($now, IL_CAL_UNIX), IL_CAL_DATETIME), $lng->txt("trac_report_owner") => $ilUser->getFullName());
     foreach ($a_data as $idx => $item) {
         switch ($idx) {
             case "title":
                 $meta[$lng->txt("title")] = $item;
                 break;
             case "active":
                 // nothing to do
                 break;
             case "closed_details":
                 foreach ($item as $detail) {
                     $meta[$a_data["closed"][0] . " - " . $detail[0]] = $detail[1];
                 }
                 break;
             default:
                 $meta[$item[0]] = $item[1];
                 break;
         }
     }
     foreach ($meta as $caption => $value) {
         $csv->addColumn(strip_tags($caption));
         $csv->addColumn(strip_tags($value));
         $csv->addRow();
     }
     $csv->addRow();
     // aggregate data
     $aggr_data = $this->adaptDataToScale($a_scale, $a_data["active"], 700);
     unset($a_data);
     // header
     $first = $aggr_data;
     $first = array_keys(array_shift($first));
     foreach ($first as $column) {
         // split weekday and time slot again
         if ($a_scale == self::SCALE_PERIODIC_WEEK && $column == "slot_begin") {
             $csv->addColumn("weekday");
             $csv->addColumn("time");
         } else {
             $csv->addColumn(strip_tags($column));
         }
     }
     $csv->addRow();
     // data
     foreach ($aggr_data as $row) {
         foreach ($row as $column => $value) {
             if (is_array($value)) {
                 $value = implode(', ', $value);
             }
             switch ($column) {
                 case "slot_begin":
                     // split weekday and time slot again
                     if ($a_scale == self::SCALE_PERIODIC_WEEK) {
                         $csv->addColumn(ilCalendarUtil::_numericDayToString(substr($value, 0, 1)));
                         $value = substr($value, 1, 2) . ":" . substr($value, 3, 2);
                         break;
                     }
                     // fallthrough
                 // fallthrough
                 case "slot_end":
                     $value = date("d.m.Y H:i", $value);
                     break;
             }
             $csv->addColumn(strip_tags($value));
         }
         $csv->addRow();
     }
     // send
     $filename .= "session_statistics_" . date("Ymd", $now) . ".csv";
     header("Content-type: text/comma-separated-values");
     header("Content-Disposition: attachment; filename=\"" . $filename . "\"");
     header("Expires: 0");
     header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
     header("Pragma: public");
     echo $csv->getCSVString();
     exit;
 }
 /**
  * Add mini version of monthly overview
  * (Maybe extracted to another class, if used in pd calendar tab
  */
 function addMiniMonth($a_tpl)
 {
     global $ilCtrl, $lng, $ilUser;
     // weekdays
     include_once 'Services/Calendar/classes/class.ilCalendarUtil.php';
     $a_tpl->setCurrentBlock('month_header_col');
     $a_tpl->setVariable('TXT_WEEKDAY', $lng->txt("cal_week_abbrev"));
     $a_tpl->parseCurrentBlock();
     for ($i = (int) $this->user_settings->getWeekStart(); $i < 7 + (int) $this->user_settings->getWeekStart(); $i++) {
         $a_tpl->setCurrentBlock('month_header_col');
         $a_tpl->setVariable('TXT_WEEKDAY', ilCalendarUtil::_numericDayToString($i, false));
         $a_tpl->parseCurrentBlock();
     }
     if (isset($_GET["bkid"])) {
         $user_id = $_GET["bkid"];
         $disable_empty = true;
     } else {
         $user_id = $ilUser->getId();
         $disable_empty = false;
     }
     include_once 'Services/Calendar/classes/class.ilCalendarSchedule.php';
     $this->scheduler = new ilCalendarSchedule($this->seed, ilCalendarSchedule::TYPE_MONTH, $user_id);
     $this->scheduler->addSubitemCalendars(true);
     $this->scheduler->calculate();
     $counter = 0;
     foreach (ilCalendarUtil::_buildMonthDayList($this->seed->get(IL_CAL_FKT_DATE, 'm'), $this->seed->get(IL_CAL_FKT_DATE, 'Y'), $this->user_settings->getWeekStart())->get() as $date) {
         $counter++;
         $events = $this->scheduler->getByDay($date, $ilUser->getTimeZone());
         $has_events = (bool) count($events);
         if ($has_events || !$disable_empty) {
             $a_tpl->setCurrentBlock('month_col_link');
         } else {
             $a_tpl->setCurrentBlock('month_col_no_link');
         }
         if ($disable_empty) {
             if (!$has_events) {
                 $a_tpl->setVariable('DAY_CLASS', 'calminiinactive');
             } else {
                 $week_has_events = true;
                 include_once 'Services/Booking/classes/class.ilBookingEntry.php';
                 foreach ($events as $event) {
                     $booking = new ilBookingEntry($event['event']->getContextId());
                     if ($booking->hasBooked($event['event']->getEntryId())) {
                         $a_tpl->setVariable('DAY_CLASS', 'calminiapp');
                         break;
                     }
                 }
             }
         } elseif ($has_events) {
             $week_has_events = true;
             $a_tpl->setVariable('DAY_CLASS', 'calminiapp');
         }
         $day = $date->get(IL_CAL_FKT_DATE, 'j');
         $month = $date->get(IL_CAL_FKT_DATE, 'n');
         $month_day = $day;
         $ilCtrl->clearParametersByClass('ilcalendardaygui');
         $ilCtrl->setParameterByClass('ilcalendardaygui', 'seed', $date->get(IL_CAL_DATE));
         $a_tpl->setVariable('OPEN_DAY_VIEW', $ilCtrl->getLinkTargetByClass('ilcalendardaygui', ''));
         $ilCtrl->clearParametersByClass('ilcalendardaygui');
         $a_tpl->setVariable('MONTH_DAY', $month_day);
         $a_tpl->parseCurrentBlock();
         $a_tpl->setCurrentBlock('month_col');
         include_once './Services/Calendar/classes/class.ilCalendarUtil.php';
         if (ilCalendarUtil::_isToday($date)) {
             $a_tpl->setVariable('TD_CLASS', 'calminitoday');
         } elseif (ilDateTime::_equals($date, $this->seed, IL_CAL_MONTH)) {
             $a_tpl->setVariable('TD_CLASS', 'calministd');
         } elseif (ilDateTime::_before($date, $this->seed, IL_CAL_MONTH)) {
             $a_tpl->setVariable('TD_CLASS', 'calminiprev');
         } else {
             $a_tpl->setVariable('TD_CLASS', 'calmininext');
         }
         $a_tpl->parseCurrentBlock();
         if ($counter and !($counter % 7)) {
             if (!$disable_empty || $week_has_events) {
                 $a_tpl->setCurrentBlock('month_row_link');
                 $ilCtrl->clearParametersByClass('ilcalendarweekgui');
                 $ilCtrl->setParameterByClass('ilcalendarweekgui', 'seed', $date->get(IL_CAL_DATE));
                 $a_tpl->setVariable('OPEN_WEEK_VIEW', $ilCtrl->getLinkTargetByClass('ilcalendarweekgui', ''));
                 $ilCtrl->clearParametersByClass('ilcalendarweekgui');
             } else {
                 $a_tpl->setCurrentBlock('month_row_no_link');
                 $a_tpl->setVariable('WEEK_CLASS', 'calminiinactive');
             }
             $a_tpl->setVariable('WEEK', $date->get(IL_CAL_FKT_DATE, 'W'));
             $a_tpl->parseCurrentBlock();
             $a_tpl->setCurrentBlock('month_row');
             $a_tpl->setVariable('TD_CLASS', 'calminiweek');
             $a_tpl->parseCurrentBlock();
             $week_has_events = false;
         }
     }
     $a_tpl->setCurrentBlock('mini_month');
     $a_tpl->setVariable('TXT_MONTH_OVERVIEW', $lng->txt("cal_month_overview"));
     $a_tpl->setVariable('TXT_MONTH', $lng->txt('month_' . $this->seed->get(IL_CAL_FKT_DATE, 'm') . '_long') . ' ' . $this->seed->get(IL_CAL_FKT_DATE, 'Y'));
     $myseed = clone $this->seed;
     $ilCtrl->setParameterByClass('ilcalendarmonthgui', 'seed', $myseed->get(IL_CAL_DATE));
     $a_tpl->setVariable('OPEN_MONTH_VIEW', $ilCtrl->getLinkTargetByClass('ilcalendarmonthgui', ''));
     $myseed->increment(ilDateTime::MONTH, -1);
     $ilCtrl->setParameter($this, 'seed', $myseed->get(IL_CAL_DATE));
     $a_tpl->setVariable('BL_TYPE', $this->getBlockType());
     $a_tpl->setVariable('BL_ID', $this->getBlockId());
     $a_tpl->setVariable('PREV_MONTH', $ilCtrl->getLinkTarget($this, "setSeed"));
     $a_tpl->setVariable('PREV_MONTH_ASYNC', $ilCtrl->getLinkTarget($this, "setSeed", "", true));
     $myseed->increment(ilDateTime::MONTH, 2);
     $ilCtrl->setParameter($this, 'seed', $myseed->get(IL_CAL_DATE));
     $a_tpl->setVariable('NEXT_MONTH', $ilCtrl->getLinkTarget($this, "setSeed"));
     $a_tpl->setVariable('NEXT_MONTH_ASYNC', $ilCtrl->getLinkTarget($this, "setSeed", "", true));
     $ilCtrl->setParameter($this, 'seed', "");
     $a_tpl->parseCurrentBlock();
 }
Exemple #28
0
<?php

exit;
define('ZONEINFO', '/usr/share/zoneinfo');
define('TZ_CONVERT', 'tz_convert');
define('READLINK', 'readlink');
chdir('../../..');
include_once 'include/inc.header.php';
include_once 'Services/Calendar/classes/class.ilCalendarUtil.php';
foreach (ilCalendarUtil::_getShortTimeZoneList() as $tz_name => $tmp) {
    $name_underscore = str_replace('/', '_', $tz_name);
    if (is_link(ZONEINFO . '/' . $tz_name)) {
        $name = exec(READLINK . ' -f ' . ZONEINFO . '/' . $tz_name);
    } else {
        $name = ZONEINFO . '/' . $tz_name;
    }
    exec(TZ_CONVERT . ' -o Services/Calendar/zoneinfo/' . $name_underscore . '.tmp' . ' ' . $name);
    $reader = fopen('Services/Calendar/zoneinfo/' . $name_underscore . '.tmp', 'r');
    $writer = fopen('Services/Calendar/zoneinfo/' . $name_underscore . '.ics', 'w');
    $counter = 0;
    while ($line = fgets($reader)) {
        if (++$counter < 4) {
            continue;
        }
        if ($counter == 5) {
            fputs($writer, 'TZID=' . $tz_name . "\n");
        } else {
            if (substr($line, 0, 13) === 'END:VCALENDAR') {
                break;
            }
            fputs($writer, $line);
 /**
  * Create calendar appointments
  * @param ilBookingEntry $booking
  * @return 
  */
 protected function createAppointments(ilBookingEntry $booking)
 {
     include_once './Services/Calendar/classes/class.ilDateList.php';
     $concurrent_dates = new ilDateList(ilDateList::TYPE_DATETIME);
     $start = clone $this->form->getItemByPostVar('st')->getDate();
     for ($i = 0; $i < $this->form->getItemByPostVar('ap')->getValue(); $i++) {
         $concurrent_dates->add(clone $start);
         $start->increment(ilDateTime::MINUTE, $this->form->getItemByPostVar('du')->getMinutes());
         $start->increment(ilDateTime::HOUR, $this->form->getItemByPostVar('du')->getHours());
         #$start = new ilDateTime(,IL_CAL_UNIX);
     }
     include_once './Services/Calendar/classes/class.ilCalendarUtil.php';
     $def_cat = ilCalendarUtil::initDefaultCalendarByType(ilCalendarCategory::TYPE_CH, $this->getUserId(), $this->lng->txt('cal_ch_personal_ch'), true);
     // Add calendar appointment for each
     include_once './Services/Calendar/classes/class.ilCalendarCategoryAssignments.php';
     include_once './Services/Calendar/classes/class.ilCalendarEntry.php';
     include_once './Services/Calendar/classes/class.ilCalendarRecurrenceCalculator.php';
     include_once './Services/Booking/classes/class.ilBookingPeriod.php';
     foreach ($concurrent_dates as $dt) {
         $end = clone $dt;
         $end->increment(ilDateTime::MINUTE, $this->form->getItemByPostVar('du')->getMinutes());
         $end->increment(ilDateTime::HOUR, $this->form->getItemByPostVar('du')->getHours());
         $calc = new ilCalendarRecurrenceCalculator(new ilBookingPeriod($dt, $end), $this->form->getItemByPostVar('frequence')->getRecurrence());
         // Calculate with one year limit
         $limit = clone $dt;
         $limit->increment(ilDAteTime::YEAR, 1);
         $date_list = $calc->calculateDateList($dt, $limit);
         foreach ($date_list as $app_start) {
             $app_end = clone $app_start;
             $app_end->increment(ilDateTime::MINUTE, $this->form->getItemByPostVar('du')->getMinutes());
             $entry = new ilCalendarEntry();
             $entry->setContextId($booking->getId());
             $entry->setTitle($this->form->getInput('ti'));
             $entry->setSubtitle("#consultationhour#");
             // dynamic, see ilCalendarEntry
             $entry->setDescription($this->form->getInput('de'));
             $entry->setLocation($this->form->getInput('lo'));
             $entry->setStart($app_start);
             $entry->setEnd($app_end);
             $entry->setTranslationType(IL_CAL_TRANSLATION_SYSTEM);
             $entry->save();
             $cat_assign = new ilCalendarCategoryAssignments($entry->getEntryId());
             $cat_assign->addAssignment($def_cat->getCategoryID());
         }
     }
 }
 /**
  * show appointment
  *
  * @access protected
  * @param array appointment
  */
 protected function showAppointment($a_app)
 {
     global $ilUser;
     $this->tpl->setCurrentBlock('panel_code');
     $this->tpl->setVariable('NUM', $this->num_appointments);
     $this->tpl->parseCurrentBlock();
     if (!$ilUser->prefs["screen_reader_optimization"]) {
         $this->tpl->setCurrentBLock('not_empty');
     } else {
         $this->tpl->setCurrentBLock('scrd_not_empty');
     }
     include_once './Services/Calendar/classes/class.ilCalendarAppointmentPanelGUI.php';
     $this->tpl->setVariable('PANEL_DATA', ilCalendarAppointmentPanelGUI::_getInstance($this->seed)->getHTML($a_app));
     $this->ctrl->clearParametersByClass('ilcalendarappointmentgui');
     $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'app_id', $a_app['event']->getEntryId());
     $this->tpl->setVariable('APP_EDIT_LINK', $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'edit'));
     $color = $this->app_colors->getColorByAppointment($a_app['event']->getEntryId());
     $style = 'background-color: ' . $color . ';';
     $style .= 'color:' . ilCalendarUtil::calculateFontColor($color);
     $td_style = $style;
     if ($a_app['event']->isFullDay()) {
         $title = $a_app['event']->getPresentationTitle();
     } else {
         switch ($this->user_settings->getTimeFormat()) {
             case ilCalendarSettings::TIME_FORMAT_24:
                 $title = $a_app['event']->getStart()->get(IL_CAL_FKT_DATE, 'H:i', $this->timezone);
                 break;
             case ilCalendarSettings::TIME_FORMAT_12:
                 $title = $a_app['event']->getStart()->get(IL_CAL_FKT_DATE, 'h:ia', $this->timezone);
                 break;
         }
         // add end time for screen readers
         if ($ilUser->prefs["screen_reader_optimization"]) {
             switch ($this->user_settings->getTimeFormat()) {
                 case ilCalendarSettings::TIME_FORMAT_24:
                     $title .= "-" . $a_app['event']->getEnd()->get(IL_CAL_FKT_DATE, 'H:i', $this->timezone);
                     break;
                 case ilCalendarSettings::TIME_FORMAT_12:
                     $title .= "-" . $a_app['event']->getEnd()->get(IL_CAL_FKT_DATE, 'h:ia', $this->timezone);
                     break;
             }
         }
         $title .= ' ' . $a_app['event']->getPresentationTitle();
         $td_style .= $a_app['event']->getPresentationStyle();
     }
     $this->tpl->setVariable('APP_TITLE', $title);
     $this->tpl->setVariable('LINK_NUM', $this->num_appointments);
     $this->tpl->setVariable('LINK_STYLE', $style);
     if (!$ilUser->prefs["screen_reader_optimization"]) {
         // provide table cell attributes
         $this->tpl->parseCurrentBlock();
         $this->tpl->setCurrentBlock('day_cell');
         $this->tpl->setVariable('DAY_CELL_NUM', $this->num_appointments);
         $this->tpl->setVariable('TD_ROWSPAN', $a_app['rowspan']);
         $this->tpl->setVariable('TD_STYLE', $td_style);
         $this->tpl->setVariable('TD_CLASS', 'calevent');
         $this->tpl->parseCurrentBlock();
     } else {
         // screen reader: work on div attributes
         $this->tpl->setVariable('DIV_STYLE', $style);
         $this->tpl->parseCurrentBlock();
     }
     $this->num_appointments++;
 }