validUser()) { $view_style = ($_SESSION['user_settings']->getViewStyle()) ? $_SESSION['user_settings']->getViewStyle() : VIEW_STYLE; // $timeout = ($_SESSION['user_settings']->getTimeout()) ? // (int) $_SESSION['user_settings']->getTimeout() : TIMEOUT; $week_start_sunday = ($_SESSION['user_settings']->getStartWeek() !== NULL) ? $_SESSION['user_settings']->getStartWeek() : WEEK_START_SUNDAY; $start_hour = ($_SESSION['user_settings']->getStartHour()) ? (int) $_SESSION['user_settings']->getStartHour() : START_HOUR; $end_hour = ($_SESSION['user_settings']->getEndHour()) ? (int) $_SESSION['user_settings']->getEndHour() : END_HOUR; } $pwd = WEB_ROOT; if ($pwd[strlen($pwd)-1] == '/') $pwd = substr($pwd, 0, -1); if (isset($_POST) && count($_POST) > 0) { $exclude = array('tzid','range','times','untildate'); $start = array('date' => NULL, 'time' => NULL); $end = array('date' => NULL, 'time' => NULL); $referer = $_POST['referer']; $allDay = false; foreach ($_POST as $key => $value) { //echo "$key => $value
"; if (strcmp($key, 'referer') == 0) continue; if (in_array($key, $exclude)) continue; if (strcasecmp($key, 'startdate') == 0) { $start['date'] = join('', explode('-',$value)); continue; } if (strcasecmp($key, 'starttime') == 0) { $start['time'] = $value; if (strlen($start['time']) < 5) $start['time'] .= '00'; continue; } if (strcasecmp($key, 'enddate') == 0) { $end['date'] = join('', explode('-',$value)); continue; } if (strcasecmp($key, 'endtime') == 0) { $end['time'] = $value; if (strlen($end['time']) < 5) $end['time'] .= '00'; continue; } if (strcasecmp("allDay", $key) == 0) { $allDay = true; continue; } if (strcasecmp("recurrence", $key) == 0) { $value = "FREQ=$value"; $key = "RRULE"; } //echo "$key => $value
"; $_SESSION['current_event']->setProperty($key, $value); } //echo 'DTSTART: '. $start['date'].'T'.$start['time']; //echo '
DTEND: '. $end['date'].'T'.$end['time']; //exit; if ($allDay) { $_SESSION['current_event']->setProperty( 'DTSTART;VALUE=DATE', $start['date']); $_SESSION['current_event']->setProperty( 'DTEND;VALUE=DATE', $end['date']); //echo "
".$start['date']."
"; //echo $end['date']."
"; } else { $start = strtotime($start['date'].'T'.$start['time']); $end = strtotime($end['date'].'T'.$end['time']); //echo "
".Calendar::timestamp2ICal($start, FALSE)."
"; //echo Calendar::timestamp2ICal($end, FALSE)."
"; //exit; $_SESSION['current_event']->setProperty('DTSTART', Calendar::timestamp2ICal($start, FALSE)); $_SESSION['current_event']->setProperty('DTEND', Calendar::timestamp2ICal($end, FALSE)); } //exit; if (isset($_SESSION['calendar'])) { $res = $_SESSION['calendar']->update( $_SESSION['current_event']->getUrl(), $_SESSION['current_event']->getEtag()); //print_r($res); //exit; unset($_SESSION['current_event']); unset($_SESSION['calendar']); unset($_SESSION['EVENT_ACTION']); if (count($res) == 0) { header('Location: ' . $referer); exit; } $msg = ''; foreach ($res as $elem) { $k = key($elem); $msg .= "$k: " . $elem[$k]; } } else throw new Exception("Error updating event"); //print "$msg\n"; $msg = join("", explode("\n", $msg)); $title = TITLE; $pwd = WEB_ROOT; $head = <<<__HEAD $title
calendar.png Logout
Logout
DAViCal Web Calendar
- A Web Interface for DAViCal
__HEAD; print "$head"; include TOP_FOLDER.'/include/menu.inc.php'; print "
"; include TOP_FOLDER.'/include/footer.inc.php'; exit; } else { $query = construct_URL($_SERVER['QUERY_STRING'], array('etag', 'referer', 'cal')); //print_r($_SESSION['all_events'][$query['cal']]); //exit; if (isset($query['cal']) && ! empty($query['cal'])) { $_SESSION['calendar'] = $_SESSION['all_events'][$query['cal']]; if (! is_object($_SESSION['calendar'])) throw new Exception("Missing calendar object"); if ($_SESSION['EVENT_ACTION'] == 'NEW') { $event = $_SESSION['calendar']->newComponent('VEVENT'); $_SESSION['current_event'] = $event; } else { foreach ($_SESSION['calendar'] as $vevent) { if ($vevent->getEtag() == $query['etag']) { $event = $vevent; break; } } $_SESSION['current_event'] = $event; } //print $query['referer']; //exit; $gui = new EventGUI($event, $query['referer'], $query['cal']); //unset($_GET['referer']); $calendar = $gui->getView(); } else { $text = '

Choose an event from one of the listed calendars

'; $text .= '

'; $text .= '

'; $text .= ''; $text .= ''; $calendar = ''; foreach ($_SESSION['all_events'] as $name => $cal) { //$calendar .= "$name
".var_export($cal, true)."
"; $text .= $name.':

'; } $text .= ''; $text .= '

'; //print "{$_GET['referer']}"; //exit; print popup_window($text, $query['referer']); exit; } } include TOP_FOLDER.'/include/header.inc.php'; include TOP_FOLDER.'/include/menu.inc.php'; print "
$calendar
"; include TOP_FOLDER.'/include/footer.inc.php'; ?>