/**
  * check if a date is today 
  * @param ilDateTime $date date to check
  * @return bool
  * @static
  */
 public static function _isToday($date)
 {
     global $ilUser;
     if (!is_object(self::$today)) {
         self::$today = new ilDateTime(time(), IL_CAL_UNIX, $ilUser->getTimeZone());
     }
     return ilDateTime::_equals(self::$today, $date, IL_CAL_DAY, $ilUser->getTimeZone());
 }
 /**
  * Standard Version of Fill Row. Most likely to
  * be overwritten by derived class.
  */
 protected function fillRow($a_set)
 {
     global $lng, $ilCtrl;
     $now = new ilDateTime(time(), IL_CAL_UNIX);
     $this->tpl->setVariable("IMG_ALT", $lng->txt("obj_" . $a_set["type"]));
     $this->tpl->setVariable("IMG_SRC", ilObject::_getIcon($a_set["obj_id"], "small", $a_set["type"]));
     $this->tpl->setVariable("VAL_TITLE", $a_set["title"]);
     $this->tpl->setVariable("ID", $a_set["ref_id"]);
     $this->tpl->setVariable("TXT_LAST_EXPORT_FILE", $lng->txt("export_last_file"));
     $this->tpl->setVariable("TXT_OMIT", $lng->txt("export_omit"));
     $this->tpl->setVariable("TXT_CREATE_NEW_EXPORT_FILE", $lng->txt("export_create"));
     $preset = "CREATE";
     if ($a_set["timestamp"] > 0) {
         $last_export = new ilDateTime($a_set["timestamp"], IL_CAL_UNIX);
         $this->tpl->setVariable("VAL_LAST_EXPORT", ilDatePresentation::formatDate($last_export));
         if (ilDateTime::_equals($last_export, $now, IL_CAL_DAY)) {
             $preset = "LAST_FILE";
         }
     }
     $this->tpl->setVariable("SEL_" . $preset, ' checked="checked" ');
 }
 /**
  * Check whether an date is within a date duration given by start and end
  * @param ilDateTime $dt
  * @param ilDateTime $start
  * @param ilDateTime $end
  * @param type $a_compare_field
  * @param type $a_tz
  */
 public static function _within(ilDateTime $dt, ilDateTime $start, ilDateTime $end, $a_compare_field = '', $a_tz = '')
 {
     return (ilDateTime::_after($dt, $start, $a_compare_field, $a_tz) or ilDateTime::_equals($dt, $start, $a_compare_field, $a_tz)) && (ilDateTime::_before($dt, $end, $a_compare_field, $a_tz) or ilDateTime::_equals($dt, $end, $a_compare_field, $a_tz));
 }
 /**
  * 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();
 }
 /**
  * Check if date is tomorrow
  *
  * @access public
  * @param object ilDateTime DateTime object to check
  * @return bool
  * @static
  */
 public static function isTomorrow(ilDateTime $date)
 {
     global $ilUser;
     if (!is_object(self::$tomorrow)) {
         self::$tomorrow = new ilDateTime(time(), IL_CAL_UNIX, $ilUser->getTimeZone());
         self::$tomorrow->increment(IL_CAL_DAY, 1);
     }
     return ilDateTime::_equals(self::$tomorrow, $date, IL_CAL_DAY, $ilUser->getTimeZone());
 }
 /**
  * edit appointment
  *
  * @access protected
  * @param
  * @return
  */
 protected function edit($a_edit_single_app = false)
 {
     global $tpl, $ilUser, $ilErr, $ilHelp;
     $ilHelp->setScreenIdComponent("cal");
     $ilHelp->setScreenId("app");
     if ($this->app->isMilestone()) {
         $ilHelp->setSubScreenId("edit_milestone");
     } else {
         $ilHelp->setSubScreenId("edit");
     }
     include_once './Services/Calendar/classes/class.ilCalendarCategory.php';
     include_once './Services/Calendar/classes/class.ilCalendarCategories.php';
     include_once './Services/Calendar/classes/class.ilCalendarCategoryAssignments.php';
     $GLOBALS['ilCtrl']->saveParameter($this, array('seed', 'app_id', 'dt', 'idate'));
     if ($_REQUEST['rexl']) {
         $GLOBALS['ilCtrl']->setParameter($this, 'rexl', 1);
         // Calculate new appointment time
         $duration = $this->getAppointment()->getEnd()->get(IL_CAL_UNIX) - $this->getAppointment()->getStart()->get(IL_CAL_UNIX);
         include_once './Services/Calendar/classes/class.ilCalendarRecurrenceCalculator.php';
         $calc = new ilCalendarRecurrenceCalculator($this->getAppointment(), $this->rec);
         $current_date = new ilDateTime($_REQUEST['dt'], IL_CAL_UNIX);
         $yesterday = clone $current_date;
         $yesterday->increment(IL_CAL_DAY, -1);
         $tomorrow = clone $current_date;
         $tomorrow->increment(IL_CAL_DAY, 1);
         foreach ($calc->calculateDateList($current_date, $tomorrow, 1) as $date_entry) {
             if (ilDateTime::_equals($current_date, $date_entry, IL_CAL_DAY)) {
                 $this->getAppointment()->setStart(new ilDateTime($date_entry->get(IL_CAL_UNIX), IL_CAL_UNIX));
                 $this->getAppointment()->setEnd(new ilDateTime($date_entry->get(IL_CAL_UNIX) + $duration, IL_CAL_UNIX));
                 break;
             }
         }
         // Finally reset recurrence
         $this->rec = new ilCalendarRecurrence();
     }
     $cat_id = ilCalendarCategoryAssignments::_lookupCategory($this->app->getEntryId());
     $cats = ilCalendarCategories::_getInstance($ilUser->getId());
     if (!$cats->isVisible($cat_id)) {
         $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->WARNING);
         return false;
     }
     if (!$cats->isEditable($cat_id) or $this->app->isAutoGenerated()) {
         $this->showInfoScreen();
         return true;
     }
     $this->initForm('edit', $this->app->isMilestone(), $a_edit_single_app);
     $tpl->setContent($this->form->getHTML());
 }
 /**
  * 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();
 }
 /**
  * calculate date list
  *
  * @access public
  * @param object ilDateTime start of period
  * @param object ilDateTime end of period
  * @param int limit number of returned dates
  * @return ilDateList ilDateList 
  */
 public function calculateDateList(ilDateTime $a_start, ilDateTime $a_end, $a_limit = -1)
 {
     #		echo $a_start;
     #		echo $a_end;
     #		echo $this->event->getStart();
     #		echo $this->event->getEnd();
     $this->valid_dates = $this->initDateList();
     // Check invalid settings: e.g no frequence given, invalid start/end dates ...
     if (!$this->validateRecurrence()) {
         $this->valid_dates->add($this->event->getStart());
         return $this->valid_dates;
     }
     // Performance fix: Switching the timezone for many dates seems to be
     // quite time consuming.
     // Therfore we adjust the timezone of all input dates (start,end, event start)
     // to the same tz (UTC for fullday events, Recurrence tz for all others).
     $this->adjustTimeZones($a_start, $a_end);
     // Add start of event if it is in the period
     if (ilDateTime::_after($this->event->getStart(), $this->period_start, IL_CAL_DAY) and ilDateTime::_before($this->event->getStart(), $this->period_end, IL_CAL_DAY) or ilDateTime::_equals($this->event->getStart(), $this->period_start, IL_CAL_DAY)) {
         // begin-patch aptar
         $this->valid_dates->add($this->event->getStart());
         #$this->valid_dates->add($this->event->getStart());
         // end patch aptar
     }
     // Calculate recurrences based on frequency (e.g. MONTHLY)
     $time = microtime(true);
     $start = $this->optimizeStartingTime();
     #echo "ZEIT: ADJUST: ".(microtime(true) - $time).'<br>';
     $counter = 0;
     do {
         ++$counter;
         // initialize context for applied rules
         // E.g
         // RRULE:FREQ=YEARLY;BYMONTH=1;BYWEEKNO=1,50	=> context for BYWERKNO is monthly because it filters to the weeks in JAN
         // RRULE:FREQ=YEARLY;BYWEEKNO=1,50				=> context for BYWERKNO is yearly because it adds all weeks.
         $this->frequence_context = $this->recurrence->getFrequenceType();
         $freq_res = $this->initDateList();
         $freq_res->add($start);
         // Fixed sequence of applying rules (RFC 2445 4.3.10)
         $freq_res = $this->applyBYMONTHRules($freq_res);
         #echo "BYMONTH: ".$freq_res;
         $freq_res = $this->applyBYWEEKNORules($freq_res);
         #echo "BYWEEKNO: ".$freq_res;
         $freq_res = $this->applyBYYEARDAYRules($freq_res);
         #echo "BYYEARDAY: ".$freq_res;
         $freq_res = $this->applyBYMONTHDAYRules($freq_res);
         #echo "BYMONTHDAY: ".$freq_res;
         #$time = microtime(true);
         $freq_res = $this->applyBYDAYRules($freq_res);
         #echo "ZEIT: ".(microtime(true) - $time);
         #echo "BYDAY: ".$freq_res;
         $freq_res = $this->applyBYSETPOSRules($freq_res);
         #echo "BYSETPOS: ".$freq_res;
         $freq_res = $this->applyLimits($freq_res);
         #echo $freq_res;
         $start = $this->incrementByFrequency($start);
         if (ilDateTime::_after($start, $this->period_end) or $this->limit_reached) {
             break;
         }
     } while (true);
     $this->applyExclusionDates();
     $this->valid_dates->sort();
     // Restore default timezone
     ilTimeZone::_restoreDefaultTimeZone();
     return $this->valid_dates;
 }
 /**
  * Updates properties
  */
 public function updateProperties()
 {
     /**
      * @var $ilCtrl ilCtrl
      */
     global $ilCtrl;
     $this->initPropertiesForm();
     $formValid = $this->form->checkInput();
     $duration = $this->form->getInput("duration");
     if ($this->form->getInput('time_type_selection') == 'permanent_room' && ilAdobeConnectServer::getSetting('enable_perm_room', '1')) {
         $durationValid = true;
     } else {
         if ($duration['hh'] * 60 + $duration['mm'] < 10) {
             global $lng;
             $this->form->getItemByPostVar('duration')->setAlert($lng->txt('min_duration_error'));
             $durationValid = false;
         } else {
             $durationValid = true;
         }
     }
     $oldObject = new ilObjAdobeConnect();
     $oldObject->setId($this->object->getId());
     $oldObject->doRead();
     $time_mismatch = false;
     if ($formValid && $durationValid) {
         $newStartDate = $this->form->getItemByPostVar("start_date")->getDate();
         $newDuration = $this->form->getInput("duration");
         $unix_newStartDate = $newStartDate->getUnixTime();
         $newEndDate = new ilDateTime($unix_newStartDate + $newDuration['hh'] * 3600 + $newDuration['mm'] * 60, IL_CAL_UNIX);
         if (!ilDateTime::_equals($newStartDate, $oldObject->getStartDate()) || !ilDateTime::_equals($newEndDate, $oldObject->getEndDate())) {
             $serverConfig = ilAdobeConnectServer::_getInstance();
             //				$minTime = new ilDateTime(time() + $serverConfig->getScheduleLeadTime() * 60 * 60, IL_CAL_UNIX);
             /*		if(ilDateTime::_before($newStartDate, $minTime))
             				{
             					ilUtil::sendFailure(sprintf($this->pluginObj->txt('xavc_lead_time_mismatch'), ilDatePresentation::formatDate($minTime)), true);
             					$time_mismatch = true;
             				}
             		*/
         }
         $this->object->setTitle($this->form->getInput("title"));
         $this->object->setDescription($this->form->getInput("desc"));
         $this->object->setInstructions($this->form->getInput('instructions'));
         $this->object->setContactInfo($this->form->getInput('contact_info'));
         $enable_perm_room = ilAdobeConnectServer::getSetting('enable_perm_room', '1') && $this->form->getInput('time_type_selection') == 'permanent_room' ? true : false;
         $this->object->setPermanentRoom($enable_perm_room ? 1 : 0);
         $this->object->setReadContents((int) $this->form->getInput('read_contents'));
         $this->object->setReadRecords((int) $this->form->getInput('read_records'));
         $access_level = ilObjAdobeConnect::ACCESS_LEVEL_PROTECTED;
         if (in_array($this->form->getInput('access_level'), array(ilObjAdobeConnect::ACCESS_LEVEL_PRIVATE, ilObjAdobeConnect::ACCESS_LEVEL_PROTECTED, ilObjAdobeConnect::ACCESS_LEVEL_PUBLIC))) {
             $access_level = $this->form->getInput('access_level');
         }
         $this->object->setPermission($access_level);
         if (!$time_mismatch || $this->form->getInput('time_type_selection') == 'permanent_room' && ilAdobeConnectServer::getSetting('enable_perm_room', '1')) {
             $this->object->setStartDate($this->form->getItemByPostVar("start_date")->getDate());
             $duration = $this->form->getInput("duration");
             $this->object->setDuration(array("hours" => $duration["hh"], "minutes" => $duration["mm"]));
         }
         $concurrent_vcs = $this->object->checkConcurrentMeetingDates();
         $num_max_ac_obj = ilAdobeConnectServer::getSetting('ac_interface_objects');
         if ((int) $num_max_ac_obj <= 0 || (int) count($concurrent_vcs) < (int) $num_max_ac_obj) {
             $this->object->update();
             ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
             $ilCtrl->redirect($this, 'editProperties');
         } else {
             ilUtil::sendFailure($this->pluginObj->txt('maximum_concurrent_vcs_reached'), true);
             $ilCtrl->redirect($this, 'editProperties');
         }
     }
     $this->form->setValuesByPost();
 }
 /**
  * fill data section
  *
  * @access public
  * 
  */
 public function show()
 {
     global $tpl, $ilUser;
     $this->tpl = new ilTemplate('tpl.month_view.html', true, true, 'Services/Calendar');
     include_once './Services/YUI/classes/class.ilYuiUtil.php';
     ilYuiUtil::initDragDrop();
     ilYuiUtil::initPanel();
     $navigation = new ilCalendarHeaderNavigationGUI($this, $this->seed, ilDateTime::MONTH);
     $this->tpl->setVariable('NAVIGATION', $navigation->getHTML());
     for ($i = (int) $this->user_settings->getWeekStart(); $i < 7 + (int) $this->user_settings->getWeekStart(); $i++) {
         $this->tpl->setCurrentBlock('month_header_col');
         $this->tpl->setVariable('TXT_WEEKDAY', ilCalendarUtil::_numericDayToString($i, true));
         $this->tpl->parseCurrentBlock();
     }
     if (isset($_GET["bkid"])) {
         $user_id = $_GET["bkid"];
         $disable_empty = true;
         $no_add = true;
     } else {
         if ($ilUser->getId() == ANONYMOUS_USER_ID) {
             $user_id = $ilUser->getId();
             $disable_empty = false;
             $no_add = true;
         } else {
             $user_id = $ilUser->getId();
             $disable_empty = false;
             $no_add = false;
         }
     }
     $is_portfolio_embedded = false;
     if (ilCalendarCategories::_getInstance()->getMode() == ilCalendarCategories::MODE_PORTFOLIO_CONSULTATION) {
         $no_add = true;
         $is_portfolio_embedded = true;
     }
     include_once 'Services/Calendar/classes/class.ilCalendarSchedule.php';
     $this->scheduler = new ilCalendarSchedule($this->seed, ilCalendarSchedule::TYPE_MONTH, $user_id);
     $this->scheduler->addSubitemCalendars(true);
     if (sizeof($this->schedule_filters)) {
         foreach ($this->schedule_filters as $filter) {
             $this->scheduler->addFilter($filter);
         }
     }
     $this->scheduler->calculate();
     include_once 'Services/Calendar/classes/class.ilCalendarSettings.php';
     $settings = ilCalendarSettings::_getInstance();
     $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++;
         $has_events = (bool) $this->showEvents($date);
         if (!$no_add) {
             include_once "Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php";
             $this->ctrl->clearParametersByClass('ilcalendarappointmentgui');
             $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'idate', $date->get(IL_CAL_DATE));
             $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'seed', $this->seed->get(IL_CAL_DATE));
             $new_app_url = $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'add');
             if ($settings->getEnableGroupMilestones()) {
                 $this->ctrl->clearParametersByClass('ilcalendarappointmentgui');
                 $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'seed', $this->seed->get(IL_CAL_DATE));
                 $this->ctrl->setParameterByClass('ilcalendarappointmentgui', 'idate', $date->get(IL_CAL_DATE));
                 $new_ms_url = $this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui', 'addMilestone');
                 $this->tpl->setCurrentBlock("new_ms");
                 $this->tpl->setVariable('DD_ID', $date->get(IL_CAL_UNIX));
                 $this->tpl->setVariable('DD_TRIGGER', ilGlyphGUI::get(ilGlyphGUI::ADD));
                 $this->tpl->setVariable('URL_DD_NEW_APP', $new_app_url);
                 $this->tpl->setVariable('TXT_DD_NEW_APP', $this->lng->txt('cal_new_app'));
                 $this->tpl->setVariable('URL_DD_NEW_MS', $new_ms_url);
                 $this->tpl->setVariable('TXT_DD_NEW_MS', $this->lng->txt('cal_new_ms'));
                 $this->tpl->parseCurrentBlock();
             } else {
                 $this->tpl->setCurrentBlock("new_app");
                 $this->tpl->setVariable('ADD_LINK', $new_app_url);
                 $this->tpl->setVariable('NEW_SRC', ilGlyphGUI::get(ilGlyphGUI::ADD, $this->lng->txt('cal_new_app')));
                 $this->tpl->parseCurrentBlock();
             }
         }
         $day = $date->get(IL_CAL_FKT_DATE, 'j');
         $month = $date->get(IL_CAL_FKT_DATE, 'n');
         if ($day == 1) {
             $month_day = '1 ' . ilCalendarUtil::_numericMonthToString($month, false);
         } else {
             $month_day = $day;
         }
         if (!$is_portfolio_embedded && (!$disable_empty || $has_events)) {
             $this->tpl->setCurrentBlock('month_day_link');
             $this->ctrl->clearParametersByClass('ilcalendardaygui');
             $this->ctrl->setParameterByClass('ilcalendardaygui', 'seed', $date->get(IL_CAL_DATE));
             $this->tpl->setVariable('OPEN_DAY_VIEW', $this->ctrl->getLinkTargetByClass('ilcalendardaygui', ''));
             $this->ctrl->clearParametersByClass('ilcalendardaygui');
         } else {
             $this->tpl->setCurrentBlock('month_day_no_link');
         }
         $this->tpl->setVariable('MONTH_DAY', $month_day);
         $this->tpl->parseCurrentBlock();
         $this->tpl->setCurrentBlock('month_col');
         include_once './Services/Calendar/classes/class.ilCalendarUtil.php';
         if (ilCalendarUtil::_isToday($date)) {
             $this->tpl->setVariable('TD_CLASS', 'caltoday');
         } elseif (ilDateTime::_equals($date, $this->seed, IL_CAL_MONTH)) {
             $this->tpl->setVariable('TD_CLASS', 'calstd');
         } elseif (ilDateTime::_before($date, $this->seed, IL_CAL_MONTH)) {
             $this->tpl->setVariable('TD_CLASS', 'calprev');
         } else {
             $this->tpl->setVariable('TD_CLASS', 'calnext');
         }
         $this->tpl->parseCurrentBlock();
         if ($counter and !($counter % 7)) {
             $this->tpl->setCurrentBlock('month_row');
             $this->tpl->parseCurrentBlock();
         }
     }
 }
