Merge pull request #61 from CatoTH/master
Calendar: Some Bugfixes and new ways to create an eventpull/62/merge
commit
a7b36e9e8e
|
@ -22,11 +22,17 @@ define("CARDDAV_NAMESPACE_PHONECONTACTS", 2);
|
||||||
|
|
||||||
define("CALDAV_DB_VERSION", 1);
|
define("CALDAV_DB_VERSION", 1);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
function getCurMicrotime () {
|
function getCurMicrotime () {
|
||||||
list($usec, $sec) = explode(" ", microtime());
|
list($usec, $sec) = explode(" ", microtime());
|
||||||
return sprintf("%14.0f", $sec * 10000 + $usec * 10000);
|
return sprintf("%14.0f", $sec * 10000 + $usec * 10000);
|
||||||
} // function getCurMicrotime
|
} // function getCurMicrotime
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
function debug_time() {
|
function debug_time() {
|
||||||
$cur = getCurMicrotime();
|
$cur = getCurMicrotime();
|
||||||
if ($GLOBALS["debug_time_last"] > 0) {
|
if ($GLOBALS["debug_time_last"] > 0) {
|
||||||
|
@ -80,13 +86,30 @@ function dav_compat_principal2uid($principalUri = "")
|
||||||
return dav_compat_username2id($username);
|
return dav_compat_username2id($username);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $name
|
||||||
|
* @return null|string
|
||||||
|
*/
|
||||||
|
function dav_compat_getRequestVar($name = "") {
|
||||||
|
if (x($_REQUEST, $name)) return $_REQUEST[$name];
|
||||||
|
else return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $text
|
* @param $text
|
||||||
* @return mixed
|
* @return null|string
|
||||||
*/
|
*/
|
||||||
function wdcal_parse_text_serverside($text)
|
function dav_compat_parse_text_serverside($text)
|
||||||
{
|
{
|
||||||
return $text;
|
return dav_compat_getRequestVar($text);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $uri
|
||||||
|
*/
|
||||||
|
function dav_compat_redirect($uri = "") {
|
||||||
|
goaway($uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -477,6 +477,67 @@ function wdcal_get_list_range_params($day, $weekstartday, $num_days, $type)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $uri
|
||||||
|
* @param string $recurr_uri
|
||||||
|
* @param int $uid
|
||||||
|
* @param string $timezone
|
||||||
|
* @param string $goaway_url
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function wdcal_postEditPage($uri, $recurr_uri = "", $uid = 0, $timezone = "", $goaway_url = "")
|
||||||
|
{
|
||||||
|
$uid = IntVal($uid);
|
||||||
|
$localization = wdcal_local::getInstanceByUser($uid);
|
||||||
|
|
||||||
|
if (isset($_REQUEST["allday"])) {
|
||||||
|
$start = $localization->date_parseLocal($_REQUEST["start_date"] . " 00:00");
|
||||||
|
$end = $localization->date_parseLocal($_REQUEST["end_date"] . " 20:00");
|
||||||
|
$isallday = true;
|
||||||
|
} else {
|
||||||
|
$start = $localization->date_parseLocal($_REQUEST["start_date"] . " " . $_REQUEST["start_time"]);
|
||||||
|
$end = $localization->date_parseLocal($_REQUEST["end_date"] . " " . $_REQUEST["end_time"]);
|
||||||
|
$isallday = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($uri == "new") {
|
||||||
|
$cals = dav_getMyCals($uid);
|
||||||
|
foreach ($cals as $c) {
|
||||||
|
$cs = wdcal_calendar_factory($uid, $c->namespace, $c->namespace_id);
|
||||||
|
$p = $cs->getPermissionsCalendar($uid);
|
||||||
|
|
||||||
|
if ($p["write"]) try {
|
||||||
|
$cs->addItem($start, $end, dav_compat_getRequestVar("subject"), $isallday, dav_compat_parse_text_serverside("wdcal_desc"),
|
||||||
|
dav_compat_getRequestVar("location"), dav_compat_getRequestVar("color"), $timezone,
|
||||||
|
isset($_REQUEST["notification"]), $_REQUEST["notification_type"], $_REQUEST["notification_value"]);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
notification(t("Error") . ": " . $e);
|
||||||
|
}
|
||||||
|
dav_compat_redirect($goaway_url);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$cals = dav_getMyCals($uid);
|
||||||
|
foreach ($cals as $c) {
|
||||||
|
$cs = wdcal_calendar_factory($uid, $c->namespace, $c->namespace_id);
|
||||||
|
$p = $cs->getPermissionsItem($uid, $uri, $recurr_uri);
|
||||||
|
if ($p["write"]) try {
|
||||||
|
$cs->updateItem($uri, $start, $end,
|
||||||
|
dav_compat_getRequestVar("subject"), $isallday, dav_compat_parse_text_serverside("wdcal_desc"),
|
||||||
|
dav_compat_getRequestVar("location"), dav_compat_getRequestVar("color"), $timezone,
|
||||||
|
isset($_REQUEST["notification"]), $_REQUEST["notification_type"], $_REQUEST["notification_value"]);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
notification(t("Error") . ": " . $e);
|
||||||
|
}
|
||||||
|
dav_compat_redirect($goaway_url);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,17 +1,53 @@
|
||||||
|
function wdcal_edit_getStartEnd() {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var start = $("#cal_start_date").datepicker("getDate");
|
||||||
|
var start_time = $.timePicker("#cal_start_time").getTime();
|
||||||
|
start.setHours(start_time.getHours());
|
||||||
|
start.setMinutes(start_time.getMinutes());
|
||||||
|
|
||||||
|
var end = $("#cal_end_date").datepicker("getDate");
|
||||||
|
var end_time = $.timePicker("#cal_end_time").getTime();
|
||||||
|
end.setHours(end_time.getHours());
|
||||||
|
end.setMinutes(end_time.getMinutes());
|
||||||
|
|
||||||
|
return {"start": start, "end": end};
|
||||||
|
}
|
||||||
|
|
||||||
|
function wdcal_edit_checktime_startChanged() {
|
||||||
|
"use strict";
|
||||||
|
var time = wdcal_edit_getStartEnd();
|
||||||
|
if (time.start.getTime() >= time.end.getTime()) {
|
||||||
|
var newend = new Date(time.start.getTime() + 3600000);
|
||||||
|
$("#cal_end_date").datepicker("setDate", newend);
|
||||||
|
$.timePicker("#cal_end_time").setTime(newend);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function wdcal_edit_checktime_endChanged() {
|
||||||
|
"use strict";
|
||||||
|
var time = wdcal_edit_getStartEnd();
|
||||||
|
if (time.start.getTime() >= time.end.getTime()) {
|
||||||
|
var newstart = new Date(time.end.getTime() - 3600000);
|
||||||
|
$("#cal_start_date").datepicker("setDate", newstart);
|
||||||
|
$.timePicker("#cal_start_time").setTime(newstart);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function wdcal_edit_init(dateFormat) {
|
function wdcal_edit_init(dateFormat) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
$("#cal_color").colorPicker();
|
$("#cal_color").colorPicker();
|
||||||
|
|
||||||
$("#cal_start_time").timePicker({ step: 15 });
|
$("#cal_start_time").timePicker({ step: 15 }).on("change", wdcal_edit_checktime_startChanged);
|
||||||
$("#cal_end_time").timePicker();
|
$("#cal_end_time").timePicker().on("change", wdcal_edit_checktime_endChanged);
|
||||||
|
|
||||||
$("#cal_start_date").datepicker({
|
$("#cal_start_date").datepicker({
|
||||||
"dateFormat": dateFormat
|
"dateFormat": dateFormat
|
||||||
});
|
}).on("change", wdcal_edit_checktime_startChanged);
|
||||||
$("#cal_end_date").datepicker({
|
$("#cal_end_date").datepicker({
|
||||||
"dateFormat": dateFormat
|
"dateFormat": dateFormat
|
||||||
});
|
}).on("change", wdcal_edit_checktime_endChanged);
|
||||||
|
|
||||||
$("#notification").on("click change", function() {
|
$("#notification").on("click change", function() {
|
||||||
if ($(this).prop("checked")) $("#notification_detail").show();
|
if ($(this).prop("checked")) $("#notification_detail").show();
|
||||||
|
|
|
@ -195,6 +195,7 @@
|
||||||
* {Number} Calendar height, false for page height by default.
|
* {Number} Calendar height, false for page height by default.
|
||||||
*/
|
*/
|
||||||
height:false,
|
height:false,
|
||||||
|
baseurl: "",
|
||||||
/**
|
/**
|
||||||
* @description {Config} url
|
* @description {Config} url
|
||||||
* {String} Url to request calendar data.
|
* {String} Url to request calendar data.
|
||||||
|
@ -1744,21 +1745,21 @@
|
||||||
temparr.push(i18n.xgcalendar.time, ':</th><td class=cb-value><div id="bbit-cal-buddle-timeshow"></div></td></tr><tr><th class="cb-key">');
|
temparr.push(i18n.xgcalendar.time, ':</th><td class=cb-value><div id="bbit-cal-buddle-timeshow"></div></td></tr><tr><th class="cb-key">');
|
||||||
temparr.push(i18n.xgcalendar.content, ':</th><td class="cb-value"><div class="textbox-fill-wrapper"><div class="textbox-fill-mid"><input id="bbit-cal-what" class="textbox-fill-input"/></div></div><div class="cb-example">');
|
temparr.push(i18n.xgcalendar.content, ':</th><td class="cb-value"><div class="textbox-fill-wrapper"><div class="textbox-fill-mid"><input id="bbit-cal-what" class="textbox-fill-input"/></div></div><div class="cb-example">');
|
||||||
temparr.push(i18n.xgcalendar.example, '</div></td></tr></tbody></table><input id="bbit-cal-start" type="hidden"/><input id="bbit-cal-end" type="hidden"/><input id="bbit-cal-allday" type="hidden"/><input id="bbit-cal-quickAddBTN" value="');
|
temparr.push(i18n.xgcalendar.example, '</div></td></tr></tbody></table><input id="bbit-cal-start" type="hidden"/><input id="bbit-cal-end" type="hidden"/><input id="bbit-cal-allday" type="hidden"/><input id="bbit-cal-quickAddBTN" value="');
|
||||||
temparr.push(i18n.xgcalendar.create_event, '" type="submit"/> <SPAN id="bbit-cal-editLink" class="lk">');
|
temparr.push(i18n.xgcalendar.create_event, '" type="submit"/> <a href="" class="lk bbit-cal-editLink">');
|
||||||
temparr.push(i18n.xgcalendar.update_detail, ' <StrONG>>></StrONG></SPAN></div></div></div><tr><td><div id="bl1" class="bubble-corner"><div class="bubble-sprite bubble-bl"></div></div><td><div class="bubble-bottom"></div><td><div id="br1" class="bubble-corner"><div class="bubble-sprite bubble-br"></div></div></tr></tbody></table><div id="bubbleClose1" class="bubble-closebutton"></div><div id="prong2" class="prong"><div class=bubble-sprite></div></div></div>');
|
temparr.push(i18n.xgcalendar.update_detail, ' <StrONG>>></StrONG></SPAN></div></div></div><tr><td><div id="bl1" class="bubble-corner"><div class="bubble-sprite bubble-bl"></div></div><td><div class="bubble-bottom"></div><td><div id="br1" class="bubble-corner"><div class="bubble-sprite bubble-br"></div></div></tr></tbody></table><div id="bubbleClose1" class="bubble-closebutton"></div><div id="prong2" class="prong"><div class=bubble-sprite></div></div></div>');
|
||||||
temparr.push('</form>');
|
temparr.push('</form>');
|
||||||
var tempquickAddHanler = temparr.join("");
|
var tempquickAddHandler = temparr.join("");
|
||||||
temparr = null;
|
temparr = null;
|
||||||
$(document.body).append(tempquickAddHanler);
|
$(document.body).append(tempquickAddHandler);
|
||||||
buddle = $("#bbit-cal-buddle");
|
buddle = $("#bbit-cal-buddle");
|
||||||
$("#bubbleClose1").click(function () {
|
$("#bubbleClose1").on("click", function () {
|
||||||
$("#bbit-cal-buddle").css("visibility", "hidden");
|
$("#bbit-cal-buddle").css("visibility", "hidden");
|
||||||
releasedragevent();
|
releasedragevent();
|
||||||
});
|
});
|
||||||
$("#bbit-cal-submitFORM").keyup(function (e) {
|
$("#bbit-cal-submitFORM").on("keyup", function (e) {
|
||||||
if (e.which == 27) $("#bubbleClose1").click();
|
if (e.which == 27) $("#bubbleClose1").click();
|
||||||
});
|
});
|
||||||
$("#bbit-cal-submitFORM").submit(function (e) {
|
$("#bbit-cal-submitFORM").on("submit", function (e) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (option.isloading) {
|
if (option.isloading) {
|
||||||
|
@ -1838,7 +1839,7 @@
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
buddle.mousedown(function (e) {
|
buddle.on("mousedown", function (e) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
|
@ -1857,6 +1858,10 @@
|
||||||
$("#bbit-cal-allday").val(isallday ? "1" : "0");
|
$("#bbit-cal-allday").val(isallday ? "1" : "0");
|
||||||
$("#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");
|
||||||
|
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).one("mousedown", function () {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
/**
|
/**
|
||||||
* Name: Calendar with CalDAV Support
|
* Name: Calendar with CalDAV Support
|
||||||
* Description: A web-based calendar system with CalDAV-support. Also brings your Friendica-Contacts to your CardDAV-capable mobile phone. Requires PHP >= 5.3.
|
* Description: A web-based calendar system with CalDAV-support. Also brings your Friendica-Contacts to your CardDAV-capable mobile phone. Requires PHP >= 5.3.
|
||||||
* Version: 0.1
|
* Version: 0.1.1
|
||||||
* Author: Tobias Hößl <https://github.com/CatoTH/>
|
* Author: Tobias Hößl <https://github.com/CatoTH/>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -18,8 +18,11 @@ function wdcal_addRequiredHeaders()
|
||||||
$a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/dav/wdcal/css/main.css' . '" media="all" />' . "\r\n";
|
$a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/dav/wdcal/css/main.css' . '" media="all" />' . "\r\n";
|
||||||
|
|
||||||
switch (get_config("system", "language")) {
|
switch (get_config("system", "language")) {
|
||||||
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"; break;
|
case "de":
|
||||||
default: $a->page['htmlhead'] .= '<script type="text/javascript" src="' . $a->get_baseurl() . '/addon/dav/common/wdcal/js/wdCalendar_lang_EN.js"></script>' . "\r\n";
|
$a->page['htmlhead'] .= '<script type="text/javascript" src="' . $a->get_baseurl() . '/addon/dav/common/wdcal/js/wdCalendar_lang_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";
|
||||||
}
|
}
|
||||||
|
|
||||||
$a->page['htmlhead'] .= '<script type="text/javascript" src="' . $a->get_baseurl() . '/addon/dav/common/wdcal/js/jquery.calendar.js"></script>' . "\r\n";
|
$a->page['htmlhead'] .= '<script type="text/javascript" src="' . $a->get_baseurl() . '/addon/dav/common/wdcal/js/jquery.calendar.js"></script>' . "\r\n";
|
||||||
|
@ -80,6 +83,7 @@ function wdcal_printCalendar($calendars, $calendar_preselected, $data_feed_url,
|
||||||
"date_format_dm2" => $localization->dateformat_js_dm2(),
|
"date_format_dm2" => $localization->dateformat_js_dm2(),
|
||||||
"date_format_dm3" => $localization->dateformat_js_dm3(),
|
"date_format_dm3" => $localization->dateformat_js_dm3(),
|
||||||
"date_format_full" => $localization->dateformat_datepicker_js(),
|
"date_format_full" => $localization->dateformat_datepicker_js(),
|
||||||
|
"baseurl" => $a->get_baseurl() . "/dav/wdcal/",
|
||||||
);
|
);
|
||||||
|
|
||||||
$x = '
|
$x = '
|
||||||
|
@ -111,6 +115,9 @@ function wdcal_printCalendar($calendars, $calendar_preselected, $data_feed_url,
|
||||||
<div class="fbutton faddbtn" style="float: right;">
|
<div class="fbutton faddbtn" style="float: right;">
|
||||||
<div><a href="' . $a->get_baseurl() . '/dav/settings/"><span>' . t("Settings") . ' / ' . t("Help") . '</span></a></div>
|
<div><a href="' . $a->get_baseurl() . '/dav/settings/"><span>' . t("Settings") . ' / ' . t("Help") . '</span></a></div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="fbutton addcal">
|
||||||
|
<div><a href="' . $a->get_baseurl() . '/dav/wdcal/new/" class="addcal">' . t("New event") . '</a></div>
|
||||||
|
</div>
|
||||||
<div class="btnseparator"></div>
|
<div class="btnseparator"></div>
|
||||||
<div class="fbutton showtodaybtn">
|
<div class="fbutton showtodaybtn">
|
||||||
<div><span class="showtoday">' . t("Today") . '</span></div>
|
<div><span class="showtoday">' . t("Today") . '</span></div>
|
||||||
|
@ -122,7 +129,7 @@ function wdcal_printCalendar($calendars, $calendar_preselected, $data_feed_url,
|
||||||
|
|
||||||
if ($view == "day") $x .= 'fcurrent';
|
if ($view == "day") $x .= 'fcurrent';
|
||||||
|
|
||||||
$x .= '">Tag</span></div>
|
$x .= '">' . t("Day") . '</span></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="fbutton showweekbtn ';
|
<div class="fbutton showweekbtn ';
|
||||||
|
|
||||||
|
@ -178,10 +185,10 @@ function wdcal_printCalendar($calendars, $calendar_preselected, $data_feed_url,
|
||||||
*/
|
*/
|
||||||
function wdcal_getDetailPage($uri, $recurr_uri)
|
function wdcal_getDetailPage($uri, $recurr_uri)
|
||||||
{
|
{
|
||||||
$a = get_app();
|
$a = get_app();
|
||||||
|
|
||||||
$details = null;
|
$details = null;
|
||||||
$cals = dav_getMyCals($a->user["uid"]);
|
$cals = dav_getMyCals($a->user["uid"]);
|
||||||
foreach ($cals as $c) {
|
foreach ($cals as $c) {
|
||||||
$cs = wdcal_calendar_factory($a->user["uid"], $c->namespace, $c->namespace_id);
|
$cs = wdcal_calendar_factory($a->user["uid"], $c->namespace, $c->namespace_id);
|
||||||
$p = $cs->getPermissionsItem($a->user["uid"], $uri, $recurr_uri);
|
$p = $cs->getPermissionsItem($a->user["uid"], $uri, $recurr_uri);
|
||||||
|
@ -199,54 +206,12 @@ function wdcal_getDetailPage($uri, $recurr_uri)
|
||||||
return $uri . " / " . $recurr_uri . "<br>" . print_r($details, true);
|
return $uri . " / " . $recurr_uri . "<br>" . print_r($details, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $uri
|
* @param string $uri
|
||||||
* @param string $recurr_uri
|
* @param string $recurr_uri
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function wdcal_postEditPage($uri, $recurr_uri)
|
function wdcal_getEditPage($uri, $recurr_uri = "")
|
||||||
{
|
|
||||||
|
|
||||||
$a = get_app();
|
|
||||||
$localization = wdcal_local::getInstanceByUser($a->user["uid"]);
|
|
||||||
|
|
||||||
check_form_security_token_redirectOnErr($a->get_baseurl() . "/dav/wdcal/", "caledit");
|
|
||||||
|
|
||||||
if (isset($_REQUEST["allday"])) {
|
|
||||||
$start = $localization->date_parseLocal($_REQUEST["start_date"] . " 00:00");
|
|
||||||
$end = $localization->date_parseLocal($_REQUEST["end_date"] . " 20:00");
|
|
||||||
$isallday = true;
|
|
||||||
} else {
|
|
||||||
$start = $localization->date_parseLocal($_REQUEST["start_date"] . " " . $_REQUEST["start_time"]);
|
|
||||||
$end = $localization->date_parseLocal($_REQUEST["end_date"] . " " . $_REQUEST["end_time"]);
|
|
||||||
$isallday = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$cals = dav_getMyCals($a->user["uid"]);
|
|
||||||
foreach ($cals as $c) {
|
|
||||||
$cs = wdcal_calendar_factory($a->user["uid"], $c->namespace, $c->namespace_id);
|
|
||||||
$p = $cs->getPermissionsItem($a->user["uid"], $uri, $recurr_uri);
|
|
||||||
if ($p["write"]) try {
|
|
||||||
$cs->updateItem($uri, $start, $end,
|
|
||||||
stripslashes($_REQUEST["subject"]), $isallday, wdcal_parse_text_serverside($_REQUEST["wdcal_desc"]),
|
|
||||||
stripslashes($_REQUEST["location"]), $_REQUEST["color"], $a->timezone,
|
|
||||||
isset($_REQUEST["notification"]), $_REQUEST["notification_type"], $_REQUEST["notification_value"]);
|
|
||||||
} catch (Exception $e) {
|
|
||||||
notification(t("Error") . ": " . $e);
|
|
||||||
}
|
|
||||||
goaway($a->get_baseurl() . "/dav/wdcal/");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $uri
|
|
||||||
* @param string $recurr_uri
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
function wdcal_getEditPage($uri, $recurr_uri)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
$a = get_app();
|
$a = get_app();
|
||||||
|
@ -290,8 +255,8 @@ function wdcal_getEditPage($uri, $recurr_uri)
|
||||||
"Subject" => $_REQUEST["title"],
|
"Subject" => $_REQUEST["title"],
|
||||||
"Location" => "",
|
"Location" => "",
|
||||||
"Description" => "",
|
"Description" => "",
|
||||||
"StartTime" => $_REQUEST["start"],
|
"StartTime" => wdcal_php2MySqlTime($_REQUEST["start"]),
|
||||||
"EndTime" => $_REQUEST["end"],
|
"EndTime" => wdcal_php2MySqlTime($_REQUEST["end"]),
|
||||||
"IsAllDayEvent" => $_REQUEST["isallday"],
|
"IsAllDayEvent" => $_REQUEST["isallday"],
|
||||||
"Color" => null,
|
"Color" => null,
|
||||||
"RecurringRule" => null,
|
"RecurringRule" => null,
|
||||||
|
@ -311,10 +276,10 @@ function wdcal_getEditPage($uri, $recurr_uri)
|
||||||
"Subject" => "",
|
"Subject" => "",
|
||||||
"Location" => "",
|
"Location" => "",
|
||||||
"Description" => "",
|
"Description" => "",
|
||||||
"StartTime" => "",
|
"StartTime" => date("Y-m-d H:i:s"),
|
||||||
"EndTime" => "",
|
"EndTime" => date("Y-m-d H:i:s", time() + 3600),
|
||||||
"IsAllDayEvent" => "",
|
"IsAllDayEvent" => "0",
|
||||||
"Color" => null,
|
"Color" => "#5858ff",
|
||||||
"RecurringRule" => null,
|
"RecurringRule" => null,
|
||||||
);
|
);
|
||||||
$notification_type = "hour";
|
$notification_type = "hour";
|
||||||
|
@ -322,26 +287,27 @@ function wdcal_getEditPage($uri, $recurr_uri)
|
||||||
$notification = true;
|
$notification = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$postto = $a->get_baseurl() . "/dav/wdcal/" . ($uri == "new" ? "new/" : $uri . "/edit/");
|
||||||
|
|
||||||
$out = "<a href='" . $a->get_baseurl() . "/dav/wdcal/'>" . t("Go back to the calendar") . "</a><br><br>";
|
$out = "<a href='" . $a->get_baseurl() . "/dav/wdcal/'>" . t("Go back to the calendar") . "</a><br><br>";
|
||||||
$out .= "<form method='POST' action='" . $a->get_baseurl() . "/dav/wdcal/$uri/edit/'><input type='hidden' name='form_security_token' value='" . get_form_security_token('caledit') . "'>\n";
|
$out .= "<form method='POST' action='$postto'><input type='hidden' name='form_security_token' value='" . get_form_security_token('caledit') . "'>\n";
|
||||||
|
|
||||||
$out .= "<label for='cal_subject'>Subject:</label>
|
$out .= "<label for='cal_subject'>Subject:</label>
|
||||||
<input name='color' id='cal_color' value='" . (strlen($event["Color"]) != 7 ? "#5858ff" : escape_tags($event["Color"])) . "'>
|
<input name='color' id='cal_color' value='" . (strlen($event["Color"]) != 7 ? "#5858ff" : escape_tags($event["Color"])) . "'>
|
||||||
<input name='subject' id='cal_subject' value='" . escape_tags($event["Subject"]) . "'><br>\n";
|
<input name='subject' id='cal_subject' value='" . escape_tags($event["Subject"]) . "'><br>\n";
|
||||||
$out .= "<label for='cal_allday'>Is All-Day event:</label><input type='checkbox' name='allday' id='cal_allday' " . ($event["IsAllDayEvent"] ? "checked" : "") . "><br>\n";
|
$out .= "<label for='cal_allday'>Is All-Day event:</label><input type='checkbox' name='allday' id='cal_allday' " . ($event["IsAllDayEvent"] ? "checked" : "") . "><br>\n";
|
||||||
|
|
||||||
$out .= "<label for='cal_startdate'>Starts:</label>";
|
$out .= "<label for='cal_startdate'>" . t("Starts") . ":</label>";
|
||||||
$out .= "<input name='start_date' value='" . $localization->dateformat_datepicker_php(wdcal_mySql2PhpTime($event["StartTime"])) . "' id='cal_start_date'>";
|
$out .= "<input name='start_date' value='" . $localization->dateformat_datepicker_php(wdcal_mySql2PhpTime($event["StartTime"])) . "' id='cal_start_date'>";
|
||||||
$out .= "<input name='start_time' value='" . substr($event["StartTime"], 11, 5) . "' id='cal_start_time'>";
|
$out .= "<input name='start_time' value='" . substr($event["StartTime"], 11, 5) . "' id='cal_start_time'>";
|
||||||
$out .= "<br>\n";
|
$out .= "<br>\n";
|
||||||
|
|
||||||
$out .= "<label for='cal_enddate'>Ends:</label>";
|
$out .= "<label for='cal_enddate'>" . t("Ends") . ":</label>";
|
||||||
$out .= "<input name='end_date' value='" . $localization->dateformat_datepicker_php(wdcal_mySql2PhpTime($event["EndTime"])) . "' id='cal_end_date'>";
|
$out .= "<input name='end_date' value='" . $localization->dateformat_datepicker_php(wdcal_mySql2PhpTime($event["EndTime"])) . "' id='cal_end_date'>";
|
||||||
$out .= "<input name='end_time' value='" . substr($event["EndTime"], 11, 5) . "' id='cal_end_time'>";
|
$out .= "<input name='end_time' value='" . substr($event["EndTime"], 11, 5) . "' id='cal_end_time'>";
|
||||||
$out .= "<br>\n";
|
$out .= "<br>\n";
|
||||||
|
|
||||||
$out .= "<label for='cal_location'>Location:</label><input name='location' id='cal_location' value='" . escape_tags($event["Location"]) . "'><br>\n";
|
$out .= "<label for='cal_location'>" . t("Location") . ":</label><input name='location' id='cal_location' value='" . escape_tags($event["Location"]) . "'><br>\n";
|
||||||
|
|
||||||
$out .= "<label 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 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;'>";
|
||||||
|
|
109
dav/main.php
109
dav/main.php
|
@ -22,48 +22,49 @@ function dav_module()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
function dav_include_files() {
|
function dav_include_files()
|
||||||
require_once (__DIR__ . "/common/dbclasses/dbclass_animexx.class.php");
|
{
|
||||||
require_once (__DIR__ . "/common/dbclasses/dbclass.friendica.calendars.class.php");
|
require_once (__DIR__ . "/common/dbclasses/dbclass_animexx.class.php");
|
||||||
require_once (__DIR__ . "/common/dbclasses/dbclass.friendica.jqcalendar.class.php");
|
require_once (__DIR__ . "/common/dbclasses/dbclass.friendica.calendars.class.php");
|
||||||
require_once (__DIR__ . "/common/dbclasses/dbclass.friendica.notifications.class.php");
|
require_once (__DIR__ . "/common/dbclasses/dbclass.friendica.jqcalendar.class.php");
|
||||||
require_once (__DIR__ . "/common/dbclasses/dbclass.friendica.calendarobjects.class.php");
|
require_once (__DIR__ . "/common/dbclasses/dbclass.friendica.notifications.class.php");
|
||||||
|
require_once (__DIR__ . "/common/dbclasses/dbclass.friendica.calendarobjects.class.php");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
require_once (__DIR__ . "/SabreDAV/lib/Sabre.includes.php");
|
require_once (__DIR__ . "/SabreDAV/lib/Sabre.includes.php");
|
||||||
require_once (__DIR__ . "/SabreDAV/lib/Sabre/VObject/includes.php");
|
require_once (__DIR__ . "/SabreDAV/lib/Sabre/VObject/includes.php");
|
||||||
require_once (__DIR__ . "/SabreDAV/lib/Sabre/DAVACL/includes.php");
|
require_once (__DIR__ . "/SabreDAV/lib/Sabre/DAVACL/includes.php");
|
||||||
require_once (__DIR__ . "/SabreDAV/lib/Sabre/CalDAV/includes.php");
|
require_once (__DIR__ . "/SabreDAV/lib/Sabre/CalDAV/includes.php");
|
||||||
*/
|
*/
|
||||||
require_once (__DIR__ . "/SabreDAV/lib/Sabre/autoload.php");
|
require_once (__DIR__ . "/SabreDAV/lib/Sabre/autoload.php");
|
||||||
|
|
||||||
$tz_before = date_default_timezone_get();
|
$tz_before = date_default_timezone_get();
|
||||||
require_once (__DIR__ . "/iCalcreator/iCalcreator.class.php");
|
require_once (__DIR__ . "/iCalcreator/iCalcreator.class.php");
|
||||||
date_default_timezone_set($tz_before);
|
date_default_timezone_set($tz_before);
|
||||||
|
|
||||||
require_once (__DIR__ . "/common/calendar.fnk.php");
|
require_once (__DIR__ . "/common/calendar.fnk.php");
|
||||||
require_once (__DIR__ . "/common/dav_caldav_backend_common.inc.php");
|
require_once (__DIR__ . "/common/dav_caldav_backend_common.inc.php");
|
||||||
require_once (__DIR__ . "/common/dav_caldav_backend.inc.php");
|
require_once (__DIR__ . "/common/dav_caldav_backend.inc.php");
|
||||||
require_once (__DIR__ . "/common/dav_caldav_root.inc.php");
|
require_once (__DIR__ . "/common/dav_caldav_root.inc.php");
|
||||||
require_once (__DIR__ . "/common/dav_user_calendars.inc.php");
|
require_once (__DIR__ . "/common/dav_user_calendars.inc.php");
|
||||||
require_once (__DIR__ . "/common/dav_carddav_root.inc.php");
|
require_once (__DIR__ . "/common/dav_carddav_root.inc.php");
|
||||||
require_once (__DIR__ . "/common/dav_carddav_backend_std.inc.php");
|
require_once (__DIR__ . "/common/dav_carddav_backend_std.inc.php");
|
||||||
require_once (__DIR__ . "/common/dav_user_addressbooks.inc.php");
|
require_once (__DIR__ . "/common/dav_user_addressbooks.inc.php");
|
||||||
require_once (__DIR__ . "/common/virtual_cal_source_backend.inc.php");
|
require_once (__DIR__ . "/common/virtual_cal_source_backend.inc.php");
|
||||||
require_once (__DIR__ . "/common/wdcal_configuration.php");
|
require_once (__DIR__ . "/common/wdcal_configuration.php");
|
||||||
require_once (__DIR__ . "/common/wdcal_cal_source.inc.php");
|
require_once (__DIR__ . "/common/wdcal_cal_source.inc.php");
|
||||||
require_once (__DIR__ . "/common/wdcal_cal_source_private.inc.php");
|
require_once (__DIR__ . "/common/wdcal_cal_source_private.inc.php");
|
||||||
|
|
||||||
require_once (__DIR__ . "/dav_friendica_principal.inc.php");
|
require_once (__DIR__ . "/dav_friendica_principal.inc.php");
|
||||||
require_once (__DIR__ . "/dav_friendica_auth.inc.php");
|
require_once (__DIR__ . "/dav_friendica_auth.inc.php");
|
||||||
require_once (__DIR__ . "/dav_carddav_backend_friendica_community.inc.php");
|
require_once (__DIR__ . "/dav_carddav_backend_friendica_community.inc.php");
|
||||||
require_once (__DIR__ . "/dav_caldav_backend_friendica.inc.php");
|
require_once (__DIR__ . "/dav_caldav_backend_friendica.inc.php");
|
||||||
require_once (__DIR__ . "/virtual_cal_source_friendica.inc.php");
|
require_once (__DIR__ . "/virtual_cal_source_friendica.inc.php");
|
||||||
require_once (__DIR__ . "/wdcal_cal_source_friendicaevents.inc.php");
|
require_once (__DIR__ . "/wdcal_cal_source_friendicaevents.inc.php");
|
||||||
require_once (__DIR__ . "/FriendicaACLPlugin.inc.php");
|
require_once (__DIR__ . "/FriendicaACLPlugin.inc.php");
|
||||||
|
|
||||||
require_once (__DIR__ . "/calendar.friendica.fnk.php");
|
require_once (__DIR__ . "/calendar.friendica.fnk.php");
|
||||||
require_once (__DIR__ . "/layout.fnk.php");
|
require_once (__DIR__ . "/layout.fnk.php");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -79,7 +80,7 @@ function dav_init(&$a)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
dav_include_files();
|
dav_include_files();
|
||||||
|
|
||||||
if (false) {
|
if (false) {
|
||||||
dbg(true);
|
dbg(true);
|
||||||
error_reporting(E_ALL);
|
error_reporting(E_ALL);
|
||||||
|
@ -174,15 +175,29 @@ function dav_content()
|
||||||
return wdcal_getSettingsPage($a);
|
return wdcal_getSettingsPage($a);
|
||||||
} elseif ($a->argv[1] == "wdcal") {
|
} elseif ($a->argv[1] == "wdcal") {
|
||||||
if ($a->argc >= 3 && strlen($a->argv[2]) > 0) {
|
if ($a->argc >= 3 && strlen($a->argv[2]) > 0) {
|
||||||
$uri = $a->argv[2];
|
$uri = $a->argv[2];
|
||||||
$recurr_uri = ""; // @TODO
|
|
||||||
if (isset($a->argv[3]) && $a->argv[3] == "edit") {
|
if ($uri == "new") {
|
||||||
$o = "";
|
$o = "";
|
||||||
if (isset($_REQUEST["save"])) $o .= wdcal_postEditPage($uri, $recurr_uri);
|
if (isset($_REQUEST["save"])) {
|
||||||
$o .= wdcal_getEditPage($uri, $recurr_uri);
|
check_form_security_token_redirectOnErr($a->get_baseurl() . "/dav/wdcal/", "caledit");
|
||||||
|
$o .= wdcal_postEditPage("new", "", $a->user["uid"], $a->timezone, $a->get_baseurl() . "/dav/wdcal/");
|
||||||
|
}
|
||||||
|
$o .= wdcal_getEditPage("new");
|
||||||
return $o;
|
return $o;
|
||||||
} else {
|
} else {
|
||||||
return wdcal_getDetailPage($uri, $recurr_uri);
|
$recurr_uri = ""; // @TODO
|
||||||
|
if (isset($a->argv[3]) && $a->argv[3] == "edit") {
|
||||||
|
$o = "";
|
||||||
|
if (isset($_REQUEST["save"])) {
|
||||||
|
check_form_security_token_redirectOnErr($a->get_baseurl() . "/dav/wdcal/", "caledit");
|
||||||
|
$o .= wdcal_postEditPage($uri, $recurr_uri, $a->user["uid"], $a->timezone, $a->get_baseurl() . "/dav/wdcal/");
|
||||||
|
}
|
||||||
|
$o .= wdcal_getEditPage($uri, $recurr_uri);
|
||||||
|
return $o;
|
||||||
|
} else {
|
||||||
|
return wdcal_getDetailPage($uri, $recurr_uri);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$cals = dav_getMyCals($a->user["uid"]);
|
$cals = dav_getMyCals($a->user["uid"]);
|
||||||
|
@ -226,9 +241,9 @@ function dav_event_updated_hook(&$a, &$b)
|
||||||
function dav_profile_tabs_hook(&$a, &$b)
|
function dav_profile_tabs_hook(&$a, &$b)
|
||||||
{
|
{
|
||||||
$b["tabs"][] = array(
|
$b["tabs"][] = array(
|
||||||
"label" => t('Calendar'),
|
"label" => t('Calendar'),
|
||||||
"url" => $a->get_baseurl() . "/dav/wdcal/",
|
"url" => $a->get_baseurl() . "/dav/wdcal/",
|
||||||
"sel" => "",
|
"sel" => "",
|
||||||
"title" => t('Extended calendar with CalDAV-support'),
|
"title" => t('Extended calendar with CalDAV-support'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
v0.1.1
|
||||||
|
======
|
||||||
|
[FEATURE] A "New Event" Button in the navigation bar of the calendar is added.
|
||||||
|
[FEATURE] When creating an event by dragging in the calendar, the "Edit Details"-Link leads to a page where the details can be added before actually creating the event.
|
||||||
|
[BUGFIX] When editing a event, the start time cannot be set befor the end time anymore.
|
||||||
|
[BUGFIX] Fixed some problems with Magic Quotes
|
||||||
|
|
||||||
|
v0.1
|
||||||
|
======
|
||||||
|
Initial Release
|
|
@ -107,10 +107,11 @@ a.imgbtn span.Delete
|
||||||
background: url(./images/icons/delete.png) no-repeat 3px 4px;
|
background: url(./images/icons/delete.png) no-repeat 3px 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
span.addcal
|
a.addcal
|
||||||
{
|
{
|
||||||
padding-left:20px;
|
padding-left:20px;
|
||||||
background: url(./images/icons/date_add.png) no-repeat 1px 50%;
|
background: url(./images/icons/date_add.png) no-repeat 1px 50%;
|
||||||
|
color: black;
|
||||||
}
|
}
|
||||||
span.showdayview
|
span.showdayview
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue