|
|
|
@ -16,7 +16,7 @@ function wdcal_getEditPage_str(&$localization, $baseurl, $uid, $calendar_id, $ur
|
|
|
|
|
if ($uri > 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);
|
|
|
|
|
$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);
|
|
|
|
@ -26,25 +26,25 @@ function wdcal_getEditPage_str(&$localization, $baseurl, $uid, $calendar_id, $ur
|
|
|
|
|
|
|
|
|
|
$obj_uri = Sabre_CalDAV_Backend_Common::loadCalendarobjectById($uri);
|
|
|
|
|
|
|
|
|
|
$vObject = dav_get_current_user_calendarobject($server, $calendar, $obj_uri["uri"], DAV_ACL_WRITE);
|
|
|
|
|
$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),
|
|
|
|
|
$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),
|
|
|
|
|
"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),
|
|
|
|
|
"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");
|
|
|
|
|
$exdates = $component->select("EXDATE");
|
|
|
|
|
$recurrentce_exdates = array();
|
|
|
|
|
/** @var Sabre_VObject_Property_MultiDateTime $x */
|
|
|
|
|
foreach ($exdates as $x) {
|
|
|
|
@ -58,7 +58,7 @@ function wdcal_getEditPage_str(&$localization, $baseurl, $uid, $calendar_id, $ur
|
|
|
|
|
|
|
|
|
|
} 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);
|
|
|
|
|
$calendar = dav_get_current_user_calendar_by_id($server, $calendar_id, DAV_ACL_WRITE);
|
|
|
|
|
|
|
|
|
|
$event = array(
|
|
|
|
|
"id" => 0,
|
|
|
|
@ -66,33 +66,33 @@ function wdcal_getEditPage_str(&$localization, $baseurl, $uid, $calendar_id, $ur
|
|
|
|
|
"StartTime" => InTVal($_REQUEST["start"]),
|
|
|
|
|
"EndTime" => IntVal($_REQUEST["end"]),
|
|
|
|
|
"IsAllDayEvent" => $_REQUEST["isallday"],
|
|
|
|
|
"Description" => "",
|
|
|
|
|
"Location" => "",
|
|
|
|
|
"Color" => "#5858ff",
|
|
|
|
|
"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;
|
|
|
|
|
$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);
|
|
|
|
|
$calendar = dav_get_current_user_calendar_by_id($server, $calendar_id, DAV_ACL_WRITE);
|
|
|
|
|
|
|
|
|
|
$event = array(
|
|
|
|
|
$event = array(
|
|
|
|
|
"id" => 0,
|
|
|
|
|
"Summary" => "",
|
|
|
|
|
"StartTime" => time(),
|
|
|
|
|
"EndTime" => time() + 3600,
|
|
|
|
|
"IsAllDayEvent" => "0",
|
|
|
|
|
"Description" => "",
|
|
|
|
|
"Location" => "",
|
|
|
|
|
"Color" => "#5858ff",
|
|
|
|
|
"Location" => "",
|
|
|
|
|
"Color" => null,
|
|
|
|
|
);
|
|
|
|
|
$notifications = array(array("rel" => "start", "type" => "duration", "period" => "hour", "period_val" => 1));
|
|
|
|
|
$recurrence = null;
|
|
|
|
|
$notifications = array(array("rel" => "start", "type" => "duration", "period" => "hour", "period_val" => 1));
|
|
|
|
|
$recurrence = null;
|
|
|
|
|
$recurrentce_exdates = array();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -102,20 +102,33 @@ function wdcal_getEditPage_str(&$localization, $baseurl, $uid, $calendar_id, $ur
|
|
|
|
|
$out .= "<form method='POST' action='$postto'>
|
|
|
|
|
<input type='hidden' name='form_security_token' value='" . get_form_security_token('caledit') . "'>\n";
|
|
|
|
|
|
|
|
|
|
$out .= "<h2>" .t("Event data") . "</h2>";
|
|
|
|
|
$out .= "<h2>" . t("Event data") . "</h2>";
|
|
|
|
|
|
|
|
|
|
$out .= "<label for='calendar'>" . t("Calendar") . ":</label><select name='calendar' size='1'>";
|
|
|
|
|
$found = false;
|
|
|
|
|
$cal_col = "aaaaaa";
|
|
|
|
|
foreach ($calendars as $cal) {
|
|
|
|
|
$prop = $cal->getProperties(array("id", DAV_DISPLAYNAME));
|
|
|
|
|
$prop = $cal->getProperties(array("id", DAV_DISPLAYNAME, DAV_CALENDARCOLOR));
|
|
|
|
|
$out .= "<option value='" . $prop["id"] . "' ";
|
|
|
|
|
if ($prop["id"] == $calendar_id) $out .= "selected";
|
|
|
|
|
if ($prop["id"] == $calendar_id) {
|
|
|
|
|
$out .= "selected";
|
|
|
|
|
$cal_col = $prop[DAV_CALENDARCOLOR];
|
|
|
|
|
$found = true;
|
|
|
|
|
} elseif (!$found) $cal_col = $prop[DAV_CALENDARCOLOR];
|
|
|
|
|
$out .= ">" . escape_tags($prop[DAV_DISPLAYNAME]) . "</option>\n";
|
|
|
|
|
}
|
|
|
|
|
$out .= "</select><br>\n";
|
|
|
|
|
|
|
|
|
|
$out .= "</select>";
|
|
|
|
|
$out .= " <label class='plain'><input type='checkbox' name='color_override' id='color_override' ";
|
|
|
|
|
if (!is_null($event["Color"])) $out .= "checked";
|
|
|
|
|
$out .= "> " . t("Special color") . ":</label>";
|
|
|
|
|
$out .= "<span id='cal_color_holder' ";
|
|
|
|
|
if (is_null($event["Color"])) $out .= "style='display: none;'";
|
|
|
|
|
$out .= "><input name='color' id='cal_color' value='" . (is_null($event["Color"]) ? "#" . $cal_col : escape_tags($event["Color"])) . "'></span>";
|
|
|
|
|
$out .= "<br>\n";
|
|
|
|
|
|
|
|
|
|
$out .= "<label class='block' for='cal_summary'>" . t("Subject") . ":</label>
|
|
|
|
|
<input name='color' id='cal_color' value='" . (strlen($event["Color"]) != 7 ? "#5858ff" : escape_tags($event["Color"])) . "'>
|
|
|
|
|
<input name='summary' id='cal_summary' value='" . escape_tags($event["Summary"]) . "'><br>\n";
|
|
|
|
|
<input name='summary' id='cal_summary' value=\"" . escape_tags($event["Summary"]) . "\"><br>\n";
|
|
|
|
|
$out .= "<label class='block' for='cal_allday'>Is All-Day event:</label><input type='checkbox' name='allday' id='cal_allday' " . ($event["IsAllDayEvent"] ? "checked" : "") . "><br>\n";
|
|
|
|
|
|
|
|
|
|
$out .= "<label class='block' for='cal_startdate'>" . t("Starts") . ":</label>";
|
|
|
|
@ -128,20 +141,28 @@ function wdcal_getEditPage_str(&$localization, $baseurl, $uid, $calendar_id, $ur
|
|
|
|
|
$out .= "<input name='end_time' value='" . date("H:i", $event["EndTime"]) . "' id='cal_end_time'>";
|
|
|
|
|
$out .= "<br>\n";
|
|
|
|
|
|
|
|
|
|
$out .= "<label class='block' for='cal_location'>" . t("Location") . ":</label><input name='location' id='cal_location' value='" . escape_tags($event["Location"]) . "'><br>\n";
|
|
|
|
|
$out .= "<label class='block' for='cal_location'>" . t("Location") . ":</label><input name='location' id='cal_location' value=\"" . escape_tags($event["Location"]) . "\"><br>\n";
|
|
|
|
|
|
|
|
|
|
$out .= "<label class='block' for='event-desc-textarea'>" . t("Description") . ":</label> <textarea id='event-desc-textarea' name='wdcal_desc' style='vertical-align: top; width: 400px; height: 100px;'>" . escape_tags($event["Description"]) . "</textarea>";
|
|
|
|
|
$out .= "<br style='clear: both;'>";
|
|
|
|
|
|
|
|
|
|
$out .= "<h2>" .t("Recurrence") . "</h2>";
|
|
|
|
|
$out .= "<h2>" . t("Recurrence") . "</h2>";
|
|
|
|
|
|
|
|
|
|
$out .= "<label class='block' for='rec_frequency'>" . t("Frequency") . ":</label> <select id='rec_frequency' name='rec_frequency' size='1'>";
|
|
|
|
|
$out .= "<option value=''>" . t("None") . "</option>\n";
|
|
|
|
|
$out .= "<option value='daily' "; if ($recurrence && $recurrence->frequency == "daily") $out .= "selected"; $out .= ">" . t("Daily") . "</option>\n";
|
|
|
|
|
$out .= "<option value='weekly' "; if ($recurrence && $recurrence->frequency == "weekly") $out .= "selected"; $out .= ">" . t("Weekly") . "</option>\n";
|
|
|
|
|
$out .= "<option value='monthly' "; if ($recurrence && $recurrence->frequency == "monthly") $out .= "selected"; $out .= ">" . t("Monthly") . "</option>\n";
|
|
|
|
|
$out .= "<option value='yearly' "; if ($recurrence && $recurrence->frequency == "yearly") $out .= "selected"; $out .= ">" . t("Yearly") . "</option>\n";
|
|
|
|
|
$out .="</select><br>\n";
|
|
|
|
|
$out .= "<option value='daily' ";
|
|
|
|
|
if ($recurrence && $recurrence->frequency == "daily") $out .= "selected";
|
|
|
|
|
$out .= ">" . t("Daily") . "</option>\n";
|
|
|
|
|
$out .= "<option value='weekly' ";
|
|
|
|
|
if ($recurrence && $recurrence->frequency == "weekly") $out .= "selected";
|
|
|
|
|
$out .= ">" . t("Weekly") . "</option>\n";
|
|
|
|
|
$out .= "<option value='monthly' ";
|
|
|
|
|
if ($recurrence && $recurrence->frequency == "monthly") $out .= "selected";
|
|
|
|
|
$out .= ">" . t("Monthly") . "</option>\n";
|
|
|
|
|
$out .= "<option value='yearly' ";
|
|
|
|
|
if ($recurrence && $recurrence->frequency == "yearly") $out .= "selected";
|
|
|
|
|
$out .= ">" . t("Yearly") . "</option>\n";
|
|
|
|
|
$out .= "</select><br>\n";
|
|
|
|
|
$out .= "<div id='rec_details'>";
|
|
|
|
|
|
|
|
|
|
$select = "<select id='rec_interval' name='rec_interval' size='1'>";
|
|
|
|
@ -151,7 +172,7 @@ function wdcal_getEditPage_str(&$localization, $baseurl, $uid, $calendar_id, $ur
|
|
|
|
|
$select .= ">$i</option>\n";
|
|
|
|
|
}
|
|
|
|
|
$select .= "</select>";
|
|
|
|
|
$time = "<span class='rec_daily'>" . t("days") . "</span>";
|
|
|
|
|
$time = "<span class='rec_daily'>" . t("days") . "</span>";
|
|
|
|
|
$time .= "<span class='rec_weekly'>" . t("weeks") . "</span>";
|
|
|
|
|
$time .= "<span class='rec_monthly'>" . t("months") . "</span>";
|
|
|
|
|
$time .= "<span class='rec_yearly'>" . t("years") . "</span>";
|
|
|
|
@ -166,16 +187,32 @@ function wdcal_getEditPage_str(&$localization, $baseurl, $uid, $calendar_id, $ur
|
|
|
|
|
$byday = array("MO", "TU", "WE", "TH", "FR", "SA", "SU");
|
|
|
|
|
}
|
|
|
|
|
if ($localization->getFirstDayOfWeek() == 0) {
|
|
|
|
|
$out .= "<label class='plain'><input class='rec_daily_byday' type='checkbox' name='rec_daily_byday[]' value='SU' "; if (in_array("SU", $byday)) $out .= "checked"; $out .= ">" . t("Sunday") . "</label> ";
|
|
|
|
|
$out .= "<label class='plain'><input class='rec_daily_byday' type='checkbox' name='rec_daily_byday[]' value='SU' ";
|
|
|
|
|
if (in_array("SU", $byday)) $out .= "checked";
|
|
|
|
|
$out .= ">" . t("Sunday") . "</label> ";
|
|
|
|
|
}
|
|
|
|
|
$out .= "<label class='plain'><input class='rec_daily_byday' type='checkbox' name='rec_daily_byday[]' value='MO' "; if (in_array("MO", $byday)) $out .= "checked"; $out .= ">" . t("Monday") . "</label> ";
|
|
|
|
|
$out .= "<label class='plain'><input class='rec_daily_byday' type='checkbox' name='rec_daily_byday[]' value='TU' "; if (in_array("TU", $byday)) $out .= "checked"; $out .= ">" . t("Tuesday") . "</label> ";
|
|
|
|
|
$out .= "<label class='plain'><input class='rec_daily_byday' type='checkbox' name='rec_daily_byday[]' value='WE' "; if (in_array("WE", $byday)) $out .= "checked"; $out .= ">" . t("Wednesday") . "</label> ";
|
|
|
|
|
$out .= "<label class='plain'><input class='rec_daily_byday' type='checkbox' name='rec_daily_byday[]' value='TH' "; if (in_array("TH", $byday)) $out .= "checked"; $out .= ">" . t("Thursday") . "</label> ";
|
|
|
|
|
$out .= "<label class='plain'><input class='rec_daily_byday' type='checkbox' name='rec_daily_byday[]' value='FR' "; if (in_array("FR", $byday)) $out .= "checked"; $out .= ">" . t("Friday") . "</label> ";
|
|
|
|
|
$out .= "<label class='plain'><input class='rec_daily_byday' type='checkbox' name='rec_daily_byday[]' value='SA' "; if (in_array("SA", $byday)) $out .= "checked"; $out .= ">" . t("Saturday") . "</label> ";
|
|
|
|
|
$out .= "<label class='plain'><input class='rec_daily_byday' type='checkbox' name='rec_daily_byday[]' value='MO' ";
|
|
|
|
|
if (in_array("MO", $byday)) $out .= "checked";
|
|
|
|
|
$out .= ">" . t("Monday") . "</label> ";
|
|
|
|
|
$out .= "<label class='plain'><input class='rec_daily_byday' type='checkbox' name='rec_daily_byday[]' value='TU' ";
|
|
|
|
|
if (in_array("TU", $byday)) $out .= "checked";
|
|
|
|
|
$out .= ">" . t("Tuesday") . "</label> ";
|
|
|
|
|
$out .= "<label class='plain'><input class='rec_daily_byday' type='checkbox' name='rec_daily_byday[]' value='WE' ";
|
|
|
|
|
if (in_array("WE", $byday)) $out .= "checked";
|
|
|
|
|
$out .= ">" . t("Wednesday") . "</label> ";
|
|
|
|
|
$out .= "<label class='plain'><input class='rec_daily_byday' type='checkbox' name='rec_daily_byday[]' value='TH' ";
|
|
|
|
|
if (in_array("TH", $byday)) $out .= "checked";
|
|
|
|
|
$out .= ">" . t("Thursday") . "</label> ";
|
|
|
|
|
$out .= "<label class='plain'><input class='rec_daily_byday' type='checkbox' name='rec_daily_byday[]' value='FR' ";
|
|
|
|
|
if (in_array("FR", $byday)) $out .= "checked";
|
|
|
|
|
$out .= ">" . t("Friday") . "</label> ";
|
|
|
|
|
$out .= "<label class='plain'><input class='rec_daily_byday' type='checkbox' name='rec_daily_byday[]' value='SA' ";
|
|
|
|
|
if (in_array("SA", $byday)) $out .= "checked";
|
|
|
|
|
$out .= ">" . t("Saturday") . "</label> ";
|
|
|
|
|
if ($localization->getFirstDayOfWeek() != 0) {
|
|
|
|
|
$out .= "<label class='plain'><input class='rec_daily_byday' type='checkbox' name='rec_daily_byday[]' value='SU' "; if (in_array("SU", $byday)) $out .= "checked"; $out .= ">" . t("Sunday") . "</label> ";
|
|
|
|
|
$out .= "<label class='plain'><input class='rec_daily_byday' type='checkbox' name='rec_daily_byday[]' value='SU' ";
|
|
|
|
|
if (in_array("SU", $byday)) $out .= "checked";
|
|
|
|
|
$out .= ">" . t("Sunday") . "</label> ";
|
|
|
|
|
}
|
|
|
|
|
$out .= "</div>";
|
|
|
|
|
|
|
|
|
@ -188,16 +225,32 @@ function wdcal_getEditPage_str(&$localization, $baseurl, $uid, $calendar_id, $ur
|
|
|
|
|
$byday = array("MO", "TU", "WE", "TH", "FR", "SA", "SU");
|
|
|
|
|
}
|
|
|
|
|
if ($localization->getFirstDayOfWeek() == 0) {
|
|
|
|
|
$out .= "<label class='plain'><input class='rec_weekly_byday' type='checkbox' name='rec_weekly_byday[]' value='SU' "; if (in_array("SU", $byday)) $out .= "checked"; $out .= ">" . t("Sunday") . "</label> ";
|
|
|
|
|
$out .= "<label class='plain'><input class='rec_weekly_byday' type='checkbox' name='rec_weekly_byday[]' value='SU' ";
|
|
|
|
|
if (in_array("SU", $byday)) $out .= "checked";
|
|
|
|
|
$out .= ">" . t("Sunday") . "</label> ";
|
|
|
|
|
}
|
|
|
|
|
$out .= "<label class='plain'><input class='rec_weekly_byday' type='checkbox' name='rec_weekly_byday[]' value='MO' "; if (in_array("MO", $byday)) $out .= "checked"; $out .= ">" . t("Monday") . "</label> ";
|
|
|
|
|
$out .= "<label class='plain'><input class='rec_weekly_byday' type='checkbox' name='rec_weekly_byday[]' value='TU' "; if (in_array("TU", $byday)) $out .= "checked"; $out .= ">" . t("Tuesday") . "</label> ";
|
|
|
|
|
$out .= "<label class='plain'><input class='rec_weekly_byday' type='checkbox' name='rec_weekly_byday[]' value='WE' "; if (in_array("WE", $byday)) $out .= "checked"; $out .= ">" . t("Wednesday") . "</label> ";
|
|
|
|
|
$out .= "<label class='plain'><input class='rec_weekly_byday' type='checkbox' name='rec_weekly_byday[]' value='TH' "; if (in_array("TH", $byday)) $out .= "checked"; $out .= ">" . t("Thursday") . "</label> ";
|
|
|
|
|
$out .= "<label class='plain'><input class='rec_weekly_byday' type='checkbox' name='rec_weekly_byday[]' value='FR' "; if (in_array("FR", $byday)) $out .= "checked"; $out .= ">" . t("Friday") . "</label> ";
|
|
|
|
|
$out .= "<label class='plain'><input class='rec_weekly_byday' type='checkbox' name='rec_weekly_byday[]' value='SA' "; if (in_array("SA", $byday)) $out .= "checked"; $out .= ">" . t("Saturday") . "</label> ";
|
|
|
|
|
$out .= "<label class='plain'><input class='rec_weekly_byday' type='checkbox' name='rec_weekly_byday[]' value='MO' ";
|
|
|
|
|
if (in_array("MO", $byday)) $out .= "checked";
|
|
|
|
|
$out .= ">" . t("Monday") . "</label> ";
|
|
|
|
|
$out .= "<label class='plain'><input class='rec_weekly_byday' type='checkbox' name='rec_weekly_byday[]' value='TU' ";
|
|
|
|
|
if (in_array("TU", $byday)) $out .= "checked";
|
|
|
|
|
$out .= ">" . t("Tuesday") . "</label> ";
|
|
|
|
|
$out .= "<label class='plain'><input class='rec_weekly_byday' type='checkbox' name='rec_weekly_byday[]' value='WE' ";
|
|
|
|
|
if (in_array("WE", $byday)) $out .= "checked";
|
|
|
|
|
$out .= ">" . t("Wednesday") . "</label> ";
|
|
|
|
|
$out .= "<label class='plain'><input class='rec_weekly_byday' type='checkbox' name='rec_weekly_byday[]' value='TH' ";
|
|
|
|
|
if (in_array("TH", $byday)) $out .= "checked";
|
|
|
|
|
$out .= ">" . t("Thursday") . "</label> ";
|
|
|
|
|
$out .= "<label class='plain'><input class='rec_weekly_byday' type='checkbox' name='rec_weekly_byday[]' value='FR' ";
|
|
|
|
|
if (in_array("FR", $byday)) $out .= "checked";
|
|
|
|
|
$out .= ">" . t("Friday") . "</label> ";
|
|
|
|
|
$out .= "<label class='plain'><input class='rec_weekly_byday' type='checkbox' name='rec_weekly_byday[]' value='SA' ";
|
|
|
|
|
if (in_array("SA", $byday)) $out .= "checked";
|
|
|
|
|
$out .= ">" . t("Saturday") . "</label> ";
|
|
|
|
|
if ($localization->getFirstDayOfWeek() != 0) {
|
|
|
|
|
$out .= "<label class='plain'><input class='rec_weekly_byday' type='checkbox' name='rec_weekly_byday[]' value='SU' "; if (in_array("SU", $byday)) $out .= "checked"; $out .= ">" . t("Sunday") . "</label> ";
|
|
|
|
|
$out .= "<label class='plain'><input class='rec_weekly_byday' type='checkbox' name='rec_weekly_byday[]' value='SU' ";
|
|
|
|
|
if (in_array("SU", $byday)) $out .= "checked";
|
|
|
|
|
$out .= ">" . t("Sunday") . "</label> ";
|
|
|
|
|
}
|
|
|
|
|
$out .= "<br>";
|
|
|
|
|
|
|
|
|
@ -207,8 +260,12 @@ function wdcal_getEditPage_str(&$localization, $baseurl, $uid, $calendar_id, $ur
|
|
|
|
|
if ($localization->getFirstDayOfWeek() == 0) $wkst = "SU";
|
|
|
|
|
else $wkst = "MO";
|
|
|
|
|
}
|
|
|
|
|
$out .= "<label class='plain'><input type='radio' name='rec_weekly_wkst' value='SU' "; if ($wkst == "SU") $out .= "checked"; $out .= ">" . t("Sunday") . "</label> ";
|
|
|
|
|
$out .= "<label class='plain'><input type='radio' name='rec_weekly_wkst' value='MO' "; if ($wkst == "MO") $out .= "checked"; $out .= ">" . t("Monday") . "</label><br>\n";
|
|
|
|
|
$out .= "<label class='plain'><input type='radio' name='rec_weekly_wkst' value='SU' ";
|
|
|
|
|
if ($wkst == "SU") $out .= "checked";
|
|
|
|
|
$out .= ">" . t("Sunday") . "</label> ";
|
|
|
|
|
$out .= "<label class='plain'><input type='radio' name='rec_weekly_wkst' value='MO' ";
|
|
|
|
|
if ($wkst == "MO") $out .= "checked";
|
|
|
|
|
$out .= ">" . t("Monday") . "</label><br>\n";
|
|
|
|
|
|
|
|
|
|
$out .= "</div>";
|
|
|
|
|
|
|
|
|
@ -216,10 +273,18 @@ function wdcal_getEditPage_str(&$localization, $baseurl, $uid, $calendar_id, $ur
|
|
|
|
|
$out .= "<div class='rec_monthly'>";
|
|
|
|
|
$out .= "<label class='block' name='rec_monthly_day'>" . t("Day of month") . ":</label>";
|
|
|
|
|
$out .= "<select id='rec_monthly_day' name='rec_monthly_day' size='1'>";
|
|
|
|
|
$out .= "<option value='bymonthday' "; if ($monthly_rule == "bymonthday") $out .= "selected"; $out .= ">" . t("#num#th of each month") . "</option>\n";
|
|
|
|
|
$out .= "<option value='bymonthday_neg' "; if ($monthly_rule == "bymonthday_neg") $out .= "selected"; $out .= ">" . t("#num#th-last of each month") . "</option>\n";
|
|
|
|
|
$out .= "<option value='byday' "; if ($monthly_rule == "byday") $out .= "selected"; $out .= ">" . t("#num#th #wkday# of each month") . "</option>\n";
|
|
|
|
|
$out .= "<option value='byday_neg' "; if ($monthly_rule == "byday_neg") $out .= "selected"; $out .= ">" . t("#num#th-last #wkday# of each month") . "</option>\n";
|
|
|
|
|
$out .= "<option value='bymonthday' ";
|
|
|
|
|
if ($monthly_rule == "bymonthday") $out .= "selected";
|
|
|
|
|
$out .= ">" . t("#num#th of each month") . "</option>\n";
|
|
|
|
|
$out .= "<option value='bymonthday_neg' ";
|
|
|
|
|
if ($monthly_rule == "bymonthday_neg") $out .= "selected";
|
|
|
|
|
$out .= ">" . t("#num#th-last of each month") . "</option>\n";
|
|
|
|
|
$out .= "<option value='byday' ";
|
|
|
|
|
if ($monthly_rule == "byday") $out .= "selected";
|
|
|
|
|
$out .= ">" . t("#num#th #wkday# of each month") . "</option>\n";
|
|
|
|
|
$out .= "<option value='byday_neg' ";
|
|
|
|
|
if ($monthly_rule == "byday_neg") $out .= "selected";
|
|
|
|
|
$out .= ">" . t("#num#th-last #wkday# of each month") . "</option>\n";
|
|
|
|
|
$out .= "</select>";
|
|
|
|
|
$out .= "</div>\n";
|
|
|
|
|
|
|
|
|
@ -228,10 +293,18 @@ function wdcal_getEditPage_str(&$localization, $baseurl, $uid, $calendar_id, $ur
|
|
|
|
|
$out .= "<label class='block' name='rec_yearly_day'>" . t("Month") . ":</label> <span class='rec_month_name'>#month#</span><br>\n";
|
|
|
|
|
$out .= "<label class='block' name='rec_yearly_day'>" . t("Day of month") . ":</label>";
|
|
|
|
|
$out .= "<select id='rec_yearly_day' name='rec_yearly_day' size='1'>";
|
|
|
|
|
$out .= "<option value='bymonthday' "; if ($monthly_rule == "bymonthday") $out .= "selected"; $out .= ">" . t("#num#th of each month") . "</option>\n";
|
|
|
|
|
$out .= "<option value='bymonthday_neg' "; if ($monthly_rule == "bymonthday_neg") $out .= "selected"; $out .= ">" . t("#num#th-last of each month") . "</option>\n";
|
|
|
|
|
$out .= "<option value='byday' "; if ($monthly_rule == "byday") $out .= "selected"; $out .= ">" . t("#num#th #wkday# of each month") . "</option>\n";
|
|
|
|
|
$out .= "<option value='byday_neg' "; if ($monthly_rule == "byday_neg") $out .= "selected"; $out .= ">" . t("#num#th-last #wkday# of each month") . "</option>\n";
|
|
|
|
|
$out .= "<option value='bymonthday' ";
|
|
|
|
|
if ($monthly_rule == "bymonthday") $out .= "selected";
|
|
|
|
|
$out .= ">" . t("#num#th of each month") . "</option>\n";
|
|
|
|
|
$out .= "<option value='bymonthday_neg' ";
|
|
|
|
|
if ($monthly_rule == "bymonthday_neg") $out .= "selected";
|
|
|
|
|
$out .= ">" . t("#num#th-last of each month") . "</option>\n";
|
|
|
|
|
$out .= "<option value='byday' ";
|
|
|
|
|
if ($monthly_rule == "byday") $out .= "selected";
|
|
|
|
|
$out .= ">" . t("#num#th #wkday# of each month") . "</option>\n";
|
|
|
|
|
$out .= "<option value='byday_neg' ";
|
|
|
|
|
if ($monthly_rule == "byday_neg") $out .= "selected";
|
|
|
|
|
$out .= ">" . t("#num#th-last #wkday# of each month") . "</option>\n";
|
|
|
|
|
$out .= "</select>";
|
|
|
|
|
$out .= "</div>\n";
|
|
|
|
|
|
|
|
|
@ -241,28 +314,34 @@ function wdcal_getEditPage_str(&$localization, $baseurl, $uid, $calendar_id, $ur
|
|
|
|
|
$count = $recurrence->count;
|
|
|
|
|
if (is_a($until, "DateTime")) {
|
|
|
|
|
/** @var DateTime $until */
|
|
|
|
|
$rule_type = "date";
|
|
|
|
|
$rule_until_date = $until->getTimestamp();
|
|
|
|
|
$rule_type = "date";
|
|
|
|
|
$rule_until_date = $until->getTimestamp();
|
|
|
|
|
$rule_until_count = 1;
|
|
|
|
|
} elseif ($count > 0) {
|
|
|
|
|
$rule_type = "count";
|
|
|
|
|
$rule_until_date = time();
|
|
|
|
|
$rule_type = "count";
|
|
|
|
|
$rule_until_date = time();
|
|
|
|
|
$rule_until_count = $count;
|
|
|
|
|
} else {
|
|
|
|
|
$rule_type = "infinite";
|
|
|
|
|
$rule_until_date = time();
|
|
|
|
|
$rule_type = "infinite";
|
|
|
|
|
$rule_until_date = time();
|
|
|
|
|
$rule_until_count = 1;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$rule_type = "infinite";
|
|
|
|
|
$rule_until_date = time();
|
|
|
|
|
$rule_type = "infinite";
|
|
|
|
|
$rule_until_date = time();
|
|
|
|
|
$rule_until_count = 1;
|
|
|
|
|
}
|
|
|
|
|
$out .= "<label class='block' for='rec_until_type'>" . t("Repeat until") . ":</label> ";
|
|
|
|
|
$out .= "<select name='rec_until_type' id='rec_until_type' size='1'>";
|
|
|
|
|
$out .= "<option value='infinite' "; if ($rule_type == "infinite") $out .= "selected"; $out .= ">" . t("Infinite") . "</option>\n";
|
|
|
|
|
$out .= "<option value='date' "; if ($rule_type == "date") $out .= "selected"; $out .= ">" . t("Until the following date") . ":</option>\n";
|
|
|
|
|
$out .= "<option value='count' "; if ($rule_type == "count") $out .= "selected"; $out .= ">" . t("Number of times") . ":</option>\n";
|
|
|
|
|
$out .= "<option value='infinite' ";
|
|
|
|
|
if ($rule_type == "infinite") $out .= "selected";
|
|
|
|
|
$out .= ">" . t("Infinite") . "</option>\n";
|
|
|
|
|
$out .= "<option value='date' ";
|
|
|
|
|
if ($rule_type == "date") $out .= "selected";
|
|
|
|
|
$out .= ">" . t("Until the following date") . ":</option>\n";
|
|
|
|
|
$out .= "<option value='count' ";
|
|
|
|
|
if ($rule_type == "count") $out .= "selected";
|
|
|
|
|
$out .= ">" . t("Number of times") . ":</option>\n";
|
|
|
|
|
$out .= "</select>";
|
|
|
|
|
|
|
|
|
|
$out .= "<input name='rec_until_date' value='" . $localization->dateformat_datepicker_php($rule_until_date) . "' id='rec_until_date'>";
|
|
|
|
@ -288,7 +367,7 @@ function wdcal_getEditPage_str(&$localization, $baseurl, $uid, $calendar_id, $ur
|
|
|
|
|
|
|
|
|
|
$out .= "</div><br>";
|
|
|
|
|
|
|
|
|
|
$out .= "<h2>" .t("Notification") . "</h2>";
|
|
|
|
|
$out .= "<h2>" . t("Notification") . "</h2>";
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
$out .= '<input type="checkbox" name="notification" id="notification" ';
|
|
|
|
@ -324,15 +403,16 @@ function wdcal_getEditPage_str(&$localization, $baseurl, $uid, $calendar_id, $ur
|
|
|
|
|
* @param Sabre_VObject_Component_VEvent $component
|
|
|
|
|
* @param wdcal_local $localization
|
|
|
|
|
*/
|
|
|
|
|
function wdcal_set_component_date(&$component, &$localization) {
|
|
|
|
|
function wdcal_set_component_date(&$component, &$localization)
|
|
|
|
|
{
|
|
|
|
|
if (isset($_REQUEST["allday"])) {
|
|
|
|
|
$ts_start = $localization->date_local2timestamp($_REQUEST["start_date"] . " 00:00");
|
|
|
|
|
$ts_end = $localization->date_local2timestamp($_REQUEST["end_date"] . " 00:00");
|
|
|
|
|
$type = Sabre_VObject_Property_DateTime::DATE;
|
|
|
|
|
$ts_end = $localization->date_local2timestamp($_REQUEST["end_date"] . " 00:00");
|
|
|
|
|
$type = Sabre_VObject_Property_DateTime::DATE;
|
|
|
|
|
} else {
|
|
|
|
|
$ts_start = $localization->date_local2timestamp($_REQUEST["start_date"] . " " . $_REQUEST["start_time"]);
|
|
|
|
|
$ts_end = $localization->date_local2timestamp($_REQUEST["end_date"] . " " . $_REQUEST["end_time"]);
|
|
|
|
|
$type = Sabre_VObject_Property_DateTime::LOCALTZ;
|
|
|
|
|
$ts_end = $localization->date_local2timestamp($_REQUEST["end_date"] . " " . $_REQUEST["end_time"]);
|
|
|
|
|
$type = Sabre_VObject_Property_DateTime::LOCALTZ;
|
|
|
|
|
}
|
|
|
|
|
$datetime_start = new Sabre_VObject_Property_DateTime("DTSTART");
|
|
|
|
|
$datetime_start->setDateTime(new DateTime(date("Y-m-d H:i:s", $ts_start)), $type);
|
|
|
|
@ -345,11 +425,12 @@ function wdcal_set_component_date(&$component, &$localization) {
|
|
|
|
|
$component->add($datetime_end);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param Sabre_VObject_Component_VEvent $component
|
|
|
|
|
* @param wdcal_local $localization
|
|
|
|
|
*/
|
|
|
|
|
function wdcal_set_component_recurrence(&$component, &$localization) {
|
|
|
|
|
/**
|
|
|
|
|
* @param Sabre_VObject_Component_VEvent $component
|
|
|
|
|
* @param wdcal_local $localization
|
|
|
|
|
*/
|
|
|
|
|
function wdcal_set_component_recurrence(&$component, &$localization)
|
|
|
|
|
{
|
|
|
|
|
$component->__unset("RRULE");
|
|
|
|
|
$component->__unset("EXRULE");
|
|
|
|
|
$component->__unset("EXDATE");
|
|
|
|
@ -358,8 +439,8 @@ function wdcal_set_component_recurrence(&$component, &$localization) {
|
|
|
|
|
$part_until = "";
|
|
|
|
|
switch ($_REQUEST["rec_until_type"]) {
|
|
|
|
|
case "date":
|
|
|
|
|
$date = $localization->date_local2timestamp($_REQUEST["rec_until_date"]);
|
|
|
|
|
$part_until = ";UNTIL=" . date("Ymd", $date);
|
|
|
|
|
$date = $localization->date_local2timestamp($_REQUEST["rec_until_date"]);
|
|
|
|
|
$part_until = ";UNTIL=" . date("Ymd", $date);
|
|
|
|
|
$datetime_until = new Sabre_VObject_Property_DateTime("UNTIL");
|
|
|
|
|
$datetime_until->setDateTime(new DateTime(date("Y-m-d H:i:s", $date)), Sabre_VObject_Property_DateTime::DATE);
|
|
|
|
|
break;
|
|
|
|
@ -402,7 +483,7 @@ function wdcal_set_component_recurrence(&$component, &$localization) {
|
|
|
|
|
|
|
|
|
|
if (isset($_REQUEST["rec_exceptions"])) {
|
|
|
|
|
$arr = array();
|
|
|
|
|
foreach ($_REQUEST["rec_exceptions"] as $except) {
|
|
|
|
|
foreach ($_REQUEST["rec_exceptions"] as $except) {
|
|
|
|
|
$arr[] = new DateTime(date("Y-m-d H:i:s", $except));
|
|
|
|
|
}
|
|
|
|
|
/** @var Sabre_VObject_Property_MultiDateTime $prop */
|
|
|
|
@ -417,7 +498,6 @@ function wdcal_set_component_recurrence(&$component, &$localization) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param string $uri
|
|
|
|
|
* @param string $recurr_uri
|
|
|
|
@ -428,25 +508,25 @@ function wdcal_set_component_recurrence(&$component, &$localization) {
|
|
|
|
|
*/
|
|
|
|
|
function wdcal_postEditPage($uri, $recurr_uri = "", $uid = 0, $timezone = "", $goaway_url = "")
|
|
|
|
|
{
|
|
|
|
|
$uid = IntVal($uid);
|
|
|
|
|
$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"];
|
|
|
|
|
$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);
|
|
|
|
|
$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();
|
|
|
|
|
$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");
|
|
|
|
|
$obj_uri = $component->__get("UID");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
wdcal_set_component_date($component, $localization);
|
|
|
|
@ -455,11 +535,13 @@ function wdcal_postEditPage($uri, $recurr_uri = "", $uid = 0, $timezone = "", $g
|
|
|
|
|
$component->__unset("LOCATION");
|
|
|
|
|
$component->__unset("SUMMARY");
|
|
|
|
|
$component->__unset("DESCRIPTION");
|
|
|
|
|
$component->__unset("X-ANIMEXXCOLOR");
|
|
|
|
|
$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")));
|
|
|
|
|
$component->add("X-ANIMEXX-COLOR", $_REQUEST["color"]);
|
|
|
|
|
if (isset($_REQUEST["color_override"])) {
|
|
|
|
|
$component->add("X-ANIMEXX-COLOR", $_REQUEST["color"]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$data = $vObject->serialize();
|
|
|
|
|
|
|
|
|
@ -476,30 +558,31 @@ function wdcal_postEditPage($uri, $recurr_uri = "", $uid = 0, $timezone = "", $g
|
|
|
|
|
/**
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
|
|
|
|
function wdcal_getEditPage_exception_selector() {
|
|
|
|
|
function wdcal_getEditPage_exception_selector()
|
|
|
|
|
{
|
|
|
|
|
header("Content-type: application/json");
|
|
|
|
|
|
|
|
|
|
$a = get_app();
|
|
|
|
|
$localization = wdcal_local::getInstanceByUser($a->user["uid"]);
|
|
|
|
|
|
|
|
|
|
$vObject = wdcal_create_empty_vevent();
|
|
|
|
|
$vObject = dav_create_empty_vevent();
|
|
|
|
|
|
|
|
|
|
foreach($vObject->getComponents() as $component) {
|
|
|
|
|
if ($component->name!=='VTIMEZONE') break;
|
|
|
|
|
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);
|
|
|
|
|
$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 = "<ul>";
|
|
|
|
|
|
|
|
|
|
$i = 0;
|
|
|
|
|
while($it->valid() && $last_start < $max_ts && $i++ < 1000) {
|
|
|
|
|
while ($it->valid() && $last_start < $max_ts && $i++ < 1000) {
|
|
|
|
|
$last_start = $it->getDtStart()->getTimestamp();
|
|
|
|
|
$o .= "<li><a href='#' class='exception_selector_link' data-timestamp='$last_start'>" . $localization->date_timestamp2localDate($last_start) . "</a></li>\n";
|
|
|
|
|
$it->next();
|
|
|
|
|