public static function modifyPalette()
 {
     $arrDca =& $GLOBALS['TL_DCA']['tl_calendar_events'];
     if (($objEvent = \CalendarEventsModel::findByPk(\Input::get('id'))) !== null && $objEvent->useMemberAuthor) {
         $arrDca['palettes']['default'] = str_replace('author,', ',', $arrDca['palettes']['default']);
     } else {
         $arrDca['palettes']['default'] = str_replace('memberAuthor,', ',', $arrDca['palettes']['default']);
     }
 }
Exemplo n.º 2
0
 /**
  * Returns the event title concatenated with its date/time
  * @param $varEvent object|int The event id or the event object itself
  */
 public static function getDateTimeFormattedEvent($varEvent, $blnSeparatedDateTime = true, $strFormat = '%s (%s)')
 {
     $objEvent = $varEvent;
     if (is_numeric($varEvent)) {
         if (($objEvent = \CalendarEventsModel::findByPk($varEvent)) === null) {
             return '';
         }
     }
     $strDateTime = DateUtil::getFormattedDateTime($objEvent, $blnSeparatedDateTime);
     return sprintf($strFormat, $objEvent->title, $strDateTime);
 }
Exemplo n.º 3
0
 /**
  * Export an event as iCalendar (ics)
  */
 public function generateIcal($eventID)
 {
     $ical = new \vcalendar();
     $ical->setConfig('ical_' . $this->id);
     $ical->setProperty('method', 'PUBLISH');
     $ical->setProperty("X-WR-TIMEZONE", $GLOBALS['TL_CONFIG']['timeZone']);
     $time = time();
     // Get event
     $objEvent = \CalendarEventsModel::findByPk($eventID);
     $vevent = new \vevent();
     if ($objEvent->addTime) {
         $vevent->setProperty('dtstart', array('year' => date('Y', $objEvent->startTime), 'month' => date('m', $objEvent->startTime), 'day' => date('d', $objEvent->startTime), 'hour' => date('H', $objEvent->startTime), 'min' => date('i', $objEvent->startTime), 'sec' => 0));
         $vevent->setProperty('dtend', array('year' => date('Y', $objEvent->endTime), 'month' => date('m', $objEvent->endTime), 'day' => date('d', $objEvent->endTime), 'hour' => date('H', $objEvent->endTime), 'min' => date('i', $objEvent->endTime), 'sec' => 0));
     } else {
         $vevent->setProperty('dtstart', date('Ymd', $objEvent->startDate), array('VALUE' => 'DATE'));
         if (!strlen($objEvent->endDate) || $objEvent->endDate == 0) {
             $vevent->setProperty('dtend', date('Ymd', $objEvent->startDate + 24 * 60 * 60), array('VALUE' => 'DATE'));
         } else {
             $vevent->setProperty('dtend', date('Ymd', $objEvent->endDate + 24 * 60 * 60), array('VALUE' => 'DATE'));
         }
     }
     $vevent->setProperty('summary', $objEvent->title, ENT_QUOTES, 'UTF-8');
     $vevent->setProperty('description', strip_tags($objEvent->details ? $objEvent->details : $objEvent->teaser));
     if ($objEvent->recurring) {
         $count = 0;
         $arrRepeat = deserialize($objEvent->repeatEach);
         $arg = $arrRepeat['value'];
         $unit = $arrRepeat['unit'];
         if ($arg == 1) {
             $unit = substr($unit, 0, -1);
         }
         $strtotime = '+ ' . $arg . ' ' . $unit;
         $newstart = strtotime($strtotime, $objEvent->startTime);
         $newend = strtotime($strtotime, $objEvent->endTime);
         $freq = 'YEARLY';
         switch ($arrRepeat['unit']) {
             case 'days':
                 $freq = 'DAILY';
                 break;
             case 'weeks':
                 $freq = 'WEEKLY';
                 break;
             case 'months':
                 $freq = 'MONTHLY';
                 break;
             case 'years':
                 $freq = 'YEARLY';
                 break;
         }
         $rrule = array('FREQ' => $freq);
         if ($objEvent->recurrences > 0) {
             $rrule['count'] = $objEvent->recurrences;
         }
         if ($arg > 1) {
             $rrule['INTERVAL'] = $arg;
         }
         $vevent->setProperty('rrule', $rrule);
     }
     /*
      * begin module event_recurrences handling
      */
     if ($objEvent->repeatExecptions) {
         $arrSkipDates = deserialize($objEvent->repeatExecptions);
         foreach ($arrSkipDates as $skipDate) {
             $exTStamp = strtotime($skipDate);
             $exdate = array(array(date('Y', $exTStamp), date('m', $exTStamp), date('d', $exTStamp), date('H', $objEvent->startTime), date('i', $objEvent->startTime), date('s', $objEvent->startTime)));
             $vevent->setProperty('exdate', $exdate);
         }
     }
     /*
      * end module event_recurrences handling
      */
     $ical->setComponent($vevent);
     $ical->setConfig("FILENAME", urlencode($objEvent->title) . ".ics");
     $ical->returnCalendar();
 }
 public static function findRelatedEventEntity($varId, array $arrRelation, \ModuleModel $objModule = null)
 {
     if (!isset($arrRelation['table'])) {
         return null;
     }
     $strModelClass = \Model::getClassFromTable($arrRelation['table']);
     if (!class_exists($strModelClass)) {
         return null;
     }
     if ($objModule === null) {
         return \CalendarEventsModel::findByPk($varId);
     }
     return \CalendarEventsModel::findPublishedByParentAndIdOrAlias($varId, deserialize($objModule->cal_calendar));
 }