0) {
$calendar = dav_get_current_user_calendar_by_id($server, $calendar_id, DAV_ACL_WRITE);
if (!$calendar) {
$calendar = dav_get_current_user_calendar_by_id($server, $calendar_id, DAV_ACL_READ);
$calendars = array();
} else {
$calendars = dav_get_current_user_calendars($server, DAV_ACL_WRITE);
}
if ($calendar == null) return "Calendar not found";
$obj_uri = Sabre_CalDAV_Backend_Common::loadCalendarobjectById($uri);
$vObject = dav_get_current_user_calendarobject($server, $calendar, $obj_uri["uri"], DAV_ACL_WRITE);
$component = dav_get_eventComponent($vObject);
if ($component == null) return t('Could not open component for editing');
/** @var Sabre_VObject_Property_DateTime $dtstart */
$dtstart = $component->__get("DTSTART");
$event = array(
"id" => IntVal($uri),
"Summary" => ($component->__get("SUMMARY") ? $component->__get("SUMMARY")->value : null),
"StartTime" => $dtstart->getDateTime()->getTimeStamp(),
"EndTime" => Sabre_CalDAV_Backend_Common::getDtEndTimeStamp($component),
"IsAllDayEvent" => (strlen($dtstart->value) == 8),
"Description" => ($component->__get("DESCRIPTION") ? $component->__get("DESCRIPTION")->value : null),
"Location" => ($component->__get("LOCATION") ? $component->__get("LOCATION")->value : null),
"Color" => ($component->__get("X-ANIMEXX-COLOR") ? $component->__get("X-ANIMEXX-COLOR")->value : null),
);
$exdates = $component->select("EXDATE");
$recurrentce_exdates = array();
/** @var Sabre_VObject_Property_MultiDateTime $x */
foreach ($exdates as $x) {
/** @var DateTime $y */
$z = $x->getDateTimes();
foreach ($z as $y) $recurrentce_exdates[] = $y->getTimeStamp();
}
if ($component->select("RRULE")) $recurrence = new Sabre_VObject_RecurrenceIterator($vObject, (string)$component->__get("UID"));
else $recurrence = null;
} elseif (isset($_REQUEST["start"]) && $_REQUEST["start"] > 0) {
$calendars = dav_get_current_user_calendars($server, DAV_ACL_WRITE);
$calendar = dav_get_current_user_calendar_by_id($server, $calendar_id, DAV_ACL_WRITE);
$event = array(
"id" => 0,
"Summary" => $_REQUEST["title"],
"StartTime" => InTVal($_REQUEST["start"]),
"EndTime" => IntVal($_REQUEST["end"]),
"IsAllDayEvent" => $_REQUEST["isallday"],
"Description" => "",
"Location" => "",
"Color" => null,
);
if ($_REQUEST["isallday"]) {
$notifications = array(array("rel" => "start", "type" => "duration", "period" => "hour", "period_val" => 24));
} else {
$notifications = array(array("rel" => "start", "type" => "duration", "period" => "hour", "period_val" => 1));
}
$recurrence = null;
$recurrentce_exdates = array();
} else {
$calendars = dav_get_current_user_calendars($server, DAV_ACL_WRITE);
$calendar = dav_get_current_user_calendar_by_id($server, $calendar_id, DAV_ACL_WRITE);
$event = array(
"id" => 0,
"Summary" => "",
"StartTime" => time(),
"EndTime" => time() + 3600,
"IsAllDayEvent" => "0",
"Description" => "",
"Location" => "",
"Color" => null,
);
$notifications = array(array("rel" => "start", "type" => "duration", "period" => "hour", "period_val" => 1));
$recurrence = null;
$recurrentce_exdates = array();
}
$postto = $baseurl . "/dav/wdcal/" . ($uri == 0 ? "new/" : $calendar_id . "/" . $uri . "/edit/");
$out = "" . t("Go back to the calendar") . "
";
$out .= "
!"; echo $part_freq . "\n"; var_dump($_REQUEST); echo ""; die(); */ if ($part_freq == "") return; if (isset($_REQUEST["rec_interval"])) $part_freq .= ";INTERVAL=" . InTVal($_REQUEST["rec_interval"]); if (isset($_REQUEST["rec_exceptions"])) { $arr = array(); foreach ($_REQUEST["rec_exceptions"] as $except) { $arr[] = new DateTime(date("Y-m-d H:i:s", $except)); } /** @var Sabre_VObject_Property_MultiDateTime $prop */ $prop = Sabre_VObject_Property::create("EXDATE"); $prop->setDateTimes($arr); $component->add($prop); } $rrule = $part_freq . $part_until; $component->add(new Sabre_VObject_Property("RRULE", $rrule)); } /** * @param string $uri * @param string $recurr_uri * @param int $uid * @param string $timezone * @param string $goaway_url * @return array */ function wdcal_postEditPage($uri, $recurr_uri = "", $uid = 0, $timezone = "", $goaway_url = "") { $uid = IntVal($uid); $localization = wdcal_local::getInstanceByUser($uid); $server = dav_create_server(true, true, false); if ($uri > 0) { $calendar = dav_get_current_user_calendar_by_id($server, $_REQUEST["calendar"], DAV_ACL_READ); $obj_uri = Sabre_CalDAV_Backend_Common::loadCalendarobjectById($uri); $obj_uri = $obj_uri["uri"]; $vObject = dav_get_current_user_calendarobject($server, $calendar, $obj_uri, DAV_ACL_WRITE); $component = dav_get_eventComponent($vObject); if ($component == null) return array("ok" => false, "msg" => t('Could not open component for editing')); } else { $calendar = dav_get_current_user_calendar_by_id($server, $_REQUEST["calendar"], DAV_ACL_WRITE); $vObject = dav_create_empty_vevent(); $component = dav_get_eventComponent($vObject); $obj_uri = $component->__get("UID"); } wdcal_set_component_date($component, $localization); wdcal_set_component_recurrence($component, $localization); $component->__unset("LOCATION"); $component->__unset("SUMMARY"); $component->__unset("DESCRIPTION"); $component->__unset("X-ANIMEXX-COLOR"); $component->add("SUMMARY", icalendar_sanitize_string(dav_compat_parse_text_serverside("summary"))); $component->add("LOCATION", icalendar_sanitize_string(dav_compat_parse_text_serverside("location"))); $component->add("DESCRIPTION", icalendar_sanitize_string(dav_compat_parse_text_serverside("wdcal_desc"))); if (isset($_REQUEST["color_override"])) { $component->add("X-ANIMEXX-COLOR", $_REQUEST["color"]); } $data = $vObject->serialize(); if ($uri == 0) { $calendar->createFile($obj_uri . ".ics", $data); } else { $obj = $calendar->getChild($obj_uri); $obj->put($data); } return array("ok" => false, "msg" => t("Saved")); } /** * @return string */ function wdcal_getEditPage_exception_selector() { header("Content-type: application/json"); $a = get_app(); $localization = wdcal_local::getInstanceByUser($a->user["uid"]); $vObject = dav_create_empty_vevent(); foreach ($vObject->getComponents() as $component) { if ($component->name !== 'VTIMEZONE') break; } /** @var Sabre_VObject_Component_VEvent $component */ wdcal_set_component_date($component, $localization); wdcal_set_component_recurrence($component, $localization); $it = new Sabre_VObject_RecurrenceIterator($vObject, (string)$component->__get("UID")); $max_ts = mktime(0, 0, 0, 1, 1, CALDAV_MAX_YEAR + 1); $last_start = 0; $o = "