/** * Constructor * * @access public * @param ilDate seed date * @param int type of schedule (TYPE_DAY,TYPE_WEEK or TYPE_MONTH) * @param int user_id * */ public function __construct(ilDate $seed, $a_type, $a_user_id = 0) { global $ilUser, $ilDB; $this->db = $ilDB; $this->type = $a_type; $this->initPeriod($seed); if (!$a_user_id || $a_user_id == $ilUser->getId()) { $this->user = $ilUser; } else { $this->user = new ilObjUser($a_user_id); } $this->user_settings = ilCalendarUserSettings::_getInstanceByUserId($this->user->getId()); $this->weekstart = $this->user_settings->getWeekStart(); $this->timezone = $this->user->getTimeZone(); // category / event filters include_once './Services/Calendar/classes/class.ilCalendarCategories.php'; // portfolio does custom filter handling (booking group ids) if (ilCalendarCategories::_getInstance()->getMode() != ilCalendarCategories::MODE_PORTFOLIO_CONSULTATION) { // consultation hour calendar views do not mind calendar category visibility if (ilCalendarCategories::_getInstance()->getMode() != ilCalendarCategories::MODE_CONSULTATION) { // this is the "default" filter which handles currently hidden categories for the user include_once './Services/Calendar/classes/class.ilCalendarScheduleFilterHidden.php'; $this->addFilter(new ilCalendarScheduleFilterHidden($this->user->getId())); } else { // handle booking visibility (target object, booked out) include_once './Services/Calendar/classes/class.ilCalendarScheduleFilterBookings.php'; $this->addFilter(new ilCalendarScheduleFilterBookings($this->user->getId())); } } }
public function __construct($a_title, $a_postvar) { global $lng, $tpl, $ilUser; $this->lng = $lng; $this->lng->loadLanguageModule('dateplaner'); $this->user_settings = ilCalendarUserSettings::_getInstanceByUserId($ilUser->getId()); $tpl->addJavascript("./Services/Calendar/js/recurrence_input.js"); parent::__construct($a_title, $a_postvar); }
/** * Constructor * * @access public * @param * @return */ public function __construct(ilDate $seed, $a_par_obj) { global $ilUser, $lng; $this->user_settings = ilCalendarUserSettings::_getInstanceByUserId($ilUser->getId()); $this->tpl = new ilTemplate('tpl.minical.html', true, true, 'Services/Calendar'); $this->lng = $lng; $this->lng->loadLanguageModule('dateplaner'); $this->seed = $seed; $this->setParentObject($a_par_obj); }
/** * init categories * * @access protected * @param * @return */ protected function initCategories() { include_once './Services/Calendar/classes/class.ilCalendarUserSettings.php'; if (ilCalendarUserSettings::_getInstance()->getCalendarSelectionType() == ilCalendarUserSettings::CAL_SELECTION_MEMBERSHIP) { $this->mode = ilCalendarCategories::MODE_PERSONAL_DESKTOP_MEMBERSHIP; } else { $this->mode = ilCalendarCategories::MODE_PERSONAL_DESKTOP_ITEMS; } include_once './Services/Calendar/classes/class.ilCalendarCategories.php'; ilCalendarCategories::_getInstance()->initialize($this->mode, (int) $_GET['ref_id'], true); }
/** * Constructor * * @access public * @param * */ public function __construct() { global $ilUser, $tpl, $lng, $ilCtrl; $this->tpl = $tpl; $this->lng = $lng; $this->lng->loadLanguageModule('dateplaner'); $this->lng->loadLanguageModule('jscalendar'); $this->ctrl = $ilCtrl; $this->user = $ilUser; $this->settings = ilCalendarSettings::_getInstance(); $this->user_settings = ilCalendarUserSettings::_getInstanceByUserId($this->user->getId()); }
/** * Constructor * * @access public * @param * */ public function __construct(ilDate $seed_date) { global $ilCtrl, $lng, $ilUser, $ilTabs, $tpl; $this->seed = $seed_date; $this->tpl = $tpl; $this->lng = $lng; $this->ctrl = $ilCtrl; $this->tabs_gui = $ilTabs; $this->user_settings = ilCalendarUserSettings::_getInstanceByUserId($ilUser->getId()); $this->app_colors = new ilCalendarAppointmentColors($ilUser->getId()); $this->timezone = $ilUser->getTimeZone(); }
/** * Constructor * * @access public * @param * */ public function __construct() { global $ilCtrl, $lng, $tpl, $ilTabs, $ilUser; $this->ctrl = $ilCtrl; $this->lng = $lng; $this->lng->loadLanguageModule('dateplaner'); $this->tpl = $tpl; $this->tabs_gui = $ilTabs; include_once './Services/Calendar/classes/class.ilCalendarCategories.php'; $cats = ilCalendarCategories::_getInstance($ilUser->getId()); include_once './Services/Calendar/classes/class.ilCalendarUserSettings.php'; if (ilCalendarUserSettings::_getInstance()->getCalendarSelectionType() == ilCalendarUserSettings::CAL_SELECTION_MEMBERSHIP) { $cats->initialize(ilCalendarCategories::MODE_PERSONAL_DESKTOP_MEMBERSHIP); } else { $cats->initialize(ilCalendarCategories::MODE_PERSONAL_DESKTOP_ITEMS); } }
/** * Constructor. * * @param ilDate seed date * @param int type of schedule (TYPE_DAY,TYPE_WEEK or TYPE_MONTH) * @param int user_id * @param ilRoomSharingRoom $room */ public function __construct(ilDate $seed, $a_type, $a_user_id = 0, ilRoomSharingRoom $room) { global $ilUser, $ilDB; $this->room_obj = $room; $this->db = $ilDB; $this->type = $a_type; $this->initPeriod($seed); if (!$a_user_id || $a_user_id == $ilUser->getId()) { $this->user = $ilUser; } else { $this->user = new ilObjUser($a_user_id); } $this->user_settings = ilCalendarUserSettings::_getInstanceByUserId($this->user->getId()); $this->weekstart = $this->user_settings->getWeekStart(); $this->timezone = $this->user->getTimeZone(); $this->ilRoomSharingDatabase = new ilRoomsharingDatabase($room->getPoolId()); }
/** * Constructor * * @access public * @param ilDate seed date * @param int type of schedule (TYPE_DAY,TYPE_WEEK or TYPE_MONTH) * @param int user_id * */ public function __construct(ilDate $seed, $a_type, $a_user_id = 0, $filter_bookings = false) { global $ilUser, $ilDB; $this->db = $ilDB; $this->type = $a_type; $this->initPeriod($seed); if (!$a_user_id || $a_user_id == $ilUser->getId()) { $this->user = $ilUser; } else { $this->user = new ilObjUser($a_user_id); } $this->filter_bookings = $filter_bookings; $this->user_settings = ilCalendarUserSettings::_getInstanceByUserId($this->user->getId()); $this->weekstart = $this->user_settings->getWeekStart(); $this->timezone = $this->user->getTimeZone(); $this->hidden_cat = ilCalendarHidden::_getInstanceByUserId($this->user->getId()); }
/** * init mini-calendar * * Used to display personal appointments and bookings in the minicalendar * copied from ilPDBlockCalendar * * @access protected */ private function initCalendar() { global $ilUser; include_once './Services/Calendar/classes/class.ilCalendarCategories.php'; $cats = ilCalendarCategories::_getInstance($ilUser->getId()); include_once './Services/Calendar/classes/class.ilCalendarUserSettings.php'; if (ilCalendarUserSettings::_getInstance()->getCalendarSelectionType() == ilCalendarUserSettings::CAL_SELECTION_MEMBERSHIP) { $cats->initialize(ilCalendarCategories::MODE_PERSONAL_DESKTOP_MEMBERSHIP); } else { $cats->initialize(ilCalendarCategories::MODE_PERSONAL_DESKTOP_ITEMS); } //if there was no calendar-category before or the calendar was deleted $categoriesInfo = $cats->getCategoriesInfo(); if ($this->cal_cat_id == 0 || !isset($categoriesInfo[$this->cal_cat_id])) { //create a new calendar-category $this->cal_cat_id = $this->createBookingsCalendarCategory(); } }
/** * Constructor */ function ilCalendarSelectionBlockGUI($a_seed) { global $ilCtrl, $lng; $this->lng = $lng; parent::__construct(); $lng->loadLanguageModule('pd'); $lng->loadLanguageModule('dateplaner'); $this->setLimit(5); $this->allow_moving = false; $this->seed = $a_seed; $this->setTitle($lng->txt('cal_table_categories')); include_once './Services/Calendar/classes/class.ilCalendarUserSettings.php'; $sel_type = ilCalendarUserSettings::_getInstance()->getCalendarSelectionType(); $ilCtrl->setParameterByClass("ilcalendarcategorygui", 'calendar_mode', ilCalendarUserSettings::CAL_SELECTION_ITEMS); $ilCtrl->setParameterByClass("ilcalendarcategorygui", 'seed', $this->seed->get(IL_CAL_DATE)); $this->addBlockCommand($ilCtrl->getLinkTargetByClass("ilcalendarcategorygui", 'switchCalendarMode'), $lng->txt('pd_my_offers'), "", "", false, $sel_type == ilCalendarUserSettings::CAL_SELECTION_ITEMS); $ilCtrl->setParameterByClass("ilcalendarcategorygui", 'calendar_mode', ilCalendarUserSettings::CAL_SELECTION_MEMBERSHIP); $ilCtrl->setParameterByClass("ilcalendarcategorygui", 'seed', $this->seed->get(IL_CAL_DATE)); $this->addBlockCommand($ilCtrl->getLinkTargetByClass("ilcalendarcategorygui", 'switchCalendarMode'), $lng->txt('pd_my_memberships'), "", "", false, $sel_type == ilCalendarUserSettings::CAL_SELECTION_MEMBERSHIP); $ilCtrl->setParameterByClass("ilcalendarcategorygui", 'calendar_mode', ""); $this->addBlockCommand($ilCtrl->getLinkTargetByClass("ilcalendarcategorygui", 'add'), $lng->txt('cal_add_calendar')); }
public function __construct($a_calendar_ids = array()) { $this->calendars = $a_calendar_ids; $this->writer = new ilICalWriter(); $this->user_settings = ilCalendarUserSettings::_getInstanceByUserId($GLOBALS['ilUser']->getId()); }
/** * Save general settings */ public function saveGeneralSettings() { global $tpl, $lng, $ilCtrl, $ilUser; $this->initGeneralSettingsForm(); if ($this->form->checkInput()) { if ($this->workWithUserSetting("skin_style")) { //set user skin and style if ($_POST["skin_style"] != "") { $sknst = explode(":", $_POST["skin_style"]); if ($ilUser->getPref("style") != $sknst[1] || $ilUser->getPref("skin") != $sknst[0]) { $ilUser->setPref("skin", $sknst[0]); $ilUser->setPref("style", $sknst[1]); } } } // language if ($this->workWithUserSetting("language")) { $ilUser->setLanguage($_POST["language"]); } // hits per page if ($this->workWithUserSetting("hits_per_page")) { if ($_POST["hits_per_page"] != "") { $ilUser->setPref("hits_per_page", $_POST["hits_per_page"]); } } // set show users online if ($this->workWithUserSetting("show_users_online")) { $ilUser->setPref("show_users_online", $_POST["show_users_online"]); } // store last visited? global $ilNavigationHistory; $ilUser->setPref("store_last_visited", (int) $_POST["store_last_visited"]); if ((int) $_POST["store_last_visited"] > 0) { $ilNavigationHistory->deleteDBEntries(); if ((int) $_POST["store_last_visited"] == 2) { $ilNavigationHistory->deleteSessionEntries(); } } // set hide own online_status if ($this->workWithUserSetting("hide_own_online_status")) { if ($_POST["hide_own_online_status"] == 1) { $ilUser->setPref("hide_own_online_status", "y"); } else { $ilUser->setPref("hide_own_online_status", "n"); } } // set show users online if ($this->workWithUserSetting("screen_reader_optimization")) { $ilUser->setPref("screen_reader_optimization", $_POST["screen_reader_optimization"]); } // session reminder include_once 'Services/Authentication/classes/class.ilSessionReminder.php'; if (ilSessionReminder::isGloballyActivated()) { $ilUser->setPref('session_reminder_enabled', (int) $this->form->getInput('session_reminder_enabled')); $ilUser->setPref('session_reminder_lead_time', $this->form->getInput('session_reminder_lead_time')); } // starting point include_once "Services/User/classes/class.ilUserUtil.php"; if (ilUserUtil::hasPersonalStartingPoint()) { ilUserUtil::setPersonalStartingPoint($this->form->getInput('usr_start'), $this->form->getInput('usr_start_ref_id')); } // 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->getFormValues($this->form); $ilUser->setPref('char_selector_availability', $char_selector->getConfig()->getAvailability()); $ilUser->setPref('char_selector_definition', $char_selector->getConfig()->getDefinition()); } $ilUser->update(); // calendar settings include_once 'Services/Calendar/classes/class.ilCalendarUserSettings.php'; $user_settings = ilCalendarUserSettings::_getInstanceByUserId($ilUser->getId()); $user_settings->setTimeZone($this->form->getInput("timezone")); $user_settings->setDateFormat((int) $this->form->getInput("date_format")); $user_settings->setTimeFormat((int) $this->form->getInput("time_format")); $user_settings->save(); ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true); $ilCtrl->redirect($this, "showGeneralSettings"); } $this->form->setValuesByPost(); $this->showGeneralSettings(true); }
/** * Constructor * * @param boolean skip initialisation (is called by derived PDCalendarBlockGUI class) */ function ilCalendarBlockGUI($a_skip_init = false) { global $ilCtrl, $lng, $ilUser, $tpl, $ilHelp; parent::ilBlockGUI(); $this->ctrl = $ilCtrl; $lng->loadLanguageModule("dateplaner"); $ilHelp->addHelpSection("cal_block"); include_once "./Services/News/classes/class.ilNewsItem.php"; $ilCtrl->saveParameter($this, 'bkid'); if (!$a_skip_init) { $this->initCategories(); $this->setBlockId($ilCtrl->getContextObjId()); } $this->setLimit(5); // @todo: needed? // alex: original detail level 1 did not work anymore $this->setAvailableDetailLevels(1); $this->setEnableNumInfo(false); if (!isset($_GET["bkid"])) { $title = $lng->txt("calendar"); } else { $title = $lng->txt("cal_consultation_hours_for") . " " . ilObjUser::_lookupFullname($_GET["bkid"]); } $this->setTitle($title); //$this->setData($data); $this->allow_moving = false; //$this->handleView(); include_once 'Services/Calendar/classes/class.ilDate.php'; include_once 'Services/Calendar/classes/class.ilCalendarUserSettings.php'; $seed_str = ""; if ((!isset($_GET["seed"]) || $_GET["seed"] == "") && isset($_SESSION["il_cal_block_" . $this->getBlockType() . "_" . $this->getBlockId() . "_seed"])) { $seed_str = $_SESSION["il_cal_block_" . $this->getBlockType() . "_" . $this->getBlockId() . "_seed"]; } else { if (isset($_GET["seed"])) { $seed_str = $_GET["seed"]; } } if (isset($_GET["seed"]) && $_GET["seed"] != "") { $_SESSION["il_cal_block_" . $this->getBlockType() . "_" . $this->getBlockId() . "_seed"] = $_GET["seed"]; } if ($seed_str == "") { $this->seed = new ilDate(time(), IL_CAL_UNIX); // @todo: check this } else { $this->seed = new ilDate($seed_str, IL_CAL_DATE); // @todo: check this } $this->user_settings = ilCalendarUserSettings::_getInstanceByUserId($ilUser->getId()); $tpl->addCSS("./Services/Calendar/css/calendar.css"); // @todo: this must work differently... $tpl->addCSS("./Services/Calendar/templates/default/delos.css"); $mode = $ilUser->getPref("il_pd_cal_mode"); $this->display_mode = $mode ? $mode : "mmon"; }
/** * Confirmation screen to cancel consultation appointment or ressource booking * depends on calendar category */ public function cancelBooking() { global $ilUser, $tpl; $entry = (int) $_GET['app_id']; include_once 'Services/Calendar/classes/class.ilCalendarEntry.php'; $entry = new ilCalendarEntry($entry); $category = $this->calendarEntryToCategory($entry); if ($category->getType() == ilCalendarCategory::TYPE_CH) { include_once 'Services/Booking/classes/class.ilBookingEntry.php'; $booking = new ilBookingEntry($entry->getContextId()); if (!$booking->hasBooked($entry->getEntryId())) { $this->ctrl->returnToParent($this); return false; } $entry_title = ' ' . $entry->getTitle() . " (" . ilObjUser::_lookupFullname($booking->getObjId()) . ')'; } else { if ($category->getType() == ilCalendarCategory::TYPE_BOOK) { $entry_title = ' ' . $entry->getTitle(); } else { $this->ctrl->returnToParent($this); return false; } } $user_settings = ilCalendarUserSettings::_getInstanceByUserId($ilUser->getId()); $timezone = $ilUser->getTimeZone(); switch ($user_settings->getTimeFormat()) { case ilCalendarSettings::TIME_FORMAT_24: $title = $entry->getStart()->get(IL_CAL_FKT_DATE, 'H:i', $timezone); $title .= "-" . $entry->getEnd()->get(IL_CAL_FKT_DATE, 'H:i', $timezone); break; case ilCalendarSettings::TIME_FORMAT_12: $title = $entry->getStart()->get(IL_CAL_FKT_DATE, 'h:ia', $timezone); $title .= "-" . $entry->getEnd()->get(IL_CAL_FKT_DATE, 'h:ia', $timezone); break; } include_once 'Services/Utilities/classes/class.ilConfirmationGUI.php'; $conf = new ilConfirmationGUI(); $conf->setFormAction($this->ctrl->getFormAction($this)); $conf->setHeaderText($this->lng->txt('cal_cancel_booking_info')); $conf->setConfirm($this->lng->txt('cal_cancel_booking'), 'cancelconfirmed'); $conf->setCancel($this->lng->txt('cancel'), 'cancel'); $conf->addItem('app_id', $entry->getEntryId(), $title . ' - ' . $entry_title); $tpl->setContent($conf->getHTML()); }
/** * 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(); }
protected function renderSlots(ilBookingSchedule $schedule, array $object_ids, $title) { global $ilUser; // fix if (!$schedule->getRaster()) { $mytpl = new ilTemplate('tpl.booking_reservation_fix.html', true, true, 'Modules/BookingManager'); $mytpl->setVariable('FORM_ACTION', $this->ctrl->getFormAction($this)); $mytpl->setVariable('TXT_TITLE', $this->lng->txt('book_reservation_title')); $mytpl->setVariable('TXT_INFO', $this->lng->txt('book_reservation_fix_info')); $mytpl->setVariable('TXT_OBJECT', $title); $mytpl->setVariable('TXT_CMD_BOOK', $this->lng->txt('book_confirm_booking')); $mytpl->setVariable('TXT_CMD_CANCEL', $this->lng->txt('cancel')); include_once 'Services/Calendar/classes/class.ilCalendarUserSettings.php'; $user_settings = ilCalendarUserSettings::_getInstanceByUserId($ilUser->getId()); $morning_aggr = $user_settings->getDayStart(); $evening_aggr = $user_settings->getDayEnd(); $hours = array(); for ($i = $morning_aggr; $i <= $evening_aggr; $i++) { switch ($user_settings->getTimeFormat()) { case ilCalendarSettings::TIME_FORMAT_24: if ($morning_aggr > 0 && $i == $morning_aggr) { $hours[$i] = sprintf('%02d:00', 0) . "-"; } $hours[$i] .= sprintf('%02d:00', $i); if ($evening_aggr < 23 && $i == $evening_aggr) { $hours[$i] .= "-" . sprintf('%02d:00', 23); } break; case ilCalendarSettings::TIME_FORMAT_12: if ($morning_aggr > 0 && $i == $morning_aggr) { $hours[$i] = date('h a', mktime(0, 0, 0, 1, 1, 2000)) . "-"; } $hours[$i] .= date('h a', mktime($i, 0, 0, 1, 1, 2000)); if ($evening_aggr < 23 && $i == $evening_aggr) { $hours[$i] .= "-" . date('h a', mktime(23, 0, 0, 1, 1, 2000)); } break; } } if (isset($_GET['seed'])) { $find_first_open = false; $seed = new ilDate($_GET['seed'], IL_CAL_DATE); } else { $find_first_open = true; $seed = new ilDate(time(), IL_CAL_UNIX); } include_once 'Services/Calendar/classes/class.ilCalendarUtil.php'; include_once 'Modules/BookingManager/classes/class.ilBookingReservation.php'; $week_start = $user_settings->getWeekStart(); if (!$find_first_open) { $dates = array(); $this->buildDatesBySchedule($week_start, $hours, $schedule, $object_ids, $seed, $dates); } else { $dates = array(); $has_open_slot = $this->buildDatesBySchedule($week_start, $hours, $schedule, $object_ids, $seed, $dates); // find first open slot if (!$has_open_slot) { // 1 year is limit for search $limit = clone $seed; $limit->increment(ilDate::YEAR, 1); $limit = $limit->get(IL_CAL_UNIX); while (!$has_open_slot && $seed->get(IL_CAL_UNIX) < $limit) { $seed->increment(ilDate::WEEK, 1); $dates = array(); $has_open_slot = $this->buildDatesBySchedule($week_start, $hours, $schedule, $object_ids, $seed, $dates); } } } include_once 'Services/Calendar/classes/class.ilCalendarHeaderNavigationGUI.php'; $navigation = new ilCalendarHeaderNavigationGUI($this, $seed, ilDateTime::WEEK, 'book'); $mytpl->setVariable('NAVIGATION', $navigation->getHTML()); foreach (ilCalendarUtil::_buildWeekDayList($seed, $week_start)->get() as $date) { $date_info = $date->get(IL_CAL_FKT_GETDATE, '', 'UTC'); $mytpl->setCurrentBlock('weekdays'); $mytpl->setVariable('TXT_WEEKDAY', ilCalendarUtil::_numericDayToString($date_info['wday'])); $mytpl->setVariable('TXT_DATE', $date_info['mday'] . ' ' . ilCalendarUtil::_numericMonthToString($date_info['mon'])); $mytpl->parseCurrentBlock(); } include_once 'Services/Calendar/classes/class.ilCalendarAppointmentColors.php'; include_once 'Services/Calendar/classes/class.ilCalendarUtil.php'; $color = array(); $all = ilCalendarAppointmentColors::_getColorsByType('crs'); for ($loop = 0; $loop < 7; $loop++) { $col = $all[$loop]; $fnt = ilCalendarUtil::calculateFontColor($col); $color[$loop + 1] = 'border-bottom: 1px solid ' . $col . '; background-color: ' . $col . '; color: ' . $fnt; } $counter = 0; foreach ($dates as $hour => $days) { $caption = $days; $caption = array_shift($caption); for ($loop = 1; $loop < 8; $loop++) { if (!isset($days[$loop])) { $mytpl->setCurrentBlock('dates'); $mytpl->setVariable('DUMMY', ' '); $mytpl->parseCurrentBlock(); } else { if (isset($days[$loop]['captions'])) { foreach ($days[$loop]['captions'] as $slot_id => $slot_caption) { $mytpl->setCurrentBlock('choice'); $mytpl->setVariable('TXT_DATE', $slot_caption); $mytpl->setVariable('VALUE_DATE', $slot_id); $mytpl->setVariable('DATE_COLOR', $color[$loop]); $mytpl->parseCurrentBlock(); } $mytpl->setCurrentBlock('dates'); $mytpl->setVariable('DUMMY', ''); $mytpl->parseCurrentBlock(); } else { if (isset($days[$loop]['in_slot'])) { $mytpl->setCurrentBlock('dates'); $mytpl->setVariable('DATE_COLOR', $color[$loop]); $mytpl->parseCurrentBlock(); } else { $mytpl->setCurrentBlock('dates'); $mytpl->setVariable('DUMMY', ' '); $mytpl->parseCurrentBlock(); } } } } $mytpl->setCurrentBlock('slots'); $mytpl->setVariable('TXT_HOUR', $caption); if ($counter % 2) { $mytpl->setVariable('CSS_ROW', 'tblrow1'); } else { $mytpl->setVariable('CSS_ROW', 'tblrow2'); } $mytpl->parseCurrentBlock(); $counter++; } } else { // :TODO: inactive for now } return $mytpl->get(); }
public function toICal($a_user_id) { $ical = 'RRULE:'; $ical .= 'FREQ=' . $this->getFrequenceType(); if ($this->getInterval()) { $ical .= ';INTERVAL=' . $this->getInterval(); } if ($this->getFrequenceUntilCount()) { $ical .= ';COUNT=' . $this->getFrequenceUntilCount(); } elseif ($this->getFrequenceUntilDate()) { $ical .= ';UNTIL=' . $this->getFrequenceUntilDate()->get(IL_CAL_FKT_DATE, 'Ymd'); } if ($this->getBYMONTH()) { $ical .= ';BYMONTH=' . $this->getBYMONTH(); } if ($this->getBYWEEKNO()) { $ical .= ';BYWEEKNO=' . $this->getBYWEEKNO(); } if ($this->getBYYEARDAY()) { $ical .= ';BYYEARDAY=' . $this->getBYYEARDAY(); } if ($this->getBYMONTHDAY()) { $ical .= ';BYMONTHDAY=' . $this->getBYMONTHDAY(); } if ($this->getBYDAY()) { $ical .= ';BYDAY=' . $this->getBYDAY(); } if ($this->getBYSETPOS()) { $ical .= ';BYSETPOS=' . $this->getBYSETPOS(); } // Required in outlook if ($this->getBYDAY()) { include_once './Services/Calendar/classes/class.ilCalendarUserSettings.php'; include_once './Services/Calendar/classes/class.ilCalendarSettings.php'; $us = ilCalendarUserSettings::_getInstanceByUserId($a_user_id); if ($us->getWeekStart() == ilCalendarSettings::WEEK_START_MONDAY) { $ical .= ';WKST=MO'; } else { $ical .= ';WKST=SU'; } } return $ical; }
/** * 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(); }
/** * initialize visible categories * * @access public * @param int mode * @param int ref_id of root node * @return */ public function initialize($a_mode, $a_source_ref_id = 0, $a_use_cache = false) { $this->setMode($a_mode); if ($a_use_cache) { // Read categories from cache if ($cats = ilCalendarCache::getInstance()->getEntry($this->user_id . ':' . $a_mode . ':categories:' . (int) $a_source_ref_id)) { if ($this->getMode() != self::MODE_CONSULTATION && $this->getMode() != self::MODE_PORTFOLIO_CONSULTATION) { $this->wakeup($cats); return; } } } switch ($this->getMode()) { case self::MODE_REMOTE_ACCESS: include_once './Services/Calendar/classes/class.ilCalendarUserSettings.php'; if (ilCalendarUserSettings::_getInstance()->getCalendarSelectionType() == ilCalendarUserSettings::CAL_SELECTION_MEMBERSHIP) { $this->readPDCalendars(); } else { $this->readSelectedItemCalendars(); } break; case self::MODE_REMOTE_SELECTED: $this->readSelectedCalendar($a_source_ref_id); break; case self::MODE_PERSONAL_DESKTOP_MEMBERSHIP: $this->readPDCalendars(); break; case self::MODE_PERSONAL_DESKTOP_ITEMS: $this->readSelectedItemCalendars(); break; case self::MODE_REPOSITORY: $this->root_ref_id = $a_source_ref_id; $this->root_obj_id = ilObject::_lookupObjId($this->root_ref_id); $this->readReposCalendars(); break; case self::MODE_MANAGE: $this->readPDCalendars(); $this->readSelectedItemCalendars(); break; case self::MODE_CONSULTATION: #$this->readPrivateCalendars(); $this->setTargetRefId($a_source_ref_id); $this->readConsultationHoursCalendar($a_source_ref_id); break; case self::MODE_PORTFOLIO_CONSULTATION: $this->readConsultationHoursCalendar(); break; } if ($a_use_cache) { // Store in cache ilCalendarCache::getInstance()->storeEntry($this->user_id . ':' . $a_mode . ':categories:' . (int) $a_source_ref_id, $this->sleep(), $this->user_id, $a_mode, 'categories'); } }
/** * 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(); }
/** * Switch calendar selection nmode * @return */ protected function switchCalendarMode() { include_once './Services/Calendar/classes/class.ilCalendarUserSettings.php'; ilCalendarUserSettings::_getInstance()->setCalendarSelectionType((int) $_GET['calendar_mode']); ilCalendarUserSettings::_getInstance()->save(); $this->ctrl->returnToParent($this); }
protected function buildDatesBySchedule($week_start, array $hours, $schedule, array $object_ids, $seed, array &$dates) { global $ilUser; include_once 'Services/Calendar/classes/class.ilCalendarUserSettings.php'; $user_settings = ilCalendarUserSettings::_getInstanceByUserId($ilUser->getId()); $map = array('mo', 'tu', 'we', 'th', 'fr', 'sa', 'su'); $definition = $schedule->getDefinition(); $has_open_slot = false; foreach (ilCalendarUtil::_buildWeekDayList($seed, $week_start)->get() as $date) { $date_info = $date->get(IL_CAL_FKT_GETDATE, '', 'UTC'); $slots = array(); if (isset($definition[$map[$date_info['isoday'] - 1]])) { $slots = array(); foreach ($definition[$map[$date_info['isoday'] - 1]] as $slot) { $slot = explode('-', $slot); $slots[] = array('from' => str_replace(':', '', $slot[0]), 'to' => str_replace(':', '', $slot[1])); } } $last = array_pop(array_keys($hours)); $slot_captions = array(); foreach ($hours as $hour => $period) { $dates[$hour][0] = $period; $period = explode("-", $period); // #13738 if ($user_settings->getTimeFormat() == ilCalendarSettings::TIME_FORMAT_12) { if (stristr($period[0], "pm")) { $period[0] = (int) $period[0] + 12; } else { $period[0] = (int) $period[0]; if ($period[0] == 12) { $period[0] = 0; } } if (sizeof($period) == 2) { if (stristr($period[1], "pm")) { $period[1] = (int) $period[1] + 12; } else { $period[1] = (int) $period[1]; if ($period[1] == 12) { $period[1] = 0; } } } } if (sizeof($period) == 1) { $period_from = (int) substr($period[0], 0, 2) . "00"; $period_to = (int) substr($period[0], 0, 2) . "59"; } else { $period_from = (int) substr($period[0], 0, 2) . "00"; $period_to = (int) substr($period[1], 0, 2) . "59"; } $column = $date_info['isoday']; if (!$week_start) { if ($column < 7) { $column++; } else { $column = 1; } } if (sizeof($slots)) { $in = false; foreach ($slots as $slot) { $slot_from = mktime(substr($slot['from'], 0, 2), substr($slot['from'], 2, 2), 0, $date_info["mon"], $date_info["mday"], $date_info["year"]); $slot_to = mktime(substr($slot['to'], 0, 2), substr($slot['to'], 2, 2), 0, $date_info["mon"], $date_info["mday"], $date_info["year"]); // always single object, we can sum up $nr_available = (array) ilBookingReservation::getAvailableObject($object_ids, $slot_from, $slot_to - 1, false, true); // check deadline if ($slot_from < time() + $schedule->getDeadline() * 60 * 60 || !array_sum($nr_available)) { continue; } // is slot active in current hour? if ((int) $slot['from'] < $period_to && (int) $slot['to'] > $period_from) { $from = ilDatePresentation::formatDate(new ilDateTime($slot_from, IL_CAL_UNIX)); $from = array_pop(explode(' ', $from)); $to = ilDatePresentation::formatDate(new ilDateTime($slot_to, IL_CAL_UNIX)); $to = array_pop(explode(' ', $to)); // show caption (first hour) of slot $id = $slot_from . '_' . $slot_to; if (!in_array($id, $slot_captions)) { $dates[$hour][$column]['captions'][$id] = $from . '-' . $to; $dates[$hour][$column]['available'][$id] = array_sum($nr_available); $slot_captions[] = $id; } $in = true; } } // (any) active slot if ($in) { $has_open_slot = true; $dates[$hour][$column]['in_slot'] = $in; } } } } return $has_open_slot; }