Beispiel #11
0
 public function removeByDAY(ilDateTime $remove)
 {
     foreach ($this->list_item as $key => $dt) {
         if (ilDateTime::_equals($remove, $dt, IL_CAL_DAY, ilTimeZone::UTC)) {
             unset($this->list_item[$key]);
         }
     }
     return true;
 }
 /**
  * Updates properties
  */
 public function updateProperties()
 {
     /**
      * @var $ilCtrl ilCtrl
      */
     global $ilCtrl, $lng;
     $this->initPropertiesForm();
     $formValid = $this->form->checkInput();
     $duration = $this->form->getInput("duration");
     if ($this->form->getInput('time_type_selection') == 'permanent_room') {
         $durationValid = true;
     } else {
         if ($duration['hh'] * 60 + $duration['mm'] < 10) {
             $this->form->getItemByPostVar('duration')->setAlert($lng->txt('min_duration_error'));
             $durationValid = false;
         } else {
             $durationValid = true;
         }
     }
     $oldObject = new ilObjAdobeConnect();
     $oldObject->setId($this->object->getId());
     $oldObject->doRead();
     $time_mismatch = false;
     if ($formValid && $durationValid) {
         $newStartDate = $this->form->getItemByPostVar("start_date")->getDate();
         $newDuration = $this->form->getInput("duration");
         $unix_newStartDate = $newStartDate->getUnixTime();
         $newEndDate = new ilDateTime($unix_newStartDate + $newDuration['hh'] * 3600 + $newDuration['mm'] * 60, IL_CAL_UNIX);
         if (!ilDateTime::_equals($newStartDate, $oldObject->getStartDate()) || !ilDateTime::_equals($newEndDate, $oldObject->getEndDate())) {
             $serverConfig = ilAdobeConnectServer::_getInstance();
             $minTime = new ilDateTime(time() + $serverConfig->getScheduleLeadTime() * 60 * 60, IL_CAL_UNIX);
         }
         $this->object->setTitle($this->form->getInput("title"));
         $this->object->setDescription($this->form->getInput("desc"));
         $this->object->setInstructions($this->form->getInput('instructions'));
         $this->object->setContactInfo($this->form->getInput('contact_info'));
         $this->object->setPermanentRoom($this->form->getInput('time_type_selection') == 'permanent_room' ? 1 : 0);
         $this->object->setReadContents((int) $this->form->getInput('read_contents'));
         $this->object->setReadRecords((int) $this->form->getInput('read_records'));
         $this->object->setMeetingLang($this->form->getInput('meeting_lang'));
         $this->object->setMaxPax($this->form->getInput('max_pax'));
         $access_level = ilObjAdobeConnect::ACCESS_LEVEL_PROTECTED;
         if (in_array($this->form->getInput('access_level'), array(ilObjAdobeConnect::ACCESS_LEVEL_PRIVATE, ilObjAdobeConnect::ACCESS_LEVEL_PROTECTED, ilObjAdobeConnect::ACCESS_LEVEL_PUBLIC))) {
             $access_level = $this->form->getInput('access_level');
         }
         $this->object->setPermission($access_level);
         if (!$time_mismatch || $this->form->getInput('time_type_selection') == 'permanent_room') {
             $this->object->setStartDate($this->form->getItemByPostVar("start_date")->getDate());
             $duration = $this->form->getInput("duration");
             $this->object->setDuration(array("hours" => $duration["hh"], "minutes" => $duration["mm"]));
         }
         $concurrent_vcs = $this->object->checkConcurrentMeetingDates();
         $num_max_ac_obj = ilAdobeConnectServer::getSetting('ac_interface_objects');
         if ((int) $num_max_ac_obj <= 0 || (int) count($concurrent_vcs) < (int) $num_max_ac_obj) {
             $this->object->update();
             ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
             $ilCtrl->redirect($this, 'editProperties');
         } else {
             ilUtil::sendFailure($this->pluginObj->txt('maximum_concurrent_vcs_reached'), true);
             $ilCtrl->redirect($this, 'editProperties');
         }
     } else {
         $this->pluginObj->includeClass('class.ilAdobeConnectServer.php');
         $this->tabs->activateTab("properties");
         $this->object->setTitle($this->form->getInput("title"));
         $this->object->setDescription($this->form->getInput("desc"));
         $this->object->setInstructions($this->form->getInput('instructions'));
         $this->object->setContactInfo($this->form->getInput('contact_info'));
         $this->object->setPermanentRoom($this->form->getInput('time_type_selection') == 'permanent_room' ? 1 : 0);
         $this->object->setReadContents((int) $this->form->getInput('read_contents'));
         $this->object->setReadRecords((int) $this->form->getInput('read_records'));
         $this->object->setMeetingLang($this->form->getInput('meeting_lang'));
         $this->object->setMaxPax($this->form->getInput('max_pax'));
         $this->getPropertiesValues();
         $settings = ilAdobeConnectServer::_getInstance();
         $max_allowed_pax = $settings->getSetting('max_pax');
         if (empty($max_allowed_pax)) {
             $max_allowed_pax = 200;
         }
         if ($this->object->getMaxPax() > $max_allowed_pax) {
             $this->form->getItemByPostVar('max_pax')->setAlert($this->pluginObj->txt('max_size_error') . ' ' . $max_allowed_pax);
         }
         if (ilAdobeConnectServer::getSetting('show_free_slots')) {
             $this->showCreationForm($this->form);
         } else {
             $this->tpl->setContent($this->form->getHtml());
         }
     }
     $this->form->setValuesByPost();
 }