From a79a85edbb136e9a26ab7c5210e3918568e06bcb Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tobias=20H=C3=B6=C3=9Fl?= Date: Thu, 12 Jul 2012 19:22:11 +0000 Subject: [PATCH] Adding and removing calendars --- dav/common/calendar.fnk.php | 2 + dav/common/dav_caldav_backend_common.inc.php | 7 + dav/common/dav_caldav_backend_private.inc.php | 7 + dav/common/wdcal.js | 23 +- dav/common/wdcal/js/jquery.calendar.js | 8 +- dav/common/wdcal_edit.inc.php | 289 +++++++++++------- ...v_caldav_backend_virtual_friendica.inc.php | 7 + dav/layout.fnk.php | 143 +++++++-- dav/main.php | 8 +- 9 files changed, 353 insertions(+), 141 deletions(-) diff --git a/dav/common/calendar.fnk.php b/dav/common/calendar.fnk.php index 72aeb198..27f51621 100644 --- a/dav/common/calendar.fnk.php +++ b/dav/common/calendar.fnk.php @@ -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 diff --git a/dav/common/dav_caldav_backend_common.inc.php b/dav/common/dav_caldav_backend_common.inc.php index c8c92e2f..2381e713 100644 --- a/dav/common/dav_caldav_backend_common.inc.php +++ b/dav/common/dav_caldav_backend_common.inc.php @@ -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 diff --git a/dav/common/dav_caldav_backend_private.inc.php b/dav/common/dav_caldav_backend_private.inc.php index 38b77ee9..d258b6ca 100644 --- a/dav/common/dav_caldav_backend_private.inc.php +++ b/dav/common/dav_caldav_backend_private.inc.php @@ -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 diff --git a/dav/common/wdcal.js b/dav/common/wdcal.js index 4c14a007..13069eba 100644 --- a/dav/common/wdcal.js +++ b/dav/common/wdcal.js @@ -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); @@ -190,4 +194,21 @@ function wdcal_edit_init(dateFormat, base_path) { }) }); }); -} \ No newline at end of file +} + + +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(); + }); +} diff --git a/dav/common/wdcal/js/jquery.calendar.js b/dav/common/wdcal/js/jquery.calendar.js index bb11139d..201917c0 100644 --- a/dav/common/wdcal/js/jquery.calendar.js +++ b/dav/common/wdcal/js/jquery.calendar.js @@ -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; } diff --git a/dav/common/wdcal_edit.inc.php b/dav/common/wdcal_edit.inc.php index ea570d00..63e39e8c 100644 --- a/dav/common/wdcal_edit.inc.php +++ b/dav/common/wdcal_edit.inc.php @@ -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 .= "
\n"; - $out .= "

" .t("Event data") . "

"; + $out .= "

" . t("Event data") . "

"; $out .= "
\n"; + + $out .= ""; + $out .= "