Adding and removing calendars

pull/73/head
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_READ", "{DAV:}read");
define("DAV_ACL_WRITE", "{DAV:}write"); define("DAV_ACL_WRITE", "{DAV:}write");
define("DAV_DISPLAYNAME", "{DAV:}displayname"); define("DAV_DISPLAYNAME", "{DAV:}displayname");
define("DAV_CALENDARCOLOR", "{http://apple.com/ns/ical/}calendar-color");
class vcard_source_data_email 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(); abstract public function getNamespace();
/**
* @static
* @abstract
* @return string
*/
abstract public static function getBackendTypeName();
/** /**
* @param int $calendarId * @param int $calendarId

View File

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

View File

@ -61,6 +61,10 @@ function wdcal_edit_init(dateFormat, base_path) {
"use strict"; "use strict";
$("#cal_color").colorPicker(); $("#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_start_time").timePicker({ step: 15 }).on("change", wdcal_edit_checktime_startChanged);
$("#cal_end_time").timePicker().on("change", wdcal_edit_checktime_endChanged); $("#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-start").val(start.getTime());
$("#bbit-cal-end").val(end.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.find(".bbit-cal-editLink").attr("href", addurl);
buddle.css({ "visibility":"visible", left:off.left, top:off.top }); buddle.css({ "visibility":"visible", left:off.left, top:off.top });
calwhat.blur().focus(); //add 2010-01-26 blur() fixed chrome calwhat.blur().focus(); //add 2010-01-26 blur() fixed chrome
$(document).one("mousedown", function () { $(document).on("mousedown", function () {
$("#bbit-cal-buddle").css("visibility", "hidden"); $("#bbit-cal-buddle").css("visibility", "hidden");
releasedragevent(); releasedragevent();
}); });
$(document).on("keyup", "#bbit-cal-what", function() {
buddle.find(".bbit-cal-editLink").attr("href", addurl + encodeURIComponent($("#bbit-cal-what").val()));
});
return false; return false;
} }

View File

@ -68,7 +68,7 @@ function wdcal_getEditPage_str(&$localization, $baseurl, $uid, $calendar_id, $ur
"IsAllDayEvent" => $_REQUEST["isallday"], "IsAllDayEvent" => $_REQUEST["isallday"],
"Description" => "", "Description" => "",
"Location" => "", "Location" => "",
"Color" => "#5858ff", "Color" => null,
); );
if ($_REQUEST["isallday"]) { if ($_REQUEST["isallday"]) {
$notifications = array(array("rel" => "start", "type" => "duration", "period" => "hour", "period_val" => 24)); $notifications = array(array("rel" => "start", "type" => "duration", "period" => "hour", "period_val" => 24));
@ -89,7 +89,7 @@ function wdcal_getEditPage_str(&$localization, $baseurl, $uid, $calendar_id, $ur
"IsAllDayEvent" => "0", "IsAllDayEvent" => "0",
"Description" => "", "Description" => "",
"Location" => "", "Location" => "",
"Color" => "#5858ff", "Color" => null,
); );
$notifications = array(array("rel" => "start", "type" => "duration", "period" => "hour", "period_val" => 1)); $notifications = array(array("rel" => "start", "type" => "duration", "period" => "hour", "period_val" => 1));
$recurrence = null; $recurrence = null;
@ -102,20 +102,33 @@ function wdcal_getEditPage_str(&$localization, $baseurl, $uid, $calendar_id, $ur
$out .= "<form method='POST' action='$postto'> $out .= "<form method='POST' action='$postto'>
<input type='hidden' name='form_security_token' value='" . get_form_security_token('caledit') . "'>\n"; <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'>"; $out .= "<label for='calendar'>" . t("Calendar") . ":</label><select name='calendar' size='1'>";
$found = false;
$cal_col = "aaaaaa";
foreach ($calendars as $cal) { 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"] . "' "; $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 .= ">" . 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> $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_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>"; $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 .= "<input name='end_time' value='" . date("H:i", $event["EndTime"]) . "' id='cal_end_time'>";
$out .= "<br>\n"; $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 .= "<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 .= "<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 .= "<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=''>" . t("None") . "</option>\n";
$out .= "<option value='daily' "; if ($recurrence && $recurrence->frequency == "daily") $out .= "selected"; $out .= ">" . t("Daily") . "</option>\n"; $out .= "<option value='daily' ";
$out .= "<option value='weekly' "; if ($recurrence && $recurrence->frequency == "weekly") $out .= "selected"; $out .= ">" . t("Weekly") . "</option>\n"; if ($recurrence && $recurrence->frequency == "daily") $out .= "selected";
$out .= "<option value='monthly' "; if ($recurrence && $recurrence->frequency == "monthly") $out .= "selected"; $out .= ">" . t("Monthly") . "</option>\n"; $out .= ">" . t("Daily") . "</option>\n";
$out .= "<option value='yearly' "; if ($recurrence && $recurrence->frequency == "yearly") $out .= "selected"; $out .= ">" . t("Yearly") . "</option>\n"; $out .= "<option value='weekly' ";
$out .="</select><br>\n"; 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'>"; $out .= "<div id='rec_details'>";
$select = "<select id='rec_interval' name='rec_interval' size='1'>"; $select = "<select id='rec_interval' name='rec_interval' size='1'>";
@ -166,16 +187,32 @@ function wdcal_getEditPage_str(&$localization, $baseurl, $uid, $calendar_id, $ur
$byday = array("MO", "TU", "WE", "TH", "FR", "SA", "SU"); $byday = array("MO", "TU", "WE", "TH", "FR", "SA", "SU");
} }
if ($localization->getFirstDayOfWeek() == 0) { 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='MO' ";
$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; "; if (in_array("MO", $byday)) $out .= "checked";
$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 .= ">" . t("Monday") . "</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='TU' ";
$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; "; if (in_array("TU", $byday)) $out .= "checked";
$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 .= ">" . 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) { 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>"; $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"); $byday = array("MO", "TU", "WE", "TH", "FR", "SA", "SU");
} }
if ($localization->getFirstDayOfWeek() == 0) { 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='MO' ";
$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; "; if (in_array("MO", $byday)) $out .= "checked";
$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 .= ">" . t("Monday") . "</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='TU' ";
$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; "; if (in_array("TU", $byday)) $out .= "checked";
$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 .= ">" . 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) { 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>"; $out .= "<br>";
@ -207,8 +260,12 @@ function wdcal_getEditPage_str(&$localization, $baseurl, $uid, $calendar_id, $ur
if ($localization->getFirstDayOfWeek() == 0) $wkst = "SU"; if ($localization->getFirstDayOfWeek() == 0) $wkst = "SU";
else $wkst = "MO"; 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='SU' ";
$out .= "<label class='plain'><input type='radio' name='rec_weekly_wkst' value='MO' "; if ($wkst == "MO") $out .= "checked"; $out .= ">" . t("Monday") . "</label><br>\n"; 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>"; $out .= "</div>";
@ -216,10 +273,18 @@ function wdcal_getEditPage_str(&$localization, $baseurl, $uid, $calendar_id, $ur
$out .= "<div class='rec_monthly'>"; $out .= "<div class='rec_monthly'>";
$out .= "<label class='block' name='rec_monthly_day'>" . t("Day of month") . ":</label>"; $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 .= "<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' ";
$out .= "<option value='bymonthday_neg' "; if ($monthly_rule == "bymonthday_neg") $out .= "selected"; $out .= ">" . t("#num#th-last of each month") . "</option>\n"; if ($monthly_rule == "bymonthday") $out .= "selected";
$out .= "<option value='byday' "; if ($monthly_rule == "byday") $out .= "selected"; $out .= ">" . t("#num#th #wkday# of each month") . "</option>\n"; $out .= ">" . t("#num#th 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_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 .= "</select>";
$out .= "</div>\n"; $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("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 .= "<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 .= "<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' ";
$out .= "<option value='bymonthday_neg' "; if ($monthly_rule == "bymonthday_neg") $out .= "selected"; $out .= ">" . t("#num#th-last of each month") . "</option>\n"; if ($monthly_rule == "bymonthday") $out .= "selected";
$out .= "<option value='byday' "; if ($monthly_rule == "byday") $out .= "selected"; $out .= ">" . t("#num#th #wkday# of each month") . "</option>\n"; $out .= ">" . t("#num#th 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_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 .= "</select>";
$out .= "</div>\n"; $out .= "</div>\n";
@ -260,9 +333,15 @@ function wdcal_getEditPage_str(&$localization, $baseurl, $uid, $calendar_id, $ur
} }
$out .= "<label class='block' for='rec_until_type'>" . t("Repeat until") . ":</label> "; $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 .= "<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='infinite' ";
$out .= "<option value='date' "; if ($rule_type == "date") $out .= "selected"; $out .= ">" . t("Until the following date") . ":</option>\n"; if ($rule_type == "infinite") $out .= "selected";
$out .= "<option value='count' "; if ($rule_type == "count") $out .= "selected"; $out .= ">" . t("Number of times") . ":</option>\n"; $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 .= "</select>";
$out .= "<input name='rec_until_date' value='" . $localization->dateformat_datepicker_php($rule_until_date) . "' id='rec_until_date'>"; $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 .= "</div><br>";
$out .= "<h2>" .t("Notification") . "</h2>"; $out .= "<h2>" . t("Notification") . "</h2>";
/* /*
$out .= '<input type="checkbox" name="notification" id="notification" '; $out .= '<input type="checkbox" name="notification" id="notification" ';
@ -324,7 +403,8 @@ function wdcal_getEditPage_str(&$localization, $baseurl, $uid, $calendar_id, $ur
* @param Sabre_VObject_Component_VEvent $component * @param Sabre_VObject_Component_VEvent $component
* @param wdcal_local $localization * @param wdcal_local $localization
*/ */
function wdcal_set_component_date(&$component, &$localization) { function wdcal_set_component_date(&$component, &$localization)
{
if (isset($_REQUEST["allday"])) { if (isset($_REQUEST["allday"])) {
$ts_start = $localization->date_local2timestamp($_REQUEST["start_date"] . " 00:00"); $ts_start = $localization->date_local2timestamp($_REQUEST["start_date"] . " 00:00");
$ts_end = $localization->date_local2timestamp($_REQUEST["end_date"] . " 00:00"); $ts_end = $localization->date_local2timestamp($_REQUEST["end_date"] . " 00:00");
@ -345,11 +425,12 @@ function wdcal_set_component_date(&$component, &$localization) {
$component->add($datetime_end); $component->add($datetime_end);
} }
/** /**
* @param Sabre_VObject_Component_VEvent $component * @param Sabre_VObject_Component_VEvent $component
* @param wdcal_local $localization * @param wdcal_local $localization
*/ */
function wdcal_set_component_recurrence(&$component, &$localization) { function wdcal_set_component_recurrence(&$component, &$localization)
{
$component->__unset("RRULE"); $component->__unset("RRULE");
$component->__unset("EXRULE"); $component->__unset("EXRULE");
$component->__unset("EXDATE"); $component->__unset("EXDATE");
@ -417,7 +498,6 @@ function wdcal_set_component_recurrence(&$component, &$localization) {
} }
/** /**
* @param string $uri * @param string $uri
* @param string $recurr_uri * @param string $recurr_uri
@ -455,11 +535,13 @@ function wdcal_postEditPage($uri, $recurr_uri = "", $uid = 0, $timezone = "", $g
$component->__unset("LOCATION"); $component->__unset("LOCATION");
$component->__unset("SUMMARY"); $component->__unset("SUMMARY");
$component->__unset("DESCRIPTION"); $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("SUMMARY", icalendar_sanitize_string(dav_compat_parse_text_serverside("summary")));
$component->add("LOCATION", icalendar_sanitize_string(dav_compat_parse_text_serverside("location"))); $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("DESCRIPTION", icalendar_sanitize_string(dav_compat_parse_text_serverside("wdcal_desc")));
if (isset($_REQUEST["color_override"])) {
$component->add("X-ANIMEXX-COLOR", $_REQUEST["color"]); $component->add("X-ANIMEXX-COLOR", $_REQUEST["color"]);
}
$data = $vObject->serialize(); $data = $vObject->serialize();
@ -476,16 +558,17 @@ function wdcal_postEditPage($uri, $recurr_uri = "", $uid = 0, $timezone = "", $g
/** /**
* @return string * @return string
*/ */
function wdcal_getEditPage_exception_selector() { function wdcal_getEditPage_exception_selector()
{
header("Content-type: application/json"); header("Content-type: application/json");
$a = get_app(); $a = get_app();
$localization = wdcal_local::getInstanceByUser($a->user["uid"]); $localization = wdcal_local::getInstanceByUser($a->user["uid"]);
$vObject = wdcal_create_empty_vevent(); $vObject = dav_create_empty_vevent();
foreach($vObject->getComponents() as $component) { foreach ($vObject->getComponents() as $component) {
if ($component->name!=='VTIMEZONE') break; if ($component->name !== 'VTIMEZONE') break;
} }
/** @var Sabre_VObject_Component_VEvent $component */ /** @var Sabre_VObject_Component_VEvent $component */
wdcal_set_component_date($component, $localization); wdcal_set_component_date($component, $localization);
@ -499,7 +582,7 @@ function wdcal_getEditPage_exception_selector() {
$o = "<ul>"; $o = "<ul>";
$i = 0; $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(); $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"; $o .= "<li><a href='#' class='exception_selector_link' data-timestamp='$last_start'>" . $localization->date_timestamp2localDate($last_start) . "</a></li>\n";
$it->next(); $it->next();

View File

@ -28,6 +28,13 @@ class Sabre_CalDAV_Backend_Friendica extends Sabre_CalDAV_Backend_Virtual
return CALDAV_NAMESPACE_PRIVATE; return CALDAV_NAMESPACE_PRIVATE;
} }
/**
* @static
* @return string
*/
public static function getBackendTypeName() {
return t("Friendicy-Native events");
}
/** /**
* @static * @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'] .= '<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'] .= '<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'] .= '<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"; $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"; $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 * @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 wdcal_getEditPage_str($localization, $a->get_baseurl(), $a->user["uid"], $calendar_id, $uri, $recurr_uri);
} }
/**
* @return string
*/
function wdcal_getNewPage() function wdcal_getNewPage()
{ {
$a = get_app(); $a = get_app();
@ -302,6 +281,62 @@ function wdcal_getSettingsPage(&$a)
info(t('The new values have been saved.')); 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 = "";
$o .= "<a href='" . $a->get_baseurl() . "/dav/wdcal/'>" . t("Go back to the calendar") . "</a><br><br>"; $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 .= '<input type="submit" name="save" value="' . t('Save') . '">';
$o .= '</form>'; $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 .= "<br><h3>" . t("Limitations") . "</h3>";
$o .= "- The native friendica events are embedded as read-only, half-transparent in the calendar.<br>"; $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_create_std_calendars();
wdcal_addRequiredHeaders();
if ($a->argc >= 2 && $a->argv[1] == "wdcal") { if ($a->argc >= 2 && $a->argv[1] == "wdcal") {
if ($a->argc >= 3 && $a->argv[2] == "feed") { if ($a->argc >= 3 && $a->argv[2] == "feed") {
wdcal_print_feed($a->get_baseurl() . "/dav/wdcal/"); wdcal_print_feed($a->get_baseurl() . "/dav/wdcal/");
killme(); killme();
} elseif ($a->argc >= 3 && strlen($a->argv[2]) > 0) {
wdcal_addRequiredHeadersEdit();
} else {
wdcal_addRequiredHeaders();
} }
return; return;
} }
@ -140,6 +136,7 @@ function dav_content()
$ret = wdcal_postEditPage("new", "", $a->user["uid"], $a->timezone, $a->get_baseurl() . "/dav/wdcal/"); $ret = wdcal_postEditPage("new", "", $a->user["uid"], $a->timezone, $a->get_baseurl() . "/dav/wdcal/");
if ($ret["ok"]) notice($ret["msg"]); if ($ret["ok"]) notice($ret["msg"]);
else info($ret["msg"]); else info($ret["msg"]);
goaway($a->get_baseurl() . "/dav/wdcal/");
} }
$o .= wdcal_getNewPage(); $o .= wdcal_getNewPage();
return $o; 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/"); $ret = wdcal_postEditPage($a->argv[3], $recurr_uri, $a->user["uid"], $a->timezone, $a->get_baseurl() . "/dav/wdcal/");
if ($ret["ok"]) notice($ret["msg"]); if ($ret["ok"]) notice($ret["msg"]);
else info($ret["msg"]); else info($ret["msg"]);
goaway($a->get_baseurl() . "/dav/wdcal/");
} }
$o .= wdcal_getEditPage($calendar_id, $a->argv[3], $recurr_uri); $o .= wdcal_getEditPage($calendar_id, $a->argv[3], $recurr_uri);
return $o; return $o;