Adding and removing calendars

This commit is contained in:
Tobias Hößl 2012-07-12 19:22:11 +00:00
parent 64fa5eb924
commit a79a85edbb
9 changed files with 353 additions and 141 deletions

View file

@ -4,6 +4,8 @@
define("DAV_ACL_READ", "{DAV:}read");
define("DAV_ACL_WRITE", "{DAV:}write");
define("DAV_DISPLAYNAME", "{DAV:}displayname");
define("DAV_CALENDARCOLOR", "{http://apple.com/ns/ical/}calendar-color");
class vcard_source_data_email

View file

@ -20,6 +20,13 @@ abstract class Sabre_CalDAV_Backend_Common extends Sabre_CalDAV_Backend_Abstract
*/
abstract public function getNamespace();
/**
* @static
* @abstract
* @return string
*/
abstract public static function getBackendTypeName();
/**
* @param int $calendarId

View file

@ -30,6 +30,13 @@ class Sabre_CalDAV_Backend_Private extends Sabre_CalDAV_Backend_Common
return CALDAV_NAMESPACE_PRIVATE;
}
/**
* @static
* @return string
*/
public static function getBackendTypeName() {
return t("Private Events");
}
/**
* @obsolete

View file

@ -61,6 +61,10 @@ function wdcal_edit_init(dateFormat, base_path) {
"use strict";
$("#cal_color").colorPicker();
$("#color_override").on("click", function() {
if ($("#color_override").prop("checked")) $("#cal_color_holder").show();
else $("#cal_color_holder").hide();
});
$("#cal_start_time").timePicker({ step: 15 }).on("change", wdcal_edit_checktime_startChanged);
$("#cal_end_time").timePicker().on("change", wdcal_edit_checktime_endChanged);
@ -191,3 +195,20 @@ function wdcal_edit_init(dateFormat, base_path) {
});
});
}
function wdcal_edit_calendars_start(dateFormat, base_path) {
"use strict";
$(".cal_color").colorPicker();
$(".delete_cal").click(function(ev) {
if (!confirm("Do you really want to delete this calendar? All events will be moved to another private calendar.")) ev.preventDefault();
});
$(".calendar_add_caller").click(function(ev) {
$(".cal_add_row").show();
$(this).parents("div").hide();
ev.preventDefault();
});
}

View file

@ -1861,15 +1861,19 @@
$("#bbit-cal-start").val(start.getTime());
$("#bbit-cal-end").val(end.getTime());
var addurl = option.baseurl + "new/?start=" + Math.floor($("#bbit-cal-start").val() / 1000) + "&end=" + Math.floor($("#bbit-cal-end").val() / 1000) + "&isallday=" + (isallday ? "1" : "0");
var addurl = option.baseurl + "new/?start=" + Math.floor($("#bbit-cal-start").val() / 1000) + "&end=" + Math.floor($("#bbit-cal-end").val() / 1000) +
"&isallday=" + (isallday ? "1" : "0") + "&title=";
buddle.find(".bbit-cal-editLink").attr("href", addurl);
buddle.css({ "visibility":"visible", left:off.left, top:off.top });
calwhat.blur().focus(); //add 2010-01-26 blur() fixed chrome
$(document).one("mousedown", function () {
$(document).on("mousedown", function () {
$("#bbit-cal-buddle").css("visibility", "hidden");
releasedragevent();
});
$(document).on("keyup", "#bbit-cal-what", function() {
buddle.find(".bbit-cal-editLink").attr("href", addurl + encodeURIComponent($("#bbit-cal-what").val()));
});
return false;
}

View file

@ -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 .= "&nbsp; &nbsp; <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> &nbsp; ";
$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> &nbsp; ";
}
$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> &nbsp; ";
$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> &nbsp; ";
$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> &nbsp; ";
$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> &nbsp; ";
$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> &nbsp; ";
$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> &nbsp; ";
$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> &nbsp; ";
$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> &nbsp; ";
$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> &nbsp; ";
$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> &nbsp; ";
$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> &nbsp; ";
$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> &nbsp; ";
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> &nbsp; ";
$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> &nbsp; ";
}
$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> &nbsp; ";
$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> &nbsp; ";
}
$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> &nbsp; ";
$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> &nbsp; ";
$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> &nbsp; ";
$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> &nbsp; ";
$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> &nbsp; ";
$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> &nbsp; ";
$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> &nbsp; ";
$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> &nbsp; ";
$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> &nbsp; ";
$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> &nbsp; ";
$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> &nbsp; ";
$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> &nbsp; ";
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> &nbsp; ";
$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> &nbsp; ";
}
$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> &nbsp; ";
$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> &nbsp; ";
$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();

View file

@ -28,6 +28,13 @@ class Sabre_CalDAV_Backend_Friendica extends Sabre_CalDAV_Backend_Virtual
return CALDAV_NAMESPACE_PRIVATE;
}
/**
* @static
* @return string
*/
public static function getBackendTypeName() {
return t("Friendicy-Native events");
}
/**
* @static

View file

@ -11,6 +11,12 @@ function wdcal_addRequiredHeaders()
$a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/dav/jqueryui/jquery-ui-1.8.21.custom.css' . '" media="all" />' . "\r\n";
$a->page['htmlhead'] .= '<script type="text/javascript" src="' . $a->get_baseurl() . '/addon/dav/jqueryui/jquery-ui-1.8.21.custom.min.js"></script>' . "\r\n";
$a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/dav/colorpicker/colorPicker.css' . '" media="all" />' . "\r\n";
$a->page['htmlhead'] .= '<script type="text/javascript" src="' . $a->get_baseurl() . '/addon/dav/colorpicker/jquery.colorPicker.min.js"></script>' . "\r\n";
$a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/dav/timepicker/timePicker.css' . '" media="all" />' . "\r\n";
$a->page['htmlhead'] .= '<script type="text/javascript" src="' . $a->get_baseurl() . '/addon/dav/timepicker/jquery.timePicker.min.js"></script>' . "\r\n";
$a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/dav/wdcal.css' . '" media="all" />' . "\r\n";
$a->page['htmlhead'] .= '<script type="text/javascript" src="' . $a->get_baseurl() . '/addon/dav/common/wdcal.js"></script>' . "\r\n";
@ -30,37 +36,7 @@ function wdcal_addRequiredHeaders()
$a->page['htmlhead'] .= '<script type="text/javascript" src="' . $a->get_baseurl() . '/addon/dav/common/wdcal/js/main.js"></script>' . "\r\n";
}
/**
*
*/
function wdcal_addRequiredHeadersEdit()
{
$a = get_app();
$localization = wdcal_local::getInstanceByUser($a->user["uid"]);
$a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/dav/jqueryui/jquery-ui-1.8.21.custom.css' . '" media="all" />' . "\r\n";
$a->page['htmlhead'] .= '<script type="text/javascript" src="' . $a->get_baseurl() . '/addon/dav/jqueryui/jquery-ui-1.8.21.custom.min.js"></script>' . "\r\n";
$a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/dav/colorpicker/colorPicker.css' . '" media="all" />' . "\r\n";
$a->page['htmlhead'] .= '<script type="text/javascript" src="' . $a->get_baseurl() . '/addon/dav/colorpicker/jquery.colorPicker.min.js"></script>' . "\r\n";
$a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/dav/timepicker/timePicker.css' . '" media="all" />' . "\r\n";
$a->page['htmlhead'] .= '<script type="text/javascript" src="' . $a->get_baseurl() . '/addon/dav/timepicker/jquery.timePicker.min.js"></script>' . "\r\n";
$a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/dav/wdcal.css' . '" media="all" />' . "\r\n";
$a->page['htmlhead'] .= '<script type="text/javascript" src="' . $a->get_baseurl() . '/addon/dav/common/wdcal.js"></script>' . "\r\n";
switch ($localization->getLanguageCode()) {
case "de":
$a->page['htmlhead'] .= '<script type="text/javascript" src="' . $a->get_baseurl() . '/addon/dav/common/wdcal/js/wdCalendar_lang_DE.js"></script>' . "\r\n";
$a->page['htmlhead'] .= '<script type="text/javascript" src="' . $a->get_baseurl() . '/addon/dav/jqueryui/jquery.ui.datepicker-de.js"></script>' . "\r\n";
break;
default:
$a->page['htmlhead'] .= '<script type="text/javascript" src="' . $a->get_baseurl() . '/addon/dav/common/wdcal/js/wdCalendar_lang_EN.js"></script>' . "\r\n";
}
}
/**
* @param array|int[] $calendars
@ -275,6 +251,9 @@ function wdcal_getEditPage($calendar_id, $uri, $recurr_uri = "")
return wdcal_getEditPage_str($localization, $a->get_baseurl(), $a->user["uid"], $calendar_id, $uri, $recurr_uri);
}
/**
* @return string
*/
function wdcal_getNewPage()
{
$a = get_app();
@ -302,6 +281,62 @@ function wdcal_getSettingsPage(&$a)
info(t('The new values have been saved.'));
}
if (isset($_REQUEST["save_cals"])) {
check_form_security_token_redirectOnErr($a->get_baseurl() . '/dav/settings/', 'calprop');
$r = q("SELECT * FROM %s%scalendars WHERE `namespace` = " . CALDAV_NAMESPACE_PRIVATE . " AND `namespace_id` = %d", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($a->user["uid"]));
foreach ($r as $cal) {
$backend = wdcal_calendar_factory($cal["namespace"], $cal["namespace_id"], $cal["uri"], $cal);
$change_sql = "";
$col = substr($_REQUEST["color"][$cal["id"]], 1);
if (strtolower($col) != strtolower($cal["calendarcolor"])) $change_sql .= ", `calendarcolor` = '" . dbesc($col) . "'";
if (!is_subclass_of($backend, "Sabre_CalDAV_Backend_Virtual")) {
if ($_REQUEST["uri"][$cal["id"]] != $cal["uri"]) $change_sql .= ", `uri` = '" . dbesc($_REQUEST["uri"][$cal["id"]]) . "'";
if ($_REQUEST["name"][$cal["id"]] != $cal["displayname"]) $change_sql .= ", `displayname` = '" . dbesc($_REQUEST["name"][$cal["id"]]) . "'";
}
if ($change_sql != "") {
q("UPDATE %s%scalendars SET `ctag` = `ctag` + 1 $change_sql WHERE `id` = %d AND `namespace_id` = %d AND `namespace_id` = %d",
CALDAV_SQL_DB, CALDAV_SQL_PREFIX, $cal["id"], CALDAV_NAMESPACE_PRIVATE, IntVal($a->user["uid"]));
info(t('The calendar has been updated.'));
}
}
if (isset($_REQUEST["uri"]["new"]) && $_REQUEST["uri"]["new"] != "" && $_REQUEST["name"]["new"] && $_REQUEST["name"]["new"] != "") {
$order = q("SELECT MAX(`calendarorder`) ord FROM %s%scalendars WHERE `namespace_id` = %d AND `namespace_id` = %d",
CALDAV_SQL_DB, CALDAV_SQL_PREFIX, CALDAV_NAMESPACE_PRIVATE, IntVal($a->user["uid"]));
$neworder = $order[0]["ord"] + 1;
q("INSERT INTO %s%scalendars (`namespace`, `namespace_id`, `calendarorder`, `calendarcolor`, `displayname`, `timezone`, `uri`, `has_vevent`, `ctag`)
VALUES (%d, %d, %d, '%s', '%s', '%s', '%s', 1, 1)",
CALDAV_SQL_DB, CALDAV_SQL_PREFIX, CALDAV_NAMESPACE_PRIVATE, IntVal($a->user["uid"]), $neworder, dbesc(strtolower(substr($_REQUEST["color"]["new"], 1))),
dbesc($_REQUEST["name"]["new"]), dbesc($a->timezone), dbesc($_REQUEST["uri"]["new"])
);
info(t('The new calendar has been created.'));
}
}
if (isset($_REQUEST["remove_cal"])) {
check_form_security_token_redirectOnErr($a->get_baseurl() . '/dav/settings/', 'del_cal', 't');
$c = q("SELECT * FROM %s%scalendars WHERE `id` = %d AND `namespace_id` = %d AND `namespace_id` = %d",
CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($_REQUEST["remove_cal"]), CALDAV_NAMESPACE_PRIVATE, IntVal($a->user["uid"]));
if (count($c) != 1) killme();
$calobjs = q("SELECT `id` FROM %s%scalendarobjects WHERE `calendar_id` = %d", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($_REQUEST["remove_cal"]));
$newcal = q("SELECT * FROM %s%scalendars WHERE `id` != %d AND `namespace_id` = %d AND `namespace_id` = %d ORDER BY `calendarcolor` LIMIT 0,1",
CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($_REQUEST["remove_cal"]), CALDAV_NAMESPACE_PRIVATE, IntVal($a->user["uid"]));
if (count($newcal) != 1) killme();
q("UPDATE %s%scalendarobjects SET `calendar_id` = %d WHERE `calendar_id` = %d", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($newcal[0]["id"]), IntVal($c[0]["id"]));
foreach ($calobjs as $calobj) renderCalDavEntry_calobj_id($calobj["id"]);
q("DELETE FROM %s%scalendars WHERE `id` = %s", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($_REQUEST["remove_cal"]));
q("UPDATE %s%scalendars SET `ctag` = `ctag` + 1 WHERE `id` = " . CALDAV_SQL_DB, CALDAV_SQL_PREFIX, $newcal[0]["id"]);
info(t('The calendar has been deleted.'));
}
$o = "";
$o .= "<a href='" . $a->get_baseurl() . "/dav/wdcal/'>" . t("Go back to the calendar") . "</a><br><br>";
@ -326,6 +361,54 @@ function wdcal_getSettingsPage(&$a)
$o .= '<input type="submit" name="save" value="' . t('Save') . '">';
$o .= '</form>';
$o .= '<br><br><h3>' . t('Calendars') . '</h3>';
$o .= '<form method="POST" action="' . $a->get_baseurl() . '/dav/settings/">';
$o .= "<input type='hidden' name='form_security_token' value='" . get_form_security_token('calprop') . "'>\n";
$o .= "<table><tr><th>Type</th><th>Color</th><th>Name</th><th>URI (for CalDAV)</th></tr>";
$r = q("SELECT * FROM %s%scalendars WHERE `namespace` = " . CALDAV_NAMESPACE_PRIVATE . " AND `namespace_id` = %d", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($a->user["uid"]));
$private_max = 0;
$num_non_virtual = 0;
foreach ($r as $x) {
$backend = wdcal_calendar_factory($x["namespace"], $x["namespace_id"], $x["uri"], $x);
if (!is_subclass_of($backend, "Sabre_CalDAV_Backend_Virtual")) $num_non_virtual++;
}
foreach ($r as $x) {
$p = explode("private-", $x["uri"]);
if (count($p) == 2 && $p[1] > $private_max) $private_max = $p[1];
$backend = wdcal_calendar_factory($x["namespace"], $x["namespace_id"], $x["uri"], $x);
$disabled = (is_subclass_of($backend, "Sabre_CalDAV_Backend_Virtual") ? "disabled" : "");
$o .= "<tr>";
$o .= "<td style='padding: 2px;'>" . escape_tags($backend->getBackendTypeName()) . "</td>";
$o .= "<td style='padding: 2px; text-align: center;'><input style='margin-left: 10px; width: 70px;' class='cal_color' name='color[" . $x["id"] . "]' id='cal_color_" . $x["id"] . "' value='#" . (strlen($x["calendarcolor"]) != 6 ? "5858ff" : escape_tags($x["calendarcolor"])) . "'></td>";
$o .= "<td style='padding: 2px;'><input style='margin-left: 10px;' name='name[" . $x["id"] . "]' value='" . escape_tags($x["displayname"]) . "' $disabled></td>";
$o .= "<td style='padding: 2px;'><input style='margin-left: 10px; width: 150px;' name='uri[" . $x["id"] . "]' value='" . escape_tags($x["uri"]) . "' $disabled></td>";
$o .= "<td style='padding: 2px;'>";
if (!is_subclass_of($backend, "Sabre_CalDAV_Backend_Virtual") && $num_non_virtual > 1) $o .= "<a href='" . $a->get_baseurl() . "/dav/settings/?remove_cal=" . $x["id"] . "&amp;t=" . get_form_security_token("del_cal") . "' class='delete_cal'>Delete</a>";
$o .= "</td>\n";
$o .= "</tr>\n";
}
$private_max++;
$o .= "<tr class='cal_add_row' style='display: none;'>";
$o .= "<td style='padding: 2px;'>" . escape_tags(Sabre_CalDAV_Backend_Private::getBackendTypeName()) . "</td>";
$o .= "<td style='padding: 2px; text-align: center;'><input style='margin-left: 10px; width: 70px;' class='cal_color' name='color[new]' id='cal_color_new' value='#5858ff'></td>";
$o .= "<td style='padding: 2px;'><input style='margin-left: 10px;' name='name[new]' value='Another calendar'></td>";
$o .= "<td style='padding: 2px;'><input style='margin-left: 10px; width: 150px;' name='uri[new]' value='private-${private_max}'></td>";
$o .= "</tr>\n";
$o .= "</table>";
$o .= "<div style='text-align: center;'>[<a href='#' class='calendar_add_caller'>" . t("Create a new calendar") . "</a>]</div>";
$o .= '<input type="submit" name="save_cals" value="' . t('Save') . '">';
$o .= '</form>';
$baseurl = $a->get_baseurl();
$o .= "<script>\$(function() {
wdcal_edit_calendars_start('" . $current_format->dateformat_datepicker_js() . "', '${baseurl}/dav/');
});</script>";
$o .= "<br><h3>" . t("Limitations") . "</h3>";
$o .= "- The native friendica events are embedded as read-only, half-transparent in the calendar.<br>";

View file

@ -78,17 +78,13 @@ function dav_init(&$a)
}
wdcal_create_std_calendars();
wdcal_addRequiredHeaders();
if ($a->argc >= 2 && $a->argv[1] == "wdcal") {
if ($a->argc >= 3 && $a->argv[2] == "feed") {
wdcal_print_feed($a->get_baseurl() . "/dav/wdcal/");
killme();
} elseif ($a->argc >= 3 && strlen($a->argv[2]) > 0) {
wdcal_addRequiredHeadersEdit();
} else {
wdcal_addRequiredHeaders();
}
return;
}
@ -140,6 +136,7 @@ function dav_content()
$ret = wdcal_postEditPage("new", "", $a->user["uid"], $a->timezone, $a->get_baseurl() . "/dav/wdcal/");
if ($ret["ok"]) notice($ret["msg"]);
else info($ret["msg"]);
goaway($a->get_baseurl() . "/dav/wdcal/");
}
$o .= wdcal_getNewPage();
return $o;
@ -154,6 +151,7 @@ function dav_content()
$ret = wdcal_postEditPage($a->argv[3], $recurr_uri, $a->user["uid"], $a->timezone, $a->get_baseurl() . "/dav/wdcal/");
if ($ret["ok"]) notice($ret["msg"]);
else info($ret["msg"]);
goaway($a->get_baseurl() . "/dav/wdcal/");
}
$o .= wdcal_getEditPage($calendar_id, $a->argv[3], $recurr_uri);
return $o;