event = $event; $this->referer = urldecode($referer); $this->cal = $cal; //print $this->referer; //exit; $this->summary = ''; $this->location = ''; $this->description = ''; $this->start = ''; $this->end = ''; $this->timezone = ''; $this->localtime = ($_SESSION['user_settings']->getTimeZone() !== NULL) ? $_SESSION['user_settings']->getTimeZone() : TIMEZONE; $root = WEB_ROOT; $week_start_sunday = ($_SESSION['user_settings']->getStartWeek() !== NULL) ? $_SESSION['user_settings']->getStartWeek() : WEEK_START_SUNDAY; $week_start_sunday = ($week_start_sunday) ? 0 : 1; $this->startdate = <<< __CAL1 __CAL1; $this->enddate = <<< __CAL1 __CAL1; $this->until = <<< __CAL1 __CAL1; } private function parseEvent() { if (! $this->event) return FALSE; $comp = $this->event->getBaseComponent(); $this->summary = $comp->GetPValue('SUMMARY'); $this->location = $comp->GetPValue('LOCATION'); $this->description = $comp->GetPValue('DESCRIPTION'); $this->start = $comp->GetPValue('DTSTART'); $this->end = $comp->GetPValue('DTEND'); $this->timezone = $this->event->getTZID(); $rrule = $this->event->getRRule(); $this->dates = $rrule->getEventDates(); $this->rrule = $rrule->getAll(); //echo $this->start .':'. $this->end .''; return TRUE; } private function createDT($elem, $name) { $res = array(); //print_r($elem); //echo ''; if (count($elem) > 1) { $date = $elem[0]; $time = substr($elem[1], 0, 4); } else { $date = $elem[0]; $time = '2359'; } for ($i = 0; $i < substr($time, 2); $i += 15); if ($i < 10) $i = "0$i"; $time = substr($time, 0, 2) . $i; //echo "$time"; $options = array(); for ($i = 0; $i < 24; $i++) { $h = ($i < 10) ? "0$i" : $i; $stop = ($i == 23) ? 61 : 60; for ($j = 0; $j < $stop; $j += 15) { $m = ($j < 10) ? "0$j" : $j; if ($m == 60) $m = 59; $hm = "$h$m"; //echo "$hm"; $option = ""; foreach ($options as $option) $select .= $option; $select .= ''; $date = substr($date, 0, 4).'-'.substr($date, 4, 2).'-'.substr($date, 6); //echo "$date"; $res['date'] = $date; $res['time'] = $select; return $res; } private function createTime() { include_once 'timezone.php'; if ($this->start == '' || $this->end == '') { $this->start = date("Ymd\THis"); $this->end = date("Ymd\THis", strtotime("+1 hour")); $this->timezone = $_SESSION['user_settings']->getTimeZone(); } //echo $this->start .':'. $this->end .''; $tz = ''; foreach ($timezones as $timezone) { $tz .= "localtime == $timezone) $tz .= ' selected="selected"'; $tz .= ">$timezone"; } $tz .= ""; $dateFormat = new DateFormat(); $UTCStart = $dateFormat->UTC2Client($this->start); $UTCEnd = $dateFormat->UTC2Client($this->end); //echo $UTCStart .':'. $UTCEnd .''; $startArray = explode('T', $UTCStart); //echo "Client: ".$dateFormat->client2UTC($dateFormat->UTC2Client($this->start)).""; //echo "Local: ".$dateFormat->UTC2Local($this->start).""; $start = $this->createDT($startArray, 'starttime'); $endArray = explode('T', $UTCEnd); $end = $this->createDT($endArray, 'endtime'); $allDay = CaldavRessource::allDayEvent($UTCStart, $UTCEnd); $allDay = ($allDay) ? 'checked="checked"' : ''; $datetime = "Date & Time All Day Event Start $this->startdate {$start['time']} $tz End $this->enddate {$end['time']} "; return $datetime; } private function recurRule($checked) { $choices = array('DAILY', 'WEEKLY', 'MONTHLY', 'YEARLY'); $rule = 'Recurrence Types'; foreach ($choices as $choice) { $rule .= "Recurrence Range No ending date End after Occurrence(s) End on {$this->until} _RULE; return $rule; } private function createRecur() { $recur = NULL; $rrule = NULL; if ($this->rrule) { $rrule = array_diff_key($this->rrule, array('freq' => '')); switch ($this->rrule['freq'][0]) { case 'DAILY': $recur = 'DAILY'; break; case 'WEEKLY': $recur = 'WEEKLY'; break; case 'MONTHLY': $recur = 'MONTHLY'; break; case 'YEARLY': $recur = 'YEARLY'; break; } } $recur = $this->recurRule($recur); $range = $this->rangeRule($rrule); //print htmlentities($recur); $res = <<<_TABLE Recurrence Rule $recur $range _TABLE; return $res; } function getView() { $title = ''; $location = ''; $description = '_DESC_'; if ($this->parseEvent()) { $title = str_replace('_SUM_', $this->summary, $title); $location = str_replace('_LOC_', $this->location, $location); $description = str_replace('_DESC_', $this->description, $description); } else { $title = str_replace('_SUM_', '', $title); $location = str_replace('_LOC_', '', $location); $description = str_replace('_DESC_', '', $description); } $btn_label = ($_SESSION['EVENT_ACTION'] == 'NEW') ? "Create" : "Update"; unset($_SESSION['EVENT_ACTION']); // for delete button $etag = $this->event->getEtag(); $url = $this->event->getUrl(); $view = dirname($_SERVER['PHP_SELF']).'/delete_event.php'; //['starttime', 'enddate', 'endtime'] $view = " General Title$title Location$location Description$description ". $this->createTime()."". $this->createRecur(). " referer\" name=\"referer\"/> referer'\"/> cal&referer=$this->referer'\"/> "; return $view; } } ?>
referer\" name=\"referer\"/> referer'\"/> cal&referer=$this->referer'\"/>